# ACCEPT/REJECT : does they influence the NISNHQ value?

**URL:** <https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051>\
**Category:** Forum\
**Tags:** Adabas-Natural, Adabas, Natural, Adabas-on-Mainframes, Natural-on-Mainframes\
**Created:** [April 27, 2022, 11:05pm UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051 "2022-04-27T23:05:43Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tomas\_Moraes](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/tomas_moraes/32/6982_2.png) [@Tomas\_Moraes](https://techcommunity.softwareag.com/u/Tomas_Moraes)\
**Post date:** [April 27, 2022, 11:05pm UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/1 "2022-04-27T23:05:43Z")

</div>

#### Natural 8

#### product with a customer license

I tried a READ loop with ACCEPT clause , and an UPDATE. I used ACCEPT instead of IF … END-IF .  
I tried ACCEPT with the intention of minimizing the amount of records in lock. Something like this:

```auto
RD1. READ MY-VIEW WITH DESC-FIELD-1 GE #INI-SCOPE
  ACCEPT IF INI-DATE GE 20220412
        AND INI-DATE LE 20220416
        AND CONTROL-BUSINESS-FIELD-1 EQ 1
  MOVE *COUNTER TO #AMOUNT-READ
  MOVE 1 TO CONTROL-BUSINESS-FIELD-8
  UPDATE (RD1.)
  END TRANSACTION
  ADD 1 TO #AMOUNT-UPDATED
END-READ
/* JUST AN EXAMPLE...

```

#### I got Error 3047 on using ACCEPT.

So I’d like to understand the influence of ACCEPT on the amount of locked records in a READ loop.

#### installed latest fixes for the products? YES

Thanks in advance!

---

<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 27, 2022, 11:27pm UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/2 "2022-04-27T23:27:17Z")

</div>

ACCEPT has NO influence on the number of records placed on hold. It controls only whether the record will be processed by the logic in the loop.

Records are placed on hold because there is an UPDATE referring to the READ, so all records read will be in hold status.

As a general rule, avoid ACCEPT, REJECT, WHERE, and ESCAPE TOP when holding records. A record is in hold from the moment read until the END TRANSACTION is executed.

---

<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:** [April 27, 2022, 11:36pm UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/3 "2022-04-27T23:36:20Z")

</div>

[RI profile parameter](https://documentation.softwareag.com/natural/nat912mf/parms/ri.htm)

Use profile parameter RI=ON to release records from hold that are rejected via WHERE or ACCEPT/REJECT statements.

Or use a GET to only put selected records on hold. Instead of UPDATE (RD1.), use:  
MY-GET. GET MY-VIEW \*ISN (RD1.)  
UPDATE (MY-GET.)

In terms of performance, you will do an Adabas call (RI) for every record to be released if you just use RI=ON. If you use the GET approach, you will do an Adabas call (L4) for each record to be updated. Either call will not use a lot of resources (the L4 will very likely just read the record from the buffer pool), so which to use will be a matter of how many records will be updated vs how many are read.

Incidentally, your #AMOUNT-READ will be incorrect unless the last record read is updated. if you reference \*COUNTER (RD1.) after the END-READ, it will have the number of records read. Or, if you need #AMOUNT-READ for some reason, put the MOVE \*COUNTER before the ACCEPT statement.

---

<div class="post-metadata">

**Author:** ![Tomas\_Moraes](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/tomas_moraes/32/6982_2.png) [@Tomas\_Moraes](https://techcommunity.softwareag.com/u/Tomas_Moraes)\
**Post date:** [April 27, 2022, 11:53pm UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/4 "2022-04-27T23:53:15Z")

</div>

I didn’t want to hold all records - only the accepted. Noted.  
One doubt: If I do END TRANSACTION on each record, the amount of locks is gradually decreasing?

---

<div class="post-metadata">

**Author:** ![Tomas\_Moraes](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/tomas_moraes/32/6982_2.png) [@Tomas\_Moraes](https://techcommunity.softwareag.com/u/Tomas_Moraes)\
**Post date:** [April 27, 2022, 11:55pm UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/5 "2022-04-27T23:55:13Z")

</div>

> [@Douglas\_Kelly](#):
>
> Use profile parameter RI=ON to release records from hold that are rejected via WHERE or ACCEPT/REJECT statements.

This seems to be a good aproach for my case. This parameter is included in JCL job?

---

<div class="post-metadata">

**Author:** ![Tomas\_Moraes](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/tomas_moraes/32/6982_2.png) [@Tomas\_Moraes](https://techcommunity.softwareag.com/u/Tomas_Moraes)\
**Post date:** [April 28, 2022, 12:03am UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/6 "2022-04-28T00:03:51Z")

</div>

> [@Douglas\_Kelly](#):
>
> MY-GET. GET MY-VIEW \*ISN (RD1.)  
> UPDATE (MY-GET.)

I do MOVE then UPDATE(RD1). But using GET, where do I place the MOVE?

---

<div class="post-metadata">

**Author:** ![Tomas\_Moraes](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/tomas_moraes/32/6982_2.png) [@Tomas\_Moraes](https://techcommunity.softwareag.com/u/Tomas_Moraes)\
**Post date:** [April 28, 2022, 12:07am UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/7 "2022-04-28T00:07:55Z")

</div>

Can I assume that ACCEPT has exactly the same effect of IF … END-IF in this situation?

---

<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:** [April 28, 2022, 12:13am UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/8 "2022-04-28T00:13:30Z")

</div>

Yes, you can supply the RI=ON from your Natural dynamic parameters (PARM=‘RI=ON’) or in your Natural parameters or profile (contact your sysadmin if you’re not clear on how to do this)

```auto
RD1. READ MY-VIEW WITH DESC-FIELD-1 GE #INI-SCOPE
  ACCEPT IF INI-DATE GE 20220412
        AND INI-DATE LE 20220416
        AND CONTROL-BUSINESS-FIELD-1 EQ 1
  MOVE 1 TO CONTROL-BUSINESS-FIELD-8
  MY-GET. GET MY-VIEW *ISN(RD1.)
  UPDATE (MY-GET.)
  END TRANSACTION
  ADD 1 TO #AMOUNT-UPDATED
END-READ
MOVE *COUNTER (RD1.) TO #AMOUNT-READ

```

With either the RI=ON or GET approach above, you will have at most 1 record on hold at a time since you are using a READ statement. A FIND statement can put all selected records (meeting WITH criteria) on hold at once, but a READ only puts the record on hold when read.

---

<div class="post-metadata">

**Author:** ![Tomas\_Moraes](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/tomas_moraes/32/6982_2.png) [@Tomas\_Moraes](https://techcommunity.softwareag.com/u/Tomas_Moraes)\
**Post date:** [April 28, 2022, 12:57am UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/9 "2022-04-28T00:57:42Z")

</div>

> [@Douglas\_Kelly](#):
>
> `MOVE *COUNTER (RD1.) TO #AMOUNT-READ`

I thinked I couldn’t use \*COUNTER outside the related loop

---

<div class="post-metadata">

**Author:** ![wolfgang.winter](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/wolfgang.winter/32/17954_2.png) [@wolfgang.winter](https://techcommunity.softwareag.com/u/wolfgang.winter)\
**Post date:** [April 28, 2022, 8:05am UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/10 "2022-04-28T08:05:10Z")

</div>

Please note there’s a difference whether you have

`READ MY-VIEW WITH DESC-FIELD-1 STARTING FROM #START ENDING AT #END`

or

`READ MY-VIEW WITH DESC-FIELD-1 STARTING FROM #START TO #END`

In the first case only the #START value will be sent to the database and any selection will be handled by NATURAL once a record has been read.

However, in the second case **both** the #START and #END values will be sent to ADABAS and thus the database will handle the selection and only return selected records to NATURAL.

So if possible tighten your READ criteria to limit the number of records that hit NATURAL in the first place, and thus reduce the number of records put in hold.

In your example you don’t even have an upper limit so the number of records hitting ACCEPT most likely is even higher than it would need to be anyway.

---

<div class="post-metadata">

**Author:** ![George\_Cooper](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/george_cooper/32/7831_2.png) [@George\_Cooper](https://techcommunity.softwareag.com/u/George_Cooper)\
**Post date:** [April 28, 2022, 8:02pm UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/11 "2022-04-28T20:02:00Z")

</div>

Hi Tomas,

Just my 2 cents worth, and attempt to answer some of your ancillary questions that may not have been addressed.

> [@Tomas\_Moraes](#):
>
> One doubt: If I do END TRANSACTION on each record, the amount of locks is gradually decreasing?

Not exactly, if I understand your question. When an END TRANSACTION statement is executed, any updates to records on hold are committed to the database and all held records are released. So the number of “locks” is immediately reduced to zero. In your original example, the “locks” count would start increasing again for every new record read until one meets the update criteria and it is updated and ET’ed. However, with the GET method shown by Douglas, (my preference too) the number of held records is never more than 1 at a time, so the “locks” count is never \> 1. A more advanced, slightly more efficient method would be to use an #ET-COUNTER you increment for each record you GET and UPDATE, and then only issue an ET when #ET-COUNTER \> 50, and then reset #ET-COUNTER. You also have to add an ET after the END-READ, just in case. It’s only worth doing this if you are updating lots of records.

> [@Tomas\_Moraes](#):
>
> I do MOVE then UPDATE(RD1). But using GET, where do I place the MOVE?

Since the GET rereads the record into the VIEW buffer, you should put the MOVE for any fields to be updated after the GET and before the UPDATE. If MOVE is before the GET, the values will just be overlaid with the original values.

> [@Tomas\_Moraes](#):
>
> Can I assume that ACCEPT has exactly the same effect of IF … END-IF in this situation?

That depends on the IF … END-IF, I guess and this exact coding. You can mimic the logic of ACCEPT with an IF … END-IF for most situations by adding an IGNORE ELSE ESCAPE TOP to the IF, for example:

RD1. READ MY-VIEW WITH DESC-FIELD-1 GE #INI-SCOPE  
IF INI-DATE GE 20220412  
AND INI-DATE LE 20220416  
AND CONTROL-BUSINESS-FIELD-1 EQ 1  
IGNORE /\* Accept and process record  
ELSE  
ESCAPE TOP /\* Reject record  
END-IF  
MY-GET. GET MY-VIEW \*ISN(RD1.)  
MOVE 1 TO CONTROL-BUSINESS-FIELD-8  
UPDATE (MY-GET.)  
END TRANSACTION  
ADD 1 TO #AMOUNT-UPDATED  
END-READ  
MOVE \*COUNTER (RD1.) TO #AMOUNT-READ

> [@Tomas\_Moraes](#):
>
> I thinked I couldn’t use \*COUNTER outside the related loop

Yes the value of \*COUNTER is available outside the loop. But always best to qualify with the READ label, \*COUNTER (RD1), in case there are multiple Reads so Natural doesn’t get confused which \*COUNTER you are referring to.

Great tip from Wolfgang, always a good idea to set an exit criteria of some kind for READ loops, either with an ENDING AT #END-KEY or TO #END-KEY, or you could put an IF test … ESCAPE BOTTOM (RD1.) END-IF before the ACCEPT statement. Unless you know the data and you will always have to read to the end of the descriptor from your starting point #INI-SCOPE to find all records that need to be updated.

Hope that helps more than confuses…  
Good luck,  
George

```auto

```

---

<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 28, 2022, 9:42pm UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/12 "2022-04-28T21:42:31Z")

</div>

Good job of filling in the gaps, George. 😉

Tomas,

Let’s consider a file of 1 million records.

If you are certain to be updating (almost) every record, then a few RI commands for the rejections would add little overhead, but 1,000,000 GETs would not be justified. (Why retrieve a record you already have?)

If you are certain that very few records will be updated, then a few GETs will add little overhead, but 1,000,000 RI commands would not be justified.

As a rule, I don’t like to issue Adabas commands that are unnecessary. I consider the RI and GET commands to be unnecessary overhead. Here is a program structure for updating a moderate number of records.

```auto
RD1. READ MY-VIEW WITH DESC-FIELD-1 GE #INI-SCOPE
  ADD 1 TO #COUNT
  IF INI-DATE GE 20220412
   AND INI-DATE LE 20220416
   AND CONTROL-BUSINESS-FIELD-1 EQ 1
    THEN
      MOVE *COUNTER TO #AMOUNT-READ
      MOVE 1 TO CONTROL-BUSINESS-FIELD-8
      UPDATE (RD1.)
      ADD 1 TO #AMOUNT-UPDATED
      ADD 1 TO #ET
  END-IF
  IF #COUNT > 500
   OR #ET > 50
    THEN
      END TRANSACTION
      RESET #COUNT
            #ET
  END-IF
END-READ
END TRANSACTION
END

```

If you decide to use GETs, consider applying Multi-fetch to reduce the physical READ command count.

---

<div class="post-metadata">

**Author:** ![Tomas\_Moraes](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/tomas_moraes/32/6982_2.png) [@Tomas\_Moraes](https://techcommunity.softwareag.com/u/Tomas_Moraes)\
**Post date:** [May 6, 2022, 1:25am UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/13 "2022-05-06T01:25:00Z")

</div>

What a class! Amazing! I appreciate it!

---

<div class="post-metadata">

**Author:** ![Manuel\_Sanchez2](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/manuel_sanchez2/32/1300_2.png) [@Manuel\_Sanchez2](https://techcommunity.softwareag.com/u/Manuel_Sanchez2)\
**Post date:** [May 6, 2022, 8:30pm UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/14 "2022-05-06T20:30:19Z")

</div>

buenas tardes como puedo leer dos work file en Natural de forma secencial

---

<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:** [May 6, 2022, 9:05pm UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/15 "2022-05-06T21:05:39Z")

</div>

Please open a new thread for this topic.  
Google translate: Por favor, abre un nuevo hilo para este tema.

---

<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:** [August 4, 2022, 9:06pm UTC](https://techcommunity.softwareag.com/t/accept-reject-does-they-influence-the-nisnhq-value/257051/16 "2022-08-04T21:06:36Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
