Defining a static array to IMS
A static array has a fixed number of array elements in every instance of a segment type.
Procedure
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).