‎2009 May 05 8:18 PM
I searched SDN and looked into several threads for this.
My req: I need to get the no.of working days between 2 dates in BW.
Amits reply in this thread works fine in R/3. But the real problem is that FM DATE_CHECK_WORKINGDAY is not existing in BW.
I tried to copy paste the code from this FM but it doesnt seem to work because there are some dynamic variables.
So please help me how 2 go about it.
Thanks
Kiran
‎2009 May 05 8:25 PM
‎2009 May 05 8:25 PM
‎2009 May 05 8:34 PM
Hi Prabhu,
This FM is not existing BW.
I need a write a code in one of the BW start routines.
Thanks
Kiran
‎2009 May 05 8:55 PM
Hi ,
try to use this Fm...
Factory date of day 1 minus the factory date in day 2.
Use function module:
DATE_CONVERT_TO_FACTORYDATE
Regards,
Prabhudas
‎2009 May 05 9:09 PM
Hi Prabu,
This FM exists in our BW system.
But I did not understand your above line.
Can you please tell me in detail or send a psuedo code.
Thanks
Kiran
Edited by: kiran dasari on May 6, 2009 5:33 PM
‎2009 May 06 1:31 PM
Hi Kiran,
use the belwo code to get the difference between two days in BW..
DATE_FROM TYPE DATUM. "First date
DATE_TO TYPE DATUM. "Second Date
REFERENCE(DAYS) TYPE I "Differnce days stored in this
DATA: l_date LIKE sy-datum,
l_end_date LIKE sy-datum,
l_factory_date LIKE sy-datum.
* Set L_DATE to the earlier date and L_END_DATE to the later date
IF date_from <= date_to.
l_date = date_from.
l_end_date = date_to.
ELSE.
l_date = date_to.
l_end_date = date_from.
ENDIF.
days = 0.
* Test all days between the two dates, and count just the factory days
WHILE l_date <= l_end_date.
* Determine if L_DATE is a factory date
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
date = l_date
correct_option = '+'
factory_calendar_id = factory_calendar_id
IMPORTING
date = l_factory_date
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.
CASE sy-subrc.
WHEN 0.
IF l_date = l_factory_date.
days = days + 1.
ENDIF.
l_date = l_date + 1.
WHEN 3.
MESSAGE e523(m7) WITH l_date
RAISING date_after_range.
WHEN 4.
MESSAGE e524(m7) WITH l_date
RAISING date_before_range.
WHEN 5.
MESSAGE e220(zsd) WITH l_date.
RAISE invalid_date_format.
WHEN 6.
MESSAGE e526(m7) WITH factory_calendar_id
RAISING factory_calendar_not_found.
WHEN OTHERS.
MESSAGE e525(m7) WITH l_date
RAISING others.
ENDCASE.
ENDWHILE.
" this part of code is for inclusive of start date and enddate ,
"if you want exclsive comment the belwo code and capture the Days from above.
IF date_from > date_to.
days = days * -1. "the difference days is stored in this Varaible
ENDIF.
Regards,
Prabhudas
‎2009 May 06 2:21 PM
Hi Prabhu,
Thanks for your code and efforts.
But what is factory_calendar_id. Should I just declare and leave it or should I pass some value into it. If so, how can I determine the calender id.
Thanks
Kiran
‎2009 May 06 2:33 PM
Can i know what exactly do u want??
If it is diff in no. of days...
jus write...date1 - date2...will give the no of days diff!!
‎2009 May 06 2:51 PM
"factory_calendar_id" This is passed to the FM.
I want to know what it is exactly and what value need to be passed when FM is called.
Thanks
Kiran
Edited by: kiran dasari on May 7, 2009 12:30 AM
‎2009 May 06 8:05 PM
Hi Kiran,
SELECT SINGLE fabkl INTO factory_calendar_id "Pass this factory_calendar_id to FM
FROM tvst where ALAND = 'US'. "country which you are checking the Holiday list
use the above query to get the factory_calendar_id .
dont forget to give points..
regards,
Prabhudas