Skip to Content
-1

Function module to convert date format (dd.mm.yyyy) to date value or integer format.

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Nov 04, 2016 at 04: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.
     
    Add comment
    10|10000 characters needed characters exceeded

  • Nov 04, 2016 at 01: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

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 04, 2016 at 05: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.

    Add comment
    10|10000 characters needed characters exceeded