01-06-2011 8:58 PM
Hello Experts,
We are working on a report in which we are supposed to display few fields regarding customer and most of them are time fields. My issue is at the end of every customer i need to display the AVERAGE time as a subtotal. I am having all the data in a internal table which i am passing to REUSE_ALV_GRID_DISPLAY which will be having multiple customer and multiple records for each customer. I tried with the optoin 'do_sum' of field catalog but it is not working. I tested with some other sample program where it worked but in the sample program i am using quantity to be summed up. Is there is any way of getting the average of the time at the end of every customer using ALV Grid..?? Or is there is any best way to display this other than ALV grid...?
My requirement will be much similar to this
Cust1 A1 123 00:04:00
A2 111 00:06:00
Total (2) 00:05:00
Cust2 B1 898 00:01:00
B2 789 00:06:00
B3 454 00:02:00
Total (3) 00:03:00
Thanks & Regards,
Uday S.
01-06-2011 9:23 PM
Hi,
In field catalog for avarage field make do_sum as truc (X) and pass the customer in the sort table. You can take reference of the below code.
Grouping A
wa_fieldcat-fieldname = 'TSL_A'.
wa_fieldcat-seltext_s = wa_fieldcat-seltext_m = wa_fieldcat-seltext_l = text-015.
wa_fieldcat-do_sum = c_true.
wa_fieldcat-outputlen = 20.
l_col_pos = l_col_pos + 1. "SD0K962726
wa_fieldcat-col_pos = l_col_pos. "SD0K962726
*--- Sort order for subtotal
l_wa_sort-fieldname = 'RBUNIT'.
l_wa_sort-spos = '01'.
l_wa_sort-subtot = c_true.
append l_wa_sort to it_sort.
l_wa_sort-fieldname = 'HRTXT1'.
l_wa_sort-spos = '02'.
append l_wa_sort to it_sort.
l_wa_sort-fieldname = 'HRTXT2'.
l_wa_sort-spos = '03'.
append l_wa_sort to it_sort.
*--- call the list for output
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
i_callback_user_command = 'F_DOUBLE_CLICK' "SD0K963313
is_layout = l_wa_layout
it_fieldcat = it_fieldcat
it_sort = it_sort " You need pass this table for your case it will be customer field
i_save = l_save
is_variant = wa_variant1
it_events = it_events
tables
t_outtab = it_output
exceptions
program_error = 1
others = 2.
Thanks
Subhankar
01-06-2011 9:30 PM
Hi Subhankar,
As i mentioned i am done the same thing, made the field 'DO_SUM' as X but still it is not showing any thing.. Not even text is displaying. Do you think this should be working for time field (sy-uzeit). I tried this with quantity field it worked fine but when i am trying the same with time field it is not working.
Thanks & Regards,
Uday S.
01-06-2011 11:54 PM
Hi Uday,
Sorry to misjudge your question at first time. You can not do any subtotal in time field (sy-uzeit).
Suppose you have two values 14:07:58 and 15:10:49 then what will be the output. I think logically also its not possible.
Thanks
Subhankar
01-19-2011 10:18 AM
I found a solution for this. I programmed to append a new row at end of every customer and will calculate the subttoals manually and will append this row into the final table at end of every customer and will highlight this during ALV Display.
Regards,
Uday S.