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.
- 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.
Hi,
Good Work. Thanks for sharing the information.
Regards,
Ashish.
Hi,
Nice blog 🙂
Nice & Helpful…
keep sharing… 🙂
Cheers,
PS
Very nice document.Thanks for sharing.
Regards
Simple, But useful.Thaks for sharing
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
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.
Good Work!!
Thanks
Regards,
Niran.Ok
Hii Abyson,
Nice and clear articulation of the topic
Keep sharing.
Thanks & regards
Hi Abyson Joseph,
Good one … Very helpful…do you have any other blogs on enhancement…please share
Regards,
Rajesh
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,
Good one joseph.
Hi Abyson,
Good work. Very helpful document.
Thanks for sharing.
Regards,
Riju.
Very good document and informative. I was looking answers to these questions from a while.
Thanks for sharing..
Good work Joseph… Thanks for sharing.
Really a helpful document 🙂 Thanks Abyson .
Useful document……
Thanks for sharing.
useful document !!!
Very nice,useful and informative sharing….
Thanks for sharing. useful Information.
Regards.
Very useful for beginners like me.. Thanks
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 🙂
hiii,
Very Usefull…
Thanks For Sharing…
Ragards,
Mahadeo…
Hi ,
Good one..Very useful..
BR.
Giri
Very nicely explained:)
thanks
hi,
Nice explanation.
Helpful one…Thanks.
BR,
Naresh K.
Thank you for sharing, good work.
Good One, Abyson .
Regards,
Anoop
Thanks for sharing; I was wondering on the difference between static & dynamic enhancements.
Very good document…
Thanks for sharing you knowledge with us.
This was a very nice and clear explanation. Thumbs up!
Very clear explanation on enhancement points.
Thanks.