1 PACKAGE BODY ENG_BIS_FUNCTIONS AS
2 /* $Header: engbisfb.pls 115.1 2002/02/06 19:36:31 skagarwa ship $ */
3
4 /*
5 * GetWorkdaysBetween
6 *
7 * This function calculates the number of mfg
8 * workdays between a start date and an end
9 * date for a particular organization.
10 */
11 FUNCTION GetWorkdaysBetween(p_organization_id NUMBER,
12 p_start_date DATE,
13 p_end_date DATE) RETURN number IS
14
15 l_days NUMBER;
16 l_calendar_code VARCHAR2(10);
17 l_exception_set_id NUMBER;
18
19
20 CURSOR GetCalendarInfo IS
21 SELECT calendar_code, calendar_exception_set_id
22 FROM mtl_parameters
23 WHERE organization_id = p_organization_id;
24
25 BEGIN
26 FOR c1 IN GetCalendarInfo LOOP
27 l_calendar_code := c1.calendar_code;
28 l_exception_set_id := c1.calendar_exception_set_id;
29 END LOOP;
30
31 SELECT count(*)
32 INTO l_days
33 FROM bom_calendar_dates
34 WHERE calendar_code = l_calendar_code
35 AND exception_set_id = l_exception_set_id
36 AND calendar_date between p_start_date and p_end_date
37 AND seq_num is not null;
38
39 RETURN l_days;
40
41 END GetWorkdaysBetween;
42
43 END ENG_BIS_FUNCTIONS;