cancel
Showing results for 
Search instead for 
Did you mean: 

Time Calculation

former_member203627
Participant
0 Kudos

Hi,

I have a scenario where I have to add time. For example

07:40:00 to 102 mins and 102 means 1 hr and 2 mins which should be 08:42:00 but if we add this we get 08:42:00.

Another example if we have to add 07:40:00 to 80 mins means 1 hr 20 mins which should be 09:00:00.

Is there any function module which can interperate 80 mins as 1 hr 20 mins or 102 mins to 1 hr and 2 mins.

Regards

Hema

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Ria,

There is a function Module which can convert seconds to the standard format. For eg: if we give 120 as the input value, it will give the output as 00:02:00, which is 2 mins.

The name is CONVERT_TIME_INPUT.

Check this code.

REPORT ztest_shail .

data: a type sy-uzeit,

c type sy-uzeit.

a = 120 .

CALL FUNCTION 'CONVERT_TIME_INPUT'

EXPORTING

input = A

  • PLAUSIBILITY_CHECK = 'X'

IMPORTING

OUTPUT = C

  • EXCEPTIONS

  • PLAUSIBILITY_CHECK_FAILED = 1

  • WRONG_FORMAT_IN_INPUT = 2

  • OTHERS = 3

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

write c.

Hope your query is solved.

Regards,

SP.

Former Member
0 Kudos

Hi,

Convert the minutes you want to add to the time as seconds and then you can add straightforwardly.

DATA time LIKE sy-uzeit.
DATA min TYPE i.
DATA sec TYPE i.

min = 80.
time = sy-uzeit.
sec = min * 60.       "Convert to seconds
time = time + sec.    "Add to the time

Regards,

Wenceslaus.