RM/COBOL File Status Codes

RM/COBOL file status codes take a 2-digit form in the file status data item (by combining the values of the Status Key 1 and Status Key 2 columns), or a 4-character or 11-character extended file status code that can be retrieved using the C$RERR standard library routine.

RM/COBOL file status codes are always returned when the FILETYPE=21 Compiler directive is in effect. If you set the DIALECT"RM" Compiler directive, this automatically sets FILETYPE=21, thus producing RM/COBOL file status codes.

If you are running under a different dialect or FILETYPE setting, but want to continue to return RM/COBOL file status codes, do the following:
  • Set environment variable COBFSTATCONV to the RM/COBOL setting:
    set COBFSTATCONV=rmstat
  • Set the COBFSTATCONV Compiler directive.

If your program is set to return RM/COBOL file status codes, but does not use a file status, or does not have a Declaratives section acting upon your data file, file I/O errors are reported by the run-time system. The extended file status reported may initially seem incorrect, but due to differences in the file handling of the different COBOL systems, the second byte of the reported error code needs to be converted from binary to ASCII. For example, if an error of 9/051 is reported, convert 051 to its ASCII character equivalent, which is 3 (0x33 in hexadecimal); therefore, the true RM/COBOL file status is actually 93.

Status Key 1 Status Key 2 Extended File Status Code Description
3 5 9/013 File not found.
3 5 9/188 Filename too large.
3 7 9/035 Incorrect access permission.
3 7 9/037 File access denied.
3 8 9/138 File is closed with lock - cannot open.
3 8 9/210 File is closed with lock.
4 1 9/141 File already open - cannot be opened.
4 2 9/142 File not open - cannot be closed.
4 3 9/143 REWRITE/DELETE not after successful READ
4 6 9/146 No current record defined for sequential read.
4 7 9/147 Wrong open or access mode for READ/ START.
4 8 9/148 Wrong open or access mode for WRITE.
4 9 9/149 Wrong open or access mode for REWRITE/ DELETE.
9 3 9/065 File locked.
9 8 9/071 Bad indexed file format.
9 8 9/139 Record length or key inconsistent.
9 9 9/068 Record is locked.