The EXTFLD keyword is used to rename a subfield in an externally described data structure. In a free-form definition, it is also used to indicate that the subfield is an external subfield.
Enter the external name of the subfield as the parameter to the EXTFLD keyword.
If a character literal is specified, the external name must be specified in the correct case. For example, if the external name is MYFIELD, the field-name parameter could be specified in a fixed-form definition as a name in mixed case such as myField or myfield, but if specified as a literal it must be 'MYFIELD'.
In the following example, three of the external field names in the file are NAME, ADR, and ID.
DCL-C ID_EXT_NAME 'ID'; 3a
DCL-DS custInfo EXTNAME('CUSTMAST');
name EXTFLD INZ('UNKNOWN'); 1a
address EXTFLD('ADR'); 2a
id_number EXTFLD(ID_EXT_NAME) INZ(-1); 3a
END-DS;
D custInfo E DS EXTNAME(custMast)
D name E INZ('UNKNOWN') 1b
D address E EXTFLD(adr) 2b
D id_number E EXTFLD('ID') INZ(-1) 3b
If the name is not a valid simple RPG name, it must be specified as a literal. For example, to rename external field A.B, specify EXTFLD('A.B').
The keyword is optional. If not specified, the name extracted from the external definition is used as the data-structure subfield name.
If the PREFIX keyword is specified for the data structure, the prefix will not be applied to fields renamed with EXTFLD. Figure 1 shows an example of the EXTFLD keyword with the ALIAS keyword.