11-03-2016 6:04 PM - edited 01-21-2024 9:59 PM
Hi Experts ,
I have a requirement to convert date format (dd.mm.yyyy) to date value or integer format.
Input: 12/12/2014
Output: 40181630
I tried following FM but it is not working properly.
CONVERSION_EXIT_INVDT_OUTPUT
Please let me know if there is any other function module which will convert data format to date value.
Many thanks,
SK
11-04-2016 4:51 PM
DATA: integer_date TYPE i.
in_date = '12/12/2014'.
TRY.
cl_abap_datfm=>conv_date_ext_to_int(
EXPORTING
im_datext = in_date
IMPORTING
ex_datint = internal_date
).
CATCH cx_abap_datfm_no_date. "
CATCH cx_abap_datfm_invalid_date. "
CATCH cx_abap_datfm_format_unknown. "
CATCH cx_abap_datfm_ambiguous. "
ENDTRY.
integer_date = internal_date.
11-04-2016 1:00 AM
Hello Sivakiran, Maybe you should try FM: CONVERSION_EXIT_INVDT_INPUT
11-04-2016 5:56 AM
You may use either the RSDAT conversion routine (SAP Library: Conversion Routine RSDAT), or use the generic input conversion released function module RS_CONV_EX_2_IN.
11-04-2016 1:12 PM
A simple move of the date field to an integer will convert a date to an integer. (SAP use a difference in days from 01.01.1901 where some other O/S or software use other reference)
To convert an external format to integer there are many FM (e.g. SE37 look for CONVERSION_EXIT_*DATE*_INPUT) and methods (like those of class cl_abap_datfm, e.g.CONV_DATE_EXT_TO_INT) that use current user configuration or a parameter for expected or plausible date format.
Regards,
Raymond
11-04-2016 4:51 PM
DATA: integer_date TYPE i.
in_date = '12/12/2014'.
TRY.
cl_abap_datfm=>conv_date_ext_to_int(
EXPORTING
im_datext = in_date
IMPORTING
ex_datint = internal_date
).
CATCH cx_abap_datfm_no_date. "
CATCH cx_abap_datfm_invalid_date. "
CATCH cx_abap_datfm_format_unknown. "
CATCH cx_abap_datfm_ambiguous. "
ENDTRY.
integer_date = internal_date.