Defining a static array to IMS

A static array has a fixed number of array elements in every instance of a segment type.

A static array is defined by coding FIELD statements in the input control statements of the DBD Generation utility. The following steps assume that the corresponding SEGM, DBD, and other utility control statements have been coded correctly:

Procedure

  1. Code the FIELD statement of the static array:
    1. Specify the external name of the array on the EXTERNALNAME parameter. Arrays do not support the NAME parameter.
    2. Specify DATATYPE=ARRAY
    3. Specify the number of elements in the array on the MINOCCURS and MAXOCCURS parameters.
      The value specified on both parameters must be the same.
    4. Specify the byte size of the array on the BYTES parameter.
      The byte size specified must be equal to or greater than the sum total of the bytes sizes of all fields that make up the array and array elements.
  2. Code the FIELD statements for each field that makes up the repeating array element.
    In the FIELD statement for each field that is a part of the array element:
    1. Specify the external name of the field on the EXTERNALNAME parameter. Arrays do not support the NAME parameter.
    2. Specify the starting byte offset of the field in the array element on the RELSTART parameter.
    3. Specify the external name of the array on the PARENT parameter.
    4. Specify the byte size of the field on the BYTES parameter.

The following FIELD statements show an example of a static array definition. In the example, the first FIELD statement defines the array. The array is named COURSES and contains 8 instance of a repeated element, as specified on the MINOCCURS and MAXOCCURS parameters. The repeated array element is defined by the last three FIELD statements. Because each array element is made up of three fields that total 64 bytes and the array is made up of 8 array elements, the array requires a minimum of 512 bytes.

The array starts at byte 5 in the segment and the first field in the first array element starts at byte 1 of the array. The subsequent array elements start at bytes 65, 129, 193, and so on.

    FIELD EXTERNALNAME=COURSES,DATATYPE=ARRAY,START=5,                  X
               BYTES=512,MINOCCURS=8,MAXOCCURS=8                 
     FIELD EXTERNALNAME=COURSE_ID,RELSTART=1,BYTES=8,PARENT=COURSES
     FIELD EXTERNALNAME=COURSE_TITLE,RELSTART=9,BYTES=48,              X
               PARENT=COURSES                            
     FIELD EXTERNALNAME=INSTRUCTOR_ID,RELSTART=57,BYTES=8,             X
               PARENT=COURSES                             

The preceding array definition is based on the following excerpt of an example COBOL copy book:

******* COPYBOOK for STUDENT/COURSES (STATIC)01   STUDENT.
        20   COURSES OCCURS 8 TIMES.
          25   COURSE_ID			PIC 9(8).
          25   COURSE_TITLE		PIC X(48).
          25   INSTRUCTOR_ID	PIC 9(8).