Indicator Variables and Structures
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:
01 STRUCTURE1.
02 FIELD1 PIC X(20).
02 FIELD2 PIC S9(9) <comp>.
02 FIELD3 PIC X(6).
02 FIELD4 PIC S9(11)V99 COMP-3.
01 INDSTRUCT.
05 INDVAR OCCURS 4 TIMES PIC S9(4) <comp>.
EXEC SQL
SELECT *
INTO :STRUCTURE1 :INDVAR
FROM table1
WHERE col1 = :hostvar2
END-EXEC
EXEC SQL
FETCH cursor1 INTO :STRUCTURE1 :INDVAR
END-EXEC
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.