You are on page 1of 4

Example: Custom Kernel Filter Dependent

BADI Creation, Implementation and


Triggering
Filter Dependent Standard BADI's:

Definition of BADI, BADI Triggering (Calling BADI) , Filter


Type---> SAP

Implementation of BADI with Filter Values-->


Developer

Custom Filter Dependent BADI Creation: (New BADI /


Kernel BADI):

Definition with Filter Type, Implementation with Filter Values,


Triggering by passing Filter Values---> Developer

1. Create Enhancement Spot--> Container of BADI definitions

2. Create BADI definition as part of Enhancement Spot

a) BADI Name

b) BADI Interface

c) BADI Interface methods

d) Single Use / Multiple Use

e) Filter dependent / Filter independent

3. Create BADI Implementations as part of Custom


Enhancement Implementations

4. Trigger the BADI

Procedure:

1. Declare the reference for BADI definition


2. Create the object for BADI definition (get badi...)

3. Using the Object, Call the appropriate BADI interface method


(Call badi....)

Example 1: Custom BADI (Filter dependent, Multiple


use)(EHP7)

Step 1: Create/consider Enhancement spot (ZESPOT) (SE18)

Step 2: Create BADI definition as part of Enhancement spot


(ZFTBADI) (SE18)

BADI Filter UNAME

Filter Type C

Description - ..

Select the radio button automatic through dictionary and


specify dictionary object as existing data element / domain
(XUBNAME).

Note: If we need to refer to a domain, select the checkbox object


is domain

BADI Interface --> ZIF_EX_FTBADI

BADI interface methods --> m1

Step 3: Create First BADI implementation (SE19)

Enhancement implementation: ZESPOT_ENHIMPL3

BADI implementation: ZFTBADIIMPL1

BADI implementation class: ZCL_IM_FTBADIIMPL1

Implementation for method 'm1':


method ZIF_EX_FTBADI~M1.
message 'First Impl of method m1' type 'I'.
endmethod.

Note: To Maintain Filter Values for this implementation, expand


BADI implementation and double click on filter values, in the right
hand side, click on the button create filter combination, then a
blank combination gets created, double click on the blank
combination and maintain filter value. Repeat the same process
for n no. of filter values.

Filter Values- ACCOUNTANT, FIORISERVER

Step 4: Create Second BADI implementation(SE19)

Enhancement Implementation: ZESPOT_ENHIMPL3

BADI Implementation: ZFTBADIIMPL2

BADI implementation class: ZCL_IM_FTBADIIMPL2

Implementation for method 'm1':

method ZIF_EX_FTBADI~M1.
message 'Second Impl of method m1' type 'I'.
endmethod.

Filter Values- FIORITEST

Step 5: Create Third BADI implementation(SE19)

Enhancement implementation: ZESPOT_ENHIMPL3

BADI Implementation: ZFTBADIIMPL3

BADI Implementation class: ZCL_IM_FTBADIIMPL3

Implementation for method 'm1':


method ZIF_EX_FTBADI~M1.
message 'Third Impl of method m1' type 'I'.
endmethod.

Filter Values- FIORISERVER

Step 6: Triggering the custom BADI (Executable Program)(SE38)

REPORT ZTRIGGERFTBADI.

data k type ref to zftbadi.

* get badi k. "syntax error

* get badi k filter-values uname = sy-uname.

* get badi k filter-values uname = ACCOUNTANT.

* get badi k filter-values uname = FIORITEST.

get badi k filter-values uname = ACCOUNTANT1. fallback class


gets executed

call badi k->m1.

FALLBACK Class
Whenever a filter dependent BADI is triggered, depending on the
filter value passed, SAP checks which active implementation/s
matches the filter value, based on this the active implementations
gets executed. If none of the active implementations matches
with filter values passed, then none of the active implementation
will be executed. In these cases, we can provide default
implementation as part of fallback class and this need to be
created and implemented as part of BADI definition. This fallback
class implementation gets executed whenever the filter value
passed doesnt match with any of the active BADI
implementations.

You might also like