Rational Developer for System z
Enterprise COBOL for z/OS, Version 4.1, Programming Guide


Using file status keys

After each input or output statement is performed on a file, the system updates values in the two digit positions of the file status key. In general, a zero in the first position indicates a successful operation, and a zero in both positions means that nothing abnormal occurred.

Establish a file status key by coding:

Specify the file status key data-name-1 as a two-character category alphanumeric or category national item, or as a two-digit zoned decimal or national decimal item. This data-name-1 cannot be variably located.

Your program can check the file status key to discover whether an error occurred, and, if so, what type of error occurred. For example, suppose that a FILE STATUS clause is coded like this:

FILE STATUS IS FS-CODE

FS-CODE is used by COBOL to hold status information like this:

This image shows FS-CODE 21, where 2 is marked invalid key and 1 is marked sequence error.

Follow these rules for each file:

For VSAM files, you can additionally code a second identifier in the FILE STATUS clause to get more detailed information about VSAM input or output requests.

You can use the file status key alone or in conjunction with the INVALID KEY option, or to supplement the EXCEPTION or ERROR declarative. Using the file status key in this way gives you precise information about the results of each input or output operation.

related references  
FILE STATUS clause (Enterprise COBOL Language Reference)  
File status key (Enterprise COBOL Language Reference)


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)