Simple bapi implementation steps
1. Create a function module
1. In sm11, create the required structure
2. Create a function group in se80
3. In se37, create a function module
Note: A function group can only contain one bapi. The parameter value must have an export parameter of the bapireturn type.
2. Encapsulation
1. In swo1, create an object type
2. Add the function module as a method, utilities-> API methods-> Add Method
3. Release object and module. In bapi browser. That is, it can be called externally.
3. Call
1. If ABAP is called in another system, Iot platform first establishes RFC in sm59 and connects to R/3 with bapi (zgogo)
Call function "zbapixxxxx" Destination zgogo exporting...
2. If Java is used to call
Introduce the package; (not necessarily from IBM)
Import com. sap. RFC .*;
Import com. sap. RFC. Exception .*;
Import com. IBM. sap. bapi .*;
Import com. IBM. sap. bapi. generated .*;
Establish a connection; call... (See call_bapi.java)
VBA for SAP
Private sub commandbutton#click ()
Set ofunction = Createobject ("sap. logoncontrol.1 ")
Set oconnection = ofunction. newconnection
Oconnectivity. Client = "500"
Oconnection. Language = "en"
Oconnection. User = "user"
Oconnection. Password = "pasword"
Oconnection. applicationserver = "sap1.yok.com.cn"
Oconnection. systemnumber = "01"
Result = oconnection. Logon (0, true)
Set ofun = Createobject ("sap. Functions ")
Set ofun. Connection = oconnection
Set func = ofun. Add ("rfc_read_table ")
Func. Exports ("query_table") = "Mara"
If func. Call = true then
Set oline = func. Tables. Item ("data ")
Row = oline. rowcount
I = 1
Do while I <= row
Cells (I, 1) = mid (TRIM (oline. Value (I, 1), 4, 22)
I = I + 1
Loop
Else
Msgbox "fail"
End if
End sub
Vba2private sub commandbutton#click ()
Dim sapfunctionctrl as object 'function control (collective object)
Dim sapconnection as object 'Connection object
Dim thefunc as object 'function object
Set sapfunctionctrl = Createobject ("sap. Functions ")
Set sapconnection = sapfunctionctrl. connectionsapconnection. Client = "800"
Sapconnection. User = "user"
Sapconnection. Language = "en" If sapconnection. Logon (0, false) <> true then
Msgbox "no connection to R/3! "End ifset thefunc = sapfunctionctrl. Add (" zrfcping ")
If thefunc. Call then' call the RFC FM
Msgbox "RFC call is okay"
End if
Sapfunctionctrl. Connection. Logoff
Set sapconnection = nothing
Set sapfunctionctrl = nothing
End sub