How to accept multiple lines of Instream data



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

How to accept multiple lines of Instream data

Postby shruti » Thu Apr 29, 2010 12:38 pm

Hi,

I have to pass 10 lines of instream data from jcl to cobol.
How to achieve it through accept statement in cobol and how can we make sure that end of data has been reached.

This has been asked in one of the interview.Can somebody please help me out in getting answer.

Thanks
Shruti
shruti
 
Posts: 4
Joined: Sun Apr 11, 2010 3:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to accept multiple lines of Instream data

Postby swd » Thu Apr 29, 2010 12:48 pm

Shruti,

look at the "The COBOL Program using SYSIN with Multiple Parameters" section of this web site http://www.simotime.com/cblpar01.htm

It explains it quite well

Cheers
Steve
User avatar
swd
 
Posts: 109
Joined: Wed Feb 18, 2009 9:18 pm
Location: UK
Has thanked: 0 time
Been thanked: 0 time

Re: How to accept multiple lines of Instream data

Postby Robert Sample » Thu Apr 29, 2010 4:45 pm

Why not use SELECT ... ASSIGN TO SYSIN and handle this with COBOL'S READ statement, which is designed for it?
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: How to accept multiple lines of Instream data

Postby dick scherrer » Fri Apr 30, 2010 2:57 am

Hello,

If an interviewer asked me how to handle multiple SYSIN records using ACCEPT, my answer would be that this is not permitted on systems with any kind of good programming standards.

As Robert mentioned, this should be done with SELECT/ASSIGN and then OPEN/READ/CLOSE within the code - not ACCEPT.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post