BAdI Part 4: Classic BAdI vs New BAdI
Compare classic BAdIs (SE18 definition, CL EXITHANDLER, interface IF EX …) with new kernel BAdIs (enhancement spots, GET BADI / CALL BADI, IF BADI INTERFACE): performance, filters, fallback classes, instance handling, migration and how to recognise each in SE18/SE19.
Explanation
📌 KEY POINTS
✅ Classic BAdIs (before NetWeaver 7.0) are called through CL_EXITHANDLER=>GET_INSTANCE; new BAdIs through the ABAP statements GET BADI and CALL BADI.
✅ New BAdIs belong to enhancement spots, are handled by the kernel (faster) and support fallback classes and more flexible filters.
✅ Both are implemented as classes in SE19; you implement whatever SAP calls — you cannot choose the type.
⚠️ Many SAP classic BAdIs have been migrated: the classic name still exists but is called via a new BAdI — check SE18 before debugging the wrong one.
━━━━━━━━━━━━━━━━━━━━
▶ WHERE WE ARE
Parts 1–3 used both kinds. This lesson makes the differences explicit, because support work involves both.
━━━━━━━━━━━━━━━━━━━━
▶ 1. CLASSIC BADI
- Definition: SE18 (classic view), interface IF_EX_<badi>, adapter class CL_EX_<badi> generated by SAP.
- Call: cl_exithandler=>get_instance( CHANGING instance = l_badi ) → l_badi->method( ).
- Implementation: SE19 classic, class ZCL_IM_<impl>.
- Filter: one filter type (e.g. LAND1), filter value is passed as method parameter FLT_VAL.
- Activation: button in SE19; the adapter checks active implementations at runtime (overhead).
━━━━━━━━━━━━━━━━━━━━
▶ 2. NEW BADI (ENHANCEMENT FRAMEWORK)
- Definition inside an enhancement spot (SE18/SE20), BAdI name as a type: DATA l_badi TYPE REF TO badi_name.
- Call: GET BADI l_badi FILTERS … . CALL BADI l_badi->method … .
- Implementation: enhancement implementation → BAdI implementation → class with IF_BADI_INTERFACE + BAdI interface.
- Filters: several filter characteristics with comparisons (=, <>, CP …) defined per implementation; no FLT_VAL parameter.
- Fallback class, instance creation modes (new instance / reuse), context-dependent BAdIs.
- Kernel-based: significantly less runtime overhead.
━━━━━━━━━━━━━━━━━━━━
▶ 3. MIGRATED CLASSIC BADIS
SAP converted many classic BAdIs: SE18 shows "Migrated" and the enhancement spot. Existing classic implementations keep working. New implementations are created via the migrated spot.
━━━━━━━━━━━━━━━━━━━━
▶ 4. RECOGNISING THEM
- In code: CL_EXITHANDLER → classic; GET BADI → new.
- In SE18: classic shows interface IF_EX_…; new shows enhancement spot and BAdI definition.
- In SE19: "Classic BAdI" vs "New BAdI" radio buttons.
━━━━━━━━━━━━━━━━━━━━
▶ 5. FOR YOUR OWN BADIS
Always create new BAdIs; classic BAdI creation is obsolete.
━━━━━━━━━━━━━━━━━━━━
▶ STEP BY STEP
- SE18: display classic BAdI ME_PROCESS_PO_CUST and note interface and adapter class.
- SE18: display a new BAdI in an enhancement spot (e.g. your own ZBADI from Part 3).
- Compare the calling code in both cases in the debugger.
✅ CHECKPOINT: you can distinguish classic and new BAdIs, implement both and create new ones.
Code example
* ===== CLASSIC BAdI - calling code =====DATA: l_classic TYPE REF TO if_ex_me_process_po_cust. CALL METHOD cl_exithandler=>get_instance EXPORTING exit_name = 'ME_PROCESS_PO_CUST' null_instance_accepted = abap_true CHANGING instance = l_classic.IF l_classic IS BOUND.* CALL METHOD l_classic->check ... " adapter calls all active implementationsENDIF. * Classic filter-dependent BAdI: filter value is a method parameter* CALL METHOD l_badi->method EXPORTING flt_val = lv_land1 ... * ===== NEW BAdI - calling code =====DATA: l_new TYPE REF TO zbadi_invoice_check, " BAdI name used as type ls_invoice TYPE zs_invoice, lt_messages TYPE bapiret2_t. TRY. GET BADI l_new FILTERS bukrs = '1000'. " kernel selects implementations CALL BADI l_new->check EXPORTING is_invoice = ls_invoice IMPORTING et_messages = lt_messages. CATCH cx_badi_not_implemented.ENDTRY. * ===== Implementing classes =====* Classic: CLASS zcl_im_po_check ... INTERFACES if_ex_me_process_po_cust.* New: CLASS zcl_bi_invoice_1000 ...* INTERFACES if_badi_interface.* INTERFACES zif_ex_invoice_check. * ===== Quick comparison =====* Aspect Classic BAdI New BAdI* Call CL_EXITHANDLER GET BADI / CALL BADI* Container - Enhancement spot* Filter one type, FLT_VAL param several, set per implementation* Default logic - Fallback class* Performance adapter overhead kernel, fast* Create own obsolete recommendedReal project scenario
A developer spent hours debugging why a classic BAdI implementation for material documents did not run after an upgrade. SE18 showed the BAdI as migrated to an enhancement spot, and the new code path called GET BADI with a filter the old implementation did not have.
After creating the implementation in the migrated spot with the correct filter, the logic ran again. The team added "check migration status in SE18" to their BAdI troubleshooting checklist.
Common mistakes
- Creating new classic BAdIs for own code.
- Debugging CL_EXITHANDLER when the code path uses GET BADI.
- Forgetting FLT_VAL handling in classic filter BAdIs.
- Missing IF_BADI_INTERFACE in new BAdI classes.
- Ignoring migration status after upgrades.
Best practices
- Create only new BAdIs for own extensions.
- Check SE18 for migration status and spots.
- Use filters and fallback classes of new BAdIs.
- Keep implementing classes thin in both types.
- Document which type each implementation uses.
Interview angle
Questions: "Classic vs new BAdI?", "How is a new BAdI called?", "What is a migrated BAdI?"
Strong answer: classic via CL_EXITHANDLER=>GET_INSTANCE with adapter class, one filter as FLT_VAL, SE18/SE19 classic; new BAdIs in enhancement spots, GET BADI/CALL BADI handled by the kernel (faster), multiple filters per implementation, fallback class, instance modes; migrated classic BAdIs are routed via spots; create only new BAdIs.
Practice this lesson
Quick check
1. How does SAP code call a new (kernel-based) BAdI?
2. In classic (pre-Enhancement Framework) BAdI technology, what role does the generated 'adapter class' play?
3. In the kernel-based Enhancement Framework, a BAdI definition must be assigned to which container object before it can be used?
Interview questions
1. Difference between classic and new BAdI.
Answer it in your own words first, then compare.
2. What is the difference between classic and new (Enhancement Framework) BAdIs?
Answer it in your own words first, then compare.
Reference-verified: the steps are checked against official SAP documentation and tutorials, and object and field names in the sample code are checked for consistency. The code has not been compiled or run on an SAP system by ERPClimb. Syntax marked release-dependent varies by SAP release, so check it in your own system.
More lessons in this topic
- BAdI Part 1: What a BAdI Is and How SAP Calls It
- BAdI Part 10: BAdIs in S/4HANA and Clean Core
- BAdI Part 2: Finding and Implementing a BAdI Step by Step
- BAdI Part 3: Designing Your Own BAdI — Fallback Class and Filters
- BAdI Part 5: Single-Use vs Multiple-Use BAdIs
- BAdI Part 6: Debugging BAdIs in Real Projects
- BAdI Part 7: Using Filter-Dependent BAdIs
- BAdI Part 8: Implementation Design — Keep BAdI Logic Clean