Friday, November 18, 2011

Redefines & Renames


REDEFINES

The REDEFINES clause allows you to use different data description entries to describe the same computer storage area. Redefining declaration should immediately follow the redefined item and should be done at the same level. Multiple redefinitions are possible. Size of redefined and redefining need not be the same.

Example:
          01 WS-DATE PIC 9(06).
          01 WS-REDEF-DATE REDEFINES WS-DATE.
                   05      WS-YEAR       PIC 9(02).
                   05      WS-MON       PIC 9(02).
                   05      WS-DAY        PIC 9(02).

RENAMES

It is used for regrouping of elementary data items in a record. It should be declared at 66 level. It need not immediately follows the data item, which is being renamed. But all RENAMES entries associated with one logical record must immediately follow that record's last data description entry. RENAMES cannot be done for a 01, 77, 88 or another 66 entry.
          01 WS-REPSONSE.
                   05 WS-CHAR143       PIC X(03).
                   05 WS-CHAR4 PIC X(04).
                   66 ADD-REPSONSE RENAMES WS-CHAR143.

No comments:

Post a Comment