Anthony Cecchini is the President of Information Technology Partners (ITP), an SAP consulting company headquartered in Pennsylvania. ITP offers comprehensive planning, resource allocation, implementation, upgrade, and training assistance to companies. Anthony has over 17 years of experience in SAP R/3 business process analysis and SAP systems integration. His areas of expertise include SAP NetWeaver integration; ALE development; RFC, BAPI, IDoc, Dialog, and Web Dynpro development; and customized Workflow development. You can reach him at [email protected].
The Enhancement Framework Technologies
OK…In this Blog let’s now take a look at the technologies offered by the Enhancement Framework.
Because you can only attach an enhancement where there is a hook, it is important to know the different kinds of enhancement options that are available.
In addition to the new kernel-based BAdI, there are many other types of enhancement options that are part of the new Enhancement Framework. You implement these enhancements using the Enhancement Framework tools, which are integrated into the ABAP Workbench — you simply switch to the enhancement mode directly within the ABAP Workbench tool that you are using, in the same way that you switch to the change mode. (see below)
You can add methods to a class, or you can replace the code of a method entirely using an overwrite method. Can you see the latitude this gives you? You can completely change how a method delivered by SAP works.
You can also add optional parameters to existing methods (added parameters must be optional so that the enhancement does not invalidate the code).
You can add pre and post methods to existing methods.A pre method is executed before the method to which it belongs and has a context of its own. This means that you have no access to the local variables of the method. The same applies analogously to post methods.
Using overwrite methods in conjunction with optional parameters gives developers a lot of freedom. The only part of a method that cannot be changed using the Enhancement Framework is the signature of a method specifying the mandatory parameters.
Function Group Enhancements:
You can enhance the interface of a function module through the use of additional parameters. As with methods, you can add only optional parameters — but not mandatory parameters — because an enhancement must not invalidate the code it enhances.
Source Code Enhancements:
There are two types of source code enhancement options — enhancement points and enhancement sections. Enhancement points and enhancement sections are positions defined in the source code where you can attach source code plug-ins that enhance the code. There is one notable difference between enhancement points and enhancement sections: Source code plug-ins that are inserted at an enhancement point are executed in addition to the existing source code, while source code plugins inserted at an enhancement section replace the code of the section.
Given these enhancement sections, not only you can add something to the original code, but you can also replace sections if they are so flagged by the developer of the unit.
When the Enhancement-Section is implemented, only the implementation gets executed and the original code doesn’t get executed.. Because of this, there can be only one active implementation of an Enhancement-Section.
On the other hand, there can be multiple active implementations of an Enhancement-Point, in which case all the implementations will be executed with no guarantee in the order of execution
Web Dynpro Enhancements:
The Web Dynpro ABAP user interface (UI) technology offers a variety of enhancement options. You can enhance a Web Dynpro view by adding UI elements to it — either new parts to existing elements (e.g., a new column to an existing table) or completely new elements (e.g., a new button). Many UI elements only make sense if they are “Event-able” i.e… a new button should trigger some action, a new table should show some data, and a new input field should transport data to the business layer, for example.
The Web Dynpro enhancements provided by the Enhancement Framework enable you to easily add such functionality.
Some examples of enhancements you can add:
– Add methods in the view or component controller and enhance existing ones using pre and post exits that are executed before or after the respective method is processed
– Add actions in the view controller and events in the component controller that trigger new methods if they subscribe to these new actions and events
– Add plugs that enable you to create new navigation paths in the view controller.
– Add attributes in the view or component controller to hold data.
– Add nodes and attributes to existing nodes to hold the data for new UI elements.
The New BAdI:
The new BAdI is now part of the Enhancement Framework. A BAdI is an object-oriented enhancement option, a hook for an object plug-in, and this way the most sophisticated enhancement type.
When defining a BAdI, you determine its interface — that is, which methods the BAdI offers. BAdI implementations are classes that implement the BAdI interface. Typically, these implementations are created in another development layer; for example, objects owned by the customer that are in the customer namespace, while the BAdI definition and the call of the BAdI methods belong to the SAP namespace. Calling a BAdI method is, in many respects, like a dynamic method call with a specified interface. Which methods are actually called is determined by the active BAdI implementation.
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)
The Enhancement Framework introduces a new BAdI with several advantages over the classic BAdI introduced with SAP R/3 4.6 — although the basic functionality has not changed. Due to its integration into the kernel, the new BAdI has taken a big leap in performance and is directly supported by the ABAP language through two new commands GET BADI and CALL BADI, which make for an easier syntax when you create a BAdI instance and later call BAdI methods. There is also advanced filter support, which provides for more flexibility.
Now that you have a solid understanding of the basic concept behind the Enhancement Framework technologies offered, let’s take a closer look at the enhancement options, which are the key to understanding the functionality of the framework.
Implicit and Explicit Enhancement Framework Options:
Some things in life are free, and, of course, some are not. This is also true for enhancement options, which come in two flavors: implicit enhancement options, which are provided by the framework, and explicit enhancement options, which must be provided by the developer back at SAP Waldorf.
Let’s look at these two enhancement option types in some more detail:
Implicit enhancement framework options exist in a unit without the SAP developer of the delivered unit having to lift a finger. There is no need to do anything explicitly — these are the ones we get for free. Implicit enhancement options are included with programs, global classes, function modules, and includes. The SAP developer back in Germany of a program or class need not make any preparations to make these compilation units enhanceable for me and you. This is done by the framework. Implicit enhancements comprise class enhancements, function group enhancements, Web Dynpro enhancements, and predefined enhancement points at the end of a report, a function module, an include, or a structure, and at the beginning and the end of a method.
Explicit enhancement framework options require some work on the part of the SAP developer back at SAP HQ, who must explicitly insert them in the compilation unit to make it enhanceable by somebody else (you & me). Only if the developer of a unit has preconceived the respective enhancement option’s need or value, can the customer do enhancements there later. Source code plug-ins and BAdIs are explicit enhancement options. An SAP developer can, for example, insert an option for a source code enhancement with the commands ENHANCEMENT-POINT and ENHANCEMENT-SECTION, so that somebody else(you & me) can insert a source code plug-in. BAdIs are a bit more complex. They must first create a BAdI in the BAdI Builder (integrated into transaction SE80 or SE18), provide an instance of this BAdI in the source code, and can call a method of this BAdI. We can then implement using (SE19).
Implementing and defining enhancement options: two different roles
Not only is defining and implementing an enhancement option technically different, there are two roles involved in enhancement options — somebody defines or provides the enhancement option (we will call them the option provider) and somebody uses the option to implement an enhancement (we will call them the option implementer).
Lets define these roles in more detail, as the final blog will use the terms and I want to be sure you clearly see the delineation of the roles.
The option provider creates an enhancement option that provides the hook to which others can attach an enhancement. In general, the option provider is the SAP developer, back in Germany, of an object who anticipates that a customer developer like us might want to add some code at a particular point to adapt the object to his or her own needs, and inserts an explicit enhancement option for this purpose. For example, perhaps in the program the SAP developer may see a need to select more columns than normally done, so they add an option for a source code plug-in to the SELECT statement. Since it is not possible to insert an enhancement point within a statement, they instead must mark the whole SELECT statement as an enhancement section, allowing the implementation contained in the source code plug-in to replace this section of code completely.
The option implementer is a developer like you and me who uses the enhancement option to implement an enhancement. An enhancement option all by itself, that is, without an implementation, does not do a lot when processed; in fact, it has no effect at all. It is a hook to which nothing is attached. So somebody needs to implement it if some work should be done here.
The implementer doesn’t need care about the details of an enhancement option, but does need to know how to use it. You might compare this to somebody who uses a service class; he or she only needs to know the public methods of the class or perhaps only the respective interface of interest, not what’s actually inside of the class. A typical implementer is an SAP customer who wants to add some functionality, and above all, wants to do this without modifying the source code delivered by SAP.
By now I am hoping you can see and appreciate the benefits this new technology brings to the table for us as developers when solving specific adaptation requirements at our customer sites.
Some of the benefits are:
– All enhancement technologies are now under a single roof of Enhancement Framework, and integrated into the ABAP workbench. Result: Enhancement is easily manageable.
– The Enhancement Framework can be switched using Switch Framework through package assignment.
– With new enhancement technologies (like Source Code, Function & Class enhancements), the options to enhance standard SAP code have increased tremendously. This cuts down on the need to do Core-mod, which requires more effort than enhancement
– Kernel-BAdi’s are much faster compared to the old classic-BADI’s
– Implementing classes of Kernel-BADI’s are re-usable through inheritance
One final word — “With great power comes great responsibility”!
So, PLEASE choose the options wisely. My best-practice recommendation for the order in which the enhancement options should be considered and used is as follows:
– Exit Forms
– Use a BADI; if there is no BADI to suite your need then….
– Try to solve it using Explicit Source code, Function and Class enhancements;
– Implicit Source code enhancement should be the last option to choose as it is essentially a changing SAP code.
The final blog installment, will further refine your understanding and give you a set of tips and rules to follow when using the enhancement framework.
This is a powerful technology and I cannot emphasize the importance of planning before you use the Enhancement Framework to adapt your SAP system.
To read part 1 of this series on the Enhancement Framework, use the following link. The New Enhancement Framework – Part 1.
To read part 2 of this series on the Enhancement Framework, use the following link. The New Enhancement Framework – Part 2.
To read part 3 of this series on the Enhancement Framework, use the following link. The New Enhancement Framework – Part 3.