ABAP how to write a date as a long text?
You can get the month's name in a given language using the module function 'MONTH_NAMES_GET
', passing the language as a parameter. The day (Sunday for example) can also be obtained using 'RH_GET_DATE_DAYNAME
'
Guillaume
This code will give you the date in the long text format like 'December 02, 2011'. You may change the code accordingly to print the date with long MONTH name.
DATA: LONG_DATE(20).
PERFORM GET_LONG_DATE USING LONG_DATE.
WRITE: LONG_DATE.
FORM GET_LONG_DATE USING DATE.
DATA: T_MONTH_NAMES LIKE TABLE OF T247 WITH HEADER LINE.
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
LANGUAGE = SY-LANGU
TABLES
MONTH_NAMES = T_MONTH_NAMES
.
DATA: YEAR(4) TYPE C,
MONTH(2) TYPE C,
DAY(2) TYPE C.
YEAR = SY-DATUM+(4).
MONTH = SY-DATUM+4(2).
DAY = SY-DATUM+6(2).
READ TABLE T_MONTH_NAMES INDEX ( MONTH ).
CONCATENATE T_MONTH_NAMES-LTX ' ' DAY INTO DATE SEPARATED BY SPACE.
CONCATENATE DATE ',' INTO DATE.
CONCATENATE DATE YEAR INTO DATE SEPARATED BY SPACE.
WRITE / DATE.
ENDFORM.
I think the absolute simplest way would be to apply the conversion exit LDATE to your date field. Easiest is to call function module CONVERSION_EXIT_LDATE_OUTPUT.
This would for example convert
20090101
to
01. January 2009
(Unless you need to actually have the day, month text and year in separate strings, which you seem to indicate. Anyway, maybe it will help someone else).