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 1. The converted source also contains two source lines, as shown in Figure 2. 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 3, where the key fields INZ and EXTFLD have been combined and only one instance on the field CHAR is shown.
Figure 1. 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 2. 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 3. 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