Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Default sort order in ALV Grid

ThFiedler
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi ABAP community,

I want to have a default sort order in my ALV Grid meaning that the data is already sorted when the ALV pops up the first time..

Does someone know how to do that?

Regards,

Thomas.

2 REPLIES 2

Hi Thomas,

it depends which ALV are you using. Below you can find explanation for the two most often used ALV types:
- if you are using CL_GUI_ALV_GRID then you should pass IT_SORT table (type LVC_T_SORT) when calling SET_TABLE_FOR_FIRST_DISPLAY.
- if you are using CL_SALV_TABLE then you should use CL_SALV_SORTS object to adjust initial sorts (get sort by calling GET_SORTS and then in simpliest case add necessary sorts with ADD_SORT method).

Best regards,
Marcin

raymond_giuseppi
Active Contributor

Set it programmatically (e.g. CL_GUI_ALV_GRID->SET_SORT_CRITERIA or parameter IT_SORT of CL_GUI_ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY, or CL_SALV_TABLE->GET_SORTS, etc.)