2007 Aug 03 6:55 AM
Hi,
I just want to get month names in output.
If i gives '3' as input it has to display next 3 month names(September,October,November).
If i gives 6 as input next 6 month names from September to February.
Thanks,
fractal.
REPORT ZTEST2 .
DATA : lt_month_names LIKE t247 OCCURS 0 WITH HEADER LINE.
DATA : lv_date LIKE sy-datum ,
l_month type i,
l_month2 type i.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-005 .
Parameter: p_month(2).
SELECTION-SCREEN END OF BLOCK b1 .
CALL FUNCTION 'MONTH_NAMES_GET'
TABLES
MONTH_NAMES = lt_month_names
EXCEPTIONS
MONTH_NAMES_NOT_FOUND = 1
OTHERS = 2
.
lv_date = sy-datum.
l_month = lv_date+4(2).
l_month2 = l_month + p_month.
2007 Aug 03 7:13 AM
Hi fractal,
Try this code , its just that u need..
DATA : lt_month_names LIKE t247 OCCURS 0 WITH HEADER LINE.
DATA : lv_date LIKE sy-datum ,
l_month TYPE i,
l_month2 TYPE i.
DATA: BEGIN OF itab OCCURS 0,
spras TYPE spras,
mnr LIKE t247-mnr,
ktx LIKE t247-ktx,
ltx LIKE t247-ltx,
END OF itab.
DATA : BEGIN OF itab1 OCCURS 0,
temp LIKE t247-ltx,
END OF itab1.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-005 .
PARAMETER: p_month(2).
SELECTION-SCREEN END OF BLOCK b1 .
SELECT * FROM t247 INTO CORRESPONDING FIELDS OF TABLE itab " TO GET THE SHORT MONTH NAMES...I.E. MAR FOR MARCH
WHERE spras = 'E'.
lv_date = sy-datum.
l_month = lv_date+4(2).
DO p_month TIMES.
READ TABLE itab WITH KEY mnr = l_month.
IF sy-subrc = 0.
itab1-temp = itab-ltx.
APPEND itab1.
ENDIF.
l_month = l_month + 1.
IF l_month > 12.
l_month = 1 .
ENDIF.
ENDDO.
LOOP AT itab1.
WRITE : / itab1-temp.
ENDLOOP.
Regards,
Bijal
2007 Aug 03 6:56 AM
Use the table T247 to get the month names.
Use this code to get the month names.
tables t247.
data mon(2).
mon = sy-datum+4(2).
mon = mon + 1.
select single ltx from t247 where mnr eq mon.
Please mark points if the solution was useful.
Regards,
Manoj
2007 Aug 03 7:19 AM
Not one month name...
I want the month names based on the number in the input.
if my input is 2 (September,October)
if my input is 7(September to March) like that....
Thanks,
fractal
2007 Aug 03 7:21 AM
Modify the code like below:
tables t247.
data mon(2).
data lv_num type i value 2.
mon = sy-datum+4(2).
do lv_num times.
mon = mon + 1.
select single ltx from t247 where mnr eq mon.
write: t247-ltx.
enddo.
Please mark points if the solution was useful.
Regards,
Manoj
2007 Aug 03 7:09 AM
Hi,
CALL FUNCTION 'MONTH_NAMES_GET'
TABLES
MONTH_NAMES = lt_month_names
EXCEPTIONS
MONTH_NAMES_NOT_FOUND = 1
OTHERS = 2
CASE input. " assuming input has number of months
WHEN '3'. " when 3
DATA: cur_mon(2) type n,
mon type i,
start type i,
end type i1.
cur_mon = sy-datum+4(2).
mon = cur_mon.
start = mon + 1 MOD 12. end = mon + 3 MOD 12.
if start = 0.
start = 12.
endif.
if end = 0.
end = 12.
endif.
LOOP AT lt_month_names FROM start TO end.
* You get your next three months here
ENDLOOP.
WHEN '6'.
DATA: cur_mon(2) type n,
mon type i,
start type i,
end type i1.
cur_mon = sy-datum+4(2).
mon = cur_mon.
start = mon + 1 MOD 12.
end = mon + 6 MOD 12.
if start = 0.
start = 12.
endif.
if end = 0.
end = 12.
endif.
LOOP AT lt_month_names FROM start TO end.
* You get your next six months here
ENDLOOP.
Regards,
Sesh
2007 Aug 03 7:13 AM
Hi fractal,
Try this code , its just that u need..
DATA : lt_month_names LIKE t247 OCCURS 0 WITH HEADER LINE.
DATA : lv_date LIKE sy-datum ,
l_month TYPE i,
l_month2 TYPE i.
DATA: BEGIN OF itab OCCURS 0,
spras TYPE spras,
mnr LIKE t247-mnr,
ktx LIKE t247-ktx,
ltx LIKE t247-ltx,
END OF itab.
DATA : BEGIN OF itab1 OCCURS 0,
temp LIKE t247-ltx,
END OF itab1.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-005 .
PARAMETER: p_month(2).
SELECTION-SCREEN END OF BLOCK b1 .
SELECT * FROM t247 INTO CORRESPONDING FIELDS OF TABLE itab " TO GET THE SHORT MONTH NAMES...I.E. MAR FOR MARCH
WHERE spras = 'E'.
lv_date = sy-datum.
l_month = lv_date+4(2).
DO p_month TIMES.
READ TABLE itab WITH KEY mnr = l_month.
IF sy-subrc = 0.
itab1-temp = itab-ltx.
APPEND itab1.
ENDIF.
l_month = l_month + 1.
IF l_month > 12.
l_month = 1 .
ENDIF.
ENDDO.
LOOP AT itab1.
WRITE : / itab1-temp.
ENDLOOP.
Regards,
Bijal
2007 Aug 03 7:22 AM
hi,
<u>Chk this logic</u>
DATA: DATE_CHAR(20).
DATA: DATE TYPE SY-DATUM.
DATA: MONTH_NAME LIKE T247-LTX.
DATE = SY-DATUM.
SELECT SINGLE LTX FROM T247
INTO MONTH_NAME
WHERE SPRAS = SY-LANGU
AND MNR = SY-DATUM+4(2).
CONCATENATE SY-DATUM+6(2) MONTH_NAME SY-DATUM(4)
INTO DATE_CHAR SEPARATED BY SPACE.
WRITE: / DATE_CHAR.
Regards
Anversha