BAPI Modifications


If customers want to functionally enhance a BAPI supplied by SAP by adding new parameters, changing existing parameters, or changing the coding of the function module upon which the BAPI is based, then this is only possible through modifications.

BAPI modifications cannot be made to business object types delivered in the standard system. Instead, you have to create a subtype of the business object type and then redefine the BAPI method inherited from the superior business object for this subtype.

Only the redefined BAPI is then available for the subtype; the original inherited BAPI can only be called from the supertype.

IBUs, customers and partners who want to create new development objects required in the context of a modification should follow the general guidelines in the documents "Changing the SAP Standard" and "Guidelines for Modifying the SAP Standard", which are available in SAPNet.

You will also have to make sure that the involved development objects are assigned names from the customer namespace.

Process Flow

The process flow for customer modification of BAPIs:

  1. Create a subtype for the involved business object type
    The procedure for creating a subtype is described under
    Creating Subtypes.
  1. Change the definition of the inherited BAPI for the subtype.
    • You can add additional parameters, for example, or modify the implementation of the BAPI. The following implementation options are available for modifications:
      • Creating a new function module
      • Compatible modifications to the superior function module
      • Creating the implementing function module as a copy of the superior function module
  1. If modifications have been made, you must redefine the changed BAPI for the subtype in the BOR. The steps required to redefine a BAPI are described in Redefining BAPIs
  1. From the customer perspective, it makes sense when the superior BAPI can be called as the supertype as well as the subtype. To achieve this, you have to define a delegation relationship between the supertype and the subtype. To define a delegation relationship, perform the steps described under Defining Delegation Relationships.

A delegation relationship is only significant for object-oriented BAPI method calls and not if the implementing function module is called directly.

Overview of Modification Options

The various ways to implement a modification are illustrated in the example below:

Object type OT has two BAPIs m1 and m2, which are implemented by the function modules BAPI_OT_m1 or BAPI_OT_m2:

If enhancements to BAPI m2 are required, you can use the following implementation options:

Creating a new function module

In this case, a new function module (BAPI_OTsub_m2) is created to call the function module of the superior BAPI method (of the supertype). The original functions are retained and can be enhanced for customer needs.

The diagram below illustrates the implementation:

If you use this method, when releases are upgraded, the system checks which interface enhancements have been carried out on the original BAPI. For example, if the interface of the original BAPI BAPI_OT_m2 is enhanced, the call in BAPI BAPI_OTsub_m2 must also be enhanced if the enhanced functions of the original BAPI are to be used.

The advantage of using this method is that the original superior BAPI (BAPI_OT_m2), whose stability has been guaranteed, is cleanly encapsulated. Any changes carried out in the future to the original superior BAPI which do not affect the interface or semantics (for example, corrections and optimizations), are automatically copied to the new BAPI without requiring the subtype to be changed in any way.

This method is not a good choice, however, if the encapsulation has a negative effect on system performance. This could be the case, for example, if both BAPI_OT_m2 and BAPI_OTsub_m2 contain UPDATE operations for different fields of the same data record, and the developer wants to implement this in one single update record (that is, with one UPDATE).

Compatible modifications to the superior function module

In principle, the BAPI method of a subtype can be implemented by the same function module as the method of the supertype (BAPI_OT_m2 in this example). This is possible if the modifications of the interface are compatible, for example, if only new optional parameters have been added.

The diagram below illustrates the implementation:

With this implementation method, remember that the modifications must be merged with the original BAPIs every time a release is upgraded. You can use the Modification Assistant for this starting in Release 4.5A.

The advantage of using this option is that the original code and enhancement can be easily compared with one another, to achieve, for example, optimal performance of database UPDATE operations.

The main disadvantage is that the encapsulation that was achieved by separating the supertype and subtype for the BAPI definition is revoked. When changes have been made, you must ensure that the function module continues to behave the same when the original method of the supertype OT is called. This option can cause problems, for example, if several subtypes of an object type exist in the same system – in the same development system or for several industry solutions in one system – even though they have been created independently of each other (for different industry solutions, for example).

Creating the Implementing Function Module as a Copy of the Superior Function Module

In this case, a copy of the function module of the superior BAPI method is created (in this example, BAPI_OT_m2).

The diagram below illustrates the implementation:

You should only use this option if the enhancement cannot be implemented by calling the function module of the superior BAPI method. If global data is defined or form routines are called in the function group associated with a BAPI function module, you may have to also copy these data declarations and form routines to ensure the copy of the BAPI can be executed.

Although it is more flexible to modify a copy of the function module, you still have to check after every release upgrade whether changes have been made to the implementation of the superior BAPI method. If changes have been made, you have to copy them to the modified copy. As the origin of the copy is not always supported, we recommend that you do not use this option.

Once you have made the required modification to the copy of the function module, assign it as a method to the relevant business object type in the Business Object Repository using the BOR/BAPI Wizard.

See also: