Add Default Sorting to ALVgrid reportIn 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:
* ALV data declarations
data: it_sortcat type LVC_T_SORT,
it_sortcatdb type LVC_T_SORT.
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 METHOD gd_tree->set_table_for_first_display
EXPORTING
is_layout = gd_layout
CHANGING
it_fieldcatalog = gd_fieldcat
it_sort = it_sortcat
it_outtab = it_report.
|
||||||||