Calling a BAPI by RFC in three minutes


Espresso Tutorials

Fabian Bentz

132Excerpt from Interface Programming in SAP ABAP by Dr. Boris Rubarth.

A BAPI is an RFM and its name starts with BAPI_. If, for example, you want to get a list of users from the target system, your coding may look as shown in Listing 2.1:

Listing2.1

Listing 2.1: Simplified RFC to BAPI example

Was that all we need to know about BAPIs? Of course not … and again this introductory coding is not sufficient, so let us dig deeper.

2.2 Getting the overview on BAPIs
With the knowledge from the previous chapter on RFCs, you can already call a BAPI using RFC as the protocol, as the BAPI implementation is always an RFM. So why are you reading this chapter? BAPIs offer some very important and helpful features for your remote communication but also hold some traps—so it is worth examining some of the details. You may also be curious about what “BAPI implementation” means.

Let’s start with the name: BAPI is the abbreviation for Business API, in the sense of an interface to business data.

BAPI or BAdI
Do not confuse a BAPI with a BAdI: a BAdI is a Business Add-In for a modification-free extension of existing ABAP coding. And a BAPI may offer a BAdI—a point to extend the BAPI without modification, as we will discuss later.

If an RFM implements a BAPI, then you know how to examine the BAPI: you examine the RFM. Nevertheless, if the RFM is the implementation, there must be something beyond the implementation, some meta level that the RFM is implementing.

You can use the Function Builder selection screen to search for RFMs with the prefix BAPI_. (Later on, we will discuss a smarter way to search for BAPIs.) The next part of the name is the object to which the BAPI is related. Remember: the other colleague mentioned something like “data… encapsulated in a business object”.

The “object” belongs to the meta level beyond the implementation. This object is a representation of business data to which the BAPI shall offer an interface. A simple example is BAPI_USER_GETLIST: this BAPI provides a list of system users, so User is the object type to work on and getlist is the method—makes sense, doesn’t it? Figure 2.1 illustrates the business object with its methods and the related RFMs which are relevant
for the RFC communication.

Keep reading in Interface Programming in SAP ABAP by Boris Rubarth.

Interface programming in SAP ABAP offers a straightforward path into the world of ABAP interfaces. This book introduces readers to all relevant classic technologies for system-to-system communication using ABAP, including synchronous and asynchronous techniques. Learn how to leverage the RFC protocol to create applications and gain an understanding of how it serves as a foundation for modern interfaces, such as Web Services in ABAP. Learn how to create an RFC in three minutes and walk through a detailed example. Dive into creating and using BAPIs, IDocs, and ALE. Explore important aspects of using function modules in SAP S/4HANA. Get an overview of SAP Connectors.

– Overview of classic SAP ABAP interface techniques
– Remote Function Call (RFC) and BAPIs
– IDoc and ALE
– Using Remote Function Module (RFM) und BAPIs in SAP S/4HANA

ET_NL_Header_04_01

4Author Dr. Boris Rubarth has been gathering experience with SAP software since 1999. He started as an ABAP instructor for customer training at SAP Germany, subsequently specializing in connectivity and integration. He was also responsible for creating a series of SAP training curricula. Boris now works as a Product Manager at SAP SE and lectures at various colleges on ABAP, SAP Basis technology, and SAP Process Integration. He studied Physics in Hamburg and Hanover and received his PhD in Physics in Oldenburg.