‎2011 Sep 19 7:22 AM
hi
I want to convert time between internal and external by parameter 'XUTIMEFM'. is there any good method? ps: 'cl_abap_timefm' have method 'conv_time_int_to_ext', but it does not match my requirement , i need convert time by date element 'XUTIMEFM'. thanks
‎2011 Sep 19 8:26 AM
‎2011 Sep 19 8:09 AM
Hi,
Could you please elaborate on the parameter mentioned? Is it a time zone?
Just check the below FMs.
CONVERT_DATE_TO_EXTERNAL
CONVERT_DATE_TO_INTERNAL
PCA_CONVERT_DATE_EXTERNAL
PCA_CONVERT_DATE_INTERNAL
If the parameter is time zone you can use the below syntax.
CONVERT TIME STAMP time_stamp TIME ZONE tz
INTO [DATE dat] [TIME tim]
[DAYLIGHT SAVING TIME dst].
‎2011 Sep 19 8:24 AM
in T-CODE su01, user can set defaults on time format. this field uses data element 'XUTIMEFM'. i just want to convert time by import parameter type 'XUTIMEFM'. this data element is not time zone and is for time fromat
because user can have different choise on time format, so i can't use 'write environment time format'.
Edited by: Wang Lin Hu on Sep 19, 2011 9:24 AM
‎2011 Sep 19 8:26 AM
‎2011 Sep 19 8:31 AM
‎2011 Sep 19 10:25 AM
hi,
try this code and after tests embedd it into your classes or subroutine:
...
REPORT Z_TIME_CONVERT_LLM.
PARAMETERS: p_time type tims,
P_period(2) type c, "PM, pm, AM, am.
p_format type XUTIMEFM.
START-OF-SELECTION.
data: g_output_time TYPE tims,
g_hour(2) TYPE n,
g_minuts(2) TYPE n,
g_seconds(2) type n,
c_code(2) type c.
g_hour = p_time(2).
g_minuts = p_time+2(2).
g_seconds = p_time+4(2).
case p_format.
when 0.
if g_hour = '00' and p_period = 'PM' . add 12 to g_hour . ENDIF.
when 1 or 2.
if g_hour = '00' and ( p_period = 'PM' or p_period = 'pm' ).
add 12 to g_hour . ENDIF.
if g_hour > 12 and ( p_period = 'PM' or p_period = 'pm' ).
sUBTRACT 12 FROM g_hour . ENDIF.
when 3 or 4.
if g_hour ge 12 and ( p_period = 'PM' or p_period = 'pm' ).
sUBTRACT 12 FROM g_hour . ENDIF.
ENDCASE.
g_output_time(2) = g_hour.
g_output_time+2(2) = g_minuts.
g_output_time+4(2) = g_seconds.
WRITE: g_output_time, ' ', p_period .
‎2011 Sep 19 10:49 AM
‎2015 Apr 29 6:32 PM
Hi ,
please have a look to the services provided in package SABP_CONVERT.
For you are the services of CL_ABAP_TIMEFM interesting especially CL_ABAP_TIMEFM=>CONV_TIME_EXT_TO_INT/CONV_TIME_INT_TO_EXT
Furthermore to this classes AUnits are attached demonstrating how to use these methods.
This thread is quite old, but may be interesting for people working with web search engines.
Regards, Jürgen