‎2005 Aug 26 7:40 PM
Hi,
Can someone help me to figure this out. I deducted 4 days from the requested date and went to factory calendar. Factory calendar gives next business day (8/1/05) which is not what we want. Need 4 days before del. date. Saturday and Sunday in between is throwing the date off. Is there another function to accomplish this. Thanks in advance for your help.
For example this is what I need:
Requested Del Date = 8/01/05 (monday)
Planned Del Time = 4 days
do not count saturday and sunday - then go back four days 8/01, 7/29, 7/28, 7/27 - planned GI should be 7/26.
‎2005 Aug 26 7:50 PM
‎2005 Aug 26 7:46 PM
Based on your previous post, I am assuming you are using 'DATE_CONVERT_TO_FACTORYDATE'. In the solution that Rich proposed, use '-' instead of '+'.
‎2005 Aug 26 7:47 PM
Instead of adjusting forward, adjust backward.....
* Use "-" instead of "+"
call function 'DATE_CONVERT_TO_FACTORYDATE'
exporting
correct_option = '-' " Adjustment
date = d1 " Date In
factory_calendar_id = 'P6' " Calendar Id
importing
date = xdate. " Date out
Regards,
Rich Heilman
Message was edited by: Rich Heilman
‎2005 Aug 26 7:50 PM
‎2005 Aug 26 7:53 PM
I'm think that I have have misunderstood the first time around. You need to go back 4 days not including the non-working days, right? Try this code..
Enter 08/01/2005 in the parameters field, the output will be 07/26/2005.
report zrich_0002.
parameters: p_datum type sy-datum.
do 4 times.
p_datum = p_datum - 1.
call function 'DATE_CONVERT_TO_FACTORYDATE'
exporting
correct_option = '-'
date = p_datum
factory_calendar_id = 'P6'
importing
date = p_datum.
enddo.
write:/ p_datum.
Here you are subtracting one day at a time, and check to see if there is a calendar adjustment which can be applied.
Regards,
Rich Heilman
Message was edited by: Rich Heilman
‎2005 Aug 26 8:01 PM
Rich solution is OK for your problem, only you have to change the calendar ID. You get out this information from T001W
‎2005 Aug 26 7:51 PM
Hi
Check also the function module:
WDKAL_DATE_ADD_FKDAYS
Cheers
Ashish
‎2005 Aug 26 8:07 PM
Thanks guys. It gives me 7/28/05 but I am looking for 7/26 which gives me 4 days excluding Sat. and Sunday. Is there a way we could exclude weekends going back for calendar function?
‎2005 Aug 26 8:16 PM
‎2005 Aug 26 8:18 PM
I runned Rick solution and the result is correct.
If you can't obtain a right result, probably you use a wrong calendar id, or in your calendar is wrong
‎2005 Aug 26 8:34 PM
Hi,
Here is a working example using the FM I gave you last time. I used a date of November 28th 2005 as input date and asked the system to back-calculate by 4 days using our custom calendar. Now while 26 and 27 are saturday and sunday, in our custom calendar, 24 and 25 are marked as holidays. So my first previous working day is 23rd November, 2nd is 22nd, and 3rd is 21st, but again I hit Saturday and Sunday on 20th and 19th. So my 4th working day backwards is 18th November. I hope this is what you are looking for and it worked for me.
REPORT ztest1 .
PARAMETERS: p_date LIKE sy-datum.
DATA: v_input_date LIKE sy-datum,
v_output_date LIKE sy-datum.
START-OF-SELECTION.
CALL FUNCTION 'BUSINESS_DATE_CREATE'
EXPORTING
* BLEIB_IM_MONAT = ''
datum_ein = p_date
geschaeftstage = 4
kalender = 'Z6'
richtung = '-'
IMPORTING
datum_aus = v_output_date
EXCEPTIONS
calendar_not_found = 1
date_out_of_range = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.Regards,
Srinivas
‎2005 Aug 26 8:39 PM
Thanks to all of you. Rich, thanks for all your help. Finally it worked after I followed your last suggestion. Gave all of you ponts.