passing value to cobol program



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

passing value to cobol program

Postby vjain » Thu Feb 14, 2008 5:32 pm

//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
vjain
 
Posts: 1
Joined: Thu Feb 14, 2008 5:22 pm
Has thanked: 0 time
Been thanked: 0 time

Re: passing value to cobol program

 

Re: passing value to cobol program

Postby dick scherrer » Thu Feb 14, 2008 8:49 pm

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).
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: passing value to cobol program

Postby rawatdewan » Thu Feb 21, 2008 11:40 am

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.
rawatdewan
 
Posts: 14
Joined: Tue Jan 15, 2008 5:28 pm
Has thanked: 0 time
Been thanked: 0 time

Re: passing value to cobol program

Postby satishmf » Sat Jun 06, 2009 1:16 pm

Should these variables be defined in linkage or working storage section?
satishmf
 
Posts: 10
Joined: Wed Jun 03, 2009 4:31 pm
Has thanked: 0 time
Been thanked: 0 time

Re: passing value to cobol program

Postby dick scherrer » Sat Jun 06, 2009 6:45 pm

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post