COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
Example 235 Copying Into Debugging Lines
Source line:
D COPY DEB-DISP.
Library lines:
?SECTION DEB-DISP
DISPLAY KINGDOM PHYLUM CLASS ORDER
FAMILY GENUS SPECIES.
Compiled as:
D DISPLAY KINGDOM PHYLUM CLASS ORDER
D FAMILY GENUS SPECIES.
Using Multiple COPY Libraries
There is no limit to the number of COPY libraries the compiler can use in a single compilation. To
specify a nondefault COPY library, use an OF or IN phrase in the COPY statement; for example:
COPY RECORD1 OF LIBRARY3.
(where LIBRARY3 is on the default volume and subvolume) or:
COPY RECORD1 IN \NODE4.$VOL2.SUBVOL1.LIBRARY2.
(where LIBRARY3 is fully qualified).
Using COPY Libraries Efficiently
You can reduce the time the compiler spends searching for items in COPY libraries by putting the
most frequently used items in the front of their COPY libraries. The reason is that the first time the
compiler encounters a COPY statement, the compiler opens the default or specified COPY library
and reads until it finds the specified item, building a temporary directory of items as it reads them.
Subsequent COPY statements search the directory for items before searching libraries for them;
therefore, COPY statements that reference items already entered in the directory compile faster
than COPY statements that reference items not yet entered in the directory. If a specified item is
not yet in the directory, the compiler resumes reading the library after the last item in the directory,
continuing to build the directory.
Including Text From a SOURCE Library
Text from a SOURCE library is included in an HP COBOL source program with a SOURCE directive.
A SOURCE directive must be the last directive on its line.
When the compiler reads a SOURCE directive, it suspends reading from its primary source file
and begins reading (entire lines) from a specified section of a SOURCE library. The SOURCE
directive does not have anything like the COPY statement’s REPLACING phrase; it cannot replace
library text-words with different text-words.
The SOURCE directive’s most common uses are:
• To copy File Descriptions into the Environment Division
• To copy record or group descriptions into the Data Division
• To copy blocks of code lines into the Procedure Division
Example 236 Including Text From a Source File
Library file, SRCFILE:
?SECTION NAMEREC
01 NAME-REC.
03 LAST-NAME PICTURE X(15).
03 M-I PICTURE X(1).
03 FIRST-NAME PICTURE X(15).
Including Text From a SOURCE Library 765










