COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
4. If control reaches the end of declarative procedure, transfer control to the statement immediately
following the terminating period or scope terminator of the I-O statement that caused the
exception condition.
5. If neither exception handling phrases nor declarative procedures apply, transfer control to the
statement immediately following the terminating period or scope terminator of the I-O statement
that caused the exception condition.
Other Error Conditions
If the execution is unsuccessful for a reason other than an at-end or invalid-key condition, the
behavior of the program depends on the presence or absence of a declarative procedure for the
file in question. If there is such a declarative procedure, the behavior of the program also depends
on the presence or absence of any negative exception handling phrase (NOT AT END or NOT
INVALID KEY).
When the run-time routines have recognized the exception condition, generated a run-time diagnostic
message, and stored the I-O status code, they take these actions in this order:
1. If a declarative procedure of the form USE AFTER EXCEPTION is associated with the file,
execute the declarative procedure.
Then, if recovery from the exception is not possible (the I-O status code is “90” or Status Key
1 is “4”), terminate the process.
If recovery from the exception is possible (either when Status Key 1 is “3,” or when it is “9”
and Status Key 2 is not “0”), and the declarative procedure has not voluntarily terminated
execution of the process, continue the execution:
a. If the statement that caused the condition includes any negative exception handling phrase
(NOT AT END or NOT INVALID KEY), transfer control to that phrase’s imperative statement.
Ignore any positive exception handling phrases (AT END, INVALID KEY).
b. If the statement that caused the condition does not include any negative exception handling
phrase, transfer control to the statement immediately following the terminating period or
scope terminator of the I-O statement that caused the exception condition.
2. If no applicable declarative procedure exists, terminate the process.
Timed Input and Output
Timed input-output prevents the deadlock that can occur when processes require concurrent access
to shared data files. Timed I-O is enabled for a file when the file is opened with an OPEN statement
containing a TIME LIMIT phrase. When timed I-O is enabled for a file, you can use a TIME LIMIT
phrase in a LOCKFILE, READ, or START statement that applies to the file. The time limit is the number
of seconds within which the operation must finish. A negative time limit means “wait indefinitely”
(until the contention is resolved or the waiting process is terminated by an external agency).
Topics:
• Expired Time Limit
• Overhead
• Fatal Error
• $RECEIVE Timeout
Expired Time Limit
An expired time limit indicates a potential deadlock. The programmed recovery action (declarative
procedure) must release any locks held by the program and restart the execution of the current
request.
If no declarative procedure applies to the file when the operation terminates, the program terminates
abnormally.
256 Procedure Division










