# How to specifiy array index and loop reference

**URL:** <https://techcommunity.softwareag.com/t/how-to-specifiy-array-index-and-loop-reference/94803>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [September 24, 2010, 5:07pm UTC](https://techcommunity.softwareag.com/t/how-to-specifiy-array-index-and-loop-reference/94803 "2010-09-24T17:07:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ats](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@Ats](https://techcommunity.softwareag.com/u/Ats)\
**Post date:** [September 24, 2010, 5:07pm UTC](https://techcommunity.softwareag.com/t/how-to-specifiy-array-index-and-loop-reference/94803/1 "2010-09-24T17:07:11Z")

</div>

This may be a basic one, but I didn’t come across this yet. In the example below:

RD. READ …  
FD. FIND …  
DISPLAY #array(1) from READ

How should I specify array index and loop label RD. with the field?

---

<div class="post-metadata">

**Author:** ![Brian\_Johnson1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/brian_johnson1/32/163_2.png) [@Brian\_Johnson1](https://techcommunity.softwareag.com/u/Brian_Johnson1)\
**Post date:** [September 24, 2010, 8:28pm UTC](https://techcommunity.softwareag.com/t/how-to-specifiy-array-index-and-loop-reference/94803/2 "2010-09-24T20:28:08Z")

</div>

I am a little confused by your question - perhaps because minimum info was given.

You can always prefix a field with the view name to remove ambiguity to the coder, especially if the field name occurs in multiple active loops.

Example:

RD. READ MYVIEW BY KEY1  
FD. FIND YOURVIEW WITH KEY2 = #XYZ  
MOVE MYVIEW.ARRAY(1) TO #BLAH  
MOVE YOURVIEW.ARRAY(1) TO #YADDA  
END-FIND  
END-READ

Does this help?

---

<div class="post-metadata">

**Author:** ![Douglas\_Kelly](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/douglas_kelly/32/102_2.png) [@Douglas\_Kelly](https://techcommunity.softwareag.com/u/Douglas_Kelly)\
**Post date:** [September 24, 2010, 11:06pm UTC](https://techcommunity.softwareag.com/t/how-to-specifiy-array-index-and-loop-reference/94803/3 "2010-09-24T23:06:46Z")

</div>

You can also include both reference and index:  
MOVE ARRAY(RD./1) TO #BLAH

Be aware that in structured mode if you use  
RD. READ MYVIEW BY KEY1  
FD. FIND MYVIEW WITH KEY2 = #XYZ  
the reference SOMEFIELD(RD.) (including ARRAY(RD./1)) inside the FD. loop will refer to the data in FD since the FD FIND overlays the data area in RD. (This bad practice shows up in programs converted from reporting mode.) As a best practice, you should always use the syntax Brian suggests, based on the view, not the line reference.

---

<div class="post-metadata">

**Author:** ![Ats](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@Ats](https://techcommunity.softwareag.com/u/Ats)\
**Post date:** [September 27, 2010, 11:17am UTC](https://techcommunity.softwareag.com/t/how-to-specifiy-array-index-and-loop-reference/94803/4 "2010-09-27T11:17:52Z")

</div>

Thanks Brian and Douglas!

I wanted syntax given by Douglas and was aware with Brian’s one. As suggested will follow the advise.

---

<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, 2:59pm UTC](https://techcommunity.softwareag.com/t/how-to-specifiy-array-index-and-loop-reference/94803/5 "2021-04-02T14:59:08Z")

</div>


