Application Development and Automation 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: 
Read only

Time Sum Problem

Former Member
0 Likes
918

Hi ABAP Guru's,

I need to find the sum of time units in my internal table.

the data i get from the database is in the format 22 :50:00 and 10:00:00 like wise.

i have to add all the enteries for the same to show the talal number of hr and mint. as 32:50:00 in the internal table.

Plz help me out in the problem......Points fully ensured..

Regards...

Lakhan..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
846

you can store in variables of type T and then add the times (normal addition).

This will give you 325000 (after adding 22:50:00 and 10:00:00 - first store these in a type )

then you can add the colons ( accordingly.

sample code :

data : tm1 type t.

loop at itab into wa.

tm1 = tm1 + wa-time. "name of the field is "time"

endloop.

now tm1 holds the value of time field summed up.

now you can store it again in a variable for proper format

data tm2 type sy-uzeit.

tm2 = tm1.

tm2 now holds the time in proper format.

regards,

Priyank

Message was edited by:

Priyank Jain

Message was edited by:

Priyank Jain

4 REPLIES 4
Read only

Former Member
0 Likes
846

hi,

u can try using Offset.

Split the time field into 3 parts.

sum them individually.

and then again concatenate in the required format

Regards,

Preeti

Read only

0 Likes
846

thankx Preeti.

Can u give me code for the same....

i need it urgently.

Regards Lakhan

Read only

Former Member
0 Likes
847

you can store in variables of type T and then add the times (normal addition).

This will give you 325000 (after adding 22:50:00 and 10:00:00 - first store these in a type )

then you can add the colons ( accordingly.

sample code :

data : tm1 type t.

loop at itab into wa.

tm1 = tm1 + wa-time. "name of the field is "time"

endloop.

now tm1 holds the value of time field summed up.

now you can store it again in a variable for proper format

data tm2 type sy-uzeit.

tm2 = tm1.

tm2 now holds the time in proper format.

regards,

Priyank

Message was edited by:

Priyank Jain

Message was edited by:

Priyank Jain

Read only

0 Likes
846

Hi,

Please check the code given below

types:begin of ty_time_ext,

time(8) type c,

end of ty_time_ext.

data:tb_time_ext type standard table of ty_time_ext,

wa_time_ext like line of tb_time_ext.

data:wf_time(6) type n,

wf_time_total(8) type n.

wa_time_ext-time = '22:50:00'.

append wa_time_ext to tb_time_ext.

wa_time_ext-time = '10:00:00'.

append wa_time_ext to tb_time_ext.

loop at tb_time_ext into wa_time_ext.

concatenate wa_time_ext-time+0(2)

wa_time_ext-time+3(2)

wa_time_ext-time+6(2)

into wf_time.

wf_time_total = wf_time_total + wf_time.

endloop.

<b>1) You cannot use TIME VARIABLE for storing the TOTAL and SUMMING up.. .SAP will automatically convert the Total time into days.

eg. if time is 20:00:00 and 10:00:00 and you add it ... SAP will store the sum as

06:00:00 and not 30:00:00.

2) You cannot use TIME variables as your internal table can have A lot of entries so the SUM Can exceed 6 characters.</b>

Regards,

Abhishek