Try OpenEdge Now
skip to main content
Error Handling
Traditional Error Handling : Statement errors : Statement behavior versus block behavior

Statement behavior versus block behavior

Consider this procedure:
/* This statement executes and raises the ERROR condition. */
FIND FIRST Customer WHERE CustNum = 1000.

/* This statement does not execute. */
FIND FIRST Customer WHERE CustNum = 2000.
The first statement will fail since the Sports2000 database does not contain a matching Customer record. When it fails, the AVM stops execution of the block at the failed statement. In other words, if another executable statement follows a failed statement in a block, it will not execute.
The AVM displays a message, like the following, to the default output destination, which is usually the screen:
This also represents the line between error processing at the statement level and error processing at the block level. The AVM takes its next actions based on either default error handling block properties or statement options of the block header statement. Block statement options cannot alter the halt in execution or the display of the default error message. Only the NO-ERROR option on the statement can do this.
Recall from ABL Block Essentials that even a simple procedure has an implicit block with an implicit ON ERROR phrase. The default error handling for that block is UNDO followed by either RETRY or LEAVE. In the previous example, there is no user input in the procedure, so the branching option is LEAVE. Control returns to the caller of the procedure block. Since there is no caller, the "application" terminates.