When an input or output operation fails, COBOL does not automatically take corrective action. You choose whether your program will continue running after a less-than-severe input or output error.
You can use any of the following techniques for intercepting and handling certain input or output conditions or errors:
For VSAM files, if you specify a FILE STATUS clause, you can also test the VSAM status code to direct your program to error-handling logic.
To have your program continue, you must code the appropriate error-recovery procedure. You might code, for example, a procedure to check the value of the file status key. If you do not handle an input or output error in any of these ways, a severity-3 Language Environment condition is signaled, which causes the run unit to end if the condition is not handled.
The following figure shows the flow of logic after a VSAM input or output error:

The following figure shows the flow of logic after an input or output error with QSAM or line-sequential files. The error can be from a READ statement, a WRITE statement, or a CLOSE statement with a REEL/UNIT clause (QSAM only).

*Possible phrases for QSAM are AT END, AT END-OF-PAGE, and INVALID KEY; for line sequential, AT END.
**You need to write the code to test the file status key.
***Execution of your COBOL program continues after the input or output statement that caused the error.
related tasks
Using the end-of-file condition (AT END)
Coding ERROR declaratives
Using file status keys
Handling errors in QSAM files
Using VSAM status codes (VSAM files only)
Handling errors in line-sequential files
Coding INVALID KEY phrases
related references
File status key (Enterprise COBOL Language Reference)