Wednesday 26 November 2014

Kernel BAdI : How to Use Kernel BAdI with limited filter Use?

----------------------------------------------------------------------------------------------------------------------------------------------
For a single implementation BAdI, it is possible to create multiple implementations but at a time only one can be active. But Single implementation with limited Filter Use option provides a different flavor of single use BAdI. For a single implementation BAdI with Limited Filter Use allows to create multiple active implementations for each filter value . This post depicts  one of the such case. 

Step1. Here is an example single implementation with limited filter use BAdI.












    
Step2. Go to Tcode - SE11, provide a domain name and create it. This domain we will use in our badi filter.




  
Step3. Provide details.




  

Step4. Provide some fix values. If we will use this domain for the filter we can max create 3 implementations for the badi definition .






  

Step5. Go to tcode- SE20 and provide a enhc spot name and create it.






  


Step6. Provide the details and continue.




  

Step7. Activate the spot and click on the create button to create a badi definition.




   

Step8. Provide badi name and description and continue.




  

Step9. By default it comes as a multiple use badi but we need a single use with limited filter use.




     


Step10. Choose appropriately.



   

Step11. From the highlighted point choose to create a filter.




   

Step12. Provide a filter name, type and description. Select the option Automatic through dictionary. Provide the above create domain name and select the check box and continue.



   


Step13. So here the filter variable is created wit a map to the domain. Now we have to create a interface and define its method . Double click on the interface.



   

Step14. Provide an interface name and hit enter key.





 Step15. From the prompt pop up yes to continue.



   

Step16. Provide a method name & activate it. Go back.



    

Step17.  BAdI definition is complete. Lets create some implementation.



  


Step18.  Right click on the implementation and choose create badi implementation.



  

Step19.  Provide an enhancement implementation name and text and continue.



  


Step20.  Provide an badi implementation name and class name and continue.





  

Step21. Here double click on the Filter Val to maintain filter value for the filter variable defined in the badi definition.



Step22.  Click on the create combination button.




   

Step23. Double click on the new appeared line.



   

Step24. Click on the F4 value.




  


Step25.  it displays all values values defined in the domain associated with the badi filter variable.



    


Step26. Choose I and continue.



   

Step27. Now lets implement the class method. So double click on the implementing class. 



  

Step28. Double click on the method name.



   

Step29. Maintain the some code in the method activate it and go back.




   

Step30.  So we have one implementation.




  

Step31. 

Create one more implementation.



   


Step32.  Select badi name from the f4 help. Give an implementation name, class name and continue.


  

Step33.  yes to continue.






    


Step34. Double click on the filter value.


   

Step35.  Create on create button.



   

Step36. Click on the new line.


  


Step37.  Choose E from the f4 value help. and continue.



  

Step38. Click on the implementating class.



   

Step39.  Double click on the method to maintain the code inside it.





  


Step40. Maintain the code. Activate it and go back.


  


Step41.  Create one more implementation.



  


Step42.  Choose BAdI name from the F4 help. provide a new implementation name and implementing class name.


  

Step43.  Double click on the filter val option to maintain the filet value for this implementation.


  

Step44. Click on the create button.




   

Step45. Click on the new appeared line.




  


Step46.  Maintain value as X from the F4 help. Here we can not create two different implementation with the same domain fix value. the error will come when second implementation is activated with the same value.




  

Step47. Double click on the implementing class.




   

Step48. Double click on the method name to maintain code for this implementation.




  

Step49. Maintain the code. Activate it and go back.





  


Step50.  So we have three active implementation for single use badi with multiple filter use. Go back.




  

Step51.  So we have a badi definition with three active implementation for a single use limited use filter.




  

Step52. In SE11 create a data element for the pre created domain.




  


Step53. Select the data element and continue.




  

Step54. provide the domain name and its label and activate it.




  

Step55. We have the data element ready.



  

Step56. create the program which the particular implementation which is decided by the value passed in the parameter source as a filter value to the filter variable in theget badi statement.




  

Step57. Run the same report in three different transactions with different filter value.




  


Step58. So here in each cane the respective filter match badi implementation is called and the method is executed and we have the below output.





---------------------------------------------------------------------------------------------------------------------------------------------------

No comments:

Comments system

Disqus Shortname