HP 3000 Manuals

Ap K. File Status [ Micro Focus COBOL System Reference, Volume 2 ] MPE/iX 5.0 Documentation


Micro Focus COBOL System Reference, Volume 2

Appendix K  File Status 

A file status is a two-digit code that indicates how a file operation
completed; indicating if it completed successfully, or with some form of
error.  If an error has occurred, the file status indicates the reason
for the error.  It is returned in a data item called the file status
item, which you define in your program.  Defining a file status item is
optional.  If a file status item is not declared and a file error occurs,
the COBOL run-time system displays an error message and aborts your
program.

If you receive an undocumented error during a file operation, you must
recode your application so that it uses file status items.  You must then
check the file status item for the exact error.

If you have a file status item defined, after every input/output
operation on the file (that is, OPEN, CLOSE, READ, WRITE, REWRITE, START
and DELETE) the run-time system updates it to indicate how the
operation completed.  After each operation, it is the programmer's
responsibility to check the file status to see if the operation completed
satisfactorily.

For example, when your program is writing to disk, there may not be
enough disk space to complete the WRITE operation.  If you have not
defined a file status item and you run out of disk space, the run-time
system displays an error number and aborts the program.  If you have a
file status item defined (for the file you are writing), it is updated
and the program continues to run.  The program can then check the file
status, determine from it that the disk is full, and take the appropriate
action.


NOTE If you declare a USE procedure (in the Declarative section of your program) to handle I-O errors, the procedure is only executed if a file status is also defined for the file. The file status item is updated before the USE procedure is executed. See the Language Reference for more information about Declaratives and USE procedures.


MPE/iX 5.0 Documentation