Skip to Content
Author's profile photo Abyson Joseph

Static Enhancement vs Dynamic Enhancement

Static Enhancment vs Dynamic Enhancement

Author: Abyson Joseph Chavara

Created on : 22.10.2013


Many a times in SCN, you might have met with the following questions regarding Static and Dynamic enhancements….


In the enhancement implementation I see “static enhancement point” or. a “dynamic enhancement point”). What’s the difference?


When I implement an implicit enhancement point, a popup with the buttons “Declaration” and “Code” appears. What is the difference?


If I choose “Declaration”, I still can insert non-declarative statements like WRITE into the enhancement code, and these code parts are processed as well as the enhancements declared as “Code”. So what’s the sense of this distinction?


Through this document, I hope you will get a clear cut idea on the basic difference between Static and Dynamic enhancements.

——————————————————————————————————————————————————


The addition STATIC is used to define a static source code enhancement. In a static source code enhancement, all incorporated source code plug-ins are taken into account when the program is executed, including those whose Switch is in the status stand-by.


The main purpose of the Switch Framework is to simplify an ABAP-based system landscape by adopting one or more industry solutions in a standard system. The Switch Framework allows you to externally control the visibility of repository objects or their components by means of switches.

The type of a switch can be specified for each business function that uses the switch.


If the option ‘Standby‘ is selected for the Switch type in Business Function, only declarative enhancements (all Dictionary enhancements such as table appends as well as static program enhancements) are activated when the business function is switched on. Also, dynamic program enhancements and BADI implementations remain switched off.


If the option ‘ Activation ‘ is selected for the Switch type in Business Function, means that when the business function is switched on, all switchable objects that are linked to the switch are activated. This means that declarative enhancements such as table appends are activated, and both static and dynamic program enhancements are executed at program runtime.


You will easily understand the above concept by going through the simple demo below.

——————————————————————————————————————————————————–


Already I have a switch in standby mode, which is assigned to a Business function via Tcode SFW2. See the image below.  For more details on Switch framework and the configuration you can check my document http://scn.sap.com/docs/DOC-47265

Now go to any of your custom program, and  create a Static enhancement option. Just right click in the editor and select create option.

Select the radio button ‘As Unconditional call’ to make it as a static enhancement option. Assign it to any enhancement spot.

Now create a Dynamic enhancement option by following the above same steps. By default the radio button ‘As conditional call’ is selected, ie it will be created as a dynamic enhancement option.

So we have created a static and dynamic enhancement option.  Now activate the program.

Next we need to implement these two enhancements options. To do that, click on the ‘Enhance’ Spiral button from the tool bar and right click on the enhancement option and select create implementation.

First create an implementation for the static enhancement point.

An important thing to remember, when you save the implementation, make sure that the package is assigned to the Switch(which we have marked as ‘Standby ‘ type). To learn how to assign a package to switch check my document http://scn.sap.com/docs/DOC-47265

Create an implementation for Dynamic enhancement option too.

\

Add some code to both implementations, here I have just hard-coded a break point in both as shown below.

Now check and confirm whether the Business function(to which our switch is assigned) is switched on Via Tcode SFW5. If not switch it on and activate the changes.

Now come back to your program and execute it.

You will find that the cursor will hit the break-point in  ‘ZENH_IMP_STATIC’ , which the implementation for the static enhancement point ‘ZENH_TEST_STATIC’. You will also notice that the debugger won’t hit the break-point added in the implementation of dynamic enhancement option.

Now you try the following changes in configuration and check how the changes are reflected.

  1. Switch off the business function via Tcode SFW5.

        Result: The debugger won’t hit both the static and dynamic implementations.

   2. Go to Tcode SFW2 and change the Switch type to ‘Activation’ Mode as shown below. Also change the Switch  to ON mode via Tcode SFW5 .

  

  Result:  The debugger will hit both the static and dynamic implementations.

The same is applicable to the ‘Declaration’ and ‘Code’ option, which you will find while creating implicit enhancements.  If you select ‘Declaration, it will be created as a Static enhancement, and if you opt ‘Code’, then that will be dynamic implementation.

Note, Data declarations are always static, even if they are inside a dynamic enhancement option.

Assigned Tags

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

      Hi,

      Good Work. Thanks for sharing the information.

      Regards,

      Ashish.

      Author's profile photo Former Member
      Former Member

      Hi,

      Nice blog 🙂

      Author's profile photo Former Member
      Former Member

      Nice & Helpful...

      keep sharing... 🙂

      Cheers,

      PS

      Author's profile photo Former Member
      Former Member

      Very nice document.Thanks for sharing.

      Regards

      Author's profile photo Former Member
      Former Member

      Simple, But useful.Thaks for sharing

      Author's profile photo Former Member
      Former Member

      This document should serve as an example to those who copy standard programs into custom ones & pass them as documents.

      You can still discuss something like this & be creative 😘 Good job Abyson Joseph

      Imo you should add a line that this is relevant only for Enhancements linked to a Switch. And may be append the document showing what happens if there is no Switch attached.

      Cheers,

      Suhas

      Author's profile photo Sougata Chatterjee
      Sougata Chatterjee

      Quite agree with Suhas here - it would be good to mention in this document that the explanation and the comparison of the Static v Dynamic is in the context of the Switch settings.

      Also,

      "Data declarations are always static, even if they are inside a dynamic enhancement option." - Not if the enhanement implimentation is in a package which is assigned to Switch which is in mode "Standby".

      Sougata.

      Author's profile photo Former Member
      Former Member

      Good Work!!

      Thanks

      Regards,

      Niran.Ok

      Author's profile photo Former Member
      Former Member

      Hii Abyson,

      Nice  and clear articulation of the topic

      Keep sharing.

      Thanks & regards

      Author's profile photo rajesh bethamcharla
      rajesh bethamcharla

      Hi Abyson Joseph,

      Good one ... Very helpful...do you have any other blogs on enhancement...please share

      Regards,

      Rajesh

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

      Hi rajesh,

      Please find the following docs...

      Switch framework http://scn.sap.com/docs/DOC-47265

      Custom Kernel badi creation http://scn.sap.com/docs/DOC-46804

      Thanks and Regards,

      Author's profile photo Former Member
      Former Member

      Good one joseph.

      Author's profile photo Former Member
      Former Member

      Hi Abyson,

      Good work. Very helpful document.

      Thanks for sharing.

      Regards,

      Riju.

      Author's profile photo Sravan Guduru
      Sravan Guduru

      Very good document and informative. I was looking answers to these questions from a while.

      Thanks for sharing..

      Author's profile photo Modadugu Hemanth Kumar
      Modadugu Hemanth Kumar

      Good work Joseph... Thanks for sharing.

      Author's profile photo Sivaganesh K
      Sivaganesh K

      Really a helpful document 🙂 Thanks Abyson .

      Author's profile photo Former Member
      Former Member

      Useful document......

      Thanks for sharing.

      Author's profile photo Jitendra Kansal
      Jitendra Kansal

      useful document !!!

      Author's profile photo abilash n
      abilash n

      Very nice,useful and informative sharing....

      Author's profile photo Shakeeluddin Khaja
      Shakeeluddin Khaja

      Thanks for sharing. useful Information.

      Regards.

      Author's profile photo Former Member
      Former Member

      Very useful for beginners like me.. Thanks

      Author's profile photo Satish Kumar Balasubramanian
      Satish Kumar Balasubramanian

      Hi,

      Very Good Document for all who work on enhancement objects.

      These many days we have implemented a few implicit enhancements,and always had a doubt on the CODE and DECLARATION.

      Am clear now, very useful and well explained document.

      Thanks for your Effort. All the best 🙂

      Author's profile photo Mahadeo Kedari
      Mahadeo Kedari

      hiii,

      Very Usefull...

      Thanks For Sharing...

      Ragards,

      Mahadeo...

      Author's profile photo Former Member
      Former Member

      Hi ,

      Good one..Very useful..

      BR.
      Giri

      Author's profile photo nabheet madan
      nabheet madan

      Very nicely explained:)

      thanks

      Author's profile photo Former Member
      Former Member

      hi,

      Nice explanation.

      Author's profile photo Former Member
      Former Member

      Helpful one...Thanks.

      BR,

      Naresh K.

      Author's profile photo Former Member
      Former Member

      Thank you for sharing, good work.

      Author's profile photo Former Member
      Former Member

      Good One, Abyson .

      Regards,

      Anoop

      Author's profile photo Tanmoy Mondal
      Tanmoy Mondal

      Thanks for sharing; I was wondering on the difference between static & dynamic enhancements.

      Author's profile photo Former Member
      Former Member

      Very good document...

      Thanks for sharing you knowledge with us.

      Author's profile photo Kjetil Kilhavn
      Kjetil Kilhavn

      This was a very nice and clear explanation. Thumbs up!

      Author's profile photo Deepa Kuppusamy
      Deepa Kuppusamy

      Very clear explanation on enhancement points.

      Thanks.