HP 3000 Manuals

Reference to Common Data through Parameter Passing [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation


HP COBOL II/XL Reference Manual

Reference to Common Data through Parameter Passing 

Because a called program often accesses data that is also used by the
calling program, both programs must have access to the same data items if
you wish to pass data to, or return data from, the called program.

In the calling program, it does not matter which section in the DATA
DIVISION is used to describe the common data.

In the called COBOL program, however, common data must be described in
the LINKAGE SECTION of the DATA DIVISION under 01 or 77 level description
entries.  Unlike the data in the calling program, no storage is allocated
for LINKAGE SECTION items when the calling program is compiled.

Communication between the called COBOL program and the common data items
stored in the calling program is provided by the USING clauses in both
the calling and the called program.

The USING clause in the calling program is part of the CALL statement.
It lists the names of common data items described in the DATA DIVISION.

In the called COBOL program, the USING clause appears as part of the
PROCEDURE DIVISION header, or of the ENTRY statement.  The common data
items, which must be described in the LINKAGE SECTION, are listed by this
clause.

Despite how the data items are described in the calling program, they are
processed according to how they are described in the LINKAGE SECTION of
the called program.

The only restriction is that descriptions of common data items must
define an equal number of character positions.

Common data items are related to each other in the calling and called
COBOL programs by their positions in the USING clauses, not by their
names.

This implies that you may use entirely different names in the called
program to represent common data items of the calling program.

For example, if EMP-INFO is the fourth name in the USING clause of a
calling program and FOURTH-PASSED is the fourth name in the USING clause
of the called program, then any reference to FOURTH-PASSED is treated as
if it were a reference to the corresponding data item EMP-INFO in the
calling program.

Also, although you may not use the same name twice within the USING
phrase of a called program, you may do so in the USING phrase of the
calling program.  This allows you to have a data item in the calling
program related to more than one data name in the called program.



MPE/iX 5.0 Documentation