SET Statement

Purpose

The SET statement defines and assigns values to JCL symbolic parameters. These parameters can then be referenced throughout the job stream, allowing for variable substitution and more flexible JCL.

Syntax

jcl
1
//[name] SET parameter-name=value[,parameter-name=value]...

Key Components

  • name - An optional 1-8 character name that identifies the SET statement. Usually omitted.
  • parameter-name - The name of the symbolic parameter being defined (1-8 characters).
  • value - The value to assign to the parameter, can be a character string, number, or other valid value.

Examples

Basic SET Statement

jcl
1
2
3
4
5
6
7
//MYJOB JOB (ACCT123),'JOHN SMITH' // SET DATASET='USER.PAYROLL.DATA', // CLASS=A, // REGION=4M //STEP1 EXEC PGM=PAYROLL,REGION=®ION //INPUT DD DSN=&DATASET,DISP=SHR //OUTPUT DD SYSOUT=&CLASS

Multiple SET Statements

jcl
1
2
3
4
5
6
7
8
9
10
11
//MYJOB JOB (ACCT123),'JOHN SMITH' // SET SYSID=PROD // SET DAY=&SYSDATE // SET OUTCLASS=A // SET PREFIX=SYS1 //* //STEP1 EXEC PGM=REPORT //SYSPRINT DD SYSOUT=&OUTCLASS //INPUT DD DSN=&PREFIX..&SYSID..MASTER,DISP=SHR //OUTPUT DD DSN=&PREFIX..&SYSID..&DAY..REPORT, // DISP=(NEW,CATLG,DELETE)

SET with IF/THEN

jcl
1
2
3
4
5
6
7
8
9
10
11
//MYJOB JOB (ACCT123),'JOHN SMITH' // SET SYSID=TEST //* // IF SYSID='PROD' THEN // SET DATASET='PROD.PAYROLL.DATA' // ELSE // SET DATASET='TEST.PAYROLL.DATA' // ENDIF //* //STEP1 EXEC PGM=PAYROLL //INPUT DD DSN=&DATASET,DISP=SHR

Notes

  • SET statements can appear anywhere in the JCL, as long as they precede any statements that reference their parameters
  • Symbolic parameters are referenced using an ampersand (&) prefix: &parameter-name
  • Values can be enclosed in apostrophes (single quotes) for strings with special characters or spaces
  • A period after a symbolic parameter is treated as a delimiter unless you need a period in the substitution (use double periods)
  • SET statements can define multiple parameters in a single statement
  • Parameters can reference other previously defined parameters
  • System symbols like &SYSUID and &SYSDATE can be used in SET statements
  • SET statements are often used with IF/THEN/ELSE statements for conditional parameter setting

Related Concepts

Related Pages