z/OS MVS JCL Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Examples of coding symbols in nested procedures

z/OS MVS JCL Reference
SA23-1385-00

Example 1: The following example defines symbols A, B, and C with multiple assignments in nested procedures:
                                             Current value of symbol:
//MYJOB    JOB    ...                        Level 0:
//SET1     SET    A=123,B=456                A=123,B=456,C=undefined
            .
//PROC1    PROC   A=234,C=GHI
//PSTEP1   EXEC   PROC=PROC2,A=ABC,B=DEF
//PSTEP2   EXEC   PGM=IEFBR14
//         PEND
            .
//PROC2    PROC
//P2STEP1  EXEC   PGM=IEBGENER
//SYSPRINT DD     SYSOUT=A
//SYSUT1   DD     DSN=&A..&B,DISP=SHR
//SYSUT2   DD     SYSOUT=A,DCB=LRECL=&C
//         PEND
            .
//STEP1    EXEC   PROC=PROC1,A=,C=789        Level 1:
            .                                A=,B=456,C=789
++PROC1    PROC   A=234,C=GHI
++PSTEP1   EXEC   PROC=PROC2,A=ABC,B=DEF     Level 2:
            .                                A=ABC,B=DEF,C=789
++PROC2    PROC
++P2STEP1  EXEC   PGM=IEBGENER
++SYSPRINT DD     SYSOUT=A
++SYSUT1   DD     DSN=ABC.DEF,DISP=SHR
++SYSUT2   DD     SYSOUT=A,DCB=LRECL=789
++         PEND
            .
++PSTEP2   EXEC   PGM=IEFBR14                Level 1:
            .                                A=,B=456,C=789
++         PEND
//BARNEY   EXEC   PGM=IEFBR14                Level 0:
//...       .                                A=123,B=456,C=undefined
The processing of symbols in MYJOB is:
  • When the SET statement SET1 is processed, symbols A and B are defined and initialized to the values 123 and 456, respectively. (The C symbol C is not yet defined.) The level of nesting (scoping) is 0.
  • EXEC statement STEP1 references in-stream procedure PROC1. The symbols are changed as follows: A is nullified, B remains 456 from SET statement SET1, and C is defined and assigned the substitution text 789. The level of nesting (scoping) is now 1.

    PROC statement PROC1 defines the default values for the symbols A and C as A=234 and C=GHI. However, these values are overridden by the values on the EXEC statement STEP1 as: A=, and C=789.B remains 456 from SET statement SET1. The level of nesting is still 1.

  • EXEC statement PSTEP1 is processed. The substitution texts for the symbols are updated again as: A=ABC and B=DEF. (C remains 789 from EXEC statement STEP1.) The substitution texts are passed to procedure PROC2 referenced by EXEC statement PSTEP1. The level of nesting is now 2.
  • The statements in procedure PROC2 are processed. The values used to resolve the symbols on DD statements SYSUT1 and SYSUT2 are those from level 2, namely A=ABC, B=DEF, C=789. The level of nesting returns to level 1.
  • EXEC statement PSTEP2 in PROC1 is processed. This statement does not change the values of the symbols. However, because the expansion of PROC2 is complete, the values of the symbols return to the level 1 values held prior to procedure PROC2, which are A=, B=456, and C=789. The level of nesting returns to level 0.
  • EXEC statement BARNEY is at level 0 and the substitution texts for symbols are restored to their original values: A=123,B=456, and C=undefined. The substitution texts, defined by SET statement SET1, are retained throughout this level of nesting (level 0).
Example 2: To illustrate the scope of symbolics in the case of nested procedures, consider the following example, where PROC1 calls PROC2:
   //JOB2   JOB    ...
   //PROC1  PROC   WORK='''1000,500'''
   //S1     EXEC   PROC2,WORK=&WORK
   //S2     EXEC   PROC2,WORK=&WORK
   //       PEND
   //PROC2  PROC   WORK='''500,250''',LABEL=DUMMY
   //P1     EXEC   PGM=IEFBR14
   //DD1    DD     UNIT=SYSDA,SPACE=(TRK,(&WORK)),DSN=&LABEL
   //       PEND
   //J1     EXEC   PROC1,WORK='''500,250''',LABEL=UNUSED
   //J2     EXEC   PROC1

In the prior example, the symbolic LABEL is defined as UNUSED in EXEC statement J1, which calls PROC1. The symbolic LABEL is not used in PROC1 but is used in PROC2, which is called by PROC1 and therefore is in the scope of the original definition of the symbolic.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014