Computing work days between two dates

Question: Hello,

here is the scenario: I have a report (BW) that reports sales orders which have not been filled. I want to report sales orders that have not been filled within 10, 20, 30 (work days) in 3 different columns.

The days will be computed using ( system-date - Order date). I only want to include work days (excluding holidays and weekends). Is userexit the only solution? Any suggestions on how to do this in a userexit? Is it possible to do this in the query formula?

Thanks.

Answer:
Hello Samkv:

You can convert both your dates to working days using function module 'DATE_CONVERT_TO_FACTORYDATE'.

Then, take the difference between both dates.

Answer:
Hello Chiu,

we knew about the function module. Which userexit do we use and how? How does the userexit know what the dates are? How do you pass the dates to the userexit?

Thanks.

Answer:
Not quite sure I understand your last response. You can use the function module 'DATE_CONVERT_TO_FACTORYDATE' in your update rules or transfer rules. Here is an example of using it in the update rule:

-----

DATA: lv_date1 TYPE scal-facdate,
lv_date2 TYPE scal-facdate,
lv_diff_between_dates TYPE scal-facdate.

CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
date = COMM_STRUCTURE-date1
factory_calendar_id = 'your factor calendar id'
IMPORTING
factorydate = lv_date1
EXCEPTIONS
calendar_buffer_not_loadable = 1
correct_option_invalid = 2
date_after_range = 3
date_before_range = 4
date_invalid = 5
factory_calendar_not_found = 6
OTHERS = 7 .

CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
date = COMM_STRUCTURE-date2
factory_calendar_id = 'your factory calendar id.'
IMPORTING
factorydate = lv_date2
EXCEPTIONS
calendar_buffer_not_loadable = 1
correct_option_invalid = 2
date_after_range = 3
date_before_range = 4
date_invalid = 5
factory_calendar_not_found = 6
OTHERS = 7 .

IF sy-subrc <> 0.
ENDIF.
lv_diff_between_dates = lv_date1 - lv_date2.
RESULT = lv_diff_between_dates.

-----

Good luck.

Answer:
Chiu,

I was asking about how do we accomplish this in the Query builder (not during the load). Our "from" date will remain the same... The "To" date is the current date (system date) is the reason we don't want to perform this during the load. System date of the date the users run the query.

Thanks.

Answer:
Hi Samkv,

USer exit has to be written in the EXIT_SAPLRRS0_001. This is the Exit used for Variables in the Bex Query.

lnv

Answer:
Hi inv15,

how do you pass the From Date and the To Date to the userexit to perform the calculation.

Thanks.
Copyright ?2007 - 2008 www.jt77.com