COBOL Manual for TNS and TNS/R Programs

Creating and Compiling HP COBOL Source
Programs
HP COBOL Manual for TNS and TNS/R Programs522555-006
22-38
Replacing Text-Words From COPY Libraries
Replacing Text-Words From COPY Libraries
The compiler processes REPLACE statements after it has processed any COPY
statements. REPLACE statements do not change COPY libraries.
In Example 22-11, the compiler substitutes OFFICES for COPY OFFNUM and SQ-FT-
SIZE for COPY AREA first and then substitutes 10 for OFFICES and 5 for SQ-FT-
SIZE.
If the COPY statement has a REPLACING phrase, the compiler applies the
REPLACING phrase before applying the REPLACE statement. For an example of a
COPY statement with a REPLACING phrase, see Copying With Replacement.
Example 22-11. Replacing Text-Words From a COPY Library
Source code:
REPLACE ==OFFICES== BY ==10==
==SQ-FT-SIZE== BY ==5==
01 OFFS.
03 OFFICE-INFO OCCURS COPY OFFNUM. TIMES.
05 DISTRICT PICTURE 99.
05 SQUARE-FEET PICTURE S9(COPY AREA.)
REPLACE OFF
Lines in default COPY library:
?SECTION OFFNUM
OFFICES
?SECTION AREA
SQ-FT-SIZE
Resulting source code (COPY library is unchanged):
01 OFFS.
03 OFFICE-INFO OCCURS 10 TIMES.
05 DISTRICT PICTURE 99.
05 SQUARE-FEET PICTURE S9(5).