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

If the word COPY appears either in a comment-entry or in a place where a comment-entry
can appear, it is considered part of the comment-entry, not as the keyword that begins
a COPY statement.
The keyword COPY must be preceded by a space character, unless it immediately follows
the indicator field.
A COPY statement cannot appear on the same line as an SQL/MP or SQL/MX statement.
All four characters of the keyword COPY must appear on the same source text line. The
remainder of the statement can extend across additional program text lines, in accordance
with the continuation conventions of the reference format.
How the Compiler Processes a COPY Statement
The compiler processes a source program that includes COPY statements as though the compiler
included a preprocessor that performs these operations in this order:
1. Locates each COPY statement
2. Replaces the COPY statement with the appropriate (and possibly edited) library text
3. Passes the resulting text to the compiler proper
The effect of processing a COPY statement is to copy the specified library text into the source
program. The copied text logically replaces the entire COPY statement, beginning with the
keyword COPY and ending with the punctuation character period.
If the source line on which the COPY statement begins contains other text preceding the word
COPY, the compiler attempts to combine that portion of the line with the first library text line.
If the source line on which the COPY statement ends contains other text following the terminating
period, the compiler attempts to combine that portion of the line with the last library text line.
Compiler Directives and the COPY Statement
A compiler directive line cannot appear between the keyword COPY and the period separator
that terminates the statement, unless it is part of pseudo-text (see REPLACE Statement).
Compiler Directives in Library Text
Library text can include compiler directives, which the compiler obeys when it analyzes the
copied text.
If a TANDEM or ANSI format directive occurs as a qualifier on the SECTION directive in the
library file, the specified formatting is active only for the copied text. When the copying is
complete, the previous formatting is again active.
If a TANDEM or ANSI format directive occurs within the library text, its effect (which overrides
the effect of any format directive that is a qualifier on the SECTION directive) persists until the
copying is complete.
Debugging Lines and the COPY Statement
If the COPY statement itself begins on a debugging line (a line that has a D or d in the indicator
field), all text that the copy operation introduces into the source program, except comment
and compiler directive lines, appears on debugging lines.
Because debugging lines and continuation lines are mutually exclusive, the compiler cannot
introduce a continued text-word into the source text when the preceding rules require it to
appear on debugging lines.
Sensitivity to Reference Format
Because the compiler analyzes pseudo-text without the benefit of any contextual information,
you must observe the COBOL reference format rules carefully. In particular, the compiler does
not identify a comma, semicolon, or period character as a separator unless it is followed by
at least one space character.
COPY Statement 501