You are on page 1of 11

How t o Add a Dr opdow n t o a Vi ew

i n a St andar d WebDynpr o f or ABAP


Component usi ng t he New
Enhanc ement Fr amew or k
Applies to:
SAP WAS ABAP 7.0 (Netweaver 2004s) and ESS/MSS Enhancement Pack 2(required only if youre
enhancing the Travel Expenses Create Expense Report component exactly as in this case). For more
information, visit the Web Dynpro ABAP homepage.
Summary
The aim of this article is to share the techniques used to enhance a standard WebDynpro ABAP Component
with a new dropdown element using SAP's new enhancement concept, the Enhancement Framework. This
new enhancement concept will gradually replace the previous concepts.
The uses of the following Enhancement Framework techniques are covered in this article.
Add new Elements to a Standard View
Add a new Node to Context of a Standard Component Controller
Add a new Node to Context of a Standard View Controller
Create a new Method (a Supply Function) on a Standard Component Controller
Implement a Pre-Exit and a Post Exit on Standard methods.

Author: Ogeday Isiklar
Company: Bluefin Solutions Ltd.
Created on: 12 April 2009
Author Bio
Ogeday Isiklar is a Senior Netweaver Consultant. Hes a former SAP Employee from Turkey.He
has been working at Bluefin Solutions Ltd. as a Senior Consultant in the UK since J anuary
2007. Hes currently working on WebDynpro ABAP, ECC6.0 Workflow and Enterprise Portals
7.0 on ESS/MSS. His background is ABAP/J ava Development. He has worked on CRM and
ECC projects.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
2009 SAP AG 1
How to Add a Dropdown to a View in a Standard WebDynpro for ABAP Component using the New Enhancement Framework
Table of Contents
Introduction ......................................................................................................................................................... 3
Procedure ........................................................................................................................................................... 3
1. Create an Enhancement Implementation ................................................................................................... 3
2. Create a new Node on Component Controller Context .............................................................................. 4
3. Create a new Method on Component Controller as the Supply Function of the new Node ....................... 4
4. Create new Node on the View Context by binding it from the Controller Context ...................................... 5
5. Create the Dropdown and Caption Elements on View ............................................................................... 5
Create a Dropdown Element ........................................................................................................................................ 6
Create Caption Element ............................................................................................................................................... 6
6. Create a Post-Exit on View method DoModifyView .................................................................................... 7
7. Create a Pre-Exit on Component method SAVEEXPENSEREPORT. ....................................................... 8
Related Content ................................................................................................................................................ 10
Disclaimer and Liability Notice .......................................................................................................................... 11
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
2009 SAP AG 2
How to Add a Dropdown to a View in a Standard WebDynpro for ABAP Component using the New Enhancement Framework
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
2009 SAP AG 3
Introduction
The screenshots below are taken before and after the enhancement. A new caption element and a new
dropdown element are added as part of the procedure described in this article.
Note: The screenshots above are from the REVIEW_VIEW of the FITE_VC_REVIEW WebDynpro component. This
component is the component for Create Expense Report WebDynpro ABAP application in the Travel Expenses
module, delivered as part of EhP 2.
The following procedure is carried out.
1. Create an Enhancement Implementation
2. Create a new Node on Component Controller Context
3. Create a new Method on Component Controller as the Supply Function of the new Node
4. Create new Node on the View Context by binding it from the Controller Context
5. Create the Dropdown and Caption Elements on View
6. Create a Post-Exit on View method DoModifyView
7. Create a Pre-Exit on Component method SAVEEXPENSEREPORT.
Procedure
1. Create an Enhancement Implementation
The enhance button looks like at the screenshot to the left.




ll the
ame implementation at each component.
At every screen, be it either Component, View, Window, or
etc. there is an Enhance button to create or assign an
Enhancement Implementation and enhance that particular
development component.
Create one Enhancement Implementation to contain a
enhancements for this procedure. Assign enhancements to this s


How to Add a Dropdown to a View in a Standard WebDynpro for ABAP Component using the New Enhancement Framework
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
2009 SAP AG 4
2. Create a new Node on Component Controller Context
Make sure you pressed the Enhance button to create an Enhancement Implementation or assign to one
created before you start enhancements on the Component Controller.
Right-click on the context of the
Component Controller and select
Create ->Node to create a new node
for the Dropdown entries.
Enter a Name for the new Node, e.g. ZZENH_APPROVERS
Select Cardinality 0..n
Select Selection 0..1
Use structure WDY_KEY_VALUE or create attributes KEY and
VALUE as string individually.
Enter a Supply Function name, e.g.
ZZENH_APPROVERS_SOURCE
3. Create a new Method on Component Controller as the Supply Function of the new Node
Double-click on the method name
implement the code of the Supp
Functio
to
ly
n.

METHOD zzenh_approvers_source .

* data declaration
DATA lt_zzenh_approvers TYPE wd_this->elements_zzenh_approvers.
DATA ls_zzenh_approvers LIKE LINE OF lt_zzenh_approvers.
* @TODO compute values
* e.g. call a data providing FuBa
lt_zzenh_approvers = ztrv_util=>get_1st_approvers( i_pernr = wd_assist-
>gs_common_rfc_input-employee_number ).

* bind all the elements
node->bind_table(
new_items = lt_zzenh_approvers
set_initial_elements = abap_true ).

ENDMETHOD.
How to Add a Dropdown to a View in a Standard WebDynpro for ABAP Component using the New Enhancement Framework
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
2009 SAP AG 5
4. Create new Node on the View Context by binding it from the Controller Context
Make sure you pressed the Enhance button to create an Enhancement Implementation or assign to one
created before you start enhancements on the View Controller Context.

Drag the new node from the controller context and drop onto the view context.
5. Create the Dropdown and Caption Elements on View
Make sure you pressed the Enhance button to create an Enhancement Implementation or assign to one
created before you start enhancements on the View Layout.
Right-click on the layout node
to create a new Element

.



The view layout should look like the screenshot below.

How to Add a Dropdown to a View in a Standard WebDynpro for ABAP Component using the New Enhancement Framework
Create a Dropdown Element
Set the following attributes for the Dropdown Element.

Create Caption Element
Set the following attributes for the Caption Element.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
2009 SAP AG 6
How to Add a Dropdown to a View in a Standard WebDynpro for ABAP Component using the New Enhancement Framework
6. Create a Post-Exit on View method DoModifyView
Make sure you pressed the Enhance button to create an Enhancement Implementation or assign to one
created before you start enhancements on the View Methods.

Click on the Create Post-Exit button to create the post-exit. The post-exit method automatically reads the
importing parameter of the original method. All the other parameters of the original method (exporting,
changing, and returning parameters) are provided as changing parameters.

method _PST_4DB78B4U79G3GLPPBRD01XZPR . "Exit of WDDOMODIFYVIEW (in
ZAPPROVER_DROPDOWN_ENH )

* find if only 'save' or 'save and send' is selected
DATA: lo_node_general_data TYPE REF TO if_wd_context_node,
ls_elem_general_data TYPE if_review_view=>element_generaldata.
lo_node_general_data = wd_context->get_child_node( name =
if_review_view=>wdctx_generaldata ).
lo_node_general_data->get_static_attributes( IMPORTING static_attributes =
ls_elem_general_data ).
IF ls_elem_general_data-settl_status EQ
cl_fitv_constants=>gc_settled_status_requested.
* save and send is selected
* enable dropdown here
cl_fitv_wd_util=>ui_set_visible(
io_view = view
iv_id = 'ZZENH_APPROVER_CAPTION'
iv_visible = abap_true ).

cl_fitv_wd_util=>ui_set_visible(
io_view = view
iv_id = 'ZZENH_APPROVER_DD'
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
2009 SAP AG 7
How to Add a Dropdown to a View in a Standard WebDynpro for ABAP Component using the New Enhancement Framework
iv_visible = abap_true ).
ELSE.
* only save is selected
* enable/disable dropdown here
cl_fitv_wd_util=>ui_set_visible(
io_view = view
iv_id = 'ZZENH_APPROVER_CAPTION'
iv_visible = abap_false ).

cl_fitv_wd_util=>ui_set_visible(
io_view = view
iv_id = 'ZZENH_APPROVER_DD'
iv_visible = abap_false ).
ENDIF.


endmethod.
7. Create a Pre-Exit on Component method SAVEEXPENSEREPORT.
The pre-exit method automatically provides all the importing and changing parameters of the corresponding
original method.

METHOD _pre_4de9hfmzfv7ezbn8whtkfcr9r . "Exit of SAVEEXPENSEREPORT (in
ZAPPROVER_DROPDOWN_ENH )

DATA lo_nd_zzenh_approvers TYPE REF TO if_wd_context_node.
DATA lo_el_zzenh_approvers TYPE REF TO if_wd_context_element.
DATA ls_zzenh_approvers TYPE wd_this->element_zzenh_approvers.

* navigate from <CONTEXT> to <ZZENH_APPROVERS> via lead selection
lo_nd_zzenh_approvers = wd_context->get_child_node( name = wd_this-
>wdctx_zzenh_approvers ).
lo_el_zzenh_approvers = lo_nd_zzenh_approvers->get_element( ).

lo_el_zzenh_approvers->get_static_attributes(
IMPORTING
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
2009 SAP AG 8
How to Add a Dropdown to a View in a Standard WebDynpro for ABAP Component using the New Enhancement Framework
static_attributes = ls_zzenh_approvers ).

l_selectedapprover = ls_zzenh_approvers-key.

ENDMETHOD.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
2009 SAP AG 9
How to Add a Dropdown to a View in a Standard WebDynpro for ABAP Component using the New Enhancement Framework
Related Content
SAP NW 7.0 HELP - Enhancement Framework
WebDynpro Enhancements
Travel Expenses - Create Expense Report WDA Component
For more information, visit the Web Dynpro ABAP homepage.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
2009 SAP AG 10
How to Add a Dropdown to a View in a Standard WebDynpro for ABAP Component using the New Enhancement Framework
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
2009 SAP AG 11
Disclaimer and Liability Notice
This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not
supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document,
and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or
code sample, including any liability resulting from incompatibility between the content within this document and the materials and
services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this
document.

You might also like