TSO-ISPF JCL COBOL VSAM DB2 CICS IMS-DB Tools Articles Forum Quiz Interview Q&A

JCL - Nested Procedure


Cataloged and in-stream procedures can invoke other procedures (up to 15 levels of nesting). In a procedure, an EXEC statement can invoke another procedure, which can contain an EXEC statement to invoke another procedure, and so on.

We cannot code an instream procedure within a cataloged procedure.

The following example shows how procedures can be nested:

Procedure C:
    //C       PROC
    //CS1     EXEC  PGM=GHI
               .
    //        PEND

 Procedure B:
    //B       PROC
    //BS1     EXEC  PROC=C
               .
    //BS2     EXEC  PGM=DEF
               .
    //        PEND

 Procedure A:
    //A       PROC
    //AS1     EXEC  PROC=B
               .
    //AS2     EXEC  PGM=ABC
               .
    //        PEND

 Job Stream:
    //JOB1    JOB
    //STEP1   EXEC  PROC=A
               .
    //STEP2   EXEC  PGM=JKL
               .
               .

The following statements are equivalent to the nested procedures shown above.

//JOB1    JOB
   //CS1     EXEC  PGM=GHI
              .
   //BS2     EXEC  PGM=DEF
              .
   //AS2     EXEC  PGM=ABC
              .
   //STEP2   EXEC  PGM=JKL
              .
              .

We don't use nested procedure often in real time projects. We mostly use cateloged procedure.


If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!

Are you looking for Job Change? Job Portal