BAdI Part 1: What a BAdI Is and How SAP Calls It
Free sample lesson · open to everyone
Understand Business Add-Ins: the BAdI definition and its interface, implementations as classes, how SAP calls classic BAdIs (CL EXITHANDLER) and new BAdIs (GET BADI / CALL BADI), and the transactions SE18 and SE19.
In this lessonShow sectionsHide sections
Visual overview
Expert visual walkthrough
What a BAdI Is and How SAP Calls It
BAdI · Chapter-specific technical teaching map
Integration path
Standard process
BAdI definition
Implementation method
Business result
Tutor's chapter takeaway
Understand Business Add-Ins: the BAdI definition and its interface, implementations as classes, how SAP calls classic BAdIs (CL_EXITHANDLER) and new BAdIs (GET BADI / CALL BADI), and the transactions SE18 and SE19.
In a real project
A purchasing team wanted to stop POs of type ZNB without a purchasing group. The developer found classic BAdI ME_PROCESS_PO_CUST, created implementation ZIM_PO_CHECK in SE19 and implemented method CHECK. Because the BAdI is…
Watch out for
• Confusing the BAdI definition (SAP) with the implementation (customer). • Using global SAP variables instead of method parameters. • Forgetting to activate the implementation in SE19. • Putting all logic directly in the…
The situation: a real project scenario
A purchasing team wanted to stop POs of type ZNB without a purchasing group. The developer found classic BAdI ME_PROCESS_PO_CUST, created implementation ZIM_PO_CHECK in SE19 and implemented method CHECK.
Because the BAdI is multiple-use, another team's implementation for approvals continued to work unchanged. During testing the team learned that CH_FAILED alone blocks saving silently in some cases, so they added a proper error message via the MM message macros (Part 2).
Explanation
A BAdI, or Business Add-In, is an object-oriented enhancement technique: SAP defines an interface, and you implement that interface in your own class. SE18 shows you the BAdI's definition — its interface, methods, and parameters — while SE19 is where you actually create your implementation.
Classic BAdIs get called through CL_EXITHANDLER=>GET_INSTANCE, while new-style BAdIs, part of the Enhancement Framework, get called via GET BADI and CALL BADI instead. One design point worth keeping in mind: a BAdI method only ever receives what its own parameters hand it, so your logic needs to be built around that data rather than reaching for global SAP variables.
This series covers BAdIs in ten parts: this lesson on what a BAdI is and how SAP calls it; Part 2 on finding and implementing a BAdI step by step; Part 3 on building your own BAdIs, including fallback classes and filter design; Part 4 comparing classic and new BAdIs; Part 5 on single-use versus multiple-use BAdIs; Part 6 on debugging BAdIs; Part 7 on using filter-dependent BAdIs; Part 8 on clean implementation design; Part 9 on performance and database access; and Part 10 on BAdIs in S/4HANA and clean core.
BAdIs exist because user exits and customer exits only allow a single implementation and are procedural by nature. BAdIs, by contrast, are interfaces: several implementations can coexist where that's allowed, filters can select which implementation applies based on criteria like org unit or country, and each implementation is a proper class with methods and typed parameters.
The pieces fit together like this: the BAdI definition, in SE18, has a name, an interface — for instance IF_EX_ME_PROCESS_PO_CUST for the classic BAdI ME_PROCESS_PO_CUST — and settings controlling whether multiple implementations and filters are allowed. The interface itself defines methods with IMPORTING, CHANGING, and EXPORTING parameters, along with exceptions. The implementation, built in SE19, is your own Z implementation, backed by an implementing class — typically named ZCL_IM_... for a classic BAdI. And finally there's the calling code sitting inside the actual SAP program.
For a classic BAdI, SAP calls it through CALL METHOD cl_exithandler=>get_instance CHANGING instance = l_badi. followed by CALL METHOD l_badi->check EXPORTING ... . The exit handler itself creates an object that in turn calls every active implementation.
For a new-style BAdI, SAP instead uses GET BADI l_badi (FILTERS ...). followed by CALL BADI l_badi->method ... . Here the kernel manages the instances directly, which makes new BAdIs faster than classic ones, and they live inside enhancement spots rather than the older exit-handler mechanism.
As an example of what a method actually looks like: the classic BAdI ME_PROCESS_PO_CUST, for purchase orders, has a method called CHECK that receives the PO header object as IM_HEADER and a CHANGING flag CH_FAILED. Your implementation reads the header and item data through that object's own methods, and sets CH_FAILED to prevent the document from being saved if your check fails.
To practice: display ME_PROCESS_PO_CUST in SE18 and look at its interface methods along with its "multiple use" setting; open the interface IF_EX_ME_PROCESS_PO_CUST in SE24 and read through the parameters of CHECK; and use SE19 to display any existing implementations of this BAdI already present in your system. With this you should be able to explain what a BAdI consists of and recognize both classic and new BAdI calls when you see them in SAP code.
Code example
* ===== How SAP calls a CLASSIC BAdI (inside SAP code, read-only) =====* DATA l_badi TYPE REF TO if_ex_me_process_po_cust.* CALL METHOD cl_exithandler=>get_instance* EXPORTING exit_name = 'ME_PROCESS_PO_CUST'* CHANGING instance = l_badi.* CALL METHOD l_badi->check* EXPORTING im_header = l_header ...* CHANGING ch_failed = l_failed. * ===== How SAP calls a NEW BAdI =====* DATA l_badi TYPE REF TO badi_name.* GET BADI l_badi FILTERS bukrs = l_bukrs.* CALL BADI l_badi->method EXPORTING ... * ===== Your implementation class (classic BAdI ME_PROCESS_PO_CUST, created in SE19) =====CLASS zcl_im_po_check DEFINITION PUBLIC FINAL CREATE PUBLIC. PUBLIC SECTION. INTERFACES if_ex_me_process_po_cust. " implementing the BAdI's interface makes this class pluggable into it (wired up in SE19)ENDCLASS. CLASS zcl_im_po_check IMPLEMENTATION. METHOD if_ex_me_process_po_cust~check. DATA ls_header TYPE mepoheader. ls_header = im_header->get_data( ). " read PO header via the object IF ls_header-bsart = 'ZNB' AND ls_header-ekgrp IS INITIAL. ch_failed = abap_true. " prevents saving ENDIF. ENDMETHOD. * Other interface methods stay empty (implement only what you need) METHOD if_ex_me_process_po_cust~initialize. ENDMETHOD. METHOD if_ex_me_process_po_cust~open. ENDMETHOD. METHOD if_ex_me_process_po_cust~process_header. ENDMETHOD. METHOD if_ex_me_process_po_cust~process_item. ENDMETHOD. METHOD if_ex_me_process_po_cust~post. ENDMETHOD. METHOD if_ex_me_process_po_cust~close. ENDMETHOD.* ... (the interface has further methods; SE19 creates empty ones for you)ENDCLASS.Watch out
Common mistakes
- Confusing the BAdI definition (SAP) with the implementation (customer).
- Using global SAP variables instead of method parameters.
- Forgetting to activate the implementation in SE19.
- Putting all logic directly in the method instead of a class.
- Not checking for existing implementations.
Do this
Best practices
- Read the interface documentation in SE18 before coding.
- Implement only the methods you need; leave others empty.
- Keep BAdI methods thin and delegate to own classes.
- Check existing implementations and multiple-use setting.
- Test all processing paths that call the BAdI.
In the interview
Interview angle
Questions: "What is a BAdI?", "Difference between SE18 and SE19?", "How does SAP call a BAdI?"
Strong answer: a BAdI is an OO enhancement with an interface defined by SAP (SE18) and customer implementations as classes (SE19); classic BAdIs are called via CL_EXITHANDLER=>GET_INSTANCE, new BAdIs via GET BADI/CALL BADI (kernel-based, in enhancement spots); can be multiple-use and filter-dependent; data only via method parameters.
Practice this lesson
Quick check
0 of 3 questions attempted
Question 1 of 3
In a classic BAdI such as ME_PROCESS_PO_CUST, who creates the implementing class?
Question 2 of 3
Which transaction is commonly used to view BAdI definitions?
Question 3 of 3
What does BAdI stand for?
Practise this in an interview
Answer in your own words and get instant feedback, the way an interviewer would judge it.
1What is a BAdI?
2What is a BAdI in SAP ABAP?
Try a related Code Lab
This published exercise covers the same SAP topic. Apply the ideas in a hands-on scenario, then return to review your answers.
Open: SELECT Inside BAdI Item Loop →See it in code
Each example starts from a requirement, shows the design, then the code step by step with a plain-language explanation of every part.
Was this lesson helpful?
Keep exploring
Interview questions on this topic
Related SAP topics
Referenced SAP objects
Reviewed reference pages for the objects this page mentions.
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.