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: 

Time Calc

Former Member
0 Kudos

Hi friends, how are you ? i need a function to sum hours, for exemple:

12:30:00 + 14:45:30 = 27:15:30

or

01:15:00 + 04:00:00 = 05:19:00

Can you help me ?

Thanks !

8 REPLIES 8

Former Member
0 Kudos

hi

good

You can use FM CATT_ADD_TO_TIME.

data : time like sy-uzeit.

CALL FUNCTION 'CATT_ADD_TO_TIME'

EXPORTING

idate = sy-datum

itime = sy-uzeit

stdaz = '4.00'

IMPORTING

EDATE =

ETIME = time

thanks

mrutyun^

former_member194669
Active Contributor
0 Kudos

report  zars no standard page heading
        line-size 170
        line-count 65(4).
data : time1 like sy-uzeit.
data : time2 like sy-uzeit.
data : time3 like sy-uzeit.

time1 = '123000'.
time2 = '144530'.

time3 = time1 + time2.

write : time3.

0 Kudos

I need sum more times for example:

12:00:05 + 12:00:10 + 15:00:00 + 23:00:30 = 62:00:45

Thanks !

0 Kudos

HI,

I think this may not possible, system always calculate in 24 hrs pattern only.

Thanks,

Sri.

0 Kudos

Check this


report  zars no standard page heading
        line-size 170
        line-count 65(4).
data : begin of itab occurs 0,
       time like sy-uzeit.
data : end of itab.

data : tottime like sy-uzeit.
data : n type i, tothrs type i.
data : hrs type i, min type i, secs type i.

itab-time = '123000'.
append itab.

itab-time = '120010'.
append itab.

itab-time = '625000'.
append itab.

loop at itab.
  tottime = tottime + itab-time.
  n = itab-time+0(2).
  tothrs = tothrs + n.
endloop.

hrs = tothrs.
min = tottime+2(2).
secs = tottime+4(2).

write 😕 'total time : ' , (2)hrs no-gap,
                       ':' no-gap,(2)min no-gap,
                       ':' no-gap,(2)secs no-gap.

0 Kudos

Thanks for all.

Former Member
0 Kudos

Hi,

Please use the FM C14B_ADD_TIME.

Thanks,

Sri.

Former Member
0 Kudos

Hello,

You can use the logic below:

Time1 type sy-uzeit,

Time2 type sy-uzeit,

time_final type char8,

var1 type i,

var2 type i,

var3 type i,

var4 type i,

var5 type i,

var1 = time1+6(2).

var2 = time2+6(2).

var3 = var1 + var2.

var4 = var3 / 60.

var_sec = var3 % 60.

var1 = time1+3(2).

var2 = time2+3(2).

var3 = var1 + var2 + var4.

var4 = var3 / 60.

var_min = var3 % 60.

var1 = time1(2).

var2 = time2(2).

var_hr = var1 + var2 + var4.

concatenate var_hr var_min var_sec separated by ':' into time_final.

Enjoy!