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

Replacing Substrings
The REPLACING phrase can only replace entire text-words (DAILY-TOTAL but not just TOTAL, for
example); however, parenthesized words within pseudo-text are recognized as text-words, allowing
you to write statements such as:
COPY SUM-IT REPLACING ==(PREFIX)== BY ==DAILY==.
Suppose that you want to declare several identifiers that begin with the same prefix (such as
DAILY-TOTAL, DAILY-MINIMUM, and DAILY-MAXIMUM), several identifiers that end with the same
suffix (such as DAILY-TOTAL, WEEKLY-TOTAL, and MONTHLY-TOTAL), and several identifiers that
contain the same strings (such as AVG-DAILY-COST, AVG-MONTHLY-COST, and
AVG-ANNUAL-COST).
Example 234 Replacing Substrings
Lines in COPY library:
?SECTION PREFIX
77 (PREFIX)-TOTAL PIC S9(8).99.
77 (PREFIX)-MINIMUM PIC S9(8).99.
77 (PREFIX)-MAXIMUM PIC S9(8).99.
?SECTION SUFFIX
77 DAILY-(SUFFIX) PIC S9(8).99.
77 WEEKLY-(SUFFIX) PIC S9(8).99.
77 MONTHLY-(SUFFIX) PIC S9(8).99.
?SECTION PRESUF
77 (PRE)-DAILY-(SUF) PIC S9(8).99.
77 (PRE)-MONTHLY-(SUF) PIC S9(8).99.
77 (PRE)-ANNUAL-(SUF) PIC S9(8).99.
Lines in HP COBOL source program:
COPY PREFIX REPLACING ==(PREFIX)== BY ==DAILY==.
COPY SUFFIX REPLACING ==(SUFFIX)== BY ==TOTAL==.
COPY PRESUF REPLACING ==(PRE)== BY ==AVG==
==(SUF)== BY ==COST==.
HP COBOL source program effectively contains these lines:
77 DAILY-TOTAL PIC S9(8).99.
77 DAILY-MINIMUM PIC S9(8).99.
77 DAILY-MAXIMUM PIC S9(8).99.
77 DAILY-TOTAL PIC S9(8).99.
77 WEEKLY-TOTAL PIC S9(8).99.
77 MONTHLY-TOTAL PIC S9(8).99.
77 AVG-DAILY-COST PIC S9(8).99.
77 AVG-MONTHLY-COST PIC S9(8).99.
77 AVG-ANNUAL-COST PIC S9(8).99.
Copying Into Debugging Lines
When the source line containing the word COPY is a debug line (has a D or d in the indicator
area), the compiler changes each library line that has a space in its indicator area to a debug
line.
764 Creating and Compiling HP COBOL Source Programs