cancel
Showing results for 
Search instead for 
Did you mean: 

Default value in the drop down by index

Former Member
0 Kudos

Hi Experts,

I have a drop down by index to which i binded one internal table,but m not able to get the default value

i want the first value to be selected in the drop down by default,Pls give me suggestion for solving this problem

Accepted Solutions (0)

Answers (5)

Answers (5)

former_member402443
Contributor
0 Kudos

Hi Shan,

As per your requirement,When ur binding the internal table to the drop down by index ,but your are not able to get the default value.

For this please check this code.

In this I hv taken a node - dropdown1 and within this attribute of type Land1 and I hv set the cardinality to 0..n.

Then I hv bind the text property of the dropdownbyidx ui element to the node attribute.

then i hv call this code in the init method of view.

DATA lo_nd_dropdown1 TYPE REF TO if_wd_context_node.

DATA lo_el_dropdown1 TYPE REF TO if_wd_context_element.

DATA lt_dropdown1 TYPE wd_this->elements_dropdown1.

DATA ls_dropdown1 LIKE LINE OF lt_dropdown1.

  • navigate from <CONTEXT> to <DROPDOWN1> via lead selection

lo_nd_dropdown1 = wd_context->get_child_node( name = wd_this->wdctx_dropdown1 ).

  • @TODO handle not set lead selection

IF lo_nd_dropdown1 IS INITIAL.

ENDIF.

  • get all declared attributes

lo_nd_dropdown1->get_static_attributes_table(

IMPORTING

table = lt_dropdown1 ).

SELECT land1 FROM t005 INTO CORRESPONDING FIELDS OF TABLE lt_dropdown1.

CALL METHOD lo_nd_dropdown1->bind_table

EXPORTING

new_items = lt_dropdown1

set_initial_elements = abap_true .

Regards

Manoj Kumar

Former Member
0 Kudos

Hi All,

i tried all the possible ways, but still i could not solve the problem,this is the code tat i have put ,please help me out with this issue.

DATA: lo_node_info TYPE REF TO if_wd_context_node_info,

lo_node TYPE REF TO if_wd_context_node,

lw_value_set1 TYPE wdr_context_attr_value,

li_value_set1 TYPE TABLE OF wdr_context_attr_value.

SELECT crevi ltext INTO TABLE li_ltext FROM t71adm08t

FOR ALL ENTRIES IN li_crevi

WHERE crevi = li_crevi-crevi.

LOOP AT li_ltext INTO lw_ltext.

lw_value_set1-value = lw_ltext-crevi.

lw_value_set1-text = lw_ltext-ltext.

APPEND lw_value_set1 TO li_value_set1.

ENDLOOP.

lo_node = wd_context->get_child_node( name =

wd_this->wdctx_vn_reviewselec ).

lo_node_info = lo_node->get_node_info( ).

lo_node_info->set_attribute_value_set( name = 'REVIEW_DROPDOWN'

value_set = li_value_set1 ).

lo_node = wd_context->get_child_node( name =

wd_this->wdctx_vn_reviewselec ).

lo_node->set_lead_selection_index( 1 ) .

Former Member
0 Kudos

hi

u shud make the Node that Is Bound to the DropDown By Index Ui Element Selection Property as 0..1

check the same ..

Former Member
0 Kudos

HI,

if suppose dropdown1 is your node and carrid is the attribute for which the dropdownbyidx field is bound then write the following code in wddoinit() of the view.

DATA lo_nd_dropdown1 TYPE REF TO if_wd_context_node.

DATA lo_el_dropdown1 TYPE REF TO if_wd_context_element.

DATA ls_dropdown1 TYPE wd_this->element_dropdown1.

DATA lv_carrid LIKE ls_dropdown1-carrid.

  • navigate from <CONTEXT> to <DROPDOWN1> via lead selection

lo_nd_dropdown1 = wd_context->get_child_node( name = wd_this->wdctx_dropdown1 ).

  • @TODO handle not set lead selection

IF lo_nd_dropdown1 IS INITIAL.

ENDIF.

lo_el_dropdown1 = lo_nd_dropdown1->get_element( ).

IF lo_el_dropdown1 IS INITIAL.

ENDIF.

LV_CARRID = 'AA'.

  • get single attribute

lo_el_dropdown1->set_attribute(

EXPORTING

name = 'CARRID'

value = lv_carrid ).

then by default you will get AA as the value for the dropdown.also check the standard example coding for wdr_test_events ,view is dropdownbyidx where in the application you are having deault value as red for the dropdown

Edited by: Sridevi Donthi on Feb 17, 2009 5:30 AM

Former Member
0 Kudos

Hi Shanmukha,

You have a context node which is binded with a table right?

Your context node property initialisation lead selection is checked?

In your ModifyView method or where ever appropiate do the following:

Get your node reference,

DATA: lr_node       TYPE REF TO if_wd_context_node.

lr_node = wd_context->get_child_node( '<YOUR_NODE>' ).
lr_node->set_lead_selection_index( index = sy-tabix ).

Set_lead_selection_index method will do the job, you can assign the index you want to be selected in the dropdown.

PS: points are welcome.

Regards,

Abhinav

Former Member
0 Kudos

check the node that is binded to dropdownbyindex has

Initialization Lead Selection flag CHECKED

Try checking the below example, it uses DD By Index and has default value selected by default

[http://help.sap.com/saphelp_erp2005/helpdata/en/dd/b0884118aa1709e10000000a155106/content.htm]

Example

You can find examples of this interface element in the system in the Web Dynpro application WDR_TEST_UI_ELEMENTS, and in the component WDR_TEST_EVENTS in the view DropDownByIdx.

Greetings

Prashant

Edited by: Prashant on Feb 16, 2009 6:39 PM