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

Example 230 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).
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 230 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:
01 STARTING-EMPLOYEE PICTURE 9(6).
To use the library in Example 230 as a SOURCE library, include a line like this in your source
program:
?SOURCE file-name (NAMEREC,ZOO-FILE)
where file-name is the name of the file containing the library text in Example 230. The effect
is the same as including these lines in your source program:
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).
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
758 Creating and Compiling HP COBOL Source Programs