Defining and nullifying JCL symbols
When you code JCL symbols, you must define or nullify them in your JCL each time a job runs; otherwise, the system does not substitute text for JCL symbols.
The maximum length of any substitution text that you can assign to a JCL symbol is 255 characters.
- The EXEC statement that calls procedures: Use the EXEC
statement to define substitution texts on statements in the called
procedures. The substitution texts you assign override the default
substitution texts assigned on the PROC statement. For example:
//STEP1 EXEC PROC=SEARCH,PARM1='MYDS1.PGM'
The system uses a JCL symbol defined on the EXEC statement for any procedures that it invokes. A JCL symbol defined on an EXEC statement is not in effect for subsequent job steps in the same level of procedure nesting. See Using symbols in nested procedures for more information.
If you specify duplicate JCL symbols on an EXEC statement, the system uses the first substitution text as the default.
- The PROC statement that begins a procedure: The PROC statement
must begin in-stream procedures and can begin cataloged procedures.
Use the PROC statement to define default substitution texts for JCL symbols in the
procedure (you can override the defaults on the EXEC statement).
If you do not define or nullify the substitution text for a JCL symbol on the EXEC
statement, the system uses the default substitution text. For example:
//PROC1 PROC PARM2=OLD,PARM3=111222
If you specify duplicate JCL symbols on a PROC statement, the system uses the first substitution text as the default.
Assign only one substitution text to each JCL symbol used in a procedure.
- The SET statement that defines and nullifies: JCL symbols Code
the SET statement in the JCL before the first use of the JCL symbol. Use the
SET statement to define JCL symbols that are
used on:
- JCL statements in the JCL stream
- Statements in a procedure (when the EXEC statement that calls the procedure and the PROC statement for the procedure do not also define JCL symbols).
For example://LEVEL1 SET PARM2=NEW,PARM3=DELETE
If you define duplicate JCL symbols on a SET statement, the system assigns the last substitution text to the JCL symbol.
Note: The substitution text specified on the SET statement is assigned to the JCL symbol regardless of the logic of the construct. This is because the SET statement is not executed conditionally (such as in the THEN and ELSE clauses of an IF/THEN/ELSE/ENDIF statement construct).
- All JCL symbols for which values are defined must be coded in the JCL.
- All JCL symbols coded in the JCL must have defined values.
JCL_symbol_name=substitution_text
- Define a substitution text that is 1-255 characters long.
- Enclose within apostrophes substitution texts that do not fit on a single line. Continue values that do not fit on a single line as described in Continuing JCL statements that contain symbols.
- Do not specify the ampersand that identifies the JCL symbol in the procedure.
- Define JCL symbols on EXEC, PROC, or SET statements, as described in Defining and nullifying JCL symbols. For example, if the JCL symbol &NUMBER
appears on one or more DD statements in a procedure, and you want
to substitute the text 3390 for &NUMBER, code one or more
of the following:
//SET1 SET NUMBER=3390 //STEP1 EXEC PROC=PROC1,NUMBER=3390 //PROC1 PROC NUMBER=3390
- Do not specify JCL symbols within other JCL symbols. The results can be unpredictable, especially if the imbedded JCL symbol is not previously defined.
Defining names for JCL symbols: IBM recommends that your installation define standard names for frequently used JCL symbols and enforce the use of those names. For example, if your installation frequently assigns department numbers in procedures, define the &DEPT JCL symbol and use it consistently. If your installation plans to provide a standard set of JCL symbols, ensure that all system and application programmers know about those JCL symbols.
You can define names for JCL symbols that are the same as system symbol names. When a JCL symbol has the same name as a system symbol, the substitution text for the JCL symbol overrides the substitution text for the system symbol. For example, if JCL defines a symbol with the name &SYSNAME, which is also the name of a system symbol, the system uses the substitution text that is defined in the JCL.
Defining default substitution texts to JCL symbols: The substitution texts that you define to JCL symbols on the PROC statement serve as defaults. You should assign default values to all JCL symbols in a procedure. The system uses the default values on the PROC statement when no calling EXEC statement or SET statement overrides them.
Using special characters in substitution texts: If a substitution text contains certain special characters, enclose the substitution text in apostrophes (for example, LOC='O''HARE'). The enclosing apostrophes are not considered to be part of the substitution text. See Table 2 for a list of special characters.
If the substitution text contains multiple ampersands and is not enclosed in apostrophes, the system treats each pair of ampersands as a single character.
// SET LOC='O''''HARE'
//S1 EXEC PGM=IEFBR14,PARM='&LOC'
//S1 EXEC PGM=IEFBR14,PARM='O''HARE'
// SET LOC='O''HARE'
//S1 EXEC PGM=IEFBR14,PARM='&LOC'
//S1 EXEC PGM=IEFBR14,PARM='O'HARE'
The system fails this statement because the apostrophes resulting from the substitution are unbalanced.
//JOB1 EXEC PROC1
//PROC1 PROC WORK='''1000,500'''
//STEP1 EXEC PROC2,WORK=&WORK
//STEP1 EXEC PROC2,WORK='1000,500'
//TPROC PROC DISP=(NEW,PASS)
If the substitution text within the parentheses contains apostrophes, the apostrophes are considered part of the substitution text. The system does not remove them.
JCL_symbol_name=
- Do not code the ampersand that identifies the JCL symbol in the procedure.
- Do not code a substitution text after the equal sign.
- Do not code literal blanks (for example, VALUE=' ').
//SET2 SET NUMBER=
//CALLER EXEC PROC=ABC,NUMBER=,ACCT=DID58
//ABC PROC NUMBER=,LOC=POK
- When you nullify a JCL symbol, delimiters, such as leading or trailing commas, are not nullified. In some cases, the remaining comma is required; in others it causes a syntax error.
- Do not nullify JCL symbols that appear on JCL keywords that do not accept NULL values. The syntax descriptions of the individual keywords specify whether the keywords allow NULL values.
- If you use an EXEC statement to nullify a JCL symbol, and a PROC statement specifies a default substitution text for the JCL symbol, the JCL symbol is nullified.
The following sections explain special considerations to make when JCL symbols are positional and not positional.
UNIT=(3390,&NUMBER,DEFER)
UNIT=(3390,,DEFER)
VOLUME=SER=(&FIRST&SECOND)
VOLUME=SER=(222222)
VOLUME=SER=(111111)
//CALLER EXEC PROC=ABC,FIRST=111111,SECOND=',222222'