Handling errors in VSAM files
When an input or output statement operation fails, COBOL does not perform corrective action for you.
About this task
All OPEN
and CLOSE
errors
with a VSAM file, whether logical errors in your program or input/output
errors on the external storage media, return control to your COBOL
program even if you coded no DECLARATIVE
and no FILE
STATUS
clause.
If any other input or output statement operation fails, you choose whether your program will continue running after a less-than-severe error.
COBOL provides these ways for you to intercept and handle certain VSAM input and output errors:
- End-of-file phrase (
AT END
) EXCEPTION/ERROR
declarativeFILE STATUS
clause (file status key and VSAM status code)INVALID KEY
phrase
You should define a status key for each VSAM file that you
define in your program. Check the status key value after each input
or output request, especially OPEN
and CLOSE
.
If
you do not code a file status key or a declarative, serious VSAM processing
errors will cause a message to be issued and a Language Environment® condition to be signaled,
which will cause an abend if you specify the runtime option ABTERMENC(ABEND)
.
Handling errors in input and output operations
Using VSAM status codes (VSAM files only)
z/OS® DFSMS Macro Instructions for Data Sets (VSAM macro return and
reason codes)