COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
10 Source Text Manipulation
Source manipulation comprises the COPY statement, COPY libraries, and the REPLACE statement.
You can use the COPY and REPLACE statements in any division of the source program.
The COPY statement summons source text from a COPY library and delivers merged text to the
compiler. Its optional REPLACING phrase replaces every occurrence of a specified portion of
library text with a specified portion of new text when it copies library text into a source program.
You can specify more than one such replacement pair in a REPLACING phrase. With or without
the REPLACING phrase, the COPY statement does not change the COPY library or the source file.
The COPY statement appears in the listing unless a NOSHOWCOPY, NOLIST, or SUPPRESS
directive is active. The library text appears in the listing unless a NOLIST or SUPPRESS directive is
active.
In the Guardian environment, a COPY library is a file in the EDIT format. It contains one or more
sections of zero or more text lines, each preceded by a SECTION directive line and succeeded
by either another SECTION directive line or the end of the file.
In the OSS environment, a COPY library is an ASCII text file.
The REPLACE statement replaces source program text. It is useful for establishing names for constants
and abbreviations for words and phrases and for overcoming the introduction of new reserved
words into the language.
• COPY Statement
• REPLACING Phrase
• COPY Libraries
• REPLACE Statement
COPY Statement
COPY summons source text from a file set up as a COPY library. In many systems, one section of
code or data is common to several programs. Such a section can be written once, kept in a COPY
library, and inserted into each program at compile time by COPY statements. In HP COBOL, the
COPY statement is a mechanism for summoning text that is managed by the Data Definition
Language (DDL) compiler. (Another such mechanism is the SOURCE directive.)
COPY
is a reserved word that cannot be split across source program lines.
text-name
is the name of a section in a COPY library file. It is a COBOL word (1 to 30 letters, digits, and
hyphens but not all digits) that appears in a SECTION directive in the file.
COPY Statement 499










