Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member184611
Active Participant
37,640

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.

33 Comments
Labels in this area