Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Setting Default values in Dropdown box in Webdynpro ABAP

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.

Former Member
Former Member replied

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

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question