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
- Definition: Symbolic parameters are defined within procedures and are replaced by actual values when the procedure is invoked.
- Syntax: Symbolic parameters are denoted by an ampersand (
&
) followed by the parameter name. - 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
andP2
are symbolic parameters.DEFAULT1
andDEFAULT2
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:
In this example:
- The procedure
MYPROC
is called. - The symbolic parameters
P1
andP2
are replaced withMY.DATA.SET1
andMY.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
In this example:
- The procedure
BACKUP
is defined with symbolic parametersBKPDSN
andBKPUNIT
. - When the procedure is called in
MYJOB
, the symbolic parameters are replaced withUSER.BACKUP.DSN
andTAPE
.
Exercises
Exercise 1: Define and Use Symbolic Parameters
- 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. - 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
- Modify the
COPYPROC
procedure to use different default values for the symbolic parameters. - 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:
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
&
.
- 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.
JCL (Job Control Language) Course
Module 1: Introduction to JCL
Module 2: JCL Statements and Syntax
Module 3: Data Definition (DD) Statements
Module 4: Procedures and Symbolic Parameters
Module 5: Advanced JCL Concepts
- Conditional Processing
- JCLLIB and INCLUDE Statements
- Generation Data Groups (GDGs)
- Restart and Checkpoint
Module 6: Error Handling and Debugging
- Common JCL Errors
- Interpreting JCL Error Messages
- Debugging Techniques
- Using JES2/JES3 for Troubleshooting