# Natural PE statement

**URL:** <https://techcommunity.softwareag.com/t/natural-pe-statement/201292>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-Code-Samples\
**Created:** [October 16, 2018, 11:18am UTC](https://techcommunity.softwareag.com/t/natural-pe-statement/201292 "2018-10-16T11:18:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Derick\_Meyer](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@Derick\_Meyer](https://techcommunity.softwareag.com/u/Derick_Meyer)\
**Post date:** [October 16, 2018, 11:18am UTC](https://techcommunity.softwareag.com/t/natural-pe-statement/201292/1 "2018-10-16T11:18:14Z")

</div>

Is it possible to read a pe field with a for in Natural

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [October 16, 2018, 11:54am UTC](https://techcommunity.softwareag.com/t/natural-pe-statement/201292/2 "2018-10-16T11:54:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [October 16, 2018, 5:51pm UTC](https://techcommunity.softwareag.com/t/natural-pe-statement/201292/3 "2018-10-16T17:51:43Z")

</div>

Here is a working example of processing a PE with a FOR loop.

```auto
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.

```auto
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
```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:41pm UTC](https://techcommunity.softwareag.com/t/natural-pe-statement/201292/4 "2021-04-02T15:41:38Z")

</div>

Closed on April 2, 2021, 3:41pm UTC


