Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to use UNTIL reading sequential input file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How to use UNTIL reading sequential input file
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

Site Director


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

PostPosted: Tue Jul 07, 2009 9:08 pm    Post subject:
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. . .

http://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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Jul 07, 2009 9:53 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Jul 07, 2009 10:22 pm    Post subject:
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    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 08, 2009 3:06 am    Post subject: Reply to: How to use UNTIL reading sequential input file
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 4 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us