COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-31
CALL
For the programs in Example 9-8 to work properly, they must be compiled in this
order:
>COBOL85 /IN SUB2SRC, / SUB2OBJ
>COBOL85 /IN SUB1SRC, / SUB1OBJ
>COBOL85 /IN MAINSRC, / MAINOBJ
If you want to eliminate the SPECIAL-NAMES paragraphs from the programs in
Example 9-8, compile them, in the same order, with these additional directives:
In COBSUB1: ?SEARCH SUBOBJ2
In COBOLMAIN: ?SEARCH SUBOBJ1
If COBSUB2 is a TNS program, and it must be recompiled for a reason that does
not involve changes to the parameter list, you need not even recompile COBSUB1
or COBOLMAIN. You can simply rebind them, replacing the old version of
MAINOBJ with the new one (see the Binder Manual).
Output from running the programs in Example 9-8 as a single run unit looks like
this:
I'M THE MAIN AND I'M ALIVE
SAVE-TABLE-INDEX = 005
I'M SUBCOB1 ALIVE AND WELL
SAVE-SUB-INDEX = 005
10
AB
I'M COBSUB2 ALIVE AND WELL
10
AB
I WILL NOW RETURN TO THE MAIN PGM VIA COBSUB1
I'M COBSUB1 AND I'M RETURNING TO MAIN NOW
PROGRAM END
DATA DIVISION.
WORKING-STORAGE SECTION.
77 DATA-MESSAGE PIC X(80) VALUE "I'M COBSUB2 ALIVE AND WELL".
LINKAGE SECTION.
01 PARM1 PIC 99.
01 PARM2 PIC XX.
PROCEDURE DIVISION USING PARM1, PARM2.
START-PROGRAM.
DISPLAY DATA-MESSAGE
DISPLAY PARM1
DISPLAY PARM2
DISPLAY "I WILL NOW RETURN TO THE MAIN PGM VIA COBSUB1".
Example 9-8. Called Program That Calls Another Program (page 3 of 3)