Page 1 of 1

passing value to cobol program

PostPosted: Thu Feb 14, 2008 5:32 pm
by vjain
//SYSIN DD*
12 34
56
/*
.....................
now cobol program i have three items
01 ABC PIC 99.
01 DEF PIC 99.
01 GHI PIC 99.

PROCEDURE DIVISION.
ACCEPT ABC.
ACCEPT DEF.
ACCEPT GHI.

wat will be the contents in these variables.
plz help as presently m not having mainframe acess

Re: passing value to cobol program

PostPosted: Thu Feb 14, 2008 8:49 pm
by dick scherrer
Hello,

If the intent is to have values in all 3 variables, the code will not work.

As the 3rd variable is not initialized, it will have an unpredictable value (if the 3rd accept does not cause an abend).

Re: passing value to cobol program

PostPosted: Thu Feb 21, 2008 11:40 am
by rawatdewan
yes as per dick if the third varible does not gives an abend the first variable wil have 12 and second variable 56
and the value of third variable is unpridictable.

Re: passing value to cobol program

PostPosted: Sat Jun 06, 2009 1:16 pm
by satishmf
Should these variables be defined in linkage or working storage section?

Re: passing value to cobol program

PostPosted: Sat Jun 06, 2009 6:45 pm
by dick scherrer
Hello,

Keep in mind that the posted example will not work correctly.

If the code is to ACCEPT values from SYSIN, the variables should be in working-storage.

Many organizations no longer permit use of ACCEPT to read multiple variables into a program. If more than one variable is needed, the code must have a SELECT, an FD, OPEN, READ, etc.