Badi Implementation for Bex user exit variables
This document gives the step by step method for implementing BADI for user exit variables in Bex. This is an alternative approach to adding the code in EXIT_SAPLRRS0_001 through CMOD.
Writing codes for user exits in CMOD exit makes it cumbersome and difficult to debug. Besides, if multiple users want to write the code for user exits at the same time, they can’t do so. To overcome this, we can create BADI implementations in Enhancement spot and write a code to call the BADI in EXIT_SAPLRRS0_001.
Go to transaction SE18 and create an enhancement Spot as shown below
Enter description in short text and hit enter
Create BADI definition
Enter a technical name and description for Badi definition and hit enter
Select the option for multiple use and create filter as shown below
Give a technical name and description for the filter and maintain settings as shown below
Before creating the filter, dictionary object ZGLOB_VAR needs to be defined through SE11. ZVAR_NAM is a domain object we created with data type as char and length 30 which should be sufficient to hold the technical name of the variable.
Next, we need to create interface by entering technical name and clicking on change.
Select level as Instance Method and give a name to method and description
Under properties tab, enter type groups you need and keep the other tabs unchanged
With this, enhancement spot definition is complete. Next, we create individual implementation for each user exit variable. An e.g is shown below.
Enter technical name and description and hit enter
Next, we create Badi implementation and Implementing Class for the enhancement
The implementation is created. Then, customer exit variable name needs to be assigned to the filter and the corresponding code should be entered in the method of implementing class.
Click on filter val and select new combination as shown below
Click on the combination 1 and assign the technical name (ZFDAY in our case) of the customer exit variable to the filter
Then we need to click on Implementing Class, select the method on the right side and say yes
Enter your code in the space
On activation, we will have completed our first implementation. Like this, we can keep adding implementations as and when we create customer exit variables.
In the include of EXIT_SAPLRRS0_001 of our enhancement project in CMOD, we need to add a code to call the BADI as given below
DATA: badi_glob TYPE REF TO ZBW_VAR_BADI_EXIT.
GET BADI badi_glob
FILTERS
zglob_var = i_vnam.
CALL BADI badi_glob ->enhance
EXPORTING
flt_val = i_vnam
i_vnam = i_vnam
i_vartyp = i_vartyp
i_iobjnm = i_iobjnm
i_s_cob_pro = i_s_cob_pro
i_s_rkb1d = i_s_rkb1d
i_periv = i_periv
i_t_var_range = i_t_var_range
i_step = i_step
CHANGING
e_t_range = e_t_range
e_meeht = e_meeht
e_mefac = e_mefac
e_waers = e_waers
e_whfac = e_whfac
c_s_customer = c_s_customer.
Hello Blasco,
Good blog.
Very detail one too.
Thanks,
Vinay
Hi Blasco,
Very nice one as we can create multiple user Exit variables under one Enhancement Implementation Spot.
Regards,
Nitin.
Hello....
Explicitly written and cleared the air for me on BADI. Could you please post a document on ''How to pass two variable for BADI implementaion''.....Its invariably appreciated...
Regards,
HariKrishna
Good one Blasco!!
Very well documented ...
Thanks Blasco !!
Thanks for the information.
Great work.
Regards,
Anil.
Thanks Blasco.. It is really informatiive and useful ... 🙂
Keep posting the articles like this... 🙂
Regards
Kiran N
Hi Blasco,
Thanks for this. But, would it work in an SAP BW 7.0 system?
I am facing an error at the i_step declaration point.
Any help is appreciated.
Guys,
Any idea on this?
Thanks!
Anirban
Very good documents. Thanks.
Hi,
I'm also experiencing the same problem as anirban mukhopadhyay..Did I miss some config?
Also, do I need to apply this in the INCLUDE ZXRSRU01 of FUNCTION EXIT_SAPLRRS0_001?
DATA: badi_glob TYPE REF TO ZBW_VAR_BADI_EXIT.
GET BADI badi_glob
FILTERS
zglob_var = i_vnam.
CALL BADI badi_glob ->userexit
EXPORTING
flt_val = i_vnam
i_vnam = i_vnam
i_vartyp = i_vartyp
i_iobjnm = i_iobjnm
i_s_cob_pro = i_s_cob_pro
i_s_rkb1d = i_s_rkb1d
i_periv = i_periv
i_t_var_range = i_t_var_range
i_step = i_step
CHANGING
e_t_range = e_t_range
e_meeht = e_meeht
e_mefac = e_mefac
e_waers = e_waers
e_whfac = e_whfac
c_s_customer = c_s_customer.
Thank you.
Loed
Hi Loed,
I think you need to define I-Step in the attributes tab.
-Swati
Hi Swati,
Attributes tab where? I can't see an option where to type it..
Can I see a screenshot how you configured yours?
Thank you.
EDIT:
I created a thread swati gawade.. 😉
Error I_STEP is unknown in BADI customer exit
Loed
Hi,
When I'm entering this code in CMOD I'm getting error "Method "ENHANCE" is unknown or PROTECTED or PRIVATE. " Can you please help?
Thanks,
Swati.
very use full stuff.
Thanks
hari