COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
The statement a COBOL program uses to call another program depends on the language in which
the called program was written.
Table 70 Statements for Calling Programs
Statement for Calling ProgramLanguage of Called Program
CALLHP COBOL
ENTER or X/Open CALLHP C
ENTER or X/Open CALLHP C++
ENTER or X/Open CALLpTAL
Called programs are not required to be in the main program’s compilation unit (see Compilation
Units).
How an HP COBOL Program Calls a Non-COBOL Program
Any HP COBOL program can call a non-COBOL program with the ENTER statement. An HP COBOL
program that was compiled with the PORT directive can also call a non-COBOL program with the
X/Open CALL statement. The difference between the ENTER statement and the X/Open CALL
statement is that the ENTER statement attempts to coerce the actual parameters into the types of
the formal parameters, while the X/Open CALL statement reports an error if the types of the actual
and formal parameters do not match.
Just as HP COBOL object programs can be read from an object file and included in the target file
during the (optional) linking phase of ECOBOL compilation, object programs from other languages
can also.
NOTE: You cannot put any combination of TNS, TNS/R, or TNS/E object files into a single
object file.
Appendix B: Data Type Correspondence, shows the correspondence between HP COBOL data
items and those of the other languages with which an HP COBOL program can interact. HP COBOL
index names are entirely internal to their own program; they cannot be written, read, or passed
as parameters. Index data items in HP COBOL correspond to 32-bit integers.
Compilation Units
The source file that is input to the compiler is also called a compilation unit. A compilation unit
contains one or more “separately compiled programs.”A separately compiled program is a program
whose source text can be submitted to the compiler independently of any other source text. Each
such program can include nested programs, and any program can call other separately compiled
programs.
Submitting a sequence of separately compiled programs to the compiler as a compilation unit (in
a single compilation step) is called “stacked compilation.”
The end of each separately compiled program is ordinarily marked by an END PROGRAM
statement, although it can be marked with an ENDUNIT compiler directive with equivalent effect.
The last (or only) program in a compilation unit does not require an END PROGRAM statement or
an ENDUNIT directive. Separately compiled programs in a compilation unit can be in any order.
If there are compilation errors in some, but not all, programs in a compilation unit, the ECOBOL
compiler produces no object file.
Example 148: Compilation Unit shows a compilation unit in which a main program and two
called programs are included in the input file, contained in file CSOURCE.
The command to compile the compilation unit in Example 148: Compilation Unit with the ECOBOL
compiler is:
ECOBOL /IN CSOURCE/ COBJECT
514 Program Compilation










