UNDO statement
- Last Updated: February 24, 2026
- 3 minute read
- OpenEdge
- Version 12.2
- Documentation
Backs out all modifications to fields and variables made during the current iteration of a block, and indicates what action to take next.
Syntax
|
- label1
-
The name of the block whose processing you want to undo. If you do not name a block with label1, the AVM undoes the processing of the closest transaction or subtransaction block. In determining the closest transaction or subtransaction block, the AVM disregards
DO ON ENDKEYblocks that do not have theON ERRORorTRANSACTIONoption. - LEAVE label2
-
Indicates that after undoing the processing of a block, the AVM leaves the block you name with label2. If you do not name a block, the AVM leaves the block that was undone. After leaving a block, the AVM continues on with any remaining processing in a routine.
- NEXT label2
-
Indicates that after undoing the processing of a block, the AVM does the next iteration of the block you name with label2. If you do not name a block, the AVM does the next iteration of the block that was undone.
- RETRY label1
-
Indicates that after undoing the processing of a block, the AVM repeats the same iteration of the block you name with label1.
Because
RETRYin a block without user input results in an infinite loop, the AVM automatically checks for this possibility and converts aRETRYblock into aLEAVEblock, or aNEXTblock if it is an iterating block. This behavior is often referred to as infinite loop protection. - RETURN ...
- Returns to the calling routine, if there is one. The following table
describes various
RETURNoptions:Option Description return-value In procedures and VOID methods, this must be a CHARACTER string. The caller can use the RETURN-VALUEfunction to read the returned value. For user-defined functions, non-VOID methods and property getters, the value must match the specified return type.ERRORUndoes the current subtransaction, and raises ERRORin the caller. You cannot specifyERRORwithin a user-interface trigger block or a destructor.For user-defined functions see note below.
ERRORreturn-valueUndoes the current subtransaction, and raises ERRORin the caller. The CHARACTER string you provide is available to the caller in theRETURN-VALUEfunction. The AVM also creates anAppErrorobject and stores the return-value in theReturnValueproperty.For user-defined functions see note below.
ERRORerror-object-expressionUndoes the current subtransaction, and raises ERRORin the caller. The specified error object instance is thrown to the caller.For user-defined functions see note below.
NO-APPLYIn a user-interface trigger, prevents the AVM from performing the default behavior for the trigger event. Otherwise, the option is ignored. Note: UsingRETURN ERRORin a user-defined function sets the target variable of the function to the Unknown value (?) instead of raisingERRORin the caller. See ABL Error Handling for more detail. - THROW error-or-stop-object-expression
-
The
THROWdirective stops the execution of the current block of code, or the current iteration of an iterating block, and raises theERRORorSTOPcondition specified in error-or-stop-object-expression. The value of error-or-stop-object-expression must be an error or stop object type.UNDO, THROWhas the following restrictions:UNDO, THROWis not allowed in aCATCHblock associated with the main block of an object destructor method. You cannot raise or return anERRORorSTOPcondition from a destructor. To do so results in a compile-time error. You can useUNDO, THROWwithin the code of the destructor itself. In this case, the statement raises the condition in the destructor block and is caught by theON ERRORorON STOPdirective of the destructor block (which can only beUNDO, LEAVE).- The
UNDO, THROWstatement can itself raise anERRORcondition, orTHROWaProgress.Lang.SysErrorobject if it fails. For example, this would happen if the object reference used is not initialized. In this case, theSysErroris trapped by the same block that would have trapped the successfully thrown error or stop object.
Example
This example shows how the UNDO, THROW statement
specifies and populates an error object, and how the CATCH block handles
it:
r-undothrow1.p
|
Notes
- You can also specify
UNDOprocessing for a block by using theON ERROR,ON STOP, andON ENDKEYphrases with a block statement. - Class-based error or stop objects can be thrown from an OpenEdge
application server and handled by a
CATCHblock on an ABL client. To be throwable from an OpenEdge application server to an ABL client, any user-defined error classes must be defined asSERIALIZABLEon both the server and client sides. In addition, note that anySTOPcondition messages are written to the server log file, even if a stop object with the messages is caught on the client. For the full list of restrictions on class-based objects that are passed between server and client, see the Parameter passing syntax entry. - If you do not supply an action (
LEAVE,NEXT,RETRY,RETURN, orTHROW) with theUNDOstatement, the AVM applies the default undo action for the type of block being undone. The default action is determined by the block context and may result in retrying the block or leaving or advancing an iteration of the block. Because the default action is implicit and context-dependent, Progress Software recommends that you always specify an action with theUNDOstatement for clarity and consistency. - For more information on the
UNDOstatement, see Develop ABL Applications. For more information on error and stop handling in general, see ABL Error Handling.
See also
ON ENDKEY phrase, ON ERROR phrase, RETRY function, RETURN statement, ROUTINE-LEVEL ON ERROR UNDO, THROW statement