IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to use UNTIL reading sequential input file


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pradyutonnet
Currently Banned

New User


Joined: 13 Nov 2005
Posts: 29
Location: pune,mumbai

PostPosted: Tue Jul 07, 2009 8:33 pm
Reply with quote

How to use UNTIL reading sequential input file.

like
READ INPUT-FILE INTO INPUT-DETAIL UNTIL DETAIL-RECORD

NOTE
where DETAIL-RECORD IS 88 LEVEL variable of WS-DETAIL-RECORD.



actually I want to read input file which has 3 different types of records:

1- header
2- detail
3- trailer

Record format

H0056
D01NAMEDATA
D02NAMEDATA
D03NAMEDATA
D04NAMEDATA
T0056

I want to read the detail record only meaning I want to stop reading once D04 is processed. That is my 2nd to last record is read.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jul 07, 2009 9:08 pm
Reply with quote

Hello,

At the top of the page is a link to "IBM Manuals". Among them is the Language Reference for cobol.

Code:
READ INPUT-FILE INTO INPUT-DETAIL UNTIL DETAIL-RECORD
This is invalid . . .
When using cobol, you must use syntax that is part of the language, not something you decided to use. . .

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/igy3lr40/6.2.28?
This is information about READ from the manual. . .
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jul 07, 2009 9:14 pm
Reply with quote

When you read a sequential file COBOL just reads the next record. If you don't want to process that record then just loop back and read the next one.
Back to top
View user's profile Send private message
pradyutonnet
Currently Banned

New User


Joined: 13 Nov 2005
Posts: 29
Location: pune,mumbai

PostPosted: Tue Jul 07, 2009 9:23 pm
Reply with quote

If you don't want to process that record then just loop back and read the next one.???
means??

all i want to read only detail record, can u plz tell me how i can stop before trailer recored...
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jul 07, 2009 9:53 pm
Reply with quote

Hello,

The language is not going to change to do as you want. You have to use the language as it is.

You have to read each record and decide if this is a record you want to use in your process. If it is, execute the code for a record you want to use. You can end any time you want.
Back to top
View user's profile Send private message
pradyutonnet
Currently Banned

New User


Joined: 13 Nov 2005
Posts: 29
Location: pune,mumbai

PostPosted: Tue Jul 07, 2009 10:14 pm
Reply with quote

i knw language is not gonna change for me ...all m asking is ; do we have any method to handle my requirement. if yes do u knw and if u knw thn can u gv help me with any example...

execute the code for a record you want to use. You can end any time you want.???
if i can end any time then can u tell me how i can stop before trailer record:(
the diff b/w detail and trailer record is detail line started with 1st bit D and trailer record started with 1st bit T , I Dont want to read trailer record all i want to stop my processing once detail record is end.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jul 07, 2009 10:22 pm
Reply with quote

Hello,

You need to arrive at a new way of thinking. . .

What you say you want to do is completely logical, but the way you structure the thought will not work for cobol programming. There is no syntax/built-in function to "read until end of detail".

In cobol, you open the file as input. You have a processing loop that reads the records one at a time and takes action based on the record read. In your case, you would detect the header and not do any processing. When a detail is detected you would do whatever processing is needed. When the trailer is detected, you would treat this as "end of file" (the same as AT END of the READ). When you reached the trailer or AT END, you would close the file and terminate your process.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jul 07, 2009 10:25 pm
Reply with quote

Without knowing how many detail records there are you can't know before you read the next record what it will be. So you have to read the next record then make your decision.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 08, 2009 3:06 am
Reply with quote

I would first READ NEXT the initial record and check the status-code for ZEROS.

If this is TRUE, then issue an in-line PERFORM (default is TEST BEFORE executing), issuing READ NEXT at the bottom of the PERFORM, which will terminate when the status-code is non-zero as the status-code will be tested at the top.

If the first READ NEXT were non-zero, then the logic will fallthru and the in-line PERFORM won't be invoked at all.

COBOL TEST BEFORE is akin to PL/I DO WHILE, whereas, COBOL TEST AFTER is akin to PL/I DO UNTIL.

TEST BEFORE ===> MAY NOT EVEN INVOKE THE PERFORM

TEST AFTER ===> PERFORM WILL BE INVOKED AT LEAST ONE TIME (I'm not a big fan)

HTH....

Regards,
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top