Jump to content

SAP BAPI ActiveX Interface


S59X

Recommended Posts

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.

post-1148-0-14125600-1316763291_thumb.pn

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 by S59X
Link to comment

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.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.