Technical Articles
Is Kernel BADI ‘really’ faster than Classic BADI ?
Author: Abyson Joseph Chavara
Created on : 04.03.2014
Introduction
SAP Business Add-Ins (BAdIs) are one of the most important technologies used to adapt SAP software to specific requirements.
As of Release 7.0 of the SAP NetWeaver Application Server ABAP (SAP NetWeaver 7.0), BAdIs are part of the Enhancement Framework, where they represent explicit enhancement options. We call these BAdIs classic BAdIs. In addition to their integration in the Enhancement Framework, BAdIs from Release 7.0 onwards differ from classic BAdIs particularly with regard to the fact that they are supported directly by the ABAP runtime environment through ABAP statements. We call these New BADIs or Kernel BADIs.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
And that is all about introduction, and you might have read that definition a 100 times.. And further, you all know, the main advantage of Kernel BADIs, its very faster than Classic BADIs.
Some of you might have checked why the kernel BADI is faster than Classic BADI?? Even I did the same and have found some answers as follows.
And after all my research, what I understood is – ” The old classic-BADI’s are implemented purely at the ABAP Workbench level; that is, both the definition and implementation are realized as workbench repository objects (global classes and interfaces). Thew Kernel BADI takes it to the ABAP language level with new commands ‘GET BADI’ and ‘CALL BADI’.
Apart from Classic BADI’s which are been called by Proxy class cl_exithandler, Kernel BADI’s are called directly with the reference to the BADI definition via GET BADI and CALL BADI statements. That is one of the reasons why Kernel BADI is faster than classic BADI. Also in Classic BADI, while we call it via cl_exithandler, we use the reference to the interface rather than BADI definition.”
The topic of this document is not about the reason of being faster, but to find whether Kernel BADI is ‘really’ faster or it is just a technically justified statement.
I didn’t get a chance to compare the performance of a Classic and Kernel BADI that process a very similar code. So I have created and tested such a scenario and just thought of sharing the findings here. Please note, this not an evaluation on the performance of New BADIs, rather I just made a comparison out of my own mere academic interest.
I have created a classic BADI via SE18 (SE18>Utilities>Create Classic BADI), and added a single method ‘DISP_MESSAGE’ in the interface, as shown below.
Subsequently I have created an Implementation for the BADI via SE19.
Since there is no specific requirement, I just wrote a code to show an Information message, as shown below.
The creation and implementation part of classic BADI is over.
Next I have created a Kernel BADI in a new Enhancement Spot and have made an implementation. To know more about creating Custom Kernel BADI’s, check the document Creation of Custom Kernel BADI and Calling it in a Custom Program .
You can see below that, there is only one method ‘DISP_MESSAGE’ added in the interface, same as we have done in case of Classic BADI.
The same code is added in the method implementation, as in Classic BADI method.
Even though we have used separate technique for creating classic and Kernel BADI’s, there is no difference in the code that is to be executed from two BADI’s. But as of our understating the second one, Kernel BADI should take less time for execution than the Classic one.
I have created two reports for calling the BADI’s. The first report calls classic BADI via the CL_EXITHANDLER proxy class. As you can see below, the instance is created in type ‘ZIF_EX_BADI_CLASSIC_TEST’ which is the interface used in classic BADI.
And in the second report program, I have called the Kernel BADI via GET BADI and CALL BADI statements. The instance is created in the type of ‘ZBADI_KERNEL_TEST09’ which is the name of BADI itself.
Using the TCode SAT (new version of se30), I have executed both the programs to check the net execution time.
The result for classic BADI program is as follows.
And in case of Kernal BADI program, the following result was displayed.
Comparing the net time in both results, it is apparent that the Kernel BADI executed very much faster than the classic BADI. The kernel BADI did take only 8,400 microseconds, whereas Classic BADI took 52,254 microseconds.
Thanks and Regards
Abyson Joseph
Hi,
Thanks for sharing 🙂
Hi Abyson,
Thanks for sharing..
I have a doubt, can we convert existing classic BADIs to Kernel one?
Hi Anoop,
A completely automated migration of all existing classic BAdIs is impossible because of the existing differences between classic and new BAdIs. But a semi automatic procedure for migration is available as mentioned in this link Migrating Classic BAdIs (SAP Library - Enhancement Framework) . Make sure that you migrate only your own BAdIs. Customers should never migrate the BAdIs that are provided by SAP.
Thanks and Regards,
Abyson Joseph
Hey Abyson - this is a good one!;-)
Thanks Carlos Roggan
Nice.
Hai,Abyson Joseph---very Good Document..
This is quite informative and well documented with images. Nice work.
Thanks
Chitwanjit
Thanks for posting such a nice doc.
Regards
Very helpful document Abyson. Thanks for sharing. 🙂
Regards,
Nandakumar S
the thought of comparing the performances of classic & kernel BADI is good. I like the idea:)
Hi Abyson Joseph Chavara
Thank you so much for sharing suprb Doc>> 🙂
Good analysis... Thanks for sharing .... 🙂
Thank you Abyson Joseph ...Nice document to clarify BADI types.
Thanks for sharing. 🙂 🙂
Regards,
Manjunatha K
Very nice explanation 🙂 Thanks very much!
Very nice and easy explanation 🙂
Thanks
Naren
Very Useful Post.
Thanks for sharing..
Beautifully explain, Thanks for sharing
Thanks for the explanation.
Does this mean that one of the popular way of looking for BADIs triggered in a process,
which is through placing a breakpoint in CL_EXITHANDLER get_instance method,
is just triggering the Classic BADIs and not the new ones as well?
Thanks A lot Abyson Joseph for sharing such a difference of classical and kernal or New BADi
Thanks Abyson, Very well explained
Thanks a million, Abyson Joseph. This one is fantastic.