05-13-2008 3:17 PM
05-13-2008 3:28 PM
Hello,
Please read this: [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907].
Regards,
05-13-2008 6:28 PM
Hi Joshi,
Award points if useful..
Summing up Percentages in an ALV Grid
ALV Grid lets you get subtotals and totals of columns, but you might often need to get averages and percentages among other not so frequent requirements.
Its possible to get averages (or sub-averages) instead of subtotals.You can use the method get_subtotals, since this method returns a reference you can use it to change the values displayed as subtotals to what ever you want, not just percentages - ratios, powers, logarithms, anything you want.
This is the code
CREATE OBJECT gr_alvcon
EXPORTING container_name = ABC. Name of the custom container
CREATE OBJECT gr_alvgrid
EXPORTING i_parent = gr_alvcon.
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
is_layout = ps_layout
CHANGING
it_fieldcatalog = fieldcat
it_sort = it_sort
it_outtab = it_delsm[].
DATA : total TYPE REF TO data,
subto TYPE REF TO data.
FIELD-SYMBOLS <ftotal> TYPE STANDARD TABLE.
FIELD-SYMBOLS <fsubto> TYPE STANDARD TABLE.
DATA wa_tot TYPE t_delsm.
CALL METHOD gr_alvgrid->get_subtotals
IMPORTING ep_collect00 = total
ep_collect01 = subto.
ASSIGN total->* TO <ftotal>.
ASSIGN subto->* TO <fsubto>.
LOOP AT <ftotal> INTO wa_tot.
wa_tot-delpc = wa_tot-delpr * 100 / wa_tot-totpr. " Set any value for this
MODIFY <ftotal> FROM wa_tot INDEX sy-tabix.
ENDLOOP.
CALL METHOD gr_alvgrid->set_ready_for_input
EXPORTING i_ready_for_input = 1.
05-13-2008 7:54 PM
Hello Tanju
The classical SE16 list display corresponds to function module REUSE_ALV_GRID_DISPLAY.
When you switch to grid display this corresponds to fm REUSE_ALV_GRID_DISPLAY_LVC.
Technically REUSE_ALV_GRID_DISPLAY belongs to the old-fashioned SLIS-based ALV lists whereas REUSE_ALV_GRID_DISPLAY_LVC is similar like the OO-based ALV lists. Its interface is almost identical to method SET_TABLE_FOR_FIRST_DISPLAY of class CL_GUI_ALV_GRID.
Regards
Uwe