SAP BAPI CommitWork error DCOM Connector

SAP development
Visual Basic
I have a VB program using BAPIs with the DCOM Connector. The BAPI object and session object are exported to an MTS server machine. In the VB program I create a global OSession object and logon to R/3 at the form load event. In one function I instantiate the BAPI Object locally with Set oBO = oSession.CreateInstance("BOprogId"), and run some methods on the object that work fine and Set oBO = nothing at the end of the function. In a followup function I instantiate the BO again locally with Set oBO = CreateInstance("BOprogid"), then do a change method on instance dependant object after doing oBO.InitKeys. The BAPI return is succesful, so I want to commit the change and issue an oSession.CommitWork. The DCOM connector monitor shows the last function is ABAP4_COMMIT_WORK but it remains in an active state there and the VB program gets a nonzero returen: error> -2147023170, automation error The remote procedure call failed. I don't know why this happens. If I use oBO.CommitWork I get an error also: -2147467259 Object created in Session, so I assume if you instantiate an object with oSession.CreateInstance you have to commit changes using the Session object. If I use Set oBO = CreateObject("BOprogId") and commit with oBO.Commit, it works without error. This is not practical since I need to enqueue the SAP object in the first function with oBO.Enqueue method before the user makes changes in the UI. When the user requests the update I invoke the change function, then oBO.Dequeue, then oSession.CommitWork. Can you tell me why the commit fails, or what I may be doing wrong? Incedentanlly, the SAP object is sucessfully changed. The change BAPI does not have a commit work, so my program must request it. Please don't suggest using the doNet Connector, this is anot an option for this project. Thank you.

Answer Wiki

Thanks. We'll let you know when a new response is added.

You did not specify which release of SAP your are connecting to.
You should possibly know that not all bapis need a bapi_commit call. I would not know of any way you do a true 2 phase commit (MTS). So if you use MTS you might have to check if you can enlist somehow the SAP source into the transaction… With SAP Connector it’s always been a one phase commit for me. Enjoy

Discuss This Question: 1  Reply

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Floridaguy51
    I found a workaround to this problem. I rebuilt my COM object in DCOM Object Builder to include the BapiService objectin the project. Then in the VB program instead of using oSession.CommitWork (which has the automation / RPC error), I instantiate the BapiService object with Set oBapiService = oSession.CreateInstance("NameSpace.BapiService.1") and then use oBapiService.BapiTransactionCommit "X" return2. This accomplishes the commit needed and still using the Session object. I would still like to know why the Session.CommitWork has an error, but if I don't use the session and simply use CreateObject, then run the object change method, then use oBO.CommitWork this works fine with no error. The DCOM connector documentation recommends to use Session object (to enable use of multiple objects and BAPIs in a single LUW) and the they clearly show to sue a 'commit for the session'. Oddly, none of the actual sample programs use any commits which makes this frustratiing. I have absolutley checked the change BAPI I am using and it is in the SAP 4.0A or higher model, no commit in the BAPI, client must make the commit. THanks for any suggestions as to why this error occurs.
    0 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: