Is it possible to read a pe field with a for in Natural
I presume you mean something like:
FOR #LOOP = 1 TO 10
READ myview
where myview has something like pe-field (#loop)
The problem is that you would issue ten calls to adabas, and read the same record ten times.
Better would be a view with pe-field (1:10).
More info would be helpful.
Is there a reasonable upper bound to the number of occurrences of the pe-group in any record?
Do you want to retrieve a range of values (your idea of having the READ within a FOR implies this), or just one occurrence.
If you are working with Report Mode, you could look up GET SAME in the documentation.
Here is a working example of processing a PE with a FOR loop.
DEFINE DATA LOCAL
1 #M-PA (I4) CONST <3>
1 #M-PL (I4) CONST <4>
1 EMP VIEW EMPLOYEES-V2009
2 PERSONNEL-ID (HD='ID')
2 C*PRIVATE-ADDRESS
2 PRIVATE-CITY (#M-PA) (HD='City')
2 PRIVATE-POST-CODE (#M-PA) (HD='Postal')
2 PRIVATE-COUNTRY (#M-PA) (HD='Country')
2 PRIVATE-ADDRESS-LINE (#M-PA, #M-PL) (HD='Address')
1 #I (I4)
END-DEFINE
LIMIT 10
READ EMP BY PERSONNEL-ID FROM '1150313'
FOR #I = 1 C*PRIVATE-ADDRESS
DISPLAY (LS=85 ES=T)
PERSONNEL-ID (IS=T)
PRIVATE-CITY (#I)
PRIVATE-COUNTRY (#I)
PRIVATE-POST-CODE (#I)
PRIVATE-ADDRESS-LINE (#I, 1)
WRITE (ES=T)
T*PRIVATE-ADDRESS-LINE
PRIVATE-ADDRESS-LINE (#I, 2)
WRITE (ES=T)
T*PRIVATE-ADDRESS-LINE
PRIVATE-ADDRESS-LINE (#I, 3)
WRITE (ES=T)
T*PRIVATE-ADDRESS-LINE
PRIVATE-ADDRESS-LINE (#I, 4)
END-FOR
END-READ
END
And here is the report.
Page 1 10/16/18 08:47:36
ID City Country Postal Address
-------- -------------------- ------- ---------- ------------------------------
11600301 Frankfurt D 60316 Am Hansenberg 17
11600302 Eschborn D 65760 Friedhofsweg 17
11600303 Stuttgart D 70188 Talstrasse 17
Postfach 7693
11600304 Sindelfingen D 71063 Burgweg 28
11600305 Frankfurt D 65933 Frankenfelderweg 16
Postfach 45
11600306 München D 80331 Hahnerstraße
11600307 Bremen D 28195 Haardtring 18
11600311 Bremen D 28195 Sternweg 2
11600312 Bremen D 28195 Venusplatz 123
11600313 München D 80331 Kreuzgasse 11