cancel
Showing results for 
Search instead for 
Did you mean: 

Calling custom BAPI from VB/VBA

Former Member
0 Kudos

Hello, all,

I have written a custom business object and its associated function module. I can single-test the business object inside native SAP, and it works successfully. I can also establish a handle to the business object from VBA (using the .GetSAPObject method of the BAPI control object.) I can't call the method of the custom BAPI, though--I get error message "UploadResults is not a BAPI method." (UploadResults is the name of both my business object and the method of the business object.) Here's my source code:

Sub UploadChemToSAP()

Dim gConnection As Object 'global connection object

Dim oBAPICtrl As New SAPBAPIControl

Dim oBAPIService As Object

Dim boFunction As Object, boResults As Object, boReturn As Object

'Set up connection object for SAP. Note that the SAP BAPI ActiveX object must be available on the form or otherwise.

Set gConnection = oBAPICtrl.Connection

'Log in to SAP. Seems like passwords must be in uppercase. There are examples of people defaulting some (or all)

'of the login values

gConnection.logon

Set boFunction = Nothing

Set boResults = Nothing

Set boReturn = Nothing

Set oBAPIService = oBAPICtrl.GetSAPObject("UploadResults")

Set boReturn = oBAPICtrl.DimAs(oBAPIService, "UploadResults", "Return")

'Log out of SAP.

gConnection.logoff

End Sub

To my knowledge, I have released both the business object and its associated method. The function module has been released, too. Any suggestions on where to go from here?

Thanks in advance,

Eric

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hey,

Please check the "Processing Type" of the function module implementing the method. It should be a Remote-Enabled module.

Kiran

Former Member
0 Kudos

Yes, it's remote-enabled.

Thanks,

Eric

Answers (1)

Answers (1)

Former Member
0 Kudos

OK, I figured it out, so I thought I'd share the solution with you. My method I was using was implemented as a local method. Once I recreated it as an API method, I was able to access it from VB/VBA immediately.