cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Default values in Dropdown box in Webdynpro ABAP

Former Member
0 Kudos

Hi,

Iam using a Dropdown element of type Dropdown by key.

and iam able to display my drop downlist without default value. now iam planing to display my dropdown list with default value(like Reports in this case)..

please advice how to do this?

Below code i have used for this..

DATA:

it_value_set_reports TYPE TABLE OF wdr_context_attr_value,

wa_value_set_reports TYPE wdr_context_attr_value,

lr_node_info_reports TYPE REF TO if_wd_context_node_info.

wa_value_set_reports-value = '01'.

wa_value_set_reports-text = 'Reports'.

APPEND wa_value_set_reports TO it_value_set_reports.

wa_value_set_reports-value = '02'.

wa_value_set_reports-text = 'Scripts'.

APPEND wa_value_set_reports TO it_value_set_reports.

APPEND INITIAL LINE TO it_value_set_reports.

IF NOT it_value_set_reports IS INITIAL.

lr_node_info_reports = wd_context->get_node_info( ).

lr_node_info_reports->set_attribute_value_set( name = 'DISPLAY'

value_set = it_value_set_reports ).

ENDIF.

Thanks for looking.

Sree.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sree,

In your case, you are binding a value set to the node(info_reports) attribute 'DISPLAY'. That means what ever value you have choosen in the dropdown will be set as the attribute value.

In case if you want to set a default value, you have to set that value to the node - attribute itself in the WDDOINIT Method, it will take of showing the default value in the dropdown.



  DATA LO_ND_INFO_REPORTS TYPE REF TO IF_WD_CONTEXT_NODE.
  DATA LO_EL_INFO_REPORTS TYPE REF TO IF_WD_CONTEXT_ELEMENT.
  DATA LS_INFO_REPORTS TYPE WD_THIS->ELEMENT_INFO_REPORTS.
  DATA LV_DISPLAY LIKE LS_INFO_REPORTS-DISPLAY.
* navigate from <CONTEXT> to <INFO_REPORTS> via lead selection
  LO_ND_INFO_REPORTS = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_INFO_REPORTS ).

* get element via lead selection
  LO_EL_INFO_REPORTS = LO_ND_INFO_REPORTS->GET_ELEMENT(  ).

* set single attribute
  LO_EL_INFO_REPORTS->SET_ATTRIBUTE(
    EXPORTING
      NAME =  `DISPLAY`
     VALUE =  '01' ).

Regards,

Trikanth

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi sree please try to understand following code.This is how we make default values in our drop down lists.

DATA: str type string.

data: title type if_MAIN=>element_ZCITY.

str = ' reports'.

node = wd_context->get_child_node( 'ZCITY' ).

title-CITY = str.

node->bind_structure( title ).

Here i am trying to make reports value to defalt of drop down.

ZCITY is the node with which i have bound the drop down list.

Try it may be it will solve your problem