# ON ERROR and skiping to next record

**URL:** <https://techcommunity.softwareag.com/t/on-error-and-skiping-to-next-record/61638>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [October 30, 2006, 2:25pm UTC](https://techcommunity.softwareag.com/t/on-error-and-skiping-to-next-record/61638 "2006-10-30T14:25:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [October 30, 2006, 2:25pm UTC](https://techcommunity.softwareag.com/t/on-error-and-skiping-to-next-record/61638/1 "2006-10-30T14:25:22Z")

</div>

I have something like that:

READ X BY KEY1  
IF X.FIELD1 NE 3  
ESCAPE BOTTOM  
END-IF  
\*  
…  
END-READ

I get error 954 on line with: ’ IF X.FIELD1 NE 3’, FIELD1 is  
member of KEY1. I need to bypass this i mean BAD record.

Could i correct this in that way:

READ X BY KEY1  
IF X.FIELD1 NE 3  
ESCAPE BOTTOM  
END-IF  
\*  
ON ERROR  
IF _ERROR-NR = 954  
IGNORE /_ READ NEXT RECORD ?  
END-IF  
END-ERROR  
\*  
…  
END-READ

Would it be working and th next record will be read ?

Thanks in advance

---

<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:** [October 30, 2006, 2:37pm UTC](https://techcommunity.softwareag.com/t/on-error-and-skiping-to-next-record/61638/2 "2006-10-30T14:37:00Z")

</div>

If X.FIELD1 is not numeric, your IF-test will produce NAT954!

You first have to check, whether X.FIELD1 is numeric. See [this thread](http://natural.forums.softwareag.com/viewtopic.php?t=570). This addresses exactly your problem.

---

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [October 30, 2006, 3:21pm UTC](https://techcommunity.softwareag.com/t/on-error-and-skiping-to-next-record/61638/3 "2006-10-30T15:21:02Z")

</div>

So…FIELD1 is P2

IF FIELD1 = MASK (9Z)  
/\* field is numeric  
ELSE  
/\* field is not numeric  
END-IF

Is this good ?

---

<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:** [October 30, 2006, 4:56pm UTC](https://techcommunity.softwareag.com/t/on-error-and-skiping-to-next-record/61638/4 "2006-10-30T16:56:33Z")

</div>

Yes! 😃 😃 😃 😃 😃

---

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [October 30, 2006, 5:02pm UTC](https://techcommunity.softwareag.com/t/on-error-and-skiping-to-next-record/61638/5 "2006-10-30T17:02:12Z")

</div>

Thanks very much for YOUR help 🙂

---

<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:** [November 1, 2006, 11:00pm UTC](https://techcommunity.softwareag.com/t/on-error-and-skiping-to-next-record/61638/6 "2006-11-01T23:00:37Z")

</div>

> [@mun1ek](#):
>
> ON ERROR  
> IF _ERROR-NR = 954  
> IGNORE /_ READ NEXT RECORD ?  
> END-IF  
> END-ERROR

By the way: I’ve often seen such a IGNORE-Construction in an ON ERROR block. But IGNORE is not a statement to leave an ON ERROR block. Valid statements are:

RETRY (only on NAT3145)  
FETCH (not FETCH RETURN)  
STOP  
TERMINATE  
ESCAPE ROUTINE

If none of these Statements are used, your program is stopped with an error message.

See the documenation for more details: [http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat421mf/sm/onerror\_0910.htm#syn\_desc](http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat421mf/sm/onerror_0910.htm#syn_desc)

---

<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/on-error-and-skiping-to-next-record/61638/7 "2021-04-02T14:40:55Z")

</div>


