Performance of Webdynpro ABAP Developement
About Me:
Kishorekumar SVS is a senior development SAP consultant. He has worked on numerous projects and gained practical experience in ABAP, Webdynpro ABAP and Floor Plan Manager (FPM). Kishorekumar is very interested in new technologies. Currently he is dealing with Web Dynpro ABAP,Floorplan manager, BADI’s and the Switch and Enhancement Framework.
This tutorial describes about the performance of webdynpro abap developement and while webdynpro development which are the point should follow every webdynpro consultant.
Performance of ABAP Webdynpro:
Dos and Don’ts in ABAP Webdynpro
Performance check
Performance tools
Look and Feel (Themes)
Running webdynpro applications via SAP GUI
High Performance
Dos and Don’ts in ABAP Webdynpro:
Checklist of do’s and don’ts
Where to Store business logic?
How to simplify context reading / writing?
Use structure Vs. fields
Handle dropdown by key
Delete unwanted components
Use supply function
Automatic refresh
Accessibility
Checklist of do’s and don’ts:
Dos and Dont’s: Web Dynpro Components
Dos and Dont’s: Web Dynpro Context
Dos and Dont’s: Web Dynpro UI elements
Dos and Dont’s: Web Dynpro Components:
Do not write your entire application source code in Web Dynpro components. For more information, see: Number,
Size, and Genericness of Components.
Write your application source code in ABAP OO classes. For example, use the assistance class.
Use Webdynpro components only for managing the views and context. Note that Web Dynpro components are
not lightweights!.
Do not create a Web Dynpro component for one single view only.
In a Web Dynpro component, group together as many views that belong to one application part as possible. If,
however, the ABAP workload is too large, split the component up.
Dos and Dont’s: Web Dynpro Components:
Delete all Web Dynpro component instances as soon as they are no longer needed. To do that, use
IF_WD_COMPONENT_USAGE=>DELETE_COMPONENT.
Use dynamic navigation or dynamic component usages only if it is absolutely necessary.
Set the lifetime of a view to when visible, if the view is displayed only once in an application.
As far as possible always set the lifetime to when visible.
Note: Although memory consumption is reduced by the lifespan of when visible, when visible can affect performance
since in this case the view has to be initialized every time it is displayed. See also Creating and Deleting Components and
Views.
Dos and Dont’s: Web Dynpro Context:
Do not put all your data into the context.
Do not create a mega context for all data belonging to one application.
Put only the data required for the UI element binding into the context.
Use the assistance class or other ABAP OO classes for the data exchange.
If required create local contexts, for example, in views.
Do not create deep-nested contexts.
Use singleton nodes, if nesting’s (master detail) are necessary.
Do not use dynamic attributes (IF_WD_CONTEXT_NODE_INFO->ADD_ATTRIBUTE)
Use data with context structure for BIND_TABLE.
Update the context only if the data actually has to be updated.
Do not create long context mapping chains.
Dos and Dont’s: Web Dynpro UI elements:
Do not use container scrolling (scrollingMode<>none)
Do not use the scrolling function of the browser window.
Note the following exception: If the application screen is to be used fordisplay only and not for user input,
as an exception you can use browser scrolling to avoid unnecessary server roundtrips.
Create application screen that fit into a typical browser window.
Use the scrolling features of Table, MultiPane, and RowRepeater.
Avoid deep nesting’s of Containers, Groups, and TabStrips.
Note: server and client performance is strongly affected by nesting’s.It may also occur that deeply nested contents are not shown on the front end as a result of browser restrictions which cannot be influenced by the Webdynpro framework.
Do not insert any TransparentContainer UI elements into ContainerUI elements, for example, Groups.
Dos and Dont’s: Web Dynpro UI elements :
To minimize nesting depths, if possible, swap the RootUIElementContainer UI element (TransparentContainer) with
other Container UI elements, such as Table, TabStrip, and Group.
See also Root Elements of Views.
It is best to arrange logically nested contents into rows
As far as possbile, do not use the UI element tree
To display tree structures use a Table with either TreeByKeyTableColumn or TreeByNestingTableColumn.
Do not use dynamic UI element programming and/or multiple components for repeating layouts.
Use RowRepeater or MultiPane for repeating layouts.
Modify your UI elements only if they really have to be changed.
If possible, use delta rendering
Note that there are special Performance Aspects when using the InteractiveForm UI element.
Where to Store business logic?
As beginners we do coding inside the respective controllers. We should be aware that it is wrong practice of coding .
Webdynpro framework is based on MVC (Model View Controller) architecture.
Model is the area to store the business logic which indicates separation of business logic and user view.
Assistance class represents the best example for model. We can put our business logic inside the assistance class and by attaching the assistance class , we can access those methods.
One more advantage would be reusability .
we could implement the assistance class and deploy methods through assistance class.
How to simplify context reading / writing?:
About 60% or more of software costs is maintenance. The more code lines we have, the more maintenance
costs are. Henceforth we need to reduce the lines of coding.
Mostly developers ignores the above fact by following standard way of generating code through code wizard.
In real time applications, we need to build multiple views and each view has to read ‘n’ number of context and nodes
Rather using 14 lines of code to read the context and nodes, we can achieve the same in 2 lines of code as given below.
method get_data.
data: ls_vbrk type wd_this-> element_vbrk.
wd_this->o_context_element->get_attributes( exporting path = ‘VBRK’ importing values = ls_vbrk ).
endmethod.
This is achieved by integrating a helper class and using it to read the context.
We need to initialize the helper class in WDDOINIT method as given below.
method wdinit.
create object o_context_element exporting context = wd_context.
endmethod.
Handle dropdown by key:
Experts advice not to use drop down by key. In unavoidable scenarios, we can handle the dropdown by key through optimization.
WD4A engines fills automatically the dropdown by key fields whose domain values are directly associated.
If domain values are not directly associated with the field, then WD4A does not fill dropdown by key field values automatically.
We have to call set_attribute_value_set of if_wd_context_node_info what we find by calling get_node_info.
We can further optimize the code by using helper class as given below
Delete unwanted components:
Delete the webdynpro components which are no longer required.
IF_wd_component_usage=>delete_component.
Unwanted nodes can be deactivated by using <node_name>->invalidate().
Use Supply Functions:
Whenever we need to populate dropdowns, radio buttons or checkboxes it’s better to use supply functions
to populate there nodes.
In that way whenever the node is invoked it will automatically call the supply function and populate the
node and intern populates our UI elements.
Automatic refresh:
You may have an application where you want to automatically refresh the data selection periodically,
without intervention from the user.
This can be achieved using a TimedTrigger UI element:
http://help.sap.com/saphelp_nw04s/helpdata/en/da/a6884121a41c09e10000000a155106/content.htm
Accessibility of a Web Dynpro Application:
To make a business application available to those users who are dependent on technical support of various kinds due to
disability, the Web Dynpro framework provides them with the option of setting up accessible applications.
Almost all UI elements additionally provide the property accessibilityDescription. This can be used to include a
title, as an alternative, whenever the UI element should not or cannot carry a visible title (Header). In contrast to the case with
the tooltip, which should contain a semantic description of the purpose of the UI element, only a short, title-like expression is
entered in the accessibilityDescription.
Displaying Accessibility Texts for Testing:
To test an application in accessibility mode, you can either set a screen reader or wait for the tooltip to display. For
quick testing you can also display the accessible text in a box at the bottom of the browser window.
To do this enter the URL parameter sap-accessibility-debug=X. The accessibility mode sap-accessibility=X must
also be activated.
The text of the element currently focused on is displayed after the prefix ACC:
Performance check:
In WDA, use the key combination ‘CTRL-ALT-SHIFT-P’ to see some interesting memory and performance stats for your
application.
Use the key combination ‘CTRL-ALT-SHIFT-H’ to see all the available keyboard shortcuts (including the one above).
Use transaction SHMM from NetWeaver 6.20 and higher to take a memory snapshot at any moment in time for your
application.
Use transaction STAD if you see a lot of server time as a problem with your app (e.g. things are taking a lot of time
on the server).
Use transaction SAT to get to the new Runtime Analysis tool – don’t forget to go to SICF first to select the ICF node you want to analyse.
Use tools like HTTPWatch or Chrome browser development tools to see what is happening in your HTTP requests/responses.
Performance tools:
Webdynpro ABAP Runtime Analysis
Webdynpro memory Analysis
Webdynpro Trace tool
Perfromance Monitor
Webdynpro abap Runtime Analysis:
Web Dynpro ABAP is integrated in the existing Runtime Analysis. You can find information about the runtime analysis
tools in the ABAP documentation.
You can launch the runtime analysis for Web Dynpro ABAP applications from the Web Dynpro Explorer in the ABAP
Workbench.
For details explanation follow below link:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/46/f7cc6bd1b3537ee10000000a1553f6/content.htm
Webdynpro Memory Analysis:
You can perform a memory analysis for your Web Dynpro ABAP application to analyze the current memory consumption. The
procedure is as follows:
Create a trace variant.
Create a memory consumption snapshot.
Call the memory inspector.
Analyze the data.
For detail explanation follow below link:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/0f/bc43c398cc4589a8b63b24d3579c8d/content.htm
Webdynpro Trace tool:
The Web Dynpro trace tool supports the analysis of problems and errors arising in Web Dynpro ABAP, by
collecting and listing the data related to the Web Dynpro ABAP application.
For detail explanation follow the
link:http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/95da36b8cf114be10000000a421937/content.htm
Performance Monitor:
The performance monitor is used to check the general performance of Web Dynpro applications. The monitor does
not provide detailed information, it just gives a rough assessment of performance.
The performance monitor shows information about the following areas: Overview information, Performance, memory,
rendering, system Information.
For detail explanation follow below link:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/4b/4cdb2ffcf74d39ac958fe21702887b/content.htm
Look and Feel( Themes):
The look and feel of your ABAP webdynpro applications can be changed using themes. A theme is a collection
of style sheets (.CSS files) and graphics.
This ability is highly significant: your applications are not restricted to the standard SAP look and feel.
Minor changes such as text size can easily be made via the theme editor (described below). With more extensive
CSS knowledge, the entire look and feel of the application can be customised. An obvious use for this would be
to apply corporate branding.
When running the webdynpro through a portal, application parameter WDFORCEEXTERNALSTYLESHEET may be useful to ensure that webdynpro always uses the style sheet from the portal. Themes may be developed using the Theme Editor supplied with the portal:
http://help.sap.com/erp2005_ehp_03/helpdata/EN/95/8bfe40f652f323e10000000a155106/content.htm
Alternatively, application parameter WDTHEMEROOT may be used to specify a theme for the webdynpro, different to that of the portal. A number of standard themes are available to choose from. The exact logic for theme determination is explained in SAP help, and also on the SDN:
http://help.sap.com/saphelp_nw04s/helpdata/en/46/89af7fbe4d429ee10000000a1553f7/content.htm
EP 7 Portal stylesheet with WD ABAP
Without a portal, we may also like to create and use bespoke themes. The Theme Editor supplied with the portal, can also be
downloaded from the SDN to be used stand-alone:
This is quite a complex procedure, requiring you to install Java and Eclipse, and then adding a plug-in to Eclipse for the theme
editor. Once complete you can copy a standard theme, such as sap tradeshow, and then modify it.
Be careful to download the versions of Java and Eclipse specified – it may not work with more recent versions. If you
have more than one version of the Java runtime environment installed, you may need an extra ‘-vm’ parameter to make it
work – explained here:
Eclipse Theme Editor:
In my own case I had difficulty in adding the parameters to my Eclipse shortcut, so instead I added to .cmd file to my desktop with the following
script:
C:
cd
cd Program FilesEclipse
eclipse.exe -vm “C:Program FilesJavaj2re1.4.2_17 injavaw.exe” -consolelog –
vmargs -Xmx512M
Once we have created our own theme, we need to upload it to the MIME repository and then use it in our webdynpro application. This is process is explained here, by Bastian Preissler and Matthias Grün:
Two possible URL parameters are mentioned here: I found ‘SAP-EP-
THEMEROOT’ to work much better than ‘SAP-CSSURL’.
Note that it is possible to set the theme from within the webdynpro code. This is enormously powerful: if required, your application could run logic to choose from a number of themes at runtime.
Here’s a screenshot from an application using a modified theme. The text is all much larger than normal, and the colours used in the table have been changed:
Running webdynpro applications via SAP GUI:
It is very simple to create a SAP GUI transaction that will run a webdynpro application. The transaction can be created in SE93, calling transaction WDYID with the application name as one of the parameters (thanks to Glen Simpson for this tip):
http://help.sap.com/saphelp_nw04s/helpdata/en/43/27ca50d51e0b19e10000000a1553f6/content.htm
Transaction WDYID uses function module
WDY_EXECUTE_IN_PLACE. This may be used to run a webdynpro application inside a browser control on a dynpro screen.
http://help.sap.com/saphelp_erp2005/helpdata/en/43/2f1a63cb883575e10000000a11466f/content.htm
High Performance of Webdynpro abap:
lower memory consumption, better performance.
using MVC, split the component up if too large, using if_wd_component_usage=>delete_component to delete all web dynpro component instances as soon as no longer needed
Using dynamic navigation or dynamic component usages only if it is absolutely necessary.
Set the lifetime of a view to when visible, if this view is displayed not too much.
Keep context as small as possible, Create context only required by UI binding, use assistance class or other ABAP OO
class as data exchange.
Use singleton node, do not use any dynamic attributes if_wd_context_node_info->add_attribute, bad context design
cause huge runtime memory.
Don’t raise exception in supply function, these cause runtime dump.
Do not use container scrolling (scrolling Mode<>none), create application screens that fits the standard browser, avoid deep
nesting of containers, groups and tabstrips, use the dynamic UI element programming only if it’s necessary
Add assistance class to sub component: For the more complicated situation, we have to split up the component and
add the sub component z_wd_component_sub into main component z_wd_component_demo, and add the assistance
into the sub component, add the z_wd_component_sub into component usage of z_wd_component_demo as sub.
Over write the wddoinit method of z_wd_component_demo
Method wddoinit.
Data: lr_ui_usage type ref to if_wd_component_usage.
Lr_ui_usage = wd_this->wd_cpuse_sub().
If lr_ui_usage->has_active_component() is initial.
Lr_ui_usage->create_component(assistance_class = wd_assist).
Endif.
Endmethod.