Simple bapi implementation steps

Source: Internet
Author: User
Tags rfc
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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.