EXEC PARM Parameter


Note! PARM parameter can be coded only at the step level.

The PARM parameter is used to pass the input data from the JOB step to the program. PARM parameter always comes with an EXEC statement, and it is optional.

How to pass data from JCL to Program -


Below diagram explains how the JCL PARM data passes to the program

EXEC PARM

COBOL program receives the PARM using the PROCEDURE DIVISION. The input data passed through the PARM variable received by the variables should declare in LINKAGE SECTION.

The variables declared in COBOL should have a length variable (S9(04) COMP) for storing data length and another variable for storing the data.

If the PARM data exceeds a line in JCL, the second line should start from the 16th position.

Simple PARM Parameter -


PARM=input-data
input-data Specifies the data to be passed to the program.
We can pass a maximum of 100 characters.
Quotes, parentheses, and commas are not counted within 100 characters.
Commas in the quotes are part of 100 characters.

Examples -

Scenario1 - Passing single numeric value to the program.

//STEP01  EXEC PGM=NEWPROG,PARM=47

We are passing input value 47 from JCL to the program NEWPROG.

Scenario2 - Passing alphanumeric value to the program.

//STEP02  EXEC PGM=NEWPROG,PARM="TEST1"

We are passing input TEST1 from JCL to the program NEWPROG. The quotes are not considered as a part of input and input is alphanumeric.

Scenario3 - Passing multiple numeric values to the program.

//STEP03  EXEC PROC=NEWPROG1,PARM=(47,64)

We are passing two inputs, 47 and 64, from JCL to the program NEWPROG1. Parentheses are used to group the values to specify those values belong to the PARM parameter. The comma is used to separate the values.

Scenario4 - Passing multiple alphanumeric values to the program.

//STEP04  EXEC PGM=NEWPROG1,PARM=('TEST1','TEST2')

We are passing two inputs, TEST1 and TEST2, from JCL to the program NEWPROG1.

Scenario5 - Passing input that coded in more than two lines.

//STEP01  EXEC PGM=PARAMP,PARM='THIS THE INPUT FROM JCL THAT IS CODED   
//             IN MORE THAN ONE LINE'                                   

We are passing 'THIS THE INPUT FROM JCL THAT IS CODED IN MORE THAN ONE LINE' from JCL to the program PARAMP.

PARM Parameter for PROCs -


If JCL is coded with a PROC and needs to pass the data to the PROC, the PARM parameter should code with the EXEC statement of the PROC.

PARM[.step-name-of-proc]=input-data
step-name-of-proc Specifies the step name of the PROC to which step the value should pass. The PARM parameter should code with a specific step name in the PROC to avoid confusion.

Examples -

Scenario1 - Passing a value to the PROC.

//STEP01  EXEC PGM=NEWPROC,PARM=47

We are passing input value 47 to the procedure NEWPROC and assumes it has only one step.

Scenario2 - Passing a value to the STEP01 of PROC.

//STEP02  EXEC PGM=NEWPROC,PARM.STEP01=47

We are passing input value 47 to the STEP01 of procedure NEWPROC.

Scenario3 - Passing a value to the PROC within the PROC.

//STEP02  EXEC PGM=NEWPROC,PARM.PROC2.STEP02=47

We are passing input value 47 to the STEP02 of PROC2 that is coded in NEWPROC.