Defining a data structure in DBD source statements
Define the data structures that are used by your application programs in your DBD source statements so that IMS stores the data in the same way that your application processes it.
A structure is a fixed set of related data elements. Unlike an array, the elements of a structure do not repeat.
A structure is defined to IMS as a field with a data type of STRUCT. The elements of a structure are fields that specify the structure as a parent.
You can define a name, an external name, or both on a structure. Defining a name allows you to specify the name of the structure field in an SSA. However, if an element of the structure is a dynamic array, you can only specify an external name and not an IMS name. Dynamic arrays and any structures that contain dynamic arrays are not searchable by IMS and therefore cannot be included in an SSA.
Procedure
These FIELD statements show an example of a structure definition. In the example, the first FIELD statement defines the structure. The structure is named ADDRESS_INFO. The elements of the structure are defined by the following three FIELD statements that all specify ADDRESS_INFO on the PARENT parameter. Because the structure contains three fields that together total 45 bytes, the structure requires a minimum of 45 bytes.
The structure and the first element of the structure start at byte 5 in the segment. The starting positions of the subsequent elements in the structure are also calculated relative to the beginning of the segment.
FIELD NAME=ADDRESS_INFO,DATATYPE=STRUCT,START=5,BYTES=45
FIELD NAME=CITY,DATATYPE=CHAR,START=5,BYTES=15,PARENT=ADDRESS_INFO
FIELD NAME=STREET,DATATYPE=CHAR,START=21,BYTES=25,PARENT=ADDRESS_INFO
FIELD NAME=ZIP,DATATYPE=CHAR,START=46,BYTES=5,PARENT=ADDRESS_INFO
The preceding array definition is based on the following excerpt of an example COBOL copy book:
02 ADDRESS-INFO.
04 CITY PIC X(15).
04 STREET PIC X(25).
04 ZIP PIC X(5).