cancel
Showing results for 
Search instead for 
Did you mean: 

How to sort DropDownList by Value instead of Key

Former Member
0 Kudos

Hi Gurus,

I am just wondering is there a way to sort the drop down list by text or description instead of key.

Sorting the internal table would not help as it will return a short dump for sorting a sorted table.

So, any help in this?

I am using the following view element and coding to populate the drop down values.

The view element:-

The codes:-

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

before binding the valueset to the attribute, just write the following code..


SORT lt_value_set ASCENDING BY text.

Former Member
0 Kudos

Hi Chandra,

The LT_VALUE_SET is type of a sorted table. Hence, sorting a sorted table is not possible.



Former Member
0 Kudos

use the following things..

DATA: lt_valueset TYPE wdr_context_attr_value_list,
         ls_valueset TYPE wdr_context_attr_value.



<<>>


SORT lt_valueset ASCENDING BY text.


   lo_node = wd_context->get_child_node( name = '<Node_name>' ).


   lo_node_info = lo_node->get_node_info( ).


   lo_node_info->set_attribute_value_set(     EXPORTING       name      = '<Attribute_name>'       value_set = lt_valueset   ).


   REFRESH lt_valueset[].

Former Member
0 Kudos

Thanks Chandra for your suggestion and the sample coding.

You solved my problem ! I should have thought of it earlier.

Former Member
0 Kudos

please be kind to mark the correct/helpful ans. and closing the thread.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Girish,

               As you said SORTing the SORTED TABLE would give you an error,

BUT to make it simple why not declare the table to be STANDARD table and then use SORT BY v_value

Hope this helps!

Happy Coding,

Santhosh Yadav