Working in cooperation with the classic append technology, the Enhancement Framework enables you to enhance all levels of an application from the Web Dynpro ABAP user interface over the application logic to the database layer. By going through a comprehensive example you will learn how to use the Enhancement Framework and discover the underlying principles and structures that make this technology so easy to work with.
Key Concept
The Enhancement Framework is the new technology for adapting SAP applications to meet business needs. If customers need to change or enhance an SAP application, they should use the Enhancement Framework instead of the classic modification technology.
In this first part of a three-article series I show you how to work with the Enhancement Framework, how to profit from its features, and how in principle an enhancement project is organized. I explain how this new framework allows customers to adapt SAP standard code without modifications. At the positions at which the customer adds something to or changes the code of a standard SAP object to enhance it, the new code can be added as an enhancement in its own package and is merged in at compile time in the original position of the underlying SAP development object. This way the enhancement is available at runtime as a part of the code it enhances, but from a transport perspective, it is the customer who owns the code. Because enhancements are objects themselves and owned by the customer, they are never overwritten in an upgrade, and the adjustment effort needed after an upgrade or installation of a Support Package (SP) is by far less than with the classic modification technology.
I also show you how to work with the relevant tools that are integrated in the ABAP Workbench, how to organize enhancement projects in detail, and in particular, how to create and handle the relevant objects of the framework. All enhancements (or to use the correct term “enhancement implementation elements”) reside in containers — simple enhancement implementations that help you to structure the many elements of an enhancement project.
I present a simple, but comprehensive example that covers all layers of an application with a Web Dynpro ABAP user interface. Using this example, I show you how to enhance a table UI element in a Web Dynpro ABAP view by adding a column and how to make all the other changes you need to wire up this additional column and fill it with life. In particular, you will learn that even adding such a simple item presupposes many other changes and come to understand the way in which you implement these changes using the Enhancement Framework and the classic append technology. Besides adding a column to the UI element, you will learn how to enhance the context that holds the data for the view, create a new data element, add an append to the database table from which the data is retrieved, enhance the structure that is used in the interface of the back-end class in the ABAP Dictionary, and enhance the Select statement in the method that gets the data from the database.
Enhance a Simple Application
Starting with a simple example, you will learn how to add new features to a Web Dynpro ABAP component, its applications logic, and the relevant ABAP Dictionary elements until you have seen the most basic concepts at work.
Suppose, within the classic ABAP flight model, there is a Web Dynpro ABAP screen delivered as an SAP standard object that shows a list of customers. Assume that your business requires some additional functionality on the screen: You want to have a column that shows whether a customer is a Frequent Flyer.
Note
The classic ABAP flight model comes from the SAP Internet Demonstration and Evaluation Systems (SAP IDES) in the SAP R/3 system.
With the Enhancement Framework, this is quite easy to achieve. All you have to do is add the screen elements you want as enhancements (how you do this is explained later in the article). You just add the new elements in the Web Dynpro ABAP editor, and you see them in the right position at runtime.
Figure 1 shows what the application looks like before you enhance it.

Figure 1
The UI of the application before it is enhanced
The table shows Customer Number, Customer name, Title, Street, Postal Code, City, and Country. This table is filled by a method in the Web Dynpro View Controller that is called before the screen is rendered.
In the example, you need another column that shows whether the customer is a frequent flyer. To get an overview of the changes that the application needs to create and wire up the new column, first look at how the application is structured, as shown in Figure 2.

Figure 2
The structure of the application before enhancing it
As Figure 3 shows, even though you have a very small change in the user interface, you need quite a few changes and additions to implement it. In fact, we only add a new column to a table UI element.

Figure 3
The structure of the enhanced application
Note
The light blue boxes are enhancements of the new Enhancement Framework. The dark blue boxes stand for new ABAP Dictionary elements or appends. Don’t worry about the other additions in the figure; I’ll explain them step-by-step.
What good is an additional column if no data type is provided for it and no data is shown in it at runtime? To type and populate the additional column with the correct data, you need to make some other changes or enhancements. Suppose that the table is typed with the fields of an ABAP Dictionary structure. First, you create a new data element and then create an append for the new structure by adding a new component ZZFREQ_FLYER that is typed with the new data element ZFREQUENT_FLYER. To do this, you use the classic append technology. These appends perfectly cooperate with the new enhancements created with the Enhancement Framework. The data for a Web Dynpro UI element in a view is held in a container, which is called the context. Because of this fact, if you want to enhance a table by adding an additional column, you first have to enhance the context by adding an additional attribute that holds the data for the new column, as shown in Figure 3.
To fill the context, a method in the view controller calls another method that selects the data from the database. Why are there two subsequent methods to do this simple job? Because of the separation of Web Dynpro logic from application logic, the Web Dynpro method does not select the data itself from the database, but rather calls another method that performs this job. This layered structure means that for your enhancement project you need to adapt both methods: The one method in the application logic must select an additional field. It also needs a broader structure as a returning parameter because additional data for the new column must be retrieved from the database table and handed to the other method. So you must enhance both the implementation of this method and its returning parameter. The other method in the Web Dynpro view controller needs another component for the structure that is used to fill the enhanced node in the Web Dynpro context, because the new column must also be filled with data.
In detail this means you need an enhanced SELECT statement in the method GET_CUSTOMERS(), which should retrieve an additional component: Frequent Flyer from the database in addition to the data that is already selected. In general, it is not possible to insert an enhancement into a statement, so you need to use an overwrite method, which replaces the whole method so that the enhanced SELECT statement can be executed. Once the data is selected by the overwrite method, the data is returned to the method WDONINIT() in the Web Dynpro Controller, which then inserts the data in the context of the Web Dynpro view so that it can be shown in the user interface.
At first, it might seem hard to understand why Figure 3 shows no changes in the returning parameter of the method GET_CUSTOMERS(). In the same way, it might seem strange that the other method WDONINIT() in the Web Dynpro Controller is not changed at all. There is a reason why you do not need these changes. In both methods you need to enhance the data of the same data type. This data type describes a structure that contains all the fields of the UI table as components. One method, the one in the application logic, needs this structure as the line type of the table it returns; the other method needs this structure as the line type of the table that the method inserts into the Web Dynpro context.
You can enhance both structures so easily in one go because, from the very beginning, they are typed with the same ABAP Dictionary structure; that is, a structure that contains all and only the fields you need in the UI table and in the relevant returning parameter. This is the structure that is shown on the bottom left of Figure 3. In the example, this DDIC structure is used for the relevant typing in the way just described. Under this condition, you can add an append to this Data Dictionary (DDIC) type. At the same time, the structures and the relevant internal tables of both methods are enhanced automatically because the table in the returning parameter of the method GET_CUSTOMERS() and the table inserted into the context have this same DDIC structure as a line type. By the way, this is a good example of how efficient the usage of DDIC types can be. In enhancing the application, you profit from the fact that the example application uses this DDIC type. So much for what you have to do. Now get ready to create a new data element.
Append the ABAP Dictionary Elements
Create a new data element (e.g., ZFREQUENT_FLYER), as shown in Figure 4.

Figure 4
Create a new data element
Add the new data element as an append to both your database table (Figure 5) and the structure (Figure 6) you need for the interface of the controller method and for the table that fills the relevant context structure in the Web ABAP view as mentioned above.

Figure 5
Add an append to the database table
Figure 6 shows the structure with the new append. (I assume that you know how to add an append to a structure or a table in the ABAP Dictionary, so I won’t cover it here.)

Figure 6
Add an append to the ABAP Dictionary structure
Because the UI and the application layer, in general, need ABAP Dictionary structures or tables and their appends, but not vice versa, you should always start an enhancement project by adding the relevant appends to the ABAP Dictionary objects as shown.
Note
An enhancement project needs careful planning. So you should know at the very beginning which ABAP Dictionary types, structures, or table definitions you need to enhance, and you should implement these things before you start enhancing the application and the Web Dynpro ABAP layer.
Enhance the Web Dynpro ABAP Component
To enhance the Web Dynpro Component, you open the relevant Web Dynpro ABAP view in the ABAP Editor and change to the Enhancement mode. Click the View menu, and then click Enhance (Figure 7). When you add something in the enhancement mode, the additions (for example, the new UI elements) are shown in the editor at the positions where you add them, and they are compiled with the original object, so that they are part of the object at runtime. From a transport perspective, the enhancements are stored as objects of their own in their relevant containers as you will learn soon.

Figure 7
Switch to the enhancement mode
Enhancements are always part of a container to which they belong. These are the enhancement implementations. If there is no container, you must create one in the process of creating an enhancement, which you will do next. So once you have selected the menu item Enhance, a dialog window opens in which you either have to create an enhancement implementation or to choose one from among the already existing enhancement implementations. Since you have not provided an enhancement implementation so far, you have to create one. In real-world enhancement projects you should organize the enhancement implementations in composite enhancement implementations. In the dialog window shown in Figure 8, you could either enter the name of an existing composite enhancement implementation or create a new one by selecting the icon to the right of the field. For this demo project, you do not need such a composite enhancement implementation.

Figure 8
Create an enhancement implementation
Now you are in the enhancement mode of the Web Dynpro ABAP Editor, as shown in Figure 9. The phrase “Enhance View” at the top of the screen indicates this. Apart from this, the Web Dynpro ABAP view looks quite the same as in the change mode. In short, in the enhancement mode of a Web Dynpro ABAP view, you can do almost everything you can do in the change mode as far as UI elements are concerned, with one notable exception: You cannot change attributes of existing elements. You can even delete all existing standard UI elements, which can be a workaround if you need to change properties of existing UI elements: Delete them and insert new elements with the properties you need in the enhancement mode. As for the navigation plugs, methods, context nodes, and attributes in a Web Dynpro ABAP view, you can add new ones, but, in general, not change properties of existing ones — again — with one notable exception: You can change the destination of plugs. In a nutshell, you can do everything necessary to wire up changes in the UI elements. However, there is no need to remember this. The Web Dynpro ABAP Editor in the enhancement mode enables you to do the things you are entitled to. You can simply see what you can add or change. The rest is grayed out.

Figure 9
A Web Dynpro view in enhancement mode
A UI element of the type table always has to be bound against the attributes of a context node. It is these attributes that determine the structure of the table columns. As you remember, you should add an additional column to the table UI element. Before you can add this, you need a new attribute in the context because up to now it doesn’t exist in the context; therefore, you have to enhance the context. Your first step is to select the Context tab, and you see the tree with the context elements of the view in which you are working. The context node against which the table UI element is bound is SCUSTOM. Right-click this node, select Create Using the Wizard, and then select Attributes from Components of Structure (Figure 10).

Figure 10
Add a new attribute to the context of a Web Dynpro view in enhancement mode
Next, you can use the wizard in the same way as in the change mode, that is, to select the components of the structure with which this node is typed. Because the structure has a new component now, this new component is offered in the relevant dialog window (Figure 11) where you can choose which components should be reflected by attributes of the node.
Note
By adding additional components or an append to an ABAP Dictionary structure the nodes in a Web Dynpro ABAP context that are typed with this structure are not automatically changed. If the new components that have been added to the ABAP Dictionary structure should also be reflected by new attributes in the relevant node, you must explicitly add new attributes as we do here in our example.

Figure 11
Add a new attribute to the context of a Web Dynpro view in enhancement mode
Next, choose the new component in the append (in the example, ZZFREQ_FLYER) by selecting the relevant row in the dialog window and confirm by pressing the Enter key or clicking the execute icon. The new attribute is now part of the context. In the properties of the element, you see not only that it is an enhancement, but also to which enhancement implementation it belongs, as highlighted in Figure 12.

Figure 12
How you know that an attribute in the context is an enhancement and to which enhancement implementation it belongs
Next, you enhance the table by adapting its binding so that it contains a column of the type of the new attribute that you have just added to the context. To do this, select the Layout tab, right-click the table in the tree representation of the view elements on the right of the editor, and then select Create Binding on the context menu (Figure 13).

Figure 13
Add a new column to a table element in the enhancement mode
As shown in Figure 14, select the new context attribute ZZFREQ_FLYER in the dialog window that opens.

Figure 14
Bind the new attribute and thereby create a new table column
You select the new attribute in the column Binding and confirm. Now the table TABLE_CUSTOMERS has one more column. If you now expand this table in the tree representation on the right of the Layout tab, you see this new column (Figure 15).

Figure 15
The table element with a new column
If you activate the changes and run the Web Dynpro ABAP application by choosing Test from the context menu of the application in the object tree of the ABAP workbench, the table, as shown in Figure 16, appears with one more column, but this new column has no content. The reason why there is no data in the column is because you have not yet enhanced the method that selects the data from the database.

Figure 16
Application with new enhancement added
To pull new data into the table, you need to adapt the method that selects the data from the database. First, choose the enhancement mode in the same way as before in the Web Dynpro UI.
As stated previously, you need a container for the enhancement. Create the enhancement implementation ZES_DEMO_BACKEND for this (Figure 17). Again, you can do without a composite enhancement implementation because you do not need these high-level containers in this example project.

Figure 17
Create an enhancement implementation for the application logic enhancement
Next, add an overwrite method to substitute the existing method implementation (Figure 18).

Figure 18
Add an overwrite method to the method of a global class
As shown in Figure 19, there is now a button in the Overwrite Exit column.

Figure 19
Navigate to the implementation of the overwrite exit
Note
The only way to insert an exit for an overwrite method is by the selecting the menu entries in the way just shown.
Double-click the Overwrite Exit button to switch to the overwrite method, so you can implement it. Enter a SELECT statement so that one more column, the column ZZFREQ_FLYER, is retrieved from the database (Figure 20).

Figure 20
Implement the overwrite exit
Activate the enhancements of the Web Dynpro ABAP component and the application logic. In the browser window that shows the application, press F5 to refresh it, and there you are. Because of the enhancement in the application logic, the new column is now filled with data (Figure 21).

Figure 21
he enhanced application with the frequent flyer data
This enhancement project is finished. You have added enhancements and appends in the different layers of your little application and have activated them, and they are compiled in addition to or instead of the original objects, depending on the type of enhancement.
Conclusion
The Enhancement Framework cooperates with classic append technology to support the enhancement of all layers of an application from the Web Dynpro ABAP user interface over the application layer to the enhancement of ABAP Dictionary elements, such as data types, structures, and database table definitions. Because of the full integration of the framework with the ABAP Workbench, you can enhance an object as easily as you can change it. The ABAP Workbench provides a new mode to create, change, and manage enhancements: The enhancement mode. Working in this mode, you can enhance SAP standard objects and still control the objects created in this mode without changing the original objects. In the rare cases in which your enhancements need to be adjusted after an upgrade, import, or installation of a Support Package, there is a tool that informs you about which enhancements you have to adjust and that supports you in adjusting them.
Thomas Weiss
Thomas Weiss has a Ph.D. in analytic philosophy and worked as a professional writer before he joined the SAP NetWeaver product management training team in 2001 where his responsibilities included the e-Learning strategy for ABAP. After becoming more involved in writing ABAP material himself, he is now a member of Solution Management of the SAP NetWeaver Application Server ABAP. One of his main interests lies in rolling out ABAP topics both for experts and for beginners by writing weblogs in SDN such as his series on ABAP Unit or his contributions to the weblog series for ABAP beginners series part 3, part 4, and part 7. (You find the whole series with all his contributions here).
You may contact the author at thomas.weiss@sap.com.
If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.