COBOL Manual for TNS and TNS/R Programs
Creating and Compiling HP COBOL Source
Programs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
22-23
Using COPY and SOURCE Libraries
The only difference between a COPY library and a SOURCE library is context—a
library that is referenced by a COPY statement is called a COPY library, and a library
that is referenced by a SOURCE directive is called a SOURCE library. The important
differences between the COPY statement and the SOURCE directive are:
•
The COPY statement can replace specified text-words in the library text with
different text-words; the SOURCE directive cannot.
•
The SOURCE directive requires the name of the library file; the COPY statement
does not, as it can use the default COPY library.
•
The SOURCE directive can be in library text (that is, SOURCE directives can be
nested); the COPY statement cannot.
To use the library in Example 22-2 as a COPY library, include a line like this in your
source program:
01 STARTING-EMPLOYEE COPY EMPLOYEE-NUM-PIC.
The COPY statement and the period (.) that follows it are replaced. The effect is the
same as including this line in your source program:
Example 22-2. COPY or SOURCE Library
?SECTION NAMEREC
01 NAME-REC.
03 LAST-NAME PICTURE X(15).
03 M-I PICTURE X(1).
03 FIRST-NAME PICTURE X(15).
03 TITLE PICTURE X(5).
?SECTION STANDARD-LINAGE
LINAGE IS 55 LINES
WITH FOOTING AT 45
LINES AT TOP 5
LINES AT BOTTOM 6
?SECTION ZOO-FILE
ASSIGN TO "$A0101.ZOO.ROSTER"
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS ANIMAL-NUMBER
ALTERNATE RECORD KEY IS SPECIES WITH DUPLICATES
ALTERNATE RECORD KEY IS HABITAT WITH DUPLICATES
FILE STATUS IS ZOO-STAT
?SECTION EMPLOYEE-NUM-PIC
PICTURE 9(6).