# Help With Code

**URL:** <https://techcommunity.softwareag.com/t/help-with-code/61801>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-News-and-General-Topics\
**Created:** [December 12, 2006, 10:02pm UTC](https://techcommunity.softwareag.com/t/help-with-code/61801 "2006-12-12T22:02:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![NatBeginner](https://avatars.discourse-cdn.com/v4/letter/n/91b2a8/32.png) [@NatBeginner](https://techcommunity.softwareag.com/u/NatBeginner)\
**Post date:** [December 12, 2006, 10:02pm UTC](https://techcommunity.softwareag.com/t/help-with-code/61801/1 "2006-12-12T22:02:37Z")

</div>

Hey! I’m currently a newbie to NATURAL. I think it is a great computer language. I’m working on a program and I came across a problem. This is what I’m trying to do:

If the previous payee isn is the same as the current payee isn then add the previous tranaction amount and current transaction amount. Store that amount in total isn transaction amount. Move that amount to CHK.TRAN-AMT.

Here is what I came up with:

MOVE CHK.PAYEE-ISN TO #CURR-PAYEE-ISN  
MOVE CHK.TRANS-AMT TO #CURR-TRANS-AMT  
COMPUTE #PREV-PAYEE-ISN = #CURR-PAYEE-ISN - 1  
COMPUTE #PREV-TRANS-AMT = #CURR-TRANS-AMT - 1  
IF #CURR-PAYEE-ISN = #PREV-PAYEE-ISN  
ADD #PREV-TRANS-AMT #CURR-TRANS-AMT GIVING #TOTAL-ISN-TRANS-AMT  
MOVE #TOTAL-ISN-TRANS-AMT TO CHK.TRANS-AMT  
END-IF

However, this didn’t work. When I ran my program, the #CURR-PAYEE-ISN = 4473 and #PREV-PAYEE-ISN = 4472. That is not right. #PREV-PAYEE-ISN is suppose to be the isn before #CURR-PAYEE-ISN which is 30897. Some how I nedd to read/get the isn before #CURR-PAYEE-ISN. If anyone can shed some light, I would greatly appreciate. THANK YOU IN ADVANCE!

Lost,  
NatBeginner

---

<div class="post-metadata">

**Author:** ![Wilfried\_B](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/wilfried_b/32/83_2.png) [@Wilfried\_B](https://techcommunity.softwareag.com/u/Wilfried_B)\
**Post date:** [December 12, 2006, 11:07pm UTC](https://techcommunity.softwareag.com/t/help-with-code/61801/2 "2006-12-12T23:07:39Z")

</div>

Hi NatBeginner,

Can you explain what you want to do and not what you did? Is this a database read or something else? What is CHK.TRAN-AMT? When it is read from the database, the “Move that amount to CHK.TRAN-AMT” is nonsense unless this value is stored back into the database (which in the described case itself is nonsense).  
Are the records grouped/sorted and when how are they sorted?

If we should shed some light on you, don’t hide behind a rock!

---

<div class="post-metadata">

**Author:** ![Lukas\_Hundemer](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/lukas_hundemer/32/113_2.png) [@Lukas\_Hundemer](https://techcommunity.softwareag.com/u/Lukas_Hundemer)\
**Post date:** [December 14, 2006, 6:19pm UTC](https://techcommunity.softwareag.com/t/help-with-code/61801/3 "2006-12-14T18:19:53Z")

</div>

I guess your CHK.PAYEE-ISN is the ISN of a database record. For Natural this is just a number eg 4473. If you subtract 1 from that number the value is of cause 4472 and NEVER equal to the original value.

```auto
x == x - 1 --> never true
```

Thus you should think about what you really want to do and what values you want to compare (but hard for us to guess).

If you run through a read loop by a descriptor value, the ISN of the record read before is normally not ISN -1. Means you have to save the previous ISN. But even if you compare these two ISNs it will most time fail unless you use a multiple-field as descriptor.

But maybe you don’t want to compare the ISNs but values of the corresponding records??  
Or …

---

<div class="post-metadata">

**Author:** ![NatBeginner](https://avatars.discourse-cdn.com/v4/letter/n/91b2a8/32.png) [@NatBeginner](https://techcommunity.softwareag.com/u/NatBeginner)\
**Post date:** [December 14, 2006, 8:30pm UTC](https://techcommunity.softwareag.com/t/help-with-code/61801/4 "2006-12-14T20:30:14Z")

</div>

Thanks for the comments and replies. They are very helpful. Again thanks!

NatBeginner

---

<div class="post-metadata">

**Author:** ![Wilfried\_B](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/wilfried_b/32/83_2.png) [@Wilfried\_B](https://techcommunity.softwareag.com/u/Wilfried_B)\
**Post date:** [December 18, 2006, 2:04pm UTC](https://techcommunity.softwareag.com/t/help-with-code/61801/5 "2006-12-18T14:04:17Z")

</div>

What has been helpful with the answers? I’m feeling fooled!

---

<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:40pm UTC](https://techcommunity.softwareag.com/t/help-with-code/61801/6 "2021-04-02T14:40:59Z")

</div>


