You are on page 1of 2

|********************************* TOP OF DATA ********************************|

|
*** REDEFINES CLAUSE ***
|
|
|
| The REDEFINES clause is an optional clause which can be specified as
|
| part of a data description entry. It allows a given storage area to be
|
| arranged or formatted in more than one way (by allowing for a given
|
| storage area to be described by more than one data description entry).
|
|
|
| The REDEFINES clause is formatted as shown below:
|
|
|
|
level-number data-name1/FILLER REDEFINES data-name2
|
|
|
| The REDEFINES clause must be the first entry following data-name1 or
|
| FILLER.
|
|
|
| Data-name1 is the name of the item associated with this data
|
| description entry; data-name2 is the name of the item being redefined.
|
| Both items must have the same level-number (which cannot be level 66 or
|
| 88).
|
|
|
| Multiple level-01 entries subordinate to an FD entry constitute
|
| implicit redefinition. In this case, the REDEFINES clause must not be
|
| used.
|
|
|
| Redefinition begins with data-name1 and ends with the first entry
|
| having a level-number less than or equal to that of data-name2.
|
|
|
| One or more redefinitions of the same storage area are permitted.
|
| Multiple redefinitions must all reference the data-name of the original
|
| entry that first defined the storage area and must immediately follow
|
| one another (i.e., without intervening items that are not part of any
|
| one of the redefinitions).
|
|
|
| Each of the redefinitions may alter the lengths as well as the formats
|
| of subordinate fields. However, if the redefined item has a level
|
| number other than 01, its length in bytes must not be less than that of
|
| any redefining item.
|
|
|
| The redefining items may not contain any VALUE clauses other than for
|
| condition-name entries.
|
|
|
| As an example:
|
|
|
|
05 FIELDA PIC X(09) VALUE 'ABCDEFGHI'.
|
|
05 FIELDB REDEFINES FIELDA.
|
|
10 FIELDX PIC S9(5) COMP-3.
|
|
10 FIELDY PIC X(6).
|
|
05 FIELDC REDEFINES FIELDA PIC X(5).
|
|
88 FIELDC-IS-SPACES VALUE SPACES.
|
|
05 FIELDD PIC S9(3) COMP-3 VALUE 0.
|
|
|
| FIELDA is redefined by FIELDB (which contains two subordinate items
|
| named FIELDX and FIELDY). Redefinition for FIELDB ends with FIELDC
|
| (which is at the same level as FIELDB). FIELDB is the same length (9
|
| bytes) as FIELDA but provides a different storage format.
|
|
|
| FIELDA is also redefined by FIELDC, which references FIELDA as the item
|
| being redefined (i.e., the first item defining this storage area).
|
| Redefinition for FIELDC ends with FIELDD (which is at the same level as
|
| FIELDC). FIELDC provides an alternative format which (at 5 bytes) is
|

| shorter than the area being redefined.


|
|
|
| FIELDA contains a VALUE clause which indicates the initial value for
|
| the storage area. Although FIELDB and FIELDC cannot contain VALUE
|
| clauses that would change the initial value specified by FIELDA's VALUE
|
| clause, note that FIELDC does contain a level-88 item which contains a
|
| VALUE clause.
|
|
|
| All descriptions for a redefined area are always in effect. And
|
| although the different descriptions share a common storage area, they
|
| are treated by the compiler (and at execution time) according to their
|
| data format and type and as if they were occupying separate storage
|
| areas.
|
|
|
| In the example above, the 9-byte area shared by FIELDA, FIELDB, and
|
| FIELDC
starts
off
initialized
to
'ABCDEFGHI'
(i.e.,
|
| X'C1C2C3C4C5C6C7C8C9'). Shown below are three statements which access
|
| the area (or portions of the area). Shown below each statement is a
|
| hexadecimal representation which, assuming the statements are executed
|
| in the order shown, shows the content of the 9-byte area after each
|
| statement is executed.
|
|
|
|
MOVE SPACES TO FIELDC.
|
|
X'4040404040C6C7C8C9'
|
|
|
|
MOVE FIELDD TO FIELDX.
|
|
X'00001D4040C6C7C8C9'
|
|
|
|
MOVE SPACES TO FIELDB.
|
|
X'404040404040404040'
|
|
X'404040404040404040'
|
|******************************* BOTTOM OF DATA *******************************|

You might also like