COBOL Manual for TNS and TNS/R Programs

Procedure Division
HP COBOL Manual for TNS and TNS/R Programs522555-006
8-34
Diagnosing Input-Output Errors
External Errors
An external error is recoverable if the program includes an associated declarative
section; otherwise, an external error causes the program to terminate abnormally. The
types of recoverable input-output errors are:
An external error that has an associated operating system input-output error
causes I-O status code “30”. The run-time routine then calls the FILEERROR
procedure to check whether an operation can be retried. If the operation is not
retried, the operating system reports an error, giving the file name and the file-
system error number, which the run-time routine includes in an error message that
it delivers to the process’s log file (usually the home terminal).
An external input-output failure that is not related to an operating system error
causes the return of I-O status code “91”.
The format of the run-time error message depends on the environment. For details,
see Section 48, Run-Time Diagnostic Messages.
The run-time routines can also generate warnings, indicating that a minor error
condition exists. A warning message is issued, but no declaratives or error actions are
executed, and the program continues.
Each COBOL run unit contains a special register called GUARDIAN-ERR, a
COMPUTATIONAL data item defined as
PIC 9(4) COMPUTATIONAL.
The process updates this register each time it executes an input-output statement. The
value of GUARDIAN-ERR is delivered to the run-time routines by the operating system
upon its completion of the requested input-output statement. Do not use the library
routine COBOLFILEINFO or the Guardian routine FILEINFO to retrieve the error,
because they can return incorrect values.
Table 8-12 is provided for your guidance only. The final authority on the meaning of the
values of GUARDIAN-ERR is the current documentation of the operating system.
Table 8-12 is not exhaustive; values other than those shown for GUARDIAN-ERR
might be returned.
Note. GUARDIAN-ERR augments, but does not replace, the I-O status code.
The value of GUARDIAN-ERR derives only from the operating system. The run-time routines
merely make the value available for the process to examine after the process has examined
the appropriate I-O status code.