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.
In a free-form definition, the EXTFLD keyword must be the first keyword.
If the name of the subfield is the same as the external name of the
field, the parameter is optional.
If specified, the external name must be specified as a character literal
or a named constant.
If it is a
named constant, the constant must be defined prior to the definition
statement.
In a fixed-form definition, enter the external name of the subfield as the parameter to
the EXTFLD keyword, and specify the name to be used in the program in the
Name field (positions 7-21).
The external name can be either a simple name
or a character literal.
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.