COBOL Manual for TNS and TNS/R Programs
Calling Other Programs and Routines
HP COBOL Manual for TNS and TNS/R Programs—522555-006
23-3
Calling Other COBOL Programs
For more information about writing programs that use the services provided by the
CRE, see the CRE Programmer’s Guide.
Calling Other COBOL Programs
A HP COBOL program calls another HP COBOL program with a CALL statement. The
called program can be either a separately compiled HP COBOL program or a nested
HP COBOL program. A nested program is usually accessible to more calling programs
if it is a common program.
If a called program is an initial program, its program state is initialized whenever it is
called.
The CALL statement can call another program statically (with the program specified at
compilation time) or dynamically (with the program specified at run time). The former is
more efficient; the latter is more flexible.
The CALL statement can pass parameters from the calling program to the called
program either by reference (the default) or by content.
Topics:
•
Separately Compiled HP COBOL Programs
•
Nested HP COBOL Programs
•
Common Programs
•
Initial Programs
•
Static Calls
•
Dynamic Calls
Separately Compiled HP COBOL Programs
A separately compiled program is an HP COBOL source program that is not nested
within any other program. A compilation unit—a collection of source statements
presented to a compiler in one compilation—contains one or more separately compiled
programs. Separately compiled programs in the same compilation unit can call each
other.
Any separately compiled program with no Linkage Section can be a main program
(that is, the program with which execution begins). If more than one of the programs in
a compilation unit has no Linkage Section, one program must include a MAIN directive
to identify it as the main program.