0% found this document useful (0 votes)
859 views

Steps To Create BAPI

BAPI stands for Business Application Programming Interface. It is a remote-enabled function module used for communication between SAP and non-SAP systems. To create a BAPI, a remote-enabled function module is inserted into a business object. BAPIs must follow certain naming conventions and pass parameters by value. They can be used to generate reports, migrate data, and communicate between different servers.

Uploaded by

Ankur Jain
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
859 views

Steps To Create BAPI

BAPI stands for Business Application Programming Interface. It is a remote-enabled function module used for communication between SAP and non-SAP systems. To create a BAPI, a remote-enabled function module is inserted into a business object. BAPIs must follow certain naming conventions and pass parameters by value. They can be used to generate reports, migrate data, and communicate between different servers.

Uploaded by

Ankur Jain
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

What is a BAPI?

BAPI is a remote enabled function module, which is used to communicate between SAP to SAP, SAP
to NON-SAP systems.

BAPI RFC function module will be inserted into business object, it will convert into BAPI.

How BAPI is created?

 Remote Enabled Function Module created.


 Remote enabled function module inserted into a business object.
 BAPI created.

Uses of BAPI

In SAP BAPI`s can be used for

 Generating reports.
 For communication between different servers SAP-SAP or SAP- NON-SAP.
 BAPI`s can be used for data migration.

Difference between BAPI and RFC.

BAPI RFC
Used for communication Between SAP SAP Used for communication Between SAP SAP and
and SAP non-SAP SAP non-SAP
BAPI is a part of business object, it can RFC is a standalone function module, it cannot
communicate with other BAPI`s. communicate with other RFC`s
BAPI Uses Object Oriented concepts RFC uses procedure oriented concepts

We know BAPI is a remote enable function module but when ever we are creating a BAPI, we need
to follow some rules.

Rules and standards (as per SAP) for creating a BAPI:

 Every BAPI must start with BAPI or ZBAPI(Custom).


 All importing and exporting parameters must be of type structures (not direct type entries).
 All importing and exporting parameter names must start with BAPI or ZBAPI.
 All importing and exporting parameters must pass by value, as pass by reference is not
supported for remote communications.
 BAPI must have return parameter (to return messages like success, warning, error etc.) of type
BAPIRET2 or RETURN.

Follow the below steps to create a custom BAPI.

 Create structures in SE11 for importing and exporting parameters.


 Create a remote enabled function module with importing and exporting parameters (must be of
type structure) in SE37.
 Create a business object in SWO1.
 Insert RFC function module into business object.

Requirement: Develop a custom BAPI to get material details.

Step 1: Create structures for required importing and exporting parameters in SE11.

Go to SE11, create a structure ZBAPI_MATNR as below for importing parameter.

Similarly create another structure ZBAPI_MARA as below for exporting parameter.

Step 2: Go to SE37, create a remote enabled Function module to get material details for material
input.

Go to SE37, provide name as ZBAPI_GET_MATERIALS and create


A popup will come provide function group and short text, enter.

Go to attributes tab, select ‘Remote-Enabled module’ radio button.

Go to import tab, add parameter as below.

Go to export tab, add parameters as below.


Go to Source code and add below code.

SELECT SINGLE MATNR


MTART
MEINS
MATKL
MEINS
FROM MARA INTO MATERIAL_DETAILS WHERE MATNR = MATERIAL.
IF SY-SUBRC NE 0. "add message to return parameter
RETURN-TYPE = 'E'.
RETURN-MESSAGE = 'Material not found'.
ENDIF.
Save and activate the function module, test.

Step 3: Go SWO1, create a business object.

Go to T-code SWO1, provide name as ZBUSMAT01 and create.


A popup will come, provide details as below.

Do not save it in a local object, we cannot make BAPI methods with non-transportable objects.

Save it in a package and create a transport request.


Step 4: Insert RFC function module into business object.

To insert RFC into business object, click on Utilities -> API Methods -> Add Method.

A popup will come, provide RFC function module name and enter.

A popup will come, click on next icon.


Again click on next icon.

A confirmation popup will come, click yes.

We have inserted a RFC function module into methods of business object, now we need to do two
things.

 Change 'change release status' to 'implemented'


 Again 'change release status' to 'released'
A popup will come just press enter.

Once object is released, you will find released icon as below.


BAPI is created, now it can be usable by SAP and NON-SAP systems.

How to use BAPI in SAP ABAP Reports ?

BAPI can be used in report development, in the example program we will develop a report to display
material basic details for a material input.

To get material details for a material we use BAPI_MATERIAL_GET_DETAIL (go to SE37 check).

Go to SE38, create a program ZSAPN_BAPI_MATERIAL, save it in a local object.

REPORT ZSAPN_BAPI_MATERIAL.
PARAMETERS: P_MATNR TYPE MARA-MATNR.
DATA : MAT_DATA TYPE BAPIMATDOA.

START-OF-SELECTION.
CALL FUNCTION 'BAPI_MATERIAL_GET_DETAIL' "get material details
EXPORTING
MATERIAL = P_MATNR
* PLANT =
* VALUATIONAREA =
* VALUATIONTYPE =
* MATERIAL_EVG =
IMPORTING
MATERIAL_GENERAL_DATA = MAT_DATA
* RETURN =
* MATERIALPLANTDATA =
* MATERIALVALUATIONDATA =
.
WRITE: / MAT_DATA-MATL_DESC, MAT_DATA-MATL_TYPE, MAT_DATA-IND_SECTOR, MAT_DATA-
MATL_GROUP.
Execute the above program and test.

Similarly create some example programs to display customer details (use


BAPI_CUSTOMER_GETDETAIL2), display vendor details (use BAPI_VENDOR_GETDETAIL) etc.

You might also like