2007 Aug 24 11:59 AM
Hi Friends,
Is it possible to call a method that is implemented in the BAdi in another method.
To be clear, I have a Z class, and in one of the method I want to call the method that is implemented in the BAdi.
I have used the method
CALL METHOD CL_EXITHANDLER=>GET_INSTANCE
EXPORTING
EXIT_NAME = lv_exitname
NULL_INSTANCE_ACCEPTED = SEEX_TRUE
CHANGING
INSTANCE = lv_instance.
But here I have to specify the BADI Definition name but not the implementation. So I will get the instance where I can use the methods of BAdi definition. I want to call the methods of BAdi implementation. How can that be done?
Thanks & Regards,
Raju
Hi Friends,
Is it possible to call a method that is implemented in the BAdi in another method.
To be clear, I have a Z class, and in one of the method I want to call the method that is implemented in the BAdi.
I have used the method
CALL METHOD CL_EXITHANDLER=>GET_INSTANCE
EXPORTING
EXIT_NAME = lv_exitname
NULL_INSTANCE_ACCEPTED = SEEX_TRUE
CHANGING
INSTANCE = lv_instance.
But here I have to specify the BADI Definition name but not the implementation. So I will get the instance where I can use the methods of BAdi definition. I want to call the methods of BAdi implementation. How can that be done?
Thanks & Regards,
Raju
2007 Aug 24 12:04 PM
<b>Implementing Business Add-Ins (BADI) </b>
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
Also do refer,
http://help.sap.com/saphelp_nw2004s/helpdata/en/5e/ebb541c5b63031e10000000a155106/content.htm
http://sap.ittoolbox.com/groups/technical-functional/sap-dev/custom-badi-implementation-324215
We can have multiple implementations for BADI
that property of BADI makes it different from user exits
see the BADI Doc
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) Dbl clk on interface name to start class builder . specify a method name (name,
level, desc).
Method level desc
Linese;ection instance methos some desc
😎 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 generarted.
5) Specify short desc for method
6) Dbl clk on method to insert code..(check the code in AAA).
7) Save , check and activate the code.
Some useful URL
http://www.esnips.com/doc/e06e4171-29df-462f-b857-54fac19a9d8e/ppt-on-badis.ppt
http://www.esnips.com/doc/10016c34-55a7-4b13-8f5f-bf720422d265/BADIs.pdf
http://www.esnips.com/doc/43a58f51-5d92-4213-913a-de05e9faac0d/Business-Addin.doc
http://www.esnips.com/doc/1e10392e-64d8-4181-b2a5-5f04d8f87839/badi.doc
www.sapgenie.com/publications/saptips/022006%20-%20Zaidi%20BADI.pdf
http://www.sapdevelopment.co.uk/enhance/enhance_badi.htm
http://help.sap.com/saphelp_nw04/helpdata/en/04/f3683c05ea4464e10000000a114084/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/e6/d54d3c596f0b26e10000000a11402f/content.htm
regards,
srinivas
<b>*reward for useful answers*</b>
2007 Aug 24 12:07 PM
Hi,
YES in the code below
CALL METHOD CL_EXITHANDLER=>GET_INSTANCE
EXPORTING
EXIT_NAME = lv_exitname "BADI NAME
NULL_INSTANCE_ACCEPTED = SEEX_TRUE
CHANGING
INSTANCE = lv_instance. " IS a TYPE REF TO BADI interface
"lv_instance" will point to the instance of BADI implementation.
So now you can call the BADI method using this instance lv_instance.
Your lv_instance must be TYPE REF TO BADI's interface.
Regards,
Sesh
2007 Aug 24 12:16 PM
Hi
Thanks for the reply.
But when i call the method using that instance,
lv_instance->method
then in debugging on pressing F5, it goes to the code that is there in the standard class but not to the code that I have written while implementing the BAdi.
Regards,
Raju
2007 Aug 24 12:18 PM
Hi,
Did you make your BADI implementation Active in SE19.
And what is the BADI type ,Can this BADI have more than one implementation active at once, that is, is this badi multi-use?.
If this is Single-use then You need to make your BADI implementation as Active one in SE19.
Regards,
Sesh
2007 Aug 24 1:14 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |