7 handling input/output exception conditions, Handling input/output exception conditions – Compaq COBOL AAQ2G1FTK User Manual
Page 241
7
Handling Input/Output Exception Conditions
Many types of exception conditions can occur when a program processes a file; not
all of them are errors. The three categories of exception conditions are as follows:
•
AT END condition—This is a normal condition when you access a file
sequentially. However, if your program tries to read the file any time after
having read the last logical record in the file, and there is no applicable
Declarative USE procedure or AT END phrase, the program abnormally
terminates when the next READ statement executes.
•
Invalid key condition—When you process relative and indexed files,
the invalid key condition is a normal condition if you plan for it with a
Declarative USE procedure or INVALID KEY phrase. It is an abnormal
condition that causes your program to terminate if there is no applicable
Declarative USE procedure or INVALID KEY phrase.
•
All other conditions—These can also be either normal conditions (if you plan
for them with Declarative USE procedures) or abnormal conditions that cause
your program to terminate.
Planning for exception conditions effectively increases program and programmer
efficiency. A program with exception handling routines is more flexible than
a program without them. Exception handling routines minimize operator
intervention and often reduce or eliminate the time you need to spend debugging
and rerunning your program.
This chapter introduces you to the tools you need to execute exception handling
routines for sequential, relative, and indexed files as a normal part of your
program. These tools are the AT END phrase, the INVALID KEY phrase,
file status values, RMS completion codes (on OpenVMS Alpha systems), and
Declarative USE procedures. The sections that follow explain how to use these
tools in your programs:
•
Planning for the AT END condition (Section 7.1)
•
Planning for the Invalid Key condition (Section 7.2)
•
Using file status values
•
On OpenVMS, using RMS completion codes (Section 7.3)
♦
•
Using Declarative USE procedures (Section 7.4)
Handling Input/Output Exception Conditions 7–1