Enhancements & Modifications
SAP standard code must not be changed casually.
SAP standard code must not be changed casually. The enhancement framework provides upgrade-safe hooks, in order of preference:
Released APIs / BAdIs in ABAP Cloud (cloud BAdIs, RAP extensions) Clean-core, upgrade-stable
New BAdIs (enhancement spots, GET BADI / CALL BADI) Kernel-based, fast, multiple implementations, filters
Classic BAdIs (SE18/SE19, CL_EXITHANDLER) Object-oriented, migrated to new BAdIs
Customer exits (SMOD/CMOD): function exits, screen exits, menu exits
CALL CUSTOMER-FUNCTION '001' → EXIT_<prog>_001 → include ZX… User exits
Empty FORM routines in SAP includes (e.g. MV45AFZZ in sales: USEREXIT_SAVE_DOCUMENT); require a modification key once
Implicit/explicit enhancement points & sections Insert code at the start/end of procedures (implicit) or at SAP-defined points (explicit) Business Transaction Events (BTE) Publish & subscribe interfaces (FIBF)
Modifications (SE95, Modification Assistant) Direct changes to SAP code — require an access key, must be adjusted at upgrade (SPAU/SPDD). Avoid.
26.1 Finding enhancements
Search in the program for CALL CUSTOMER-FUNCTION, GET BADI, CL_EXITHANDLER=>GET_INSTANCE, ENHANCEMENT-POINT.
Set a breakpoint in CL_EXITHANDLER=>GET_INSTANCE (classic BAdIs) or watch GET BADI statements.
Use SE84 / SPRO documentation, or ST05 trace tables SXS_ATTR, BADI_SPOTS.
26.2 Implementing a new BAdI
SE18/ADT: find enhancement spot (e.g. BADI_SD_SALES family varies by module), note the BAdI definition and interface.
SE19: create enhancement implementation → BAdI implementation → implementing class ZCL_IM_….
Implement the interface methods; activate.
How SAP calls it (and how you define your own BAdI in your code for others to extend):
BAdI properties: single vs. multiple use, filter-dependent, fallback class, context (instance reuse).
DATA lo_badi TYPE REF TO zbadi_order_check.
TRY.
GET BADI lo_badi
FILTERS country = 'DE'.
CALL BADI lo_badi->check_order
EXPORTING is_order = ls_order
CHANGING cv_valid = lv_valid.
CATCH cx_badi_not_implemented.
" no active implementation: default behavior
ENDTRY.26.3 Customer exit example
" SAP code (in the standard program):
CALL CUSTOMER-FUNCTION '001' EXPORTING i_vbak = vbak CHANGING c_flag = lv_flag.
" Your code: CMOD project → activate component EXIT_SAPMV45A_001 → include ZXVVAU01:
IF i_vbak-auart = 'ZOR' AND i_vbak-netwr > 100000.
c_flag = abap_true.
ENDIF.26.4 Implicit enhancement example
In SE80/ADT on an SAP function module: *Enhance* → show implicit enhancement options → create implementation at the start of the FM:
Implicit enhancements are powerful but couple you tightly to SAP internals — in clean-core projects they are considered "not clean".
ENHANCEMENT 1 ZENH_CHECK_MATERIAL. "active version
IF iv_matnr CP 'TEST*'.
RAISE invalid_material.
ENDIF.
ENDENHANCEMENT.26.5 Append structures, custom fields, and key user extensibility
Add fields to standard tables through appends (ZZ fields) or, in S/4HANA, via the Custom Fields Fiori app, which also extends CDS views, OData services, and UIs. Custom logic in S/4HANA Cloud uses cloud BAdIs in the *Custom Logic* app or developer extensibility (ABAP Cloud).