S59X Posted September 23, 2011 Report Share Posted September 23, 2011 (edited) 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 Edited September 23, 2011 by S59X Quote Link to comment
asbo Posted September 23, 2011 Report Share Posted September 23, 2011 You'll need to cast that GetSAPObject variant to a LabVIEW ActiveX reference. You already do this with the Connection variant, you just need to figure the right type of reference to cast the GetSAPObject output as. Quote Link to comment
S59X Posted September 23, 2011 Author Report Share Posted September 23, 2011 There isn't any ActiveX references of SalesOrder object. There are a lot of different objects in SAP with different interfaces. The objects are developed by SAP developers using ABAP. I can look up the interface in SAP documentation, but I don't have a proper ActiveX reference to cast. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.