Coding variables in JCL

A variable, either user-defined or supplied by IBM Z Workload Scheduler, consists of up to 8 alphanumeric characters, the first of which must be alphabetic. When using a variable in a job, precede it with an ampersand (&), a percent sign (%), or a question mark (?). The symbol preceding the variable determines how IBM Z Workload Scheduler carries out the variable substitution. A period can denote the end of a variable name. You can use a variable repeatedly within the job using different prefix symbols.

Table 1. Symbols that mark the end of variables
Symbol Description
, Comma
/ Forward slash
' Single quotation mark
( Left parenthesis
) Right parenthesis
* Asterisk
& Ampersand
&& Double ampersand
% Percent sign
+ Plus sign
- Dash
= Equals sign
  Blank ( )
Blank
? Question mark

To maintain compatibility with variable substitution within z/OSĀ® JCL procedures, IBM Z Workload Scheduler will assume that a variable has ended (even if the completing period is missing) if the variable is followed by one of the symbols listed in Table 1. An ampersand or percent variable can be assigned a value that is itself a variable.

For example, if LIBRARY is given the value LINKLIB for the following statement:

//STEPLIB DD DSN=MY.&LIBRARY.(IEFBR14),DISP=SHR

or the following statement (without the completing period):

//STEPLIB DD DSN=MY.&LIBRARY(IEFBR14),DISP=SHR

The JCL line becomes as follows:

//STEPLIB DD DSN=MY.LINKLIB(IEFBR14),DISP=SHR

The product assumes that the variable LIBRARY ends when it detects the left parenthesis '('.

Note: The completing period is discarded when a variable is substituted. Other termination symbols are left in place.
Note: When coding JCL, do not insert all the messages that IBM Z Workload Scheduler uses during the variable substitution process (that is, VARIABLE SUBSTITUTION FAILED with OPCSMSG at column 73).