ON ERROR and skiping to next record

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

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. This addresses exactly your problem.

So…FIELD1 is P2

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

Is this good ?

Yes! :smiley: :smiley: :smiley: :smiley: :smiley:

Thanks very much for YOUR help :slight_smile:

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