Page 1 of 1

How to ACCEPT Numeric value from JCL to Cobol

PostPosted: Thu Feb 09, 2012 7:53 am
by charungandhi
Hi All,

I have to send a X digit (less than or equal to 8 digits) number from JCL to Cobol Program through SYSIN Statement.
But the COBOL program is receiving spaces in the trailing part

Below is the details.

COBOL PROGRAM VARIABLE DECLARATION in Working Storage Section:
000078 * VARIABLE TO ACCEPT DATA (IMEI RANGE AND QUANTITY ) FROM JCL
000079 01 WR-CPN-GROUP.
000080 05 WR-CPN-NUMBER PIC 9(8) VALUE ZEROES.
000081 05 FILLER PIC X(10) VALUE SPACES.
000082 05 WR-CPN-QUANTITY PIC 9(3) VALUE ZEROES.

The Values are accepted in Cobol program using the below accept statement:
ACCEPT WR-CPN-NUMBER
ACCEPT WR-CPN-QUANTITY


the Display staement used in COBOL to display the data received
DISPLAY WR-CPN-NUMBER

Values are passed from JCL Using JCL SYSIN Statement:
//SYSIN DD *
22291
006
/*

Output after running the JCL:
22291bbb (where 'bbb' is spaces)

I want the output to be 00022291. Is there any solution for this. please let me know if extra details are needed.

Re: How to ACCEPT Numeric value from JCL to Cobol

PostPosted: Thu Feb 09, 2012 10:50 am
by NicC
Pass 8 digits e,g, 00022291

Re: How to ACCEPT Numeric value from JCL to Cobol

PostPosted: Thu Feb 09, 2012 2:51 pm
by Nik22Dec
Hi,

IMHO, you should see the leading zeroes correctly with the current code. Where exactly have you directed your output to? Sysout?PS File?

Re: How to ACCEPT Numeric value from JCL to Cobol

PostPosted: Thu Feb 09, 2012 3:13 pm
by BillyBoyo
charungandhi,

I assume this is an exercise. Normally on a mainframe you won't be using ACCEPT for getting input data. Far better to use a file in the normal way.

You need to check in the manual to discover that ACCEPT is not doing anything clever for you, which means you need to do the clever stuff afterwards. So you have to work out how to turn one to eight left-justified bytes into eight right-justified leading-zero-padded bytes. Read up well in the manual and come back here if you have problems.

Nik22Dec,

You have to check in the manual as well.