If you are going to read the Empty file it will get into the AT END condition.
If you use a RECORD-READ counter to track the no. of records read you will find that the value of this counter will be zero.
The code will be something like below:
MOVE ZEROES TO RECORD-COUNTER.
DISPLAY 'End of File.'
NOT AT END
ADD 1 to RECORD-COUNTER
When u try to read an empty input file then the file-status will be NON ZERO (i.e) 35.
so check the file status if it is '35' then u read an empty input file.
Then abort or do the exception wat ever u need.
Joined: 08 Jun 2007 Posts: 71 Location: Zoetermeer, the Netherlands
Be carefull with "empty files" on the mainframe. Whenever a dataset (=file) is catalogued (by means of an IEFBR14 step) but never opened for output then you should not try to open this dataset for input. You might get an abend. It is more safe to ensure that you have a "real" empty dataset.
This can be accomplised "on the drawing board" by means of JCL or coding standards.
File status 10 indicates end of file (i.e) you have opened the infile properly & read the data.
But in case if the file is empty you cannot open the file itself. so immediately after opening the file u will get the file status as 35 and no need to read the file & u can't read the file.
ex : OPEN input INFILE.
IF INFILE-STATUS = 35
Perform your logic to abort or what ever ur option