SAP Tech Pro

SAP Technical Blog
Topprice Price Comparison

How to use Web Dynpro UI element – “Drop Down By Index” with Static and Dynamic Programming

How to use Web Dynpro UI element – “Drop Down By Index” with Static and Dynamic Programming

The UI element Drop Down By Index provides the end user with a dropdown list from where he can choose only one entry. This UI element doesn’t differ from the DropDownByKey when displayed on the screen, the implementation being the only difference. We create the same WD Component; in this case, we use a dropDownByIndex UI element instead of the dropDownByKey.In Fig. we show the context structure.In this case, we use a context node with the dictionary structure SHSVALSTR2, cardinality 0...n, Singleton.

Context structure

How to use Web Dynpro UI element – “Drop Down By Key”

View Layout

How to use Web Dynpro UI element – “Drop Down By Key”

Here under,we present a table with some of the DropDownByIndex properties that can be bound,and the attribute type in case the property is bindable (Table).

How to use Web Dynpro UI element – “Drop Down By Key”

As we can see,the texts property is mandatory. If this property of the drop- DownByIndex UI Element is bound to the VALUE attribute, the values stored in this attribute are displayed in the selection list. Listing shows how we can populate the dropdown list with values via a supply function method.

Supply function method


METHOD supply_dropdownbyindex.

DATA:ls_country TYPE if_v_view=element_dropdownbyindex,
     lt_country LIKE TABLE OF ls_country.

ls_country-value ='Austria'.
ls_country-key ='Vienna'.
APPEND ls_country TO lt_country.

ls_country-value ='Belgium'.
ls_country-key ='Brussels'.
APPEND ls_country TO lt_country.

node->bind_table(new_items = lt_country set_initial_elements = abap_true).

ENDMETHOD.

Runtime

How to use Web Dynpro UI element – “Drop Down By Key”

Dynamic Programming

RUNTIME CLASS: CL_WD_DROPDOWN_BY_IDX

Hereunder,we present a table showing the correspondence between the view designer name and the runtime name,with the proper types,in case of dynamic programming of a DropDownByIndex UI element (Table).

How to use Web Dynpro UI element – “Drop Down By Key”

The implementation of a dynamic DropDownByIndex UI element


DATA lr_dropdown_by_index TYPE REF TO cl_wd_dropdown_by_idx. 

DATA lv_bind_attribute TYPE string. 

lv_bind_attribute ='DROPDOWNBYINDEX.VALUE'. 

lr_dropdown_by_index = cl_wd_dropdown_by_idx=>new_dropdown_by_idx( id = 'DDI' bind_texts = lv_bind_attribute ). 
 

Add comment

Before Buying, Compare Prices at Topprice.in

Topprice.in