Skip to Content
2
May 07, 2020 at 08:13 AM

How to show only the aggregated value and not the individual records using CL_SALV_TABLE

147 Views Last edit May 07, 2020 at 10:09 AM 4 rev

Hello Everyone,

I am required to write codes which will generate an alv. In the ALV the time field will be aggregated depending on the Kostenart. The additional requirement is that the ALV should only output the aggregated amount and the not the records. That means if Kostenart Y001 got 2 records of total 135 minutes (90+45) then only 135 minitues will come as output not the 90 and 45. If my question is not clear then please feel free to look at the screen shot. It will give a much clearer view.

Your suggestions will be highly appreciated.

Thanks in advance

Arnab

  cl_salv_table=>factory(
  IMPORTING r_salv_table = g_o_table
  CHANGING t_table = g_it_output ).

  "Funktionen aktivieren
  g_o_functions = g_o_table->get_functions( ).
  g_o_functions->set_all( abap_true ).
  g_o_display = g_o_table->get_display_settings( ).

  g_o_display->set_striped_pattern( abap_true ).
  g_o_columns = g_o_table->get_columns( ).

  "Um spalten aus zu blenden
  g_o_column ?= g_o_columns->get_column( 'MANDT' ).
  g_o_column->set_technical( if_salv_c_bool_sap=>true ).
  g_o_column ?= g_o_columns->get_column( 'AWE_ID' ).
  g_o_column->set_technical( if_salv_c_bool_sap=>true ).

  "Spalten optimieren
  g_o_columns->set_optimize( abap_true ).

  "Um Daten zu sortieren
  g_o_sorts = g_o_table->get_sorts( ).
  g_o_sorts->add_sort( columnname = 'KOSTENART' subtotal = abap_true ).
  g_o_sorts = g_o_table->get_sorts( ).
  g_o_sorts->add_sort( columnname = 'MATNR' subtotal = abap_true ).

  "Zu aggregieren
  g_o_agg = g_o_table->get_aggregations( ).
  g_o_agg->add_aggregation( 'ZEIT' ).

Attachments

aggregate.png (24.1 kB)