Hello,
this is cross post from NI forum...
http://forums.ni.com/t5/LabVIEW/SAP-BAPI-ActiveX-Interface/td-p/1715732
I'm trying to integrate our test stations to SAP ERP. SAP stores data in busines objects in busines object repository. The objects are exposed over BAPI interface. There is a lot of different busines objects in the repository. SAP developers can also build new objects if they want. The objective is to read inspection characeristics from quality management module of SAP. I haven't done much ActiveX stuff, neither know much about SAP, so I started with a simple example that I found searching for BAPI examples. The example works fine in Excel. The example just reads some data from a sales order object.
Sub BAPI1()Dim
oBook As Workbook
Dim oSheet As Worksheet
Dim oBAPICtrl As Object
Dim oBAPILogon As Object
Dim oSalesOrder As Object
Dim oItem As Object
Dim iIndex As Integer
Set oBook = Application.ActiveWorkbook
Set oSheet = oBook.Worksheets(1)
'---------------------------------
' Initialize SAP ActiveX Control.
'---------------------------------
Set oBAPICtrl = CreateObject("sap.bapi.1")
'---------------------------------
' Initialize SAP ActiveX Logon.
'---------------------------------
Set oBAPILogon = CreateObject("sap.logoncontrol.1")
'-----------------------------------
' Initialize the connection object.
'-----------------------------------
Set oBAPICtrl.Connection = oBAPILogon.newconnection
'--------------------
' Logon with prompt.
'--------------------
oBAPICtrl.Connection.System = "Q02"
oBAPICtrl.Connection.Client = 101
oBAPICtrl.Connection.Logon
'---------------------------------
' Retrieve a sales order.
'---------------------------------
Set oSalesOrder = oBAPICtrl.GetSAPObject("SalesOrder","0010732181")
'-----------------------------------
' Display Sales Order header data.
'-----------------------------------
oSheet.Cells(2, 1).Value = oSalesOrder.salesdocument
oSheet.Cells(2, 2).Value = oSalesOrder.netvalue
oSheet.Cells(2, 3).Value = oSalesOrder.orderingparty.customerno
oSheet.Cells(2, 4).Value = oSalesOrder.documentdate
oSheet.Cells(2, 5).Value = oSalesOrder.items.Count
'-----------------------------------
' Logoff SAP and close the control.
'-----------------------------------
oBAPICtrl.Connection.logoff
Set oBAPILogon = Nothing
Set oBAPICtrl = Nothing
End Sub
[/CODE] I tried to implement that in LabVIEW. The logon and logout part works, I can also obtain SalesOrder object with GetSAPObject method. There is no error and probing the Object output from GetSAPObject methods gives an integer value - probably a reference to the SalesOrder object. Now I can't figure out how do I read the object properties. It's very simple in VBA. I also don't know how do I call object methods. I would appreciate any hints... Bye, Mirko