Ü OCCUR (Set the Occurrence or Get the occurrence of a Data
Structure)
·
The OCCUR operation
establishes which occurrence of a multiple occurrence data structure is used
next in a program.
·
If factor 1 is a data structure name, it must be a multiple
occurrence data structure. The current occurrence of the data structure in
factor 1 is used to set the occurrence of the data structure in factor 2.
Factor 1
|
Op-code
|
Factor 2
|
Result Field
|
Resulting Indicators
HI LO EQ
|
Occurrence Index
|
OCCUR(E)
|
Data structure
|
Current Occurrence index
|
|
ER
|
|
Example
Columns . . . : 6 80 Browse AMINEM/QRPGLESRC
SEU==> MULTDS
FMT D DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
*************** Beginning of data ****************************************************
0001.00 D DS1 DS OCCURS(10) 130118
0002.00 D FLD01 1 5 130130
0003.00 D FLD02 6 10 130130
0004.00 DX S 2 0 INZ(1) 130118
0005.00 DN S 2 0 INZ(1) 130130
0006.00 130118
0007.00 C X DO 5 130130
0008.00 C X OCCUR DS1 N 130130
0009.00 C EVAL FLD01=%char(X) 130130
0010.00 C EVAL FLD02=%char(X) 130130
0011.00 C EVAL X=X+1 130118
0012.00 C DS1 DSPLY 130118
0013.00 C N DSPLY 130130
0014.00 C ENDDO 130118
0015.00 C SETON LR 130118
****************** End of data *******************************************************
OUTPUT
DSPLY 1
1
DSPLY 1
DSPLY 2
2
DSPLY 2
DSPLY 3
3
DSPLY 3
DSPLY 4
4
DSPLY 4
DSPLY 5
5
DSPLY 5