Skip to Content
-2

Default sort order in ALV Grid

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Mar 14 at 12:35 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 14 at 12:37 PM

    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.)

    Add comment
    10|10000 characters needed characters exceeded