8 4 Technique 3 Using the DEF_ARRAY Command

LANSA Application Design

8.4 Technique 3 - Using the DEF_ARRAY Command

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