During developing a report I came across this situation:
I've select option in which I want first date of the current month in LOW of select option and Last date of current month in HIGH of select month. Which FUNCTION MODULES are used for this?
There's one way to do this, though it's not a straight idea.
There's a function module 'OIL_LAST_DAY_OF_PREVIOUS_MONTH' that is used to determine the last day of the previous month. from this you can derive the first date of the current month.
Sample:
parameters : date1 like sy-datum.
CALL FUNCTION 'OIL_LAST_DAY_OF_PREVIOUS_MONTH'
EXPORTING
I_DATE_OLD = date1
IMPORTING
E_DATE_NEW = date1
.
data date2 like sy-datum.
date2 = date1 + 1.
write date2.
If you put 27.12.2005 as the input date, date2 you will get as 01.12.2005.
Or else you can use the following code:
v_startdate = sy-datum.
v_startdate+6(2) = '01'.
v_enddate = v_startdate.
if v_enddate+4(2) >= '01' AND v_enddate >= '11'.
v_endate+4(2) = v_enddate+4(2) + 1.
elseif v_enddate = '12'.
v_enddate+4(2) = '01'.
v_enddate+(4) = v_enddate+(4) + 1.
endif.
v_enddate = v_enddate - 1.