COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
2 Source Program Organization and Format
The lines of a COBOL source program are organized into divisions. The program ends with an
END PROGRAM statement. Individual lines must follow a reference format that the compiler accepts.
Any line in a source program can contain a COPY statement, which tells the compiler to insert
source text from a specified disk file, called a COPY library.
A run unit can contain more than one source program. Programs in the same run unit can share
resources with each other. The programs can be nested, which means that one program contains
one or more other programs, which might in turn contain one or more other programs. A nested
program can be common, which means that it can be called by any other program contained in
the program that contains it. Nested programs are always in the same run unit; therefore, they can
share resources.
An initial program is one whose program state is initialized whenever any program in its run unit
calls it.
Source Program Components
The components of a COBOL source program must appear in the order shown in Table 6.
Table 6 Source Program Components
Explained in ChapterPurposeRequired or Optional?Component
5RequiredIdentification Division
• To specify the program name
(required)
• To specify your name, the date, and
the program purpose (optional)
6To describe the program’s equipment
and processing options and name the
OptionalEnvironment Division
files it uses (you must change this
information when you move a COBOL
program to an HP system from another
type of system)
7To define the data that the program
uses (reserve data storage; define data
OptionalData Division
formats, types, and structures; complete
file descriptions)
8To specify the program activity (the
data processing)
OptionalProcedure Division
2To mark the end of the programDepends—see PurposeEND PROGRAM
statement
If you submit only one program to the
compiler at a time, the END PROGRAM
statement is optional. If you compile
several programs (one after another or
nested), the END PROGRAM statement
is required for each program except the
one that ends last. You can use an
ENDUNIT directive instead of an END
PROGRAM statement.
The END PROGRAM statement has this syntax:
Source Program Components 43










