Symbolic parameters in JCL are placeholders that can be replaced with actual values when the JCL is executed. They are particularly useful in procedures (PROCs) to make them more flexible and reusable. This section will cover the basics of symbolic parameters, how to define them, and how to use them in your JCL jobs.

Key Concepts

  1. Definition: Symbolic parameters are defined within procedures and are replaced by actual values when the procedure is invoked.
  2. Syntax: Symbolic parameters are denoted by an ampersand (&) followed by the parameter name.
  3. Substitution: The actual values for symbolic parameters are provided in the JCL that calls the procedure.

Defining Symbolic Parameters

Symbolic parameters are defined in the procedure using the & symbol. Here is an example of a procedure with symbolic parameters:

//MYPROC PROC P1='DEFAULT1', P2='DEFAULT2'
//STEP1  EXEC PGM=MYPROG
//DD1    DD   DSN=&P1,DISP=SHR
//DD2    DD   DSN=&P2,DISP=SHR

In this example:

  • P1 and P2 are symbolic parameters.
  • DEFAULT1 and DEFAULT2 are default values for these parameters.

Using Symbolic Parameters

When you call a procedure, you can override the default values of symbolic parameters. Here is how you can do it:

//MYJOB  JOB  'ACCOUNTING INFO'
//STEP1  EXEC MYPROC,P1='MY.DATA.SET1',P2='MY.DATA.SET2'

In this example:

  • The procedure MYPROC is called.
  • The symbolic parameters P1 and P2 are replaced with MY.DATA.SET1 and MY.DATA.SET2, respectively.

Practical Example

Let's look at a more detailed example to understand how symbolic parameters work in a real-world scenario.

Procedure Definition

//BACKUP PROC BKPDSN='DEFAULT.BACKUP.DSN', BKPUNIT='SYSDA'
//STEP1  EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSIN    DD DUMMY
//SYSUT1   DD DSN=INPUT.DATA.SET,DISP=SHR
//SYSUT2   DD DSN=&BKPDSN,DISP=(NEW,CATLG,DELETE),
//            UNIT=&BKPUNIT,SPACE=(CYL,(5,5),RLSE)

JCL Calling the Procedure

//MYJOB  JOB  'ACCOUNTING INFO'
//BACKUP EXEC BACKUP,BKPDSN='USER.BACKUP.DSN',BKPUNIT='TAPE'

In this example:

  • The procedure BACKUP is defined with symbolic parameters BKPDSN and BKPUNIT.
  • When the procedure is called in MYJOB, the symbolic parameters are replaced with USER.BACKUP.DSN and TAPE.

Exercises

Exercise 1: Define and Use Symbolic Parameters

  1. Define a procedure named COPYPROC that copies data from one data set to another. Use symbolic parameters for the input and output data set names.
  2. Call the procedure in a JCL job, providing actual values for the symbolic parameters.

Solution

Procedure Definition:

//COPYPROC PROC INDSN='DEFAULT.INPUT.DSN', OUTDSN='DEFAULT.OUTPUT.DSN'
//STEP1    EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSIN    DD DUMMY
//SYSUT1   DD DSN=&INDSN,DISP=SHR
//SYSUT2   DD DSN=&OUTDSN,DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,SPACE=(CYL,(5,5),RLSE)

JCL Calling the Procedure:

//MYJOB  JOB  'ACCOUNTING INFO'
//COPYSTEP EXEC COPYPROC,INDSN='USER.INPUT.DSN',OUTDSN='USER.OUTPUT.DSN'

Exercise 2: Modify Default Values

  1. Modify the COPYPROC procedure to use different default values for the symbolic parameters.
  2. Call the procedure without overriding the symbolic parameters to see the default values in action.

Solution

Modified Procedure Definition:

//COPYPROC PROC INDSN='NEW.DEFAULT.INPUT.DSN', OUTDSN='NEW.DEFAULT.OUTPUT.DSN'
//STEP1    EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSIN    DD DUMMY
//SYSUT1   DD DSN=&INDSN,DISP=SHR
//SYSUT2   DD DSN=&OUTDSN,DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,SPACE=(CYL,(5,5),RLSE)

JCL Calling the Procedure:

//MYJOB  JOB  'ACCOUNTING INFO'
//COPYSTEP EXEC COPYPROC

In this case, the default values NEW.DEFAULT.INPUT.DSN and NEW.DEFAULT.OUTPUT.DSN will be used.

Common Mistakes and Tips

  • Mistake: Forgetting to use the & symbol when defining symbolic parameters.
    • Tip: Always start symbolic parameter names with &.
  • Mistake: Not providing values for symbolic parameters when calling the procedure.
    • Tip: Ensure you provide values for all required symbolic parameters, or verify that the default values are appropriate.

Conclusion

Symbolic parameters are a powerful feature in JCL that enhance the flexibility and reusability of procedures. By understanding how to define and use symbolic parameters, you can create more dynamic and adaptable JCL jobs. Practice defining and using symbolic parameters to become proficient in this essential JCL concept.

© Copyright 2024. All rights reserved