I'm trying to get familiar with the accessing modes for tables. I would like to use theses 'free indices' (declared on level 77) but didn't manage it. How can I use this kind of indices?
I have the following strukture and I would like to access all attributes in the same loop with only one index:
01 MY-STRUCTURE.
10 ATTRIBUTE-A OCCURS 50 PIC X(5).
10 ATTRIBUTE-B OCCURS 50 PIC X(8).
10 ATTRIBUTE-C OCCURS 50 PIC X(26).
10 ATTRIBUTE-D OCCURS 50 PIC S9(5)V USAGE COMP-3.
10 ATTRIBUTE-E OCCURS 50 PIC S9(5)V USAGE COMP-3.
10 ATTRIBUTE-F OCCURS 50 PIC X(8).
10 ATTRIBUTE-G OCCURS 50 PIC S9(11)V USAGE COMP-3.
10 ATTRIBUTE-A OCCURS 50 PIC X(5).
10 ATTRIBUTE-B OCCURS 50 PIC X(8).
10 ATTRIBUTE-C OCCURS 50 PIC X(26).
10 ATTRIBUTE-D OCCURS 50 PIC S9(5)V USAGE COMP-3.
10 ATTRIBUTE-E OCCURS 50 PIC S9(5)V USAGE COMP-3.
10 ATTRIBUTE-F OCCURS 50 PIC X(8).
10 ATTRIBUTE-G OCCURS 50 PIC S9(11)V USAGE COMP-3.
I tried to define the index as follows:
77 INX-B USAGE IS INDEX.
And access the elements as follows:
PERFORM VARYING INX-B FROM 1 BY 1 UNTIL INX-B > 10
DISPLAY ATTRIBUTE-A (INX-B)
END-PERFORM
DISPLAY ATTRIBUTE-A (INX-B)
END-PERFORM
But it doesn't really work. I get the following errors:
"INX-B" was defined as a type that was invalid in this context. The statement was discarded.
"INX-B (INDEX DATA ITEM)" was compared with "10". The comparison was discarded.
Not enough subscripts or indices were specified for "ATTRIBUTE-A". A subscript or index value of 1 was assumed
for each missing subscript or index.
"INX-B (INDEX DATA ITEM)" was compared with "10". The comparison was discarded.
Not enough subscripts or indices were specified for "ATTRIBUTE-A". A subscript or index value of 1 was assumed
for each missing subscript or index.
How does this thing work with the indices declared on level 77??
BTW, I'm working with the Cobol Enterprise Z-OS compiler 3.4.1