Instream procedures are procedures that are defined within the JCL input stream of a job, rather than being stored in a procedure library. They allow you to define a sequence of JCL statements once within a job and execute it multiple times with different parameters, without the need to create and maintain a separate cataloged procedure.
Advantage:
Instream procedures are particularly useful for one-time or rarely used processes, testing changes to procedures, or when you want to keep all JCL components together in a single job stream.
12345678//jobname JOB parameters... //procname PROC [parameters...] //stepname EXEC PGM=program //DDname DD parameters... // ... // PEND // //execstep EXEC procname[,parameter overrides...]
Component | Description |
---|---|
PROC Statement | Marks the beginning of the procedure definition and can include parameter declarations with default values |
Procedure Body | The JCL statements that make up the procedure (EXEC, DD, IF, etc.) |
PEND Statement | Marks the end of the procedure definition |
EXEC Statement | Executes the procedure with optional parameter overrides |
123456789//MYJOB JOB (ACCT#),'JOHN DOE',CLASS=A //* //MYPROC PROC //STEP1 EXEC PGM=IEFBR14 //DD1 DD DSN=MY.DATASET,DISP=(NEW,CATLG), // SPACE=(TRK,(10,5)),UNIT=SYSDA // PEND //* //RUN1 EXEC MYPROC
This example defines a simple procedure that creates a new dataset and then executes it once.
123456789101112131415//COPYJOB JOB (ACCT#),'JANE SMITH',CLASS=A //* //COPYPROC PROC DSN1='MY.INPUT.DATASET', // DSN2='MY.OUTPUT.DATASET' //COPY EXEC PGM=IEBGENER //SYSUT1 DD DSN=&DSN1,DISP=SHR //SYSUT2 DD DSN=&DSN2,DISP=(NEW,CATLG), // SPACE=(TRK,(10,5)),UNIT=SYSDA //SYSIN DD DUMMY //SYSPRINT DD SYSOUT=* // PEND //* //RUN1 EXEC COPYPROC //* //RUN2 EXEC COPYPROC,DSN1='PROD.DATA',DSN2='PROD.COPY'
This example defines a procedure with parameters for copying a dataset, then executes it twice: once with default parameter values and once with overridden values.
123456789101112131415//MULTIJOB JOB (ACCT#),'ADMIN',CLASS=A //* //CLEAN PROC //STEP1 EXEC PGM=IEFBR14 //DD1 DD DSN=TEMP.DATASET,DISP=(MOD,DELETE) // PEND //* //CREATE PROC TYPE='DATA',NAME='DEFAULT' //STEP1 EXEC PGM=IEFBR14 //DD1 DD DSN=&NAME..&TYPE,DISP=(NEW,CATLG), // SPACE=(TRK,(10,5)),UNIT=SYSDA // PEND //* //RUN1 EXEC CLEAN //RUN2 EXEC CREATE,TYPE=MASTER,NAME=PROD
This example defines two different instream procedures and executes them in the same job.
12345678910111213141516//CONDJOB JOB (ACCT#),'ADMIN',CLASS=A //* //CONDPROC PROC ENV='PROD',DEBUG=N //STEP1 EXEC PGM=MYPROG //INPUT DD DSN=&ENV..DATA,DISP=SHR //OUTPUT DD DSN=&ENV..OUTPUT,DISP=(NEW,CATLG), // SPACE=(TRK,(10,5)),UNIT=SYSDA //DEBUG DD DUMMY // IF &DEBUG=Y THEN //DEBUG DD SYSOUT=* //TRACE DD SYSOUT=* // ENDIF // PEND //* //TEST EXEC CONDPROC,ENV=TEST,DEBUG=Y //PROD EXEC CONDPROC
This example defines a procedure with conditional processing based on parameter values, then executes it with different parameter combinations.
Issue | Possible Causes & Solutions |
---|---|
Procedure not found |
|
Parameter substitution errors |
|
JCL syntax errors |
|
Conditional logic issues |
|
MSGLEVEL=(1,1)
on the JOB statement to see expanded procedures in the job logJCLDUMP DD SYSOUT=*
to see JCL after parameter substitutionTYPRUN=SCAN
on the JOB statement to check for JCL errors without executing the jobInstream procedures are supported in both JES2 and JES3 environments with some differences:
Characteristic | Instream Procedures | Cataloged Procedures |
---|---|---|
Availability | Limited to the job where defined | Available to all jobs in the system |
Maintenance | Must update all jobs containing the procedure | Update once in procedure library |
Implementation | Immediate - no library updates needed | Requires update to procedure library |
Testing | Easier for temporary changes | May require temporary procedure libraries |
Documentation | Self-documented in the job | May require separate documentation |
Standardization | May lead to inconsistencies | Supports standardized processing |