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

character date conversion to sap internal format

Former Member
0 Likes
1,872

Hi ,

I want to convert character date to internal sap format

say I have chardate -- 25/07/2007

i have to convert it to sap Internal 20070725

thanks

bobby

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,170

Hi Bobby,

Since your Date format is not decided(xyz format), I think you need to decide your approach.

To dispaly the Date form System Format to User Format the FM 'CONVERT_DATE_TO_EXTERNAL' is used.

Consider this code.

REPORT zztest_arun_2.

DATA: e_date(10) type c VALUE '2/2/2006',

i_date(10).

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

date_external = e_date

IMPORTING

date_internal = i_date

EXCEPTIONS

date_external_is_invalid = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

WRITE : / 'CONVERT_DATE_TO_INTERNAL',

/ 'My Date:' , e_date ,

'Conv Date:', i_date.

skip 2.

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

DATE_INTERNAL = sy-datum

IMPORTING

DATE_EXTERNAL = e_date

EXCEPTIONS

DATE_INTERNAL_IS_INVALID = 1

OTHERS = 2

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

WRITE : / 'CONVERT_DATE_TO_EXTERNAL',

/ 'My Date:' , sy-datum,

'Conv Date:', e_date.

Thanks,

Reward If Helpful.

Hi ,

I want to convert character date to internal sap format

say I have chardate -- 25/07/2007

i have to convert it to sap Internal 20070725

thanks

bobby

8 REPLIES 8
Read only

Former Member
0 Likes
1,171

Hi Bobby,

Since your Date format is not decided(xyz format), I think you need to decide your approach.

To dispaly the Date form System Format to User Format the FM 'CONVERT_DATE_TO_EXTERNAL' is used.

Consider this code.

REPORT zztest_arun_2.

DATA: e_date(10) type c VALUE '2/2/2006',

i_date(10).

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

date_external = e_date

IMPORTING

date_internal = i_date

EXCEPTIONS

date_external_is_invalid = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

WRITE : / 'CONVERT_DATE_TO_INTERNAL',

/ 'My Date:' , e_date ,

'Conv Date:', i_date.

skip 2.

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

DATE_INTERNAL = sy-datum

IMPORTING

DATE_EXTERNAL = e_date

EXCEPTIONS

DATE_INTERNAL_IS_INVALID = 1

OTHERS = 2

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

WRITE : / 'CONVERT_DATE_TO_EXTERNAL',

/ 'My Date:' , sy-datum,

'Conv Date:', e_date.

Thanks,

Reward If Helpful.

Read only

Former Member
0 Likes
1,170

Hi

DAY_OUT(4)     = DAY_IN+6(4).
DAY_OUT+4(2) = DAY_IN+3(2).
DAY_OUT+6(2) = DAY_IN(2).

Max

Read only

Former Member
0 Likes
1,170

The FM CONVERT_DATE_TO_INTERNAL or CONVERT_DATE_TO_EXTERNAL will solve your purpose.

Read only

former_member582701
Contributor
0 Likes
1,170

DATA: c_date(8) TYPE C.

CONCATENATE chardate6(4) chardate3(2) chardate+0(2) INTO c_date.

regards

Read only

Former Member
0 Likes
1,170

Hi use this Logic..

date(10) = '25/07/2007.

day = date+0(2).

month = date+3(2).

year = date+6(4).

concatenate year month date into date1.

Reward All elpfull Answers..........

Read only

Former Member
0 Likes
1,170

Hi,

Use the Function module CONVERT_DATE_TO_INTERNAL

Regards

Sudheer

Read only

Former Member
0 Likes
1,170

Hi,

use this snippet in ur code

CONDENSE temp_date NO-GAPS.

STRLEN( temp_date ) EQ 10.

o_date0(4) = temp_date6(4).

o_date4(2) = temp_date3(2).

o_date6(2) = temp_date0(2).

Regards

Read only

Former Member
0 Likes
1,170

*date --> your date.

data: w_date like sy-datum.

concatenate date6(4) date3(2) date+0(2) into w_date.

reward points if its helpful.