ILE RPG Programmer's Guide


Renaming and Initializing an Externally Described DS Subfield

In RPG III, when both renaming and initializing a field in an externally described data structure, you had to use two source lines, as shown for the field CHAR in Figure 237. The converted source also contains two source lines, as shown in Figure 238. This use of two source lines for a field will result in a compile-time error, as the field CHAR is defined twice. To correct this code you must combine the keywords of the field CHAR into a single line as shown in Figure 239, where the key fields INZ and EXTFLD have been combined and only one instance on the field CHAR is shown.

Figure 237. RPG III source with renamed and initialized external subfield
     IDSONE     E DSEXTREC
     I              CHARACTER                       CHAR
     I I            'XYZ'                           CHAR
     C           CHAR      DSPLY
     C                     SETON                     LR
Figure 238. RPG IV source with two definitions for renamed subfield
     D DSONE         E DS                  EXTNAME(EXTREC)
     D  CHAR         E                     EXTFLD(CHARACTER)
     D  CHAR         E                     INZ('XYZ')
     C     CHAR          DSPLY
     C                   SETON                                        LR
Figure 239. Corrected RPG IV source with a single definition
     D DSONE         E DS                  EXTNAME(EXTREC)
     D  CHAR         E                     EXTFLD(CHARACTER) INZ('XYZ')
     C     CHAR          DSPLY
     C                   SETON                                        LR

[ Top of Page | Previous Page | Next Page | Contents | Index ]