Compaq COBOL AAQ2G1FTK User Manual

Page 434

Advertising
background image

Interprogram Communication
12.2 COBOL Program Attributes

Example 12–3 Run Unit with Three Separately Compiled Programs, One with

Two Contained Programs

IDENTIFICATION DIVISION.
PROGRAM-ID.

MAIN-PROGRAM.

7

.
.
.
CALL SUB1.
CALL SUB2.
.
STOP RUN.

IDENTIFICATION DIVISION.
PROGRAM-ID.

SUB1.

8

.
.
.
CALL SUB3.
EXIT PROGRAM.
END PROGRAM SUB1.

IDENTIFICATION DIVISION.
PROGRAM-ID.

SUB2.

9

.
.
.
EXIT PROGRAM.
END PROGRAM

SUB2.

END PROGRAM MAIN-PROGRAM.

IDENTIFICATION DIVISION.
PROGRAM-ID.

SUB3.

1 0

.
.
.
CALL SUB4.
.
.
.
STOP RUN.

IDENTIFICATION DIVISION.
PROGRAM-ID.

SUB4.

1 1

.
.
.
EXIT PROGRAM.

12.2.1 The INITIAL Clause

A COBOL program with an INITIAL clause is returned to its initial state
whenever that program exits. This ensures that it will be in its initial state the
next time it is called.

During this initialization process, all internal program data whose description
contains a VALUE clause is initialized to that defined value. Any item whose
description does not include a VALUE clause will be initialized, and contain an
undefined value.

When an INITIAL clause is present and when the program is called, an implicit
CLOSE statement executes for all files in the open mode associated with internal
file connectors.

12–4 Interprogram Communication

Advertising