Skip to content
S4Guide

BAPI is Obsolete, Use BDEF in S/4HANA

With SAP S/4HANA migration and advent of RAP, BAPI is obsolete and a new generation of APIs, known as RAP Behavior Definition (BDEF) has emerged. In this blog post, we’ll explore how BDEFs offer a more streamlined and clean core approach in SAP S/4HANA.

As an ABAP developer you are familiar with SAP BAPI, lets revisit the basic definition of BAPI and its usage.

What is a BAPI?

SAP BAPI (Business Application Programming Interface) is a standardized programming interface provided by SAP. It allows external applications to interact with SAP systems in a controlled and standardized manner. BAPIs are methods of SAP Business Objects, enabling access to processes and data in the SAP system.

BAPIs operate on SAP Business Objects (e.g., Customer, Material, Sales Order). Each business object has methods (BAPIs) to perform specific operations. BAPIs are implemented as remote function calls (RFCs), which means they can be called from external systems or other SAP systems.

Following are common examples of BAPIs and there are many more in SAP ECC.

Common Use Cases of BAPI

What is ABAP RAP?

ABAP RAP, which stands for RESTful Application Programming Model, is a modern development approach in SAP S/4HANA that represents a significant evolution to create business applications.

ABAP RAP provides a metadata-driven development approach and supports both on-premise and cloud scenarios. We will not go into details of ABAP RAP in this blog post, thats for another day.

In the ABAP RAP (RESTful Application Programming) model, the Behavior Definition (BDEF) is a critical component that defines the transactional behavior of a RAP Business Object (BO). It governs how business objects can be created, modified, deleted, and accessed within the SAP S/4HANA.

BAPI is obsolete, use BDEF

Both RAP Behavior Definition in short BDEF and BAPI operate on business objects; BDEFs are based on ABAP RAP Business Objects and BAPIs are on classical Business Objects(SWO1). Lets look at an example where BDEFs can be used instead of BAPI for Sales Order business object.

Tip

As the RAP BO are still growing in SAP S/4HANA system, there won’t be BDEF for every business object in SAP ECC. Use clear core object search tool to find the availability of BDEF for the BAPI you planned to implement.

Now lets learn, how we can use RAP BDEF instead of BAPI to create sales order.

As first step, lets find out if there is a successor Behavior Definition for the BAPI using Clean Core Object Search tool. After our search we know I_SALESORDERTP is the successor BDEF for the BAPI - BAPI_SALESORDER_CREATEFROMDAT2.

Next, lets use ABAP EML to consume the BDEF in our custom program. Following the code snippet to create sales order using BDEF - I_SALESORDERTP.

 MODIFY ENTITIES OF i_salesordertp
ENTITY salesorder 
CREATE
  FIELDS (  salesordertype
            salesorganization
            distributionchannel
            organizationdivision
            soldtoparty
            purchaseorderbycustomer )
            WITH VALUE #( ( %cid  = 'H001'
                            %data = VALUE #(  salesordertype          = 'TA'
                                              salesorganization       = '1010'
                                              distributionchannel     = '10'
                                              organizationdivision    = '00'
                                              soldtoparty             = '0010100001'
                                              purchaseorderbycustomer = '0010100006' ) ) )

            CREATE BY \_item
              FIELDS ( product
                       requestedquantity )
              WITH VALUE #( ( %cid_ref = 'H001'
                               salesorder = space
                               %target = VALUE #( ( %cid = 'I001'
                                                    product           =  co_test_data-product_valid
                                                    requestedquantity = '10' ) ) )
                            ( %cid_ref = 'H001'
                              salesorder = space
                              %target = VALUE #( ( %cid  = 'I002'
                                                    product           = co_test_data-product_valid
                                                    requestedquantity = '20' ) ) )
                            ( %cid_ref = 'H001'
                              salesorder = space
                              %target = VALUE #( ( %cid  = 'I003'
                                                    product           = co_test_data-product_valid
                                                    requestedquantity = '30' ) ) ) )
               ENTITY salesorderitem
                 
               MAPPED   DATA(ls_mapped)
               FAILED   DATA(ls_failed) ##NEEDED
               REPORTED DATA(ls_reported).

" Save sales order
    COMMIT ENTITIES BEGIN
      RESPONSE OF i_salesordertp
        FAILED   DATA(ls_save_failed)
        REPORTED DATA(ls_save_reported).
    IF sy-subrc <> 0.
      "Handle error scenario
    ENDIF.
   
   COMMIT ENTITIES END.

Conclusion

ABAP RAP essentially represents SAP’s strategic approach to modernizing ABAP development, moving away from traditional ABAP programming towards a more standardized, cloud-native model.

It’s particularly crucial for organizations migrating to S/4HANA, as it provides a forward-looking framework for building sophisticated business applications. This shift highlights the evolution of SAP’s development methodology and reinforces why BAPI is obsolete, use BDEF for modern development.


Share this post:

Previous Post
Automatic Batch Copying in MIGO
Next Post
Joule in S/4HANA Private Cloud: AI Copilot for Enterprise Excellence