[Home] [Help]
PACKAGE BODY: APPS.HR_HIERARCHY_ELEMENT_API
Source
1 Package Body hr_hierarchy_element_api as
2 /* $Header: peoseapi.pkb 120.0 2005/05/31 12:22:41 appldev noship $ */
3 --
4 -- Package Variables
5 --
6 g_package varchar2(33) := ' hr_hierarchy_element_api.';
7 g_hr_installed varchar2(1);
8 g_pa_installed varchar2(1);
9 g_industry varchar2(20);
10 g_installed1 boolean := fnd_installation.get(800,800,g_hr_installed,g_industry);
11 g_installed2 boolean := fnd_installation.get(275,275,g_pa_installed,g_industry);
12 --
13 --
14 --
15 -- ----------------------------------------------------------------------------
16 -- |---------------------< create_hierarchy_element - new >--------------------|
17 -- ----------------------------------------------------------------------------
18 --
19 procedure create_hierarchy_element
20 (p_validate in boolean default false
21 ,p_effective_date in DATE
22 ,p_organization_id_parent in number
23 ,p_org_structure_version_id in number
24 ,p_organization_id_child in number
25 ,p_business_group_id in number default null
26 ,p_pos_control_enabled_flag in varchar2
27 ,p_inactive_org_warning out nocopy boolean
28 ,p_org_structure_element_id out nocopy number
29 ,p_object_version_number out nocopy number
30 ) is
31 --
32 -- Declare cursors and local variables
33 --
34 l_org_structure_element_id
35 per_org_structure_elements.org_structure_element_id%TYPE;
36 l_object_version_number
37 per_org_structure_elements.object_version_number%TYPE;
38 l_exists_in_hierarchy varchar2(1);
39 l_view_all_orgs varchar2(3);
40 l_effective_date date;
41 l_date_from date;
42 l_security_profile_id number;
43 l_warning_raised varchar2(1);
44 l_proc varchar2(72) := g_package||'create_hierarchy_element';
45 --
46 cursor get_old_element is select org_structure_element_id,
47 object_version_number
48 from per_org_structure_elements
49 where organization_id_child = p_Organization_Id_Child
50 and org_structure_version_id = p_org_structure_version_id;
51
52 --Bug fix 2879820 starts here
53
54 cursor c_date_from is select date_from
55 from per_org_structure_versions
56 where org_structure_version_id= p_org_structure_version_id;
57
58 cursor c_org_flag is select VIEW_ALL_ORGANIZATIONS_FLAG
59 from per_security_profiles
60 where security_profile_id= l_security_profile_id;
61
62 --Bug fix 2879820 ends here
63 --
64 begin
65 --
66 hr_utility.set_location('Entering:'|| l_proc, 10);
67 hr_utility.set_location('p_org_structure_version_id:'||p_org_structure_version_id, 568);
68 hr_utility.set_location('p_effective_date:'||p_effective_date, 568);
69 hr_utility.set_location('p_business_group_id:'||p_business_group_id, 568);
70 --
71 -- Issue a savepoint
72 --
73 savepoint create_hierarchy_element;
74 --
75 -- Truncate the time portion from all IN date parameters
76 --
77 l_effective_date := trunc(p_effective_date);
78 l_security_profile_id := hr_security.get_security_profile; --Bug 2879820
79
80
81 --
82 -- Call Before Process User Hook
83 --
84 begin
85 hr_hierarchy_element_bk1.create_hierarchy_element_b
86 ( p_effective_date => p_effective_date
87 ,p_organization_id_parent => p_organization_id_parent
88 ,p_org_structure_version_id => p_org_structure_version_id
89 ,p_organization_id_child => p_organization_id_child
90 ,p_business_group_id => p_business_group_id
91 ,p_pos_control_enabled_flag => p_pos_control_enabled_flag
92 );
93 exception
94 when hr_api.cannot_find_prog_unit then
95 hr_api.cannot_find_prog_unit_error
96 (p_module_name => 'create_hierarchy_element'
97 ,p_hook_type => 'BP'
98 );
99 end;
100 --
101 -- Validation in addition to Row Handlers
102 --Bug fix 2879820 starts here
103 --
104 open c_date_from;
105 fetch c_date_from into l_date_from;
106 if c_date_from%notfound then
107 close c_date_from;
108 hr_utility.set_message(800,'HR_289732_ORG_VER_INV');
109 hr_utility.raise_error;
110 else
111 close c_date_from;
112 end if;
113 --Bug fix 2879820 ends here
114 --
115 per_org_structure_elements_pkg.check_org_active
116 (p_org_id_parent => p_Organization_Id_Parent
117 ,p_date_from => l_date_from --Bug 2879820
118 ,p_end_of_time => hr_api.g_eot --Bug 2879820
119 ,p_warning_raised => l_warning_raised
120 );
121 if l_warning_raised= 'Y' then
122 p_inactive_org_warning := TRUE;
123 elsif l_warning_raised= 'N' then
124 p_inactive_org_warning := FALSE;
125 else
126 p_inactive_org_warning := NULL;
127 end if;
128 --
129 -- Process Logic
130 --
131 if ((hr_organization_units_pkg.exists_in_hierarchy(p_org_structure_version_id
132 ,p_organization_id_child) = 'Y')) then
133
134 --
135 -- Yes, then remove existing element and replace with a new one
136 --
137 open get_old_element;
138 fetch get_old_element into l_org_structure_element_id, l_object_version_number;
139 if get_old_element%found then
140 close get_old_element;
141 --
142 per_ose_del.del
143 (p_org_structure_element_id => l_org_structure_element_id
144 ,p_object_version_number => l_object_version_number
145 ,p_hr_installed => g_hr_installed --Bug 2879820
146 ,p_pa_installed => g_pa_installed --Bug 2879820
147 ,p_chk_children_exist => 'N'
148 );
149 --
150 else
151 close get_old_element;
152 end if;
153 end if;
154 --
155 per_ose_ins.ins
156 (p_organization_id_parent => p_organization_id_parent
157 ,p_org_structure_version_id => p_org_structure_version_id
158 ,p_organization_id_child => p_organization_id_child
159 ,p_business_group_id => p_business_group_id
160 ,p_effective_date => l_effective_date
161 ,p_org_structure_element_id => p_org_structure_element_id
162 ,p_object_version_number => p_object_version_number
163 ,p_pos_control_enabled_flag => p_pos_control_enabled_flag
164 );
165 --
166 -- Post-insert code
167 -- Maintains org_list security profiles
168 -- Bug fix 2879820 starts here
169 open c_org_flag;
170 fetch c_org_flag into l_view_all_orgs;
171 if c_org_flag%notfound then
172 l_view_all_orgs := 'Y';
173 close c_org_flag;
174 else
175 close c_org_flag;
176 end if;
177
178 if l_view_all_orgs = 'N' then
179 per_org_structure_elements_pkg.maintain_org_lists(p_Business_Group_Id
180 ,l_security_profile_id
181 ,p_Organization_Id_Parent
182 );
183 end if;
184 -- Bug fix 2879820 ends here
185 --
186 -- Call After Process User Hook
187 --
188 begin
189 hr_hierarchy_element_bk1.create_hierarchy_element_a
190 ( p_effective_date => p_effective_date
191 ,p_organization_id_parent => p_organization_id_parent
192 ,p_org_structure_version_id => p_org_structure_version_id
193 ,p_organization_id_child => p_organization_id_child
194 ,p_business_group_id => p_business_group_id
195 ,p_pos_control_enabled_flag => p_pos_control_enabled_flag
196 ,p_inactive_org_warning => p_inactive_org_warning
197 ,p_org_structure_element_id => p_org_structure_element_id
198 ,p_object_version_number => p_object_version_number
199 );
200 exception
201 when hr_api.cannot_find_prog_unit then
202 hr_api.cannot_find_prog_unit_error
203 (p_module_name => 'create_hierarchy_element'
204 ,p_hook_type => 'AP'
205 );
206 end;
207 --
208 -- When in validation only mode raise the Validate_Enabled exception
209 --
210 if p_validate then
211 raise hr_api.validate_enabled;
212 end if;
213 --
214 -- Set all output arguments
215 -- use values returned from ins (PZWALKER)
216 -- p_id := <local_var_set_in_process_logic>
217 -- p_object_version_number := <local_var_set_in_process_logic>
218 -- p_some_warning := <local_var_set_in_process_logic>
219 --
220 hr_utility.set_location(' Leaving:'||l_proc, 70);
221 exception
222 when hr_api.validate_enabled then
223 --
224 -- As the Validate_Enabled exception has been raised
225 -- we must rollback to the savepoint
226 --
227 rollback to create_hierarchy_element;
228 --
229 -- Only set output warning arguments
230 -- (Any key or derived arguments must be set to null
231 -- when validation only mode is being used.)
232 --
233 p_org_structure_element_id := null;
234 p_object_version_number := null;
235 hr_utility.set_location(' Leaving:'||l_proc, 80);
236 when others then
237 --
238 -- A validation or unexpected error has occured
239 --
240 rollback to create_hierarchy_element;
241 --
242 -- set in out parameters and set out parameters
243 --
244 p_org_structure_element_id := null;
245 p_object_version_number := null;
246 p_inactive_org_warning := null;
247 hr_utility.set_location(' Leaving:'||l_proc, 90);
248 raise;
249 end create_hierarchy_element;
250 --
251 -- ----------------------------------------------------------------------------
252 -- |--------------------------< create_hierarchy_element- old >--------------------|
253 -- ----------------------------------------------------------------------------
254 --
255 procedure create_hierarchy_element
256 (p_validate in boolean default false
257 ,p_organization_id_parent in number
258 ,p_org_structure_version_id in number
259 ,p_organization_id_child in number
260 ,p_business_group_id in number default null
261 ,p_effective_date in DATE
262 ,p_date_from in DATE
263 ,p_security_profile_id in NUMBER
264 ,p_view_all_orgs in VARCHAR2
265 ,p_end_of_time in DATE
266 ,p_hr_installed in VARCHAR2
267 ,p_pa_installed in VARCHAR2
268 ,p_pos_control_enabled_flag in varchar2
269 ,p_warning_raised IN OUT NOCOPY VARCHAR2
270 ,p_org_structure_element_id out nocopy number
271 ,p_object_version_number out nocopy number
272 ) is
273 --
274 -- Declare cursors and local variables
275 --
276 l_inactive_org_warning boolean;
277 l_proc varchar2(72) := g_package||'create_hierarchy_element (old)';
278 --
279 begin
280 hr_utility.set_location('Entering:'|| l_proc, 10);
281 --
282 -- Issue a savepoint
283 --
284 savepoint create_hierarchy_element1;
285
286 create_hierarchy_element(
287 p_validate => p_validate
288 ,p_effective_date => p_effective_date
289 ,p_organization_id_parent => p_organization_id_parent
290 ,p_org_structure_version_id => p_org_structure_version_id
291 ,p_organization_id_child => p_organization_id_child
292 ,p_business_group_id => p_business_group_id
293 ,p_pos_control_enabled_flag => p_pos_control_enabled_flag
294 ,p_inactive_org_warning => l_inactive_org_warning
295 ,p_org_structure_element_id => p_org_structure_element_id
296 ,p_object_version_number => p_object_version_number
297 );
298
299 if l_inactive_org_warning then
300 p_warning_raised := 'Y';
301 elsif not(l_inactive_org_warning) then
302 p_warning_raised := 'N';
303 else
304 p_warning_raised := null;
305 end if;
306 --
307 hr_utility.set_location(' Leaving:'||l_proc, 70);
308 --
309 end create_hierarchy_element;
310 --
311 --
312 -- ----------------------------------------------------------------------------
313 -- |--------------------------< update_hierarchy_element >--------------------|
314 -- ----------------------------------------------------------------------------
315 --
316 procedure update_hierarchy_element
317 (p_validate in boolean default false
318 ,p_effective_date in date
319 ,p_org_structure_element_id in number
320 ,p_organization_id_parent in number default hr_api.g_number
321 ,p_organization_id_child in number default hr_api.g_number
322 ,p_pos_control_enabled_flag in varchar2 default hr_api.g_varchar2
323 ,p_object_version_number in out nocopy number
324 ) is
325 --
326 -- Declare cursors and local variables
327 --
328 l_effective_date date;
329 l_proc varchar2(72) := g_package||'update_hierarchy_element';
330 l_object_version_number per_org_structure_elements
331 .object_version_number%TYPE;
332 l_ovn per_org_structure_elements .object_version_number%TYPE := p_object_version_number;
333 begin
334 hr_utility.set_location('Entering:'|| l_proc, 10);
335 --
336 l_object_version_number := p_object_version_number;
337 --
338 -- Issue a savepoint
339 --
340 savepoint update_hierarchy_element;
341 --
342 -- Truncate the time portion from all IN date parameters
343 --
344 l_effective_date := trunc(p_effective_date);
345
346 --
347 -- Call Before Process User Hook
348 --
349 begin
350 hr_hierarchy_element_bk2.update_hierarchy_element_b
351 (p_effective_date => p_effective_date
352 ,p_org_structure_element_id => p_org_structure_element_id
353 ,p_organization_id_parent => p_organization_id_parent
354 ,p_organization_id_child => p_organization_id_child
355 ,p_pos_control_enabled_flag => p_pos_control_enabled_flag
356 ,p_object_version_number => p_object_version_number
357 );
358 exception
359 when hr_api.cannot_find_prog_unit then
360 hr_api.cannot_find_prog_unit_error
361 (p_module_name => 'update_hierarchy_element'
362 ,p_hook_type => 'BP'
363 );
364 end;
365 --
366 -- Validation in addition to Row Handlers
367 --
368
369
370
371 --
372 -- Process Logic
373 --
374
375 per_ose_upd.upd
376 (p_org_structure_element_id => p_org_structure_element_id
377 ,p_effective_date => l_effective_date
378 ,p_object_version_number => l_object_version_number
379 ,p_organization_id_parent => p_organization_id_parent
380 ,p_organization_id_child => p_organization_id_child
381 ,p_pos_control_enabled_flag => p_pos_control_enabled_flag
382 );
383
384
385 --
386 -- Call After Process User Hook
387 --
388 begin
389 hr_hierarchy_element_bk2.update_hierarchy_element_a
390 (p_effective_date => p_effective_date
391 ,p_org_structure_element_id => p_org_structure_element_id
392 ,p_organization_id_parent => p_organization_id_parent
393 ,p_organization_id_child => p_organization_id_child
394 ,p_pos_control_enabled_flag => p_pos_control_enabled_flag
395 ,p_object_version_number => p_object_version_number
396 );
397 exception
398 when hr_api.cannot_find_prog_unit then
399 hr_api.cannot_find_prog_unit_error
400 (p_module_name => 'update_hierarchy_element'
401 ,p_hook_type => 'AP'
402 );
403 end;
404 --
405 -- When in validation only mode raise the Validate_Enabled exception
406 --
407 if p_validate then
408 raise hr_api.validate_enabled;
409 end if;
410 --
411 -- Set all output arguments
412 --
413 p_object_version_number := l_object_version_number;
414 --
415 hr_utility.set_location(' Leaving:'||l_proc, 70);
416 exception
417 when hr_api.validate_enabled then
418 --
419 -- As the Validate_Enabled exception has been raised
420 -- we must rollback to the savepoint
421 --
422 rollback to update_hierarchy_element;
423 --
424 -- Only set output warning arguments
425 -- (Any key or derived arguments must be set to null
426 -- when validation only mode is being used.)
427 --
428 p_object_version_number := p_object_version_number;
429 hr_utility.set_location(' Leaving:'||l_proc, 80);
430 when others then
431 --
432 -- A validation or unexpected error has occured
433 --
434 rollback to update_hierarchy_element;
435 --
436 -- set in out parameters and set out parameters
437 --
438 p_object_version_number := l_ovn;
439 hr_utility.set_location(' Leaving:'||l_proc, 90);
440 raise;
441 end update_hierarchy_element;
442 --
443 -- ----------------------------------------------------------------------------
444 -- |----------------------< delete_hierarchy_element - new >------------------|
445 -- ----------------------------------------------------------------------------
446 --
447 procedure delete_hierarchy_element
448 (p_validate in boolean default false
449 ,p_org_structure_element_id in number
450 ,p_object_version_number in number
451 ) is
452 --
453 -- Declare cursors and local variables
454 --
455 l_proc varchar2(72) := g_package||'delete_hierarchy_element';
456 begin
457 hr_utility.set_location('Entering:'|| l_proc, 10);
458 --
459 --
460 -- Issue a savepoint
461 --
462 savepoint delete_hierarchy_element;
463 --
464 -- Truncate the time portion from all IN date parameters
465 --
466
467 --
468 -- Call Before Process User Hook
469 --
470 begin
471 hr_hierarchy_element_bk3.delete_hierarchy_element_b
472 (p_org_structure_element_id => p_org_structure_element_id
473 ,p_object_version_number => p_object_version_number
474 );
475 exception
476 when hr_api.cannot_find_prog_unit then
477 hr_api.cannot_find_prog_unit_error
478 (p_module_name => 'delete_hierarchy_element'
479 ,p_hook_type => 'BP'
480 );
481 end;
482 --
483 -- Validation in addition to Row Handlers
484 --
485
486
487
488 --
489 -- Process Logic
490 --
491
492 per_ose_del.del
493 (p_org_structure_element_id => p_org_structure_element_id
494 ,p_object_version_number => p_object_version_number
495 ,p_hr_installed => g_hr_installed --Bug 2879820
496 ,p_pa_installed => g_pa_installed --Bug 2879820
497 ,p_chk_children_exist => 'Y'
498 -- ,p_exists_in_hierarchy => p_exists_in_hierarchy --Bug 2879820
499 );
500
501
502 --
503 -- Call After Process User Hook
504 --
505 begin
506 hr_hierarchy_element_bk3.delete_hierarchy_element_a
507 (p_org_structure_element_id => p_org_structure_element_id
508 ,p_object_version_number => p_object_version_number
509 );
510 exception
511 when hr_api.cannot_find_prog_unit then
512 hr_api.cannot_find_prog_unit_error
513 (p_module_name => 'delete_hierarchy_element'
514 ,p_hook_type => 'AP'
515 );
516 end;
517 --
518 -- When in validation only mode raise the Validate_Enabled exception
519 --
520 if p_validate then
521 raise hr_api.validate_enabled;
522 end if;
523 --
524 -- Set all output arguments
525 --
526 --
527 hr_utility.set_location(' Leaving:'||l_proc, 70);
528 exception
529 when hr_api.validate_enabled then
530 --
531 -- As the Validate_Enabled exception has been raised
532 -- we must rollback to the savepoint
533 --
534 rollback to delete_hierarchy_element;
535 --
536 -- Only set output warning arguments
537 -- (Any key or derived arguments must be set to null
538 -- when validation only mode is being used.)
539 --
540 hr_utility.set_location(' Leaving:'||l_proc, 80);
541 when others then
542 --
543 -- A validation or unexpected error has occured
544 --
545 rollback to delete_hierarchy_element;
546 --
547 -- set in out parameters and set out parameters
548 --
549 -- p_exists_in_hierarchy := null;
550 hr_utility.set_location(' Leaving:'||l_proc, 90);
551 raise;
552 end delete_hierarchy_element;
553
554 -- ----------------------------------------------------------------------------
555 -- |-----------------------< delete_hierarchy_element - old >----------------|
556 -- ----------------------------------------------------------------------------
557 --
558 procedure delete_hierarchy_element
559 (p_validate in boolean default false
560 ,p_org_structure_element_id in number
561 ,p_object_version_number in number
562 ,p_hr_installed in VARCHAR2
563 ,p_pa_installed in VARCHAR2
564 ,p_exists_in_hierarchy in out nocopy VARCHAR2
565 ) is
566 --
567 -- Declare cursors and local variables
568 --
569 l_proc varchar2(72) := g_package||'delete_hierarchy_element- old';
570 begin
571 hr_utility.set_location('Entering:'|| l_proc, 10);
572 --
573 --
574 -- Issue a savepoint
575 --
576 savepoint delete_hierarchy_element;
577
578 delete_hierarchy_element
579 (p_validate => p_validate
580 ,p_org_structure_element_id => p_org_structure_element_id
581 ,p_object_version_number => p_object_version_number
582 );
583 --
584 p_exists_in_hierarchy := 'N';
585 --
586 hr_utility.set_location(' Leaving:'||l_proc, 90);
587
588 end delete_hierarchy_element;
589 --
590 --
591 end hr_hierarchy_element_api;
592