How to rename a field in an IBM-i logical file

How Field Renaming Works in a Logical File (DDS)

IBM’s DDS for logical files supports the RENAME(fieldname) keyword. You place it on the logical file field definition, and the parameter is the physical file field name you want to map from.

A            NewFieldName      RENAME(OldPhysicalField)

Example from IBM Docs

Renaming PF field QTYDUE to LF field QTY:

A            QTY             RENAME(QTYDUE)

Practical Example (More Complex)

From RPGPGM’s example, renaming PF field PFLD4 to LFLD1 in the LF:

A            LFLD1           RENAME(PFLD4)

You can even rename the same PF field multiple times with different data types (useful for mapping date fields, packed fields, etc.). IBM confirms this is allowed: one PF field may be renamed to multiple LF fields.

Why You Might Rename a Field

IBM lists several reasons:

  • Program uses a different field name than the PF.

  • High‑level language restrictions (e.g., RPG III storage rules).

  • Mapping one PF field to multiple LF fields (e.g., different data types).

Full Minimal LF Example

A      R MYLFR       PFILE(MYPF)
A        CUSTNAME    RENAME(CUNM)
A        ORDERQTY    RENAME(QTYDUE)
A      K ORDERQTY

This creates a logical file where:

  • CUNMCUSTNAME

  • QTYDUEORDERQTY

  • And ORDERQTY is used as a key.

Important Notes

  • RENAME only changes the LF field name, not the PF.

  • Data storage is shared — the renamed field still points to the same bytes in the PF.

  • If you rename the same PF field multiple times, the last one wins on update/insert.

Want the SQL Equivalent?

If you’re using SQL logical views, you rename fields using AS:

CREATE VIEW MYVIEW AS
SELECT QTYDUE AS ORDERQTY
FROM MYPF;
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>