How do you make a Function Return / Raise an Error?

JTWilson

New Member
I’ve been writing a Progress .W which has a number of User defined Functions, which I want to return / raise an error like a Procedure will do, if an error is encountered. (e.g. ‘DO ON ERROR UNDO, RETURN ERROR:’) But this doesn’t seem to work for me. I’ve attached a simple program to test the rollback of a transaction based off this error. Is there a way or a work around for making a Function trigger an Error status in the calling Procedure? As these functions are called so many times that it would be nice to just have a Function that can return an error like a Procedure.

Code:
 DEF VAR v_TestTran AS CHAR INIT "FirstVal". 

FUNCTION Test3 RETURN INT:
DO ON ERROR UNDO, RETURN ERROR:
FIND BIK_Monthly.
END.
END FUNCTION.

MainTrans:
DO TRANSACTION ON ERROR UNDO MainTrans:
RUN Test1.
/* RUN Test2. */
MESSAGE Test3() 
VIEW-AS ALERT-BOX INFO.
END.

MESSAGE v_TestTran
VIEW-AS ALERT-BOX INFO.

PROCEDURE Test1:
v_TestTran = "SecondVal".
END PROCEDURE.

PROCEDURE Test2:
DO ON ERROR UNDO, RETURN ERROR:
FIND BIK_Monthly.
END.
END PROCEDURE.

 
Back
Top