Overrides (via SET Statement Context)

Purpose

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.

SET Statement Fundamentals

The SET statement assigns values to symbolic parameters that can be referenced elsewhere in the JCL:

jcl
1
2
3
4
5
6
7
8
//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.

Override Context Mechanisms

Several mechanisms provide context for SET statement overrides:

Override MechanismDescriptionScope
Multiple SET StatementsLater SET statements override earlier ones for the same parameterFrom point of definition forward until next override
Conditional SET (IF/THEN)SET statements within IF/THEN/ELSE structuresExecuted only when conditions are met
PROC Parameter OverridesValues specified when invoking a procedureLimited to the procedure's execution
JOB Statement EXEC OverridesParameters specified directly on EXEC statementOverride stored procedure values for that execution
System SymbolsSystem-defined symbols referenced in SET statementsJob-wide, with values provided by the system

Multiple SET Statements

When multiple SET statements assign values to the same symbolic parameter, the most recent definition applies:

jcl
1
2
3
4
5
6
7
8
9
10
11
//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)).

Conditional SET Statements

SET statements can be conditionally executed using IF/THEN/ELSE structures:

jcl
1
2
3
4
5
6
7
8
9
// 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.

Complex Conditional Logic

jcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// 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.

PROC Parameter Overrides

Parameters defined in procedures can be overridden when the procedure is invoked:

jcl
1
2
3
4
5
6
7
8
9
10
//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 in Overrides

System symbols can be used in SET statements to create dynamic overrides based on system characteristics:

jcl
1
2
3
4
5
6
7
8
9
10
11
// 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.

Common System Symbols

SymbolDescriptionExample Value
&SYSNAMESystem nameSYSA
&SYSPLEXSysplex namePLEXPR
&SYSDATECurrent date (Julian format)23180 (June 29, 2023)
&LYYMMDDLocal date in YYMMDD format230629
&SYSSYMRSymbolic substitution characters& and .

Common Override Use Cases

Environment-Specific Settings

jcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// 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).

Date-Based Processing

jcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// 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.

Dynamic Selection of Input Files

jcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// 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.

Advanced Override Techniques

EXPORT and SYMLIST

The EXPORT statement allows symbolic parameter values to be passed to nested procedures:

jcl
1
2
3
4
5
6
7
8
// 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

Substring notation can be used to extract portions of symbolic parameter values:

jcl
1
2
3
4
5
6
7
8
// 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.

Nested Override Resolution

Complex override scenarios may involve multiple levels of resolution:

jcl
1
2
3
4
5
6
7
8
// 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.

Common Issues and Troubleshooting

IssuePossible CausesSolutions
Symbol not resolvedSymbol not defined, or defined after use
  • Ensure SET statement appears before symbol usage
  • Check for typos in symbol names
  • Verify IF/THEN condition logic is correct
Unexpected symbol valueMultiple overrides, conditional logic errors
  • Trace all SET statements for the symbol
  • Check all conditional logic paths
  • Verify procedure parameter overrides
Nested symbol not resolvedReference to undefined symbol within another symbol
  • Ensure all referenced symbols are defined
  • Check for proper SYMLIST and EXPORT usage
JCL error in symbolicsSyntax error in symbol resolution
  • Check for missing periods in symbol concatenation
  • Verify quotes are properly paired
  • Ensure parentheses are balanced in complex expressions

Best Practices

  1. Group related SET statements together for clarity and easier maintenance
  2. Use comments to explain complex override logic, especially for conditional statements
  3. Define symbolic parameters at the beginning of the JCL when possible, for better visibility
  4. Use descriptive names for symbolic parameters that indicate their purpose
  5. Consider using a naming convention for different types of symbolic parameters
  6. Document the expected values and impact of override parameters
  7. Limit nested symbolic references to reduce complexity and potential errors
  8. Test JCL with different override combinations to ensure all paths work correctly
  9. Use consistent patterns for environment-specific overrides across all jobs
  10. Consider creating a centralized override library for common override patterns

JES2 vs JES3 Considerations

SET statement override processing is generally the same in both JES2 and JES3 environments, but there are some considerations:

  • JES3 provides additional options for specific override contexts via JES3 control statements
  • JES3 allows for catalog setup considerations that might affect dataset resolution
  • JES2 and JES3 might have different behavior with certain system symbols

Note:

With z/OS 2.5, JES3 is being phased out in favor of JES2, making JES2-specific behaviors the standard moving forward.

Related Concepts