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, SdU, SFS, and STL file-system requests by coding a second data item in the FILE STATUS clause.

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.

STL files: For STL 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).

If you attempt to open a file using a different definition than the one with which the file was created, and use the file status code structure shown above, 39 is returned in exception-return-value, and a message that tells which keys you need in order to perform the open request is returned in additional-info.

SdU and SFS files: For SdU and SFS file-system input and output requests, define data-name-8 with PICTURE X(n) and USAGE DISPLAY attributes, where n is 6 or greater. The PICTURE string value represents the first n bytes of the reply message structure that is documented in VSAM File System Reply Messages. If the size m of the reply message structure is less than n, only the first m bytes contain useful information.

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

related references  
DB2 file system  
SdU file system  
SFS file system
  
STL file system  
FILE STATUS clause (COBOL for AIX Language Reference)  
File status key (COBOL for AIX Language Reference)  
VSAM File System Reply Messages