An application may abend with either a Protection Exception (S0C4 abend) or Data Exception (S0C7 abend) when the program logic fails to address the possibility of an empty input file.
Include a test for the case when there is no data in the input file.
VISION:Results provides a keyword, STATUS, on the FILE statement which is followed by a dataname you choose. The field pointed to by this dataname is automatically populated with the file status after each attempted access. (Please refer to the VISION:Results Reference Guide for more details.) This field should be tested for end of file at the beginning of every program.
In this example a message is printed if end of file is encountered on the first read before the program is terminated by the QUIT command:
FILE INFILE INPUT ... STATUS IEOF ON ONE IF IEOF EQ 'E' PRINT 'ATTENTION! INPUT FILES ARE EMPTY. NO REPORT GENERATED.' QUIT ENDIF ENDONE