COBOL Manual for TNS and TNS/R Programs

Calling Other Programs and Routines
HP COBOL Manual for TNS and TNS/R Programs522555-006
23-5
Common Programs
An HP COBOL program can call any program directly contained within itself and any
other separately compiled program. It cannot call a program indirectly contained within
itself. The programs in Figure 23-1 can call each other:
Common Programs
If a program has the COMMON clause in its Identification Division, it is called a
common program, and it can be called by any program directly or indirectly contained
in the program that directly contains it. In Figure 23-1, if Aaa, Bbb, and Ccc are
common, the programs in Figure 23-1 can call each other:
You gain no performance benefits by making Ddd common.
Initial Programs
If a program has the INITIAL clause in its Identification Division, it is an initial program.
Its program state is initialized whenever it is called. The data in its Working-Storage
Section is allocated when it is called rather than being statically allocated. For more
information about initial programs, see Initial Programs.
Static Calls
A static call is achieved with the statement CALL program-name, where program-
name is an alphanumeric literal whose value is known at compilation time. program-
name is the PROGRAM-ID of the called program, and it can be qualified with the
phrase OF file-mnemonic or IN file-mnemonic.
The program ...
Can call the program ...
Mane Aaa Bbb Ccc Ddd Sub
Mane X X X
Aaa X
Bbb X X
Ccc X X
Ddd X
Sub X
The program ...
Can call the program ...
Mane Aaa Bbb Ccc Ddd Sub
Mane X X X
Aaa X X
Bbb XXX
Ccc X X X X
Ddd XXX X
Sub X