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

Function Module for converting seconds into hours and minutes

Former Member
0 Likes
11,837

Hi

Can any one tell me function module name for converting seconds in to hours and minutes ..

Regards

Hi

Can any one tell me function module name for converting seconds in to hours and minutes ..

Regards

6 REPLIES 6
Read only

Former Member
0 Likes
5,165

See the simple Example -

report test.

data: sec type i value 10920,

hh,

mm,

ss,

temp type i,

sep type c value ':',

time(20) type c.

hh = sec div 3600.

temp = sec mod 3600.

mm = temp div 60.

ss = temp mod 60.

concatenate hh sep mm sep ss into time.

You can use the function module CONVERSION_EXIT_SDURA_OUTPUT

This function module takes minutes as input and gets the time back in HH:MM format.

So convert the seconds into minutes by dividing by 60, and call the function.

Thanks

Seshu

Read only

0 Likes
5,165

Thnks for the reply

i did in the same way .. earlier but it rounds the figure for example if there is 23.45

it makes ir 24.00 round,

Pls look the below code and tell me where iam wrong .

actually iam doing a equipment report in pm module ....

for that i have to capture the time of equipment on batch process

so this time iam converting ins seconds .

w_addtime has total number of seconds.

perform convert using w_addtime .

FORM convert CHANGING w_time.

DATA: w_str1(10) ,

w_str2(10) ,

w_str3(10) ,

w_str4(10) ,

w_hrsad(10),

w_hrsadd(10).

w_str1 = w_time DIV 3600 .

w_str2 = w_time MOD 3600 .

CONDENSE: w_str1 ,

w_str2 .

IF w_str2 > 0 AND w_str2 > 59.

w_str3 = w_str2 DIV 60 .

w_str4 = w_str2 MOD 60 .

CONDENSE: w_str3 ,

w_str4 ,

w_str2 .

w_str1 = w_str1 . "+ w_str3 .

w_str2 = w_str3 . "w_str4 .

CONDENSE: w_str1 ,

w_str2 .

CONCATENATE: w_str1 '.' w_str2 INTO w_time .

ELSE.

CONCATENATE: w_str1 '.' w_str2 INTO w_time .

ENDIF .

SPLIT w_time AT '.' INTO w_hrsad w_hrsadd.

IF w_hrsadd = 0 .

w_time = w_hrsad.

ENDIF .

ENDFORM. " convert

and lastly very important if i want to minus ...time supoose totime -fromtime of equipment

13.01.00 - 24.00.00

when i want to convert 24 hrs seconds it give wrong result why so ...

answers will be rewarded points

Read only

0 Likes
5,165

Check with below code and i used FM :

data: sec type i value 10920. " Seconds

data time(20) type c.

sec = sec / 60. " -> converting minutes

CALL FUNCTION 'CONVERSION_EXIT_SDURA_OUTPUT'

EXPORTING

INPUT = sec

IMPORTING

OUTPUT = time

.

write time.

Thanks

Seshu

Read only

0 Likes
5,165

First of all you should not perform computations using character types.

>Pls look the below code and tell me where iam wrong .

>DATA: w_str1(10) ,

>w_str2(10) ,

>w_str3(10) ,

>w_str4(10) ,

>w_hrsad(10),

>w_hrsadd(10).

Read only

0 Likes
5,165

hi Farukh,

Refer this thread

Regards,

Santosh

Read only

Former Member
0 Likes
5,165

You can use the function module CONVERSION_EXIT_SDURA_OUTPUT

This function module takes minutes as input and gets the time back in HH:MM format.

So convert the seconds into minutes by dividing by 60, and call the function.

or use

DATA: lv_hours TYPE i,

lv_minutes TYPE i,

lv_seconds TYPE i.

lv_hours = lv_seconds / 3600.

lv_seconds = lv_seconds - lv_hours * 3600.

lv_minutes = lv_seconds / 60.

lv_seconds = lv_seconds - lv_minutes * 60.

Concatenate all the fields into a variable. And display that variable using below write statement.

WRITE (8) TIME USING EDIT MASK '__:__:__'. "Output: 15:46:33