Loading

FILE-STATUS and EOF (End of File) in Easytrieve

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.
i.e,

 IF EOF INFILE
     DISPLAY 'END OF FILE'
 END-IF

In case of a VSAM file, FILE-STATUS can mean any of the following

FILE-STATUS Meaning
0 Successful operation
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

Related Posts




blog comments powered by Disqus

There's 3 Comments So Far

  •   suresh babu
    May 22nd, 2012 at 9:36 am

    Hi,

    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?

    Regards,
    Suresh

  •   Karthik
    May 22nd, 2012 at 11:22 am

    Hi Suresh,
    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.

  •   Mani
    December 19th, 2012 at 6:39 pm

    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.

    Thank you

Share your thoughts, leave a comment!