Creating flexible and reusable JCL through variable substitution
Symbolic parameters are variables in JCL that allow you to create flexible, reusable job streams. They act as placeholders that are replaced with actual values when the JCL is processed, making it possible to write generic procedures that can be customized for different runs.
Symbolic parameters provide several key benefits:
Symbolic parameters are identified by an ampersand (&) prefix followed by a valid JCL name (1-8 characters). For example: &SYSID
, &DATE
, &FILENAME
.
A placeholder prefixed with an ampersand (&)
Optional value that's used if no override is provided
Using the parameter elsewhere in JCL with the & prefix
Setting a value using the SET statement or procedure override
You can provide default values for parameters in procedure definitions. If no value is specified when the procedure is called, the default value is used:
12345678//MYPROC PROC DSN='SYS1.DATASET', // UNIT=SYSDA, // SPACE=(CYL,(10,5)) //STEP1 EXEC PGM=MYPROG //INPUT DD DSN=&DSN, // UNIT=&UNIT, // SPACE=&SPACE, // DISP=SHR
The SET statement explicitly assigns values to symbolic parameters. It must precede the statements that use the parameters:
1234567//MYJOB JOB (ACCT),'MY JOB',CLASS=A // SET DATE='2023/05/15' // SET REGION=EAST //STEP1 EXEC PGM=DATEPROG //SYSIN DD * PROCESS_DATE=&DATE REGION=®ION /*
The SET statement must begin in column 3 (with the '//' in columns 1-2), and the assignment is in the form SET parameter=value.
Parameters are substituted before JCL execution. The substitution follows these rules:
Original JCL with Parameters:
1234// SET SYSID=PROD //STEP1 EXEC PGM=REPORT //SYSOUT DD SYSOUT=* //INPUT DD DSN=&SYSID..DATA,DISP=SHR
After Substitution:
123//STEP1 EXEC PGM=REPORT //SYSOUT DD SYSOUT=* //INPUT DD DSN=PROD.DATA,DISP=SHR
Notice the double period in &SYSID..DATA
. The first period ends the parameter name, and the second is kept as a literal period in the substitution.
Original JCL with Quoted Parameter:
12345// SET MSG='HELLO WORLD' //STEP1 EXEC PGM=MSGPROG //SYSIN DD * MESSAGE=&MSG /*
After Substitution:
1234//STEP1 EXEC PGM=MSGPROG //SYSIN DD * MESSAGE=HELLO WORLD /*
Note that quotes used in the SET statement are not included in the substituted value. They only serve to delimit the value, especially when it contains spaces.
12345678//MYPROC PROC ENV='TEST',REGION=4M,CLASS=A //STEP1 EXEC PGM=MYPROG,REGION=®ION //SYSOUT DD SYSOUT=&CLASS //INPUT DD DSN=&ENV..MASTER.FILE,DISP=SHR //OUTPUT DD DSN=&ENV..OUTPUT.FILE, // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(10,5)) // PEND
123//RUNJOB JOB (ACCT),'PRODUCTION RUN',CLASS=A //RUNPROC EXEC MYPROC,ENV='PROD',CLASS=X /*
In this example, the job overrides the ENV parameter with 'PROD' and the CLASS parameter with 'X', but uses the default REGION value.
Important: Parameters must be defined in the PROC statement to be overridden when calling the procedure. The EXEC statement overrides follow a specific format: parameter-name=value
without the ampersand.
JCL supports both symbolic parameters and system symbols. While they use similar syntax, they serve different purposes:
Common system symbols include:
&SYSUID
- User ID&SYSDATE
- Current date&SYSTIME
- Current time&SYSNAME
- System name&SYSPLEX
- Sysplex name1234//MYJOB JOB (ACCT),'&SYSUID JOB',CLASS=A //STEP1 EXEC PGM=REPORT //OUTPUT DD DSN=&SYSUID..REPORT.&SYSDATE, // DISP=(NEW,CATLG,DELETE)
This example creates a dataset name that includes the user ID and current date, providing unique dataset names for each run.
12345678910111213//MYPROC PROC TYPE='FULL' //******************************************** //* IF TYPE=FULL, RUN ALL STEPS //* IF TYPE=INCR, SKIP STEP2 //******************************************** //STEP1 EXEC PGM=PROG1 //... //STEP2 EXEC PGM=PROG2, // COND=(0,NE,STEP1,(&TYPE='INCR')) //... //STEP3 EXEC PGM=PROG3 //... // PEND
In this example, STEP2 will be skipped if the TYPE parameter is set to 'INCR' and STEP1 completes successfully.
For complex concatenation, ensure proper parameter termination:
123// SET PREFIX=MY // SET SUFFIX=DATA //INPUT DD DSN=&PREFIX..&SUFFIX..FILE,DISP=SHR
After substitution: DSN=MY.DATA.FILE
123// SET VER=2 // SET PGMNAME=PROGRAM&VER //STEP1 EXEC PGM=&PGMNAME
After substitution: PGM=PROGRAM2
Always use sensible defaults that will work in most cases, making it optional to override parameters.
Include comments that explain each parameter's purpose, allowed values, and impact on job execution.
Develop and follow organizational standards for parameter names to improve maintainability.
When possible, include validation steps that check parameter values before using them in critical operations.
Avoid deep nesting or chaining of parameters that make JCL difficult to understand and debug.
Use MSGLEVEL=(1,1) to review the JCL after substitution and verify parameters are resolved as expected.
Create a reusable JCL procedure for backing up datasets using symbolic parameters. The procedure should:
Consider how you would:
Try writing the JCL yourself, then compare with a sample solution in a future lesson.
1. What is the primary purpose of Symbolic Parameters in JCL?
2. How are symbolic parameters defined in JCL?
3. Which statement is used to assign values to symbolic parameters?
4. In which parts of JCL can symbolic parameters be used?
5. What happens if a symbolic parameter is referenced but not assigned a value?