Rational Developer for System z
Enterprise COBOL for z/OS, Version 4.1, Programming Guide


Coding INVALID KEY phrases

You can include an INVALID KEY phrase on READ, START, WRITE, REWRITE, and DELETE statements for VSAM indexed and relative files. The INVALID KEY phrase is given control if an input or output error occurs because of a faulty index key.

You can also include the INVALID KEY phrase in WRITE requests for QSAM files, but the phrase has limited meaning for QSAM files. It is used only if you try to write to a disk that is full.

Use the FILE STATUS clause with the INVALID KEY phrase to evaluate the status key and determine the specific INVALID KEY condition.

INVALID KEY phrases differ from ERROR declaratives in several ways. INVALID KEY phrases:

If you code INVALID KEY in a statement that causes an INVALID KEY condition, control is transferred to the INVALID KEY imperative statement. Any ERROR declaratives that you coded are not performed.

If you code a NOT INVALID KEY phrase, it is performed only if the statement completes successfully. If the operation fails because of a condition other than INVALID KEY, neither the INVALID KEY nor the NOT INVALID KEY phrase is performed. Instead, after the program performs any associated ERROR declaratives, control passes to the end of the statement.

Example: FILE STATUS and INVALID KEY


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)