ERPClimb logoERPClimb
BAdI
ABAP Developmentbeginner 8 min read

BAdI Part 1: What a BAdI Is and How SAP Calls It

Free sample lesson · open to everyone

Key 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 this lessonShow sections

Visual overview

BAdI Part 1: What a BAdI Is and How SAP Calls It — learning sheetFlow: SE18: display ME_PROCESS_PO_CUST; look at the interface methods and "multiple use" setting → Open the interface IF_EX_ME_PROCESS_PO_CUST in SE24 and read the parameters of CHECK → SE19: display existing implementations of this BAdI in your system. Key ideas: WHY BADIS; THE PARTS; HOW SAP CALLS A CLASSIC BADI; HOW SAP CALLS A NEW BADI. Watch out: A BAdI method only receives what its parameters provide — design your logic around that data, not around global SAP variables.ERPClimb.com / ABAP / LESSON 1/10 / LEARNING SHEETBAdI Part 1: What a BAdI Is and How SAP Calls It1 · HOW IT FLOWS1SE18display ME_PROCESS_PO_CUST; lookat the interface methods and…2Open the interfaceIF_EX_ME_PROCESS_PO_CUSTin SE24 and read the…3SE19display existing implementationsof this BAdI in your system2 · KEY IDEAS EXPLAINEDWhy BAdIsUser exits and customer exits allow only oneimplementation and are procedural. BAdIs areinterfaces: several implementations are possible…The PartsBAdI definition (SE18) — name, interface (e.g.IF_EX_ME_PROCESS_PO_CUST for classic BAdIME_PROCESS_PO_CUST), settings: multiple use…Interface — methods withIMPORTING/CHANGING/EXPORTING parameters andexceptions.How SAP Calls A Classic BAdICALL METHOD cl_exithandler=>get_instanceCHANGING instance = l_badi. then CALL METHODl_badi->check EXPORTING … . The exit handler…How SAP Calls A New BAdIGET BADI l_badi (FILTERS …). then CALL BADIl_badi->method … . The kernel handles instances— faster than classic BAdIs. New BAdIs live in…3 · REMEMBER · WATCH OUTRememberA BAdI (Business Add-In) is an object-oriented enhancement: SAPdefines an interface, you implement it in a class.SE18 shows the BAdI definition (interface, methods, parameters); SE19is where you create your implementation.Classic BAdIs are called via CL_EXITHANDLER=>GET_INSTANCE; newBAdIs (Enhancement Framework) via GET BADI and CALL BADI.!Watch outA BAdI method only receives what itsparameters provide — design yourlogic around that data, not aroundglobal SAP variables.4 · IN A REAL PROJECTA purchasing team wanted to stop POs of type ZNB without a purchasing group. The developer found classic BAdIME_PROCESS_PO_CUST, created implementation ZIM_PO_CHECK in SE19 and implemented method CHECK. Because the BAdIis multiple-use, another team's implementation for approvals continued to work unchanged. During testing the…Original ERPClimb learning sheet • Verify against your SAP release and edition

Expert visual walkthrough

ABAP DEVELOPMENT ACADEMY · Integration pathERPClimb.com

What a BAdI Is and How SAP Calls It

BAdI · Chapter-specific technical teaching map

Integration path

1Concept

Standard process

2Concept

BAdI definition

3Concept

Implementation method

4Concept

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…

Conceptual study map, not an SAP configuration screenshot or a guaranteed runtime sequence. Consult the lesson for implementation prerequisites and exceptions.

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

ABAP Code
* ===== 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?

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

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.