06-19-2008 8:23 AM
Hi,
I want set the first and last day of the last month as default values for the parameters on my selection screen. Do i need to do offset operations or is there any simple way to do so..
Thanks in advance,
Ram.
06-19-2008 8:27 AM
Hi,
It is better to use OFFSET way, it is better in performance.
To set the first and last day of the last month as default values for the parameters.
First day of the month.
date1 = sy-datum.
date1+6(2) = '01'.
Last day of the month.
date2 = sy-datum.
if date2+4(2) < 12.
date24(2) = date24(2) + 1.
else.
date2+4(2) = '01'.
date20(4) = date20(4) + 1.
endif.
date2 = date2 - 1.
P_Para1 = date1.
P_Para2 = date2.
06-19-2008 8:32 AM
Hi Ravi,
How can we set the last day of a month, as it can be varied for each month.pls any body suggest me. Or is there any function module to do so...
Thanks,
Ram.
06-19-2008 8:34 AM
06-19-2008 8:35 AM
hiiii
for getting first & last date of last month.. you can use following code
DATA:
w_fldate TYPE sy-datum,
w_carrid TYPE sflight-carrid,
w_date TYPE sy-datum,
w_date1 TYPE i VALUE '01',
w_temp TYPE sy-datum,
w_next TYPE i,
w_last TYPE sy-datum.
SELECT-OPTIONS
s_fldate FOR w_fldate.
MOVE sy-datum TO s_fldate-low.
MOVE sy-datum TO s_fldate-high.
w_date = sy-datum.
s_fldate-low+6(2) = w_date1.
w_temp = s_fldate-low.
w_next = s_fldate-low+4(2) + 1.
w_temp+4(2) = w_next.
w_last = w_temp - 1.
s_fldate-high = w_last.
APPEND s_fldate.
reward if useful
thx
twinkal
06-19-2008 8:35 AM
You can use the below function modules too...
Last day of the month.
1) SG_PS_GET_LAST_AY_OF_MONTH
Please consider the below code for the last day of the month or the above function module.
date2 = sy-datum.
if date2+4(2) < 12.
date24(2) = date24(2) + 1.
date2+6(2) = '01'.
else.
date20(4) = date20(4) + 1.
date2+4(2) = '01'.
date2+6(2) = '01'.
endif.
date2 = date2 - 1.
Edited by: Ravi Kumar on Jun 19, 2008 9:40 AM
06-19-2008 8:36 AM
Hi,
In my view this ould be the best possible way.
Data:
w_date LIKE sy-datum. " Date Variable
SELECT-OPTIONS:
s_date FOR w_date.
w_date = sy-datum.
w_date+6(2) = 01.
s_date-low = w_date.
w_date = sy-datum.
ADD 1 TO w_date+4(2).
w_date+6(2) = 01.
w_date = w_date - 1.
s_date-high = w_date.
Regards,
Nisrin.
06-19-2008 8:45 AM
Hi,
I want last day of the last month. Not present month.
Thanks,
Ram.
06-19-2008 8:49 AM
Hi ,
A soultion would be to substract the current day from the date.
Here is a sample code
data : data type sy-datum ,
day(2) type n.
data = sy-datum.
write / data.
day = data+6(2).
data = data - day.
write / data.
Regards
Arun
06-19-2008 8:50 AM
Hi ,
A soultion would be to substract the current day from the date.
Here is a sample code
data : data type sy-datum ,
day(2) type n.
data = sy-datum.
write / data.
day = data+6(2).
data = data - day.
write / data.
Regards
Arun
06-19-2008 8:51 AM
date2 = sy-datum.
if date2+4(2) > 1.
date24(2) = date24(2) - 1. " Month
else.
date20(4) = date20(4) - 1. " Year
date2+4(2) = '12'. " Month
endif.
Then use below function module.
1) SG_PS_GET_LAST_AY_OF_MONTH
06-19-2008 8:54 AM
Hi Ram
Check this code
REPORT ztest.
TABLES:
syst.
SELECT-OPTIONS:
s_date FOR sy-datum.
INITIALIZATION.
s_date-high = sy-datum.
s_date-high+6(2) = '01'.
s_date-high = s_date-high - 1.
s_date-low = s_date-high.
s_date-low+6(2) = '01'.
APPEND s_date.
06-19-2008 8:52 AM
Hi.
Are giving select option on selection screen then use the following code it is working.
select-options:
s_date for sy-datum.
data:
w_firstdate type sy-datum,
w_lastdate type sy-datum.
initialization.
CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
EXPORTING
iv_date = sy-datum
IMPORTING
EV_MONTH_BEGIN_DATE = w_firstdate
EV_MONTH_END_DATE = w_lastdate.
s_date-low = w_firstdate.
s_date-high = w_lastdate.
append s_date.
If not r u using parameters only, Use the same function module to get first and last date of a month and then write initialization event as given below.
INITIALIZATION.
p_firstdate = w_firstdate.
p_lastdate = w_lastdate.
PLZ reward points both will definately work.
Regards.
06-19-2008 8:53 AM
Hi.
Are giving select option on selection screen then use the following code it is working.
select-options:
s_date for sy-datum.
data:
w_firstdate type sy-datum,
w_lastdate type sy-datum.
initialization.
CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
EXPORTING
iv_date = sy-datum
IMPORTING
EV_MONTH_BEGIN_DATE = w_firstdate
EV_MONTH_END_DATE = w_lastdate.
s_date-low = w_firstdate.
s_date-high = w_lastdate.
append s_date.
If not r u using parameters only, Use the same function module to get first and last date of a month and then write initialization event as given below.
INITIALIZATION.
p_firstdate = w_firstdate.
p_lastdate = w_lastdate.
PLZ reward points both will definately work.
Regards.
06-19-2008 9:19 AM
Hi everybody,
Thanks for your ans. Now i got the solution. But its not coming to my parameters as default values. I perfromed calculations under INITIALIZATION event before declaring parameters. Is that wrong. If so, where should i perform these calculations.
Thanks,
Ram.
06-19-2008 10:02 AM
Hi ,
Declare the selection screen objects first and then write the code for initialization.
Regrads
Arun