To facilitate use of indicator variables with host structures for output, PP2 accepts
the definition of an array of small integers.
As an example, consider the following:
02 FIELD1 PIC X(20).
02 FIELD2 PIC S9(9) <comp>.
02 FIELD3 PIC X(6).
02 FIELD4 PIC S9(11)V99 COMP-3.
05 INDVAR OCCURS 4 TIMES PIC S9(4) <comp>.
INTO :STRUCTURE1 :INDVAR
WHERE col1 = :hostvar2
FETCH cursor1 INTO :STRUCTURE1 :INDVAR
Where <comp> is COMP-5 for MF COBOL and COMP for all other COBOL compilers.
Note the use of INDVAR rather than INDSTRUCT to identify the indicator array.
The variable name which contains the OCCURS clause is always used to identify the
indicator array to the precompiler.
In both examples, INDVAR(1) is associated with FIELD1, INDVAR(2) with FIELD2 and so
The host variable is not required to have an associated indicator variable.
The INDVAR array above could have had two elements rather than four.
PP2, however, associates host variables and indicator variables one to one in order
In these examples, FIELD1 and FIELD2 would have associated indicators, while FIELD3
and FIELD4 would have no indicators (assuming the array is defined with two elements).
Indicator arrays may be associated only with a structure.
Use of an array with individual elements results in a precompiler error.