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 HCL Workload Automation for Z. Even if the z/OS® JCL variable name is the same as an HCL Workload Automation for Z 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 HCL Workload Automation for Z-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 HCL Workload Automation for Z. 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. HCL Workload Automation for Z 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. HCL Workload Automation for Z substitutes the variables that have values that are not blanks, as well as variables that require values.

Because procedures are called after HCL Workload Automation for Z substitution has taken place, a situation in which a procedure variable is assigned an HCL Workload Automation for Z variable value can occur. Consider the JCL in Substituting a variable in a procedure: job JCL and the procedure in Substituting a variable in a procedure: procedure JCL.

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 HCL Workload Automation for Z 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 ddname DD2 occurs in the procedure MYPROC, the entire JCL line will be substituted in the procedure, including the HCL Workload Automation for Z 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 HCL Workload Automation for Z value, you can give the variable a default value of (blank) and set the VALUE REQUIRED attribute to ‘Nʼ in the HCL Workload Automation for Z database using the JCL VARIABLE DEFINITION panel. This causes HCL Workload Automation for Z 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.