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: 

calculate time and Demurages

Former Member
0 Kudos

Hello Friends,

I am making one program, Program is one truck is entering at 7:30 A.M. and it is exiting at 7:25 P.M. I want to calculate time in hours and minutes like(11 hours 55 minutes) from entring to exiting also want to calculate wages on the basis of hours and minutes......

Please guide me as soon as possible......

Waiting For positive response

1 ACCEPTED SOLUTION

karol_seman
Active Participant
0 Kudos

Hi Shelly,

this code put into begenning:


data: time_in like sy-uzeit.
data: time_out like sy-uzeit.
data: time_total type i.
data: time_hours type i.
data: time_min type i.

time_in = sy-uzeit.

now process your program and then execute the code below



time_out = sy-uzeit.

time_total = time_out - time_in.

time_hours = time_total div 3600.

time_min = time_total - ( 3600 * time_hours ).
time_min = time_min div 60.

write: / 'hours:', time_hours, 'min:', time_min.

you get time spent during execution of program.

Regards,

Karol

5 REPLIES 5

karol_seman
Active Participant
0 Kudos

Hi Shelly,

this code put into begenning:


data: time_in like sy-uzeit.
data: time_out like sy-uzeit.
data: time_total type i.
data: time_hours type i.
data: time_min type i.

time_in = sy-uzeit.

now process your program and then execute the code below



time_out = sy-uzeit.

time_total = time_out - time_in.

time_hours = time_total div 3600.

time_min = time_total - ( 3600 * time_hours ).
time_min = time_min div 60.

write: / 'hours:', time_hours, 'min:', time_min.

you get time spent during execution of program.

Regards,

Karol

Former Member
0 Kudos

Hi,

There are many FMs for calculating difference between time.

Eg- TIMECALC_DIFF

For using this you need to timestamp the Entry and Exit date, time with timezone.

then give it to this FM. It will calculate the difference in seconds

Cheers,

Kothand

saranwin
Contributor
0 Kudos

Hi,

Try this Code :

DATA : entry_time type syuzeit.

DATA : exit_time type syuzeit.

tot_time : entry_time - exit_time.

it will give you the total working time.

Regards,

Saran

former_member387317
Active Contributor
0 Kudos

Hi shelly Malik,

Use FM

SD_CALC_DURATION_FROM_DATETIME

Pass paramters like

I_DATE1 16.09.2008

I_TIME1 10:33:00

I_DATE2 16.09.2008

I_TIME2 19:00:00

and you will get the result as below..

E_TDIFF 8:27

8 hours and 27 minutes...

Use Offsets and get the hour and minute value from E_TDIFF

Now u can use this values of hours and minutes to get the exact wage type values... get the details from HR module and multiply it with the hours and minute and calculate it...

Hope it will solve your problem..

Thanks & Regards

ilesh 24x7

Subhankar
Active Contributor
0 Kudos

Hi..

Please do in this way...

In the beginning of START-OF-SELECTION the current time as..

v_entry_time = sy-uzeit,

When you want to display the time diff.(END OF SELECTION)

v_time_diff = sy-uzeit - v_entry_time.

And display v_time_diff