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 specified.

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 BADI.

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.

Implementing BADI for XK01

You will go to next screen, change any one value and click on Save (Ctrl S).

BADI for XK01

The break-point will be triggered, note down all BADI names.

BADI for Vendor in SAP

Below are the list of BADI`s you will get
  • VENDOR_FIELDSTATUS
  • GOS_SRV_SELECT
  • ADDRESS_CHECK
  • ADDR_TXJCD_CHECK
  • CVI_CALL_BTE
  • ADDRESS_UPDATE
  • VENDOR_ADD_DATA

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 a 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 implementation.

Implement BADI for XK01

A popup will open, provide a implementaion name ex: ZVENDOR_ADD_DATA, continue.

Vendor BADI implementation

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 CHECK_ALL_DATA.
METHOD IF_EX_VENDER_ADD_DATA~CHECK_ALL_DATA.
BREAK-POINT.
ENDMETHOD.
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.
METHOD IF_EX_VENDER_ADD_DATA~CHECK_ALL_DATA.
IF I_LFA1=LAND1=`DE’AND I_LFA1-REGIO=`  ‘.
MESSAGE 'Region is required for German Vendors'  TYPE  'E'.
ENDMETHOD.
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 a error message.

BADI in SAP

The BADI is implemented successfully.

Please Sign in to ask a question

Was this lesson helpful to you? Yes No 82 People out of 85 think this lesson helpful


Lesson Navigation

←Previous Chapter
Next Lesson → SD and MM flows in SAP