cancel
Showing results for 
Search instead for 
Did you mean: 

Using transactions (start,end,rollback) with UI operations

Former Member
0 Kudos

Hi,

I'm trying to use transactions in order to couple 2 database operations:

1. Adding a document through the UI.

2. Adding a document through the DI.

If one fails, I want the other to rollback. In order to do that, I'm trying to start a transaction before the 1st UI document addition and end/rollback once it is finished and I've added the 2nd document through the DI.

Problem is that the rollback option doesn't seem to block the addition of a document through the UI.

Is it possible to implement this idea with current SDK tools?

private bool BeforeFormAdd(SAPbouiCOM.ItemEvent pVa)

        {

            if (!mCompany.InTransaction)

                mCompany.StartTransaction();

            return true;

        }

private bool AfterFormAdd(SAPbouiCOM.ItemEvent pVal)

        {

            if (mCompany.InTransaction)

            {

                if (Create2ndDocSuccess())

                 mCompany.EndTransaction(di.BoWfTransOpt.wf_Commit)

               else

                 mCompany.EndTransaction(di.BoWfTransOpt.wf_RollBack);

           }

             return true;

        }

Thanks,

Heli.

Accepted Solutions (1)

Accepted Solutions (1)

pedro_magueija
Active Contributor

Hi Heli,

Also tried this in the past with the same result as you. Since the transaction is started on the company object (not necessarily B1) you can only, unfortunately, rollback actions executed on that company object. It is like trying to get the NewObjectKey for a Document added via UI. Since your object didn't add it then there is no way to get it (via that method).

I speculate that when a transaction is started it is only for the present connection (the one of your Company object) and UI must have a different one through which it does its operations. Hence why we cannot rollback the "UI doc".

Again this is me speculating, maybe someone as more information on this matter that they can share.

Good luck.

Best regards,

Pedro Magueija

ps: I solved my problem by creating a routine that verified if the 2nd document could be added and ran it in the BeforeDataAdd Event.

Answers (0)