All about BAdIs

Experienced SAP consultants use the word “BAdI” frequently. In this post, I am going to explain what it is and its most common uses.

The BAdIs (Business Ad-ins) are tools for object-oriented programming in ABAP, that are used in SAP to implement validations and extensions to the SAP standard code in versions from 4.6c. For instance, the code generated by SAP in standard transactions (to order,…) cannot be changed (except to implement a SAP patch) since you would lose the support that SAP offers to its product. But imagine that when we finish a purchase order (PO) with transaction ME21N, we need to save certain data in a custom table called ZPORDER. For this reason we have the expansions (BAdIs, user exits, field exits, …). After all, they are just pieces of custom code that SAP allows us to introduce in its standard code to perform certain operations.

Do not confuse BAdIs with BApIs. The BApIs are simply ABAP functions available from transaction BAPI and called from other systems that perform specific operations with the parameters passed to them and can create purchase orders, modify, create material documents, …

Differences between BAdI and USER EXIT

  • BAdIs can be used as many times as needed, while USER EXITS can be used once time only. For example, if you assign a USER EXIT to a project with CMOD transaction, then you cannot assign it to another project. On the other hand, several developers can implement the same BAdI independently.
  • BAdIs are much more flexibles to the developer’s needs. We can define the exit points and the programming logic we need. It has all the properties of an object-oriented programming.
How to find the BAdI we need
There are several methods to find the BAdI we need, but I am going to explain a method based on transaction code ST05 (Performance Analysis).
This analysis technique is based on the fact that all BAdIs are registered in SAP tables. Thus, each time a BAdI is called the system go through those tables. The tables of the BAdIs are the following: SXS_INTER, SXC_EXIT, SXC_CLASS and SXC_ATTR. SAP always accesses those tables through the views V_EXT_IMP and V_EXT_ACT. Those views (tr. SE11) will be the basis of our analysis.
Suppose we want to know what BAdIs are called in transaction BT “Mantain Business Partners”.


1.- Firstly, we have to check that no other user (tr. SM04) or background jobs (tr. SM50) are using the same user as you.
2.- Secondly, we have to enter in transaction ST05 (Performance Analysis) and set the indicator “Buffer trace”, after that we can press the button “Activate Trace”.
3.- Now the system is in “record” mode. Go to transaction BT, press the button “Organization” and fill in the fields with the following test data:
At the end, press the save button.
4.- Go back to the ST05 window and press the button “Deactivate trace” to finish the trace and press the button “Display Trace”. The popup “Set Restrictions for Displaying Trace” will appear.
5.- We have to filter the Trace by the objects: V_EXT_IMP and V_EXT_ACT. Which are our views.
Press the “Copy” button (F8), Fill Operations: OPEN and press “Enter”.
We will obtain a Trace List like this:
All the “interface class names” of the view V_EXT_IMP start with IF_EX_. This is the standard SAP prefix for the “BAdI class interfaces”. The name of the BAdI starts after that IF_EX_. For instance, the name of the BAdI for IF_EX_ADDR_LANGU_TO_VERS is ADDR_LANGU_TO_VERS.
In transaction SE18 we can see the definition of the BAdI:
Advice: While the Trace execution, do not execute other transactions or commands in order to obtain the results as clean as possible.
However, we can see a list of the BAdIs availables following these steps:
– Go to transaction SE18
– Press F4 to open the matchcode
– Click on the “System information” icon
– Increase the maximum number of results to 999999
– Press the “OK” button

How to implement a BAdI
These are the two transactions we are going to work with BAdIs:
SE18 = BAdIs definition
SE19 = BAdIs implementation
Imagine that we have chosen the BAdI ME_PROCESS_PO_CUST and its method CLOSE which covers specific needs in the creation and modification of purchase orders, transactions ME21N and ME2N.
1.- Obtaining relevant information of the BAdI
  • Go to transaction SE18 with the BAdI ME_PROCESS_PO_CUST
  • Click on “Visualize”
  • Click on “Interface”
  • Double-click on “CLOSE”
  • Click on “Parameters” and go to IM_HEADER
In reference type we can see that its type is IF_PURCHASE_ORDER_MM
2.- Finding the available methods for each parameter
Suppose that we have chosen the BAdI ME_PROCESS_PO_CUST and the Interface POST
  • Go to transaction SE18 with the BAdI ME_PROCESS_PO_CUST
  • Click on “Visualize”
  • Click on “Interface”
  • Double-click on “POST”
We can see its parameters. Each of them has a reference type. The first of them is a simple type of data EBELN, the second IM_HEADER has the reference type IF_PURCHASE_ORDER_MM. With double-click on IM_HEADER the available methods will appear:
With double-click on each method, we can see more details. For example:
  • Double-click on GET_DATA
  • Click on parameters
  • The parameter RE_DATA appears. It is a MEPOHEADER-type parameter.
  • Double-click on MEPOHEADER and we will see that is a header data stucture
It is important to know that at the beginin the implementation is not defined. The first time we enter in transaction SE19, we have to create the implementation with the same name that already has in SE18.
3.- Creating the implementation of the chosen BAdI
  • Go to transaction SE19
  • Click on “Create”
  • Enter the implementation name, for example ME_PROCESS_PO_CUST
  • Enter the definition name. It must be ME_PROCESS_PO_CUST
  • Select the AM2P package
  • Enter the transport order
  • Press the save button
  • Enter the SAP standard object modification password
  • Enter a short definiton. Usually the name of the transport order
  • Press the save button
  • Click on “Activate” and select all in order to recompile completely
4.- Modifying the source code of the implementation
  • Go to SE19 with the BAdI ME_PROCESS_PO_CUST
  • Click on Modify
  • Click on Interface
  • Double-click on CLOSE
  • Enter the password
  • Edit the text of the source code
Important: Do not forget the formal activation
– Go to SE19
– Click on Implementation
– Click on Activate

About Darío Franco
I enjoy reading science books and making photos. Passions: Technology, websites, management, running, MTB, nature, adventure sports and snowboarding. Favourite quote: “Whatever you are, be a good one.” Abraham Lincoln.

One Response to All about BAdIs

  1. Jon says:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: