JCL Overrides via SET statements provide a powerful mechanism for dynamically modifying job execution parameters without altering the core JCL. This enables flexible job execution across different environments, scenarios, or runtime conditions, while maintaining a single source JCL.
Key Benefit:
Using SET statement overrides significantly reduces JCL maintenance by allowing a single JCL stream to be parameterized and reused across different environments or with different processing options, eliminating the need for multiple near-duplicate job variants.
The SET statement assigns values to symbolic parameters that can be referenced elsewhere in the JCL:
12345678//SET1 SET SYSID='PROD', // VOLSER=PROD01, // SPACE=(CYL,(100,50)) //STEP1 EXEC PGM=IEBGENER //SYSUT2 DD DSN=&SYSID..MASTER.FILE, // VOL=SER=&VOLSER, // SPACE=&SPACE
In this example, symbolic parameters SYSID, VOLSER, and SPACE are defined using a SET statement and then referenced in subsequent JCL.
Several mechanisms provide context for SET statement overrides:
Override Mechanism | Description | Scope |
---|---|---|
Multiple SET Statements | Later SET statements override earlier ones for the same parameter | From point of definition forward until next override |
Conditional SET (IF/THEN) | SET statements within IF/THEN/ELSE structures | Executed only when conditions are met |
PROC Parameter Overrides | Values specified when invoking a procedure | Limited to the procedure's execution |
JOB Statement EXEC Overrides | Parameters specified directly on EXEC statement | Override stored procedure values for that execution |
System Symbols | System-defined symbols referenced in SET statements | Job-wide, with values provided by the system |
When multiple SET statements assign values to the same symbolic parameter, the most recent definition applies:
1234567891011//SET1 SET ENV='DEV', // SPACE=(CYL,(10,5)) //* //STEP1 EXEC PGM=MYPGM //DD1 DD DSN=&ENV..FILE1,SPACE=&SPACE //* //SET2 SET ENV='TEST', // SPACE=(CYL,(20,10)) //* //STEP2 EXEC PGM=MYPGM //DD2 DD DSN=&ENV..FILE2,SPACE=&SPACE
In this example, STEP1 uses ENV='DEV' and SPACE=(CYL,(10,5)), while STEP2 uses the overridden values ENV='TEST' and SPACE=(CYL,(20,10)).
SET statements can be conditionally executed using IF/THEN/ELSE structures:
123456789// SET DAY=&SYSDATE //* // IF DAY='FRIDAY' THEN // SET BACKUP=FULL // ELSE // SET BACKUP=INCREMENTAL // ENDIF //* //STEP1 EXEC PGM=BACKUP,PARM='&BACKUP'
This example sets BACKUP='FULL' on Fridays and BACKUP='INCREMENTAL' on other days, controlling the backup type.
1234567891011121314151617// SET SYSID=&SYSNAME //* // IF SYSID='SYSA' THEN // SET ENV='PROD' // SET VOLSER=PROD01 // ELSE // IF SYSID='SYSB' THEN // SET ENV='TEST' // SET VOLSER=TEST01 // ELSE // SET ENV='DEV' // SET VOLSER=DEV01 // ENDIF // ENDIF //* //STEP1 EXEC PGM=MYPGM //DD1 DD DSN=&ENV..MASTER,VOL=SER=&VOLSER
This example uses nested IF/THEN/ELSE logic to set environment-specific parameters based on the system name.
Parameters defined in procedures can be overridden when the procedure is invoked:
12345678910//MYPROC PROC ENV='DEV', // SPACE=(CYL,(10,5)) //* //STEP1 EXEC PGM=MYPGM //DD1 DD DSN=&ENV..FILE1,SPACE=&SPACE //* End of procedure //* //* Main JCL that executes the procedure //MYJOB JOB (ACCT),'MY JOB',CLASS=A //STEP1 EXEC MYPROC,ENV='PROD',SPACE=(CYL,(50,20))
In this example, the procedure MYPROC defines default values, but the EXEC statement overrides them with ENV='PROD' and SPACE=(CYL,(50,20)).
System symbols can be used in SET statements to create dynamic overrides based on system characteristics:
1234567891011// SET SYSID=&SYSNAME(1:4) // SET DATE=&LYYMMDD // SET ENV='PROD' //* // IF SYSID='SYS1' THEN // SET ENV='DEV' // ENDIF //* //STEP1 EXEC PGM=MYPGM //DD1 DD DSN=&ENV..MASTER.&DATE, // DISP=(NEW,CATLG,DELETE)
This example uses system symbols &SYSNAME and &LYYMMDD to create dynamic values for dataset naming.
Symbol | Description | Example Value |
---|---|---|
&SYSNAME | System name | SYSA |
&SYSPLEX | Sysplex name | PLEXPR |
&SYSDATE | Current date (Julian format) | 23180 (June 29, 2023) |
&LYYMMDD | Local date in YYMMDD format | 230629 |
&SYSSYMR | Symbolic substitution characters | & and . |
12345678910111213141516171819202122232425// SET SYSID=&SYSNAME //* // IF SYSID='PRODA' | SYSID='PRODB' THEN // SET ENV='PROD' // SET HLQUAL='PROD' // SET SPACE=(CYL,(100,50)) // SET UNIT=SYSDA // ELSE // IF SYSID='TESTA' | SYSID='TESTB' THEN // SET ENV='TEST' // SET HLQUAL='TEST' // SET SPACE=(CYL,(50,20)) // SET UNIT=SYSDA // ELSE // SET ENV='DEV' // SET HLQUAL='DEV' // SET SPACE=(CYL,(10,5)) // SET UNIT=VIO // ENDIF // ENDIF //* //STEP1 EXEC PGM=MYPGM //DD1 DD DSN=&HLQUAL..MASTER.FILE, // SPACE=&SPACE, // UNIT=&UNIT
This example adapts resource allocations based on the execution environment (production, test, or development).
1234567891011121314151617181920// SET DAY=&SYSDATE // SET DATEN=&LYYMMDD //* // IF DAY='FRIDAY' THEN // SET PROCESS=WEEKLY // SET SPACE=(CYL,(50,20)) // ELSE // IF DAY='01' & SUBSTR(DAY,5,2)='01' THEN // SET PROCESS=MONTHLY // SET SPACE=(CYL,(100,50)) // ELSE // SET PROCESS=DAILY // SET SPACE=(CYL,(10,5)) // ENDIF // ENDIF //* //STEP1 EXEC PGM=GENRPT,PARM='&PROCESS' //REPORT DD DSN=REPORT.&PROCESS..&DATEN, // DISP=(NEW,CATLG,DELETE), // SPACE=&SPACE
This example adjusts processing based on the day of the week or month, with different space allocations and report names.
12345678910111213141516171819202122// SET REG=&PARM1 //* // IF REG='EAST' THEN // SET INFILE=EAST.REGION.DATA // ELSE // IF REG='WEST' THEN // SET INFILE=WEST.REGION.DATA // ELSE // IF REG='NORTH' THEN // SET INFILE=NORTH.REGION.DATA // ELSE // IF REG='SOUTH' THEN // SET INFILE=SOUTH.REGION.DATA // ELSE // SET INFILE=ALL.REGIONS.DATA // ENDIF // ENDIF // ENDIF // ENDIF //* //STEP1 EXEC PGM=PROCESS //INPUT DD DSN=&INFILE,DISP=SHR
This example selects different input files based on a parameter passed to the job, enabling region-specific processing.
The EXPORT statement allows symbolic parameter values to be passed to nested procedures:
12345678// SET REGION='EAST' // SET SPACE=(CYL,(50,20)) // EXPORT SYMLIST=(REGION,SPACE) //* //STEP1 EXEC PROC=MYPROC //* // SET REGION='WEST' /* This only affects steps after this point */ //STEP2 EXEC PROC=MYPROC
In this example, EXPORT makes the specified symbolic parameters available to called procedures, allowing consistent values to be used across the job.
Substring notation can be used to extract portions of symbolic parameter values:
12345678// SET FULLDATE=&LYYMMDD // SET YEAR='20'&FULLDATE(1:2) // SET MONTH=&FULLDATE(3:2) // SET DAY=&FULLDATE(5:2) //* //STEP1 EXEC PGM=MYPGM //DD1 DD DSN=REPORT.&YEAR..&MONTH..&DAY, // DISP=(NEW,CATLG,DELETE)
This example extracts year, month, and day components from a date string for use in dataset naming.
Complex override scenarios may involve multiple levels of resolution:
12345678// SET TYPE='SALES' // SET CYCLE='MONTHLY' // SET PREFIX='&TYPE..&CYCLE' /* First level of resolution */ // SET DSNAME='&PREFIX..REPORT' /* Second level of resolution */ //* //STEP1 EXEC PGM=REPORTER //OUTDD DD DSN=&DSNAME, /* Resolves to SALES.MONTHLY.REPORT */ // DISP=(NEW,CATLG,DELETE)
This example demonstrates how symbolic parameters can reference other symbolic parameters, with multiple levels of resolution.
Issue | Possible Causes | Solutions |
---|---|---|
Symbol not resolved | Symbol not defined, or defined after use |
|
Unexpected symbol value | Multiple overrides, conditional logic errors |
|
Nested symbol not resolved | Reference to undefined symbol within another symbol |
|
JCL error in symbolics | Syntax error in symbol resolution |
|
SET statement override processing is generally the same in both JES2 and JES3 environments, but there are some considerations:
Note:
With z/OS 2.5, JES3 is being phased out in favor of JES2, making JES2-specific behaviors the standard moving forward.