Sie sind auf Seite 1von 6

Th o m a s We i s s , S A P AG

Technical Column | Under Development


This article appeared in the Jul Aug Sep 2008 issue of SAP Insider and appears here with
n n

permission from the publisher, Wellesley Information Services (WIS), www.WISpubs.com.

Modification-Free Adaptations of SAP Programs?


With Enhancements, They’re Possible — and Here’s How

One of the great strengths of SAP software has always cycle; enhancements are never overwritten in an
been its adaptability — customers can either use a upgrade because they are objects in your namespace,
solution straight out of the box or truly customize it while modifications are part of the object they modify.
to their business needs. Until a few years ago, though, So with enhancements, you have most of the advan-
developers had to hard code any changes as modifi- tages of modifications while enjoying a freedom
cations, which would then be swept away should the from most of the work that modifications require in
company decide to upgrade the core. an upgrade.
Thomas Weiss (thomas.weiss@
But now, as previous Under Development columns All SAP industry solutions are now developed in
sap.com) has a Ph.D. in analytic have delved into, there’s a more state-of-the-art the latest ERP system. This translates into substantial
philosophy and worked as a
professional writer before he
technology to adapt SAP software to your needs: the advantages for customers:
joined the SAP NetWeaver switch and enhancement framework.
Product Management Training
 You can install the IS you like based on the latest
team in 2001, where his
In addition to the move away from modifications, SAP ERP release — you need not wait for conflict
responsibilities included the this framework powers some exciting benefits for resolution transports.
e-learning strategy for ABAP.
After getting increasingly
SAP customers — you’ve likely heard about the new
 You can use the latest SAP ERP technology in your
involved in writing ABAP material enhancement packages for SAP ERP 6.0, or the fact
himself, he is now a member of IS — some new logistics features in the IS Oil and
the SAP NetWeaver Application
that SAP now develops all of its industry solutions
Gas, for example — whereas before you needed
Server Product Management (ISs) in one system and delivers them on one set of
team. The enhancement and two systems: one for the IS and another system
switch framework has been a
DVDs (you simply switch on the solution you need).
running the latest version of SAP ERP.
topic of primary interest to These are the switch and enhancement framework’s
Thomas for quite some time.  Accordingly, you now need fewer systems in your
most important use cases:
Customers can now adapt SAP code without landscape — and this, in turn, means a lower TCO.
modifying it. With the new switch and enhancement Apart from this, by providing all ISs on one set of
4 Note!
framework, you can use enhancements to change or DVDs, SAP can offer functionality that can be used
In the April-June
add something to SAP standard objects without having within different ISs. A user of one IS can reuse
2008 Under Develop-
ment column, Karl to modify them. Enhancements are almost as flexible functionality from another IS. For example, IS Oil and
Kessler described as modifications, and they help you avoid most of Gas customers can reuse all the functionality of the
how to enhance a the work that modifications cause in the software life IS Utilities (as of enhancement package 3). This is a
Web Dynpro ABAP great advantage: Oil and gas companies can not only
application in some For an introduction to the switch and enhancement framework, see

calculate the mineral oil tax and plan the
“A New and Improved Approach to SAP Industry Solutions — How the
detail. In this article,
Switch and Enhancement Framework Now Consolidates SAP Industry storage and transport of oil and gas, but — because of
I’ll focus on the Solutions with the ERP Core” by Karl Kessler in the July-September
2005 issue of SAP Insider (www.SAPinsideronline.com). the additional functionality of the IS Utilities — can
structure of such
also handle mass billing for the end customer.
enhancements and 
For more about the SAP ERP enhancement package strategy, please
their basic principles, see “SAP’s New ERP Strategy for Developers: 4 Ways to Make the Most The enhancement package strategy of SAP ERP
of Your SAP ERP System” by Karl Kessler in the July-September 2007
rather than imple- issue of SAP Insider (www.SAPinsideronline.com).
6.0 gives you a new dimension of choices for get-
mentation details. ting new functionality. In the classic world, you had

The benefits of enhancements greatly outweigh those of modifications,
and the enhancement framework covers a lot of cases in which
customers want to adapt SAP code to their needs. But there might still Conflict resolution transports (CRTs) resolve conflicts that can arise


be some cases in which modifications are necessary; I will explain in between a support package for SAP ERP and an SAP industry solution
more detail later in this article. or other add-on component.

Subscribe today. Visit www.SAPinsideronline.com.


to choose whether you wanted to stay on one stable only the parts of the imported new functions you are
release or have new functionality. With SAP’s new interested in.
enhancement package strategy, you can have all the In this article, I will focus on the first use case: I’ll
advantages of staying on one release and you can get explain the basic advantages that enhancements
new functionality — not by an upgrade, but as parts have over modifications and walk you through how
of enhancement packages. Enhancement packages to make modification-free adaptations of SAP pro-
provide new features on top of the recent release. grams. In future articles, I’ll demonstrate how these
The import of these new features is separate from basic mechanisms are put to work in the reintegra-
their activation. Directly after the import, your sys- tion of SAP industry solutions and ERP enhance-
tem behavior is still the same: There are no changes ment packages. All told, you will learn how the
of user interfaces (UIs) or processes. Once imported, switch and enhancement framework empowers all
the sources that realize the new functionality are still three of these use cases, and you will gain a solid
not compiled before they are activated or switched understanding of this powerful new technology’s
on. On both levels (import and activation), you have basic structure and concepts.
full choice: Import only what you want and activate
Enhancements Versus Modifications:
What Are the Key Differences?
Consider a customer who wants to enhance a Web
Dynpro ABAP UI table element by adding an addi-
tional column and a detail table. With the enhance-
Adding an
additional ment framework, this is quite easy to achieve: You’d
UI column
simply add the screen elements as enhancements —
to indicate
frequent you’ll then see them in the correct position, both in
flyers
the design-time tools and at run time (see Figure 1).
But what is the difference between these enhance-
ments and a normal change of code? The additional
column, the additional table, and a new button
can enhance an SAP object and still be part of your
package as is shown in Figure 1. And still, at run time,
Adding an additional
details table, which you they appear in the correct position as part of a screen
access by clicking a new that is an SAP standard object. Your enhancements
Show Bookings button
merge into the object they enhance at compile time
Figure 1 p Adding enhancements to an SAP UI table element (see Figure 2). This has one important consequence:
Because this merging is done at compile time,
processing enhancements does not slow down an
application.
The best way to highlight the impressive difference
that enhancements make is to sketch how you would
make the same changes with the classic modification
technology (see Figure 3 on page 52) — specifically,
how do modifications and enhancements fare differ-
ently in an upgrade?
From a technical point of view, a modification is part
of the object it modifies. This explains all of the incon-
veniences that modifications introduce in an upgrade.
A modification is a subtenant in an SAP object, so it
depends on the SAP object far more than enhance-
ments do. Enhancements, on the other hand, are
objects of their own — and they live a life of their own in
Figure 2 p UI enhancements merge into the SAP standard object screen at compile time packages of their own.

Subscribe today. Visit www.SAPinsideronline.com.


In an upgrade, a new SAP object substitutes the make their lives safer in an upgrade. Consider that
old one, and all modifications are lost. Using SAP’s you’ve enhanced an SAP object that will change in
Modification Assistant (the SAP tool that adjusts the upgrade; it will be replaced by a different version,
modifications) you can reinsert the modification as shown in Figure 4.
semiautomatically or manually (depending on the At the bottom left corner of Figure 4 (enclosed by
4 Note! way the changes in the SAP object affect the position the blue dotted line), you see what happens to our
It is never the change of the modification). But unless you adjust every single UI table in an upgrade. The new version of the table,
mode, but always the modification in your system after the upgrade, your where we’re back to one less column, substitutes
new enhancement modifications are gone. You have to touch every sin- the old version . But even though the new object
mode, in which you
gle modification after the upgrade — even though substitutes the SAP standard object, this has no
add enhancements
none of the ojects you have modified may have impact on the enhancements. The upgrade only
to an object.
changed in the upgrade. affects the SAP objects. Customer’s packages are
In contrast, enhancements cause far less work in not touched in an upgrade, so all your enhance-
an upgrade because they reside in packages, which ments will survive the upgrade without you having
to lift a finger ( and ). In the next step, the
enhancements are again merged into the SAP object
at compile time .

Easily Exchange a Global Class Method —


A Step-By-Step Description
As simple as it was to add a new column to the UI
table, that alone will not suffice — to populate the
new column with data, you also need enhancements
in the back end. In particular, you have to adapt the
SELECT statement, which retrieves the necessary
data from the database. To give you the real flavor of
how easy it is create back-end enhancements, let’s
walk through how to enhance the method that gets
the data.
It’s important to understand that you can now not
only enhance but substitute an SAP development
Figure 3 p A major inconvenience of all modifications is that they
object without modifying it. To do this, there is a new
are overwritten in an upgrade
mode for enhancing objects in the ABAP Editor: The
enhancement mode.

. First, you get to the enhancement mode in an anal-


ogous way to how you moved to the change mode
(see Figure 5).

2. Next, create a new container (or use an existing


one) for your enhancements (see Figure 6). I won’t
delve into any details about these containers,
which are called Enhancement Implementations, in
this article; for the most part, they function only as
a useful coating for the enhancements themselves.

As you confirm this dialog window by clicking the


green check mark, you’re ensuring that everything
you now create will be an enhancement — and
Figure 4 p An upgrade only overwrites SAP objects; your enhancements are not therefore will not change, or even touch, the
touched by an upgrade underlying development object.

Subscribe today. Visit www.SAPinsideronline.com.


. After closing the dialog window, you will see the
screen shown in Figure 7.

You are now in the enhancement mode of class


CL_EXAMPLE_CLASS. In the brackets at the top of
Figure 7, you see information about which con-
tainer your enhancements are stored in.

. For a method of a global class, you have three


options for where to attach an enhancement: a
pre-exit, a post-exit, and an overwrite exit. An Figure 5 p Entering the new enhancement mode from within the ABAP Editor
enhancement attached to a pre-exit is processed
before the method, to a post-exit is processed
after the method, and to an overwrite exit replaces
the implementation of the method at run time.

From a functional perspective, we want to select


one more column in our SELECT statement.
Because it is not possible to add an enhancement
Figure 6 p Choosing a container for your enhancement
within a statement, we have to substitute the
whole statement — so here we’ll select the over-
write method in order to substitute the whole
method implementation.

To do this, select Edit → Enhancement Operations


→ Insert Overwrite-Method (see Figure 8).

5. You will then see an additional button in the row (see


Figure 9). This button represents the enhancement
method, which will substitute the original method.
Figure 7 p The enhancement mode of the global class
6. Click the Overwrite-Exit button to navigate to the
ABAP Editor, where you can implement the over-
write exit code.

Then, when the applications calls the method at


run time, the code of the overwrite method will
execute instead of the original code (see Figure 10
on the next page). And that’s it!

By means of the enhancement framework, all of this


happens without the developer having to change the
original class. The framework knows: If an overwrite
exit is implemented, compile the overwrite method
code instead of the original method.
Figure 8 p Selecting the appropriate option for where to attach the enhancement

Where and How to Enhance an Application:


Lessons Learned
So what does this example teach us? I’d like to
emphasize three main points:

 You cannot add an enhancement to a method of a


global class anywhere you want; you can only
implement or add enhancements at positions Figure 9 p The button leading to the implementation of the overwrite exit

Subscribe today. Visit www.SAPinsideronline.com.


where there is an enhancement option, which is
like an exit or a hook for an enhancement (see
sidebar). This is generally true for all types of
enhancements. If there is no option, or no hook,
there is no place for the enhancement to hold on.
At run time, the enhancement option functions as
a jumping off point where the relevant enhance-
ment merges into the code of the enhanced devel-
opment object. And for a method of a global class,
there are only pre, post, and overwrite exits.

 Enhancement options carry information about


Figure 10 p The overwrite method code, not the original code, executes at run time where an enhancement should be processed at

A Detailed Look at Enhancement Options


You can add enhancements not everywhere, but only at so-called  The end of a private, protected, or public section of a
enhancement options. So for customers, it is important to know local class
which options the system provides and which have to be explic-  The end of a report and include
itly inserted by an SAP developer. In fact, the framework pro- The new Web Dynpro ABAP UI technology offers nearly any
vides lots of different enhancement options. enhancement option you could dream of. Concerning the UI
elements, the enhancement mode offers you almost the same
Implicit Enhancement Options
level of freedom as the change mode. This means you can add any
The enhancement framework provides many different implicit
UI element you want, but you cannot change UI elements. And you
enhancement options, including options for:
can add the relevant enhancements you need to wire up new UI
 Additional types, attributes, and methods of global classes
elements you may have added — new plug-ins, new methods, or
 Pre, post, and overwrite methods of global classes pre and post methods of existing classes, to name a few. You can
 Optional parameters for methods of global classes and even hide existing UI elements.
function modules
The framework’s source code plug-in technology also Explicit Enhancement Options
provides default positions where you can add source code to Explicit enhancement options (which the developer has to pro-
existing source code units. For example, you can add source code vide) comprise enhancement points, enhancement sections, and
plug-ins at: the new kernel-based Business Add-In (BAdI):

 The beginning or end of a method (both of global and local  Enhancement points allow you to insert source code plug-ins.
classes), function module, or form routine These are additional code lines that, if they exist, are executed
additionally (see Figure 11).
 The end of a local structure
 Enhancement sections behave the same way, the only difference
being that the source code plug-in replaces the section in the
original code. So an enhancement section is a section that is
flagged for possible substitution.
 The new kernel-based BAdI is now integrated into the enhance-
ment framework. BAdIs are hooks for object plug-ins. A BAdI
definition provides an interface with methods. You enhance a
BAdI by providing a class that implements the BAdI interface. If
you call BAdI methods, you can (among other things) specify
which method implementations are to be carried out on the
basis of filter values. In other words, a BAdI method call is like
Figure 11 p An enhancement’s code is processed in the middle of a dynamic method call with a specified interface, where it’s
an SAP object, even though the enhancement belongs to the not determined until run time which method implementations
customer namespace are to take place.

Subscribe today. Visit www.SAPinsideronline.com.


run time. If an option gets lost or is changed in an for developers. In contrast to modifications, which
upgrade, the system might no longer know where are part of the object they modify and are lost in
to place the enhancement. To support you in this an upgrade, enhancements are never overwritten
situation, the transaction SPAU_ENH shows you in an upgrade because they live in the customer
which enhancements you have to adjust after an namespace.
upgrade, which support packages to install, or To implement enhancements, developers have to
which transports to import. assign them to enhancement options, which carry
information about where the enhancement should
 The kind of enhancement you want to attach must
be processed at run time. The framework provides
fit the enhancement option. For example, you can
many different implicit enhancement options, but
only attach an overwrite method to an overwrite
exit, or new methods to an enhancement option developers can also add explicit enhancement
for new methods. In other words, you can attach options. In the rare case that an enhancement option
different kinds of objects on different kinds of hooks. is affected by an upgrade, a new support package, or
an import, a new transaction (SPAU_ENH) will alert
In contrast to modifica-
Enhancement Options: Implicit and Explicit you so that you can then insert the untouched
tions, which are part
Global and local classes, function modules, reports, enhancements somewhere else.
of the object they
includes, and Web Dynpro ABAP views offer a lot of Modification-free enhancements are one important modify and are lost
different enhancement options without anyone having use case of the switch and enhancement framework. in an upgrade,
to do additional work. They are much like default Look for future Under Development columns that will enhancements are
exits, which the framework automatically provides in cover how the framework empowers the reintegration never overwritten in
the respective development unit. This means, for of SAP industry solutions in the SAP ERP core, the an upgrade because

example, that whenever you have a method of a new enhancement package strategy of SAP ERP 6.0, they live in the
customer namespace.
global class, the framework automatically provides and the benefits of each. With an understanding of
pre, post, and overwrite exits. This is why they are these additional use cases, you will gain an even
called implicit enhancement options. deeper understanding of the power of the framework
In addition to implicit enhancement options, which and its benefits for developers. n
the framework supplies, there are also explicit
enhancement options, which have to be clearly
defined by an SAP application developer, for example, AdditionalResources...
who anticipates that a customer might want to select
more columns from the database than the original
...from
program does. Here, the developer could insert an
 “Introducing the Enhancement Framework
explicit enhancement option. This way, another devel-
— a new way to enhance SAP programs without
oper could implement this enhancement option with-
having to modify them” by Thomas Weiss
out changing the original development unit.
and Michael Acker (SAP Professional Journal ,
An interesting note: While implementing an
January/February 2008, www.SAPpro.com)
enhancement option is not a modification for a cus-
tomer, inserting an explicit enhancement option into  “Introducing the switch and enhancement
the original SAP program does modify the program. framework — consolidating industry
For modification-free adaptations of SAP objects, cus- solutions with the mySAP ERP core” by
tomers depend on the existing enhancement options. Karl Kessler (SAP Professional Journal ,
If you need to add some code at a position where there March/April 2006, www.SAPpro.com)
is no enhancement option, you still have to modify the  “A New and Improved Approach to SAP
object. (This is why I earlier referred to enhancements Industry Solutions — How the Switch and
as being almost as flexible as modifications.) Enhancement Framework Now Consolidates
SAP Industry Solutions with the ERP Core,”
Conclusion an Under Development column by Karl
SAP’s new enhancement framework makes customer Kessler (SAP Insider, July-September 2005,
adaptations of SAP objects far more robust in an www.SAPinsideronline.com)
upgrade — and creates far less post-upgrade work

Subscribe today. Visit www.SAPinsideronline.com.

Das könnte Ihnen auch gefallen