Skip to Content
-1

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

Nov 03, 2016 at 06:04 PM

331

avatar image

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

10 |10000 characters needed characters left characters exceeded
Former Member

Hello Sivakiran, Maybe you should try FM: CONVERSION_EXIT_INVDT_INPUT

1
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Raghu Govindarajan Nov 04, 2016 at 04:51 PM
0
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.
 
Share
10 |10000 characters needed characters left characters exceeded
Raymond Giuseppi
Nov 04, 2016 at 01:12 PM
1

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

Share
10 |10000 characters needed characters left characters exceeded
Sandra Rossi Nov 04, 2016 at 05:56 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded