# Can \*OCCURRENCE(#X-ARRAY) define the X-ARRAY memory space in execution time?

**URL:** <https://techcommunity.softwareag.com/t/can-occurrence-x-array-define-the-x-array-memory-space-in-execution-time/312218>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, NaturalONE\
**Created:** [May 15, 2026, 6:14pm UTC](https://techcommunity.softwareag.com/t/can-occurrence-x-array-define-the-x-array-memory-space-in-execution-time/312218 "2026-05-15T18:14:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Imnacho2000](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/imnacho2000/32/31777_2.png) [@Imnacho2000](https://techcommunity.softwareag.com/u/Imnacho2000)\
**Post date:** [May 15, 2026, 6:14pm UTC](https://techcommunity.softwareag.com/t/can-occurrence-x-array-define-the-x-array-memory-space-in-execution-time/312218/1 "2026-05-15T18:14:14Z")

</div>

#### _ **Product/components** used and **version/fix** level:_

#### _Detailed explanation of the problem:_

#### _Error messages / **full error** message screenshot / **log** file:_

#### _Question related to a **free trial** , or to a **production (customer)** instance?_

I was encoding a program and it gave an error in execution time since it called a subroutine and when returning from it I performed a loop for from 1 to 180 consulting by #X-ARRAY(#i), it gave me the NAT1257 but a SENIOR programmer came and solved it with \*OCCURRENCE(#X-ARRAY), I did not know that it could be assigned in runtime dimension that way, making the code stay

FOR #J 1 \*OCCURRENCE(#X-ARRAY)

---

<div class="post-metadata">

**Author:** ![Dion\_Kejlberg](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/dion_kejlberg/32/525_2.png) [@Dion\_Kejlberg](https://techcommunity.softwareag.com/u/Dion_Kejlberg)\
**Post date:** [May 18, 2026, 6:38am UTC](https://techcommunity.softwareag.com/t/can-occurrence-x-array-define-the-x-array-memory-space-in-execution-time/312218/2 "2026-05-18T06:38:33Z")

</div>

For better performance you should change the code a little. Inside the loop \*OCC will be executed each time, which is a waste of time, unless you change the size of #X-ARRAY.

Try:

#IX := \*OCC(#X-ARRAY)

FOR #J 1 #IX

---

<div class="post-metadata">

**Author:** ![Ellie-Mae](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ellie-mae/32/39517_2.png) [@Ellie-Mae](https://techcommunity.softwareag.com/u/Ellie-Mae)\
**Post date:** [June 5, 2026, 10:58am UTC](https://techcommunity.softwareag.com/t/can-occurrence-x-array-define-the-x-array-memory-space-in-execution-time/312218/3 "2026-06-05T10:58:58Z")

</div>

Nice solution. Using \*OCCURRENCE(#X-ARRAY) makes the loop more flexible and avoids hardcoding the array size.
