What is BADI in SAP ABAP?

โšก Smart Summary

BADI in SAP ABAP stands for Business Add-In, an object oriented enhancement that hooks custom logic onto standard SAP functionality. This page explains what a BADI is, its features, the classic and new types, the SE18 and SE19 workflow, and how it compares with exits.

  • ๐Ÿงฉ Core Definition: A Business Add-In is an enhancement hook, like a customer exit, that attaches custom functionality to standard SAP without modifying it.
  • ๐Ÿงฑ Object Oriented: A BADI defines an interface, and the enhancement lives in a class that implements it, rather than in a reserved include.
  • ๐Ÿ” Multiple Implementations: Unlike a customer exit, a BADI can be implemented several times, which suits industry solutions and country versions.
  • ๐Ÿ”“ Upgrade Safe: A BADI needs no SAP Software Change Registration and is unaffected by a release upgrade.
  • ๐Ÿ› ๏ธ Definition and Implementation: The definition and interface are created in SE18, and the implementation with its class is created in SE19.
  • ๐Ÿ†• Classic and New: The classic BADI is enhancement based, and the new kernel BADI introduced in NetWeaver adds filters, fallback classes, and better performance.

What is BADI in SAP ABAP

What is BADI?

BADI stands for Business Add Ins. Just like Customer Exits , BADI help hook custom enhancements to SAP functionality. Example of a BADI: In transaction CAT2 – Time Sheet Entry, HR wishes to include an interactive acknowledgment that knowingly submitting incorrect data is grounds for dismissal. This can be achieved using BADI

Example of a BADI

The difference from a classic exit is technical. A BADI is built on ABAP Objects, so the standard program calls an interface method, and the custom code lives in a class that implements that method. This is why a BADI is often described as the object oriented successor to the customer exit.

Features

  • BADI’s are Object Oriented
  • They can be implemented multiple times
  • It does not require SAP Software Change Registration
  • No effect on release upgraded on the functioning of BADI’s

These four features explain why SAP recommends a BADI over a classic exit. Because the enhancement sits in a separate class, it survives an upgrade untouched, and because a BADI can be defined as multiple use, several teams can enhance the same point without overwriting each other.

Types of BADI

SAP offers two generations of Business Add-Ins. The classic BADI is the enhancement based version described above, and the new BADI, introduced with SAP NetWeaver, is part of the Enhancement Framework and is faster and more flexible.

Criteria Classic BADI New (Kernel) BADI
Maintained in SE18 and SE19 The Enhancement Builder inside an enhancement spot
Filters Simple filter values Filter combinations with logical expressions
Fallback Not available A default fallback class runs when no implementation is active
Instantiation CL_EXITHANDLER=>GET_INSTANCE The GET BADI and CALL BADI statements
Performance Slower, object created every call Faster, managed by the kernel

Both generations are found and implemented in a similar way, described next.

How to Define and Implement a BADI

This involved three steps

Step 1) Creating BADI Definition and its interface : Transaction SE18.

Define and Implement a BADI

Step 2) Create the BADI Implementation: Transaction SE19

Define and Implement a BADI

Step 3) Define a class that implements the interface : During implementation creation, a class for implementing the enhancement’s interface is also created

In code, the standard program reaches the implementation through the exit handler. The classic pattern instantiates the BADI reference and then calls the interface method.

* Reference typed with the BADI interface
DATA: lo_badi TYPE REF TO zif_ex_badi_demo.

* Get the active implementation(s)
CALL METHOD cl_exithandler=>get_instance
  CHANGING
    instance = lo_badi.

* Call the interface method that carries the custom logic
CALL METHOD lo_badi->check_data
  EXPORTING
    is_input = ls_input.

๐Ÿ’ก Tip: A new, kernel BADI is called more simply with GET BADI and CALL BADI, which also handle the filter values automatically. Use SE18 to check whether the enhancement point is a classic or a new BADI before writing the call.

โš ๏ธ Warning: Transaction SE18 holds the definition and the interface, while SE19 holds the implementation. Creating the implementation in SE18, or the definition in SE19, is a common mistake that leaves the BADI inactive.

BADI vs Customer Exit vs User Exit

All three techniques enhance standard SAP, but they differ in technology and flexibility. The table below places the BADI next to the two older exit techniques.

Criteria User Exit Customer Exit BADI
Technology Subroutine (FORM) Function module, screen, or menu Object oriented interface and class
Scope SD module only All modules All modules
Number of implementations One One Multiple, when defined as multiple use
Maintained with Direct edit of the include SMOD and CMOD SE18 and SE19
Upgrade safe Checked with SPAU Yes Yes

The practical rule is to use a BADI whenever one exists, because it is object oriented, upgrade safe, and can be implemented more than once.

FAQs

SE18 is the BADI Builder where the definition and its interface are created. SE19 is the Implementation Builder where an implementing class is attached to that definition. One defines the hook, the other fills it.

A multiple use BADI allows more than one active implementation at the same time, and all of them run when the method is called. A single use BADI permits only one active implementation.

Set a breakpoint on CL_EXITHANDLER=>GET_INSTANCE, run the transaction, and read the BADI name from the EXIT_NAME parameter. For new BADIs, search the enhancement spots of the program in the Repository Information System.

Yes. AI assistants in ABAP development tools draft the implementing class, the method body, and the filter logic from a description of the requirement. A developer still activates the implementation in SE19 and tests it.

AI advisors examine the standard program and report which enhancement options exist, then recommend the new BADI inside an enhancement spot for fresh work, keeping the classic BADI where only that option is offered.

Summarize this post with: