on 02-26-2009 12:09 PM
Hi,
I have already created a drop down list and populated it with data from table by using the node and linking it with the internal table. Now I need to know which element is selected so based on that I need to perform some function. eg. based on the selected data , i need to populate the next drop down list.
A demo code will be really helpful.
Thanks and Regards
Tenzin
Hi Tenzin,
Refer to the following code:
Use this code in the onselect method of your dropdown by key UI element.
DATA key type string.
* Read context element*
DATA lo_el_cn_countrycode TYPE REF TO if_wd_context_element. "cn_countrycode is the node name
lo_el_cn_countrycode = wd_context->get_lead_selection( ).
* display the value of the KEY event parameter
key = wdevent->get_string( 'KEY' ).
Now varaible named key will contain the key of selected item from the drop down.
I hope it helps.
Regards
Arjun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tenzin,
You should create two global attribute of string type. In the onselect method of both the drop down use the code I gave in the previous and set the value of those attributes with it. Now use the value of both the attribute while populating the values in 3rd drop down.
Create a attribute in component controller with name Value type string.
DATA key type string.
* display the value of the KEY event parameter
key = wdevent->get_string( 'KEY' ).
wd_comp_controller->value = key.
Now you can use wd_comp_controller->value where ever you want to.
Regards
Arjun
Hi,
On selcting the value from the drop down, we have one event ONSELECT.
Write the code in this event.
Get the attribute value to lV_xxxxxx using get attribute.
then using that you can fill the next DDBK attribute.
method wddoinit .
data:
lo_nd_spfli type ref to if_wd_context_node,
lo_el_spfli type ref to if_wd_context_element,
ls_spfli type wd_this->element_spfli.
data:
lv_carrid LIKE ls_sflight-carrid,
itab_carrid type wd_this->elements_spfli,
wa_carrid type wd_this->element_spfli,
lo_nodeinfo_spfli type ref to if_wd_context_node_info,
lt_value_set type wdy_key_value_table,
ls_value_set type wdy_key_value.
lo_nd_spfli = wd_context->get_child_node( name = wd_this->wdctx_spfli ).
lo_nodeinfo_spfli = lo_nd_spfli->get_node_info( ).
select carrid
from spfli
into corresponding fields of table itab_carrid.
if sy-subrc = 0.
sort itab_carrid by carrid.
delete adjacent duplicates from itab_carrid comparing carrid.
endif.
loop at itab_carrid into wa_carrid.
ls_value_set-key = wa_carrid-carrid.
ls_value_set-value = wa_carrid-carrid.
append ls_value_set to lt_value_set.
endloop.
lo_nodeinfo_spfli->set_attribute_value_set( name = 'CARRID'
value_set = lt_value_set ).
endmethod.
in the event of first DDBK, write the select statement wsing where condition of lv_XXX.
and append the record as above.
Regards,
sarath
Hi,
Sorry for late reply.. I was not well...
My doubt here is I have used drop down by index ui element .. is it necessary to use drop down by key cause in one book it is suggested to use drop down by index... kindly, let me know which one to be used.. do i need to change it or wat....
Thanks and Regards
Tenzin
Hi Tenzin,
You can use any kind of drop down you want ( either key or index). If you are using Drop down by key the use the following code get the index of the selected item
DATA key type string.
* display the value of the KEY event parameter
key = wdevent->get_string( 'INDEX' ).
Now you key variable will contain the index of the value which you have selected. Then you need to get the corresponding value/ key and then populate the next drop down. My advice would be that you use Drop down by key, as you'll directly get the selected key according to which you can populate the next drop.
I hope it helps.
Regards,
Arjun
Tenzin,
Like I said in my previous post, Drop down by index will give you only the index of the selected value from the drop down, say your drop down list has 4 values, then the possible index could be 1,2,3,4. You need to extract the key or the value of the item selected according to that index. Either you can follow this approach or you can simply use Drop down by key and use the code which i gave in my first post, that will give you the key of the item selected, then you can use it in whatever way you want to, may be in a select query or in a fm.
I hope it helps.
Regards
Arjun
Tenzin,
You can read the node that is binded to your drop down with the help of code wizard. This way you'll get the values in an internal table. After the simply apply the READ statement to get the selected value by passing the index as well. Suppose the value of the index is in a variable lv_index
READ TABLE <internal table> INTO <work area> INDEX lv_index.
This way you'll get all the details of the selected item
Regards
Arjun
you can use get_attribute method directly on that attribute.
elem->get_attribute( importing name = 'ATTRIBUTE_NAME' Value = lv_xxxxx).
Regards,
sarath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.