In order to display an ALV report with specific columns already sorted by default you will need to build a
sort catalogue. This is fairly straight forward and is done in the following way:
Step 1. Add data declaration for sort catalogue
Step 2. Add code to build sort catalogue table
Step 3. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include parameter 'it_sort'
* ALV data declarations data: it_sortcat type slis_sortinfo_alv occurs 1, wa_sort like line of it_sortcat.
perform build_sortcat. *&----------------------------------------------------------* *& Form build_sortcat *&----------------------------------------------------------* * Build Sort catalog *-----------------------------------------------------------* FORM build_sortcat . wa_sort-spos = 1. wa_sort-fieldname = 'EBELN'. wa_sort-SUBTOT = 'X'. "subtotals any totals column by this field * gd_sortcat-tabname APPEND wa_sort TO it_sortcat. wa_sort-spos = 2. wa_sort-fieldname = 'EBELP'. * gd_sortcat-tabname APPEND wa_sort TO it_sortcat. ENDFORM. " build_sortcat
call function 'REUSE_ALV_GRID_DISPLAY' exporting i_callback_program = gd_repid i_callback_top_of_page = 'TOP-OF-PAGE' is_layout = gd_layout it_fieldcat = fieldcatalog[] it_sort = it_sortcat i_save = 'X' tables t_outtab = it_ekko exceptions program_error = 1 others = 2.