Pathway/iTS SCREEN COBOL Reference Manual (G06.24+, H06.03+, Pathway/iTS 1.0+)
Procedure Division
Compaq NonStop™ Pathway/iTS SCREEN COBOL Reference Manual—426750-001
6-109
USE FOR TERMINAL-ERRORS Statement
file-system error code just as in steps 1 and 2, but resumes execution at the next
statement in the procedure itself.
The USE FOR TERMINAL-ERRORS declarative is both simple and powerful. It
allows you maximum control when a terminal I/O error occurs, but it can lead to
unexpected results. You should be careful both in how you use this procedure and for
what purpose.
Consider the following:
•
In block mode, you have no way of knowing which statement caused the error.
•
Pathway logging is not performed on errors handled by the USE FOR TERMINAL-
ERRORS procedure.
•
If an irrecoverable terminal I/O error occurs during an ACCEPT statement, the TCP
resets TERMINATION-STATUS to zero before returning to the statement following
the ACCEPT.
•
If you call another SCREEN COBOL program unit from within a USE FOR
TERMINAL-ERRORS declaratives procedure:
°
The called program (and any program it calls) must not contain a USE FOR
TERMINAL-ERRORS statement; if it does, a run-time error occurs and the
program suspends.
°
An irrecoverable terminal I/O error in the called program will cause the calling
program to suspend.
You should consider the nature of the error before attempting a retry within the
Declaratives section. Some errors can be retried, others cannot. To determine the nature
of the error, you can check the TERMINATION-SUBSTATUS special register for the
file-system error code.
If the declaratives procedure does not contain any executable statement, execution
resumes with the next statement following the statement that caused the error. Thus,
irrecoverable terminal I/O errors can occur with no indication that they have occurred.
One way to avoid this situation is to include at least one statement in the declaratives
procedure, possibly an EXIT PROGRAM statement.
The Declaratives procedures can be used to save current data (context). Saving current
data by using the declaratives procedures lets you resume the application with a more
completely recovered screen than is possible with, for instance, EXIT PROGRAM
WITH ERROR or CALL...ON ERROR when used outside the declaratives procedure.
The following example saves the current and last record when a terminal I/O error
occurs.
. . .
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CONTEXT-INFO.
02 CURRENT-REC.
04 NAME PIC A(33).
04 ACCT-NUM.
06 ACCT-PRE PIC AA.