You are on page 1of 7

This article appeared in the Jan Feb Mar 2006 issue of SAP Insider and appears here with

■ ■

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

Web Dynpro — Not Just Regular Feature


for Java Developers Under
Anymore Development

One of the standout features of SAP SAP NetWeaver Developer Studio


NetWeaver is its support for open tech- based on the powerful, open-source
nology and user interfaces that are tooling platform Eclipse. The resulting
browser-based, model-driven, device- customer projects typically target SAP
independent, and accessible — in short, NetWeaver Application Server Java as
everything today’s Web applications the runtime environment.
require. SAP NetWeaver’s UI technology,
But what if your team has strong
Web Dynpro, is a first-class approach
ABAP skills and a background in BSP
to building application content designed
programming? Or perhaps the backend
to run in SAP NetWeaver Portal.
And because Web Dynpro is language-
services you would like to address are Karl Kessler, SAP AG
not fully exposed as the Web services or
independent by design, it’s not just for
remote function modules required for
Java developers. Those application devel-
Java model binding? Or what if, from a
opers who are fluent in ABAP and have
performance point of view, you cannot the same metamodel as its cousin Web
mastered Web enablement through BSPs
afford a decoupling of UI logic executed Dynpro Java, and their views, models, and
will now be able to build Web Dynpro
on the server and the underlying business controllers share the same semantics —
applications in a familiar development
logic? What if you already have working so there is no need for developers to
environment with substantial support for
ABAP software maintenance in place learn a new UI paradigm. The main
efficient, reliable development that they
but cannot quickly set up a development differences between Web Dynpro Java
can reuse and — best of all — that
infrastructure for Java? In all these and ABAP are simple ones designed to
requires minimal coding.
cases, Web Dynpro ABAP can help. make it easy for developers to transition
between traditional ABAP projects and
Some Background on Web Dynpro applications:
Web Dynpro This article takes you on a quick tour ■
The Web Dynpro ABAP design-time
From the very beginning, the Web through the tools of Web Dynpro ABAP
environment is embedded directly in the
Dynpro metamodel was designed in a and walks you through a simple flight
ABAP Workbench. (For a look at how
programming-language-neutral way. Web report example to highlight new and
the tools are similar in functionality, see
Dynpro uses the model-view-controller updated tools in the familiar ABAP
the sidebar at bottom of next page.)
(MVC) approach to Web interface environment.
Web Dynpro artifacts (components,
development (see sidebar at top of next
views, models, etc.) are listed just like
page), so that a Web Dynpro component
any other of your ABAP-based projects
and all its pieces have the same seman- Web Dynpro ABAP is part of
and BSP applications. ABAP developers
tics whether they are written in ABAP SAP NetWeaver 2004s, which is the
can access all projects in the same
or Java. The very first version of the Web foundation for the shipment of the
way and in a familiar environment.
Dynpro development environment to be mySAP Business Suite, most promi-
delivered was for Java-based projects. nently mySAP ERP 2005. As its name ■
ABAP developers won’t find
It included strong tool support from suggests, Web Dynpro ABAP uses exactly any surprises in the development

Subscribe today. Visit www.SAPinsider.com.


A Brief Guide to Web Dynpro Terminology for ABAP Developers
Web Dynpro strictly follows the model-view-controller (MVC) Some other Web Dynpro terms include:
paradigm, meaning that any application you design with Web ■
Context — The context is technically a hierarchy of vari-
Dynpro cleanly separates the layout and the interaction code
ables related to the user interface. ABAP developers can
from the business data.* In this widespread UI-development
think of the context as being similar to the field list,
paradigm, the component consists of three basic parts:
while the dynpro fields are similar to the view. The field

Model — The model indicates the business data to be transport then automatically copies the values from the
manipulated and corresponds to the global data and program to the user interface and vice versa. Likewise,
tables of the module pool. variables of the Web Dynpro context are copied back and
forth to corresponding Web Dynpro view fields.

View — The layout information is all held in the view,
which corresponds roughly to fields and subscreens in the ■
Service controller — A service controller is a controller
traditional dynpro model. that encapsulates a service call. In the example we walk
through in this article, this is a simple BAPI call.

Controller — The controller manages the interaction of
the interface. This corresponds to the flow logic in the ■
Component — A component is a modular unit with
classical dynpro model. various interfaces (both programmatic and UI-oriented).
* For an overview of MVC, see my article in the April-June 2003 issue of SAP Insider, as well as the article by Dr. Peter Tillert in the October-December 2003 issue, entitled
“How to Streamline User Interfaces: Web Dynpro Makes Software Reuse a Reality” (www.SAPinsider.com).

infrastructure, either. The correction


and transport system keeps track of
all changes, versions them, and helps
propagate the Web Dynpro application
from development to production —
just as you would do with any BSP
or dynpro-based applications.


The execution platform is the ABAP
server, rather than the Java server.
This ABAP server produces applica-
tion content ready to be seamlessly
integrated into the SAP NetWeaver
Portal. Features like portal eventing Figure 1 The Final Flight Search Interface, Automatically Generated and
can be used between applications Viewed in the Browser
written in ABAP and in Java or
generated by Visual Composer.

The story of Web Dynpro ABAP


Similar Functions, Different Tools
sounds simple: it’s easy and efficient Here is a quick look at the tools used for various designing tasks with dynpro
to create a modern Web UI with very and their corresponding tools when using the Web Dynpro model.
little coding and in a familiar ABAP Tool Aspect Dynpro Web Dynpro
development environment. As with Web
Layout Screen Painter View Designer
Dynpro for Java, however, while creating
Field List Editor Context Editor
the UI is simple, the Web Dynpro tools
within the ABAP Workbench are highly Outline of Object Browser Web Dynpro Explorer
sophisticated. This article takes you on program/component
a quick tour through the tools to show- Event code ABAP Editor ABAP Editor
case their capabilities, walking through
Navigation Implicit in code Navigation Modeler
a simple flight report example that
touches all major editors (see the result Data flow Implicit in code Data Modeler
in Figure 1). We created this same

Subscribe today. Visit www.SAPinsider.com.


interface with Web Dynpro Java in a New Workbench Tools for Web ■
Web Dynpro Wizard
previous column.1 As with Web Dynpro Dynpro ABAP
Java, you might be surprised by how

New updates to editing code in the
This article will introduce new or
little coding is required. ABAP Workbench
updated tools that SAP has added to the
1
See “Under Development: Your ‘Easy Way In’ to Web familiar ABAP environment, including: Let’s jump directly into our example,
Dynpro Development: New Design-Time Tools Now beginning with the ABAP Development
Available with SAP Web Application Server 6.30” in ■
Web Dynpro Explorer
the April-June 2003 issue of SAP Insider
Workbench (transaction SE80). In
(www.SAPinsider.com). ■
Web Dynpro Designer Figure 2, you can see that the dropdown
box now includes a new category for
Web Dynpro Component/Interfaces.
Here’s where our work starts.

The Web Dynpro Component


You can think of a Web Dynpro component
as a modular unit with various interfaces
(both programmatic and UI-oriented).
To start the process, name your new
component (z_bapiflight in our example).
Once you enter this component name, a
dialog pops up to actually begin creating
the Web Dynpro component in the Web
Dynpro Explorer. Here, you’ll be asked to
fill in the typical correction and trans-
port information. In our result, shown
in Figure 3, the outline of the newly
created Web Dynpro component is on
Figure 2 Launching the ABAP Development Workbench in the left and some dependency informa-
SAP NetWeaver 2004s tion is on the right.

One of the outstanding features of


the Web Dynpro model is its ability to
have data attached on various levels
(e.g., the view and the controller). This
is much like the classic dynpro, which
had a similar feature based on field lists
and dynpro fields; a field transport then
automatically copied the values from
the program to the UI and vice versa.

Web Dynpro follows this tradition,


but in a much more fine-grained way.
This is the context, which is technically
a hierarchy of variables related to parts
of the user interface. You can attach a
context to a view on the view level and
to a component on the component level,
which is not necessarily visualized. Once
you have defined the contexts at the
various levels, you can then graphically
map context nodes in the Context Editor
and the information flows automatically
Figure 3 Viewing the Newly Created Web Dynpro Component
— you will see this in our example.

Subscribe today. Visit www.SAPinsider.com.


Web Dynpro View and Designer
A view contains all visual controls, such
Web Dynpro
as buttons, labels, and fields. From the Designer
outline menu, we create a new view,
which can be edited in the Web Dynpro
Designer (see Figure 4). The Web
Dynpro Designer is a WYSIWYG tool
that immediately renders what you have
changed so far. On the left you see a rich
palette of graphical controls at your
disposal, grouped by category. You simply
Control
drag and drop controls into your layout. Palette
On the upper right, the control is incre-
mentally built, and below you find the
usual list of properties for that control.

Web Dynpro Wizard


Now that the view is complete, we need
to manage how these controls function —
Figure 4 A View of the Web Dynpro Designer
in this case, we’ll focus on a key control
in our interface, the “Search Flights”
button (the Get List function). At the
controller level, we could start to main-
tain the layout manually, but there is a
much faster method: the Web Dynpro
Wizard. This wizard helps you derive a lot
of properties for input fields and output
fields automatically. Launch the wizard
from the context menu of the Web Dynpro
Explorer and a dialog pops up asking
you for the specification of a service
controller. In our example, this is a simple
BAPI call, but it could be a simple func-
tion module or a Web service call as well.

The wizard guides you through a


series of steps (see Figure 5) where you
Figure 5 The Web Dynpro Wizard for Generating the Service Call
first select a controller that should
contain the service call (I simply used
the component controller), then you serve as search criteria, and the Dynpro runtime will transport the search
specify a service type (function module), FLIGHT_LIST as the result table. fields (in our example, DESTINATION_
then the name of the function module FROM and DESTINATION_TO) from
or BAPI to be called, and finally the the view to the BAPI call, execute the
parameters of the BAPI that should be
Defining the Graphical Layout
BAPI, and place the result table back in
reflected in the context.
of the Interface
the view context again so that the Web
Now that we have created the context
Dynpro rendering can produce the
The final result of the wizard is the for the service call, let’s quickly specify
output page in the browser.
context for the service call triggered by the graphical layout of our application
the Get List button, as shown in Figure 6. (see Figure 7), including mapping the Once you’ve defined the mapping,
The context hierarchy on the right side controller to the view. In Figure 7, you you can derive a container form that
contains the DESTINATION_FROM and see how the controller context and the renders all the fields plus their labels
DESTINATION_TO fields, which will view context are mapped. The Web derived from the BAPI definition simply

Subscribe today. Visit www.SAPinsider.com.


keep manual coding to a minimum. So
instead, we’ll focus here on the last step,
where we add a table to the layout and
specify its binding. The result is shown
in Figure 8 on the next page.

Launch the Application


We’re almost done. What is missing is
the proper embedding of the view in the
component’s window (see Figure 9)
and the creation of a starting point
for the application. Once you test your
application, data flows from the input
fields to the BAPI call, and the results
of the BAPI call are immediately and
automatically sent back to the table
control, which is finally rendered in the
Figure 6 The Controller Context for the Service Call Invoked by the Search
browser, as shown back in Figure 1.
Flights Button, Generated from the Web Dynpro Wizard
This step completes our quick tour.
Although the application was a simple
example, it touched on the important
areas of the Web Dynpro tools set inside
the ABAP Workbench.

More Advanced Features of


Web Dynpro ABAP
Web Dynpro has much more to offer
than simple input/output handling. Maybe
you saw the rich palette of controls in
the view layer back in Figure 4. Besides
offering nice features such as predefined
business graphics and embedded Microsoft
Office applications, Web Dynpro hosts a
complete form design environment based
on Adobe Designer. Here you can define
interactive forms that exchange contex-
tual data with Web Dynpro controls as
if they were properly built in. During
runtime the Adobe formula is then
Figure 7 Mapping the Controller and View Contexts processed in the Web Dynpro context.
Features like context mapping are
by selecting a context node for DESTI- that make it worthy of its own “Under applicable here as well.
NATION_FROM and selecting the Development” column (see sidebar on
Other features also ease development
relevant fields. next page).
and make for richer interfaces. For
To launch the BAPI from the user But, as I mentioned above, Web example, you can take advantage of
interface, we need to add a button, Dynpro is not the place to dive into personalization features that allow an
associate an action with the button, code. Of course, you probably won’t end user to customize the order of
and place the BAPI call inside. The get away with no coding, but the Web columns that are displayed — and hide
code is then presented in the brand-new Dynpro development environment is columns that are not needed — in a
ABAP Editor, which is full of features designed to capitalize on reuse and large table. In addition, portal integration

Subscribe today. Visit www.SAPinsider.com.


(e.g., portal eventing), definition and
reuse of Web Dynpro components, and the
Web Dynpro ALV, which has similar
capabilities as its counterpart in the
ABAP controls world,2 are also now
available with Web Dynpro ABAP.
For more information, please visit
www.sdn.sap.com  Web Application
Server  ABAP to view tutorials about
Web Dynpro ABAP’s additional features.

Summary
Web Dynpro ABAP is a strong model-
driven tooling environment based on
the classical ABAP infrastructure. The
focus of Web Dynpro ABAP is not just
on getting interfaces ready for use as
iViews or for browser-based access.
2
Beyond the Web Dynpro controls layer, Web Dynpro Figure 8 The Final Layout of the Flight List Interface with Table Binding and
ALV offers a lot of prebuilt functions for filtering, Object Properties
sorting, and totaling similar to the classic ALV.

The New ABAP Editor with Web Dynpro ABAP


A complete discussion of the new ABAP
Editor is certainly beyond the scope of
this article, but here is a list of some of
its more outstanding features:

Coloring and highlighting that reflects
the ABAP syntax.

Source code compression that allows
you to fold and unfold a syntactical
structure, such as method…endmethod.
For example, you can expand or
collapse a “while loop” so you can
hide the code inside the loop.

Macros, which mean less typing for
developers. For example, you can
generate “if-then-else” constructs to
save development time and effort.

Code snippets, which allow developers New ABAP Editor
to cut and later paste some lines of
code. For example, you can reuse a
A future “Under Development” column will cover the
sort function later on that you don’t currently need.
ABAP Editor in more detail. For more on the new ABAP

A lot of personalization extras, including color assign- Editor, please see www.sdn.sap.com  Web Application
ments, indentation rules, etc. Server  ABAP.

Subscribe today. Visit www.SAPinsider.com.


It’s also on making it easier for devel- that can integrate with and run in and making better use of the applica-
opers to create these interfaces, whether SAP NetWeaver Portal. tions you’ve already built: coding is
it’s functionally, with a familiar develop- reduced to a minimum in Web Dynpro
ment environment, or technically, The best news of all for ABAP devel- applications, and reuse is a key part of
with final Web application interfaces opers is that you’ll be typing in less code the Web Dynpro strategy.
If you currently develop applica-
tions based on BSP, you should look at
whether Web Dynpro offers additional
choices and more abstraction than
low-level HTML code.
For more information, please
visit www.sdn.sap.com  Web
Application Server  ABAP or
help.sap.com (and search for Web
Dynpro ABAP).

Karl Kessler joined SAP in 1992. He is the


Product Manager of the SAP NetWeaver
foundation, which includes SAP NetWeaver
Application Server, Web Dynpro, ABAP
Workbench, and SAP NetWeaver
Developer Studio, and is responsible for
all rollout activities. You can reach him
Figure 9 Web Dynpro Builder via email at karl.kessler@sap.com.

Subscribe today. Visit www.SAPinsider.com.

You might also like