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

Date Formatting.

Murali_Shanmu
SAP Champion
SAP Champion
0 Likes
393

Hi

I have a date which could be either 01.01.2006 or even 1.1.2006. Whenever the date appears as 1.1.2006, i need it to be converted to the format 01.01.2006. Can anyone providde me with the logic or is any FM available for this ?

Murali.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
361

Hi Murali,

There is a FM for this purpose.

It is CONVERT_DATE_INPUT.

Just check this code.

parameters: a(12).

data: b type sy-datum.

CALL FUNCTION 'CONVERT_DATE_INPUT'

EXPORTING

input = a

  • PLAUSIBILITY_CHECK = 'X'

IMPORTING

OUTPUT = b

  • EXCEPTIONS

  • PLAUSIBILITY_CHECK_FAILED = 1

  • WRONG_FORMAT_IN_INPUT = 2

  • OTHERS = 3

.

IF sy-subrc <> 0.

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

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

ENDIF.

This will convert 1.1.2006 to 01.01.2006.

Hope your query is solved.

Regards,

SP.

2 REPLIES 2
Read only

Former Member
0 Likes
362

Hi Murali,

There is a FM for this purpose.

It is CONVERT_DATE_INPUT.

Just check this code.

parameters: a(12).

data: b type sy-datum.

CALL FUNCTION 'CONVERT_DATE_INPUT'

EXPORTING

input = a

  • PLAUSIBILITY_CHECK = 'X'

IMPORTING

OUTPUT = b

  • EXCEPTIONS

  • PLAUSIBILITY_CHECK_FAILED = 1

  • WRONG_FORMAT_IN_INPUT = 2

  • OTHERS = 3

.

IF sy-subrc <> 0.

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

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

ENDIF.

This will convert 1.1.2006 to 01.01.2006.

Hope your query is solved.

Regards,

SP.

Read only

Former Member
0 Likes
361

hi

good

The field TCURR-GDATU is subject to a conversion routine INVDT

look at the CONVERSION_EXIT_INVDT_INPUT and

CONVERSION_EXIT_INVDT_OUTPUT function modules. Basically it converts the date to 8 characters.

DATUMSAUFBEREITUNG Country-specific date formatting

DAYS_BETWEEN_TWO_DATES

Number of days is returned in the E_TAGE parameter

thanks

mrutyun