2007 Mar 20 6:54 AM
Hi All,
Can anyone let me know.. how to give last one month date range in select options.
Regards,
Parvez.
2007 Mar 20 6:56 AM
Hi,
In the <b>initialization</b> event,
u can do this...
s_date-low = sy-datum-30.
cheers,
Simha.
2007 Mar 20 6:57 AM
i don't think it is possible.
You can do validation based on the input.
If u want to give the last month date as default values,
Subtract 1 from present month, and pass the value in initialization event.
2007 Mar 20 11:45 AM
hi
as u have have to give the range as last month u should should assign
select option field name-low = (sy-udatum-30)
select option field name-high = (sy-udatum)
in the initiallization event with in the top include.
regards
vijay sharma.
2007 Mar 20 11:47 AM
Hi ...
We would need to change the high and low values of select-options variable after some coding .
I have written some code for you which finds out the previous month and accordingly assigns first date and last date to the HIGH and LOW variables of Select Options Variable.
I have tested ,it works fine .
data : var_date type dats.
select-options dates for var_date .
data: t type i.
*date
<b> t is previous month</b>
t = sy-datum+4(2) - 1.
if t = 0.
t = 12.
endif.
<b>year and month assignment</b>
dates-high0(4) = sy-datum0(4).
dates-low0(4) = sy-datum0(4).
dates-high+4(2) = t.
dates-low+4(2) = t.
case t.
when '1' or '3' or '5' or '7' or '8' or '10' or '12'.
dates-high+6(2) = 31.
dates-low+6(2) = 1.
when '4' or '6' or '9' or '11' .
dates-high+6(2) = 30.
dates-low+6(2) = 1.
WHEN '2'.
<b>for febraury</b>
*MAKE CODE FOR LEAP YEAR DETERMINATION.
*dates-low = 1.
endcase.
WRITE : DATES-LOW , DATES-high.
Pls Reward points if useful!!
Regards,
Shweta.
2007 Mar 23 10:30 AM
Hai Parveez,
This belw Codeis for last one month date range in select options.
SELECT-OPTIONS:
S_DATE FOR SY-DATUM.
INITIALIZATION.
S_DATE-LOW = SY-DATUM - 30.
S_DATE-HIGH = SY-DATUM - 1.
APPEND S_DATE.
WRITE:
/ S_DATE-LOW,S_DATE-HIGH.
May i know what actially last one month(last 30 days,28 days,31 days)p be specific.
I think this helps you.(You might have forgotten to append S_DATE)
Reward points if helpful.
regds,
Rama chary.Pammi
2007 Mar 23 1:07 PM
Hi Parvez,
I would suggest you dont hard code values like 30/31 to subtract from current date to get dates one month in the past etc. There is a class CL_HRPAD_DATE_COMPUTATIONS which has very useful methods e.g. SUBTRACT_MONTHS_FROM_DATE which will give you the date exactly one month in the past (it also accounts for leap years without concerns).
Hope this just substantiates the above advices.
Regards,
Aditya
2007 Mar 24 6:39 AM
hi
SELECT-OPTIONS:
S_DATE FOR SY-DATUM.
INITIALIZATION.
S_DATE-LOW = SY-DATUM - 30.
S_DATE-HIGH = SY-DATUM - 1.
APPEND S_DATE.
WRITE:
/ S_DATE-LOW,S_DATE-HIGH.
this wil workkk
vijay
2007 Mar 24 8:43 AM
Solution 1
Fill yourself the range/select-option in INITIALIZATION or first PBO
date = sy-datum.
date+6(2) = '01'. " first day of current moth
last_day = date - 1. " last day of previous month
first day = last_day. first_day+6(2) = '01'. " first day previous
so-date-sign = 'I'.
so-date-option = 'BT'.
so-date-low = first_day.
so-date-high = last-day.
append so-date.
More complex is possible
- previous month use FM RE_ADD_MONTH_TO_DATE and add -1 month to sy-datum
- last day of month: use FM LAST_DAY_OF_MONTHS with previous result
- first day of a month, move '01' in date+6(2)
Solution 2 for reports
Create a variant for your transaction and use selection variable for the date range
Regards
2007 Mar 26 10:59 AM
data : gv_date type sydatum.
&-----Selection Screen Definition--
SELECTION-SCREEN BEGIN OF BLOCK -001.
SELECT-OPTIONS so_budat FOR erdk-budat OBLIGATORY
DEFAULT gv_date TO sy-datum.
SELECTION-SCREEN END OF BLOCK -001.
INITIALIZATION.
gv_date = sy-datum - 30.
so_budat-low = gv_date.
MODIFY so_budat FROM so_budat INDEX 1.
This works I've used it in one of my reports.
Pls Reward if it helps.
Regards
2007 Mar 26 11:49 AM
Hi,
U can use the following code
data:
w_date like sy-datum.
select-options:
s_date for w_date.
initialization.
s_date-high = sy-datum.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
DATE = s_date-high
DAYS = 0
MONTHS = 1
SIGNUM = '-'
YEARS = 0
IMPORTING
CALC_DATE = w_date .
s_date-low = w_date.
append s_date.
2007 Mar 26 12:15 PM
hi......
Try this code......
DATA DATE LIKE SY-DATUM.
SELECT-OPTIONS S_DATE FOR DATE.
INITIALIZATION.
DATE = SY-DATUM.
S_DATE-HIGH = DATE.
SUBTRACT 1 FROM DATE+4(2).
IF DATE+4(2) = 0.
DATE+4(2) = '12'.
SUBTRACT 1 FROM DATE+0(4).
ENDIF.
S_DATE-LOW = DATE.
APPEND S_DATE.
Suresh.......
2007 Mar 27 10:49 AM
Hi,
in initialization part u have to write the following code
s_date-low = sy-datum-30.
s_date-high = sy-datum
regards,
sangeetha.a