Several statements help you to direct the compilation of your program.
These are the compiler-directing statements:
COPY statement syntax >>-COPY-+-text-name-+-+--------------------------+--------------> '-literal-1-' '-+-OF-+--+-library-name-+-' '-IN-' '-literal-2----' >--+----------+--+-----------------------------------------+--->< '-SUPPRESS-' | .--------------------------. | | V | | '-REPLACING----operand-1--BY--operand-2-+-'
This library statement places prewritten text into a COBOL program. A user-defined word can be the same as a text-name or a library-name. The uniqueness of text-name and library-name is determined after the formation and conversion rules for a system-dependent name have been applied. If library-name is omitted, SYSLIB is assumed.
When compiling with JCL:
text-name, library-name, and literal are processed as follows:
For example:
COPY INVOICES1Q COPY "Company-#Employees" IN Personellib
In the IN/OF phrase, library-name is the ddname that identifies the partitioned data set to be copied from. Use a DD statement such as in the following example to define library-name:
//COPYLIB DD DSNAME=ABC.COB,VOLUME=SER=111111, // DISP=SHR,UNIT=3380
To specify more than one copy library, use either JCL or a combination of JCL and the IN/OF phrase. Using just JCL, concatenate data sets on your DD statement for SYSLIB. Alternatively, define multiple DD statements and include the IN/OF phrase on your COPY statements.
The maximum block size for the copy library depends on the device on which your data set resides.
When compiling in the z/OS UNIX shell:
When you compile with the cob2 command, copybooks are included from the HFS. text-name, library-name, and literal are processed as follows:
COPY "MyInc" COPY "x/MyInc" COPY "/u/user1/MyInc"
If an environment variable of that name is not defined, the copybook is searched for as the following names, in this order:
export MYCOPY=mystuff/today.cpy export MYLIB=/u/user1
These settings result in:
/u/user1/mystuff/today.cpy
When library-name is an environment variable that identifies the path from which copybooks are to be copied, use an export command such as the following example to define library-name:
export COPYLIB=/u/mystuff/copybooks
The name of the environment variable must be uppercase. To specify more than one copy library, set the environment variable to multiple path names delimited by colon (:).
When library-name is omitted and text-name is not an absolute path name, the copybook is searched for in this order:
related tasks
Changing the header of a source listing
Specifying compiler options under z/OS
Specifying compiler options under UNIX
Setting environment variables under UNIX
Eliminating repetitive coding
related references
cob2 syntax and options
COPY statement (Enterprise COBOL Language Reference)