Finding and handling input-output errors
File status keys can help you determine whether your program errors are due to input-output errors occurring on the storage media.
To use file status keys in debugging, check for a nonzero value in the status key after each input-output statement. If the value is nonzero (as reported in an error message), look at the coding of the input-output procedures in the program. You can also include procedures to correct the error based on the value of the status key.
If
you determine that a problem lies in an input-output procedure, include
the USE EXCEPTION/ERROR declarative to help debug
the problem. Then, when a file fails to open, the appropriate EXCEPTION/ERROR declarative
is performed. The appropriate declarative might be a specific one
for the file or one provided for the open attributes INPUT, OUTPUT, I-O,
or EXTEND.
Code each USE AFTER STANDARD
ERROR statement in a section that follows
the DECLARATIVES keyword in the PROCEDURE
DIVISION.