You are on page 1of 4

SAP Community Network Wiki - Code Gallery - Create BADI without Implementation with fallback class

One of the key feature in SAP R/3 ecc 6.0 onwards is that the BADI can be assecced without implementation.

Steps:

1.) Go to SE18 ( create an enhancement spot )

give short description and continue

Step 2.) Create BADI by giving BADI name and short description

step 3.) Save your BADI definition and Enhancement Spot. Click on Interface

http://wiki.sdn.sap.com/wiki/display/Snippets/Create+BADI+without+Implementation+with+fallback+class[10/17/2010 5:32:50 PM]


SAP Community Network Wiki - Code Gallery - Create BADI without Implementation with fallback class

step 4.) Give interface as Z_BADI_INTERFACE and save it.

step 5.) Double click on the Interface and create a method like GET_FLIGHT_DATA and activate the interface.

step 6.) In the main screen of SE18 where we had created BADI, define a Fall Back Class and give a z_class name and press enter ..

http://wiki.sdn.sap.com/wiki/display/Snippets/Create+BADI+without+Implementation+with+fallback+class[10/17/2010 5:32:50 PM]


SAP Community Network Wiki - Code Gallery - Create BADI without Implementation with fallback class

The class will automatically inherit the methods of the interface defined. ( ie Z_BADI_INTERFACE ).

Step 7.) Double click on the method and write the code.

Step 8.) Save and Activate the Enhancement Spot and the BADI.

Step 9.) In the Application use ABAP statements GET BADI, CALL BADI to Access Badi Objects . Following is the code to access the BADI

*&---------------------------------------------------------------------*
*& Report YH1328_BADI_FLIGHT_TEST
*&

http://wiki.sdn.sap.com/wiki/display/Snippets/Create+BADI+without+Implementation+with+fallback+class[10/17/2010 5:32:50 PM]


SAP Community Network Wiki - Code Gallery - Create BADI without Implementation with fallback class

*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT yh1328_badi_flight_test.
*&---------------------------------------------------------------------
*& Parameters declaration
*&---------------------------------------------------------------------
PARAMETERS:
p_carrid TYPE scarr-carrid, " Airline code
p_connid TYPE sflight-connid, " Connection number
p_fldate TYPE sflight-fldate. " Flight date
*&---------------------------------------------------------------------
*& Internal table declaration
*&---------------------------------------------------------------------
DATA:
lt_flight TYPE STANDARD TABLE OF sflight.
*&---------------------------------------------------------------------
*& Field string declaration
*&---------------------------------------------------------------------
DATA:
fs_flight LIKE LINE OF lt_flight.
*&---------------------------------------------------------------------
*& Create instance for BADI
*&---------------------------------------------------------------------
DATA:
w_flight TYPE REF TO z_badi_test.
*&---------------------------------------------------------------------
*& START-OF-SELECTION EVENT
*&---------------------------------------------------------------------
START-OF-SELECTION.
GET BADI w_flight. " Access badi objects
*& Call BADI
CALL BADI w_flight->get_flight_data
EXPORTING
carrid = p_carrid
connid = p_connid
fldate = p_fldate
RECEIVING
t_flight = lt_flight.
LOOP AT lt_flight INTO fs_flight.
WRITE:
/ fs_flight-carrid,
fs_flight-connid,
fs_flight-fldate,
fs_flight-price,
fs_flight-seatsmax,
fs_flight-seatsocc.
ENDLOOP. " LOOP AT lt_flight INTO fs_flight

http://wiki.sdn.sap.com/wiki/display/Snippets/Create+BADI+without+Implementation+with+fallback+class[10/17/2010 5:32:50 PM]

You might also like