Compaq COBOL AAQ2G1FTK User Manual

Page 444

Advertising
background image

Interprogram Communication
12.5 Communicating with Contained COBOL Programs

12.5.1 The COMMON Clause

The COMMON clause is a program attribute that can be applied to a directly
contained program. The COMMON clause is a means of overriding normal
scoping rules for program names, namely that a program that does not possess
the common attribute and that is directly contained within another program can
be referenced only by statements included in that containing program. For more
information on Scope of Names rules, refer to the Compaq COBOL Reference
Manual
.

The common attribute is attained by specifying the COMMON clause in a
program’s Identification Division. A program that possesses the common attribute
can be referenced by statements included in that containing program and by any
programs directly or indirectly contained in that containing program, except the
program possessing the common attribute and any programs contained within it.

Example 12–6 shows a run unit that has a COBOL program (PROG-MAIN)
(

1

) with three contained programs (

2

,

3

, and

4

); one of which ((

2

) has the

COMMON clause. The example indicates which programs can call the common
program.

Example 12–6 Using the COMMON Clause

IDENTIFICATION DIVISION.
PROGRAM-ID. PROG-MAIN.

1

.
.
.

CALL PROG-NAME-B
.
.
.
IDENTIFICATION DIVISION.
PROGRAM-ID. PROG-NAME-B IS COMMON PROGRAM.

2

.
.
.
IDENTIFICATION DIVISION.
PROGRAM-ID. PROG-NAME-D.

3

.
.
.
.
.
END PROGRAM PROG-NAME-D.
END PROGRAM PROG-NAME-B.

IDENTIFICATION DIVISION.
PROGRAM-ID. PROG-NAME-C.

4

.
CALL PROG-NAME-B
.
.
END PROGRAM PROG-NAME-C.
END PROGRAM PROG-MAIN.

PROG-NAME-B (

2

) and PROG-NAME-C (

4

) are directly contained in PROG-

MAIN (

1

); PROG-NAME-D (

3

) is indirectly contained in PROG-MAIN.

12–14 Interprogram Communication

Advertising