Skip to Content
0
Mar 05, 2009 at 10:11 AM

Time Split

69 Views

Dear Experts,

My report requires to calculate average of the time given. Now, when I calculate, it's giving me the correct output, however, it's not according to the time format.

e.g. The Result = 7.76

Correct Value should be 8.26 i.e. 8 hours and 26 mins

Is there any Function Module available for this?

My Logic is as follows, but not able to calculate it.

FORM time_split USING l_tim1

CHANGING l_tim2.

DATA: l_hrs TYPE i,

l_min TYPE p DECIMALS 2,

l_t1 TYPE i,

l_t2 TYPE i.

DATA: l_hr TYPE n,

l_mn TYPE n,

l_t3 TYPE n,

l_t4 TYPE n.

SPLIT l_tim1 AT '.' INTO l_hr l_mn.

l_hrs = l_hr.

l_min = l_mn.

IF l_min GE 60.

l_min = l_min / 60.

ENDIF.

l_mn = l_min.

SPLIT l_mn AT '.' INTO l_t3 l_t4.

l_t1 = l_t3.

l_t2 = l_t4.

l_hrs = l_hrs + l_t1.

l_hr = l_hrs.

l_t4 = l_t2.

CONCATENATE l_hr '.' l_t4 INTO l_tim2.

ENDFORM. " TIME_SPLIT