Using file system status codes
Often the two-digit file status key is too general to pinpoint the result of an input
or output request. You can get more detailed information about Db2®, LSQ, QSAM,
RSD, SdU, SFS, and STL file-system requests by coding a second
data item in the FILE STATUS
clause.
About this task
FILE STATUS IS data-name-1 data-name-8
In the example above, the data item data-name-1 specifies the two-digit COBOL file status key, which must be a two-character category alphanumeric or category national item, or a two-digit zoned decimal or national decimal item. The data item data-name-8 specifies a data item that contains the file-system status code if the COBOL file status key is not zero. data-name-8 is at least 6 bytes long, and must be an alphanumeric item.
LSQ, QSAM, RSD, SFS, STL and SdU files: For LSQ, QSAM, RSD, SFS, STL and SdU file system input and output requests, if data-name-8 is 6 bytes long, it contains the file status code. If data-name-8 is longer than 6 bytes, it also contains a message with further information:
01 my-file-status-2.
02 exception-return-value PIC 9(6).
02 additional-info PIC X(100).
The exception-return-value
contains a
value that can further refine the error noted in FILE STATUS
.
The additional-info
contains further diagnostic information
of the error noted in exception-return-value
to help
you diagnose the problem.
Db2 files: For Db2 file-system input and output requests, define data-name-8 as a group item. For example:
01 FileStatus2.
02 FS2-SQLCODE PICTURE S9(9) COMP.
02 FS2-SQLSTATE PICTURE X(5).
The runtime values in FS2-SQLCODE
and FS2-SQLSTATE
represent
SQL feedback information for the operation previously completed.
Example: checking file system status codes
Db2 file system
QSAM file system
MongoDB file system
SFS file system
STL file system
FILE STATUS clause (COBOL for Linux on x86 Language Reference)
File status key (COBOL for Linux on x86 Language Reference)