cancel
Showing results for 
Search instead for 
Did you mean: 

How to set a default value in dropdown list in Wendynpro ABAP? Help!

gopalkrishna_baliga
Participant
0 Kudos

Hi Experts,

I have Webdynpro for ABAP application that shows a DropdownwithKey UI element.

1. I am able to populate the dropdown list. But by default the list is not showing any value. Only when I select a value from the list then it shows it.

So how to set the default value to the first value in the list? Any code sample will be really helpfull.

I have written the following code:

method WDDOINIT .

DATA:

node_category TYPE REF TO if_wd_context_node_info.

node_category = WD_CONTEXT->GET_NODE_INFO( ).

node_category = node_category->GET_CHILD_NODE( 'CATEGORY' ).

data: LT_VALUESET type WDR_CONTEXT_ATTR_VALUE_LIST,

L_VALUE type WDR_CONTEXT_ATTR_VALUE.

L_VALUE-VALUE = 'V1'.

L_VALUE-TEXT = 'yesterday'.

INSERT L_VALUE into table LT_VALUESET.

L_VALUE-VALUE = 'V2'.

L_VALUE-TEXT = 'today'.

INSERT L_VALUE into table LT_VALUESET.

L_VALUE-VALUE = 'V3'.

L_VALUE-TEXT = 'tomorrow'.

INSERT L_VALUE into table LT_VALUESET.

node_category->SET_ATTRIBUTE_VALUE_SET(

NAME = 'CAT_VALUE'

VALUE_SET = LT_VALUESET ).

endmethod.

Note that: I am using webdynpro for ABAP.

Thanks

Gopal

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Bind the "selectedKey" property to a context attribute and set the attribute value to the key that shall be selected.

Armin

gopalkrishna_baliga
Participant
0 Kudos

Hi Armin,

I did the binding for selectedKey. But how to "set the attribute value to the key that shall be selected" as you said? Any code snippet will be really helpfull.

Thanks

Gopal

Former Member
0 Kudos

I am not sure how it works in Web Dynpro for ABAP, but in Web Dynpro for Java to set default drop down value you will have to set the value for particular attribute (which is linked to the dropdown element) in the context

like

wdContext.currentContext<nodeName>Element.set<FieldName>(<defalut value>)

This generally done in Initialization method of the controller.

Former Member
0 Kudos

Hi Gopal,

To get default value from your drop down list, please check the INITIALIZATION LEAD SELECTION in your Node/attribute.

Regards,

Vamsee Kundurthi