By default, the Compiler looks for copybooks in the same directory as the program using them. If your copybooks are elsewhere, you need to define their location.
You can define the location of your copybooks outside the project directory by specifying the copybook paths in project properties on the
Copybook Paths tab,
by adding copybook projects as project dependencies on the properties
Projects tab, by adding them to the project as linked files or folders,
or by setting the environment variable COBCPY.
Tip: Linked resources are an Eclipse concept and are supported for COBOL projects, but Micro Focus recommends you use project dependencies where possible, and create projects to contain the resources and define an appropriate dependency between them.
You can choose the order in which to search these copybook locations by clicking
Project > Properties > Micro Focus > Build Configurations > Build Path >
Copybook Paths and arranging the folders into the required order.
Tip: In order to increase the speed of indexing and background parsing, we recommend you deselect paths that don't contain copybooks.
Each COPY statement in your program identifies a copybook to be copied. If the filename in the COPY statement is incomplete, because it lacks either an extension or a path, the Compiler searches for it as follows:
- In the paths specified in the
Copybook Paths list in the project properties.
If you have included any copybook projects as project dependencies, they are included in this list.
- In the directory given by the COPY
library-name. Note that if the name of the copybook is a qualified filename, that is, it includes the path or directory, the Compiler searches that directory only.
- In the directory containing the main source program being compiled.
- In any directories listed in the COBCPY environment variable, in the order specified.
If the COPY statement does not give the extension of the copybook's filename, the Compiler searches for files with extensions given by the directive COPYEXT.