Symbolic substitution delimiters, primarily the ampersand (&) character, are used in JCL to identify variables and parameters that will be replaced with actual values during job processing. This mechanism enables dynamic content in JCL, making jobs more flexible and reusable.
Key Benefit:
The ampersand delimiter creates standardized, parameterized JCL that can adapt to different environments, process varying inputs, and reduce maintenance overhead by centralizing common values as variables.
The ampersand (&) symbol in JCL serves several important roles:
Symbolic parameters in JCL procedures follow this basic pattern:
1234//PROC1 PROC PARAM1=DEFAULT1,PARAM2=DEFAULT2 //STEP1 EXEC PGM=PROGRAM1,PARM='&PARAM1' //DDNAME DD DSN=PREFIX.&PARAM2.SUFFIX, // DISP=SHR
Substitution occurs at different times depending on the type of symbolic reference:
Symbolic Type | Substitution Timing | Example |
---|---|---|
Procedure Parameters | When procedure is called from JCL | &PARAM in a PROC substituted when called with PROC=PROCNAME,PARAM=value |
System Symbols | At converter processing time | &SYSUID substituted with user ID |
JCL Variables (SET) | During JCL processing in execution order | &VAR defined with SET VAR=value |
EXPORT Statements | Available to subsequent jobs in session | &EXPVAR made available with EXPORT SYMLIST=(EXPVAR) |
12345678910//MYPROC PROC DSN=PROD.MASTER, // VOL=PROD01, // SPACE=(CYL,(10,5)) //STEP1 EXEC PGM=MYPGM //INPUT DD DSN=&DSN, // DISP=SHR, // VOL=SER=&VOL //OUTPUT DD DSN=&DSN..BACKUP, // DISP=(NEW,CATLG,DELETE), // SPACE=&SPACE
This procedure defines parameters with default values that can be overridden when the procedure is called:
1//STEP1 EXEC MYPROC,DSN=TEST.MASTER,VOL=TEST01
12345//STEP1 EXEC PGM=MYPGM //SYSOUT DD SYSOUT=* //OUTPUT DD DSN=&SYSUID..REPORT.&SYSDATE, // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(1,1))
This example uses system symbols for the user ID and current date to create a unique dataset name.
12345678910111213//STEP1 EXEC PGM=MYPGM // SET PREFIX=PROD // SET SUFFIX=DATA //INPUT DD DSN=&PREFIX..&SUFFIX, // DISP=SHR //* // IF (STEP1.RC = 0) THEN // SET STATUS=SUCCESS // ELSE // SET STATUS=FAILURE // ENDIF //* //STEP2 EXEC PGM=REPORTER,PARM='&STATUS'
This example uses SET statements to create variables for dataset names and for dynamic decision-making based on a return code.
123456//STEP1 EXEC PGM=MYPGM // SET ENV=PROD // SET PRODDSN=PRODUCTION.MASTER // SET TESTDSN=TEST.MASTER //INPUT DD DSN=&&&ENV.DSN, // DISP=SHR
This example demonstrates nested substitution. If ENV=PROD, &&PRODDSN becomes &PRODDSN which becomes PRODUCTION.MASTER.
Note on Nested Substitution:
When using nested substitution with multiple ampersands, the number of ampersands determines the level of indirection:
The period is used to terminate a symbolic parameter name when it would otherwise be ambiguous:
1//DD1 DD DSN=PREFIX.&PARAM.SUFFIX
Without the period after &PARAM, the system would look for a symbol named PARAMSUFFIX.
If the period itself should be part of the value, you can use different approaches:
12// SET MYVAL=ABC.DEF //DD1 DD DSN=&MYVAL
To include a literal ampersand in JCL (not for substitution), double the ampersand:
1//STEP1 EXEC PGM=MYPGM,PARM='A&&B'
This passes the literal string 'A&B' to the program.
If a symbolic parameter resolves to a null value, different behaviors can occur:
123//PROC1 PROC PARAM1= //STEP1 EXEC PGM=PROGRAM1 //DD1 DD DSN=PREFIX.&PARAM1.SUFFIX,DISP=SHR
In the example, the dataset name becomes PREFIX.SUFFIX when PARAM1 is null.
Symbol | Description | Example Value |
---|---|---|
&SYSUID | User ID of the submitter | JOHNDOE |
&SYSDATE | Current date (format yyyyddd) | 2023142 |
&SYSTIME | Current time (format hhmmss) | 143022 |
&SYSNAME | System name | SYSA |
&SYSPLEX | Sysplex name | PLEX1 |
&SYSSMFID | SMF ID | SYS1 |
&SYSJES | JES level (2 or 3) | 2 |
&SYSJOBID | Job identifier | JOB12345 |
The SYMLIST parameter controls which symbols are eligible for substitution:
1234//STEP1 EXEC PGM=IEBUPDTE //SYSIN DD *,SYMLIST=(SYS) &SYSUID..DATA /*
This example allows only system symbols to be substituted in the SYSIN data. Options include:
The SYMBOLS parameter on the JOB statement controls substitution for the entire job:
12//MYJOB JOB (ACCT),'NAME',SYMBOLS=JCLONLY //STEP1 EXEC PGM=MYPGM
Options include:
Issue | Possible Causes | Solutions |
---|---|---|
Unresolved symbols | Symbol not defined or scope issues |
|
Incorrect concatenation | Missing period delimiter |
|
Literal & not displayed | Single & treated as start of a symbol |
|
Nested substitution failure | Incorrect number of ampersands or order of operations |
|
Unexpected substitution | Symbol resolved at unintended time |
|
Symbolic substitution behavior is generally the same in both JES2 and JES3 environments, but there are some considerations:
Feature | JES2 | JES3 |
---|---|---|
Basic symbol handling | Standard implementation | Standard implementation |
JES-specific symbols | Some JES2-specific symbols available | Some JES3-specific symbols available |
Control statements | Standard JCL symbol processing | Additional symbol options in JES3 control statements |