[Home] [Help]
PACKAGE BODY: APPS.HXC_TIME_ENTRY_RULE_GROUP_API
Source
1 Package Body hxc_time_entry_rule_group_api as
2 /* $Header: hxctegapi.pkb 120.2 2005/09/23 07:10:15 nissharm noship $ */
3 --
4 -- Package Variables
5 --
6 g_package varchar2(33) := ' hxc_time_entry_rule_group_api.';
7
8 g_entity_type varchar2(16) := 'TIME_ENTRY_RULES';
9
10 g_debug boolean := hr_utility.debug_enabled;
11 --
12 -- ----------------------------------------------------------------------------
13 -- |-----------------------< create_time_entry_rule_group >------------------------|
14 -- ----------------------------------------------------------------------------
15 --
16 procedure create_time_entry_rule_group
17 (p_validate in boolean default false
18 ,p_time_entry_rule_group_id in out nocopy number
19 ,p_object_version_number in out nocopy number
20 ,p_name in varchar2
21 ) is
22 --
23 -- Declare cursors and local variables
24 --
25 l_proc varchar2(72);
26 l_object_version_number hxc_entity_groups.object_version_number%TYPE;
27 l_time_entry_rule_group_id hxc_entity_groups.entity_group_id%TYPE;
28 --
29 begin
30 g_debug := hr_utility.debug_enabled;
31 --
32
33 --
34 if g_debug then
35 l_proc := g_package||' create_entity_group';
36 hr_utility.set_location('Entering:'|| l_proc, 10);
37 end if;
38 --
39 -- Issue a savepoint if operating in validation only mode
40 --
41 savepoint create_time_entry_rule_group;
42 --
43 hxc_time_entry_rule_group_api.chk_name
44 ( p_name => p_name
45 , p_entity_type => g_entity_type
46 , p_entity_group_id => p_time_entry_rule_group_id );
47
48 if g_debug then
49 hr_utility.set_location(l_proc, 20);
50 end if;
51 --
52 -- Call Before Process User Hook
53 --
54 begin
55 hxc_time_entry_rule_group_BK_1.create_time_entry_rule_group_b
56 (p_time_entry_rule_group_id => p_time_entry_rule_group_id
57 ,p_object_version_number => p_object_version_number
58 ,p_name => p_name
59 );
60 exception
61 when hr_api.cannot_find_prog_unit then
62 hr_api.cannot_find_prog_unit_error
63 (p_module_name => 'create_time_entry_rule_group'
64 ,p_hook_type => 'BP'
65 );
66 end;
67 --
68 if g_debug then
69 hr_utility.set_location(l_proc, 30);
70 end if;
71 --
72 -- Process Logic
73 --
74 --
75 if g_debug then
76 hr_utility.set_location(l_proc, 40);
77 end if;
78 --
79 -- call row handler
80 --
81 hxc_heg_ins.ins (
82 p_name => p_name
83 ,p_entity_type => g_entity_type
84 ,p_entity_group_id => l_time_entry_rule_group_id
85 ,p_object_version_number => l_object_version_number );
86 --
87 if g_debug then
88 hr_utility.set_location(l_proc, 50);
89 end if;
90 --
91 -- Call After Process User Hook
92 --
93 begin
94 hxc_time_entry_rule_group_BK_1.create_time_entry_rule_group_a
95 (p_time_entry_rule_group_id => l_time_entry_rule_group_id
96 ,p_object_version_number => l_object_version_number
97 ,p_name => p_name
98 );
99 exception
100 when hr_api.cannot_find_prog_unit then
101 hr_api.cannot_find_prog_unit_error
102 (p_module_name => 'create_time_entry_rule_group'
103 ,p_hook_type => 'AP'
104 );
105 end;
106 --
107 if g_debug then
108 hr_utility.set_location(l_proc, 60);
109 end if;
110 --
111 -- When in validation only mode raise the Validate_Enabled exception
112 --
113 if p_validate then
114 raise hr_api.validate_enabled;
115 end if;
116 --
117 if g_debug then
118 hr_utility.set_location(' Leaving:'||l_proc, 70);
119 end if;
120 --
121 -- Set all output arguments
122 --
123 p_time_entry_rule_group_id := l_time_entry_rule_group_id;
124 p_object_version_number := l_object_version_number;
125 --
126 exception
127 --
128 when hr_api.validate_enabled then
129 --
130 -- As the Validate_Enabled exception has been raised
131 -- we must rollback to the savepoint
132 --
133 ROLLBACK TO create_time_entry_rule_group;
134 --
135 -- Only set output warning arguments
136 -- (Any key or derived arguments must be set to null
137 -- when validation only mode is being used.)
138 --
139 p_time_entry_rule_group_id := null;
140 p_object_version_number := null;
141 --
142 if g_debug then
143 hr_utility.set_location(' Leaving:'||l_proc, 80);
144 end if;
145 --
146 when others then
147 --
148 -- A validation or unexpected error has occured
149 --
150 if g_debug then
151 hr_utility.trace('In exeception');
152 end if;
153 ROLLBACK TO create_time_entry_rule_group;
154 raise;
155 --
156 END create_time_entry_rule_group;
157 --
158 -- ----------------------------------------------------------------------------
159 -- |-------------------< update_time_entry_rule_group>-----------------------------|
160 -- ----------------------------------------------------------------------------
161 --
162 procedure update_time_entry_rule_group
163 (p_validate in boolean default false
164 ,p_time_entry_rule_group_id in number
165 ,p_object_version_number in out nocopy number
166 ,p_name in varchar2
167 ) is
168 --
169 -- Declare cursors and local variables
170 --
171 l_proc varchar2(72);
172 l_object_version_number hxc_entity_groups.object_version_number%TYPE := p_object_version_number;
173 --
174 begin
175 g_debug := hr_utility.debug_enabled;
176 --
177 if g_debug then
178 l_proc := g_package||' update_time_entry_rule_group';
179 hr_utility.set_location('Entering:'|| l_proc, 10);
180 end if;
181 --
182 -- Issue a savepoint if operating in validation only mode
183 --
184 savepoint update_time_entry_rule_group;
185 --
186 hxc_time_entry_rule_group_api.chk_name
187 ( p_name => p_name
188 , p_entity_type => g_entity_type
189 , p_entity_group_id => p_time_entry_rule_group_id );
190
191 if g_debug then
192 hr_utility.set_location(l_proc, 20);
193 end if;
194 --
195 -- Call Before Process User Hook
196 --
197 begin
198 hxc_time_entry_rule_group_BK_2.update_time_entry_rule_group_b
199 (p_time_entry_rule_group_id => p_time_entry_rule_group_id
200 ,p_object_version_number => p_object_version_number
201 ,p_name => p_name
202 );
203 exception
204 when hr_api.cannot_find_prog_unit then
205 hr_api.cannot_find_prog_unit_error
206 (p_module_name => 'update_time_entry_rule_group'
207 ,p_hook_type => 'BP'
208 );
209 end;
210 --
211 if g_debug then
212 hr_utility.set_location(l_proc, 30);
213 end if;
214 --
215 -- Process Logic
216 --
217 -- call row handler
218 --
219 hxc_heg_upd.upd (
220 p_name => p_name
221 ,p_entity_type => g_entity_type
222 ,p_entity_group_id => p_time_entry_rule_group_id
223 ,p_object_version_number => l_object_version_number );
224 --
225 --
226 if g_debug then
227 hr_utility.set_location(l_proc, 40);
228 end if;
229 --
230 -- Call After Process User Hook
231 --
232 begin
233 hxc_time_entry_rule_group_BK_2.update_time_entry_rule_group_a
234 (p_time_entry_rule_group_id => p_time_entry_rule_group_id
235 ,p_object_version_number => l_object_version_number
236 ,p_name => p_name
237 );
238 exception
239 when hr_api.cannot_find_prog_unit then
240 hr_api.cannot_find_prog_unit_error
241 (p_module_name => 'update_time_entry_rule_group'
242 ,p_hook_type => 'AP'
243 );
244 end;
245 --
246 if g_debug then
247 hr_utility.set_location(l_proc, 50);
248 end if;
249 --
250 -- When in validation only mode raise the Validate_Enabled exception
251 --
252 if p_validate then
253 raise hr_api.validate_enabled;
254 end if;
255 --
256 if g_debug then
257 hr_utility.set_location(' Leaving:'||l_proc, 60);
258 end if;
259 --
260 -- Set all output arguments
261 --
262 p_object_version_number := l_object_version_number;
263 --
264 exception
265 --
266 when hr_api.validate_enabled then
267 --
268 -- As the Validate_Enabled exception has been raised
269 -- we must rollback to the savepoint
270 --
271 ROLLBACK TO update_time_entry_rule_group;
272 --
273 -- Only set output warning arguments
274 -- (Any key or derived arguments must be set to null
275 -- when validation only mode is being used.)
276 --
277 p_object_version_number := null;
278 --
279 if g_debug then
280 hr_utility.set_location(' Leaving:'||l_proc, 60);
281 end if;
282 --
283 when others then
284 --
285 -- A validation or unexpected error has occured
286 --
287 if g_debug then
288 hr_utility.trace('In exeception');
289 end if;
290 ROLLBACK TO update_time_entry_rule_group;
291 raise;
292 --
293 END update_time_entry_rule_group;
294 --
295 -- ----------------------------------------------------------------------------
296 -- |----------------------< delete_time_entry_rule_group >-------------------------|
297 -- ----------------------------------------------------------------------------
298 --
299 procedure delete_time_entry_rule_group
300 (p_validate in boolean default false
301 ,p_time_entry_rule_group_id in number
302 ,p_object_version_number in number
303 ) is
304 --
305 -- Declare cursors and local variables
306 --
307 l_proc varchar2(72);
308 --
309 begin
310 g_debug := hr_utility.debug_enabled;
311 --
312
313 if g_debug then
314 l_proc := g_package||'delete_time_entry_rule_group';
315 hr_utility.set_location('Entering:'|| l_proc, 10);
316 end if;
317 --
318 -- Issue a savepoint if operating in validation only mode
319 --
320 savepoint delete_time_entry_rule_group;
321 --
322 hxc_time_entry_rule_group_api.chk_delete (
323 p_entity_group_id => p_time_entry_rule_group_id
324 , p_entity_type => g_entity_type );
325
326 if g_debug then
327 hr_utility.set_location(l_proc, 20);
328 end if;
329 --
330 -- Call Before Process User Hook
331 --
332 begin
333 --
334 hxc_time_entry_rule_group_BK_3.delete_time_entry_rule_group_b
335 (p_time_entry_rule_group_id => p_time_entry_rule_group_id
336 ,p_object_version_number => p_object_version_number
337 );
338 exception
339 when hr_api.cannot_find_prog_unit then
340 hr_api.cannot_find_prog_unit_error
341 (p_module_name => 'delete_time_entry_rule_group_b'
342 ,p_hook_type => 'BP'
343 );
344 end;
345 --
346 if g_debug then
347 hr_utility.set_location(l_proc, 30);
348 end if;
349 --
350 -- Process Logic
351 --
352 hxc_heg_del.del
353 (
354 p_entity_group_id => p_time_entry_rule_group_id
355 ,p_object_version_number => p_object_version_number
356 );
357 --
358 if g_debug then
359 hr_utility.set_location(l_proc, 40);
360 end if;
361 --
362 -- Call After Process User Hook
363 --
364 begin
365 --
366 hxc_time_entry_rule_group_BK_3.delete_time_entry_rule_group_a
367 (p_time_entry_rule_group_id => p_time_entry_rule_group_id
368 ,p_object_version_number => p_object_version_number
369 );
370 exception
371 when hr_api.cannot_find_prog_unit then
372 hr_api.cannot_find_prog_unit_error
373 (p_module_name => 'delete_time_entry_rule_group_a'
374 ,p_hook_type => 'AP'
375 );
376 end;
377 --
378 -- When in validation only mode raise the Validate_Enabled exception
379 --
380 if p_validate then
381 raise hr_api.validate_enabled;
382 end if;
383 --
384 if g_debug then
385 hr_utility.set_location(' Leaving:'||l_proc, 50);
386 end if;
387 --
388 exception
389 --
390 when hr_api.validate_enabled then
391 --
392 -- As the Validate_Enabled exception has been raised
393 -- we must rollback to the savepoint
394 --
395 ROLLBACK TO delete_time_entry_rule_group;
396 --
397 when others then
398 --
399 -- A validation or unexpected error has occured
400 --
401 ROLLBACK TO delete_time_entry_rule_group;
402 raise;
403 --
404 end delete_time_entry_rule_group;
405 --
406 --
407 -- ----------------------------------------------------------------------------
408 -- |-----------------------< chk_name >---------------------------------------|
409 -- ----------------------------------------------------------------------------
410 --
411 -- Description:
412 --
413 -- SEE DESCRIPTION IN PACKAGE HEADER
414 --
415 -- Note:
416 -- This procedure is called from the client
417 --
418 -- ----------------------------------------------------------------------------
419 Procedure chk_name
420 (
421 p_name in hxc_entity_groups.name%TYPE
422 ,p_entity_type in hxc_entity_group_Comps.entity_type%TYPE
423 ,p_entity_group_id in hxc_entity_groups.entity_group_id%TYPE
424 ) IS
425
426 l_proc varchar2(72);
427 --
428 -- cursor to check name is unique
429 --
430 CURSOR csr_chk_name IS
431 SELECT 'error'
432 FROM sys.dual
433 WHERE EXISTS (
434 SELECT 'x'
435 FROM hxc_entity_groups heg
436 WHERE heg.name = p_name
437 AND heg.entity_type = p_entity_type AND
438 ( heg.entity_group_id <> p_entity_group_id OR
439 p_entity_group_id IS NULL ) );
440 --
441 l_dup_name varchar2(5) := NULL;
442 --
443 BEGIN
444 g_debug := hr_utility.debug_enabled;
445
446 if g_debug then
447 l_proc := g_package||'chk_name';
448 hr_utility.set_location('Entering:'||l_proc, 5);
449 end if;
450 --
451 -- check that the name has been entered
452 --
453 IF ( p_name IS NULL )
454 THEN
455 --
456 hr_utility.set_message(809, 'HXC_HEG_TER_NAME_MAND');
457 hr_utility.raise_error;
458 --
459 END IF;
460 if g_debug then
461 hr_utility.set_location('Processing:'||l_proc, 10);
462 end if;
463 --
464 -- check that the name is unique
465 --
466 OPEN csr_chk_name;
467 FETCH csr_chk_name INTO l_dup_name;
468 CLOSE csr_chk_name;
469 --
470 IF ( l_dup_name IS NOT NULL )
471 THEN
472 --
473 hr_utility.set_message(809, 'HXC_HEG_TER_NAME_DUP');
474 hr_utility.raise_error;
475 --
476 END IF;
477 --
478 hr_utility.set_location('Leaving:'||l_proc, 20);
479 --
480 END chk_name;
481 --
482 -- ----------------------------------------------------------------------------
483 -- |-----------------------< chk_delete >-------------------------------------|
484 -- ----------------------------------------------------------------------------
485 --
486 -- Description:
487 --
488 -- SEE DESCRIPTION IN PACKAGE HEADER
489 --
490 -- ----------------------------------------------------------------------------
491 Procedure chk_delete
492 (
493 p_entity_group_id in hxc_entity_groups.entity_group_id%TYPE
494 ,p_entity_type in hxc_entity_group_comps.entity_type%TYPE
495 ) IS
496 --
497 l_proc varchar2(72);
498 --
499 --
500 /*
501 CURSOR csr_chk_pref IS
502 SELECT 'exists'
503 FROM sys.dual
504 WHERE EXISTS (
505 SELECT 'x'
506 FROM hxc_resource_all_elig_pref_v
507 WHERE preference_code = 'TS_PER_TIME_ENTRY_RULES'
508 AND attribute1 = TO_CHAR(p_entity_group_id) );
509 */
510 l_exists VARCHAR2(6) := NULL;
511
512 BEGIN
513 g_debug := hr_utility.debug_enabled;
514
515 if g_debug then
516 l_proc := g_package||'chk_delete';
517 hr_utility.set_location('Entering:'||l_proc, 5);
518 end if;
519
520 -- check that entity_group is not being used in the pref hierarchy
521
522 /*OPEN csr_chk_pref;
523 FETCH csr_chk_pref INTO l_exists;
524 CLOSE csr_chk_pref;*/
525
526 if g_debug then
527 hr_utility.set_location('Calling num_hierarchy_occurances:'||l_proc,10);
528 end if;
529 l_exists := HXC_PREFERENCE_EVALUATION.num_hierarchy_occurances
530 ('TS_PER_TIME_ENTRY_RULES'
531 ,1
532 ,TO_CHAR(p_entity_group_id));
533 if g_debug then
534 hr_utility.set_location('After calling num_hierarchy_occurances:'||l_proc,20);
535 end if;
536
537 IF l_exists <> 0 THEN
538 --
539 hr_utility.set_message(809, 'HXC_HEG_TER_IN_USE');
540 hr_utility.raise_error;
541 --
542 END IF;
543 --
544 if g_debug then
545 hr_utility.set_location('Processing: '||l_proc, 60);
546 end if;
547 --
548 -- Start Fix for Bug No. 2873485
549 l_exists := null;
550 l_exists := HXC_PREFERENCE_EVALUATION.num_hierarchy_occurances
551 ('TS_PER_ELP_RULES'
552 ,1
553 ,TO_CHAR(p_entity_group_id));
554 IF l_exists <> 0 THEN
555
556 hr_utility.set_message(809, 'HXC_HEG_TER_IN_USE');
557 hr_utility.raise_error;
558 --
559 END IF;
560 if g_debug then
561 hr_utility.set_location('Processing: '||l_proc, 70);
562 end if;
563 -- End Fix for Bug No. 2873485
564
565 l_exists := null;
566 l_exists := HXC_PREFERENCE_EVALUATION.num_hierarchy_occurances
567 ('TS_PER_AUDIT_REQUIREMENTS'
568 ,1
569 ,TO_CHAR(p_entity_group_id));
570 IF l_exists <> 0 THEN
571
572 hr_utility.set_message(809, 'HXC_HEG_TER_IN_USE');
573 hr_utility.raise_error;
574 --
575 END IF;
576 END chk_delete;
577 --
578 END hxc_time_entry_rule_group_api;