RENAME (Rename) keyword—logical files only

Use this field-level keyword when you want a field name in the logical record format that you are defining to be different from its corresponding physical file field name.

The format of the keyword is:
RENAME(physical-file-field-name)

The name as it appears in the physical file record format is the parameter value for this keyword. One field in the physical file record format can be renamed to more than one field in the record format being described.

You can rename fields in situations similar to the following ones:
  • You want to use programs that were written using a different name for the same field.
  • You want to map one field in a physical file record format to two or more fields in a logical file record format.
  • You are using a high-level language (such as RPG III) that does not permit two fields having different names to have only one data storage area. By specifying the RENAME keyword, you allow both fields to access the same data storage area.

If you specify the same physical field more than once in a record format in the logical file (that is, by using either RENAME or CONCAT), the sequence in which the fields are specified in the logical file is the sequence in which the data is moved to the physical file on an update or insert operation. Thus, the value in the last occurrence of the physical field is the value that is put in the physical record and is the value that is used for all keys built over that physical field. All previous values of the same field are written over and have no effect.

Examples

The following examples show how to specify the RENAME keyword.

In the following example, the QTYDUE field in the physical file (PF1) is renamed QTY in the logical file.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00050A          R RCD1                      PFILE(PF1)
00060A            QTY                       RENAME(QTYDUE)
     A

In the following example, the renamed field in the logical file (QTY) is used as a key field.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00050A          R RCD2                      PFILE(PF2)
00060A             :
     A             :
00130A            QTY                       RENAME(QTYDUE)
00140A          K QTY
     A