Controlling Aggregation, Filtering & Sorting in ALV
General actions like aggregation(total), filtering & sorting is automatically enabled for the fields and obviously aggregation of the fields with relevant data type. It is also possible to disable all the actions on the particular column(s) as per needed by using the methods of the IDA interface IF_SALV_GUI_FIELD_CATALOG_IDA
A simple program.
Output: Right click on the CONNID field & choose the option – Group.
It groups all records based on the particular CONNID value.
Ungroup it.
Filtering on the PLANETYPE column.
Press F4 and it lists all the distinct planetype value. Choose one.
Continue.
Now the list is filtered out.
Also Aggregation(Total).
It SUMS the column value.
Sorting on the CARRID column.
List sorted.
Code: To disable Aggregation, Filtering and sorting on few columns.
DATA: lr_salv TYPE REF TO if_salv_gui_table_ida.
DATA: lr_fcat TYPE REF TO if_salv_gui_field_catalog_ida.
TRY.
cl_salv_gui_table_ida=>create(
EXPORTING
iv_table_name = ‘SFLIGHT’
RECEIVING
ro_alv_gui_table_ida = lr_salv ).
CATCH cx_salv_db_connection.
CATCH cx_salv_db_table_not_supported.
CATCH cx_salv_ida_contract_violation.
ENDTRY.
* Get the field catalog reference
lr_fcat = lr_salv->field_catalog( ).
lr_fcat->disable_sort( iv_field_name = ‘CARRID’ ).
lr_fcat->disable_filter( iv_field_name = ‘PLANETYPE’ ).
lr_fcat->disable_aggregation( iv_field_name = ‘SEATSMAX’ ).
* Display ALV
lr_salv->fullscreen( )->display( ).
Output:
Sorting Disabled on CARRID column.
Filtering disabled on PLANETYPE column.
Aggregation disabled on SEATSMAX column.