Skip to main content

Problem:

Open input to a file that does not exist continues to the read, without error.

Resolution:

If the file does not exist, OPEN INPUT causes an error status, unless the file is optional.

Defining a file status data item is optional. If a file status data item is not declared and a serious file error occurs, the COBOL run-time system displays an error message and aborts your program.

You should check the file status data item after each input/output operation, to see if the operation completed successfully. For example, when your program is writing to disk, there might not be enough disk space to complete the WRITE operation. If you have not defined a file status data item and you run out of disk space, the run-time system displays an error number and aborts the program. If you have a file status data item defined (for the file you are writing), it is updated and the program continues to run. The program can then check the file status data item, determine from it that the disk is full, and take the appropriate action

So unless there is code in the program  to handle the file status, then do not declare the file status data item and MF cobol  will issue the error and abort the program.

Old KB# 2202

#COBOL
#AcuCobol
#netexpress
#RMCOBOL
#ServerExpress