BAdI
ABAP Cloud
Developer
Tier 2

BAdIs — Business Add-Ins

SAP's primary in-system developer extension mechanism — implement released Business Add-In interfaces to inject custom business logic into standard S/4HANA processes without modifying a single line of SAP code.

BAdI Architecture

BAdI Registration and Execution Lifecycle
Rendering diagram…

Executive Summary

BAdIs (Business Add-Ins) are SAP's primary mechanism for injecting custom business logic into standard S/4HANA processes. SAP defines Enhancement Spots in the standard code where customers can implement custom logic via released BAdI interfaces. The customer code runs inside S/4HANA but is fully isolated from SAP standard objects — and because the BAdI interface carries a C1 release contract, it is guaranteed stable across S/4HANA upgrades for 10+ years.

BAdI Types

Classic BAdI (deprecated)Legacy

Uses GET BADI + CALL BADI syntax. Still present in S/4HANA standard code but cannot be used in ABAP Cloud development. Do not create new implementations using this pattern.

New BAdI (current)Current

Uses BADI_INSTANTIATE or CL_BADI_CONTEXT=>GET_DATA. Fully ABAP Cloud-compatible. All new BAdI implementations must use this pattern.

Released BAdIs (C1 contract)Required

SAP-published BAdIs with an explicit C1 release contract. Guaranteed stable for 10+ years. These are the only BAdIs customers should implement in a Clean Core context.

BAdI Implementation Workflow

  1. 1Search for released BAdIs in SPRO or SAP Help for the target business process area
  2. 2Create an Implementation class in ADT (set ABAP language version: Cloud Development)
  3. 3Implement the released BAdI interface methods in the class
  4. 4Activate the Implementation under Enhancement Spot → Enhancement Implementation
  5. 5Optionally set filter values to restrict when the implementation fires
  6. 6Write ABAP Unit tests covering the implementation logic
  7. 7Run ATC check — resolve all findings before transport
  8. 8Transport to Quality and run regression test suite

DEWA BAdI Implementation — Pricing Logic

This example implements the SD_COND_ACCESS_BADI (C1-released) to apply a government entity pricing discount for DEWA's government customer segment.

abap
" =====================================================
" DEWA — Sales Order Pricing BAdI Implementation
" Enhancement Spot: SD_COND_ACCESS_BE
" BAdI Name: SD_COND_ACCESS_BADI (Released — C1)
" =====================================================

CLASS zcl_dewa_pricing_badi DEFINITION
  PUBLIC FINAL
  CREATE PUBLIC.

  PUBLIC SECTION.
    INTERFACES if_badi_sd_cond_access.  " Released BAdI interface (C1)

ENDCLASS.

CLASS zcl_dewa_pricing_badi IMPLEMENTATION.

  METHOD if_badi_sd_cond_access~determine_access_sequence.
    " DEWA custom pricing: apply UAE government discount for public entities
    " This method is called for each condition type access

    " Only process DEWA-specific pricing condition Z_GOV_DISC
    CHECK iv_kschl = 'Z_GOV_DISC'.

    " Read customer data via released CDS view
    SELECT SINGLE
      yy1_customertier_bpa AS customer_tier
      FROM i_businesspartnerbasic
      WHERE BusinessPartner = @iv_kunnr
      INTO @DATA(lv_tier).

    IF sy-subrc = 0 AND lv_tier = 'GOV'.
      " Government customerapply 10% discount
      APPEND VALUE #(
        knumh = 'GOVT_DISC_10'
        datab = sy-datum
        datbi = '99991231'
      ) TO et_konv_add.
    ENDIF.
  ENDMETHOD.

ENDCLASS.

ABAP Unit Tests for the BAdI

Test before transport
ABAP Unit tests for BAdI implementations should be written and passing before the first transport to Quality. BAdI bugs are notoriously difficult to reproduce post-production.
abap
" =====================================================
" ABAP Unit Test for the BAdI Implementation
" =====================================================

CLASS ltc_dewa_pricing_badi DEFINITION FOR TESTING
  RISK LEVEL HARMLESS DURATION SHORT.

  PRIVATE SECTION.
    METHODS:
      setup,
      test_gov_customer_gets_discount FOR TESTING,
      test_non_gov_no_discount         FOR TESTING.

    DATA: mo_cut TYPE REF TO zcl_dewa_pricing_badi.
ENDCLASS.

CLASS ltc_dewa_pricing_badi IMPLEMENTATION.

  METHOD setup.
    mo_cut = NEW zcl_dewa_pricing_badi( ).
  ENDMETHOD.

  METHOD test_gov_customer_gets_discount.
    DATA: lt_konv_add TYPE STANDARD TABLE OF ty_konv.

    " Act — government customer
    mo_cut->if_badi_sd_cond_access~determine_access_sequence(
      EXPORTING iv_kschl  = 'Z_GOV_DISC'
                iv_kunnr  = 'CUST_GOV_001'
      CHANGING  et_konv_add = lt_konv_add
    ).

    " Assert — discount condition added
    cl_abap_unit_assert=>assert_not_initial(
      act  = lt_konv_add
      msg  = 'Government customer should receive discount condition'
    ).
  ENDMETHOD.

  METHOD test_non_gov_no_discount.
    DATA: lt_konv_add TYPE STANDARD TABLE OF ty_konv.

    mo_cut->if_badi_sd_cond_access~determine_access_sequence(
      EXPORTING iv_kschl  = 'Z_GOV_DISC'
                iv_kunnr  = 'CUST_PRIV_001'
      CHANGING  et_konv_add = lt_konv_add
    ).

    " Assert — no discount for private customer
    cl_abap_unit_assert=>assert_initial(
      act  = lt_konv_add
      msg  = 'Private customer should not receive government discount'
    ).
  ENDMETHOD.

ENDCLASS.

How to Discover Released BAdIs

SAP Help PortalSearch "released badi [process area]" in S/4HANA On-Premise documentation
ABAP ADTRight-click on a standard class → Extension Points — shows all BAdIs in scope
Transaction SPROExtension Log → Released BAdIs, filtered by application area
SAP Note 2633628Catalog of released BAdIs for S/4HANA, organised by process area
api.sap.comABAP APIs section → filter by "Business Add-In" for the target module

DEWA Enterprise Implementation

BAdIs Implemented
4
All C1-Released
Yes
ABAP Unit Test Coverage
100%
ATC BLOCKER Findings
0
FI_TAX_POSTING_BADI
Custom UAE VAT determination logic for DEWA entity types
SD_COND_ACCESS_BADI
Government customer pricing rules — 10% discount for public sector
MM_VENDOR_MASTER_BADI
Local content % validation enforced on vendor creation
FI_AR_DUNNING_BADI
Custom dunning logic for UAE government entities (no dunning for ministries)

Best Practices

Verify C1 release contract

Before implementing any BAdI, confirm the interface has a C1 release contract in ADT (Properties tab). Un-released BAdIs have no stability guarantee.

Write ABAP Unit tests first

Write ABAP Unit tests before committing the BAdI implementation to a transport. Test the happy path, edge cases, and error scenarios.

Use filter values to restrict scope

Set filter values (plant, country, document type) to restrict when your BAdI fires. A BAdI called for all documents when only needed for one type wastes system resources.

Single Responsibility per class

One BAdI implementation class = one business responsibility. Do not combine multiple unrelated customisations into a single implementation class.

Track SAP Note updates

Subscribe to SAP Note updates for BAdIs you have implemented. SAP occasionally adds optional methods to released BAdI interfaces in Feature Pack Stacks.

Common Pitfalls

Implementing un-released BAdIs
BAdIs without a C1 contract can be changed or removed in any S/4HANA update. Your implementation will break on upgrade with no warning from SAP.
Missing filter values
Without filter values, the BAdI fires for every single document processed, including mass runs and batch jobs. This is a significant performance problem in high-volume systems.
Classic BAdI pattern in ABAP Cloud
Using GET BADI / CALL BADI syntax in ABAP Cloud code triggers an ATC BLOCKER finding. Only the new BADI_INSTANTIATE pattern is permitted in the Cloud language version.
No ABAP Unit tests
BAdI regressions are particularly hard to catch without automated tests — they fire inside standard processes with no obvious trace. Always test before transporting.

Security Considerations

Authorisation Context
BAdI implementations execute with the calling user's authorisation context. Never bypass authority-check calls inside BAdI logic. Validate all input parameters before processing. Never hard-code credentials, system IDs, or passwords in BAdI implementations — use Secure Store or credential management APIs. Use SAP's standard authority-check APIs for any data access inside the BAdI.