Online Tutorials & Training Materials | STechies.com
Register Login

BADI- Step by Step Guide for Beginners

|| || 6

BADI- Step by Step Guide for Beginners
Stechies

DEFINING THE BADI

1) execute Tcode SE18.
2) Specify a definition Name: ZBADI_SPFLI
3) Press create
4) Choose the attribute tab. Specify short desc for badi.. and specify the type: multiple use.
5) Choose the interface tab
6) Specify interface name: ZIF_EX_BADI_SPFLI and save.
7) Double click on interface name to start class builder. specify a method name (name, level, desc).

Method level desc

Line section instance method some desc

8) place the cursor on the method name desc its parameters to define the interface.

Parameter type refe field desc
I_carrid import spfli-carrid some
I_connid import spefi-connid some

9) save, check and activate…adapter class proposed by system is

ZCL_IM_IM_LINESEL is genereated.

IMPLEMENTATION OF BADI DEFINITION

1) EXECUTE tcode se18.choose menuitem create from the implementation menubar.
2) Specify aname for implementation ZIM_LINESEL
3) Specify short desc.
4) Choose interface tab. System proposes a name fo the implementation class. ZCL_IM_IMLINESEL which is already generated.
5) Specify short desc for method
6) Double click on method to insert code..(check the code in “AAA”).
7) Save , check and activate the code.

Now write a sample program to use this badi method..

Look for “BBB” sample program.

“AAA”

data : wa_flights type sflight,
it_flights type table of sflight.

format color col_heading.
write:/ 'Flight info of:', i_carrid, i_connid.
format color col_normal.

select * from sflight
into corresponding fields of table it_flights
where carrid = i_carrid
and connid = i_connid.

loop at it_flights into wa_flights.
write:/ wa_flights-fldate,
wa_flights-planetype,
wa_flights-price currency wa_flights-currency,
wa_flights-seatsmax,
wa_flights-seatsocc.
endloop.

“BBB”

*&---------------------------------------------------------------------*
*& Report ZBADI_TEST *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT ZBADI_TEST.

tables: spfli.

data: wa_spfli type spfli,
it_spfli type table of spfli with key carrid connid.

*Initialise the object of the interface.
data: exit_ref type ref to ZCL_IM_IM_LINESEL,
exit_ref1 type ref to ZIF_EX_BADISPFLI1.

selection-screen begin of block b1.
select-options: s_carr for spfli-carrid.
selection-screen end of block b1.

start-of-selection.
select * from spfli into corresponding fields of table it_spfli
where carrid in s_carr.

end-of-selection.
loop at it_spfli into wa_spfli.
write:/ wa_spfli-carrid,
wa_spfli-connid,
wa_spfli-cityfrom,
wa_spfli-deptime,
wa_spfli-arrtime.

hide: wa_spfli-carrid, wa_spfli-connid.

endloop.

at line-selection.
check not wa_spfli-carrid is initial.
create object exit_ref.
exit_ref1 = exit_ref.

call method exit_ref1->lineselection
EXPORTING
i_carrid = wa_spfli-carrid
i_connid = wa_spfli-connid.

clear wa_spfli.

Get More Questions and Answers with Explanation at SAP ABAP Forums.


Comments

  • 01 Feb 2009 10:21 pm
    How the standard BADIs are called from the standard code? Suppose there is a BADI for transaction code VA01. I have decided to use BADI instead of an user exit. How this can be achieved? I am clear of definition and implementation of BADI.

    Thank you,
  • 28 Feb 2009 11:55 am
    it was very usefull example .
    I tried with this code.but i am getting error that
    "the type exit_ref1 cannot be converted into exit_ref."
    why its getting like that.
  • 23 Oct 2009 4:10 am

    Badi IMPLEMENTATION OF BADI DEFINITION tcode is se19
  • 07 Nov 2009 11:44 pm
    My understanding is that a BADI is the object oriented version of a User Exit. User exits are placed in SAP's code so that a customer can customize some of the functionality without making modifications to objects that fall in the SAP name space.

    1) Why do you need a BADI in a Z program???? Can't you just modify the program.

    2) Can you show us an example of using SAP provided BADIs?

    3) Adding code the SAP BADI's is easy. How would you modify screens in ENJOY transactions like ME51N using BADIs like adding a new tab (screen) or a button on the task bar? I have been trying to find examples for this on the net and I must say the literature available on the net is inadequate to say the least.
  • 09 Dec 2009 10:02 am
    Can any one define BADI in Functional language about the BADI, I know this is used for enhancement of SAP functionality. but can any one provide more info about what type of enhancements can be achieved and its limitation.
    Dont mind SAP GURU's but please provide inputs from Laymens idea...
    Can also provide inputs at ooksap@gmail.com
    THANKS IN ADVANCE
  • 11 Dec 2010 8:00 pm
    Hi,

    I can execute this BADI example. Bur I have one doubt. I think the same thing we can do without using BADI. Can u tell me what is the use of BADI here in the above example.

    RR

Related Articles

0.0186 seconds.