ALIAS

When the ALIAS keyword is specified for an externally-described file, the RPG compiler will use the alias (alternate) names, if present, when determining the subfield names for data structures defined with the LIKEREC keyword. When the ALIAS keyword is not specified for the RPG file, or an external field does not have an alias name defined, the RPG compiler will use the standard external field name.

Note:
If the alternate name for a particular external field is enclosed in quotes, the standard external field name is used for that field.

The ALIAS keyword is allowed for an externally-described file for which the RPG compiler will not generate Input or Output specifications. This includes files defined with the TEMPLATE or QUALIFIED keyword, and local files defined in subprocedures.

When the PREFIX keyword is specified with the ALIAS keyword, the second parameter of PREFIX, indicating the number of characters to be replaced, does not apply to the alias names. In the following discussion, assume that the file MYFILE has fields XYCUSTNM and XYID_NUM, and the XYCUSTNM field has the alias name CUSTOMER_NAME.

Figure 113. Using the ALIAS keyword for an externally-described file
 * The DDS specifications for file MYFILE, using the ALIAS keyword 
 * for the first field to associate the alias name CUSTOMER_NAME 
 * with the CUSTNM field 
A          R CUSTREC
A            CUSTNM        25A         ALIAS(CUSTOMER_NAME)
A            ID_NUM        12P 0

 * The RPG source, using the ALIAS keyword:
Fmyfile    if   e             disk    ALIAS QUALIFIED
 * The subfields of the LIKEREC data structure are
 *    CUSTOMER_NAME (using the ALIAS name)
 *    ID_NUM        (using the standard name) 
D myDs            ds                  LIKEREC(myfile.custRec)
 /free
     read myfile myDs;
     if myDs.customer_name <> *blanks
     and myDs.id_num > 0;
       ...


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