Hi all,
is it possable to check for an EOF condition on an input file?
I have a simple job that reads a sequential file and writes another, after various lookups. I would like to be able to write to a third file, to record input and output record counts, and the value of various stage variables if required, and to do this AFTER an EOF condition on the input file.
I can arrange for there to be a special end of file record written to the input file, but I would have thought that I could test for the EOF condition.
I have seached this site, and the DS help files, to no avail.
Cheers,
Neil Courtney
Sequential file EOF
Moderators: chulett, rschirm, roy
Have you considered sending output to an aggregator stage of your various metrics (row counts, etc)? Then output the aggregator data to another sequential file to have your metrics.
I've done job designs where a "ready" type file is created after the job is finished writing the main file. I stream to an aggregator the current date, as well as a literal "1". The aggregator groups by the date, and sums the "1" column. When the job finishes reading the source file, the aggregator will output its data to another sequential file. The result is a data file and a ready file that contains the date of the data and the row count. This is one method you might use.
I've done job designs where a "ready" type file is created after the job is finished writing the main file. I stream to an aggregator the current date, as well as a literal "1". The aggregator groups by the date, and sums the "1" column. When the job finishes reading the source file, the aggregator will output its data to another sequential file. The result is a data file and a ready file that contains the date of the data and the row count. This is one method you might use.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
If you're doing this in BASIC there's an easy answer. The ReadSeq statement takes its ELSE path if you are at end of file.
So you could:
This can also be written using the Boolean context of ReadSeq.
You can also use the Seek statement in BASIC to position to end of file. This would be much more efficient if you weren't reading anyway.
The 0 is an offset, the 2 means "from end of file". You can also position to an offset with respect to beginning of file or to current position.
Both of these statements are described in the BASIC manual, and are available at your release (4.x).
So you could:
Code: Select all
Loop
ReadSeq Line From SeqFileVar Else Exit
statements
Repeat
Code: Select all
Loop
While ReadSeq Line From SeqFileVar
statements
Repeat
Code: Select all
Seek SeqFileVar,0,2
Else
* statements to handle Seek failure (corrupted file)
End
Both of these statements are described in the BASIC manual, and are available at your release (4.x).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.