1 Package Body ota_frm_bus as
2 /* $Header: otfrmrhi.pkb 120.3 2006/04/27 00:19 aabalakr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ota_frm_bus.'; -- Global package name
9 --
10 -- The following two global variables are only to be
11 -- used by the return_legislation_code function.
12 --
13 g_legislation_code varchar2(150) default null;
14 g_forum_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_forum_id in number
22 ,p_associated_column1 in varchar2 default null
23 ) is
24 --
25 -- Declare cursor
26 --
27 cursor csr_sec_grp is
28 select pbg.security_group_id,
29 pbg.legislation_code
30 from per_business_groups_perf pbg
31 , ota_forums_b frm
32 where frm.forum_id = p_forum_id
33 and pbg.business_group_id = frm.business_group_id;
34 --
35 -- Declare local variables
36 --
37 l_security_group_id number;
38 l_proc varchar2(72) := g_package||'set_security_group_id';
39 l_legislation_code varchar2(150);
40 --
41 begin
42 --
43 hr_utility.set_location('Entering:'|| l_proc, 10);
44 --
45 -- Ensure that all the mandatory parameter are not null
46 --
47 hr_api.mandatory_arg_error
48 (p_api_name => l_proc
49 ,p_argument => 'forum_id'
50 ,p_argument_value => p_forum_id
51 );
52 --
53 open csr_sec_grp;
54 fetch csr_sec_grp into l_security_group_id
55 , l_legislation_code;
56 --
57 if csr_sec_grp%notfound then
58 --
59 close csr_sec_grp;
60 --
61 -- The primary key is invalid therefore we must error
62 --
63 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
64 hr_multi_message.add
65 (p_associated_column1
66 => nvl(p_associated_column1,'FORUM_ID')
67 );
68 --
69 else
70 close csr_sec_grp;
71 --
72 -- Set the security_group_id in CLIENT_INFO
73 --
74 hr_api.set_security_group_id
75 (p_security_group_id => l_security_group_id
76 );
77 --
78 -- Set the sessions legislation context in HR_SESSION_DATA
79 --
80 hr_api.set_legislation_context(l_legislation_code);
81 end if;
82 --
83 hr_utility.set_location(' Leaving:'|| l_proc, 20);
84 --
85 end set_security_group_id;
86 --
87 -- ---------------------------------------------------------------------------
88 -- |---------------------< return_legislation_code >-------------------------|
89 -- ---------------------------------------------------------------------------
90 --
91 Function return_legislation_code
92 (p_forum_id in number
93 )
94 Return Varchar2 Is
95 --
96 -- Declare cursor
97 --
98 cursor csr_leg_code is
99 select pbg.legislation_code
100 from per_business_groups_perf pbg
101 , ota_forums_b frm
102 where frm.forum_id = p_forum_id
103 and pbg.business_group_id = frm.business_group_id;
104 --
105 -- Declare local variables
106 --
107 l_legislation_code varchar2(150);
108 l_proc varchar2(72) := g_package||'return_legislation_code';
109 --
110 Begin
111 --
112 hr_utility.set_location('Entering:'|| l_proc, 10);
113 --
114 -- Ensure that all the mandatory parameter are not null
115 --
116 hr_api.mandatory_arg_error
117 (p_api_name => l_proc
118 ,p_argument => 'forum_id'
119 ,p_argument_value => p_forum_id
120 );
121 --
122 if ( nvl(ota_frm_bus.g_forum_id, hr_api.g_number)
123 = p_forum_id) then
124 --
125 -- The legislation code has already been found with a previous
126 -- call to this function. Just return the value in the global
127 -- variable.
128 --
129 l_legislation_code := ota_frm_bus.g_legislation_code;
130 hr_utility.set_location(l_proc, 20);
131 else
132 --
133 -- The ID is different to the last call to this function
134 -- or this is the first call to this function.
135 --
136 open csr_leg_code;
137 fetch csr_leg_code into l_legislation_code;
138 --
139 if csr_leg_code%notfound then
140 --
141 -- The primary key is invalid therefore we must error
142 --
143 close csr_leg_code;
144 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
145 fnd_message.raise_error;
146 end if;
147 hr_utility.set_location(l_proc,30);
148 --
149 -- Set the global variables so the values are
150 -- available for the next call to this function.
151 --
152 close csr_leg_code;
153 ota_frm_bus.g_forum_id := p_forum_id;
154 ota_frm_bus.g_legislation_code := l_legislation_code;
155 end if;
156 hr_utility.set_location(' Leaving:'|| l_proc, 40);
157 return l_legislation_code;
158 end return_legislation_code;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |-----------------------< chk_non_updateable_args >------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 -- This procedure is used to ensure that non updateable attributes have
167 -- not been updated. If an attribute has been updated an error is generated.
168 --
169 -- Pre Conditions:
170 -- g_old_rec has been populated with details of the values currently in
171 -- the database.
172 --
173 -- In Arguments:
174 -- p_rec has been populated with the updated values the user would like the
175 -- record set to.
176 --
177 -- Post Success:
178 -- Processing continues if all the non updateable attributes have not
179 -- changed.
180 --
181 -- Post Failure:
182 -- An application error is raised if any of the non updatable attributes
183 -- have been altered.
184 --
185 -- {End Of Comments}
186 -- ----------------------------------------------------------------------------
187 Procedure chk_non_updateable_args
188 (p_effective_date in date
189 ,p_rec in ota_frm_shd.g_rec_type
190 ) IS
191 --
192 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
193 --
194 Begin
195 --
196 -- Only proceed with the validation if a row exists for the current
197 -- record in the HR Schema.
198 --
199 IF NOT ota_frm_shd.api_updating
200 (p_forum_id => p_rec.forum_id
201 ,p_object_version_number => p_rec.object_version_number
202 ) THEN
203 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
204 fnd_message.set_token('PROCEDURE ', l_proc);
205 fnd_message.set_token('STEP ', '5');
206 fnd_message.raise_error;
207 END IF;
208 --
209 -- EDIT_HERE: Add checks to ensure non-updateable args have
210 -- not been updated.
211 --
212 End chk_non_updateable_args;
213 --
214 -- ----------------------------------------------------------------------------
215 -- |----------------------------< check_start_end_dates >-----------------|
216 -- ----------------------------------------------------------------------------
217 -- PUBLIC
218 -- Description:
219 -- Validates the startdate and enddate.
220 -- Startdate must be less than, or equal to, enddate.
221 --
222 Procedure check_start_end_dates
223 ( p_start_date IN DATE
224 ,p_end_date in date
225 ) is
226 --
227 v_proc varchar2(72) := g_package||'check_start_end_dates';
228 --
229 Begin
230 --
231 hr_utility.set_location('Entering:'|| v_proc, 5);
232 --
233 ota_general.check_start_end_dates( p_start_date, p_end_date);
234 --
235 hr_utility.set_location(' Leaving:'|| v_proc, 10);
236
237 Exception
238 WHEN app_exception.application_exception THEN
239
240 IF hr_multi_message.exception_add(
241 p_associated_column1 => 'OTA_FORUMS_B.START_DATE_ACTIVE')
242 -- ,p_associated_column2 => 'OTA_FORUMS_B.END_DATE_ACTIVE')
243 THEN
244
245 hr_utility.set_location(' Leaving:'||v_proc, 22);
246 RAISE;
247
248 END IF;
249 hr_utility.set_location(' Leaving:'||v_proc, 25);
250 --
251 End check_start_end_dates;
252 --
253 --
254 -- BUG#4654544
255 -- ----------------------------------------------------------------------------
256 -- |--------------------------< chk_category_start_end_dates >----------------|
257 -- ----------------------------------------------------------------------------
258 --
259 -- PUBLIC
260 -- Description:
261 -- Validates the startdate and enddate with respect to category dates.
262 --
263 Procedure chk_category_start_end_dates
264 (p_forum_id in number
265 ,p_start_date in date
266 ,p_end_date in date
267 ) is
268 --
269 -- Declare cursors and local variables
270 --
271 -- Cursor to get value if parent category is already exits in child hierarchy of base category
272
273 CURSOR csr_cat_start_end_date is
274 select
275 ctu.start_date_active,
276 ctu.end_date_active
277 from
278 ota_category_usages ctu,
279 ota_frm_obj_inclusions foi
280 where
281 ctu.category_usage_id = foi.object_id
282 and foi.primary_flag= 'Y'
283 and foi.forum_id = p_forum_id;
284
285 --
286 -- Variables for API Boolean parameters
287 l_proc varchar2(72) := g_package ||'chk_category_start_end_dates';
288 l_cat_start_date date;
289 l_cat_end_date date;
290
291 Begin
292 hr_utility.set_location(' Entering:' || l_proc,10);
293 --
294 if(hr_multi_message.no_exclusive_error
295 (p_check_column1 => 'OTA_FORUMS_B.START_DATE_ACTIVE'
296 ,p_check_column2 => 'OTA_FORUMS_B.END_DATE_ACTIVE'
297 ,p_associated_column1 => 'OTA_FORUMS_B.START_DATE_ACTIVE'
298 ,p_associated_column2 => 'OTA_FORUMS_B.END_DATE_ACTIVE'
299 )) THEN
300 --
301 OPEN csr_cat_start_end_date;
302 FETCH csr_cat_start_end_date into l_cat_start_date, l_cat_end_date;
303
304 IF csr_cat_start_end_date%FOUND THEN
305 CLOSE csr_cat_start_end_date;
306
307 IF ( l_cat_start_date > p_start_date
308 or nvl(l_cat_end_date,hr_api.g_eot) < nvl(p_end_date,hr_api.g_eot)
309 ) THEN
310 --
311 fnd_message.set_name ( 'OTA','OTA_443785_FRM_OUTOF_CAT_DATES');
312 fnd_message.raise_error;
313 --
314 End IF;
315 ELSE
316 CLOSE csr_cat_start_end_date;
317
318 End IF;
319 End IF;
320 --
321 hr_utility.set_location(' Leaving:' || l_proc,10);
322 Exception
323 when app_exception.application_exception then
324 IF hr_multi_message.exception_add
325 (p_associated_column1 => 'OTA_FORUMS_B.START_DATE_ACTIVE'
326 ,p_associated_column2 => 'OTA_FORUMS_B.END_DATE_ACTIVE'
330 END IF;
327 ) THEN
328 hr_utility.set_location(' Leaving:'|| l_proc,20);
329 raise;
331
332 hr_utility.set_location(' Leaving:'|| l_proc,30);
333 --
334 End chk_category_start_end_dates;
335 --
336 -- BUG#4654544
337 -- ----------------------------------------------------------------------------
338 -- |--------------------------< chk_forum_end_date >--------------------------|
339 -- ----------------------------------------------------------------------------
340 --
341 -- PUBLIC
342 -- Description:
343 -- Validates the enddate and ensures that it is not newly set to less than sysydate
344 -- Exception being, if the category has already expired we can allow the forum end-date to be
345 -- less than the sysdate.
346 --
347 Procedure chk_forum_end_date
348 (p_forum_id in number
349 ,p_end_date in date
350 ) is
351 --
352 -- Declare cursors and local variables
353 --
354
355 CURSOR csr_cat_start_end_date is
356 select
357 ctu.end_date_active
358 from
359 ota_category_usages ctu,
360 ota_frm_obj_inclusions foi
361 where
362 ctu.category_usage_id = foi.object_id
363 and foi.primary_flag= 'Y'
364 and foi.forum_id = p_forum_id
365 and foi.object_type = 'C';
366
367 -- Variables for API Boolean parameters
368 l_proc varchar2(72) := g_package ||'chk_forum_end_date';
369 l_cat_end_date date;
370
371 Begin
372 hr_utility.set_location(' Entering:' || l_proc,10);
373 --
374 --
375 OPEN csr_cat_start_end_date;
376 FETCH csr_cat_start_end_date into l_cat_end_date;
377
378
379 IF NOT (trunc(nvl(l_cat_end_date,sysdate)) < trunc(sysdate)) then
380 IF (trunc(nvl(p_end_date,sysdate)) < trunc(sysdate)) THEN
381 --
382 fnd_message.set_name ( 'OTA','OTA_443992_FRM_END_DATE_ERR');
383 fnd_message.raise_error;
384 End IF;
385 End IF;
386 CLOSE csr_cat_start_end_date;
387
388 --
389 hr_utility.set_location(' Leaving:' || l_proc,10);
390 Exception
391 when app_exception.application_exception then
392 IF hr_multi_message.exception_add
393 (p_associated_column1 => 'OTA_FORUMS_B.END_DATE_ACTIVE'
394 ) THEN
395 hr_utility.set_location(' Leaving:'|| l_proc,20);
396 raise;
397 END IF;
398
399 hr_utility.set_location(' Leaving:'|| l_proc,30);
400 --
401 End chk_forum_end_date;
402 --
403 --
404 -- ----------------------------------------------------------------------------
405 -- |---------------------------< insert_validate >----------------------------|
406 -- ----------------------------------------------------------------------------
407 Procedure insert_validate
408 (p_effective_date in date
409 ,p_rec in ota_frm_shd.g_rec_type
410 ) is
411 --
412 l_proc varchar2(72) := g_package||'insert_validate';
413 --
414 Begin
415 hr_utility.set_location('Entering:'||l_proc, 5);
416 --
417 -- Call all supporting business operations
418 --
419 hr_api.validate_bus_grp_id
420 (p_business_group_id => p_rec.business_group_id
421 ,p_associated_column1 => ota_frm_shd.g_tab_nam
422 || '.BUSINESS_GROUP_ID');
423 --
424 -- After validating the set of important attributes,
425 -- if Multiple Message detection is enabled and at least
426 -- one error has been found then abort further validation.
427 --
428 --
429 hr_multi_message.end_validation_set;
430 --
431 ota_frm_bus.check_start_end_dates(p_rec.start_date_active
432 ,p_rec.end_date_active);
433
434 -- Validate Dependent Attributes
435 --
436 --
437 hr_utility.set_location(' Leaving:'||l_proc, 10);
438 End insert_validate;
439 --
440 -- ----------------------------------------------------------------------------
441 -- |---------------------------< update_validate >----------------------------|
442 -- ----------------------------------------------------------------------------
443 Procedure update_validate
444 (p_effective_date in date
445 ,p_rec in ota_frm_shd.g_rec_type
446 ) is
447 --
448 l_proc varchar2(72) := g_package||'update_validate';
449 --
450 Begin
451 hr_utility.set_location('Entering:'||l_proc, 5);
452 --
453 -- Call all supporting business operations
454 --
455 hr_api.validate_bus_grp_id
456 (p_business_group_id => p_rec.business_group_id
457 ,p_associated_column1 => ota_frm_shd.g_tab_nam
458 || '.BUSINESS_GROUP_ID');
459 --
460 -- After validating the set of important attributes,
461 -- if Multiple Message detection is enabled and at least
462 -- one error has been found then abort further validation.
463 --
464 hr_multi_message.end_validation_set;
465 --
466 -- Validate Dependent Attributes
467 --
468 chk_non_updateable_args
469 (p_effective_date => p_effective_date
470 ,p_rec => p_rec
471 );
472 --
473 ota_frm_bus.check_start_end_dates(p_rec.start_date_active
474 ,p_rec.end_date_active);
475
476 chk_forum_end_date(p_forum_id =>p_rec.forum_id,
477 p_end_date =>p_rec.end_date_active);
478
479 chk_category_start_end_dates(p_forum_id =>p_rec.forum_id,
483
480 p_start_date =>p_rec.start_date_active,
481 p_end_date =>p_rec.end_date_active );
482
484 --
485 --
486 hr_utility.set_location(' Leaving:'||l_proc, 10);
487 End update_validate;
488 --
489 -- ----------------------------------------------------------------------------
490 -- |---------------------------< delete_validate >----------------------------|
491 -- ----------------------------------------------------------------------------
492 Procedure delete_validate
493 (p_rec in ota_frm_shd.g_rec_type
494 ) is
495 --
496 l_proc varchar2(72) := g_package||'delete_validate';
497 --
498 Begin
499 hr_utility.set_location('Entering:'||l_proc, 5);
500 --
501 -- Call all supporting business operations
502 --
503 hr_utility.set_location(' Leaving:'||l_proc, 10);
504 End delete_validate;
505 --
506 end ota_frm_bus;