Redefining fields

Some application programming languages, such as COBOL, allow application programs to redefine fields for various purposes. IMS is unaware of the redefinition of a field, unless you include corresponding definitions for the redefined fields in the database description (DBD).

A field can be redefined as one or more fields as long as the total length of the fields in the redefinition is equal to or less than the length of the field that is being redefined.

If you are redefining a field as multiple fields, use a structure field to contain the multiple fields of the redefinition.

You cannot redefine a field that specifies DATATYPE=ARRAY.

The following example shows a one-to-one field redefinition in DBD source statements. FLD2 redefines FLD1. FLD0 and FLD3 are not a part of the redefinition example and are included only to show the example in context.

    FIELD NAME=FLD0,START=1,BYTES=4       
    FIELD NAME=FLD1,START=5,BYTES=15                  
    FIELD NAME=FLD2,REDEFINES=FLD1,START=5,BYTES=15 
    FIELD NAME=FLD3,START=20,BYTES=6

The following is an example of a field that is redefined as multiple fields in the COBOL programming language. FLD2 redefines FLD1 as two fields, FLD3 and FLD4. FLD0 and FLD5 are not a part of the redefinition, but are included in the example only to show the example in context and help illustrate the relative starting positions of the fields in the redefinition.

*     01  FLD0               PIC X(4).
*     01  FLD1               PIC X(15).  
*     01  FLD2 REDEFINES FLD1.         
*       01 FLD3   PIC X(7).      
*       01 FLD4   PIC X(8).
*     01  FLD5               PIC X(1).           

The following example FIELD statements show the FIELD statement definitions in DBD source that correspond to the preceding copybook. In the example, FLD2 redefines FLD1 and has the same byte length as FLD1. FLD2 specifies DATATYPE=STRUCT. FLD3 and FLD4 both specify PARENT=FLD2. The sum total of the BYTES parameter for FLD3 and FLD4 equals the value of BYTES of both FLD1 and FLD2.

    FIELD NAME=FLD0,START=1,BYTES=4                     
    FIELD NAME=FLD1,START=5,BYTES=15                    
    FIELD NAME=FLD2,REDEFINES=FLD1,START=5,BYTES=15,   
             DATATYPE=STRUCT                          
      FIELD NAME=FLD3,START=5,BYTES=7,PARENT=FLD2   
      FIELD NAME=FLD4,START=12,BYTES=8,PARENT=FLD2
    FIELD NAME=FLD5,START=20,BYTES=1