Undo the transaction and create a message

Hi,

I have situtation as follows,

RUN src/InvoicePost.p
(OUTPUT vErrorMsgCaused dueTo).
IF RETURN-VALUE = "ERROR" THEN DO:
UNDO trx-block , RETURN "ERROR".
END.
end. /* trx-block */

Run p_shootMessageCauseOfError.

If an error happens, I want to populate a record in the database with the value of 'vErrorMsgCaused dueTo' variable. What is happening now is it never excute the internal procedure p_shootMessageCauseOfError since there is a return. If I move up the excution of that internal procedure before undo, while undoing , it undo the DB record what I created in p_shootMessageCauseOfError .

How can I accomplish this.

TIA
Philip P Oommen
 
If you are in a transaction block and do an undo, you can't retain any database records created ... or it wouldn't be a very atomic transaction, would it. Set a flag and create the record outside the block.
 
Hi,

I have situtation as follows,

RUN src/InvoicePost.p
(OUTPUT vErrorMsgCaused dueTo).
IF RETURN-VALUE = "ERROR" THEN DO:
UNDO trx-block , RETURN "ERROR".
END.
end. /* trx-block */

Run p_shootMessageCauseOfError.

If an error happens, I want to populate a record in the database with the value of 'vErrorMsgCaused dueTo' variable. What is happening now is it never excute the internal procedure p_shootMessageCauseOfError since there is a return. If I move up the excution of that internal procedure before undo, while undoing , it undo the DB record what I created in p_shootMessageCauseOfError .

How can I accomplish this.

TIA
Philip P Oommen

Thanks much for your Reply.
As you said , please help me to create a record outside the transaction. My problem is in the above snippet of code how can I execute the procedure 'Run p_shootMessageCauseOfError' because once the error appears it returns from the above line. How can tweak the code so that contol has to come down even after an error occur. Instead return from there.
-Philip-
 
E.g., define a no-undo variable and set it to FAILED on entry to the block and to PASSED if you get through the other program without an error. Then test the variable after the block and write your record.

Or, look up CATCH blocks, but that is a bigger project.
 
Back
Top