on 01-24-2014 6:12 PM
Hi Experts,
I am facing a situation in my application , i have an alv with dropdown , this dropdown list is dependent on the another column of the alv ( the list will change each row) for eg: if first column "country" is india, then dropdown should only have provinces in India .
I read in SDN that its possible only through dropdown by index as we can have a value set attribute in the alv node.
This question has been asked multiple times but i couldnt find any proper answer for dropdown by index (so please avoid answering with DDbyKey solutions).
In my wddoinit method, i have following code
DATA: lo_dropdown_idx TYPE REF TO cl_salv_wd_uie_dropdown_by_idx.
lo_column = lo_column_settings->get_column('PROVINCES').
CREATE OBJECT lo_dropdown_idx
EXPORTING
selected_key_fieldname = 'PROVINCES'.
CALL METHOD lo_dropdown_idx->set_valueset_fieldname
EXPORTING
value = 'VALUESET'.
CALL METHOD lo_dropdown_idx->set_type
EXPORTING
value = if_salv_wd_c_uie_drdn_by_index=>type_key_convert_to_value.
lo_column->set_cell_editor( lo_dropdown_idx ).
On click of the search button, i will get all the records form the database.
SEARCH METHOD
LOOP the records from database
Create the value set and put it in the context attribute "VALUESET"
MOVE '1' TO ls_value_set-value.
MOVE 'Trial' TO ls_value_set-text.
APPEND ls_value_set TO lt_value_set.
MOVE lt_value_set TO ls_dashboard-valueset.
append ls_dashboard TO lt_dashboard
ENDLOOP.
lo_nd_dashboard->bind_table( lt_dashboard).
When i run the application, and on click of the search button, my dropdown values are not populated, but i can see the size of listbox changing depending on the condition.
Please hlep me with clues on what i may be doing wrong
Regards,
Tashi
Hi Experts,
I think i solved this question myself, i am not sure this is the proper way of doing it but it surely works.
Find the steps i have done :
In WDDOINIT
i populated the node if with all possible values for our dropdown.
LT_VALUE_SET will contain all the provinces.
MOVE '0' TO ls_value_set-value.
MOVE 'Karnataka' TO ls_value_set-text.
APPEND ls_value_set TO lt_value_set.
MOVE '1' TO ls_value_set-value.
MOVE 'Kerala' TO ls_value_set-text.
APPEND ls_value_set TO lt_value_set.
MOVE '2' TO ls_value_set-value.
MOVE 'Andhra' TO ls_value_set-text.
APPEND ls_value_set TO lt_value_set.
lo_nd_info = lo_nd_dashboard->get_node_info( ).
lo_nd_info->SET_ATTRIBUTE_VALUE_SET( EXPORTING NAME = 'PROVINCES' VALUE_SET = LT_VALUE_SET ).
Now in the Search method (which populated my alv):
LOOP the records from database
Create the value set and put it in the context attribute "VALUESET"
IF country EQ INDIA
MOVE '1' TO ls_value_set-value.
APPEND ls_value_set TO lt_value_set.
MOVE lt_value_set TO ls_dashboard-valueset.
ENDIF.
append ls_dashboard TO lt_dashboard
ENDLOOP.
It will get kerala in the dropdown .. you can put an if condition to pass value accordinly to the dropdown
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
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.