Instream Procedure


An instream procedure is a type of procedure that is defined within the same JCL where it calls. The instream procedure won't validate syntax errors until an EXEC statement calls it. A maximum of 15 instream procedures can be coded in any job.

Syntax -

Defintion -

//proc-name PROC 
//jcl-statements
//    PEND

Calling -

//step-name EXEC proc-name 
or
//step-name EXEC PROC=proc-name

Rules -

  • Instream procedure can't be coded within another instream procedure.
  • Instream procedure allows CNTL, comment, DD, ENDCNTL, EXEC, IF/THEN/ELSE/ENDIF, INCLUDE, OUTPUT JCL, and SET statements only. The instream procedure will not allow any other apart from the above.
  • PEND is mandatory while coding the instream procedure.

Default and overrides -

To override a default parameter value on a PROC statement, code the same parameter on the EXEC statement that calls the procedure.

Examples -


Scenario1 - JCL to create two PS files.

//MTHUSERC JOB (MTH1234),'PAWAN Y',CLASS=B,NOTIFY=&SYSUID
//STEP10   EXEC PGM=IEFBR14
//DD1      DD DSN=MATEPK.IEFBR14.PSFILE1,
//            DISP=(NEW,CATLG,DELETE),
//            SPACE=(TRK,(3,2),RLSE),
//            UNIT=SYSDA,VOLUME=SER=DEVHD4,
//            DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)
//STEP20   EXEC PGM=IEFBR14
//DD1      DD DSN=MATEPK.IEFBR14.PSFILE2,
//            DISP=(NEW,CATLG,DELETE), 
//            SPACE=(TRK,(3,2),RLSE),
//            UNIT=SYSDA,VOLUME=SER=DEVHD4,
//            DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)

Same JCL with instream proc -

//MTHUSERC JOB (MTH1234),'PAWAN Y',CLASS=B,NOTIFY=&SYSUID
//*
//CREATEPS PROC
//STEPA    EXEC PGM=IEFBR14
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SYSDUMP  DD SYSOUT=*
//DD1      DD DSN=&PSNAME,
//            DISP=(NEW,CATLG,DELETE),
//            SPACE=(TRK,(3,2),RLSE),
//            UNIT=SYSDA,VOLUME=SER=DEVHD4,
//            DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)
//         PEND
//*
//STEP10   EXEC CREATEPS,PSNAME=MATEPK.IEFBR14.PSFILE1
//STEP20   EXEC CREATEPS,PSNAME=MATEPK.IEFBR14.PSFILE2
//*