Skip to Content
Technical Articles
Author's profile photo Abyson Joseph

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.

/wp-content/uploads/2014/03/reason1_401969.jpg

/wp-content/uploads/2014/03/reason2_401970.jpg

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.

/wp-content/uploads/2014/03/cbadi1_401971.jpg

Subsequently I have created an Implementation for the BADI via SE19.

 

/wp-content/uploads/2014/03/cbadi2_401978.jpg

Since there is no specific requirement, I just wrote a code to show an Information message, as shown below.

/wp-content/uploads/2014/03/cbadi3_401979.jpg

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 .

 

/wp-content/uploads/2014/03/kbadi1_401980.jpg

 

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.

 

/wp-content/uploads/2014/03/kbadi2_401981.jpg

 

The same code is added in the method implementation, as in Classic BADI method.

 

/wp-content/uploads/2014/03/kbadi3_401982.jpg

 

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.

 

/wp-content/uploads/2014/03/cbadi_rpt_4_401983.jpg

 

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.

 

/wp-content/uploads/2014/03/kbadi_rpt_4_401984.jpg

 

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.

 

/wp-content/uploads/2014/03/cl_badi_result_401985.jpg

 

And in case of Kernal BADI program, the following result was displayed.

 

/wp-content/uploads/2014/03/ke_badi_result_401986.jpg

 

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

Assigned Tags

      22 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi,

      Thanks for sharing 🙂

      Author's profile photo Former Member
      Former Member

      Hi Abyson,

      Thanks for sharing..
      I have a doubt, can we convert existing classic BADIs to Kernel one?

      Author's profile photo Abyson Joseph
      Abyson Joseph
      Blog Post Author

      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

      Author's profile photo Carlos Roggan
      Carlos Roggan

      Hey Abyson - this is a good one!;-)

      Author's profile photo Abyson Joseph
      Abyson Joseph
      Blog Post Author

      Thanks Carlos Roggan

      Author's profile photo Madhu Vadlamani
      Madhu Vadlamani

      Nice.

      Author's profile photo Purnaiah Bandi
      Purnaiah Bandi

      Hai,Abyson Joseph---very Good Document..

      Author's profile photo Former Member
      Former Member

      This is quite informative and well documented with images. Nice work.

      Thanks

      Chitwanjit

      Author's profile photo Former Member
      Former Member

      Thanks for posting such a nice doc.

      Regards

      Author's profile photo Nandakumar S Nair
      Nandakumar S Nair

      Very helpful document Abyson. Thanks for sharing. 🙂

      Regards,

      Nandakumar S

      Author's profile photo Former Member
      Former Member

      the thought of comparing the performances of classic & kernel BADI is good. I like the idea:)

      Author's profile photo Former Member
      Former Member

      Hi Abyson Joseph Chavara

      Thank you so much for sharing suprb Doc>> 🙂

      Author's profile photo rajesh bethamcharla
      rajesh bethamcharla

      Good analysis... Thanks for sharing .... 🙂

      Author's profile photo ABAP Developer
      ABAP Developer

      Thank you Abyson Joseph ...Nice document to clarify BADI types.
      Thanks for sharing. 🙂 🙂

      Regards,
      Manjunatha K

      Author's profile photo Former Member
      Former Member

      Very nice explanation 🙂 Thanks very much!

      Author's profile photo Former Member
      Former Member

      Very nice and easy explanation 🙂

      Thanks

      Naren

      Author's profile photo Former Member
      Former Member

      Very Useful Post.
      Thanks for sharing..

      Author's profile photo Former Member
      Former Member

      Beautifully explain, Thanks for sharing

      Author's profile photo Akira Mizukami
      Akira Mizukami

      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?

      Author's profile photo Giri Babu Darapaneni
      Giri Babu Darapaneni

      Thanks A lot Abyson Joseph for sharing such a difference of classical and kernal or New BADi

      Author's profile photo sreenivasa kothuru
      sreenivasa kothuru

      Thanks Abyson,  Very well explained

      Author's profile photo Pankaj Yadav
      Pankaj Yadav

      Thanks a million, Abyson Joseph. This one is fantastic.