cancel
Showing results for 
Search instead for 
Did you mean: 

selected value in dropdown

Former Member
0 Kudos

Hi,

Can any body tell me,how to get the selected value in the dropdown listbox.

I filled the value in the dropdown listbox,all the value avl in the dropdown listbox,but i can't able get the selected value in the dropdown list box.

can anybody tell me what may the problem.

thanks in advance,

Regards,

Ravi

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Ravi,

As I can see from the snippets you have posted, you are using a DropDownByKey and not a DropDownByIndex. To get the selected value in the OnSelect event, use the following code -

lo_el_country = wdevent->get_context_element( name 'COUNTRY' ).

lo_el_country->get_attribute(

exporting

name = 'LAND1'

importing

value = lv_land1 ).

The parameter wdevent is available as an importing parameter to the action handler (So you don't have to declare it).

Regards,

Neha

<i><b>PS:Reward if helpful</b></i>

Former Member
0 Kudos

hi ravi.........

you just click the code wizard button and read the attribute to which the dropdown box has been bound. with this you can get the current value. in case if you want to get other values, you can get it by index.

-


regards,

alex b justin

Former Member
0 Kudos

Hi,

i did the same thing,kindly check the follwing code.

In Do-init,

data: lt_valueset type standard table of wdr_context_attr_value,

ls_valueset type wdr_context_attr_value,

lr_node_info type ref to if_wd_context_node_info,

lr_node type ref to if_wd_context_node,

wa_T005U type T005U,

lt_T005U like table of wa_T005U.

lr_node = wd_context->get_child_node( 'COUNTRY' ).

lr_node_info = lr_node->get_node_info( ).

select distinct land1 from T005U into table lt_T005U.

loop at lt_T005U into wa_T005U.

ls_valueset-value = wa_T005U-land1. "this will be the selected value

ls_valueset-text = wa_T005U. "this will be the displayed value in the UI

append ls_valueset to lt_valueset.

endloop.

lr_node_info->set_attribute_value_set(

exporting

name = 'LAND1'

value_set = lt_valueset ).

I filled the dropdown list box,with the help of above code and also read the attribute land1 value into my selectkey in the layout.

In dropdown list all the values are displaying,i can't able to select the 2nd,3rd value... in the drop down list apart from the default(1st) value.

Thanks in advance,

Regards,

Ravi.

Former Member
0 Kudos

hi ravi...........

instead of writing this code in initialization,

write it in supply function of the specific node which contains the attribute of the dropdown box.

but you can get the attribute in the action command of the dropdownbox.

-


regards,

alex b justin

Former Member
0 Kudos

Hi,

Thanks for your valuable suggestion.

Can you guide me,how to proceed with the help of supply function of the specific node.

guide me with sample code.

thanks in advance,

Regards,

ravi

Former Member
0 Kudos

hi ravi.............

i hope you will be having youe attribute to which the dropdown box has been bound, inside a node. consider the node name to be 'a'.

when you click that node, its properties will be displayed below.

in that there will be an option called 'supply function'.

just enter any name for that function. it automatically creates a method of the same name.

now you write the same codings just like you have written in the initialization, inside that method.

so whenever you invalidate the node 'a' or initialized, this supply function would be called.

now go to the method of the 'onaction' of dropdown box and write the codings to read the attribute. now it will work perfectly..

---regards,

alex b justin

Former Member
0 Kudos

Hi Ravi,

Your code is fine. If the selectedKey property is bound to the context attribute, it should work fine. What is the code in your onSelect event? You should simply do get_element and read the static attributes, and it will give you the selected value. Please post the code in your onSelect event.

Regards

Nithya

Former Member
0 Kudos

hi nithya,

This is my code in the "onSelect" event.

data:

Node_Country type ref to If_Wd_Context_Node,

Elem_Country type ref to If_Wd_Context_Element,

Stru_Country type If_Main=>Element_Country,

wa_T005U type T005U,

lt_T005U type table of T005U.

.

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

Node_Country = wd_Context->get_Child_Node( Name = IF_MAIN=>wdctx_Country ).

  • get element via lead selection

Elem_Country = Node_Country->get_Element( ).

  • get all declared attributes

Elem_Country->get_Static_Attributes(

importing

Static_Attributes = Stru_Country ).

select * from T005U into table lt_T005U where land1 = Stru_Country-land1.

Node_Country = wd_context->get_child_node( Name = 'COUNTRY' ).

Node_Country->bind_table( lt_T005U ).

i think i did every thing correct,eventhough i didn't get the selected value in my dropdown list box.

kindly give your suggestion.

Thanks in advance,

Regards,

Ravi.

Former Member
0 Kudos

Hi,

can u just put a break point at your select statement and check wheather the enties you are expecting are getting selected

cheers

Former Member
0 Kudos

hi ravi..

did you try writing the code in the supply function as i suggested before?

as of now do not write any coding in 'on select'.

-


regards,

alex b justin

Former Member
0 Kudos

Hi Alex,

I tryed in supply function also,as u suggested.

but i am getting error like

"<b>The lead selection has not been set. MAIN "</b>

In my Node,i set as

Cardinality - 0 to 1.

Selection 0 to 1.

but i don't know why i am getting error.

can u guide me.

thanks in advance.

Regards,

Ravi.M

Former Member
0 Kudos

hi ravi........

set the cardinality to 0..n. and have a single attribute inside it which must be bound to the dropdownbox.

-


regards,

alex b justin

Former Member
0 Kudos

hi alex,

i already set the cardinality to 0..n and checked it,even though i am getting the same error.

advice....

regards,

ravi.M

Former Member
0 Kudos

hi ,

Your code looks fine and you need to use supply fuction you can put your code in wddoinit method itself.

loop at lt_T005U into wa_T005U.

ls_valueset-value = wa_T005U-land1. "this will be the selected value

ls_valueset-text = wa_T005U."this will be the displayed value in the UI

append ls_valueset to lt_valueset.

endloop.

here why you are not passing value to text filed.

this may be the reason or just sort it and pass it to set_attribute_value_set.

or make sure your UI element type is DROPDOWN_BY_KEY.

regards

sarath

Former Member
0 Kudos

first line you need not to you supply function you can you wddoinit. (typo error)

regards

sarath

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi Ravi.

use the wizard button in the code where you want to access the attribute.

Regards

Abhimanyu L