‎2006 Dec 12 2:19 PM
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
‎2006 Dec 12 2:30 PM
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.
‎2006 Dec 12 2:23 PM
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
‎2006 Dec 12 2:29 PM
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!
‎2006 Dec 12 2:30 PM
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.
‎2006 Dec 12 2:32 PM
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.