Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

reports

Former Member
0 Likes
546

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

1 ACCEPTED SOLUTION
Read only

VXLozano
Active Contributor
0 Likes
506
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

2 REPLIES 2
Read only

VXLozano
Active Contributor
0 Likes
507
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

Read only

Former Member
0 Likes
506

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.