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

Adding hours together

Former Member
0 Likes
920

I am trying to total a list of hours.

Adding 2:20 to 2:57 using the statement add a to b gives me a total of 4:77 rather than the expected 5:17 because it is treating the numbers as decimals rather than hours.

The variables are declared like fahztd.

I have tried using fm C14B_ADD_TIME. This is fine unless the total of the two fields is over 24 hours. ie if I add 12:00 + 13:00 it returns 1:00.

5 REPLIES 5
Read only

Former Member
0 Likes
775

check out this function module:

DIMP_ADD_TIME

may it is useful.

Read only

0 Likes
775

I can't find DIMP_ADD_TIME. Is this new to later versions than 4.7?

Read only

0 Likes
775

Consider this option.


REPORT yptc_goof3 .

DATA:
  s_time LIKE sy-uzeit,
  e_time LIKE sy-uzeit,
  a_time LIKE sy-uzeit,
  s_date LIKE sy-datum,
  e_date LIKE sy-datum,
  e_days TYPE p.

s_time = '022000'.
a_time = '235700'.
s_date = '00010101'.

CALL FUNCTION 'C14B_ADD_TIME'
     EXPORTING
          i_starttime = s_time
          i_startdate = s_date
          i_addtime   = a_time
     IMPORTING
          e_endtime   = e_time
          e_enddate   = e_date.

e_days = e_date - s_date.

WRITE:/ 'Days', e_days, 'Hours', e_time.

Out put is :

Days 1 Hours 02:17:00

Read only

0 Likes
775

that one is new one we are using ECC 6.0

Read only

Former Member
0 Likes
775

HI,


  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,

Sriram Ponna.