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

'CONVERT_DATE_TO_INTERN_FORMAT'

Former Member
0 Likes
3,065

hi abapers,

when i am entering the input value in parameter the value of the output is entirely different.it just split the date without convert the date. help me please.

thank you.

PARAMETERS:P TYPE D.

DATA:DATS LIKE SY-DATUM.

CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'

EXPORTING

datum = p

dtype = DATS

  • IMPORTING

  • ERROR =

  • IDATE =

  • MESSG =

  • MSGLN =

.

write (10) P USING EDIT MASK '____/__/__'.

8 REPLIES 8
Read only

Former Member
0 Likes
1,451

use the fm:

CONVERT_DATE_TO_INTERN_FORMAT

SAMPLE USAGE:

call function 'CONVERT_DATE_TO_INTERN_FORMAT'

exporting datum = '12/12/2006'

dtype = 'DATS'

importing idate = v_date. "v_date should be of type sy-datum or chracter field of length 8

Read only

Former Member
0 Likes
1,451

enter your date in the format like this:

enter the date: 12122007

output will be : 12/12/2007

copy and paste the following code.

i have changed the last line..read it carefully..

Reward points if helpful...

PARAMETERS:P TYPE D.

DATA:DATS LIKE SY-DATUM.

CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'

EXPORTING

datum = p

dtype = DATS

  • IMPORTING

  • ERROR =

  • IDATE =

  • MESSG =

  • MSGLN =

.

write (10) P USING EDIT MASK '__/__/____'.

Read only

Former Member
0 Likes
1,451

Hi,

pls give us ur input date format.

here is a working sample code: '9/2/2003' to 20030209
data : urdate(10) type c,
mydate type d.

*move '9/2/2003' to urdate.
 urdate = '9/2/2003'.

CALL FUNCTION 'RP_FORMATING_DATE'
EXPORTING
DATE_I = urdate
* BIRTH_DATE = 'X'
IMPORTING
DATE_O = mydate
* EXCEPTIONS
* DATE_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.
CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'
EXPORTING
DATUM = mydate
DTYPE = 'DATS'
IMPORTING
* ERROR =
IDATE = mydate
* MESSG =
* MSGLN =
.
write : mydate.

Hope it was helpful.

Regards,

Anjali

Read only

Former Member
0 Likes
1,451

Use function module 'CONVERT_DATE_TO_INTERN_FORMAT'

With datum = <date_value>

dtype = 'DATS'.

Read only

Former Member
0 Likes
1,451

Hi MAnjula,

Now paste this code..

PARAMETERS:P TYPE D.

DATA:DATS LIKE SY-DATUM,

<b> date type d.</b>

CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'

EXPORTING

datum = p

dtype = DATS

<b> IMPORTING</b>

  • ERROR =

<b> IDATE = date</b>

  • MESSG =

  • MSGLN =

.

write (10) date using EDIT MASK '____/__/__'.

Read only

Former Member
0 Likes
1,451

Hi,

please look at the changes in bold.

PARAMETERS:P TYPE D.

DATA:DATS LIKE SY-DATUM.

<b>

data : idate type DATUV.</b>

CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'

EXPORTING

datum = p

dtype = DATS

<b> IMPORTING</b>

  • ERROR =

<b>IDATE = idate</b>

  • MESSG =

  • MSGLN =

.

write (10) <b>idate</b> USING EDIT MASK '____/__/__'.

rewards if useful,

regards,

nazeer

Read only

0 Likes
1,451

hi abapers,

sorry i thik i didnt explain u properly.for ex.when i am entering the input in parameter as '03/03/2007'.the output is '0303/20/07'.this is a wrong answer.

i want 2007/03/03.help me please.

Read only

Former Member
0 Likes
1,451

hi abapers,

sorry i thik i didnt explain u properly.for ex.when i am entering the input in parameter as '03/03/2007'.the output is '0303/20/07'.this is a wrong answer.

i want 2007/03/03.help me please.