COPY Statement - Format 1 - Basic

Read syntax diagramSkip visual syntax diagram
COPY Statement - Format 1

>>-COPY--text-name---------------------------------------------->

>--+-------------------------------------------+---------------->
   '-+-OF-+--+--------------------+--file-name-'   
     '-IN-'  |                (1) |                
             '-library-name- -----'                

>--+--------------+--+-----------------------+--.--------------><
   |          (2) |  '-REPLACING--| phrase |-'      
   '-SUPPRESS-----'                                 

Notes:
  1. Required hyphen between library-name-file-name to qualify.
  2. IBM Extension
text-name
The text-name is the name of the member to be copied. The text-name must begin with an alphabetic character. The first 10 characters of the text-name are used as the member name; these first 10 characters must, therefore, be unique within one file.

Text-name can be qualified by the library-name and file-name in which it resides. If no file-name is specified, QCBLLESRC is assumed as the file-name. If the copy member is not found in default file QCBLLESRC then file QLBLSRC is searched next for the copy member. If the file-name is not qualified by a library-name, file-name is assumed to reside in a library in the library list. A hyphen is required between library-name and file-name, with no intervening spaces. For example, to qualify file MYFILE in library MYLIB code as MYLIB-MYFILE.

The library-name, file-name, and text-name must follow the rules for formation of a program-name.

library-name
The first 10 characters of the library-name are used as the identifying name; these first 10 characters must therefore be unique within the system. To qualify file-name, a hyphen is required between library-name and file-name with no intervening spaces.

Each COPY statement must be preceded by a space and ended with a separator period.

A COPY statement may appear in the source program anywhere a character string or a separator may appear; however, a COPY statement must not be specified within a COPY statement. The resulting copied text must not contain a COPY statement.

IBM Extension

COPY statements can be nested. However, nested COPY statements cannot contain the REPLACING phrase, and a COPY statement with the REPLACING phrase cannot contain nested COPY statements.

A COPY statement may not cause recursion. That is, a COPY member may be named only once in a set of nested COPY statements until the end-of-file for that COPY member is reached.

End of IBM Extension

Debugging lines are permitted within library text and pseudo-text. Text words within a debugging line participate in the matching rules as if the D did not appear in the indicator area. A debugging line is specified within pseudo-text if the debugging line begins in the source program after the opening pseudo-text-delimiter but before the matching closing pseudo-text-delimiter.

When a COPY statement is specified on a debugging line, the copied text is treated as though it appeared on a debugging line, except that comment lines in the text appear as comment lines in the resulting source program.

If the word COPY appears in a comment-entry, or in the place where a comment-entry may appear, it is considered part of the comment-entry.

After all COPY and REPLACE statements have been processed, a debugging line will be considered to have all the characteristics of a comment line, if the WITH DEBUGGING MODE clause is not specified in the SOURCE-COMPUTER paragraph.

Comment lines or blank lines may occur in library text. Comment lines or blank lines appearing in library text are copied into the resultant source program unchanged with the following exception: a comment line or blank line in library text is not copied if that comment line or blank line appears within the sequence of text words that match pseudo-text-1 (refer to Replacement and Comparison Rules).

The syntactic correctness of the entire COBOL source program cannot be determined until all COPY statements have been completely processed, because the syntactic correctness of the library text cannot be independently determined.

Library text copied from the library is placed into the same area of the resultant program as it is in the library. Library text must conform to the rules for Standard COBOL format.