5 communicating with contained cobol programs – Compaq COBOL AAQ2G1FTK User Manual

Page 443

Advertising
background image

Interprogram Communication

12.5 Communicating with Contained COBOL Programs

Figure 12–4 Defining Data Names in the Linkage Section

IDENTIFICATION DIVISION.

PROGRAM−ID. MAINPROG.

ENVIRONMENT DIVISION.

DATA DIVISION.

FILE SECTION.

01 FILE−RECORD PICTURE ...

WORKING−STORAGE SECTION.

01 WORK−RECORD PICTURE ...

IDENTIFICATION DIVISION.

PROGRAM−ID. SUB.

ENVIRONMENT DIVISION.

DATA DIVISION.

FILE SECTION.

WORKING−STORAGE SECTION.

01 F−RECORD PICTURE ...

01 W−RECORD PICTURE ...

LINKAGE SECTION.

PROCEDURE DIVISION USING F−RECORD

W−RECORD.

PROCEDURE DIVISION.

BEGIN.

BEGIN.

.

.
.

EXIT PROGRAM.

CALL "SUB" USING FILE−RECORD

WORK−RECORD.

STOP RUN.

1

4

2

3

ZK−1477−GE

12.5 Communicating with Contained COBOL Programs

A contained COBOL program is a subprogram nested in another COBOL program
(the containing program). The complete source of the contained program is found
within the containing program. A contained program can also be a containing
program.

A COBOL containing/contained program provides you with program and data
attributes that noncontained COBOL programs do not have. These attributes,
described in the next several sections, often allow you to more easily share and
more conveniently access COBOL data items and other program resources.

This COBOL programming and data structuring capability encourages modular
programming. In modular programming, you divide the solution of a large data
processing problem into individual parts (the contained programs) that can be
developed relatively independently.

Consequently, the use of the COBOL containing/contained block structure as
a modular programming design can increase program efficiency and assist in
program modification and maintainability.

The contained program uses all calling procedures described in Sections 12.3
and 12.4. However, when a contained program includes the COMMON clause (a
program attribute) and the GLOBAL clause (a data and file trait), the additional
rules described in the following sections apply.

Interprogram Communication 12–13

Advertising