DEFINE

Use the DEFINE compiler option to assign a literal value to a compilation variable that is defined in the program by using the DEFINE directive with the PARAMETER phrase. The literal value provided for the compilation variable in the DEFINE option is sometimes referred to as a "parameter value" for the corresponding compilation variable. Compilation variables can be used within any of the conditional compilation directives, including DEFINE, EVALUATE, and IF. When a conditional compilation variable appears in a conditional compilation directive, it is treated as a symbolic reference to the literal value it currently represents.

The DEFINE compiler option provides a way for you to assign values to compilation variables from outside the program source. If that is not needed, it is sufficient to use the DEFINE directive within program source to define compilation variables.

DEFINE option syntax

Read syntax diagramSkip visual syntax diagramNODEFINEDEFINE( compilation-variable-name-1=,1literal-1)
Notes:
  • 1 You cannot use "=" if you are invoking the COBOL compiler from the z/OS® UNIX shell via the cob2 command.

Default is: NODEFINE

Abbreviations are: DEF | NODEF

compilation-variable-name-1
The name of a compilation variable to be referenced in conditional compilation directives in the program. If no corresponding DEFINE directive with PARAMETER phrase exists for compilation-variable-name-1 in the program, any instances of the DEFINE compiler option specified for that compilation variable are ignored. compilation-variable-name-1 is formed according to the rules of a data-name user-defined word, except that DBCS characters are not allowed in the name. For details, see User-defined words in the Enterprise COBOL for z/OS Language Reference.
literal-1
The literal value that compilation-variable-name-1 will represent symbolically in conditional compilation-related directives in the program. literal-1 must be one of the following items:
  • An alphanumeric literal, which can be specified as a regular alphanumeric literal ('abcd') or as a hex literal (x'F1F2F3'). National literals, UTF-8 literals, DBCS literals, and null-terminated alphanumeric literals (Z literals) are not supported.
  • An integer literal.
  • A boolean literal (only B'0' and B'1' are supported).
If literal-1 is not specified, a value of B'1' will be assigned to the compilation variable. For example, if you specify:
DEFINE(foo)
foo will be assigned the value B'1'.

Multiple instances of the DEFINE option can be specified to define a value for multiple different compilation variables. If a single conditional compilation variable is defined more than once, the last definition of the variable will be used as the value of the corresponding conditional compilation variable. If NODEFINE appears after previous instances of the DEFINE option, the definitions for all conditional compilation variables are canceled.

When DEFINE options are specified in CBL statements, they can be used only on the first program of a batch program. Therefore, if a file has multiple COBOL programs in it, there can be CBL statements with DEFINE options preceding the first program, but not the other programs. The DEFINE options specified for the first program (and DEFINE options specified in PARM of JCL or DEFINE options specified as cob2 command options under z/OS UNIX) apply to all programs in a file.

Related references  
Conditional compilation (Enterprise COBOL for z/OS Language Reference)  
DEFINE (Enterprise COBOL for z/OS Language Reference)