The sorting and grouping of data in ALV Table can be programmatically achieved. The method add_sort( ) of the class CL_SALV_SORTS can be used to sort or group the data. This sorting object is created from the get_sorts( ) method of the ALV Object.
DATA lr_salv_sorts TYPE REF TO cl_salv_sorts.
Lr_salv_sorts = lr_salv_table->get_sorts( ).
Lr_salv_sorts->add_sort( EXPORTING columnname = ‘AGE’
sequence = if_salv_c_sort=>sort_up ).
The following sorting and grouping options are available.
If_salv_c_sort=>sort_none.
If_salv_c_sort=>sort_up.
If_salv_c_sort=>sort_down.
If_salv_c_sort=>group_with_underline.
If_salv_c_sort=>group_with_newpage.
If_salv_c_sort=>group_none.