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.
Software/Hardware used:
ASKED:
March 10, 2005 1:04 PM
UPDATED:
March 14, 2005 3:51 PM
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.