# Regarding ACCEPT/REJECT statement?

**URL:** <https://techcommunity.softwareag.com/t/regarding-accept-reject-statement/60907>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [May 3, 2006, 3:44pm UTC](https://techcommunity.softwareag.com/t/regarding-accept-reject-statement/60907 "2006-05-03T15:44:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahul\_mf](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rahul\_mf](https://techcommunity.softwareag.com/u/rahul_mf)\
**Post date:** [May 3, 2006, 3:44pm UTC](https://techcommunity.softwareag.com/t/regarding-accept-reject-statement/60907/1 "2006-05-03T15:44:16Z")

</div>

Hi all,

My query–\>  
What is the difference in using an IF statement and using an ACCEPT/REJECT statement?

---

<div class="post-metadata">

**Author:** ![anon29934956](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@anon29934956](https://techcommunity.softwareag.com/u/anon29934956)\
**Post date:** [May 3, 2006, 3:54pm UTC](https://techcommunity.softwareag.com/t/regarding-accept-reject-statement/60907/2 "2006-05-03T15:54:28Z")

</div>

The documentation states:

> [@](#):
>
> The statements ACCEPT and REJECT are used for accepting/rejecting a record based on user-specified logical criterion. The ACCEPT/REJECT statement may be used in conjunction with statements which read data records in a processing loop (FIND, READ, HISTOGRAM, CALL FILE, SORT or READ WORK FILE). The criterion is evaluated after the record has been selected/read.

> [@](#):
>
> The IF statement is used to control execution of a statement or group of statements based on a logical condition.

I hope this helps  
Regards,  
Michael

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [May 3, 2006, 5:58pm UTC](https://techcommunity.softwareag.com/t/regarding-accept-reject-statement/60907/3 "2006-05-03T17:58:40Z")

</div>

> [@](#):
>
> What is the difference in using an IF statement and using an ACCEPT/REJECT statement?

AFAIK there are no major differences between an IF and ACCEPT REJECT. You can express each ACCEPT or REJECT-Statement with an IF-Statement. Both have no influence of \*COUNTER/\*NUMBER (i.e. the number of processing loops).

The only thing you have to think about is the following (according to the documentation):

> [@](#):
>
> - If an ACCEPT condition is satisfied, the record will be accepted and consecutive ACCEPT/REJECT statements will be ignored.
> - If a REJECT condition is satisfied, the record will be rejected and consecutive ACCEPT/REJECT statements will be ignored.[…]  
> If other statements are interleaved between multiple ACCEPT/REJECT statements, each ACCEPT/REJECT will be handled independently.

---

<div class="post-metadata">

**Author:** ![rahul\_mf](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rahul\_mf](https://techcommunity.softwareag.com/u/rahul_mf)\
**Post date:** [May 4, 2006, 10:18am UTC](https://techcommunity.softwareag.com/t/regarding-accept-reject-statement/60907/4 "2006-05-04T10:18:41Z")

</div>

Does it mean the only difference is that →

By using an IF statement we can perform a set of instructions/intruction (depending upon the logical condition of IF statement)

But by using an ACCEPT/REJECT we cannot perform a set of instructions/intruction, only thing it can do is to accept or reject a record based on a logical condition.

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [May 4, 2006, 12:18pm UTC](https://techcommunity.softwareag.com/t/regarding-accept-reject-statement/60907/5 "2006-05-04T12:18:41Z")

</div>

> [@rahul\_mf](#):
>
> Does it mean the only difference is that →
> 
> By using an IF statement we can perform a set of instructions/intruction

Correct! I guess the right of ACCEPT/REJECT to exist is, that it is more compact. Example:

```auto
REJECT IF criterion1
REJECT IF criterion2
ACCEPT IF criterion3
```

does the same as

```auto
IF criterion1
  ESCAPE TOP
ELSE
  IF criterion2
    ESCAPE TOP
  ELSE
    IF NOT criterion 3
      ESCAPE TOP
    END-IF
  END-IF
END-IF
```

---

<div class="post-metadata">

**Author:** ![Arnold\_Carreon](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@Arnold\_Carreon](https://techcommunity.softwareag.com/u/Arnold_Carreon)\
**Post date:** [May 5, 2006, 1:03am UTC](https://techcommunity.softwareag.com/t/regarding-accept-reject-statement/60907/6 "2006-05-05T01:03:24Z")

</div>

… and then there is the possible problem if the hierarchy of accept/reject is not correct.

---

<div class="post-metadata">

**Author:** ![rahul\_mf](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rahul\_mf](https://techcommunity.softwareag.com/u/rahul_mf)\
**Post date:** [May 8, 2006, 3:33pm UTC](https://techcommunity.softwareag.com/t/regarding-accept-reject-statement/60907/7 "2006-05-08T15:33:53Z")

</div>

Is it true —\>

“ACCEPT/REJECT does not write in the buffer ,i.e. , if a condition of REJECT IF statement is satisfied than data wont be written in the buffer and same is the case when condition of ACCEPT IF statement is not satisfied.”

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [May 8, 2006, 7:42pm UTC](https://techcommunity.softwareag.com/t/regarding-accept-reject-statement/60907/8 "2006-05-08T19:42:06Z")

</div>

Is it true —\>

“ACCEPT/REJECT does not write in the buffer ,i.e. , if a condition of REJECT IF statement is satisfied than data wont be written in the buffer and same is the case when condition of ACCEPT IF statement is not satisfied.”

Not true. ACCEPT/REJECT are statements within a loop. A record gets read at the beginning of the loop.

---

<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/regarding-accept-reject-statement/60907/9 "2021-04-02T14:40:37Z")

</div>


