Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

code sniplet

Former Member
0 Likes
647

Hello!

Who can show me the usage of

'CONVERT_DATE_TO_INTERNAL' with a code sniplet?

Regards

sas

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
616

Hi,

Please refer below code:


     " system conversion - date format in user master record.
            CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
              EXPORTING
                date_external            = p_val
              IMPORTING
                date_internal            = p_field
              EXCEPTIONS
                date_external_is_invalid = 1
                OTHERS                   = 2.
            IF sy-subrc <> 0.
              MOVE sy-subrc TO p_rc.
              EXIT.
            ENDIF.

Thanks,

Sriram Ponna.

5 REPLIES 5
Read only

Former Member
0 Likes
617

Hi,

Please refer below code:


     " system conversion - date format in user master record.
            CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
              EXPORTING
                date_external            = p_val
              IMPORTING
                date_internal            = p_field
              EXCEPTIONS
                date_external_is_invalid = 1
                OTHERS                   = 2.
            IF sy-subrc <> 0.
              MOVE sy-subrc TO p_rc.
              EXIT.
            ENDIF.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
616

Hi,

DATA : DATE LIKE SY-DATUM.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
       EXPORTING
            DATE_EXTERNAL            = '31.03.1999'
       IMPORTING
            DATE_INTERNAL            = DATE
       EXCEPTIONS
            DATE_EXTERNAL_IS_INVALID = 1
            OTHERS                   = 2.

OUTPUT WILL BE

DATE = '19990331'.

Regards,

V.Balaji

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Mar 27, 2008 12:36 PM

Read only

Former Member
0 Likes
616

Hi,

data : date1 like sy-datum value '20080101',

date2(10).

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

date_external = date1

IMPORTING

date_internal = date2

EXCEPTIONS

date_external_is_invalid = 1

OTHERS = 2.

date2 will be 01.01.2008.

Regards,

Sanki.

Read only

Former Member
0 Likes
616

Balaji V thank u but what happens

if the user has set his date format

to MM/DD/YYYY instead of 'DD.MM.YYYY'

like your example in your posting ???

DATA : DATE LIKE SY-DATUM.
 
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
       EXPORTING
            DATE_EXTERNAL            = '03/31/1999'
       IMPORTING
            DATE_INTERNAL            = DATE
       EXCEPTIONS
            DATE_EXTERNAL_IS_INVALID = 1
            OTHERS                   = 2

Read only

0 Likes
616

I tested the function in SE37 with your 12/31/1999 as input and the result was 19991231