COBOL Manual for TNS/E Programs (H06.03+)
Program Compilation
HP COBOL Manual for TNS/E Programs—520347-003
11-5
Compilation Units
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 11-2 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 11-2 with the ECOBOL
compiler is:
ECOBOL /IN CSOURCE/ COBJECT
COBJECT is called the target file. It contains the object programs that the compiler
produces.
Example 11-2. Compilation Unit (page1of2)
IDENTIFICATION DIVISION.
PROGRAM-ID. CPGM1.
* CALLED PROGRAM 1.
...
DATA DIVISION.
...
LINKAGE SECTION.
01 LS-NAMES.
03 LS-A-NAME PICTURE X(30).
03 LS-B-NAME PICTURE X(30).
...
END PROGRAM CPGM1.










