Compaq COBOL AAQ2G1FTK User Manual

Page 249

Advertising
background image

Handling Input/Output Exception Conditions

7.4 Using Declarative USE Procedures

Example 7–6 The Declaratives Skeleton

PROCEDURE DIVISION.
DECLARATIVES.

.
.
.

END DECLARATIVES.
MAIN-BODY SECTION.
BEGIN.

.
.
.

As shown in Example 7–7, a Declarative procedure consists of a section header,
followed, in order, by a USE statement and one or more paragraphs.

Example 7–7 A Declarative USE Procedure Skeleton

.
.
.

PROCEDURE DIVISION.
DECLARATIVES.
D0-00-FILE-A-PROBLEM SECTION.

USE AFTER STANDARD ERROR PROCEDURE ON FILE-A.

D0-01-FILE-A-PROBLEM.

.
.
.

D0-02-FILE-A-PROBLEM.

.
.
.

D0-03-FILE-A-PROBLEM.

.
.
.

END DECLARATIVES.
MAIN-BODY SECTION.
BEGIN.

.
.
.

Declarative USE procedures can be either ordinary or global. Ordinary
Declarative USE procedures have a limited scope; you can use them only
in programs where they are originally introduced. Global Declarative USE
procedures have a wider scope; you can use them in programs that introduce
them as well as in programs that are contained within the introducing program.

In Compaq COBOL Declarative procedures, the conditions in the USE statements
indicate when they execute. There are five conditions. One USE statement
can have only one condition; therefore, if you need all five conditions in one
program, you must use five separate USE procedures. These procedures and
their corresponding conditions are as follows:

File name—You can define a file name Declarative USE procedure for each
file name. This procedure takes precedence over the next four procedures. It
executes for any unsuccessful exception condition. (One USE statement can
specify multiple file names.)

Handling Input/Output Exception Conditions 7–9

Advertising