EXTFLD{(field_name)}

Start of changeThe 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.End of change

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.

  1. Subfield name is initialized to 'UNKNOWN'.
    1. In the free-form version of the code, the parameter for EXTFLD is not needed because the subfield name is the same as the external name.
    2. In the fixed-form version of the code, the EXTFLD keyword is not specified, because the subfield is not being renamed.
  2. Subfield address is renamed from external field ADR.
    1. In the free-form version of the code, the external name is specified as a literal.
    2. In the fixed-form version of the code, the external name is specified as a simple name.
  3. Subfield id_number is renamed from external field ID and initialized to -1.
    1. In the free-form version of the code, the external name is specified as a named constant, ID_EXT_NAME whose value is 'ID'.
    2. In the fixed-form version of the code, the external name is specified as a literal.
  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.