To avoid the STOP condition that is thrown ending program execution,
1. Add an ON STOP condition to the block containing the failed record retrieval statement.Example: Test for the STOP condition within the block where the lock is attempted
DO ON STOP UNDO, LEAVE:
FIND FIRST <tablename> EXCLUSIVE-LOCK.
END.
MESSAGE "hi " AVAILABLE(<tablename>)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
2. Alternatively, use NO-WAIT with NO-ERROR and check if the record is locked until the lock is released: Example:
ETIME(TRUE).
REPEAT:
FIND FIRST <tablename> EXCLUSIVE-LOCK NO-WAIT NO-ERROR.
IF NOT LOCKED <tablename> OR
ETIME GT 10000 /* 10000 milliseconds = 10 seconds */ THEN LEAVE.
END.
IF LOCKED <tablename> THEN DO:
MESSAGE "The record is locked" VIEW-AS ALERT-BOX.
LEAVE.
END.
Since OpenEdge 11.7, the "
-catchStop 1" feature can be used to CATCH a STOP condition. Refer to Article
How to use -catchStop to trap error 8812