COBOL Manual for TNS and TNS/R Programs

Data Division
HP COBOL Manual for TNS and TNS/R Programs522555-006
7-41
CALL Statement and USING Phrase
Statements within the Procedure Division of the called program can refer to any items
defined in the Linkage Section of the program. Global items can be referenced by
contained programs. The Linkage Section can contain matched and unmatched items.
Matched items are those within a record that is specified in the USING phrase of the
Procedure Division header, within a record that is a redefinition of a matched record, a
level-77 item or a record that is in the USING phrase, or a redefinition of those. An
unmatched item is one not associated with the USING phrase.
The PORT directive determines the action taken for a reference to an unmatched item.
If the program was not compiled with the PORT directive, the compiler issues a
warning for any unmatched record or level-77 item. A reference to an unmatched item
can cause abnormal program termination, data corruption, or other failures. If the
program was compiled with the PORT directive, the SET ADDRESS OF statement can
make unmatched items accessible. A reference to an unmatched item for which no
address was set can cause abnormal program termination, data corruption, or other
failures.
Example 7-7. Correspondence Between Formal and Actual Parameters
These lines are in the calling program:
WORKING-STORAGE SECTION.
01 PARAMETER-TABLE.
02 ROW-PART OCCURS 20 TIMES.
03 COL-PART PIC 9999 COMPUTATIONAL
OCCURS 10 TIMES.
...
77 ROW PIC 99 COMPUTATIONAL.
77 COL PIC 99 COMPUTATIONAL.
...
PROCEDURE DIVISION.
...
CALL "SUBPROG1" USING ROW,
COL,
PARAMETER-TABLE.
...
These lines are in the called program:
LINKAGE SECTION.
01 PARM-3-IN-OUT.
04 FORMAL-ROW OCCURS 20 TIMES.
07 FORMAL-COLUMN PIC 9999 COMPUTATIONAL
OCCURS 10 TIMES.
77 PARM-R PIC 99 COMPUTATIONAL.
88 ROW-WITHIN-RANGE VALUE IS 1 THROUGH 20.
77 PARM-C PIC 99 COMPUTATIONAL.
88 COLUMN-WITHIN-RANGE VALUE IS 1 THROUGH 10.
...
PROCEDURE DIVISION USING PARM-R, PARM-C, PARM-3-IN-OUT.
...