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: 

Hours calculation

Former Member
0 Kudos
190

All,

I wanted to add the hours into Time field. For example:

I have the Time 083000 (HH:MM:SS) & number of hours 4.30 (This may vary at runtime). I wanted to add the 4.30 into 083000. How can i do that?

BM

1 ACCEPTED SOLUTION

Former Member
0 Kudos
134

Use this FM

C14B_ADD_TIME

Importing

I_STARTTIME 08:30:00

I_STARTDATE

I_ADDTIME 04:30:00

-Pavan

12 REPLIES 12

Former Member
0 Kudos
135

Use this FM

C14B_ADD_TIME

Importing

I_STARTTIME 08:30:00

I_STARTDATE

I_ADDTIME 04:30:00

-Pavan

0 Kudos
134

Thanks. but in my case the format is 4.30 not 04:30:00. I cant use this FM.

BM

former_member156446
Active Contributor
0 Kudos
134

I did a similar for dates with months check it might be helpful

IF pa_older = 'X'.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

date = pa_end

days = '00'

months = '06'

signum = '-'

years = '00'

IMPORTING

calc_date = pa_end.

ENDIF.

Former Member
0 Kudos
134

Hi,

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,

Sriram Ponna.

0 Kudos
134

sriram,

if i use stdaz = '4.30' the output is not correct. Can you help me?

BM

0 Kudos
134

Hi,

I am getting exact result as expected.

Can you please go to se37 and test the FM, you can find it.

Thanks,

Sriram Ponna.

0 Kudos
134

ok i wanted to add 4 hours 30 mins to the TIme 08:30:00. I get the output as 12:36:00. I suppoed to get 13:00:00.

Hope this is clear.

BM.

0 Kudos
134

Let me see once again.

0 Kudos
134

Hi,

I can see the issue, I donno why it showing 12 seconds less.

Sri.

0 Kudos
134

I suppose RP_CALC_DATE_IN_INTERVAL have that capability..

0 Kudos
134

Hi,

I donno how far i am correct, after analysis I found below :

I think 4.30 mins means 4 and half hours. In general we will write it as 4.5. In the code I have give if you change it to 4.5.

Similarly for 4.15 mins we can write it as 4.25(quater of 60 mins) 4.25 you will get 4:15 mins.

You will get the exact result.

I may be wrong in this case, just do analysis with the above.

Thanks,

Sriram Ponna.

Former Member
0 Kudos
134

All,

I solved with below logic:

+SPLIT V_STR AT '.' INTO V_MIN V_SEC.

IF STRLEN( V_MIN ) = 1.

CONCATENATE '0' V_MIN INTO V_MIN.

ENDIF.

CONCATENATE V_MIN V_SEC '00' INTO V_HRS.

T_TIMES = V_HRS.

TO_TIME = FROM_TIME + T_TIMES.+

Thanks for all your help.

BM