2008 Mar 15 6:54 AM
Hi,
I want a instance or example which allows me to display the on the basis of date. i.e. if the date which is 15 th of any month in selection field then i should display the data of previous month's last date and if
date is 16 th of any month then it displays the data of 31 or 30 th date of that month.
As the data is stored on month wise concept and storing it on last date of each month as the program for updating the table has dis condition and i am not allowed to modify it.
tdas why i have to display the data in the form of 15 days concept i.e. if we enter date say 15 th of any month den it displays data of previous last date of month and if it is 16 th of any month den it displays data which is stored in last dat eof dis month.
plzz help me as it is really urgent.
Edited by: ric .s on Mar 15, 2008 7:54 AM
2008 Mar 15 9:53 AM
hi
check this code
parameters: p_date type d.
data:
num type i
w_date type d.
at selection-screen on p_date
num = p_date+6(2)
if num =15
p_date+6(2)=01
w_date = p_date-1.
else if num =16.
p_date = p_date+30
p_date+6(2)=01
w_date = p_date-1.
endif.
in this code u can get what u have in w_date .
Edited by: ravi kumar on Mar 15, 2008 10:54 AM
hi
check this code
parameters: p_date type d.
data:
num type i
w_date type d.
at selection-screen on p_date
num = p_date+6(2)
if num =15
p_date+6(2)=01
w_date = p_date-1.
else if num =16.
p_date = p_date+30
p_date+6(2)=01
w_date = p_date-1.
endif.
in this code u can get what u have in w_date .
Edited by: ravi kumar on Mar 15, 2008 10:54 AM
2008 Mar 15 7:50 AM
Hi,
Take 3 temp variables for last date of previous month and last dates 30th and 31st of the month.
Extract the date and month which u enter in selection date say 15.02.2008,means 15 and 02.
compare date if it is 15 or 16.
if it 15 subtract 1 from month and compare which month it is and get the lastdate of the month.I mean to say u can hardcode the last date of every month depending on month and build the date format by concatinating date month and year and pass it.u can get the data.
If it is 16 hard code the last days of the month and again build the date format and pass it select query.
Thanks & Regards,
R.P.Sastry
2008 Mar 15 8:10 AM
Hi,
thanks for explanation ca u give me a exmaple of it more clearly plz as help will be deifnately rewarded.more how can i compare it with month as dere are lot of months present.and lot of last dates present ina year.
you are saying take variable for previous month and last - 30 or 31 st of a month but i am having dese dates of every month of fiscal year.
dats why i am saying to u give me some example regarding it.
Edited by: ric .s on Mar 15, 2008 9:10 AM
Edited by: ric .s on Mar 15, 2008 9:17 AM
2008 Mar 15 8:24 AM
Hi,
suppose i enter 15.03.2008 in selection screen,say this variable as s_date.
temp type sy-datum.
take t_date = s_date+6(2) which is =15.
t_month = s_date+4(2) which is =02.
now check vth tht t_month to every month and set the date first.
compare if t_month = 01 or 03 0r like tht.
means it is t_month is 2 then last date of previous is 31 store it in temp1 bcoz its january.and year vl b same wht u entered in selection.
same for if it 16 take 2 vars and assign 30th and 31st..
temp+0(4)=year
temp+4(2)=t_month - 1.
temp+6(2)=temp1.
now pass the temp 2 select query
I think this vl helps u
Regards,
R.P.sastry
2008 Mar 15 8:43 AM
hi,
in ur exmaple it displays the data to be picked from januaray but not from febuarary as it consist of 29 days dis year.
plzz give some more clear example as its really urgent to me.
Edited by: ric .s on Mar 15, 2008 9:45 AM
2008 Mar 15 9:18 AM
hi,
i am few questions about d example given below:-
suppose i enter 15.03.2008 in selection screen,say this variable as s_date.
temp type sy-datum.
take t_date = s_date+6(2) which is =15.
t_month = s_date+4(2) which is =02.
now check vth tht t_month to every month and set the date first.
compare if t_month = 01 or 03 0r like tht.
means it is t_month is 2 then last date of previous is 31 store it in temp1 bcoz its january.and year vl b same wht u entered in selection.
same for if it 16 take 2 vars and assign 30th and 31st..
temp+0(4)=year
temp+4(2)=t_month - 1.
temp+6(2)=temp1.
now pass the temp 2 select query
what is the type of it and how it is :-
take t_date = s_date+6(2) which is =15.
t_month = s_date+4(2) which is =02.
and how do i compare the value where as dere is NO COMPARE keyword in sap as dere is only compute.
plzz help em out i am in need of it.
2008 Mar 15 8:18 AM
parameter : v_date like sy-datum.
data : last_day like sy-datum.
v_date = v_date - 15.
CALL FUNCTION 'LAST_DAY_OF_MONTHS'
EXPORTING
day_in = v_date
IMPORTING
LAST_DAY_OF_MONTH = last_day
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
write : last_day.
2008 Mar 15 8:21 AM
hi vivek,
how can i compare it with month as dere are lot of months present.and lot of last dates present ina year.
you are saying take variable for previous month and last - 30 or 31 st of a month but i am having dese dates of every month of fiscal year . And i have to display the data according to it .
dats why i am saying to u give me some example regarding it.
Edited by: ric .s on Mar 15, 2008 9:23 AM
2008 Mar 15 9:53 AM
hi
check this code
parameters: p_date type d.
data:
num type i
w_date type d.
at selection-screen on p_date
num = p_date+6(2)
if num =15
p_date+6(2)=01
w_date = p_date-1.
else if num =16.
p_date = p_date+30
p_date+6(2)=01
w_date = p_date-1.
endif.
in this code u can get what u have in w_date .
Edited by: ravi kumar on Mar 15, 2008 10:54 AM
2008 Mar 15 10:16 AM
hi ravi,
thanks yaar ,u know something u have solved my problem and for dat i am rewarding you your full 10 points for that. enjoy it and continue to help others like dis.
2008 Mar 15 10:27 AM
hi ric..
check this example ...
parameters:p_date type sy-datum.
data:date1(2),
date2(2) type n,
date3(2),
date4(4),
date type sy-datum,
LAST_DAY_OF_MONTH type dats.
date1 = p_date+4(2).
date2 = p_date+6(2).
date4 = p_date+0(4).
if date2 le 15.
date1 = date1 - 1.
if date1 le 10.
concatenate date4 '0' date1 date2 into date .
else.
concatenate date4 date1 date2 into date .
endif.
CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
EXPORTING
day_in = date
IMPORTING
LAST_DAY_OF_MONTH = LAST_DAY_OF_MONTH .
else.
concatenate date4 date1 date2 into date.
CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
EXPORTING
day_in = date
IMPORTING
LAST_DAY_OF_MONTH = LAST_DAY_OF_MONTH .
endif.
write:/ LAST_DAY_OF_MONTH.
regards,
venkat.
2008 Mar 15 10:45 AM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |