Sorun Cevaplayalım

İşinizle ilgili öngörüler edinin, gerçek zamanlı bilgilere göre karar alın.

SAP Eğitim ve Sertifika Dönemleri

Uzmanlığınızı ve deneyiminizi SAP çözümleri kullanarak tasdik edin.

Çözüm Ekibi Başvurusu

Kullanıcılara hızlı ve pratik çözümler üreterek görev almak isteyenler.

SAP ABAP BAPI Example with Flights

SAP Blog

Kayıtlı Üye
Katılım
22 Ara 2017
Mesajlar
1,035
Tepki puanı
6
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:

img1.png


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.

img2.png


Result:

img3.png


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:


img4.png




img5.png


Okumaya devam et...
 
Üst