You are on page 1of 9

Real time example of using BADI in SAP

Real time example of BADI for Vendor Master (Xk01) in SAP, BADI implementation for XK01

Requirement: Raise an error message whenever the vendor belongs to German and region is not

Requirement analysis In SAP vendors are created using T-code XK01, the created vendors will
be stored in LFA1 (Vendor Master Table), so we need to add custom functionality to validate
region when creating vendor using XK01 (also when changing in XK02), to do this we go for

To implement the BADI for XK01 we need to follow the below steps.

Step1: Find the BADI.

Step2: Select suitable BADI.

Step3: Implement the BADI.

Step4: Test the BADI.

Find the BADI for XK01/XK02

First step to implement BADI is finding the badi


Go to SE24 and put the break point in GET_INSTANCE method of CL_EXITHANDLER class.

Go to LFA1, take a vendor no and go to XK02, provide vendor no, enter.

You will go to next screen, change any one value and click on Save (Ctrl S).
The break-point will be triggered, note down all BADI names.

Below are the list of BADI`s you will get








Select the suitable BADI and verify the BADI

To select the suitable BADI, go to SE18, provide BADI name, display

Based on description and interface signature (importing and exporting parameters) we can
choose and verify some BADI`s
Now VENDOR_ADD_DATA will be useful for our requirement.

Implement the BADI

BADI uses object oriented concepts, BADI is nothing but an interface, to implement the BADI,
we need to create implementation for the interface.

To implement the BADI go to SE19 (BADI Builder), provide BADI name, create

A popup will open, provide an implementation name ex: ZVENDOR_ADD_DATA, continue.

Provide short description, based on description choose a method and double click to add owr
own code.

Here CHECK_ALL_DATA will be useful for final checks, so double click on

Go to XK02, provide vendor no, select address check box, change any one, save. Now our break
point will trigger, so we can implement this because this is very much suitable for our
requirement. Remove the break point and write the below code for implementing exit.
MESSAGE 'Region is required for German Vendors' TYPE 'E'.
Save, activate the method, go back activate the implementation.

Now BADI is implemented.

Test the BADI

To test the BADI, go to XK02, provide a vendor no, enter.

Change country to DE and Region to Space.

Save (Ctrl S).

You will get an error message.

The BADI is implemented successfully.