File Status Key in Cobol


Introduction
This document provides a summary of the two-byte File-Status-Key (sometimes referred to as file return code or file status code). For the COBOL environment if the FILE STATUS clause is specified in the FILE-CONTROL entry, a value is placed in the specified status key (the 2-character data item named in the FILE STATUS clause) during execution of any request on that file. The value indicates the status of that request. The value is placed in the status key before execution of any EXCEPTION/ERROR declarative or INVALID KEY/AT END phrase associated with the request.

The following tables contain file-status-key content that may be set by Micro Focus COBOL (Mainframe Express or Net Express) or an IBM Mainframe (MVS or OS/390).

File Status Key Overview

The ANS/85 standard provides for a two-byte file-status-key. The first character of the file-status-key is known as status-key-1. The second character is known as status-key-2. The combinations of possible values and their meanings are shown below with some comments where vendor additions or extensions may occur.

Note: If status-key-1 is a nine (9) then status key 2 is "implementor-defined". Many vendors take advantage of the x"00' to x'FF' (or 0-255) binary value. Therefore, the file status key may not always be a numeric value.
Status
Key-1
 
Condition Status
Key-2
 
Description




0Successful
Completion
0No further information
  2The input-output statement was successfully executed, but a duplicate key was detected. For a READ statement the key value for the current key of reference was equal to the value of the same key in the next record within the current key of reference. For a REWRITE or WRITE statement, the record just written created a duplicate key value for at least one alternate record key for which duplicates are allowed.
  4A READ statement was successfully executed, but the length of the record being processed did not conform to the fixed file attributes for that file.
  5An OPEN statement is successfully executed but the referenced optional file is not present at the time the OPEN statement is executed. If the open mode is I-O, the file has been created. Under MVS, the file has been created if the open mode is I-O or EXTEND. This does not apply to VSAM sequential files. File status 0 is returned.
  7For a CLOSE statement with the NO REWIND, REEL/UNIT, or FOR REMOVAL phrase or for an OPEN statement with the NO REWIND phrase, the referenced file was on a non-reel/unit medium.




1At END0A sequential READ statement was attempted and no next logical record existed in the file because the end of the file had been reached, or the first READ was attempted on an optional input file that was not present.
  4A sequential READ statement was attempted for a relative file and the number of significant digits in the relative record number was larger than the size of the relative key data item described for the file.




2Invalid key1A sequence error exists for a sequentially accessed indexed file. The prime record key value has been changed by the program between the successful execution of a READ statement and the execution of the next REWRITE statement for that file, or the ascending requirements for successive record key values were violated.
  2An attempt was made to write a record that would create a duplicate key in a relative file; or an attempt was made to write or rewrite a record that would create a duplicate prime record key or a duplicate alternate record key without the DUPLICATES phrase in an indexed file. This key value applies to an indexed file in which the alternate key has been declared 'UNIQUE'.
  3An attempt was made to randomly access a record that does not exist in the file, or a START or random READ statement was attempted on an optional input file that was not present.
  4An attempt was made to write beyond the externally defined boundaries of a relative or indexed file. Or, a sequential WRITE statement was attempted for a relative file and the number of significant digits in the relative record number was larger than the size of the relative key data item described for the file.




3Permanent error0No further information.
  4A permanent error exists because of a boundary violation; an attempt was made to write beyond the externally-defined boundaries of a sequential file.
  5An OPEN statement with the INPUT, I-O, or EXTEND phrase was attempted on a non-optional file that was not present.
  7An OPEN statement was attempted on a file that would not support the open mode specified in the OPEN statement. Possible violations are:
1. The EXTEND or OUTPUT phrase was specified but the file would not support write operations.
2. The I-O phrase was specified but the file would not support the input and output operations permitted.
3. The INPUT phrase was specified but the file would not support read operations.
4. Under VSE, the EXTEND phrase was specified for a SAM file.
  8An OPEN statement was attempted on a file previously closed with lock.
  9The OPEN statement was unsuccessful because a conflict was detected between the fixed file attributes and the attributes specified for that file in the program. These attributes include the organization of the file (sequential, relative, or indexed), the prime record key, the alternate record keys, the code set, the maximum record size, the record type (fixed or variable), and the blocking factor.




4Logic error1An OPEN statement was attempted for a file in the open mode.
  2A CLOSE statement was attempted for a file not in the open mode.
  3For a mass storage file in the sequential access mode, the last input-output statement executed for the associated file prior to the execution of a REWRITE statement was not a successfully executed READ statement.
For relative and indexed files in the sequential access mode, the last input-output statement executed for the file prior to the execution of a DELETE or REWRITE statement was not a successfully executed READ statement.
  4A boundary violation exists because an attempt was made to rewrite a record to a file and the record was not the same size as the record being replaced, or an attempt was made to write or rewrite a record that was larger than the largest or smaller than the smallest record allowed by the RECORD IS VARYING clause of the associated file-name.
  5An attempt has been made to REWRITE a record to a file, and the record is not the same size as the record being replaced.
(Micro Focus) For line sequential files this refers to the physical size of the record, that is after space removal, tab compression and null insertion. In this case, the physical size of the new record is allowed to be smaller than that of the record being replaced.
  6A sequential READ statement was attempted on a file open in the input or I-O mode and no valid next record had been established because:
1. The preceding READ statement was unsuccessful but did not cause an at end condition
2. The preceding READ statement caused an at end condition.
  7The execution of a READ statement was attempted on a file not open in the input or I-O mode.
  8The execution of a WRITE statement was attempted on a file not open in the I-O, output, or extend mode.
  9The execution of a DELETE or REWRITE statement was attempted on a file not open in the I-O mode.




9Implementor-
defined
0No further information.
  1For VSAM only: Password failure.
  2Logic error.
  3For VSAM only: Resource not available.
  4For VSAM with CMPR2 compiler-option only: No file position indicator for sequential request.
  5For VSAM only: Invalid or incomplete file information.
  6For VSAM under MVS: No DD statement specified for this file.
FOR VSAM and SAM under VSE: No DLBL statement specified for this file.
  7For VSAM only: OPEN statement execution successful: File integrity verified.




Primary File Status Keys
The first character of the file-status-key is known as status-key-1; the second character is known as status-key-2. The combinations of possible values and their meanings are shown below.

Status
1 & 2
Description


00Successful completion
02Indexed files only. Possible causes:
For a READ statement, the key value for the current key is equal to the value of that same key in the next record in the current key of reference.
For a WRITE or REWRITE statement, the record just written created a duplicate key value for at least one alternate record key for which duplicates are allowed.
04The length of the record being processed does not conform to the fixed file attributes for that file.
05The referenced optional file is not present at the time the OPEN statement is executed.
06Attempted to write to a file that has been opened for input.
07Sequential files only. For an OPEN or CLOSE statement with the REEL/UNIT phrase the referenced file is a non-reel/unit medium.
08Attempted to read from a file opened for output.
09No room in directory or directory does not exist.
10No next logical record exists. You have reached the end of the file.
12Attempted to open a file that is already open.
13File not found.
14Relative files only. 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.
Too many files open simultaneously (Micro Focus).
15Too many indexed files open (Micro Focus).
16Too many device files open (Micro Focus).
17Record error: probably zero length (Micro Focus).
18Read part record error: EOF before EOR or file open in wrong mode (Micro Focus).
19Rewrite error: open mode or access mode wrong (Micro Focus).
20Device or resource busy (Micro Focus).
21Sequentially accessed files only. Indicates a sequence error. The ascending key requirements of successive record key values has been violated, or, the prime record key value has been changed by a COBOL program between successful execution of a READ statement and execution of the next REWRITE statement for that file.
22Indexed and relative files only. Indicates a duplicate key condition. Attempt has been made to store a record that would create a duplicate key in the indexed or relative file OR a duplicate alternate record key that does not allow duplicates.
23Indicates 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. Alternatively a START or READ operation has been tried on an optional input file that is not present.
24Relative and indexed files only. Indicates a boundary violation. Possible causes:
Attempting to write beyond the externally defined boundaries of a file
Attempting a sequential WRITE operation has been tried on a relative file, but the number of significant digits in the relative record number is larger than the size of the relative key data item described for the file.
30The I/O statement was unsuccessfully executed as the result of a boundary violation for a sequential file or as the result of an I/O error, such as a data check parity error, or a transmission error.
32Too many Indexed files opened. This can also happen when a sequential file is open for input and an attempt is made to open the same file for output.(Run Time System (RTS) message by Micro Focus).
34The I/O statement failed because of a boundary violation. This condition indicates that an attempt has been made to write beyond the externally defined boundaries of a sequential file.
35An OPEN operation with the I-O, INPUT, or EXTEND phrases has been tried on a non-OPTIONAL file that is not present. Trying to open a file that does not exist.
May need to map the COBOL file name to the physical file name. (Micro Focus, refer to the ASSIGN(EXTERNAL) directive)
37An OPEN operation has been tried on a file which does not support the open mode specified in the OPEN statement.
38An OPEN operation has been tried on a file previously closed with a lock.
39A conflict has been detected between the actual file attributes and the attributes specified for the file in the program.
This is usually caused by a conflict with record-length, key-length, key-position or file organization.
Other possible causes are:
1. Alternate indexes are incorrectly defined (Key length or position, duplicates or sparse parameters).
2. The Recording Mode is Variable or Fixed or not defined the same as when the file was created..
41An OPEN operation has been tried on file already opened.
42A CLOSE operation has been tried on file already closed.
43Files in sequential access mode. The last I/O statement executed for the file, before the execution of a DELETE or REWRITE statement, was not a READ statement.
44A boundary violation exists. Possible causes:
Attempting 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
Attempting to REWRITE a record to a file and the record is not the same size as the record being replaced.
45An attempt has been made to REWRITE a record to a file, and the record is not the same size as the record being replaced.
(Micro Focus) For line sequential files this refers to the physical size of the record, that is after space removal, tab compression and null insertion. In this case, the physical size of the new record is allowed to be smaller than that of the record being replaced.
46A sequential READ operation has been tried on a file open in the INPUT or I-O mode but no valid next record has been established.
47A READ or START operation has been tried on a file not opened INPUT or I-O.
48A WRITE operation has been tried on a file not opened in the OUTPUT, I-O, or EXTEND mode, or on a file open I-O in the sequential access mode.
49A DELETE or REWRITE operation has been tried on a file that is not opened I-O.

Extended File Status Keys

The first character of the file-status-key is known as status-key-1. If status-key-1 is equal to 9 then status-key-2 is a one byte, binary value as defined in the following table.

Status-key-2DecimalStatus-key-2HexDescription



900000No further information.
900101Insufficient buffer space. Could also indicate an out of memory situation.
900202File not open when access tried.
900303Serial mode error.
900404Illegal file name.
Micro Focus, the COBOL file name may not be mapped to a fully qualified PC file name. Check the ASSIGN(EXTERNAL) directive and possible environment variable setting for the COBOL file name.
900505Illegal device specification.
900606Attempt to write to a file opened for input.
900707Disk space exhausted.
900808Attempt to input from a file opened for output.
900909No room in directory or directory does not exist.
90100AFile name not supplied.
90120CAttempt to open a file that is already open.
90130DFile not found.
90140EToo many files open simultaneously.
90150FToo many indexed files open.
901610Too many device files open.
901711Record error, probable cause is zero record length.
901812Read partial record error: EOF before EOR or file open in wrong mode.
This can also be cause when a physical line sequential file (ASCII/Text) is being read as a sequential file and the directive SEQUENTIAL(LINE) is not set (Micro Focus).
901913Rewrite error: open mode or access mode wrong.
902014Device or resource busy.
902115File is a directory.
902216Illegal or impossible access mode for OPEN.
902317Illegal or impossible access mode for CLOSE.
902418Disk I/O error.
Attempting to read a LINE SEQUENTIAL file as a SEQUENTIAL file(Micro Focus).
902519Operating system data error.
90261ABlock I/O error.
90271BDevice not available.
90281CNo space on device.
90291DAttempt to delete open file.
90301EFile system is read only.
90311FNot owner of file.
903220Too many indexed files, or no such process.
903321Physical I/O error.
903422Incorrect mode or file descriptor.
903523Attempt to access a file with incorrect permission.
903624File already exists.
903725File access denied.
903826Disk not compatible.
903927File not compatible.
904028Language initialization not set up correctly.
904129Corrupt index file.
90422AAttempt to write on broken pipe.
90432BFile information missing for indexed file.
(Micro Focus) This could indicate the filename.IDX is missing.
90442CAttempt to open an NLS file using an incompatible program.
90452DIndexed structure overflow. (Could indicate that you have reached the maximum number of duplicate keys.)
906541File locked.
906642Attempt to add duplicate record key to indexed file.
906743Indexed file not open.
906844Record locked.
906945Illegal argument to ISAM module.
907046Too many indexed files open.
907147Bad indexed file format.
907248End of indexed file.
907349No record found in indexed file.
90744ANo current record in indexed file.
90754BIndexed data file name too long.
90764CInternal ISAM module failure.
90774DIllegal key description in indexed file.
908151Key already exists in indexed file.
90905AUser does not have appropriate access permissions to the file (ANS74 and usually RM/COBOL).
90925CA PUT for update or an ERASE was issued without a previous GET for update.
910064Invalid file operation.
910165Illegal operation on an indexed file.
910266Sequential file with non-integral number of records.
910468Null file name used in a file operation.
910569Memory allocation error.
91247CConnection to remote system is failing.
(Micro Focus) This could indicate a File Name is mapped to use Fileshare and the Fileshare Server has not been started.
91257DConnection to remote system file server is failing (Micro Focus)
912981Attempt to access record zero of relative file.
913587File must not exist.
91388AFile closed with lock - cannot be opened.
91398BRecord length or key data inconsistency.
91418DFile already open - cannot be opened.
91428EFile not open - cannot be closed.
91438FREWRITE/DELETE in sequential mode not preceded by successful READ.
914692No current record defined for sequential read.
914793Wrong open mode or access mode for READ/START.
914894Wrong open mode or access mode for WRITE. This can be caused by issuing a read after the end-of-file has been reached during sequential processing.
914995Wrong open mode or access mode for REWRITE/ DELETE.
915096Program abandoned at user request.
915197Random read on sequential file.
915298REWRITE on file not opened I-O.
91589EAttempt to REWRITE to a line-sequential file.
91599FMalformed line sequential-file.
9161A1File header not found.
9173ADCalled program not found.
9180B4End-of-file marker error.
9182B6Console input or console output open in wrong direction.
9183B7Attempt to open line sequential file for I-O.
9188BCFile name too large.
9193C1Error in variable length count.
9194C2File size too large.
9195C3DELETE/REWRITE not preceded by a READ.
9196C4Record number too large in relative or indexed file.
9210D2File is closed with lock.
9213D5Too many locks.
9218DAMalformed MULTIPLE REEL/UNIT file.
9219DBOperating system shared file limit exceeded.