JCL PARM Parameter
PARM parameter is an optional keyword parameter in JCL.
PARM parameter is a way to pass a data from JCL to the program but the maximum amount of data which we can send to the program using the PARM Parameter is 100 character.
Syntax:
PARM=DATA
Example - Pass a single value from the JCL
//STEP01 EXEC PGM=ACCPARM,PARM=1234
Explanation
In this example, we are passing a value of 1234 from the JCL to the program ‘ACCPARM‘
Example - Pass values separated by commas without any quotes
//STEP01 EXEC PGM=ACCPARM,PARM=(12,34)
Explanation
In this example, we are passing a numeric value of 12, 34 from the JCL to the program ‘ACCPARM‘
Example - Pass a value separated by commas using quotes
//STEP01 EXEC PGM=ACCPARM,PARM=(’12’,’34’)
Explanation
In this example, we are passing Character value of ’12’ and ’34’ from the JCL to the program. Here, even though 12 and 34 are numbers but they are enclosed inside the single inverted commas so they will be treated as characters.
We can also send alphabetical characters or alphanumeric characters like ‘XYZ’ or ‘ABC123’
How to code PARM Parameter in JCL for a PROC
If your JCL contains a PROC, then you can code the PARM Parameter to pass a value to either a single step of the PROC or to all the steps of the PROC.
Example - To pass a value to the first step of the PROC using PARM
//STEP01 EXEC PROC=PROC1,PARM=’12,VAR=15,34′
Explanation
In this case, we are passing 12, VAR=15,34 to the 1st step of the PROC PROC1
Note/warning/suggestion/improvement:
If the PROC PROC1 contains multiple steps i.e. if it contains multiple EXEC statements and PARM is coded in each EXEC statement, then it will nullify(cancel out) the existing PARM Parameter.
Example - To pass a value to a single step of the PROC using PARM
//STEP03 EXEC PROC=PROC2,PARM.STEP5=(1234,HI,VAL=15)
Explanation
In this example, JCL passes 1234, HI, VAL=15 to the only STEP5 of the procedure ‘PROC2’
Example - To pass a value to a PROC present inside another PROC
//STEP04 EXEC PROC=MAINPROC,PARM.SECPROC=(123, XYZ)
Explanation
In this example, JCL passes 123, XYZ to the procedure ‘SECPROC ‘which is present inside the Main procedure ‘MAINPROC‘
Note/warning/suggestion/improvement:
If the PROC SECPROC contains multiple steps i.e. if it contains multiple EXEC statements and PARM is coded in each EXEC statement of the PROC SECPROC, then those PARM Parameters does not get affected and remains unchanged.
There are 2 types of Parameters which are used in JCL. Parameters can be coded at JOB level(JOB card) or EXEC statement or DD statement.
They are –
- Positional Parameters
- Keyword Parameters
Sample JCL to Pass the data from JCL to Program using PARM
In this example, we are passing a value of 1234 to the COBOL Program ‘COBPARM’
Example of COBOL Program to accept data from the JCL using the PARM Parameter
In this example, the program ‘COBPARM’ accepts the value passed from the JCL using ‘PARM-DET’ which is coded in the PROCEDURE DIVISION as below –
PROCEDURE DIVISION USING PARM-DET.
PARM-DET is defined in the LINKAGE SECTION. so the PARM length is defined as PARM-LEN PIC S9(04) COMP and PARM-VAL-1 and PARM-VAL-2 will accept values from the JCL.
PARM-VAL-1 will get 12 and PARM-VAL-2 will get 34.
The Output of the Program
In this example, You can see that the output of the program is 46 i.e. 12 + 34 = 46