COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

Example 40 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.
...
Index-Names
A Procedure Division reference to a Linkage Section data item in the called program refers to a
location in the calling program; however, this convention does not extend to index-names. The
index-name of a table in the calling program and the index-name of a table in the called program
always refer to separate indexes. This remains true even when the names of the indexes are the
same in the calling program and the Linkage Section of the called program. An index-name’s value
can be passed if it is saved in a separate item and then passed. (See the example under CALL
(page 293).)
Absent Linkage Section
If there is no Linkage Section in the called program, it looks like a main program to the compiler.
If you compile a main program and a subprogram with no parameters in the same compilation
session, you must include either a MAIN directive or an empty Linkage Section to tell the compiler
which program is the main one (see Main Programs (page 513)). If you do neither, the compiler
reports that it found two main programs.
Because the compiler interprets subprograms that have no parameters as main programs, if you
want to compile a collection of such subprograms, you need to direct the compiler not to attempt
to give any of them the main attribute. To do this, use a MAIN directive specifying a program-name
that does not correspond to the name of any program in the compilation.
Descriptions of Records (Levels 01-49)
A data description entry that starts at level-01 is a record description entry. It defines the
characteristics of a record, and is followed by subordinate data description entries for items that
are part of the record. You can put record description entries in any section in the Data Division.
182 Data Division