‎2006 Dec 20 11:18 AM
Hi all,
I have one requirement.
The requirement is
1)get the present data (sy-datum)
2) Now i want to find out the name of the day for that date and find the date for the friday which is coming after that date.
eg : if sy-datum = 20.12.2006 then name of tha day = wednesday
then date for friday is 22.12.2006.
plz tell me what are function modules required for this requirement and how to do this.
thanks in advance to all,
regards,
Shoban
‎2006 Dec 20 11:21 AM
‎2006 Dec 20 11:21 AM
‎2006 Dec 20 11:22 AM
‎2006 Dec 20 11:23 AM
Hi,
Check these fm
DATE_COMPUTE_DAY Returns day of the week for a particular date(1=Monday, 5=Friday etc.)
DATE_TO_DAY Returns day of the week for a particular date('Monday', 'Friday', 'Sat.')
‎2006 Dec 20 11:25 AM
use FM
RH_GET_DATE_DAYNAME to get the day name and day number
for example 20.12.2006 it will return
3 and wednesday
now
reduce one from day number and add that to current date 20.12.2006
you will get the following friday date
Regards
Raja
‎2006 Dec 20 11:25 AM
Use DATE_COMPUTE_DAY...this returns number.
If 1 then monday
if 2 then tuesday
if 3 wednesday
if 4 thursday
if 5 friday
if 6 saturday
if 7 sunday....so...
if 1.
date = sy-datum + 4.
elseif 2.
date = sy-datum + 3.
elseif 3.
date = sy-datum + 2.
elseif 4.
date = sy-datum + 1.
elseif 5.
date = sy-datum + 0.
elseif 6.
date = sy-datum + 6.
elseif 7.
date = sy-datum + 7.
endif.
‎2006 Dec 20 11:31 AM
Hi,
Use this FM;
DATE_TO_DAY
just give the date and u will get the day
Thanks
Shiva
‎2006 Dec 20 11:33 AM
hi,
just copy this code
DATA : day LIKE SCAL-INDICATOR,
attr LIKE TABLE OF CASDAYATTR WITH HEADER LINE,
wa_date type sy-datum.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
date = sy-datum
IMPORTING
DAY = day
.
WRITE : day. "wednesday
call function 'RP_CALC_DATE_IN_INTERVAL'
exporting
date = sy-datum
days = 2 --------------------> give ur required date
months = 0--------------------> give ur required month
years = 0
signum = '+'
importing
calc_date = wa_date.
write :/ wa_date. " friday dateRegards
Anver
‎2006 Dec 20 11:43 AM
Hi,
Use the FM RH_GET_DATE_DAYNAME ,
this gives as output the Day(DAYTXT) and also a value (DAYNR) indicating the day of week .
So Friday will have value 5 , to get the date of friday comming after this day all you need to do is substract the value of DAYNR from 5 and then add the result to your current date.
E.G.
data : v_one type PDAYNR ,
v_two type TAGBEZ ,
v_diff type i ,
v_date type sy-datum.
START-OF-SELECTION.
CALL FUNCTION 'RH_GET_DATE_DAYNAME'
EXPORTING
LANGU = SY-LANGU
DATE = SY-DATUM
* CALID =
IMPORTING
DAYNR = v_one
DAYTXT = v_two
* DAYFREE =
* EXCEPTIONS
* NO_LANGU = 1
* NO_DATE = 2
* NO_DAYTXT_FOR_LANGU = 3
* INVALID_DATE = 4
* OTHERS = 5
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
.
v_diff = 5 - v_one.
v_date = sy-datum + v_diff.
write:/ v_date , v_two.Regards
Arun