Variable substitution within JCL
JCL within a JCL GEN... ENDJCL block may contain a mix of literal JCL text and variables. This section discusses rules that govern variable use and substitution in JCL statements.
JCL statements that are to be prepared for submission are defined with the JCL GEN... ENDJCL block. All coding lines between JCL GEN and ENDJCL statements are considered to be input JCL.
The following rules govern processing:
- Each statement between the JCL GEN block and the ENDJCL block represents one JCL statement.
- The statement may be JCL, comments, or in-stream data statements.
- JCL syntax checking is not performed.
- JCL is processed as it appears in the statement with column positions honored. Normal JCL statements must start in column 1.
JCL is case sensitive. Uppercase text translation is not performed. Variable names may be entered in mixed case (uppercase and lowercase) text and are resolved correctly. However, fixed data text remains in the case in which it was entered.
Text values that are inserted by means of a substitution variable are not translated into uppercase text. Variable contents must be in the correct uppercase or lowercase format.
- Variable substitution is performed according to the following rules:
Only simple variables may be used within JCL statements. Recursive variables and array variables are not supported, as they complicate JCL coding because of data shuffling and variable delimiter issues.
This limitation is overcome by adjusting the JCL script to assign recursive or array variable values to a simple variable immediately preceding the JCL script statement.
- An ampersand (&) must prefix all variable names.
- The presence of two ampersands (&&) causes variable substitution to be ignored. You can specify temporary data set names into your JCL.
- The presence of an ampersand-space (as in CAT & DOG) causes variable substitution to be ignored, as no variable name is supplied.
Where JCL requires a textual value preceded by a single ampersand (&) without substitution (as in check &LASTCC), this requirement can be achieved by assigning the textual value to a variable with the LET script statement and then inserting the variable into the JCL text:
LET TEXT = '&LASTCC'
JCL GENTo determine whether the SEARCH works, check &TEXT.:
ENDJCL- The use of special characters, a blank, or a period delimits the variable name.
- When a special character delimiter is used--for example (or)--the variable value is inserted and the special character is included as part of the text.
- When a blank character is used to delimit the variable name, the variable value is inserted followed by a blank character. Data to the right of the delimiting blank is shuffled left or right to preserve one blank character.
When multiple blanks delimit the variable, any data to the right of the variable remains in its columnar position. Shuffling data left does not occur.
If insufficient room exists to insert the variable value and honor trailing data to the right of the variable, the trailing data is shuffled right with one interleaving blank preserved.
- When a period (.) delimits the variable, the variable value is inserted and the period is removed from the text. To retain a period in the text, you need to specify the variable name, followed by a delimiting period, followed by a period for the normal text.
- If the inserted data causes an overflow beyond column 72, data truncation occurs. No error conditions or messages are issued.
- The variable values are substituted at the time the JCL GEN... ENDJCL statements are processed. The values used equate the variable value setting at the time of the JCL statement.
- The value of the substitution variable is inserted without case translation. If the variable is assigned lowercase text values, the resultant JCL contains lowercase text.
- Constructed JCL statements are added to a concatenated list of JCL. Multiple sets of JCL GEN... ENDJCL may be executed to build a sequence of JCL.