What is BAPI:
BAPIs ( Business Application Programming Interface) are specific methods for SAP business objects, which are stored in the Business Object Repository (BOR) of the SAP system and are used for carrying out particular business tasks.
In the SAP system, BAPIs are stored as RFC-capable function modules in the ABAP Workbench Function Builder. BAPIs have standard business interfaces that enable external applications (with the help of SAP business objects) to access SAP processes, functions and data.
Source: https://help.sap.com/saphelp_nw73ehp1/helpdata/en/c2/0da27f769e4c7d99f119110f6a24f4/frameset.htm
Example of using a BAPI:
First question you have to make is: What is the function am I looking for? And instead of starting coding this function, we gonna search in transaction BAPI, and check if there is already a BAPI for this.
Let’s assume we want details from flights:
Ok, we found the Function Module BAPI_FLIGHT_GETDETAIL.
Before implemente, you can test in SE37, check the input parameter and so on. Also in the Documentation tab, you can get more importante information about the BAPI.
Result:
Implementing BAPI in a example, with ABAP OO:
*&———————————————————————*
*& Report Z_TEST_RBAPI
*&
*&———————————————————————*
*&
*&
*&———————————————————————*
REPORT z_test_rbapi.
CLASS flight DEFINITION.
PUBLIC SECTION.
METHODS: getflidetails IMPORTING airid TYPE bapisflkey–airlineid
connid TYPE bapisflkey–connectid
fldate TYPE bapisflkey–flightdate.
PRIVATE SECTION.
DATA: it_fldata TYPE bapisfldat.
DATA: it_return TYPE STANDARD TABLE OF bapiret2.
ENDCLASS.
CLASS flight IMPLEMENTATION.
METHOD: getflidetails.
CALL FUNCTION ‘BAPI_FLIGHT_GETDETAIL’
EXPORTING
airlineid = airid
connectionid = connid
flightdate = fldate
IMPORTING
flight_data = it_fldata
* ADDITIONAL_INFO =
* AVAILIBILITY =
TABLES
* EXTENSION_IN =
* EXTENSION_OUT =
return = it_return.
WRITE: / ‘Company: ‘, it_fldata–airline, ‘ From: ‘, it_fldata–cityfrom, ‘ To: ‘, it_fldata–cityto.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
* Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text–001.
PARAMETERS: p_airid TYPE bapisflkey–airlineid,
p_connid TYPE bapisflkey–connectid,
p_fldate TYPE bapisflkey–flightdate.
SELECTION-SCREEN END OF BLOCK b1.
* Create object and execute Function Module.
DATA: oflight TYPE REF TO flight.
CREATE OBJECT oflight.
oflight->getflidetails( airid = p_airid connid = p_connid fldate = p_fldate ).
Result:
Okumaya devam et...
BAPIs ( Business Application Programming Interface) are specific methods for SAP business objects, which are stored in the Business Object Repository (BOR) of the SAP system and are used for carrying out particular business tasks.
In the SAP system, BAPIs are stored as RFC-capable function modules in the ABAP Workbench Function Builder. BAPIs have standard business interfaces that enable external applications (with the help of SAP business objects) to access SAP processes, functions and data.
Source: https://help.sap.com/saphelp_nw73ehp1/helpdata/en/c2/0da27f769e4c7d99f119110f6a24f4/frameset.htm
Example of using a BAPI:
First question you have to make is: What is the function am I looking for? And instead of starting coding this function, we gonna search in transaction BAPI, and check if there is already a BAPI for this.
Let’s assume we want details from flights:
Ok, we found the Function Module BAPI_FLIGHT_GETDETAIL.
Before implemente, you can test in SE37, check the input parameter and so on. Also in the Documentation tab, you can get more importante information about the BAPI.
Result:
Implementing BAPI in a example, with ABAP OO:
*&———————————————————————*
*& Report Z_TEST_RBAPI
*&
*&———————————————————————*
*&
*&
*&———————————————————————*
REPORT z_test_rbapi.
CLASS flight DEFINITION.
PUBLIC SECTION.
METHODS: getflidetails IMPORTING airid TYPE bapisflkey–airlineid
connid TYPE bapisflkey–connectid
fldate TYPE bapisflkey–flightdate.
PRIVATE SECTION.
DATA: it_fldata TYPE bapisfldat.
DATA: it_return TYPE STANDARD TABLE OF bapiret2.
ENDCLASS.
CLASS flight IMPLEMENTATION.
METHOD: getflidetails.
CALL FUNCTION ‘BAPI_FLIGHT_GETDETAIL’
EXPORTING
airlineid = airid
connectionid = connid
flightdate = fldate
IMPORTING
flight_data = it_fldata
* ADDITIONAL_INFO =
* AVAILIBILITY =
TABLES
* EXTENSION_IN =
* EXTENSION_OUT =
return = it_return.
WRITE: / ‘Company: ‘, it_fldata–airline, ‘ From: ‘, it_fldata–cityfrom, ‘ To: ‘, it_fldata–cityto.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
* Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text–001.
PARAMETERS: p_airid TYPE bapisflkey–airlineid,
p_connid TYPE bapisflkey–connectid,
p_fldate TYPE bapisflkey–flightdate.
SELECTION-SCREEN END OF BLOCK b1.
* Create object and execute Function Module.
DATA: oflight TYPE REF TO flight.
CREATE OBJECT oflight.
oflight->getflidetails( airid = p_airid connid = p_connid fldate = p_fldate ).
Result:
Okumaya devam et...