SAP’s Web Application Server Release 6.10 offers a programming model pow
that supports both classical and web development. The new web-based development
model is based on Business Server Pages and provides XML-related functionality,
such as an integrated XSLT processor, to name just two of the most prominent
examples of Release 6.10’s support for web programming — both
of which are built on ABAP Objects technology.
Of course, ABAP Objects itself is not new
— it’s a proven development platform for any kind of business
programming (after all, method invocation in ABAP is now faster than calling
a function module!). But with 6.10, ABAP Objects has added advanced object-oriented
techniques, including broader support for exception handling, Object Services
for persistent classes, and friend classes.1 And the tools in 6.10 have
been enhanced right along with them!
This article highlights the updates to
the Class Builder, Object Navigator, and ABAP Debugger that developers
will most appreciate, whether your projects involve classical or web development.
These features will enhance your daily development work when accessing
development objects of any kind, support the techniques now available,
and make it extremely easy to define your business logic in a clean, object-oriented
A Revised Class Builder Designed to Handle Advanced
The ABAP language environment in Release 6.10 introduced advanced techniques
in ABAP Objects such as friend classes, exception handling, and object
services for transparent object persistence, and the Class Builder has
Easy Designation of Friend Classes
The ABAP 6.10 language now supports friend classes, which allows
classes to access private and protected members. This is also reflected
in the Class Builder, where you simply enumerate friend classes under
the “Friends” tab, shown in Figure 1. A special keyword
syntax is provided for local classes.
||Designating Friendship in the Class Builder
Whenever the concept of friend classes
comes up, be cautious. The flexibility it gives you also poses
some risks. The higher your friend classes show up in the inheritance
hierarchy, the more classes can see your implementation details
as all subclasses will automatically become friends. A similar
rule holds for friend interfaces where all implementing classes
Powerful Support for Exception Classes
ABAP 6.10 now supports exception-handling in an object-oriented way.
The first step is to encapsulate “exceptional” programmatic
situations — such as “arithmetic error” or “object
not found” — as exception classes, which are defined
by either the system or the programmer. Exception classes have only attributes
and a constructor, but no other methods. Typical exception attributes
include an exception ID and, often, the cause of the exception.
Because exceptions can be caught on various
levels of abstraction — from very specific application errors to
very generic exceptions (e.g., simply catching exceptions of type CX_ROOT)
— the hierarchy of exception classes helps the developer to take
full advantage of the object-oriented programming discipline. A second
advantage of exception classes is that all catchable runtime errors, such
as zero division and convert_no_number errors, are present in the exception
hierarchy as predefined system exception classes. Hence, there is no need
to use the older exception concepts (although they are still supported
for compatibility reasons).
The exception-handling features available
in ABAP Objects are now supported by the Class Builder in two specific
- Exception classes follow very specific naming conventions2 and are
derived from CX_ROOT, which is the base class of all exception classes.
The Class Builder checks all naming conventions and ensures the inheritance
relationship, see Figure 2.
- When you develop a new exception class, you can define texts associated
with exceptions that can occur. The texts are maintained in the online
text repository and allow for attribute substitution. The Class Builder
creates default exceptions that are passed automatically if constructor
parameters are missing.
||Exception Class Hierarchy
Object Services and Mapping for Persistence
While exceptions and friends focus on transient objects, Object Services
provide Persistence Services for persistent classes. Persistent
classes can be maintained in the new Class Builder very much like ordinary
classes. They have attributes and methods, raise events and exceptions,
and can even implement interfaces. Most important, they provide some means
to persist an object’s state to the database, which allows other
transactions to get these objects later, after program termination, and
continue processing. Persistent classes enable you to develop in purely
object-oriented terms, without burdening you with coding SQL statements
for database access to the persistent objects.
When creating a persistent class, you must
define a mapping to an underlying database table. The Class Builder’s
new Mapping Assistant (see Figure 3) asks you first for
the database table to map to your persistent class (multi-table mapping
is also supported). In this case, table SFLIGHT has been mapped to the
persistent class ZCL_FLIGHT. During the mapping procedure, you select
key and value columns from the database table and associate them with
attributes of your persistent class. You must map only the attributes
you wish to persist.
||Mapping Assistant Available in the Class Builder
The class actor is a companion class
of your persistent class. It handles all the select and update functionality
related to your persistent objects, and offers methods for object creation
and deletion. During activation of your persistent class, the class actor,
together with SET/GET methods for each mapped attribute, are automatically
The full potential of Object Services becomes
apparent once you take into account that mapping is not limited to standard
tables with a business key, such as company code; you can also develop
complete object networks whose persistent objects point to each other
via GUIDs. If you get such a networked object from the database, references
to other persistent objects are handled in a “lazy” manner,
meaning that referred objects are only loaded on demand into the transient
To summarize, Object Services help to offer
a pure object-oriented view of existing tables or to set up new persistent
object networks. The Class Builder serves both as a mapping tool and a
generator for class actors in this respect.
Other Nice Touches in the 6.10 Class Builder
A couple of smaller yet helpful features assist you with the maintenance
of object-oriented ABAP code.
First, directly from the Class Builder,
you can now change a class via context menus, without actually running
SE24 in the tool frame. The new user interface makes it easy to
add attributes and method signatures directly, and maintenance of
the method signature can be carried out without leaving the method
Additional new functional updates
- Support for versioning classes in the development repository
for all major pieces of a class, such as its PUBLIC, PROTECTED,
and PRIVATE sections, and the ability to compare and restore versions.
- Support for modifications just like those in functional ABAP
code. For example, modifications like INSERT or REPLACE are marked
with pseudo comments (“custom code modification”) in
the source code, as shown in the figure below.
- Enhanced printing of classes.
|Modification Assistant in the
Rearrange Complex Class Hierarchies with the Refactoring
The Refactoring Assistant is a real power-user tool for those
of you who deal with larger class hierarchies and who notice, during your
development project, that your initial class hierarchy design no longer
represents your problem domain in an optimal way. Changing a class hierarchy
manually later in development is really cumbersome and error-prone, since
so many dependent relations can exist between classes. Good support for
refactoring alleviates these problems and, in fact, is now included in
the most recent releases of popular Java environments.
From the Class Builder, when changing a
class, you can now invoke the Refactoring Assistant (F7) to display a
tree that represents the class hierarchy containing your class. You can
now modify your initial design by simply dragging and dropping items from
one hierarchy or class component level to another.
The Refactoring Assistant (shown in Figure
4) confirms that two methods have been moved to the CL_ITEM_TREE_CONTROL
The Refactoring Assistant allows you to:
- Move class components to superclasses, subclasses, interfaces, and
- Move interfaces to superclasses or subclasses
- Move interface components to the component interface or to classes
- Split classes or interfaces
The Refactoring Assistant only makes changes
to the class hierarchy. It leaves all users of your classes unchanged.
Where-used lists can then more accurately point you to the program codes
that access your classes, since they are now based on the ABAP syntax
check, rather than a source scan.
||The Refactoring Assistant
New Object Navigator Features Help Speed Up Development
Everyone in the ABAP development community should be familiar with the
important features that have been added to the Object Navigator.
First, with the updated Object Navigator,
several browsers can be opened in parallel (see Figure 5). This
is especially helpful for web development where you often work with various
tools simultaneously. Switching is fast and easy. The Workbench Organizer
(transaction SE09) has been added as a new type of browser, allowing you
to inspect your development tasks and requests without leaving the Workbench.
You can invoke all Organizer-related functionality through the context
menu and can customize the browsers in your own personal Workbench settings.
||Support for Multiple Browsers from the Object Navigator
Second, object lists are now expanded by
default. If, for example, you are browsing through a package (the new
term for a development class with additional semantics)4
and drill down to the classes contained therein, the classes themselves
display automatically (as in Figure 6), unless you request their
object list to be displayed instead.
||Display of Classes in the Object Navigator
Finally, the ABAP Editor now fully supports
source code with 255 characters per line (check your Workbench settings,
however, since the default is still 72 characters). ABAP developers will
welcome this, especially when working with long ABAP Objects identifiers.
ABAP Debugger Enhancements Reflect Updates to ABAP
The ABAP Debugger has also been enhanced to be in synch with the new
ABAP Objects features, so now it can:
- Set breakpoints at the class and method invocation level, which allows
you to trace object creation as well.
- Display exception objects and navigate to the point where the exception
was raised. This is an important feature, since an exception can occur
deeply inside, even when the corresponding handler catches the exception
on a very high level.
- Differentiate between breakpoints for “normal” code and
code that is processed when a Business Server Page is being requested
by a browser.
- Skip code for execution. While this feature is not specific to ABAP
Objects, it can be helpful in development (although forbidden in production).
A skip of code is secured by suitable authorization checks and is documented
in the system log.
For More on New Tools and Updates for Developers
New features in tools like the Class Builder, the ABAP Debugger, and
the Object Navigator now make it extremely easy to take full advantage
of the advances in ABAP Objects. For more information on the changes to
ABAP Objects in 6.10, and related tool updates, see the documentation
available at http://help.sap.com
and general technical information at www.sap.com/technology.
For specifics on recent changes to ABAP
Objects, see the articles available at www.SAPinsider.com,
including “ABAP 6.10: New Unicode-Enabling Features, Plus a Whole
Lot More!” in the July-September 2001 archives, and “A Preview
of Component Technology in R/3 Enterprise” in the January-March 2002
More detailed information on Object Services
and persistent classes is also available in the article “Write Smarter
ABAP Programs with Less Effort: Manage Persistent Objects and Transactions
with Object Services” in the January/February 2002 issue of SAP
Professional Journal (www.SAPpro.com).
brief coverage of the friends concept and
an introduction to ABAP’s
new exception-handling features, see the article I co-wrote with Andreas
Blumenthal, “ABAP 6.10: New Unicode-Enabling Features, Plus a Whole
Lot More!” in the July-September 2001
issue of SAP Insider
and online at the Article Archives.
2 All exception classes start with CX_ (or ZCX_
for customer-defined exception classes).
Column updates must be done with the generated SET/GET methods. It is
worth noting that updates are not carried out until a COMMIT WORK is issued
and the update task is triggered.
more on packages, see my article “A Preview of Component Technology
in R/3 Enterprise” in the January-March
2002 issue of SAP Insider
and online at the Article Archives.
Karl Kessler studied Computer Science at the Technical University
of Munich, Germany. He joined SAP AG in 1992 as a member of the Basis
modeling group, where he gained experience with SAP's Basis technology.
In 1994, he joined the product management group of the ABAP Development
Workbench. Since 1997, Karl has been Product Manager for SAP's business
programming languages and frameworks, and is responsible for all rollout
activities. He can be reached at firstname.lastname@example.org.