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

  1. Procedures (PROCs): A set of JCL statements that can be reused in multiple jobs.
  2. Symbolic Parameters: Placeholders in procedures that can be replaced with actual values when the procedure is invoked.
  3. 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 in STEP1 of MYPROC is overridden with a new data set name and different space allocation parameters.

Practical Exercise

Exercise 1: Overriding Symbolic Parameters

  1. Create a procedure named COPYPROC that copies data from one data set to another.
  2. Use symbolic parameters for the input and output data sets.
  3. 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

  1. Modify the COPYPROC procedure to include a temporary data set.
  2. 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.
  • Mistake: Using incorrect symbolic parameter names.
    • Tip: Ensure that the symbolic parameter names in the procedure match those used in the EXEC statement.

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.

© Copyright 2024. All rights reserved