In Easytrieve, whenever you perform an operation to a File, the STATUS of the operation can be checked using the FILE-STATUS variable.
For Normal Files,
FILE-STATUS = 0 means, Successful GET or PUT or READ or WRITE operation.
GET INFILE IF INFILE:FILE-STATUS NE 0 DISPLAY 'ERROR IN READING FILE' END-IF
End of a File can be identified using EOF keyword.
IF EOF INFILE DISPLAY 'END OF FILE' END-IF
In case of a VSAM file, FILE-STATUS can mean any of the following
|4||End of File|
|8||Duplicate key during a Write/PUT (or)
Additional records with the same key exist in the
alternate index during a GET operation
|12||Keys not in Sequence during PUT/WRITE|
|16||Record not found during READ|
3 thoughts on “FILE-STATUS and EOF (End of File) in Easytrieve”
In my requirement i need to read the file for all records more than once..
But i am not able to read second time as EOF has been set. How to reset the EOF?
I don’t think there is a way we can read through a file sequentially more than once. (since there is no OPEN / CLOSE command for the FILEs in Easytrieve).
Even if there is a way, it will not be an adviseable idea to do so.
If you want to search some lookup data from a file, there are few ways.
1) For random read, you may want to use a VSAM file and then READ by KEY.
2) you can define the FILE as a TABLE and lookup by key
3) read and move all the data from the file to an internal array, and refer the array any number of times.
How to read and move all the data from the file to an internal array, and refer the array any number of times.
Please give a sample.