Setting environment variables under z/OS UNIX
An environment variable is a name that is associated with a string of characters and that defines some variable aspect of the program environment. You use environment variables to set values that programs, including the compiler, need.
Set the environment variables for the compiler by using the export
command.
For example, to set the SYSLIB variable, issue the export
command
from the shell or from a script file:
export SYSLIB=/u/mystuff/copybooks
The value that you assign to an environment variable
can include other environment variables or the variable itself. The
values of these variables apply only when you compile from the shell
where you issue the export
command. If you do not
set an environment variable, either a default value is applied or
the variable is not defined. The environment-variable names must be
uppercase.
The environment variables that you can set for use by the compiler are as follows:
- COBOPT
- Specify compiler options separated
by blanks or commas. Separate suboptions with commas. Blanks at the
beginning or the end of the variable value are ignored. Delimit the
list of options with quotation marks if it contains blanks or characters
that are significant to the z/OS® UNIX shell.
For example:
export COBOPT="TRUNC(OPT) XREF"
COBOL_INSTALL_DIR
The
cob2
utility and related files are normally installed under the HFS directory /usr/lpp/IBM/cobol/igyv6r2. If thecob2
utility is installed somewhere else on your system, it is necessary to set theCOBOL_INSTALL_DIR
environment variable to that location in order to use the utility.- SYSLIB
- Specify paths to directories
to be used in searching for COBOL copybooks if you do not specify
an explicit library-name in the
COPY
statement. Separate multiple paths with a colon. Paths are evaluated in order from the first path to the last in theexport
command. If you set the variable with multiple files of the same name, the first located copy of the file is used.For
COPY
statements in which you have not coded an explicit library-name, the compiler searches for copybooksin z/OS UNIX directories
in this order:
- In the current directory
- In the paths
you specify with the
-I cob2
option - In the paths you specify in the SYSLIB environment variable
In the locations specified in instances of the
COPYLOC
option that use the default library name or specify an explicit library name of SYSLIB
If the copybook is not found in any of the z/OS UNIX directories to be searched, and there are instances of the
COPYLOC
option specified without an explicit library name or specified with the library name SYSLIB, those locations are searched in the order that they were specified. - library-name
- Specify the directory path from which
to copy when you specify an explicit library-name in the
COPY
statement. The environment-variable name is identical to the library-name in your program. You must set an environment variable for each library; an error will occur otherwise. The environment-variable name library-name must be uppercase. - text-name
- Specify the name of the file from which to copy text. The environment-variable name is identical to the text-name in your program. The environment-variable name text-name must be uppercase.
Specifying compiler options under z/OS UNIX
Compiling and linking with the cob2 command
Setting and accessing environment variables
Compiler-directing statements
Compiler options
COPY statement (Enterprise COBOL for z/OS Language Reference)