MainframeMaster

JCL Tutorial

Symbolic Parameters in JCL

Creating flexible and reusable JCL through variable substitution

Progress0 of 0 lessons

What are Symbolic Parameters?

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:

  • Make JCL more flexible and adaptable to different requirements
  • Reduce duplication by creating reusable JCL templates
  • Simplify maintenance by centralizing common values
  • Standardize job submission across an organization
  • Support conditional processing based on parameter values

Symbolic Parameter Syntax

Defining Symbolic Parameters

Symbolic parameters are identified by an ampersand (&) prefix followed by a valid JCL name (1-8 characters). For example: &SYSID, &DATE, &FILENAME.

Parameter Definition

A placeholder prefixed with an ampersand (&)

Default Value

Optional value that's used if no override is provided

Parameter Reference

Using the parameter elsewhere in JCL with the & prefix

Parameter Assignment

Setting a value using the SET statement or procedure override

Parameter Naming Rules

  • Must begin with an alphabetic character (A-Z) or national character (@, #, $)
  • Can contain alphanumeric characters (A-Z, 0-9) and national characters
  • Maximum length is 8 characters (not including the & prefix)
  • Must follow standard JCL naming conventions

Using Symbolic Parameters in JCL

Defining Parameters with Default Values

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:

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

Assigning Values with SET Statements

The SET statement explicitly assigns values to symbolic parameters. It must precede the statements that use the parameters:

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

Parameter Substitution in JCL

Parameters are substituted before JCL execution. The substitution follows these rules:

  • Parameters are resolved before job execution begins
  • Quotes are handled specially during substitution (see examples below)
  • A null value is used if no value is provided and no default exists
  • Parameter names must be terminated by a delimiter (space, comma, etc.) or period

Parameter Substitution Examples

Basic Substitution

Original JCL with Parameters:

jcl
1
2
3
4
// SET SYSID=PROD //STEP1 EXEC PGM=REPORT //SYSOUT DD SYSOUT=* //INPUT DD DSN=&SYSID..DATA,DISP=SHR

After Substitution:

jcl
1
2
3
//STEP1 EXEC PGM=REPORT //SYSOUT DD SYSOUT=* //INPUT DD DSN=PROD.DATA,DISP=SHR

Parameter Concatenation

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.

Handling Quotes in Parameters

Original JCL with Quoted Parameter:

jcl
1
2
3
4
5
// SET MSG='HELLO WORLD' //STEP1 EXEC PGM=MSGPROG //SYSIN DD * MESSAGE=&MSG /*

After Substitution:

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

Using Symbolic Parameters in Procedures

Procedure Definition with Parameters

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

Overriding Parameters When Calling a Procedure

jcl
1
2
3
//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.

System Symbols vs. Symbolic Parameters

JCL supports both symbolic parameters and system symbols. While they use similar syntax, they serve different purposes:

Symbolic Parameters

  • User-defined at the job or procedure level
  • Used for job customization and procedure flexibility
  • Defined using SET statements or PROC parameters
  • Scope limited to the job or procedure

System Symbols

  • Predefined by the system
  • Represent system values like date, time, system ID
  • Cannot be directly set by users
  • Available system-wide

Common system symbols include:

  • &SYSUID - User ID
  • &SYSDATE - Current date
  • &SYSTIME - Current time
  • &SYSNAME - System name
  • &SYSPLEX - Sysplex name

Using System Symbols in JCL

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

Advanced Parameter Techniques

Conditional Processing Based on Parameters

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

Concatenating Parameters with Text

For complex concatenation, ensure proper parameter termination:

jcl
1
2
3
// SET PREFIX=MY // SET SUFFIX=DATA //INPUT DD DSN=&PREFIX..&SUFFIX..FILE,DISP=SHR

After substitution: DSN=MY.DATA.FILE

Nested Parameter Substitution

jcl
1
2
3
// SET VER=2 // SET PGMNAME=PROGRAM&VER //STEP1 EXEC PGM=&PGMNAME

After substitution: PGM=PROGRAM2

Best Practices for Symbolic Parameters

Provide Meaningful Default Values

Always use sensible defaults that will work in most cases, making it optional to override parameters.

Document Parameters Thoroughly

Include comments that explain each parameter's purpose, allowed values, and impact on job execution.

Use Consistent Naming Conventions

Develop and follow organizational standards for parameter names to improve maintainability.

Validate Parameter Values

When possible, include validation steps that check parameter values before using them in critical operations.

Limit Parameter Complexity

Avoid deep nesting or chaining of parameters that make JCL difficult to understand and debug.

Test Parameter Substitution

Use MSGLEVEL=(1,1) to review the JCL after substitution and verify parameters are resolved as expected.

Common Challenges with Symbolic Parameters

Practical Exercise

Parameterized Backup Procedure

Create a reusable JCL procedure for backing up datasets using symbolic parameters. The procedure should:

  1. Define parameters for environment (DEV/TEST/PROD), backup type (FULL/INCR), and retention period
  2. Use IEBGENER to copy the specified dataset to a backup dataset
  3. Name the backup dataset based on the original name, date, and backup type
  4. Include conditional processing to handle different backup types
  5. Create a report showing the backup details

Consider how you would:

  • Provide sensible default values
  • Document the parameters for users
  • Handle various error conditions
  • Make the procedure flexible for different environments

Try writing the JCL yourself, then compare with a sample solution in a future lesson.

Test Your Knowledge

1. What is the primary purpose of Symbolic Parameters in JCL?

  • To automate job scheduling
  • To create variables that make JCL reusable and flexible
  • To encrypt sensitive information
  • To improve JCL compilation performance

2. How are symbolic parameters defined in JCL?

  • Using the SYMBOL statement
  • Using ampersand (&) prefix
  • Using the DEFINE statement
  • Using the VAR keyword

3. Which statement is used to assign values to symbolic parameters?

  • ASSIGN
  • DEFINE
  • SET
  • LET

4. In which parts of JCL can symbolic parameters be used?

  • Only in procedures
  • Only in DD statements
  • Only in JOB statements
  • In any JCL statement

5. What happens if a symbolic parameter is referenced but not assigned a value?

  • The job abends with an error
  • The parameter is replaced with a null value
  • The parameter is replaced with its default value if specified, otherwise null
  • The parameter name remains in the JCL with the ampersand prefix removed

Frequently Asked Questions