If the FILE STATUS clause is specified in a file control entry, a value is placed into the specified two-character data item during the execution of an OPEN, CLOSE, READ, WRITE, REWRITE, DELETE, UNLOCK or START statement before any applicable USE procedure is executed, to indicate the status of that input-output operation.
The file status keys described in the following pages are for those files which conform fully to the ANSI standard and which use none of the extensions available with this COBOL system.
Use of extensions, for example, specifying a file as LINE SEQUENTIAL, affects
the status keys returned. Additional information is provided under the relevant
verbs.
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 |
![]() |
- 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. |
![]() |
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. |
The rightmost character position of the FILE STATUS data item is known as status key 2 and is used to further describe the results of the input-output operation.
The combination of status key 1 and status key 2 defines the result of the input-output operation as detailed below.
If status key 1 contains "0" to indicate the successful completion of the input-output operation, status key 2 can contain one of the following values:
"0" | (all files) No further information is available |
"2" | (indexed files only) Indicates one of two possibilities:
|
![]() |
(all files) Indicates that the length of the record being processed does not conform to the fixed file attributes for that file. |
![]() |
(all files) Indicates that the referenced optional file was not present at the time the OPEN statement was executed. |
![]() |
(record sequential files only) Indicates that for a CLOSE statement with the NO REWIND, REEL/UNIT or FOR REWIND phrase, or an OPEN statement with the NO REWIND phrase, the referenced file is a non-reel/unit medium. |
If status key 1 contains "1" to indicate the AT END condition, status key 2 can contain one of the following values:
"0" | (all files) Indicates that there is no next logical record. This can be caused
by two conditions:
|
![]() |
(relative files only) Indicates that the number of significant digits in the relative record number is larger than the size of the relative key data item described for that file. |
If status key 1 contains "2" to indicate INVALID KEY condition, status key 2 indicates the cause of the condition by one of the values:
"1" | (sequentially accessed indexed files) Indicates a sequence error. The ascending sequence requirements of successive record key values have been violated (see the topic The WRITE Statement), or the prime record key value has been changed by the COBOL runtime element between the successful execution of a READ statement and the execution of the next REWRITE statement for that file. |
"2" | (relative and indexed files only) Indicates a duplicate key value. An attempt has been made either to write a record that would create a duplicate prime record key or to write or rewrite a record that would create a duplicate alternate record key when the DUPLICATES phrase is not specified for that alternate record key. |
"3" | (relative and indexed files only) Indicates no record found. An attempt has been made to access a record, identified by a key, and that record does not exist in the file, or a START or READ statement has been attempted on an optional input file that is not present. |
![]() |
(relative and indexed files only) Indicates a boundary violation arising
from one of the following conditions:
|
If status key 1 contains "3" to indicate a permanent error condition, status key 2 can contain one of the following values to indicate the cause of that error:
"0" | (all files) Indicates that no further information is available concerning the cause of the error. |
"4" | (sequential files only) Indicates a boundary violation. An attempt has been made to write beyond the externally defined boundaries of a file. |
![]() |
(all files) Indicates that an OPEN statement with the INPUT, I-O, or EXTEND phrase has been attempted on a non-optional file that is not present. |
![]() |
(all files) Indicates that an OPEN statement has been attempted on a file
which does not support the open mode specified in the OPEN statement. The
possible violations are:
|
![]() |
(all files) Indicates that an OPEN statement has been attempted on a file previously closed with lock. |
![]() |
(record sequential, relative and indexed files) Indicates that a conflict has been detected between the fixed file attributes and the attributes specified for that file in the source element. |
If status key 1 contains "4" to indicate a logic error condition, status key 2 can contain one of the following values to indicate the cause of that error:
"1" | (all files) Indicates that an OPEN statement has been attempted for a file already in open mode. |
"2" | (all files) Indicates that a CLOSE statement has been attempted for a file not in open mode. |
"3" | (all files, sequential access mode only) Indicates that the last input-output statement executed for the associated file, prior to the execution of a DELETE or REWRITE statement, was not a successfully executed READ statement. |
"4" | (record sequential files only) Indicates that a boundary violation exists. A possible violation is that an attempt has been made to WRITE or REWRITE a record that is larger than the largest, or smaller than the smallest, record allowed by the RECORD IS VARYING clause of the associated file. |
"5" | (all files ) An attempt has been made to REWRITE a record to a file, and
the record is not the same size as the record being replaced.
|
"6" | (all files) Indicates that a sequential READ statement has been attempted
on a file open in input or I-O mode, but no valid next record has been established.
This can be caused by the following conditions:
|
"7" | (all files) Indicates that the execution of a READ or START statement has been attempted on a file not open in input or I-O mode. |
"8" | (all files) Indicates that the execution of a WRITE statement has been attempted on a file not open in I-O, output or extend mode, or on a file open I-O in sequential access mode. |
"9" | (all files) Indicates that the execution of a DELETE or REWRITE statement has been attempted on a file not open in I-O mode. |
If status key 1 contains " 9" to indicate a run-time system error message, status key 2 contains the run-time system error message number in binary. These are described in full in your COBOL system documentation.
In the following table: "S" indicates a Record Sequential file,
"L " indicates a Line Sequential file,
"R" indicates a Relative file and "I" indicates an Indexed file.
A particular combination of status key 1 and status key 2 is valid for a given file organization if the letter for that organization is found at the corresponding intersection in Table 1.