# How to avoid NAT1310?

**URL:** <https://techcommunity.softwareag.com/t/how-to-avoid-nat1310/61011>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Linux\
**Created:** [May 18, 2006, 7:01pm UTC](https://techcommunity.softwareag.com/t/how-to-avoid-nat1310/61011 "2006-05-18T19:01:41Z")\
**Posts on this page:** 4\
**Page:** 1

<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 18, 2006, 7:01pm UTC](https://techcommunity.softwareag.com/t/how-to-avoid-nat1310/61011/1 "2006-05-18T19:01:41Z")

</div>

The Natural-Documentation of ON ERROR says:

> [@](#):
>
> When a subroutine structure is built by using CALLNAT, PERFORM or FETCH RETURN, each module may contain an ON ERROR statement.  
> When an error occurs, Natural will automatically trace back the subroutine structure and select the first ON ERROR statement encountered in a subroutine for execution.

and the Documentation of RETRY says:

> [@](#):
>
> The RETRY statement must be placed in the object that causes the Error 3145.

That means: If a NAT3145 happens in a module with no ON ERROR-Block, Natural traces back all structure-levels. And if an ON-ERROR-Block is found in one of the calling programs, this one is taken for error handling. But there, I can’t do a RETRY, otherwise a NAT1310 occurs.

So my question is: How can I avoid this situation from the ON-ERROR’s point of view? Is it possible to code the following way:

```auto
ON ERROR
  IF *ERROR-NR = 3145
    IF this-block-is-found-by-back-tracing /* <-- what to code here?
      WRITE 'Record is in hold! Try later!'
      ESCAPE ROUTINE /* or whatever
    ELSE
      INPUT 'Hit ENTR to retry'
      RETRY
    END-IF
  END-IF
END-ERROR
```

Maybe there’s something with IF \*PROGRAM = ‘…’ or IF \*LEVEL = … But I got no idea how to solve this.

I know, that it’s possible to give every module an ON-ERROR-Block to avoid a NAT1310. But that would be a real time-consuming job for me (we got \> 10000 Modules).

Regards,

Matthias

---

<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:** [May 18, 2006, 10:53pm UTC](https://techcommunity.softwareag.com/t/how-to-avoid-nat1310/61011/2 "2006-05-18T22:53:14Z")

</div>

USR2001N will give you detailed information about the last error. Only if level and program name match, you may issue a retry (this user exit will provide you with the missing system variables \*error-program and \*error-level)🙂

---

<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 19, 2006, 12:27pm UTC](https://techcommunity.softwareag.com/t/how-to-avoid-nat1310/61011/3 "2006-05-19T12:27:41Z")

</div>

Thanks! USR2001N is a quite simple and working solution. It’s a shame that I didn’t know this by myself. :oops: 😉

The USR2001N-Parameter P\_ERROR\_PROGRAM delivers an alphanumeric 32-byte field. But I tested it and it seems, that it’s always filled with the short name of the module. This is important in case of subroutine-modules, which have a long and a short name… But P\_ERROR\_LEVEL should work anyway.

---

<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/how-to-avoid-nat1310/61011/4 "2021-04-02T14:40:39Z")

</div>


