1 PACKAGE gmp_calendar_api AS
2 /* $Header: GMPCAPIS.pls 120.1.12010000.1 2008/07/30 06:15:09 appldev ship $ */
3 /*#
4 * This is the public interface for fetching data from OPM Shop Calendar
5 * These APIs are used by that OPM Process Execution.
6 * The calendar APIs provide various calendar related information such as
7 * if a given day is a work day, provide contiguous working periods etc.
8 * @rep:scope public
9 * @rep:product GMP
10 * @rep:displayname GMP_CALENDAR_API
11 * @rep:lifecycle active
12 * @rep:category BUSINESS_ENTITY GMP_CALENDAR_API
13 */
14
15 m_api_version CONSTANT NUMBER := 1;
16 m_pkg_name CONSTANT VARCHAR2 (30) := 'GMP_CALENDAR_API';
17
18
19 TYPE contig_time_rec IS RECORD
20 (
21 start_date DATE,
22 duration NUMBER,
23 end_date DATE
24 );
25
26 TYPE contig_period_tbl IS TABLE OF contig_time_rec INDEX BY BINARY_INTEGER;
27
28 TYPE date_rec IS RECORD (
29 cal_date DATE,
30 is_workday NUMBER );
31 TYPE date_tbl IS TABLE OF date_rec
32 INDEX BY BINARY_INTEGER;
33
34 TYPE workday_rec IS RECORD(
35 workday DATE);
36 TYPE workdays_tbl IS TABLE OF workday_rec
37 INDEX BY BINARY_INTEGER;
38
39 TYPE shopday_dtl_rec IS RECORD (
40 shift_no NUMBER,
41 shift_start NUMBER ,
42 shift_duration NUMBER );
43 TYPE shopday_dtl_tbl IS TABLE OF shopday_dtl_rec
44 INDEX BY BINARY_INTEGER;
45
46 /*#
47 * API for IS_WORKING_DAY - FUNCTION
48 * This API takes Calendar_id and date as input and returns if the given
49 * day is a Working day or not.
50 * @param p_api_version Version Number of the API
51 * @param p_init_msg_list Flag for initializing message list
52 * @param p_calendar_code This is the calendar code.
53 * @param p_date This is the date which is determined to be a work day or not
54 * @param x_return_status Return status 'S'-Success, 'E'-Error,
55 * 'U'-Unexpected Error
56 * @rep:scope public
57 * @rep:lifecycle active
58 * @rep:displayname IS_WORKING_DAY
59 */
60 FUNCTION is_working_day(
61 p_api_version IN NUMBER,
62 p_init_msg_list IN BOOLEAN := TRUE,
63 p_calendar_code IN VARCHAR2,
64 p_date IN DATE,
65 x_return_status IN OUT NOCOPY VARCHAR2
66 ) RETURN BOOLEAN ;
67
68 /*#
69 * API for IS_WORKING_DAYTIME - FUNCTION
70 * This API returns if the date time passed for a calendar is a falls during
71 * working time of a work day.
72 * @param p_api_version Version Number of the API
73 * @param p_init_msg_list Flag for initializing message list
74 * @param p_calendar_code This is the calendar code.
75 * @param p_date This is the date and time which is determined to be in the
76 * worktime or not
77 * @param p_ind Indicator takes values 0 or 1, 0 means Start and 1 means End.
78 * @param x_return_status Return status 'S'-Success, 'E'-Error,
79 * 'U'-Unexpected Error
80 * @rep:scope public
81 * @rep:lifecycle active
82 * @rep:displayname IS_WORKING_DAYTIME
83 */
84 FUNCTION IS_WORKING_DAYTIME(
85 p_api_version IN NUMBER,
86 p_init_msg_list IN BOOLEAN := TRUE,
87 p_calendar_code IN VARCHAR2,
88 p_date IN DATE,
89 p_ind IN NUMBER,
90 x_return_status IN OUT NOCOPY VARCHAR2
91 ) RETURN BOOLEAN ;
92
93
94 /*#
95 * API for GET_CONTIGUOUS_PERIODS - PROCEDURE
96 * This s the API to fetch contiguous periods of times that add upto the
97 * required duration.If Start date is given, the duration is calculated
98 * from the start date forward. If the end date is given, the duration is
99 * calculated from the end date backwards. The return is the collection of
100 * contiguous periods with their start date,end date and durations
101 *
102 * @param p_api_version Version Number of the API
103 * @param p_init_msg_list Flag for initializing message list
104 * @param p_start_date This is the Start date
105 * @param p_end_date This is the end date
106 * @param p_calendar_code This is the calendar code.
107 * @param p_duration This is the required durationrequired. The sum of
108 * contiguous periods fetched add upto this. Contiguous periods start on or
109 * after start date if provided. Or contiguous period end at or before end date
110 * if provided. Only one of the two dates can be supplied.
111 * @param p_output_tbl This is PL/SQL table where the output is stored
112 * @param x_return_status Return status 'S'-Success, 'E'-Error,
113 * 'U'-Unexpected Error
114 * @rep:scope public
115 * @rep:lifecycle active
116 * @rep:displayname GET_CONTIGUOUS_PERIODS
117 */
118 PROCEDURE get_contiguous_periods(
119 p_api_version IN NUMBER,
120 p_init_msg_list IN BOOLEAN := TRUE,
121 p_start_date IN DATE,
122 p_end_date IN DATE,
123 p_calendar_code IN VARCHAR2,
124 p_duration IN NUMBER,
125 p_output_tbl OUT NOCOPY contig_period_tbl,
126 x_return_status IN OUT NOCOPY VARCHAR2
127 ) ;
128
129 /*#
130 * API for GET_ALL_DATES - PROCEDURE
131 * This API returns the Working and Non-Working days between a specified
132 * Start and End dates in Calendar
133 * @param p_api_version Version Number of the API
134 * @param p_init_msg_list Flag for initializing message list
135 * @param p_calendar_code This is the calendar code.
136 * @param p_start_date This is the start date of the desired range
137 * @param p_end_date This is the End date of the desired range
138 * @param p_output_tbl This is PL/SQL table where the output is stored
139 * @param x_return_status Return status 'S'-Success, 'E'-Error,
140 * 'U'-Unexpected Error
141 * @rep:scope public
142 * @rep:lifecycle active
143 * @rep:displayname GET_ALL_DATES
144 */
145 PROCEDURE get_all_dates(
146 p_api_version IN NUMBER,
147 p_init_msg_list IN BOOLEAN := TRUE,
148 p_calendar_code IN VARCHAR2,
149 p_start_date IN DATE,
150 p_end_date IN DATE,
151 p_output_tbl OUT NOCOPY date_tbl,
152 x_return_status IN OUT NOCOPY VARCHAR2
153 );
154
155 /*#
156 * API for GET_WORK_DAYS - PROCEDURE
157 * This API returns the Working days between a specified
158 * Start and End dates in Calendar
159 * @param p_api_version Version Number of the API
160 * @param p_init_msg_list Flag for initializing message list
161 * @param p_calendar_code This is the calendar code.
162 * @param p_start_date This is the start date of the desired date range
163 * @param p_end_date This is the End date of the desired date range
164 * @param p_output_tbl This is PL/SQL table where the output is stored
165 * @param x_return_status Return status 'S'-Success, 'E'-Error,
166 * 'U'-Unexpected Error
167 * @rep:scope public
168 * @rep:lifecycle active
169 * @rep:displayname GET_WORK_DAYS
170 */
171 PROCEDURE get_work_days(
172 p_api_version IN NUMBER,
173 p_init_msg_list IN BOOLEAN := TRUE,
174 p_calendar_code IN VARCHAR2,
175 p_start_date IN DATE,
176 p_end_date IN DATE,
177 p_output_tbl OUT NOCOPY workdays_tbl,
178 x_return_status IN OUT NOCOPY VARCHAR2
179 );
180
181 /*#
182 * API for GET_WORKDAY_DETAILS - PROCEDURE
183 * This API returns the Working day details i.e. shift numbers and their
184 * durations for a given Shop Day
185 * @param p_api_version Version Number of the API
186 * @param p_init_msg_list Flag for initializing message list
187 * @param p_calendar_code This is the calendar code.
188 * @param p_shopday_no This is the calendar Shop Day.
189 * @param p_output_tbl This is PL/SQL table where the output is stored
190 * @param x_return_status Return status 'S'-Success, 'E'-Error,
191 * 'U'-Unexpected Error
192 * @rep:scope public
193 * @rep:lifecycle active
194 * @rep:displayname GET_WORKDAY_DETAILS
195 */
196 PROCEDURE get_workday_details(
197 p_api_version IN NUMBER,
198 p_init_msg_list IN BOOLEAN := TRUE,
199 p_calendar_code IN VARCHAR2,
200 p_shopday_no IN NUMBER,
201 p_output_tbl OUT NOCOPY shopday_dtl_tbl,
202 x_return_status IN OUT NOCOPY VARCHAR2
203 );
204
205 -- Bug: 6265867 Kbanddyo added this procedure
206 /*#
207 * Returns the nearest working day details,shift numbers
208 * @param p_api_version Version Number of the API
209 * @param p_init_msg_list Flag for initializing message list
210 * @param p_calendar_id This is the calendar id.
211 * @param p_date This is the date to be checked against calendar
212 * @param p_direction This provides the direction to find nearest date forward
213 * or backward
214 * @param x_date This is the nearest date checked against the calendar
215 * @param x_return_status Return status 'S'-Success, 'E'-Error,
216 * 'U'-Unexpected Error
217 * @rep:scope public
218 * @rep:lifecycle active
219 * @rep:displayname GET_NEAREST_WORKDAYTIME
220 */
221 PROCEDURE get_nearest_workdaytime(
222 p_api_version IN NUMBER,
223 p_init_msg_list IN BOOLEAN := TRUE,
224 p_calendar_id IN VARCHAR2,
225 p_date IN DATE,
226 p_direction IN NUMBER,
227 x_date IN OUT NOCOPY DATE ,
228 x_return_status IN OUT NOCOPY VARCHAR2
229 ) ;
230
231 END gmp_calendar_api ;