LINKAGE SECTION [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
LINKAGE SECTION
The LINKAGE SECTION consists of the header, "LINKAGE SECTION", and one or
more data description entries for noncontiguous data items, as well as
record description entries.
The LINKAGE SECTION in a program is meaningful only if the object program
is to be called from another object program through a CALL statement, and
the CALL statement in the calling program contains a USING phrase. See
Chapter 11 , "Interprogram Communication", for more information on how
calling programs and called programs operate.
The LINKAGE SECTION is used to describe the data that is available from
the calling program, but is to be used in both the calling program and
the called program.
No space is allocated in the program containing a LINKAGE SECTION entry
for the data items described in such an entry. PROCEDURE DIVISION
references to these data items are resolved at object time by equating
the reference in the called program to the location used in the calling
program.
In the case of index names, no such correspondence is established. Index
names are always local to their programs. Therefore, such names in the
called and calling program always refer to separate indices. If index
names are to be passed between programs, they should first be saved in a
data item described in the WORKING-STORAGE SECTION as an index data item.
A SET statement in the PROCEDURE DIVISION accomplishes this. Next, the
index data item should be passed to the called program by the USING
option of the CALL statement in the PROCEDURE DIVISION. Once the index
data item is passed, a SET statement in the called program can be used to
set the index value to the index name declared in the LINKAGE SECTION of
the called program.
Data items defined in the LINKAGE SECTION of the called program may be
referenced within the PROCEDURE DIVISION of the called program only under
the following conditions:
* If they are specified as operands of the USING phrase of the
PROCEDURE DIVISION header[REV BEG] or ENTRY statement[REV END] or
are subordinate to such operands.
* If the object program is under the control of a CALL statement
that specifies the USING phrase.
All data description clauses may be used in the LINKAGE SECTION, with the
restriction that a VALUE clause can only be used in a condition name
(level 88) entry.
The VALUE clause cannot be used in any other type of entry because no
memory space is allocated for LINKAGE SECTION data items.
The LINKAGE SECTION has the following format:
MPE/iX 5.0 Documentation