Rational Developer for System z
COBOL for Windows, Version 7.5, 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:

Btrieve files: The following values for the file status key are not set for Btrieve files:

In addition to the file status key, you can code a second identifier in the FILE STATUS clause to get more detailed information about file-system input or output requests. See the related reference below about file system status codes.

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.

Example: file status key
Example: checking file system status codes

related tasks
Setting up a field for file status
Using file system status codes

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


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)