‎2006 May 09 7:41 PM
i need a FM that i give the number of month 01,02....
and i get the date start and end date
‎2006 May 09 7:46 PM
You can do something like this, but you can't just use the month, you must know the year as well. Here you can see that we take the parameter date, and force that date to the 1st day of that month/year, then use this date to find the end of the month.
report zrich_0001 .
parameters: p_datum type sy-datum.
data: begin_date type sy-datum,
end_date type sy-datum.
begin_date = p_datum.
begin_date+6(2) = '01' .
call function 'LAST_DAY_OF_MONTHS'
exporting
day_in = begin_date
importing
last_day_of_month = end_date.
write:/ begin_date, end_date.
Regards,
Rich Heilman
‎2006 May 09 7:46 PM
You can do something like this, but you can't just use the month, you must know the year as well. Here you can see that we take the parameter date, and force that date to the 1st day of that month/year, then use this date to find the end of the month.
report zrich_0001 .
parameters: p_datum type sy-datum.
data: begin_date type sy-datum,
end_date type sy-datum.
begin_date = p_datum.
begin_date+6(2) = '01' .
call function 'LAST_DAY_OF_MONTHS'
exporting
day_in = begin_date
importing
last_day_of_month = end_date.
write:/ begin_date, end_date.
Regards,
Rich Heilman
‎2006 May 09 7:48 PM
‎2006 May 09 7:49 PM
FM "HR_JP_MONTH_BEGIN_END_DATE" (<u><b> get begin date and end date of a month)</b></u>
call function 'HR_JP_MONTH_BEGIN_END_DATE'
exporting
iv_date = ld_new_date
importing
ev_month_begin_date = s_begda-low
ev_month_end_date = s_begda-high.
Hope thisll give you idea!!
<b>P.S award the points.!!! !!!</b>
Good luck
Thanks
Saquib Khan
"Some are wise and some are otherwise"
‎2006 May 09 7:53 PM
Hi Liat,
Date field in SAP is stored with YYYYMMDD(8 characters field). So to find the month, look at position 5th and 6th of the field.
Month = GV_DATE+4(2).
To get the first date of the month, set position 7th and 8th as '01'.
GV_DATE+6(2) = '01'.
FirstDate = GV_DATE.
To get the last date of the month, add 31 days to the first date of the month, then set position 7th and 8th as '01', lastly deduct the date by 1.
NextMonth = FirstDate + 31.
NextMonth+6(2) = '01'.
LastDate = NextMonth - 1.
‎2006 May 09 8:46 PM