In this section, we will explore how to override parameters in JCL procedures. Overriding parameters is a powerful feature that allows you to customize the behavior of a procedure without modifying the procedure itself. This is particularly useful in large systems where procedures are reused across multiple jobs.
Key Concepts
- Procedures (PROCs): A set of JCL statements that can be reused in multiple jobs.
- Symbolic Parameters: Placeholders in procedures that can be replaced with actual values when the procedure is invoked.
- Overriding Parameters: The process of specifying different values for symbolic parameters or modifying DD statements in a procedure.
Overriding Symbolic Parameters
Symbolic parameters in a procedure can be overridden by specifying new values in the JCL that invokes the procedure. This is done using the EXEC
statement.
Example Procedure (MYPROC)
//MYPROC PROC //STEP1 EXEC PGM=MYPROG //INFILE DD DSN=&INFILE,DISP=SHR //OUTFILE DD DSN=&OUTFILE,DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(5,5)),UNIT=SYSDA
Invoking the Procedure with Overrides
//MYJOB JOB (ACCT),'OVERRIDE EXAMPLE' //STEP1 EXEC MYPROC,INFILE='INPUT.DATA.SET',OUTFILE='OUTPUT.DATA.SET'
In this example:
- The procedure
MYPROC
is invoked. - The symbolic parameters
&INFILE
and&OUTFILE
are overridden with actual data set names.
Overriding DD Statements
You can also override entire DD statements within a procedure. This is useful when you need to change the data set attributes or other DD parameters.
Example Procedure (MYPROC)
//MYPROC PROC //STEP1 EXEC PGM=MYPROG //INFILE DD DSN=&INFILE,DISP=SHR //OUTFILE DD DSN=&OUTFILE,DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(5,5)),UNIT=SYSDA
Invoking the Procedure with DD Overrides
//MYJOB JOB (ACCT),'DD OVERRIDE EXAMPLE' //STEP1 EXEC MYPROC,INFILE='INPUT.DATA.SET' //STEP1.OUTFILE DD DSN=NEW.OUTPUT.DATA.SET,DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(10,10)),UNIT=SYSDA
In this example:
- The
OUTFILE
DD statement inSTEP1
ofMYPROC
is overridden with a new data set name and different space allocation parameters.
Practical Exercise
Exercise 1: Overriding Symbolic Parameters
- Create a procedure named
COPYPROC
that copies data from one data set to another. - Use symbolic parameters for the input and output data sets.
- Write a JCL job that invokes
COPYPROC
and overrides the symbolic parameters with actual data set names.
Solution
Procedure (COPYPROC)
//COPYPROC PROC //COPYSTEP EXEC PGM=IEBGENER //SYSUT1 DD DSN=&INFILE,DISP=SHR //SYSUT2 DD DSN=&OUTFILE,DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(5,5)),UNIT=SYSDA //SYSPRINT DD SYSOUT=* //SYSIN DD DUMMY
JCL Job
//COPYJOB JOB (ACCT),'COPY EXAMPLE' //COPYSTEP EXEC COPYPROC,INFILE='SOURCE.DATA.SET',OUTFILE='TARGET.DATA.SET'
Exercise 2: Overriding DD Statements
- Modify the
COPYPROC
procedure to include a temporary data set. - Write a JCL job that overrides the temporary data set with a permanent data set.
Solution
Modified Procedure (COPYPROC)
//COPYPROC PROC //COPYSTEP EXEC PGM=IEBGENER //SYSUT1 DD DSN=&INFILE,DISP=SHR //SYSUT2 DD DSN=&OUTFILE,DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(5,5)),UNIT=SYSDA //TEMP DD DSN=&&TEMP,DISP=(NEW,PASS), // SPACE=(CYL,(1,1)),UNIT=SYSDA //SYSPRINT DD SYSOUT=* //SYSIN DD DUMMY
JCL Job
//COPYJOB JOB (ACCT),'DD OVERRIDE EXAMPLE' //COPYSTEP EXEC COPYPROC,INFILE='SOURCE.DATA.SET',OUTFILE='TARGET.DATA.SET' //COPYSTEP.TEMP DD DSN=PERMANENT.DATA.SET,DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(2,2)),UNIT=SYSDA
Common Mistakes and Tips
- Mistake: Forgetting to specify the step name when overriding DD statements.
- Tip: Always include the step name (e.g.,
STEP1.OUTFILE
) when overriding DD statements.
- Tip: Always include the step name (e.g.,
- Mistake: Using incorrect symbolic parameter names.
- Tip: Ensure that the symbolic parameter names in the procedure match those used in the
EXEC
statement.
- Tip: Ensure that the symbolic parameter names in the procedure match those used in the
Conclusion
Overriding parameters in JCL procedures allows for flexible and reusable job control. By understanding how to override symbolic parameters and DD statements, you can customize procedures to meet specific job requirements without altering the original procedure. This enhances maintainability and reduces redundancy in your JCL scripts.
In the next module, we will delve into advanced JCL concepts, including conditional processing and the use of JCLLIB and INCLUDE statements.
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