COBOL Manual for TNS and TNS/R Programs
Source Text Manipulation
HP COBOL Manual for TNS and TNS/R Programs—522555-006
10-18
REPLACE Statement
The REPLACE statement in Example 10-3 enables you to declare a name for a
constant in your program, then use that name in various places in a program.
While OFFICES could have been declared as a data-item for this purpose, SQ-FT-
SIZE could not have.
Of course, with either EDIT or PS Text Edit (TEDIT), you could easily change all
instances of reserved words in a source program to another word; but if your data
dictionary contains any fields whose names have become reserved words, you
might find the REPLACE statement a handy tool. The REPLACE operation occurs
conceptually after the COPY operation, but before the remainder of the
compilation.
Example 10-3. REPLACE Statement
DATA DIVISION.
REPLACE ==OFFICES== BY ==10==
==SQ-FT-SIZE== BY ==5==.
...
01 OFFS.
03 OFFICE-INFO OCCURS OFFICES TIMES.
05 DISTRICT PICTURE 99.
05 SQUARE-FEET PICTURE S9(SQ-FT-SIZE).
...
PROCEDURE DIVISION.
...
PERFORM REPORT-OFFICE OFFICES TIMES.
...