10-01-2015 8:24 AM
Dear All,
In my ALV report I have some fields which are showing times. The actual times are in minutes format which i have to show in hour format. So I have used some formulas and finally shown the values in hour : min format. To do this i have used data type as char. My report is ok. No problem with that. Now requirement is to show the totals of time fields. Do_sum in alv fieldcatlog not works. I have to add them manually. In my internal table i did the calculations on minutes fields and also converted them in hour : min format. But how to show them as total ?
My report looks like below.
Plant | Work center | Standard Hour | Total Time in Hour | Difference | |
1001 | GP.FBD01 | 120:00:00 | 24:50:00 | 95:10:00 | |
1001 | GP.CMP1 | 120:00:00 | 48:00:00 | 72:00:00 |
I need to show the totals of 4th & 5th column.
Thanks & regards.
10-01-2015 8:42 AM
Hi,
So for '24:50:00' and '48:00:00' display as 72:50:00 right?
If yes you can split each time at ':' and calculate the individual sum and again concatenate;
Example : split '24:50:00' at ':' into val1 val2 val3.
split '48:00:00' at ':' into val3 val4 val5.
now you can add them as val1+val3 , val2 + val4, val3 + val5. and concatenate each with ':' at the end.
Try to implement this ( still needs to take care of some issues ) just try 🙂
Regards,
Nagendra
10-01-2015 9:07 AM
Dear Nagendra,
Thanks for your reply. I can add them in my internal table. But displaying as total in ALV grid is not working. Since char fields can not be summed.
With regards.
10-01-2015 10:08 AM
10-01-2015 10:51 AM
Thanks again.
Actually I need to keep the format as it is. In my internal table i took the values as quantity and can sum up. Also can show that value in hour: min format. But had to assign a different field for that. Problem is showing this sum as Total in ALV. I need some tricks to do this. Any guess ?
With regards.
10-01-2015 11:07 AM
Hi,
Take an empty line in the final internal table and pass that value , will it be possible?
10-01-2015 12:06 PM
Hi,
Is this the correct way forward? The empty line can show the total. But how will you make sure it is the final line. And how will it behave by a GROUP BY, FILTER, DOWNLOAD or SORT done by the user. And there are other totals which have the real ALV aggregate functionality.
Or either you use a data type which suports aggregates or you choose a different report style. Like using the ALV Hierarchy or may the old WRITE statement.
Have a look at program: BCALV_TEST_HIERSEQ_LIST
Cheers,
Henk.
10-01-2015 12:18 PM
Hi,
I dont think it is possible. Because to show total I need to use the same field. Isn't it ? Is there any use of ALV footer ?
10-01-2015 12:22 PM
Hi,
Thanks for your reply. The option you told earlier seems good but I need to show time format like hour:min . So cant try that option. Otherwise it was good. Can using footer make any help ?
With regards.
10-01-2015 8:44 AM
Hi,
In ALV aggregate functions are not possible on CHAR (or other character) fields. The best option is to show everything as a NUMC or decfloat. Then you can do a SUM.
In reports like CADO SAP does it that way. Display you result in hours with 2 decimals. And then you can use the SUM function.
See documentation of class CL_SALV_AGGREGATIONS for details.
Cheers,
Henk.
10-01-2015 12:49 PM
Which ALV class are you using, depending on this you should now find some event/method than allow access to subtotal values and refresh of displayed data (from grid_after_refresh event to method as get_subtotals and refresh_table_display to cl_salv_aggregations class)
Regards,
Raymond