Variable substitution in z/OS JCL procedures

Variable substitution does not take place within JCL procedures. If you have z/OS® JCL variables within such procedures, their substitution is independent of any substitution made by IBM Z Workload Scheduler. Even if the z/OS JCL variable name is the same as an IBM Z Workload Scheduler variable name, the values assigned to the two variables will be unrelated. However, if you want the variable reference outside the procedure to be substituted by z/OS, you can define the IBM Z Workload Scheduler-variable with the attribute DEF= (value not required). with the attribute DEF=blank (value not required).

If a variable is given a value of (blank), the If a variable is given a value of blank, the variable will not be substituted if the variable definition states that no value is required. This lets these variables undergo normal JCL substitution after the tailoring performed by IBM Z Workload Scheduler. If a variable is given a default value of ¬ (logical not), the variable is deleted from the line.

This means that z/OS substitutes the variables that have a blank, or not-required, value. IBM Z Workload Scheduler substitutes the variables that have values that are not blanks, as well as variables that require values.

This means that MVS™ substitutes the variables that have a blank, or not-required, value. IBM Z Workload Scheduler substitutes the variables that have values that are not blanks, as well as variables that require values.

Because procedures are called after IBM Z Workload Scheduler substitution has taken place, a situation in which a procedure variable is assigned an IBM Z Workload Scheduler variable value can occur. Consider the JCL in Figure 1 and the procedure in Figure 2.

Figure 1. Substituting a variable in a procedure: job JCL
//EXEC    PROC=MYPROC
//DD2     DD DSN=MY.&DS2,DISP=SHR
//EXEC    PROC=MYPROC
//DD2     DD DSN=MY.&DS2,DISP=SHR

If DS2 is defined as an IBM Z Workload Scheduler variable, it is substituted in the usual way.

Figure 2. Substituting a variable in a procedure: procedure JCL
//MYPROC   EXEC PGM=IKJEFT01,DYNAMNBR=50,REGION=4096K
//DD2      DD DSN=MY.&DS2,DISP=SHR
//MYPROC   EXEC PGM=IKJEFT01,DYNAMNBR=50,REGION=4096K
//DD2      DD DSN=MY.&DS2,DISP=SHR
If, as in this example, the DD name DD2 occurs in the procedure MYPROC, the entire JCL line will be substituted in the procedure, including the IBM Z Workload Scheduler substituted value of DS2:
//DD2     DD DSN=MY.&DS2,DISP=SHR

Any value that the variable DS2 is assigned within the procedure is not substituted in this line because, as far as z/OS is concerned, the variable DS2 does not occur. If you want the variable to take the value assigned by the procedure rather than the IBM Z Workload Scheduler value, you can give the variable a default value of (blank) and set the VALUE REQUIRED attribute to ‘Nʼ in the IBM Z Workload Scheduler database using the JCL VARIABLE DEFINITION panel. This causes IBM Z Workload Scheduler to ignore the variable when performing variable substitution.

Note: For inline procedures it is possible to apply variable substitution when VARPROC(YES) has been specified in the OPCOPTS statement.