Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

sorting using button action.


I have 2 buttons 'SORT ASCENDING' and 'SORT DESCENDING' . also there is a table UI element. On click of any one button sorting will be done on a particular table column selected .As i am new to WDA can nybody help me with the code snippet.

thanks in advance.



You want to select one Table Column and then Press Ascending or Descending. For this you can follow this approach.

Here I suppose you are displaying data in Table. That Code in in wddoinit and internal table itab.

1. To make Table Column Selectable -> Change ColSelectionState to NotSelected.

2. In onAction of Table Column C1 let us say, make an On Action - A1.

3. In A1, get the values of the Column selected in an internal table itab1.

4. Now Make buttons - Asc and Desc with action assigned to it as ASC and DESC.

5 In the On Action of Asc, Sort the Values Using :

sort itab1 Ascending.

6. Move this sorted values in another internal table itab2.

7.Fill data for other columns too. Use below mentioned Code :

loop at itab into wa1.

READ TABLE itab1 INDEX sy-tabix into wa2.

wa1-carrid = wa2-carrid.

APPEND wa1 to itab2.


8. This way you will be having All Data for Sorted Columns and other columns in another internal table itab2.

9. Bind this internal table with Node which you have binded to table.

10. You have to do it for all Columns. Get Selected Column data in one table and then sort it and then move it to another table along with data of other columns and finally bind it.

There may be other possible situations too but i have tried this and it is working.


Edited by: Saurav Mago on Apr 10, 2009 3:40 PM

0 View this answer in context

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question