7.20.2 DEF_ARRAY Comments / Warnings

To use the array facility properly you must understand the IBM i data storage formats of character, packed decimal and signed / zoned decimal.

When you define an array various fields are automatically defined into the function, just as if you had defined them yourself using the DEFINE command.

RDMLX fields may not be overlaid, nor overlay another field.

The following example assumes that #VAL01, #VAL02 and #VAL03 are all packed decimal fields of length 7, with 2 decimals:

DEF_ARRAY NAME(#VAL) INDEXES(#II #JJ) OF_FIELDS(#VAL01 #VAL02 #VAL03)

will define the following "fields" into your function:

         CHANGE FIELD(#II) TO(3)

         SET_ERROR FOR_FIELD(#VAL#II)

         CHANGE FIELD(#JJ) TO(1)

         SET_ERROR FOR_FIELD(#VAL#JJ)

         DISPLAY FIELDS(#VAL01 #VAL02 #VAL03)

   will cause fields #VAL01 and #VAL03 to be displayed in reverse video because they have had their error flags turned on by the SET_ERROR commands.

             FETCH FIELDS(#VAL01) FROM_FILE(.....)

             and   CHANGE #II 1

             FETCH FIELDS(#VAL#II) FROM_FILE(.....)

#VAL#ARRAY as a character field of length 12. This field is the full representation of array #VAL in character format. In this case 3 * P(7,2) uses 12 bytes of storage. This field is only automatically defined when the aggregate array length is less than or equal to 256 bytes.

This full array field #VAL#ARRAY is very useful because it can be used to: