Actions for an Enhancement Based on Existing SAP Database Tables


We assume that the customer wants to append his own fields to SAP tables involved in a BAPI and/or include additional existing fields from these tables in the BAPI after the fact.

Process Flow

In this case, the following steps are required at most:

  1. Extending the database table
    The customer must perform the following actions for each SAP table to append that is involved in the BAPI:
    1. Create a data structure that contains the customer fields that will be added to the table.
    2. Then add an APPEND to the database table that includes the data structure created in a) above.

An example is available under Appending Customer Fields.

  1. Identifying and/or creating the BAPI table extensions
    The customer has to make sure that each SAP table that is used for this type of enhancement has its corresponding BAPI table extension. This is done by reading the documentation on the BAPI extension parameters. If a required table extension has not been supplied by SAP, then the customer is responsible for creating it. Make sure to observe the following guidelines:

The naming convention for BAPI table extensions is <namespace>BAPI_TE_<table_name>.
If you cannot follow this naming convention due to the length restriction for structure names, reduce the name accordingly, but try to keep its context clear.


Each table should only have one table extension. Therefore, if several BAPIs use the same table, they will have to share the table extension.



If a BAPI has two or more parameters that refer to the same database table, then a separate BAPI table extension is created for each of these BAPI parameters. The naming convention in this case is <namespace>BAPI_TE<table_name><consecutive_number>. In our example, our table extensions would be named YBAPI_TE_STRAVELAG1, YBAPI_TE_STRAVELAG2, and so on.


The structure of the BAPI table extension must contain all the identified key fields of the table to which the BAPI table extension relates. The table extension does not initially contain any other fields except the key fields.

  1. Enhancing the BAPI table extensions
    The APPEND technique is now used to enhance the BAPI table extensions that you identified and/or created above. As mentioned above, we can differentiate between the following cases:
    1. If the customer wants to add additional fields from the SAP table for the BAPI table extension, he adds these fields directly to the APPEND structure.
    2. If the customer has appended his own fields to the corresponding SAP table, then he should include the same data structure – with the customer fields – in the APPEND as the one used to extend the database table.
    3. If you want to both add existing fields from the SAP table to the BAPI and append customer fields, proceed as follows:

First add all existing fields from the corresponding table to the APPEND structure.


Then add the INCLUDE that contains the new customer fields to the same APPEND structure. Please note that you have to use the same INCLUDE in both the database table and in the corresponding BAPI table extension.

  1. Programming the BAdIs
    The first BAdI gives customers the option of performing data checks, while the second BAdI allows the further processing of the data passed on to the BAPI (also see
    Actions by the BAPI Developer). The standard BAdI rules apply here.

Read the documentation about Business Add-Ins.

  1. Filling ExtensionIn before a BAPI call
    Before a BAPI that involves extended tables can be called, you have to make sure that the enhancements are written to parameter ExtensionIn. ExtensionIn is filled as follows for each data record that is written to the container:
    • Field VALUEPART1 is first filled with the keys that identify the table lines.
    • Fields VALUEPART1 through VALUEPART4 are then filled with the values of the customer fields in the proper sequence. By structuring the container in this way, its contents can be converted with a single MOVE command in the structure of the BAPI table extension.

The part for implementation can be described in pseudo-coding as follows:


FOR every extendable table X




Fill ExtensionIn-VALUEPART1 with key values.
Fill VALUEPART1 through VALUEPART4 with data in sequence.
APPEND ExtensionIn.


UNTIL table X is processed





It is not possible to give the container a key value in Create() BAPIs with internal number assignment, as these values are generated in the BAPI itself. In this case, you should give the container an initial key value. The BAPI developer has already anticipated the assignment of the key generated in the BAPI to the BAPI table extension.

A detailed programming example on filling the ExtensionIn parameter and calling the enhanced BAPI is available in the Examples.

  1. Evaluating ExtensionOut after a BAPI call
    The conversion of the ExtensionOut container to a structure may have to be implemented, depending on your specific situation.