2007 Jul 30 8:51 AM
Hi,
Default previous month first day as the low value for Change Date and previous month end date as high value for Change Date.
How to do this?
Regards,
kb
2007 Jul 30 8:54 AM
SELECT-OPTIONS: s_date FOR sy-datum.
INITIALIZATION.
DATA: l_date TYPE sy-datum.
* First day of the actual month
CONCATENATE sy-datum(6) '01' INTO l_date.
* subtracting one, we have the last day of the previous month
l_date = l_date - 1.
* Taking first day of the p.month
CONCATENATE l_date(6) '01' INTO s_date-low.
* Getting the last day
s_date-high = l_date.Message was edited to make it clearer:
Vicenç Lozano
2007 Jul 30 8:54 AM
SELECT-OPTIONS: s_date FOR sy-datum.
INITIALIZATION.
DATA: l_date TYPE sy-datum.
* First day of the actual month
CONCATENATE sy-datum(6) '01' INTO l_date.
* subtracting one, we have the last day of the previous month
l_date = l_date - 1.
* Taking first day of the p.month
CONCATENATE l_date(6) '01' INTO s_date-low.
* Getting the last day
s_date-high = l_date.Message was edited to make it clearer:
Vicenç Lozano
2007 Jul 30 8:55 AM
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_endate4(2) = v_enddate4(2) + 1.
elseif v_enddate = '12'.
v_enddate+4(2) = '01'.
v_enddate(4) = v_enddate(4) + 1.
endif.
v_enddate = v_enddate - 1.