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

Converting seconds values

Former Member
0 Likes
2,191

Hi All,

I have values in fields KAKO-BEGZT (Start time in seconds (internal)) and KAKO-ENDZT (Finish time in seconds (internal)) which I want to convert into HH:MM:SS format.

Is there any FM existing. Or if anyone can tell me the logic of converting this value into HH:MM:SS format.

Problem is I don't know in which format data is stored in fields KAKO-BEGZT and KAKO-ENDZT.

Regards,

Pawan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,371

Hi Pawan,

1. MONI_TIME_CONVERT

This FM will solve your problem.

Regards,

Amit M.

5 REPLIES 5
Read only

Former Member
0 Likes
1,371

Hi use this FM..

CONVERT_TIME_INPUT.

thanks

vijay

Read only

0 Likes
1,371

convert_time_input is converting time from external user format to internal SAP format.

to convert seconds into hours, mins and secons.

you can use the following code sample.

data: output type string .

parameters: p_time type i .


data: wl_hours   type i,
        wl_minutes type i,
        wl_seconds type i,
        wl_hr_rem  type i,
        wl_min_rem type i,
        wl_min(4)  type p decimals 2,
        wl_sec(4)  type p decimals 2 .

start-of-selection .

clear: wl_hours,
         wl_minutes,
         wl_seconds,
         wl_hr_rem,
         wl_min_rem,
         wl_min,
         wl_sec .
  wl_hours = p_time div 3600.

  wl_hr_rem = p_time mod 3600.

  wl_minutes = wl_hr_rem div 60.

  wl_min_rem = wl_hr_rem mod 60.

  wl_seconds = wl_min_rem.

  wl_sec = wl_seconds / 60.

  wl_min = ( wl_minutes + wl_sec ) / 100.
  if wl_min = '0.60'.
  wl_hours = wl_hours + 1.
  clear wl_min.
  endif.

Regards

Raja

Read only

Former Member
0 Likes
1,371

Hi pawan,

1. try this code (just copy paste)

2. On selection screen enter number of seconds.

it will give output in HH:MM:SS

REPORT abc.

*----


DATA : mytime(8) TYPE c.

PARAMETERS : begzt LIKE kako-begzt DEFAULT '45000'.

PERFORM gettime USING begzt CHANGING mytime.

WRITE 😕 mytime.

*----


FORM gettime USING sec CHANGING tm.

DATA : hh(2) TYPE n.

DATA : mm(2) TYPE n.

DATA : ss(2) TYPE n.

DATA :remsec(10) TYPE n.

hh = sec / 3600.

remsec = sec - ( 3600 * hh ).

mm = remsec / 60 .

remsec = sec - ( 60 * mm ).

ss = remsec.

CONCATENATE hh ':' mm ':' ss INTO tm.

ENDFORM. "gettime

regards,

amit m.

Read only

Former Member
0 Likes
1,372

Hi Pawan,

1. MONI_TIME_CONVERT

This FM will solve your problem.

Regards,

Amit M.

Read only

Former Member
0 Likes
1,371

Hi,

pls award points if any answers have been helpful.

regards,

amit m.