Library View Topics Framed Contents Revised Topics Previous Topic Next Topic Search Search ResultsPrevious Topic MatchNext Topic Match Notes List Notes Print Download No PDF Handheld DisconnectedHandheld ConnectedHelp

5.3.12.1 REDEFINES Clause Considerations



Data items within an area can be redefined without changing their lengths. For example:


     05  NAME-2.
       10  SALARY                  PICTURE XXX.
       10  SO-SEC-NO               PICTURE X(9).
       10  MONTH                   PICTURE XX.
     05  NAME-1 REDEFINES NAME-2.
       10  WAGE                    PICTURE XXX.
       10  EMP-NO                  PICTURE X(9).
       10  YEAR                    PICTURE XX.

Data item lengths and types can also be re-specified within an area. For example:


     05  NAME-2.
       10  SALARY                  PICTURE XXX.
       10  SO-SEC-NO               PICTURE X(9).
       10  MONTH                   PICTURE XX.
     05  NAME-1 REDEFINES NAME-2.
       10  WAGE                    PICTURE 999V999.
       10  EMP-NO                  PICTURE X(6).
       10  YEAR                    PICTURE XX.

When an area is redefined, all descriptions of the area are always in effect; that is, redefinition does not cause any data to be erased and never supersedes a previous description. Thus, if B REDEFINES C has been specified, either of the two procedural statements, MOVE X TO B and MOVE Y TO C, could be executed at any point in the program.

In the first case, the area described as B would assume the value and format of X. In the second case, the same physical area (described now as C) would assume the value and format of Y. Note that, if the second statement is executed immediately after the first, the value of Y replaces the value of X in the one storage area.

The usage of a redefining data item need not be the same as that of a redefined item. This does not, however, cause any change in existing data. For example:


     05  B                      PICTURE  99 USAGE DISPLAY VALUE 8.
     05  C REDEFINES B          PICTURE S99 USAGE COMPUTATIONAL-4.
     05  A                      PICTURE S99 USAGE COMPUTATIONAL-4.

Redefining B does not change the bit configuration of the data in the storage area. Therefore, the following two statements produce different results:


     ADD B TO A
     ADD C TO A

In the first case, the value 8 is added to A (because B has USAGE DISPLAY). In the second statement, the value -3848 is added to A (because C has USAGE COMPUTATIONAL-4), and the bit configuration of the storage area has the binary value -3848.

The above example demonstrates how the improper use of redefinition can give unexpected or incorrect results.

Previous Topic Next Topic © Copyright IBM Corp. 1991, 1998

IBM Library Server Copyright 1989, 2005 IBM Corporation. All rights reserved.





Return to library:   z/OS | z/OS.e | TPF | z/VSE | z/VM | IBM Hardware | IBM System z Redbooks
Glossary:   IBM terminology
Publications:   How to order publications
Readers:   Download IBM Library Reader | Download IBM Softcopy Reader | Download Adobe® Acrobat® Reader®
Library management:   Download IBM Softcopy Librarian
Contacts:   Contact z/OS


Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks of Adobe Systems incorporated.