Try OpenEdge Now
skip to main content
ABL Essentials
Managing Transactions : Using the UNDO statement : STOP condition
 

STOP condition

ABL supports a STOP statement that lets the user terminate or restart your application altogether if an unrecoverable error occurs. You can trap the STOP condition in your block header statements as well. The STOP condition occurs when an ABL STOP statement executes or when the user presses the keyboard key mapped to that value. The STOP key, by default, is mapped to CTRL+BREAK in Windows and CTRL+C on UNIX.
When the STOP condition occurs, by default the AVM undoes the current transaction (if any). If the user starts the application from an OpenEdge tool, such as the Procedure Editor, OpenEdge terminates the application and returns to that tool. Otherwise, if the user starts the application using the Startup procedure (-p) startup option on the session, OpenEdge reruns the startup procedure.
OpenEdge raises the STOP condition when an unrecoverable system error occurs, such as when a database connection is lost or an external procedure that your code runs cannot be found. You cannot put the NO-ERROR condition on a RUN statement for an external procedure, as you can for an internal procedure. Therefore, the only way to trap such an error is to put the statement in a DO ON STOP block such as this:
DO ON STOP undo, LEAVE:
  RUN foo.p.
END.
MESSAGE "The procedure to support your last action cannot be found." SKIP
  SKIP "Please try another option." VIEW-AS ALERT-BOX.
If the procedure isn't found you still get an error, as shown in the following figure.
Figure 61. Procedure not found error message
But your procedure continues executing and you can deal with the error, as shown in the following figure.
Figure 62. Example message for procedure not found condition
If you anticipate that this might happen, it is better to use the SEARCH function to determine in advance whether the AVM can find the procedure in the current PROPATH:
IF SEARCH("foo.p") = ? THEN
  MESSAGE "The procedure to support your last action cannot be found." SKIP
    "Please try another option." VIEW-AS ALERT-BOX.
ELSE RUN foo.p.
* System and software failures