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

3 thoughts on “FILE-STATUS and EOF (End of File) in Easytrieve”

  1. 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

  2. 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.

  3. 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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.