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 FM

Former Member
0 Kudos

I m using CONVERSION_EXIT_PDATE_INPUT function module to convert the date format from DD/MM/YYYY -> YYYYMMDD.

Its working fine if the date is up to todays date.

If i give any date greater than this month or year its throwing an error as Invalid date.

But i want to change the format for future days also.

is there any alternative way to solve this issue.

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

try this...

data : v_date1(10) value '23/02/2007',
         v_date(8).

concatenate  v_date1+6(4) v_date1+3(2) v_date1+0(2) into v_date.

OR

as suggested by Alavaro

data : v_date1 TYPE KCDE_INTERN_VALUE,

v_date2 TYPE KCDE_INTERN_VALUE.

CALL FUNCTION 'KCD_EXCEL_DATE_CONVERT'

EXPORTING

EXCEL_DATE = v_date1

DATE_FORMAT = 'TMJ'

IMPORTING

SAP_DATE = v_date2

EXCEPTIONS

OTHERS = 0.

Message was edited by:

Chandrasekhar Jagarlamudi

10 REPLIES 10

former_member181962
Active Contributor
0 Kudos

Hi,

It works fine for all the dates. Check the date format in your user settings.

By the way, it accepts only DD/MM/YYY

Regards,

Ravi

Message was edited by:

Ravi Kanth Talagana

0 Kudos

when i gave input as 12/12/2008 or 12/12/2007 its throwing error invalid date.

if i gave 01/12/2007 its working fine.

May i know where i made mistake.

I checked the date format in user profile its MM/DD/YYYY

Thanks

Message was edited by:

Kalpanashri Rajendran

0 Kudos
REPORT YCHATEST.

TYPE-POOLS : KCDE.

DATA : V_DATE1 TYPE KCDE_INTERN_VALUE,
       V_DATE2 TYPE KCDE_INTERN_VALUE.

V_DATE1 = '23/02/2007'.

CALL FUNCTION 'KCD_EXCEL_DATE_CONVERT'
  EXPORTING
    EXCEL_DATE  = V_DATE1
    DATE_FORMAT = 'TMJ'
  IMPORTING
    SAP_DATE    = V_DATE2
  EXCEPTIONS
    OTHERS      = 0.
WRITE : V_DATE2.

Former Member
0 Kudos

Hi Kalpanashri,

try FM KCD_EXCEL_DATE_CONVERT

For example, "01/03/2007" yields "20070301"

I hope it helps. BR,

Alvaro

0 Kudos

ya i checked with this FM also but the output is in YYYY/DD/MM format.

But i need output in YYYY/MM/DD format.

The input can be in any format.

Is this possible.

Thanks

0 Kudos

Well, the second parameter is the input format: "T" for day, "M" for month and "J" for year. For example, suppose it's March 23rd, 2007:


call function 'KCD_EXCEL_DATE_CONVERT'
  exporting
    excel_date = '20/03/2007'
    date_format = 'TMJ'
  importing
    sap_date = l_date.

This yields 20070320.

If you need the input form in, say, year-day-month, just set date_format = 'JTM'.

Does it solve your problem? If not, please answer back. BR,

Alvaro

0 Kudos

Use this FM

CONVERT_DATE_TO_INTERNAL

Check this

http://www.sapdevelopment.co.uk/tips/date/date_format.htm

Former Member
0 Kudos

try this...

data : v_date1(10) value '23/02/2007',
         v_date(8).

concatenate  v_date1+6(4) v_date1+3(2) v_date1+0(2) into v_date.

OR

as suggested by Alavaro

data : v_date1 TYPE KCDE_INTERN_VALUE,

v_date2 TYPE KCDE_INTERN_VALUE.

CALL FUNCTION 'KCD_EXCEL_DATE_CONVERT'

EXPORTING

EXCEL_DATE = v_date1

DATE_FORMAT = 'TMJ'

IMPORTING

SAP_DATE = v_date2

EXCEPTIONS

OTHERS = 0.

Message was edited by:

Chandrasekhar Jagarlamudi

Former Member
0 Kudos

Try this out

DATA: ZTEMP(9).  

CLEAR: ZTEMP, ZDD, ZMMM, ZYYYY.  

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'  
EXPORTING  
INPUT = IS_DLV_DELNOTE-HD_GEN-CREA_DATE  
IMPORTING  
OUTPUT = ZTEMP.  

ZDD = ZTEMP+3(2).  
ZMMM = ZTEMP+0(3).  
ZYYYY = ZTEMP+5(4). 

http://www.sap-img.com/abap/abap-program-output-of-date-format.htm

If u give 01/12/2007 its taking as January 12th so no error.

Message was edited by:

Judith Jessie Selvi

Former Member
0 Kudos

Hi,

Use the FM:

<b>DATE_CONV_EXT_TO_INT</b> - user formatted date is converted to system date

Hope this helps.

Reward if helpful.

Regards,

Sipra