COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

One possible I-O status code that results from unsuccessful random or dynamic read operations
is:
Unsuccessful Random or Dynamic Read OperationI-O Status Code
The invalid-key condition exists, and the read operation is unsuccessful“23”
For other possible I-O status codes representing successful and unsuccessful operations, see
File-Status Data Item under READ for Sequential or Dynamic Access (page 405).
NOTE: After an unsuccessful execution of a READ statement, these values are unpredictable:
The value of the file position indicator
The contents of the current record area
The key of reference
Any key value found in the current record area: that is, the value of the current key for indexed
files or the value of the alternate key for any type of file-system file, because in HP COBOL,
sequential and relative files can have alternate keys.
Key of Reference to Specify a Record
The program specifies which record is to be read by assigning the appropriate value to the
data item established as the key of reference, before the READ statement is to be executed.
Handling Exception Conditions
For general exception handling, put declaratives at the beginning of the Procedure Division.
They can respond to error conditions arising for a single file or for all files open in the same
mode (INPUT, OUTPUT, I-O, or EXTEND). (See USE (page 484).)
The USE AFTER STANDARD ERROR PROCEDURE statement specifies what to do when a
file-manipulating statement encounters an error. Declaratives can be called for AT END,
INVALID KEY, and other error conditions.
If an invalid-key condition is encountered at the beginning of a read, and the READ statement
contains the INVALID KEY phrase, control passes to imperative-stmt-1 and no USE
procedure is executed. If the READ statement does not contain an INVALID KEY phrase, but
an applicable USE procedure exists, that procedure is executed.
After an invalid-key condition arises for a relative, indexed, or queue file, sequential read
operatons cannot be done on the file until you either:
Close and reopen the file
Execute a successful START statement on the file
Execute a successful random READ statement on the file
Timed Input-Output Errors
If a READ statement includes the TIME LIMIT phrase, and the I-O request exceeds the time
interval indicated, the codes FILE STATUS 30 and GUARDIAN-ERR 40 are returned. For
information about the special register GUARDIAN-ERR, see Diagnosing Input-Output Errors
(page 251).
See these usage considerations in READ for Sequential or Dynamic Access:
File-Status Data Item
LOCK Phrase
READ 421