You are on page 1of 9

How to Add a Dropdown to a View

in a Standard WebDynpro for ABAP


Component using the New
Enhancement Framework

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.

Summ ary
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.

Ho w to Add a Dropdown to a V iew in a S tandard W e bDyn pro for A B AP Comp one nt us ing the Ne w E nhancem e nt F ramew ork

Table o f C ontents
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

Ho w to Add a Dropdown to a V iew in a S tandard W e bDyn pro for A B AP Comp one nt us ing the Ne w E nhancem e nt F ramew ork

Introduc tion
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.

Proc edure
1. Cre ate an E nhancem ent Implementation
The enhance button looks like at the screenshot to the left.
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 all the
enhancements for this procedure. Assign enhancements to this same implementation at each component.

Ho w to Add a Dropdown to a V iew in a S tandard W e bDyn pro for A B AP Comp one nt us ing the Ne w E nhancem e nt F ramew ork

2. Cre ate a new Node on Com pone nt C ontroller Cont ext


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. Cre ate a new Method on Com ponent Control ler as the Supply Funct ion of the new Node
Double-click on the method name to
implement the code of the Supply
Function.

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.

Ho w to Add a Dropdown to a V iew in a S tandard W e bDyn pro for A B AP Comp one nt us ing the Ne w E nhancem e nt F ramew ork

4. Cre ate n ew Node o n the View C ontext by b inding it from the Co ntroller C ontext
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. Cre ate the Dropdow n and C aption E lements 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.

Ho w to Add a Dropdown to a V iew in a S tandard W e bDyn pro for A B AP Comp one nt us ing the Ne w E nhancem e nt F ramew ork

Create a Dropdown Element


Set the following attributes for the Dropdown Element.

Create Caption Element


Set the following attributes for the Caption Element.

Ho w to Add a Dropdown to a V iew in a S tandard W e bDyn pro for A B AP Comp one nt us ing the Ne w E nhancem e nt F ramew ork

6. Cre ate a P ost -E xit on V iew method DoM odifyView


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'

Ho w to Add a Dropdown to a V iew in a S tandard W e bDyn pro for A B AP Comp one nt us ing the Ne w E nhancem e nt F ramew ork

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. Crea te a P re-Ex it o n C omponent m ethod SA VE E XP E NS E RE PORT .


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

Ho w to Add a Dropdown to a V iew in a S tandard W e bDyn pro for A B AP Comp one nt us ing the Ne w E nhancem e nt F ramew ork

static_attributes = ls_zzenh_approvers ).
l_selectedapprover = ls_zzenh_approvers-key.
ENDMETHOD.

You might also like