Page 1 of 1

Usage of PARM in COBOL from JCL

PostPosted: Thu Apr 23, 2009 6:38 pm
by navennaik
Hello

I want to use the PARM value passed by the JCL in my COBOL program.

So for the sake of the same i am just looking into some other module where the JCL parameter is as follows.

//STEP1 EXEC PGM=TESTAPP,TIME=5,REGION=6M,
// PARM='090422'

But in my cobol program The coding has been done as below.

LINKAGE SECTION.

01 PARM-INFO.
05 PARM-LENGTH PIC S9(04) COMP.
05 PARM-DATE.
10 PARM-YY PIC X(02).
10 PARM-MM PIC X(02).
10 PARM-DD PIC X(02).

PROCEDURE DIVISION USING PARM-INFO.

So even though the PARM value passed to the program is only 6 charecter long , why have they used the COMP field PARM-LENGTH.

Thanks
Naveen

Re: Usage of PARM in COBOL from JCL

PostPosted: Thu Apr 23, 2009 7:04 pm
by swd
Naveen
The PARM-LENGTH PIC S9(04) COMP is the length of the parameter passed (which will be 6 in your example), and this length is stored in the PARM-LENGTH field which is defined in the 'standard' and usual way, which is a signed number field. The format of the parm field is the length (S9(4) COMP field) and then the actual parm contents which (I think) can be up to 256 bytes long.

I hope this answers your question.
Cheers
Steve

Re: Usage of PARM in COBOL from JCL

PostPosted: Thu Apr 23, 2009 7:30 pm
by Bill Dennis
A parm in JCL has max length of 100.

You might want to test the length indicator to ensure all 6 bytes were supplied in the PARM.

Re: Usage of PARM in COBOL from JCL

PostPosted: Fri Apr 24, 2009 1:37 am
by dick scherrer
Hello,

Keep in mind that even if you don't compare the length field for a proper length, you still must allow for the length field (as it is in the posted code).

You also need to check the parm fields to ensure the date entered is valid.