Interprogram Communication
12.5 Communicating with Contained COBOL Programs
At run time, two special precedence rules apply for the selection of a declarative
when programs are contained in other programs. In applying these two rules,
only the first qualifying declarative is selected for execution. The order of
precedence for the selection of a declarative follows:
Rule 1 —The declarative that executes first is the declarative within the
program containing the statement that caused the qualifying condition. In
Figure 12–6, FILE-NAME-PROBLEM procedure executes.
Figure 12–6 Executing Declaratives with Contained Programs (Rule 1)
IDENTIFICATION DIVISION.
PROGRAM−ID. MAIN−PROGRAM.
.
.
.
IDENTIFICATION DIVISION.
PROGRAM−ID. SUB1.
.
.
.
IDENTIFICATION DIVISION.
PROGRAM−ID. USE−PROGRAM.
.
.
.
PROCEDURE DIVISION.
DECLARATIVES.
FILE−NAME−PROBLEM SECTION.
USE AFTER STANDARD ERROR PROCEDURE ON FILEA.
OPEN INPUT FILEA.
.
.
.
END PROGRAM USE−PROGRAM.
END PROGRAM SUB1.
END PROGRAM MAIN−PROGRAM.
3
2
1
ZK−1428A−GE
Rule 2 —If a declarative is not found using Rule 1, the Run-Time System
searches all programs directly or indirectly containing that program for a
global use procedure. This search continues until the Run-Time System
either: ( 1 ) finds an applicable USE GLOBAL declarative, or ( 2 ) finds the
outermost containing program. Either condition terminates the search; the
second condition terminates both the search and the run unit.
Figure 12–7 shows applicable USE GLOBAL declaratives found in a containing
program before the outermost containing program. Note that the first OPEN goes
to the mode-specific procedure in the USE-PROGRAM rather than the file-specific
procedure in the MAINPROG-PROGRAM.
For information on the negative effect of USE procedures that reference
LINKAGE SECTION items on compiler optimization, see Section 15.5.5,
Minimizing USE Procedures with LINKAGE SECTION References .
Interprogram Communication 12–17
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......