2007 Jul 09 6:47 PM
Is there a function to return the month of a date in the format
03/15/2007.
For example, return 03 or 'Mar'.
2007 Jul 09 6:50 PM
REPORT ztest_tmp.
DATA : mname(10) TYPE c.
PARAMETER : d TYPE sy-datum.
PERFORM getmonth USING d mname.
write 😕 mname.
&----
*& Form getmonth
&----
text
----
-->M text
-->MNAME text
----
FORM getmonth USING d mname.
DATA : month_names LIKE t247 OCCURS 0 WITH HEADER LINE.
DATA : m(2) TYPE c.
m = d+4(2).
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
LANGUAGE = SY-LANGU
IMPORTING
RETURN_CODE =
TABLES
month_names = month_names
EXCEPTIONS
month_names_not_found = 1
OTHERS = 2
.
READ TABLE month_names INDEX m.
IF sy-subrc = 0.
mname = month_names-ltx.
ENDIF.
ENDFORM. "getmonth
Thanks
Seshu
2007 Jul 09 6:50 PM
REPORT ztest_tmp.
DATA : mname(10) TYPE c.
PARAMETER : d TYPE sy-datum.
PERFORM getmonth USING d mname.
write 😕 mname.
&----
*& Form getmonth
&----
text
----
-->M text
-->MNAME text
----
FORM getmonth USING d mname.
DATA : month_names LIKE t247 OCCURS 0 WITH HEADER LINE.
DATA : m(2) TYPE c.
m = d+4(2).
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
LANGUAGE = SY-LANGU
IMPORTING
RETURN_CODE =
TABLES
month_names = month_names
EXCEPTIONS
month_names_not_found = 1
OTHERS = 2
.
READ TABLE month_names INDEX m.
IF sy-subrc = 0.
mname = month_names-ltx.
ENDIF.
ENDFORM. "getmonth
Thanks
Seshu
2007 Jul 09 6:51 PM
Hello,
Check this sample.
REPORT ZV_DATE_IN_WORDS .
*REPORT YCHATEST LINE-SIZE 350.
TABLES : T247.
DATA : V_DATE LIKE SY-DATUM,
V_DATE_FULL(09),
V_MONTH(25),
V_FINAL(45).
V_DATE = SY-DATUM.
CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'
EXPORTING
INPUT = V_DATE
IMPORTING
OUTPUT = V_DATE_FULL.
SELECT SINGLE LTX FROM T247 INTO V_MONTH WHERE KTX EQ V_DATE_FULL+2(3)
AND SPRAS = 'E'.
IF V_DATE_FULL+0(2) = '01' OR V_DATE_FULL+0(2) = '31'.
CONCATENATE V_DATE_FULL+0(2) 'ST' INTO V_FINAL.
ELSEIF V_DATE_FULL+0(2) = '02' OR V_DATE_FULL+0(2) = '22'.
CONCATENATE V_DATE_FULL+0(2) 'ND' INTO V_FINAL.
ELSEIF V_DATE_FULL+0(2) = '03' OR V_DATE_FULL+0(2) = '23'.
CONCATENATE V_DATE_FULL+0(2) 'RD' INTO V_FINAL.
ELSE.
CONCATENATE V_DATE_FULL+0(2) 'TH' INTO V_FINAL.
ENDIF.
CONCATENATE V_FINAL V_MONTH INTO V_FINAL SEPARATED BY SPACE.
CONCATENATE V_FINAL V_DATE_FULL+5(4) INTO V_FINAL SEPARATED BY ','.
WRITE : / V_FINAL.
Vasanth