# Nat1317 error help

**URL:** <https://techcommunity.softwareag.com/t/nat1317-error-help/194119>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [April 13, 2017, 8:43pm UTC](https://techcommunity.softwareag.com/t/nat1317-error-help/194119 "2017-04-13T20:43:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mytwo22](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@mytwo22](https://techcommunity.softwareag.com/u/mytwo22)\
**Post date:** [April 13, 2017, 8:43pm UTC](https://techcommunity.softwareag.com/t/nat1317-error-help/194119/1 "2017-04-13T20:43:06Z")

</div>

Hi, I hope someone can help.

For the following statement I get error Nat1317 - Array range operation on invalid ranges  
Move #ws-proc-status (1:#M) to #proc-status (#fp:#lp)

When I hardcode the values I don’t get an error:  
MOVE #WS-PROC-STATUS (1:1) TO #PROC-STATUS(13:14)

The second version will move one occurrence to 2 occurrences without an error.

What exactly is the error?

Thank you!

---

<div class="post-metadata">

**Author:** ![Nikolay\_Kuhta](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nikolay\_Kuhta](https://techcommunity.softwareag.com/u/Nikolay_Kuhta)\
**Post date:** [April 13, 2017, 8:59pm UTC](https://techcommunity.softwareag.com/t/nat1317-error-help/194119/2 "2017-04-13T20:59:14Z")

</div>

Hi, I hope it may help you 🙂  
When you do  
MOVE #WS-PROC-STATUS (1:1) TO #PROC-STATUS(13:14) ,  
you are moving the first item of #WS-PROC-STATUS to the 13 and 14 occurrences of #PROC-STATUS; well, it is easy.

However, when you do Move #ws-proc-status (1:#M) to #proc-status (#fp:#lp), you must make sure (and apparently it is NOT the case because you are getting Nat1317) that  
a) ether #M = 1  
b) or #M = #LP - #FP + 1, e.g. you are moving the same number of items from the first array to the second

---

<div class="post-metadata">

**Author:** ![mytwo22](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@mytwo22](https://techcommunity.softwareag.com/u/mytwo22)\
**Post date:** [April 13, 2017, 9:09pm UTC](https://techcommunity.softwareag.com/t/nat1317-error-help/194119/3 "2017-04-13T21:09:49Z")

</div>

Thank you for your quick reply!!!

#M=1, #fp = 13 and #lp = 14

The first version allows 1 → 2 but the second version only allows 1-\>1?  
I was wondering why it was only abending in one version.

---

<div class="post-metadata">

**Author:** ![Nikolay\_Kuhta](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nikolay\_Kuhta](https://techcommunity.softwareag.com/u/Nikolay_Kuhta)\
**Post date:** [April 13, 2017, 9:18pm UTC](https://techcommunity.softwareag.com/t/nat1317-error-help/194119/4 "2017-04-13T21:18:30Z")

</div>

I hope  
Move #ws-proc-status (1:#M) to #proc-status (#fp:#lp)  
when #M = 1 will function well in the next release of Natural 🙂

To my opinion, it should be legal to move (1:#M) when #M = 1, but it is just NOT implemented this way YET!

---

<div class="post-metadata">

**Author:** ![Jerome\_LeBlanc](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/jerome_leblanc/32/111_2.png) [@Jerome\_LeBlanc](https://techcommunity.softwareag.com/u/Jerome_LeBlanc)\
**Post date:** [April 13, 2017, 10:34pm UTC](https://techcommunity.softwareag.com/t/nat1317-error-help/194119/5 "2017-04-13T22:34:10Z")

</div>

I would not hold my breath hoping that MOVE #WS-PROC-STATUS (1:#M) TO #PROC-STATUS (#FP:#LP) when #M = 1 will ever work. When we catalog Natural code, the compiler converts our statements into object code and makes the code as efficient as possible.

So, when you write MOVE #A (1:1) TO #B (#X:#Y) it knows that you are moving one occurrence to one or many occurrences, so it converts it to the equivalent of a for loop moving #A(1) to #B(n) – for n = #X to #Y.

When you write MOVE #A (1:#Z) TO #B (#X:#Y), Natural must assume that the two sub-arrays are identical in size so it builds to code to move the sub-array of #A to the appropriate sub-array of #B.

You are asking a bit much of Natural. Basically you are expecting Natural to assume that if #Z is 1, then move occurrence 1 of #A to every occurrence of #B between #X and #Y, otherwise, move the occurrences 1:#Z of #A to #X:#Y of #B. If that is really what you want, then write it that way.

```auto
IF #M = 1
  MOVE #WS-PROC-STATUS (1) TO #PROC-STATUS (#FP:#LP)
ELSE
  MOVE #WS-PROC-STATUS (1:#M) TO #PROC-STATUS (#FP:#LP)
END-IF
```

---

<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:** [April 13, 2017, 10:34pm UTC](https://techcommunity.softwareag.com/t/nat1317-error-help/194119/6 "2017-04-13T22:34:47Z")

</div>

MOVE statement syntax allows you to copy a scalar to many target variables.

```auto
MOVE #SCALAR TO #PROC-STATUS(13) #PROC-STATUS(14)
```

or

```auto
MOVE #SCALAR TO #PROC-STATUS(13:14)
```

When you specify a single occurrence of an array, it is the same as for a scalar.

```auto
MOVE #WS-PROC-STATUS (1:1) TO #PROC-STATUS(13:14)
```

If you acre MOVEing multiple occurrences of one array to another, the number of occurrences must be the same on either side of the TO; Natural moves individual occurrences to corresponding target positions.

```auto
MOVE #WS-PROC-STATUS (1:2) TO #PROC-STATUS(13:14)
```

In the examples above, the Natural compiler knows what to do because all the indexes are specified as literals. If you introduce variables, then an error message is issued if the compiler cannot determine if the number of occurrences match. This is true even if your logic guarantees that the occurrences will be correct at execution time.

```auto
MOVE #WS-PROC-STATUS (1:#M) TO #PROC-STATUS(#FP:#LP)
```

#FP and #LP specify two occurrences, but what if #M was 5?

There are two cases where non-literals can be used, one using constants, the other using simple arithmetic.

```auto
1 #M (I4) CONST <1>

MOVE #WS-PROC-STATUS (1:#M) TO #PROC-STATUS(#FP:#LP) /* single occurrence of #WS-PROC-STATUS 
```

```auto
MOVE #WS-PROC-STATUS(#FP:#LP) TO #PROC-STATUS(#FP:#LP) /* same range
MOVE #WS-PROC-STATUS(#FP:#LP) TO #PROC-STATUS(#FP+2:#LP+2) /* same count
```

---

<div class="post-metadata">

**Author:** ![mytwo22](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@mytwo22](https://techcommunity.softwareag.com/u/mytwo22)\
**Post date:** [April 14, 2017, 2:22pm UTC](https://techcommunity.softwareag.com/t/nat1317-error-help/194119/7 "2017-04-14T14:22:33Z")

</div>

Thank you so much for the replies!!! I like understanding what is happening!!.  
Something is wrong with the logic of the program in a certain situation, and it is trying to move one occurrence to two occurrences. But when I tried to hardcode the occurrences it worked so I wasn’t sure what the error was.  
Now on to figuring out why this is happening!

---

<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:38pm UTC](https://techcommunity.softwareag.com/t/nat1317-error-help/194119/8 "2021-04-02T15:38:17Z")

</div>


