Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV sum average subtotal...

Former Member
0 Likes
975

Can anyone show me where in code of class CL_GUI_ALV_GRID are calculated:

sum, average, max, min.

I need to calculatete this values on a huge amount of data and I;m interesting how this is done in ALV.

Regards, Tomek

1 ACCEPTED SOLUTION
Read only

former_member199581
Active Participant
0 Likes
742

Hi Tomasz,

method GET_TOTALS of class CL_GUI_ALV_GRID says this:

method get_totals .
* not in use while import/export from memory has to be used for
* saving the internal tables. Therfore the function module
* LVC_TOTALS_GET is used.
* ...
endmethod.

For subtotals, take a look at method GET_GROUPLEVELS, line 65:

  data: l_sumlevel      type i,
        l_sumlevel_unit type i.

  call function 'LVC_SUMLEVEL_TRANSLATE'
    changing
      ct_sort           = m_cl_variant->mt_sort
      ct_grouplevels    = m_cl_variant->mt_grouplevels
      c_sumlevel_global = l_sumlevel
      c_sumlevel_unit   = l_sumlevel_unit.

Hope this helps,

R.

4 REPLIES 4
Read only

Former Member
0 Likes
742

For sum, you just need to pass DO_SUM = 'X' for the fields for which you need the totals, in the field catalog.

For averafe you need to pass DO_SUM = 'C'.

for maximum, you need to sort the table based on the quantity and the key fields.

the first is maximum and the last will be the minimum(for descending order).

Regards,

Ravi

Read only

0 Likes
742

No! I don't need explanation how to calculate! As I wrote I need to find in class place where this is calculated. I must perform on huge amount data calculations and then calculate sum, averages, minimun, maximum and so one.

Thatway I'm curious how this is done in code of ALV Greed!

Read only

former_member199581
Active Participant
0 Likes
743

Hi Tomasz,

method GET_TOTALS of class CL_GUI_ALV_GRID says this:

method get_totals .
* not in use while import/export from memory has to be used for
* saving the internal tables. Therfore the function module
* LVC_TOTALS_GET is used.
* ...
endmethod.

For subtotals, take a look at method GET_GROUPLEVELS, line 65:

  data: l_sumlevel      type i,
        l_sumlevel_unit type i.

  call function 'LVC_SUMLEVEL_TRANSLATE'
    changing
      ct_sort           = m_cl_variant->mt_sort
      ct_grouplevels    = m_cl_variant->mt_grouplevels
      c_sumlevel_global = l_sumlevel
      c_sumlevel_unit   = l_sumlevel_unit.

Hope this helps,

R.

Read only

Former Member
0 Likes
742

Hi,

it is not calculated in the class but you pass some values to the grid in the field catalogue like this:

CALL METHOD mygrid->set_table_for_first_display

EXPORTING

it_toolbar_excluding = t_fcodes[]

CHANGING

it_outtab = mytable[]

it_fieldcatalog = field_catal[].

for your field catalogue you can fill the table so

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'SFLIGHT'

CHANGING

ct_fieldcat = field_catal.

field_catal is of type lvc_t_fcat and this one has among others fields DO_SUM.