The REPLACE statement is used to replace source program text.
The REPLACE statement can occur anywhere in the source program where a character-string can occur. It must be preceded by a separator period except when it is the first statement in a separately compiled program. It must be terminated by a separator period.
The REPLACE statement resembles the REPLACING phrase of the COPY statement, except that it acts on the entire source program, not just the text in COPY libraries.
REPLACE Statement - Format 1 >>-REPLACE------------------------------------------------------> .--------------------------------------------------. V | >----==--pseudo-text-1--==--BY--==--pseudo-text-2--==-+--.-----><
REPLACE Statement - Format 2 >>-REPLACE--OFF--.---------------------------------------------><
Pseudo-text-1 must contain at least one text word other than a separator comma or separator semicolon. Beginning and ending spaces are not included in the text comparison process, and multiple embedded spaces are considered to be a single space.
Pseudo-text-2 does not need to contain a text word; it may consist solely of space characters and/or comment lines.
Since pseudo-text-1 requires a text word, which must be bounded by separators, pseudo-text cannot be used to replace part of a data name (for example, a prefix); the entire data name must be used.
Pseudo-text-1 or pseudo-text-2 can contain DBCS or national character-strings. Such pseudo-text cannot be continued across lines.
When a REPLACE statement is in effect, there are certain restrictions on the layout of a Format 2 - DDS Translate COPY statement. (See COPY Statement - Format 2 - DDS Translate.)
REPLACE statements are processed after all COPY statements have been processed. The text that results from the processing of a REPLACE statement must not include a REPLACE statement.