COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
Diagnosing Input-Output Errors
The I-O status code returned to the program indicates what type of input-output error occurred. The
run-time routines send diagnostic messages for permanent error conditions and logic error conditions
to the home terminal (or designated execution-log file), regardless of whether an error is recoverable.
You must examine the I-O status code and to determine whether an unsuccessful input-output
operation must cause the program to terminate abnormally or allow it to continue processing. To
facilitate program execution and error recovery, the COBOL run-time input-output errors are classified
as either:
• Program Logic Errors
• External Errors
Program Logic Errors
A program logic error is considered nonrecoverable and causes the program to terminate
abnormally after execution of any applicable declarative section. This type of error causes I-O
status code “4x ” where x is a decimal digit, or I-O status code “90” (for errors defined by HP).
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 Chapter 48:
Run-Time Diagnostic Messages (page 1178).
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.
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.
Table 49 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 49 is not exhaustive;
values other than those shown for GUARDIAN-ERR might be returned.
Input-Output 251










