‎2007 Jan 18 10:32 AM
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
‎2007 Jan 18 10:43 AM
Try these FM:
TIME_CHAR_CONVERSION
CONVERT_TIME_INPUT
Plz Reward Points if helpful
‎2007 Jan 18 10:43 AM
hi,
try using this function module
' CONVERT_TIME_INPUT'
hope this helps.
pls reward if helpful.
‎2007 Jan 18 10:51 AM
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.
‎2007 Jan 18 10:52 AM
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
‎2007 Jan 18 11:18 AM
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.