Merging an Array with an Externally Described DS Subfield

As mentioned earlier, you are not allowed to define a standalone array and a data structure subfield with the same name in RPG IV. In general, the Conversion Aid will merge these two definitions. However, if the subfield is in an externally described data structure, this merging is not handled and you will be required to manually correct the converted source member.

For example, the field ARRAY in Figure 1 is included twice in Figure 2. It is included once as a standalone array and once in the externally described data structure EXTREC. When converted, the RPG IV source generated is shown in Figure 3. This code will not compile since ARRAY is defined twice. In order to correct this problem, delete the standalone array and add a subfield with the keywords to data structure DSONE as shown in Figure 4.

Figure 1. DDS for external data structure
     A          R RECORD
     A            CHARACTER     10
     A            ARRAY         10
Figure 2. RPG III source using external data structure with array
     E                    ARRAY      10  1
     IDSONE     E DSEXTREC
     C           CHAR      DSPLY
     C                     SETON                     LR
Figure 3. RPG IV source with two definitions for the array
     D ARRAY           S              1    DIM(10)
     D DSONE         E DS                  EXTNAME(EXTREC)
     C     CHAR          DSPLY
     C                   SETON                                        LR
Figure 4. Corrected RPG IV source with a single definition for the array
     D DSONE         E DS                  EXTNAME(EXTREC)
     D  ARRAY        E                     DIM(10)
     C     CHAR          DSPLY
     C                   SETON                                        LR