09-23-2011 04:14 AM
Hello,
This is a cross post from LAVA forum...
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
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. This is apicture from SAP BAPI documentatios showing available properties and methods.
I would appreciate any hints...
bye, Mirko
10-13-2011 01:42 AM
Dear Mirko,
like it is mentioned on the lavag.org forum, you have to cast the SAP Object variant to the ActiveX reference. Did you manage to find the right type of reference?
BR,
10-14-2011 01:07 AM
No, there isn't any reference type that matches BAPI Object. In fact, there can't be a fixed type reference, since BAPI object are actually function modules that SAP programmers write themselves using language called ABAP. I concluded that we can't call the object methods or read/write properties in LabVIEW, if we don't know the right type at development time. So, I gave up on BAPI API.
There are also other methods of SAP integration. O step down on abstraction scale is Remote Function Call (RFC) API. The API is much more involved, but it allows us to call functions that are behind BAPI objects. In a few test that I did it worked fine. The interface is exposed over three ActiveX controls - SAP Remote Function Call Control, SAP Table Factory Control and SAP Logon Control.
There is also .NET assembly and web services which I didn't tried.
Regards, Mirko
12-17-2012 05:19 AM
Hi Mirko,
I tried to collect datas from our SAP system, but as you, I did not succed in collecting datas with BAPI object.
Do you have any example with RFC functions ?
Best Regards,
12-16-2014 02:31 AM
Hi Mirko,
I tried to reproduce your screenshot in LabVIEW, with no success. Can you please provide me a link or a tutorial hoe to build that code? I googled several hours to find any good material, with no result. I place an activex container on the front panel, insert a SAPLogonControl into that, setting the properties regarding to the server/user, so I have an indicator on the block diagram. As next step, I place the automation open.vi from the activeX plaette (like you), so I have a reference (valid number). Does it mean, that I made a succesful logon? How to step on? I cannot create that property nodes, which would be essential.
Thanks for your help!
tzs
I work on Win7 + LabVIEW2009 + SAPgui installed (if it counts)
12-19-2018 07:34 AM
I was able to Export data from SAP server using ActiveX.The BAPI information (Name,Index,etc) have to be provided by SAP Backend Administrator.
01-07-2019 11:35 PM
Hello, ohiofudu
your diagram is not so clear, could you please send another one, thanks a lot.
01-08-2019 07:27 AM
Hello Henrylau,
Here is the SAP BAPI ActiveX Diagramm broken down
1.Connect to SAP with SAP Connection Information
2.Send SAP BAPI Command to SAP Server
3.Get SAP BAPI Responds (Import) from SAP Server
SAP Connection Information
Send API Information
Get (Import) BAPI Information from SAP
if you need more information let me know.
01-08-2019 09:37 PM
Hello ohiofudu,
Thanks for your infomation. Now i can call a RFC and get the response from SAP, here is my VI, it looks like a little differrent with yours, i think just because we used different version of SAPgui.
I still face a another problem to write a parameter(Values) to the tables whitch looks like below. It's not a real table, it is a structure, Do you get any idea how to write it?
01-09-2019 05:10 AM
Hi henrylau,
Try the Export Funktion.
what is the error message?