JBON_DATA

EWM Custom Enhancements: BAdI Best Practices

SAP EWM provides extensive BAdI (Business Add-In) frameworks for customization without modifying standard code. Using them correctly keeps your system upgradeable and maintainable.

Key EWM BAdI Frameworks

  • /SCWM/EX_WHO: Warehouse order processing
  • /SCWM/EX_WT: Warehouse task handling
  • /SCWM/EX_HU: Handling unit processing
  • /SCWM/EX_INB: Inbound delivery processing
  • /SCWM/EX_OUT: Outbound delivery processing

Implementation Pattern

CLASS zcl_ewm_custom_badi DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC.
  
  PUBLIC SECTION.
    INTERFACES: /scwm/if_ex_who_modify.
    
  PRIVATE SECTION.
    METHODS: validate_custom_requirements
      IMPORTING it_who TYPE /scwm/tt_who
      RETURNING VALUE(rv_valid) TYPE abap_bool.
      
ENDCLASS.

CLASS zcl_ewm_custom_badi IMPLEMENTATION.

  METHOD /scwm/if_ex_who_modify~modify_who.
    " Early exit if not relevant
    IF NOT is_relevant( it_who ).
      RETURN.
    ENDIF.
    
    " Apply custom logic
    LOOP AT ct_who ASSIGNING FIELD-SYMBOL().
      apply_custom_rules( CHANGING cs_who =  ).
    ENDLOOP.
  ENDMETHOD.
  
ENDCLASS.

Design Principles

1. Single Responsibility

One BAdI implementation per business requirement:

  • Easier to test and debug
  • Can enable/disable independently
  • Clear ownership

2. Filter Values

Use filter values to limit when enhancements fire:

" Only execute for specific warehouse
IF iv_lgnum NE 'WH01'.
  RETURN.
ENDIF.

3. Defensive Coding

" Always handle empty inputs
IF it_who IS INITIAL.
  RETURN.
ENDIF.

" Wrap in try-catch for stability
TRY.
    perform_enhancement( ).
  CATCH cx_root INTO DATA(lx_error).
    log_error( lx_error ).
ENDTRY.

Common BAdI Use Cases

Requirement BAdI
Custom putaway logic /SCWM/EX_PUTAWAY_STRATEGY
Wave assignment rules /SCWM/EX_WAVE_TEMPL
RF screen modifications /SCWM/EX_RF
Task validation /SCWM/EX_WT_CHECK

Testing Strategy

  1. Unit test enhancement logic in isolation
  2. Integration test with EWM transactions
  3. Volume test for performance impact
  4. Regression test standard scenarios

Avoid These Mistakes

  • Putting too much logic in one implementation
  • Not documenting business requirements
  • Ignoring performance implications
  • Not considering upgrade impact
  • Modifying standard code instead of using BAdIs

Well-structured BAdI implementations are a joy to maintain. Poorly structured ones become technical debt.

← Back to Blog