‎2006 Jan 18 11:13 AM
Is there any function module to choose date by day. for example if I give today's date the FM should give me next thursday's date.
Thanks
Tharani
‎2006 Jan 18 12:36 PM
this works good........
&----
*& Report YCHATEST *
*& *
&----
*& *
*& *
&----
REPORT YCHATEST
.
data:day like DTRESR-WEEKDAY.
parameters:curr_dat like sy-datum default sy-datum.
CALL FUNCTION 'DATE_TO_DAY'
EXPORTING
DATE = CURR_DAT
IMPORTING
WEEKDAY = day.
write : / day.
case day.
when 'Monday'.
CURR_DAT = CURR_DAT + 3.
when 'Tuesday'.
CURR_DAT = CURR_DAT + 2.
when 'Wed.'.
CURR_DAT = CURR_DAT + 1.
when 'Thursday'.
CURR_DAT = CURR_DAT + 7.
when 'Friday'.
CURR_DAT = CURR_DAT + 6.
when 'Sat.'.
CURR_DAT = CURR_DAT + 5.
when 'Sunday'.
CURR_DAT = CURR_DAT + 4.
endcase.
write 😕 CURR_DAT.
.
‎2006 Jan 18 11:14 AM
‎2006 Jan 18 11:20 AM
Hi Tharani,
can you explain it more clearly?
In general you can add the number of days directly to date fields, like
date after ten days = sy-datum + 10.
‎2006 Jan 18 11:23 AM
You can calculate it yourself...
Like...
data MYDATE type D.
MYDATE = SY-DATUM + 7.
write MYDATE.
‎2006 Jan 18 11:24 AM
Hi
This u can do it without FM.
For eg.
DATA date LIKE sy-datum.
date = sy-datum + 10.
WRITE date.
Regards,
Abdul
‎2006 Jan 18 11:28 AM
hI
Thing is the input date will be dynamic. the current date would be given as input. I have to choose the next Thurday's Date based on my input date.
Thanks
Tharani
‎2006 Jan 18 11:43 AM
Hi,
Use FM date_to_day to find the sy-datum.
Then in your program,design the logic,such that
case 'Monday'.
v_date = v_date + 10.
case 'Tuesday'.
v_date = v_date + 9.
....
case 'Sunday'.
..
endcase.
KIndly reward points by clicking the star on the left of reply,if it helps.
‎2006 Jan 18 11:27 AM
Hi Tharani,
You can use FM <b>WDKAL_DATE_ADD_FKDAYS</b>.
Pass the date, number of days to add and factory calendar, you will get the date according to factory calendar and days entered.
For eg:
date: 01/18/2006
no.of.days: 5
fact. calendar: IN
Will return: 01/25/2006
Regards,
Raj
‎2006 Jan 18 11:28 AM
May the foll. FM will solves your probs by adding some logic
date_to_day
date_compute_day
‎2006 Jan 18 11:34 AM
Hi Tharani,
For your requirement you can use FM <b>FIMA_DATE_SHIFT_WITH_WEEKDAY</b>
Pass any date, give I_WEEKDAY as 4,
It will return the date of coming thursday.
Regards,
Raj
‎2006 Jan 18 11:36 AM
Hi,
You can use arythmetic operation for field that have sydatum type!
It handles end of monthes . . .
‎2006 Jan 18 11:38 AM
Hi Tharani,
Here is the code
parameters: p_date like sy-datum.
data:v_day like SCAL-INDICATOR,
v_date type sy-datum.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
date = p_date
IMPORTING
DAY = v_day
.
case v_day.
when '1'.
v_date = p_date + 3.
when '2'.
v_date = p_date + 2.
when '3'.
v_date = p_date + 1.
when '4'.
v_date = p_date + 7.
when '5'.
v_date = p_date + 6.
when '6'.
v_date = p_date + 5.
when '7'.
v_date = p_date + 4.
endcase.
write: v_date.
Best of luck.
Thanks
Eswar
‎2006 Jan 18 12:36 PM
this works good........
&----
*& Report YCHATEST *
*& *
&----
*& *
*& *
&----
REPORT YCHATEST
.
data:day like DTRESR-WEEKDAY.
parameters:curr_dat like sy-datum default sy-datum.
CALL FUNCTION 'DATE_TO_DAY'
EXPORTING
DATE = CURR_DAT
IMPORTING
WEEKDAY = day.
write : / day.
case day.
when 'Monday'.
CURR_DAT = CURR_DAT + 3.
when 'Tuesday'.
CURR_DAT = CURR_DAT + 2.
when 'Wed.'.
CURR_DAT = CURR_DAT + 1.
when 'Thursday'.
CURR_DAT = CURR_DAT + 7.
when 'Friday'.
CURR_DAT = CURR_DAT + 6.
when 'Sat.'.
CURR_DAT = CURR_DAT + 5.
when 'Sunday'.
CURR_DAT = CURR_DAT + 4.
endcase.
write 😕 CURR_DAT.
.