Below are several FMs which can be used to convert date format.
1. CONVERSION_EXIT_IDATE_OUTPUT
INPUT: 20080203
OUTPUT: FEB032008
2. CONVERT_DATE_TO_EXTERNAL
INPUT: 20080203
OUTPUT: 02/03/2008 "According to user's default setting.
3. CONVERT_DATE_TO_INTERNAL
INPUT: 02/03/2008 "Should be same as the user's default setting
OUPUT: 20080203
We can also use following code to convert date format as per user's default setting.
*&--------------------------------------------------------------------*
*& Form convert_date_format
*&--------------------------------------------------------------------*
* change date format as per user's default setting
*---------------------------------------------------------------------*
* -->LV_BNAME text
* -->LV_DATE text
*---------------------------------------------------------------------*
FORM convert_date_format USING lv_bname LIKE usr01-bname
CHANGING lv_date TYPE char10.
DATA: lv_datfm LIKE usr01-datfm,
lv_year(4) TYPE c,
lv_month(2) TYPE c,
lv_day(2) TYPE c.
lv_year = lv_date+0(4).
lv_month = lv_date+4(2).
lv_day = lv_date+6(2).
* Get user's default setting.
SELECT datfm INTO lv_datfm FROM usr01
UP TO 1 ROWS WHERE bname = lv_bname .
ENDSELECT.
IF sy-subrc = 0.
CASE lv_datfm.
WHEN '1'.
CONCATENATE lv_day
lv_month
lv_year INTO lv_date SEPARATED BY '.'.
WHEN '2'.
CONCATENATE lv_month
lv_day
lv_year INTO lv_date SEPARATED BY '/'.
WHEN '3'.
CONCATENATE lv_month
lv_day
lv_year INTO lv_date SEPARATED BY '-'.
WHEN '4'.
CONCATENATE lv_year
lv_month
lv_day INTO lv_date SEPARATED BY '.'.
WHEN '5'.
CONCATENATE lv_year
lv_month
lv_day INTO lv_date SEPARATED BY '/'.
WHEN '6'.
CONCATENATE lv_year
lv_month
lv_day INTO lv_date SEPARATED BY '-'.
ENDCASE.
ELSE.
CONCATENATE lv_month
lv_day
lv_year INTO lv_date SEPARATED BY '/'.
ENDIF.
ENDFORM. "convert_date_format