Status Key 1

The leftmost character position of the FILE STATUS data item is known as status key 1 and is set to indicate one of the following conditions upon completion of the input-output operation on a file of any organization.

"0" - Successful completion
"1" - At end
"2" - Invalid key
"3" - Permanent error
"4" - Logic error
"9" - Run-time system error message

The meaning of the above conditions is as follows:

"0" Successful completion. The input-output statement was successfully executed.
"1" At end. The sequential READ statement was unsuccessfully executed either because of an attempt to read a record when no next logical record exists in the file or because the first READ statement was executed for a file described with the OPTIONAL clause when that file was not available at the time its associated OPEN statement was executed.
"2" Invalid key. The input-output statement on a non-sequential file was unsuccessfully executed because of one of the following:

Sequence error Duplicate key No record found Boundary violation

"3" Permanent error. The input-output statement was unsuccessfully executed because of a boundary violation for a sequential file or because of an input-output error, such as a data check parity error or transmission error.
"4" Logic error. The input-output statement was unsuccessfully executed, either because an improper sequence of input-output operations was performed on the file, or because a limit you defined was violated.
"9" Run-time system error message. The input-output statement was unsuccessfully executed because of a condition that is specified by the run-time system error message number. This value is used only to indicate a condition not indicated by other defined values of status key 1, or by specified combinations of the values of status key 1 and status key 2.