[ |../../index.htm#lansa/dsnb9_0030.htm]
You are here:

12.1 Using the DEF_ARRAY Command

In the following example, it is assumed that the database file involved contains a character field called CYR that is 84 bytes long.
It actually contains an array of 12 x 7,2 signed positive decimal fields.
Even though the technique described only deals with one 12 position numeric array, it should be very easy to extrapolate the techniques to handle more than one array, to handle arrays with a different number of entries, or to handle arrays containing alphanumeric data.
Note: This technique only uses a small part of the command DEF_ARRAY's full features. Refer to the DEF_ARRAY command in the LANSA Technical Reference Guide for more details and examples.
In the RDML program define the array index field (#XX) and then use the DEF_ARRAY command to overlay field CYR with array #CYA:
          DEFINE    FIELD(#XX) TYPE(*DEC) LENGTH(7) DECIMALS(0)
 
          DEF_ARRAY NAME(#CYA) INDEXES(#XX) OVERLAYING(#CYR 1)
                    TYPE(*SIGNED) TOT_ENTRY(12) ENTRY_LEN(7)
                    ENTRY_DEC(2)
After defining array #CYA you can "index" field CYR like this, to calculate totals of all 12 fields:
          CHANGE     FIELD(#TOT) TO(0)
          BEGIN_LOOP FROM(1) TO(12) USING(#XX)
          CHANGE     FIELD(#TOT) TO('#TOT + #CYA#XX')
          END_LOOP
to increment all values in the array by 10 percent:
          BEGIN_LOOP FROM(1) TO(12) USING(#XX)
          CHANGE     FIELD(#CYA#XX) TO('#CYA#XX * 1.1')
          END_LOOP
 
 
[ |../../index.htm#lansa/dsnb9_0030.htm]