The /COPY compiler directive causes records from other files to be inserted, at the point where the /COPY occurs, with the file being compiled. The inserted files may contain any valid specification except /COPY.
The /COPY statement is entered in the following way:
libraryname/filename,membername (RPG/400 AS/400 environment)
Examples of the /COPY Compiler Directive Statement shows some examples of the /COPY directive statement.
For more information see How the Compiler Recognizes a Compiler /COPY, Conditions on the Members That Are Copied, Sequence Numbering of the Listing after a Compile, and Results of the /COPY during Compile.
Use the rules for RPG/400 symbolic names, to specify the library files and member.
Examples of the /COPY Compiler Directive Statement
C/COPY MBR1 1 I/COPY SRCFIL,MBR2 2 O/COPY SRCLIB/SRCFIL,MBR3 3 O/COPY "SRCLIB!"/"SRC>3","MBR^3" 4
If the member being copied from is not a source type file, meaning that the file was not created with the filetype *SRC, then a message is issued. This condition does not stop compilation and the copy function is still processed.
The members being copied can contain any valid RPG/400 specifications except another /COPY directive.
The member being copied can contain a control specification (form type H), which is then processed as if it were part of the source code. Therefore, the first statement in the program can be a /COPY directive pointing to the member containing the control specification. The H specification must still follow the rules governing its use (refer to Control Specifications) and precede any other RPG/400 specification.
During compilation, the specified file members are merged into the program at the point where the /COPY statement occurs. Any overrides defined that apply to the specified file and member are ignored.
For an RPG/400 compile, the low-order 6 digits of the 8-character sequence number in the listing reflect the original source sequence number of the /COPY member. In this way you can correlate the compiler listing sequence numbers (the last 6 digits) to the source member sequence numbers (in SEU).
The high order 2 digits of the sequence number are made up of the characters A through Z and 0 through 9 in the following order: A, B, C, ..., Z, 1, 2, ..., 9, A0, AA, AB, ..., AZ, A1, A2, ..., A9, B0, BA, ..., ZZ, ..., Z9, 10, ..., 99.
This structure allows for up to 1295 different increments of the high order sequence number.
Each /COPY directive causes the high order 2 characters of the sequence number for all the code lines brought in by this /COPY to be incremented in value.
If the copied code contains specifications for externally defined files, each externally defined file may cause the high-order characters of the sequence number to be incremented in value two more times: once for input specifications, and once for output specifications.
If more than 1295 increments result from /COPY directives and/or externally defined files, a message is issued. A message is also issued if more than 50 externally defined files are specified. Remember that one externally defined file can take up two increments: for input and output specifications.
The low order 6 digits of the sequence number is incremented by one for each I specification generated for an externally defined file.
If the program is compiled by RPG/400, records that are copied into the program in this way contain a "+" adjacent to the sequence number field on the left side of the listing, between the sequence number and the form type field. If the Program Verifier is used, the lines from the copied file are identified on the listing by line numbers which start at 100001. For example, the third line in the first copied file would be 100003 and the seventh line of the fourth copied file would be 400007.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.