cancel
Showing results for 
Search instead for 
Did you mean: 

BAdI........How are they used in the real time scenario.

Former Member
0 Kudos

Im a rookie in ABAP development and i was wondering that how we use the BAdI enhancement technique in the real time scenarios. Like do we get create them or we have few already built BAdI's which we work on? Can any body please explain how this works.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi! Ramana,

Coming to BAdi's we have two scenarios we can create our own BAdi's (rare situation) or use an existing BAdi. BAdi's are just like user exits, but the difference is once if an exit is implemented it will never appear from SMOD. But BAdi dehaves different, even if you implement a BAdi you can see it again. User exit can be implemented only once, but we have single and multiple implementation BAdi's. Standard BAdi's are just like skeleton's, they may or may not have code in it. BAdi's are like Interfaces in JAVA, we will create the skeleton for methods and classes in interface, based on our requirement we can call this interface from any part of any program and write custom code in these methods and classes.

Coming to the usage of BAdi, say you have a situation where you need to enhance standard functionality of a transaction when save button is clicked, but in vein you have no exits for that, then you can find the BAdi's triggering in that situation and try to implement the BAdi and add your own custom code into that implementation.

Follow the below steps to find out what all BAdi's are called when you press any button in any transaction.

1) Go to SE24, in the Object type input box enter CL_EXITHANDLER and display

2) You will be taken to a window, click on Methods tab and double click on GET_INSTANCE method.

3) Put a break-point at line no. 25 (SY-SUBRC).

4) Now execute any SAP standard transaction in which you would like to find BAdi’s.

5) Press the required button for which you need to write exit logic, the execution will stop at the break point and you will be taken to debug mode.

6) Type EXIT_NAME in debug mode, on the right side you can find the name of BAdi's triggering at that time.

Cheers,

Venkatesh.

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Ramana,

BADI's are used for enhancement purposes.

Badi Definition - se18

Badi implementation - se19

As part of Badi definition we get one interface (set of abstract methods) and a business add in class.

Business add in class maintains the index of the active badi implementations for that badi definition.

As part of Badi implementation we will be getting one implementation class.

Inside the badi implementation we need to implement the appropriate badi interface method .

A single use badi can have only one active implemenation at any point of time.

A multiple use badi can have any no of active implementations.

Example : Custom badi.

Badi definition .

se18 -->provide badi definition name (ztestbadi), click on create --> provide the methods in the interface displayed. For this double click on interface , it opens class builder where we need to specify the methods for the badi interface. eg : sayhello.Save and check the class builder tool.

Comeback ,save and check the badi definition.

Badi implementation.

se19--> provide badi implementation name(zimplbadi), click on create --> it prompts for badi definition name, provide it(ztestbadi),click on continue. Now implement the appropriate method. Double click on method (sayhello) , it opens class builder ,provide the implementation logic for badi method sayhello.

Eg : write 'hello'.

Save and check the method , comeback , save ,check and activate the badi implementation.

Calling the custom badi from executable program :

Procedure 1:

data : obj type ref to ZIF_EX_TESTBADI.

CALL METHOD cl_exithandler=>get_instance

CHANGING

instance = obj.

call method obj->sayhello.

procedure 2:

data : obj type ref to ZIF_EX_TESTBADI.

data : obj1 type ref to ZCL_IM_IMPLBADI.

create object obj1.

obj = obj1.

call method obj->sayhello.

<u><b>Searching of BADI</b></u>

Go to the Transaction, for which we want to find the BADI,

Get the Program Name of Corresponding Transaction.

(Click on System->Status. Double Click on Program Name)

Once inside the program search for ‘CL_EXITHANDLER=>GET_INSTANCE’.

Make sure the radio button “In main program” is checked.

A list of all the programs with call to the BADI’s will be listed.

The export parameter ‘EXIT_NAME’ for the method GET_INSTANCE of class CL_EXITHANDLER will give badi definition name.

<u><b>Advantage of BADI over user exits</b></u>

BADIs can have multiple active implementations unlike user exits which has only 1 active implementation.

Check following URLs.

http://esnips.com/doc/e06e4171-29df-462f-b857-54fac19a9d8e/ppt-on-badis.ppt

http://esnips.com/doc/43a58f51-5d92-4213-913a-de05e9faac0d/Business-Addin.doc

http://esnips.com/doc/10016c34-55a7-4b13-8f5f-bf720422d265/BADIs.pdf

http://esnips.com/doc/1e10392e-64d8-4181-b2a5-5f04d8f87839/badi.doc

http://esnips.com/doc/365d4c4d-9fcb-4189-85fd-866b7bf25257/customer-exits--badi.zip

http://esnips.com/doc/3b7bbc09-c095-45a0-9e89-91f2f86ee8e9/BADI-Introduction.ppt

Award points if found useful.

Regards

Indrajit

Former Member
0 Kudos

hi,

Implementing Business Add-Ins (BADI)

The use of object orientated code within SAP has lead to new method of enhancing standard SAP code called

Business Add-Ins or BADI's for short. Although the implementation concept is based on classes, methods and

inheritance you do not really have to understand this fully to implement a BADI. Simply think of methods

as a function module with the same import and export parameters and follow the simple instructions below.

Steps:

1. Execute Business Add-In(BADI) transaction SE18

2. Enter BADI name i.e. HRPBSGB_HESA_NISR and press the display

button

3. Select menu option Implementation->Create

4. Give implementation a name such as Z_HRPBSGB_HESA_NISR

5. You can now make any changes you require to the BADI within this

implementation, for example choose the Interface tab

6. Double click on the method you want to change, you can now enter

any code you require.

7. Please note to find out what import and export parameters a

method has got return the original BADI definition

(i.e. HRPBSGB_HESA_NISR) and double click on the method name

for example within HRPBSGB_HESA_NISR contract is a method

8. When changes have been made activate the implementation

regards

Former Member
0 Kudos

Hi Ramana,

Business add-ins are enhancements to the standard version of the system.

Business Add-In is a new SAP enhancement technique based on ABAP Objects.

They can be inserted into the SAP system based on specific user requirements.

Each Business Add-In has:

• at least one Business Add-In definition

• a Business Add-In interface

• a Business Add-In class that implements the interface

In order to enhance a program, a Business Add-In must first be defined

Subsequently two classes are automatically generated:

• An interface with ‘IF_EX_’ inserted between the first and second characters of the BADI name.

• An adapter class with ‘CL_EX_’ inserted between the first and second characters of the BADI name.

The Application developer creates an interface for this Add-In.

There are multiple ways of searching for BADI.

• Finding BADI Using CL_EXITHANDLER=>GET_INSTANCE

• Finding BADI Using SQL Trace (TCODE-ST05).

• Finding BADI Using Repository Information System (TCODE- SE84).

1. Go to the Transaction, for which we want to find the BADI, take the example of Transaction VD02. Click on System->Status. Double click on the program name. Once inside the program search for ‘CL_EXITHANDLER=>GET_INSTANCE’.

Make sure the radio button “In main program” is checked. A list of all the programs with call to the BADI’s will be listed.

The export parameter ‘EXIT_NAME’ for the method GET_INSTANCE of class CL_EXITHANDLER will have the user exit assigned to it. The changing parameter ‘INSTANCE’ will have the interface assigned to it. Double click on the method to enter the source code.Definition of Instance would give you the Interface name.

2. Start transaction ST05 (Performance Analysis).

Set flag field "Buffer trace"

Remark: We need to trace also the buffer calls, because BADI database tables are buffered. (Especially view V_EXT_IMP and V_EXT_ACT)

Push the button "Activate Trace". Start transaction VA02 in a new GUI session. Go back to the Performance trace session.

Push the button "Deactivate Trace".

Push the button "Display Trace".

The popup screen "Set Restrictions for Displaying Trace" appears.

Now, filter the trace on Objects:

• V_EXT_IMP

• V_EXT_ACT

Push button "Multiple selections" button behind field Objects

Fill: V_EXT_IMP and V_EXT_ACT

All the interface class names of view V_EXT_IMP start with IF_EX_. This is the standard SAP prefix for BADI class interfaces. The BADI name is after the IF_EX_.

So the BADI name of IF_EX_CUSTOMER_ADD_DATA is CUSTOMER_ADD_DATA

3. Go to “Maintain Transaction” (TCODE- SE93).

Enter the Transaction VD02 for which you want to find BADI.

Click on the Display push buttons.

Get the Package Name. (Package VS in this case)

Go to TCode: SE84->Enhancements->Business Add-inns->Definition

Enter the Package Name and Execute.

Here you get a list of all the Enhancement BADI’s for the given package MB.

Have a look at http://help.sap.com/saphelp_nw04/helpdata/en/04/f3683c05ea4464e10000000a114084/content.htm

http://help.sap.com/saphelp_erp2005/helpdata/en/73/7e7941601b1d09e10000000a155106/frameset.htm

http://support.sas.com/rnd/papers/sugi30/SAP.ppt

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/abapindx.htm

http://members.aol.com/_ht_a/skarkada/sap/

http://www.ct-software.com/reportpool_frame.htm

http://www.saphelp.com/SAP_Technical.htm

http://www.kabai.com/abaps/q.htm

http://www.guidancetech.com/people/holland/sap/abap/

http://www.planetsap.com/download_abap_programs.htm

http://help.sap.com/saphelp_nw04/helpdata/en/c8/1975cc43b111d1896f0000e8322d00/content.htm

/people/thomas.weiss/blog/2006/04/03/how-to-define-a-new-badi-within-the-enhancement-framework--part-3-of-the-series

/people/thomas.weiss/blog/2006/04/18/how-to-implement-a-badi-and-how-to-use-a-filter--part-4-of-the-series-on-the-new-enhancement-framework

Reward if useful.

Thanks

Aneesh.

Former Member
0 Kudos

See things u r talking about is like this....

There are some standard functionality provided by SAP which fits into the business processes of your client and I see in most cases all requirements are met by SAP standard functionality ...in some cases SAP does fit and these processes are specific to ur client ....like in standard SAP like take case of MIRO process , u do LIV verification w.r.t PO ...In that suppose you want to put some check that w.r.t. some payment method ...system should consider some specific cost centers only....and since this is not a standard function provided by SAP ...so there is a GAP betwen SAP and your clients requirement so custom the MIRO process as per your clients requirement u go for user_exits or BAdi .

Reward Points if it is helpful

Thanks

Seshu