COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

COPY Libraries
Any line in a source program can contain a COPY statement, which tells the COBOL compiler to
insert source text from a specified disk file, called a COPY library.
A COPY library is an EDIT or OSS ASCII file divided into one or more sections that begin with a
SECTION directive. In the COPY library, you can specify the reference format of the line or lines
to be copied.
You can specify the name of a COPY library in the source program or in a command to compile
the program:
The COPY statement itself can include the phrase IN library-name (see COPY Statement
(page 499)).
The command that initiates the compilation can specify a library-name for the compiler
to use whenever a COPY statement does not include a library-name (see Starting a
Compilation (page 529)).
If you do not specify a library-name in the compile command or in the COPY statement, the
compiler uses the name COPYLIB.
If you do not fully qualify library-name in the compile command or in the COPY statement,
the compiler assumes the library file is on the current default volume or subvolume or both.
For details on the COPY statement and COPY libraries, see COPY Statement (page 499).
Nested Source Programs
Source programs can be nested (that is, a source program can contain other source programs).
One program can contain another program directly or indirectly. When a program directly or
indirectly contains other programs, each program can use the same user-defined names for different
objects.
Topics:
Directly Contained Programs and Indirectly Contained Programs
Scope of User-Defined Names
Directly Contained Programs and Indirectly Contained Programs
One program can contain another program directly or indirectly. Suppose a program, L, contains
another program, R. Program L directly contains program R when program L does not contain any
other program that also contains program R. Program L indirectly contains program R if program
L does contain any other program that contains program R.
In Figure 2, all the programs are in the same run unit and:
And indirectly contains Directly contains The program
Ccc, DddAaa, BbbMane
NothingNothingAaa
DddCccBbb
NothingDddCcc
NothingNothingDdd
NothingNothingSub
48 Source Program Organization and Format