Application Development 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: 

Problem in showing Totals of time fields in ALV report.

former_member308418
Participant
0 Kudos

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.

PlantWork centerStandard HourTotal Time in HourDifference
1001GP.FBD01120:00:0024:50:0095:10:00
1001GP.CMP1120:00:0048:00:0072:00:00

I need to show the totals of 4th & 5th column.

Thanks & regards.

10 REPLIES 10

Former Member
0 Kudos

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

0 Kudos

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.

0 Kudos

Hi,

Check this thread may help https://scn.sap.com/thread/84971 ..

Regards,

Nagendra

0 Kudos

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.

0 Kudos

Hi,

Take an empty line in the final internal table and pass that value , will it be possible?

0 Kudos

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.

0 Kudos

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 ?

0 Kudos

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.

henk_verdaasdonk4
Active Participant
0 Kudos

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.

raymond_giuseppi
Active Contributor
0 Kudos

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