Application Development 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: 

date conversion

Former Member
0 Kudos

Hi Abapers,

I need a FM which can convert date: YYYYMMDD to MM/DD/YYYY.

I have used the FM '/SAPDII/SPP05_CONVERT_DATE' to achieve this. but the problem is it doesnt handle exceptions. so it may lead to dump in some scenarios. kindly suggest me some Fm which can handle exceptions too.

Regards,

Radhika.

5 REPLIES 5

Former Member
0 Kudos

Do like this

Data: Var1 type sy-datum,

var2(10) type c.

var1 = sy-datum.

Concatanate var14(2)'/' var16(2) '/' var1+0(4) into var2.

write var2.

Former Member
0 Kudos

Hi Prem,

Do like this

YYYYMMDD to MM/DD/YYYY

Data: date1 type sy-datum,
         date2(10) type c.

Date1 = sy-datum. " This will be in YYYYMMDD format

Concatenate date1+4(2) date1+6(2) + date1+0(4) into date2 seperated by '/'.

write date2.

<b>Reward Points if this helps,</b>

Satish

Former Member
0 Kudos

hi

may this will help u..

data: gd_date(10). "field to store output date

  • Converts SAP date from 20020901 to 01.09.2002

write sy-datum to gd_date dd/mm/yyyy.

  • Converts SAP date from 20020901 to 01.09.02

write sy-datum to gd_date dd/mm/yy.

Prarthan

former_member386202
Active Contributor
0 Kudos

Hi,

Try this FM

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

date_internal = lv_date

IMPORTING

date_external = lv_date1

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.

Regards,

Prashant

Former Member
0 Kudos

to convert yyyymmdd to dd.mm.yyyy

data : wa1 type sy-datum,

wa2(10).

concatenate wa1+6(2)'.'

wa1+4(2)'.'

wa1(4) into wa2.