Because of differences between the RPG III and RPG IV languages, the Conversion Aid must reorder certain source statements. An example of this reordering is shown in Example of Source Conversion for the RPG III source member TEST1. If you compare the placement of the data structure DS1 in Figure 221 and in Figure 222, you can see that the data structure DS1 was moved so that it precedes the record format FORMAT1.
Now suppose that the RPG III member TEST1 was split into two members, TEST2 and COPYDS1, where the data structure DS1 and the named constant CONST1 are in a copy member COPYDS1. This copy member is included in source TEST2. Figure 228 and Figure 229 show the source for TEST2 and COPYDS1 respectively.
H TSTPGM
FFILE1 IF E DISK COMM1
FQSYSPRT O F 132 OF LPRINTER
LQSYSPRT 60FL 56OL
E ARR1 3 3 1 COMM2
E ARR2 3 3 1
IFORMAT1
I OLDNAME NAME
/COPY COPYDS1
C ARR1,3 DSPLY
C READ FORMAT1 01
C NAME DSPLY
C SETON LR
C EXCPTOUTPUT
OQSYSPRT E 01 OUTPUT
O ARR2,3 10
**
123
**
456
I* DATA STRUCTURE COMMENT
IDS1 DS
I 1 3 FIELD1
I* NAMED CONSTANT COMMENT
I 'XYZ' C CONST1 COMM3
I 4 6 ARR1
In this situation, the Conversion Aid would convert both member TEST2 and the copy member COPYDS1 correctly. However, when the copy member is included at compile time, it will be inserted below FORMAT1, because this is where the /COPY directive is located. As a result, all source lines in the copy member COPYDS1 will get a "source record is out of sequence" error. In RPG IV, definition specifications must precede input specifications.
Note that the Conversion Aid could not move the /COPY directive above FORMAT1 because the contents of /COPY member are unknown.
There are two methods of correcting this type of problem:
This approach is easy and will work most of the time. However, including the /COPY members in each source member reduces the maintainability of your application.
Other examples of this type of problem include:
In RPG III the line counter specification and the Record Address File of the extension specification are changed to keywords (RAFDATA, FORMLEN, and FORMOFL) on the file description specification. If the content of a /COPY member contains only the line counter specification and/or the Record Address File of the extension specification but not the corresponding file description specification, the Conversion Aid does not know where to insert the keywords.
As mentioned in Example of Source Conversion, you are not allowed to define a standalone array and a data structure subfield with the same name in RPG IV. Therefore, as shown in the example TEST1 ( Figure 222), the Conversion Aid must merge these two definitions. However, if the array and the data structure subfield are not in the same source member (that is, one or both is in a /COPY member), this merging cannot take place and a compile-time error will result.
As shown in the example TEST1 ( Figure 222), if compile-time arrays are merged with data structure subfield definitions, the loading of array data may be affected. To overcome this problem, compile-time array data are changed to the new **CTDATA format if at least one compile-time array is merged. However, if the arrays and the data do not reside in the same source file (that is, one or both is in a COPY member) the naming of compile-time data records using the **CTDATA format cannot proceed properly.