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

Time format

Former Member
0 Likes
732

is there any function module for time conversion.

Eg. if my input is mm:hh:ss

output must be hh:mm:ss

i should not change the user setting in SU01 i want to do it by program.

Thanks in advance

5 REPLIES 5
Read only

Former Member
0 Likes
645

Try these FM:

TIME_CHAR_CONVERSION

CONVERT_TIME_INPUT

Plz Reward Points if helpful

Read only

Former Member
0 Likes
645

hi,

try using this function module

' CONVERT_TIME_INPUT'

hope this helps.

pls reward if helpful.

Read only

Former Member
0 Likes
645

hi,

try this fm .

pass the time in seconds as input parameter.

RSSM_CONVERT_DAYSEC2TIMESTAMP.

otherwise split the time into three variables as mm ss hh

and concatenate it.

Read only

Former Member
0 Likes
645

if you are sure of your input then you can simply use offset functionality to modify to your desired options.

For Eg

data : input type t, output type t.

input = MMHHSS

concatenate input2(2) input0(2) input+4(2) into output.

hope this helps

Raj

Read only

Former Member
0 Likes
645

I think if u refer the field to a time field then an error is triggered at the selection screen itself asking for a valid time format .

so in case your input is MMHHSS then i suppose you need to go for a logic as said above and dont forget to check the time plausibility.

the code will be like

parameters : p_time(6) type c .  "if the input is mmhhss
data : time(6) type c.
data : len type i.

data : tim like sy-uzeit.

data : mm(2) type c, hh(2) type c,ss(2) type c.
len = strlen( p_time ).
if len < 6 .
message e999 with 'Invalid Input'.
endif.
mm = p_time+0(2) .
hh = p_time+2(2) .
ss = p_time+4(2) .


concatenate HH MM SS INTO TIME .
tim = time.


CALL FUNCTION 'TIME_CHECK_PLAUSIBILITY'
  EXPORTING
    time                           = tim
 EXCEPTIONS
   PLAUSIBILITY_CHECK_FAILED       = 1
   OTHERS                          = 2
          .
if sy-subrc eq 0.
write:/ tim.
endif.

*if p_time+0(2) gt 59 .
*   p_time+0(2) = 59.
*endif.
*if p_time+4(2) gt 59 .
*   p_time+4(2) = 59.
*endif.
you need to handle this scenario.

regards,

vijay.