View previous topic :: View next topic
|
Author |
Message |
pradyutonnet Currently Banned New User
Joined: 13 Nov 2005 Posts: 29 Location: pune,mumbai
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
pradyutonnet Currently Banned New User
Joined: 13 Nov 2005 Posts: 29 Location: pune,mumbai
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
pradyutonnet Currently Banned New User
Joined: 13 Nov 2005 Posts: 29 Location: pune,mumbai
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
|