Several compiler-directing statements and one compiler directive help you to direct the compilation of your program.
These are the compiler-directing statements and directive:
>>CALLINTERFACE can be used only in the PROCEDURE DIVISION.
The syntax and usage of the >>CALLINTERFACE directive are similar to that of the CALLINT compiler option. Exceptions are:
If you specify >>CALLINT with no suboptions, the call convention used is determined by the CALLINT compiler option.
DESCRIPTOR only: The >>CALLINT directive is treated as a comment except for these forms:
These directives turn DESCRIPTOR on or off; SYSTEM is ignored.
If you code OPTLINK or CDECL (valid COBOL for Windows values) instead of SYSTEM, the compiler generates an I-level diagnostic, and the entire directive (not just the first keyword) is ignored.
The >>CALLINT directive can be specified anywhere that a COBOL procedure statement can be specified. For example, this is valid syntax:
MOVE 3 TO >>CALLINTERFACE SYSTEM RETURN-CODE.
The effect of >>CALLINT is limited to the current program. A nested program or a program compiled in the same batch inherits the calling convention specified in the CALLINT compiler option, but not a convention specified by the >>CALLINT compiler directive.
If you are writing a routine that is to be called with >>CALLINT SYSTEM DESCRIPTOR, this is the argument-passing mechanism:
COPY statement syntax >>-COPY-+-text-name-+-+--------------------------+--------------> '-literal-1-' '-+-OF-+--+-library-name-+-' '-IN-' '-literal-2----' >--+----------+--+-----------------------------------------+--->< '-SUPPRESS-' | .--------------------------. | | V | | '-REPLACING----operand-1--BY--operand-2-+-'
This compiler-directing statement places prewritten text into a COBOL program.
Neither text-name nor library-name need to be unique within a program. They can be identical to other user-defined words in the program.
You must specify a text-name (the name of a copybook) that contains the prewritten text; for example, COPY my-text. You can qualify text-name with a library-name; for example, COPY my-text of inventory-lib. If text-name is not qualified, a library-name of SYSLIB is assumed.
library-name
If you specify library-name as a literal, the content of the literal is treated as the actual path. If you specify library-name as a user-defined word, the name is used as an environment variable and the value of the environment variable is used for the path to locate the copybook. To specify multiple path names, delimit them with a colon (:).
If you do not specify library-name, the path used is as described under text-name.
text-name
If you specify text-name as a literal, the content of the literal is treated as the actual path. If you specify text-name as a user-defined word, processing depends on whether the environment variable that corresponds to text-name is set. If the environment variable is set, the value of the environment variable is used as the file name, and possibly the path name, for the copybook.
A text-name is treated as an absolute path if all three of these conditions are met:
For example, this is treated as an absolute path:
COPY "/mycpylib/mytext.cpy"
If the environment variable that corresponds to text-name is not set, the search for the copybook uses the following names:
For example, COPY MyCopy searches in the following order:
COBOL defaults library-name and text-name to uppercase unless the name is contained in a literal ("MyCopy"). In this example, MyCopy is not the same as MYCOPY. If your file name is mixed case (as in MyCopy.cbl), define text-name as a literal in the COPY statement.
-I option
For other cases (when neither a library-name nor text-name indicates the path), the search path is dependent on the -I option.
To have COPY A be equivalent to COPY A OF MYLIB, specify -I$MYLIB.
Based on the above rules, COPY "/X/Y" will be searched in the root directory, and COPY "X/Y" will be searched in the current directory.
COPY A OF SYSLIB is equivalent to COPY A. The -I option does not affect COPY statements that have explicit library-name qualifications besides those with the library name of SYSLIB.
If both library-name and text-name are specified, the compiler inserts a path separator (/) between the two values if library-name does not end in /. For example, COPY MYCOPY OF MYLIB with these settings:
export MYCOPY=MYPDS(MYMEMBER) export MYLIB=MYFILE
results in MYFILE/MYPDS(MYMEMBER).
If you specify text-name as a user-defined word, you can access local files and also access PDS members on z/OS without changing your mainframe source. For example:
COPY mycopybook
In this example, if the environment variable mycopybook is set to h/mypds(mycopy):
You can access z/OS files from AIX using NFS (Network File System), which let you access z/OS files by using an AIX path name. However, note that NFS converts the path separator to "." to follow z/OS naming conventions. To ensure proper name formation, keep this in mind when assigning values to your environment variables. For example, these settings:
export MYCOPY=(MYMEMBER) export MYLIB=M/MYFILE/MYPDS
do not work because the resulting path is:
M/MYFILE/MYPDS/(MYMEMBER)
which after conversion of the path separator becomes:
M.MYFILE.MYPDS.(MYMEMBER)
related tasks
Changing the header of a source listing
Compiling from the command line
Specifying compiler options in the PROCESS (CBL) statement
related references
cob2, cob2_j, and cob2_r options
CALLINTERFACE directive (COBOL for AIX Language Reference)
CBL (PROCESS) statement (COBOL for AIX Language Reference)
*CONTROL (*CBL) statement (COBOL for AIX Language Reference)
COPY statement (COBOL for AIX Language Reference)