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

Wrong Calculate Total Time

former_member212713
Contributor
0 Likes
1,710

I wrote a program. My purpose is calculate total time. But I dont know, this program calculate wrong total time.


REPORT ZZ_TEST .
DATA : LV1 TYPE FAHZTD,
       LV2 TYPE FAHZTD,
       LV3 TYPE FAHZTD,
       LV4 TYPE FAHZTD,
       LV5 TYPE FAHZTD,
       LV6 TYPE FAHZTD,
       LV7 TYPE FAHZTD,
       LVT TYPE FAHZTD.
LV1 = 3000.
LV2 = 3000.
LV3 = 10000.
LV4 = 4000.
LV5 = 5000.
LV6 = 2500.
LV7 = 3000.
LVT = LV1 + LV2 + LV3 + LV4 + LV5 + LV6 + LV7.
WRITE : LVT.

Result : 3:05 (wrong)

4:25 (correct)

Thank you for helping.

12 REPLIES 12
Read only

Former Member
0 Likes
1,622

Hi,

System is showing the correct time .. let us know how you arrived 4:25

Regards

JK

Read only

0 Likes
1,622

My system showed 3:05 . Which version your SAP?

Read only

0 Likes
1,622

LV1 = 3000. (30 min)

LV2 = 3000. (30 min)

LV3 = 10000. (1 hour) = (60 min)

LV4 = 4000. (40 min)

LV5 = 5000. (50 min)

LV6 = 2500. (25 min)

LV7 = 3000. (30 min)

total : 4 h 25 min or 265 min.

Read only

0 Likes
1,622

Hi,

You can use systtimlo instead of fahztd. Any particular reason you are using the same?

Hope it helps.

Sujay

Read only

0 Likes
1,622

Hi;

I want to calculate a lot of time. For example monthly machine downtime. Maybe one machine downtime total 48 hours. My customers want to see downtime items and total downtime on ALV.

Thanks.

Read only

Former Member
0 Likes
1,622

Hi,

You have specified these values, are they seconds?

I mean 3000 Seconds, 10000 Seconds? is it so?

if it is so, then...

3000 Seconds / 60 = 50 Minitues and

50 Minutes / 60 = 0.833 Hr

Am i getting right?

please don't mind, i am new to SAP.

Thanks and regards

from

Sachin.

Updated:

I know that we need to use SY-UZEIT while declarations, so I think Srini's codes will work.

Edited by: Sachin Bhatt IN on Oct 5, 2010 12:02 PM

Read only

Former Member
0 Likes
1,622

Hi,

Write the coding as :

DATA : LV1 TYPE sy-uzeit,

LV2 TYPE sy-uzeit,

LV3 TYPE sy-uzeit,

LV4 TYPE sy-uzeit,

LV5 TYPE sy-uzeit,

LV6 TYPE sy-uzeit,

LV7 TYPE sy-uzeit,

LVT TYPE sy-uzeit.

LV1 = '003000'.

LV2 = '003000'.

LV3 = '010000'.

LV4 = '004000'.

LV5 = '005000'.

LV6 = '002500'.

LV7 = '003000'.

LVT = LV1 + LV2 + LV3 + LV4 + LV5 + LV6 + LV7.

WRITE : LVT.

Regards,

Srini.

Read only

0 Likes
1,622

Yes, your solution correct but only for one day or 24 hours. I want to calculate maybe 5 days.


REPORT ZZ_TEST .
DATA : LV1 TYPE sy-uzeit,
LV2 TYPE sy-uzeit,
LV3 TYPE sy-uzeit,
LV4 TYPE sy-uzeit,
LV5 TYPE sy-uzeit,
LV6 TYPE sy-uzeit,
LV7 TYPE sy-uzeit,
LVT TYPE sy-uzeit.

LV1 = '003000'.
LV2 = '003000'.
LV3 = '220000'.
LV4 = '004000'.
LV5 = '005000'.
LV6 = '002500'.
LV7 = '003000'.

LVT = LV1 + LV2 + LV3 + LV4 + LV5 + LV6 + LV7.
WRITE : LVT.

Result : 00:25:00 (I think wrong)

25:25:00 (I want to show this time)

Read only

0 Likes
1,622

Hi,

It is very Basic Question i am Replying because every one is Confuse. Check the Bellow Sample Code.

DATA: LV1 TYPE p,
      LV2 TYPE p,
      LVT TYPE sy-uzeit.

LV1 = 3000 . " = 50 min
lv2 = 6000 . " = 100 min
LVT = LV1 + LV2. " 50 + 100 = 150 / 60 = 2 Hours and 30 Min 
"         (SY-UZEIT use Seconds for Calculation)
WRITE : LVT." here the output will (02:30:00) 

Regards,

Faisal

Edited by: Rob Burbank on Oct 5, 2010 9:25 AM

Read only

0 Likes
1,622

Please new code again run. If total time > 24 hours then reset time. But I dont want to reset time.

 
REPORT ZZ_TEST .
DATA: LV1 TYPE p,
      LV2 TYPE p,
      LVT TYPE sy-uzeit.

LV1 = 83000. " = 50 min
lv2 = 6000. " = 100 min
LVT = LV1 + LV2. " 50 + 100 = 150 / 60 = 2 Hours and 30 Min (SY-UZEIT
"use Seconds for Calculation)
WRITE : LVT." here the output will (02:30:00)

Read only

0 Likes
1,622

Hi ,

You need to write a small program using FM TIMESTAMP_DURATION_ADD.

For this declare a dummy variable with some timestamp say '20000101000001'.

DATA : TIMESTAMP_OUT TYPE TIMESTAMP ,

TIMESTAMP_IN TYPE TIMESTAMP ,

duration type i value 1440 . " duration should be in minutes only ....

diff(10) type C.

TIMESTAMP_IN = '20000101000001'. <-- a dummy value for input

CALL FUNCTION 'TIMESTAMP_DURATION_ADD'

EXPORTING

TIMESTAMP_IN = TIMESTAMP_IN

TIMEZONE = 'UTC'

DURATION = duration "<--- add all your minutes and pass here

UNIT = 'MIN' " <-- MIN ..

IMPORTING

TIMESTAMP_OUT = TIMESTAMP_OUT

EXCEPTIONS

TIMESTAMP_ERROR = 1

OTHERS = 2

.

diff = TIMESTAMP_OUT - TIMESTAMP_IN.

write 😕 diff. <-- now this has the time in Days , Hours , Minutes.

Regards,

Srini.

Read only

Former Member
0 Likes
1,622

Moderator message - Please see before posting. Do not ask basic date/time questions - post locked Rob