1 Package Body HR_Api As
2 /* $Header: hrapiapi.pkb 120.4.12010000.5 2009/03/26 12:32:26 nerao ship $ */
3 --
4 -- The following global variable is used by the return_commit_unit function.
5 --
6 g_commit_unit_number number default 0;
7 --
8 -- The following global variable is used by the customer_hooks
9 -- procedure and call_cus_hooks function.
10 --
11 g_call_cus_api_hooks boolean default true;
12 --
13 -- The following global variable is used by the legislation_hooks
14 -- procedure and call_leg_hooks function.
15 --
16 g_call_leg_api_hooks boolean default true;
17 --
18 -- The following global variable is used by the application_hooks
19 -- procedure and call_app_hooks function.
20 --
21 g_call_app_api_hooks boolean default true;
22 --
23 -- The following two global variables are only to be
24 -- used by the return_legislation_code function and
25 -- validate_bus_grp_id procedure.
26 --
27 g_legislation_code varchar2(30) default null;
28 g_business_group_id number default null;
29 --
30 -- The following two global variables are used
31 -- to support R12 Initialization procedures.
32 --
33 -- 120.2 (START)
34 --
35 --g_session_context number default null;
36 g_session_context number default 0;
37 --
38 -- 120.2 (END)
39 --
40 g_leg_code PER_BUSINESS_GROUPS_PERF.LEGISLATION_CODE%TYPE default null;
41
42 -- ------------------------ mandatory_arg_error ------------------------------
43 --
44 -- Description: This procedure is called by business processes which have
45 -- identified a mandatory argument which needs to be NOT null.
46 -- If the argument is null then need to error.
47 -- Varchar2 format.
48 --
49 Procedure mandatory_arg_error
50 (p_api_name in varchar2,
51 p_argument in varchar2,
52 p_argument_value in varchar2) is
53 --
54 Begin
55 --
56 If (p_argument_value is null) then
57 hr_utility.set_message(801, 'HR_7207_API_MANDATORY_ARG');
58 hr_utility.set_message_token('API_NAME', p_api_name);
59 hr_utility.set_message_token('ARGUMENT', p_argument);
60 hr_utility.raise_error;
61 End If;
62 --
63 End mandatory_arg_error;
64 --
65 -- ------------------------ mandatory_arg_error ------------------------------
66 --
67 -- Description: Overloaded procedure which converts argument into a varchar2.
68 --
69 Procedure mandatory_arg_error
70 (p_api_name in varchar2,
71 p_argument in varchar2,
72 p_argument_value in date) is
73 --
74 Begin
75 --
76 If (p_argument_value is null) then
77 hr_utility.set_message(801, 'HR_7207_API_MANDATORY_ARG');
78 hr_utility.set_message_token('API_NAME', p_api_name);
79 hr_utility.set_message_token('ARGUMENT', p_argument);
80 hr_utility.raise_error;
81 End If;
82 --
83 End mandatory_arg_error;
84 --
85 -- ------------------------ mandatory_arg_error ------------------------------
86 --
87 -- Description: Overloaded procedure which converts argument into a varchar2.
88 --
89 Procedure mandatory_arg_error
90 (p_api_name in varchar2,
91 p_argument in varchar2,
92 p_argument_value in number) is
93 --
94 Begin
95 --
96 If (p_argument_value is null) then
97 hr_utility.set_message(801, 'HR_7207_API_MANDATORY_ARG');
98 hr_utility.set_message_token('API_NAME', p_api_name);
99 hr_utility.set_message_token('ARGUMENT', p_argument);
100 hr_utility.raise_error;
101 End If;
102 --
103 End mandatory_arg_error;
104
105 --
106 -- ----------------------- argument_changed_error ----------------------------
107 --
108 -- Description: This procedure is call by business processes which have
109 -- identified a mandatory argument which has been specified
110 -- as null and therefore need to error.
111 --
112 Procedure argument_changed_error
113 (p_api_name in varchar2,
114 p_argument in varchar2,
115 p_base_table in varchar2 default null) is
116 --
117 l_assoc_column varchar2(70);
118 --
119 Begin
120 hr_utility.set_message(801, 'HR_7210_API_NON_UPDATEABLE_ARG');
121 hr_utility.set_message_token('API_NAME', p_api_name);
122 hr_utility.set_message_token('ARGUMENT', p_argument);
123 -- hr_utility.raise_error;
124 IF p_base_table IS NULL THEN
125 l_assoc_column := p_argument;
126 ELSE
127 l_assoc_column := p_base_table || '.' || p_argument;
128 END IF;
129 hr_multi_message.add(p_associated_column1 => l_assoc_column);
130 --
131 End argument_changed_error;
132 --
133 -- ------------------------------- hr_installed ------------------------------
134 --
135 Function HR_Installed Return Boolean Is
136 l_pa_installed fnd_product_installations.status%TYPE;
137 l_industry fnd_product_installations.industry%TYPE;
138 l_pa_appid fnd_product_installations.application_id%TYPE := 800;
139 Begin
140 --
141 -- We need to determine if HR is installed.
142 --
143 If (fnd_installation.get(appl_id => l_pa_appid,
144 dep_appl_id => l_pa_appid,
145 status => l_pa_installed,
146 industry => l_industry)) then
147 --
148 -- Check to see if the returned status = 'I'
149 --
150 If (l_pa_installed = 'I') then
151 Return (True);
152 Else
153 Return (False);
154 End If;
155 Else
156 Return (False);
157 End If;
158 End hr_installed;
159 --
160 -- ------------------------ return_business_group_id -------------------------
161 --
162 Function return_business_group_id
163 (p_name in per_organization_units.name%TYPE)
164 Return per_organization_units.business_group_id%TYPE Is
165 --
166 l_business_group_id per_organization_units.business_group_id%TYPE;
167 l_proc varchar2(72) := hr_api.g_package||'return_business_group_id';
168 --
169 -- Note: This cursor statement should not require a distinct, as
170 -- business group names should be unique. It has been
171 -- included to allow use with development databases.
172 --
173 Cursor Sel_Id Is
174 select distinct
175 business_group_id
176 from per_business_groups_perf
177 where name = p_name;
178 --
179 Begin
180 --
181 mandatory_arg_error(p_api_name => l_proc,
182 p_argument => 'name',
183 p_argument_value => p_name);
184 -- DK 2002-11-08 PLSQLSTD
185 -- hr_utility.set_location(l_proc, 10);
186 --
187 -- Select the business group Id
188 --
189 Open Sel_Id;
190 fetch Sel_Id Into l_business_group_id;
191 if Sel_Id%notfound then
192 Close Sel_Id;
193 hr_utility.set_message(801, 'HR_7208_API_BUS_GRP_INVALID');
194 hr_utility.raise_error;
195 end if;
196 Close Sel_Id;
197 --
198 Return (l_business_group_id);
199 --
200 End return_business_group_id;
201 --
202 -- ------------------------ return_lookup_code ------------------------------
203 --
204 Function return_lookup_code
205 (p_meaning in fnd_common_lookups.meaning%TYPE default null,
206 p_lookup_type in fnd_common_lookups.lookup_type%TYPE)
207 Return fnd_common_lookups.lookup_code%TYPE Is
208 --
209 l_lookup_code fnd_common_lookups.lookup_code%TYPE := null;
210 l_proc varchar2(72) := hr_api.g_package||'return_lookup_code';
211 l_argument varchar2(30);
212 --
213 Cursor Sel_Id Is
214 select hl.lookup_code
215 from hr_lookups hl
216 where hl.lookup_type = p_lookup_type
217 and hl.meaning = p_meaning;
218 --
219 Begin
220 --
221 mandatory_arg_error(p_api_name => l_proc,
222 p_argument => 'lookup_type',
223 p_argument_value => p_lookup_type);
224 if p_meaning is not null then
225 --
226 -- DK 2002-11-08 PLSQLSTD
227 -- hr_utility.set_location(l_proc, 10);
228 --
229 -- Select the lookup_code
230 --
231 open Sel_Id;
232 fetch Sel_Id Into l_lookup_code;
233 if Sel_Id%notfound then
234 close Sel_Id;
235 hr_utility.set_message(801, 'HR_7209_API_LOOK_INVALID');
236 hr_utility.raise_error;
237 end if;
238 close Sel_Id;
239 end if;
240 Return (l_lookup_code);
241 --
242 End return_lookup_code;
243 --
244 -- ----------------------------------------------------------------------------
245 -- |------------------------< set_security_group_id >-------------------------|
246 -- ----------------------------------------------------------------------------
247 --
248 procedure set_security_group_id
249 (p_security_group_id in number
250 ) is
251 begin
252
253 --Bug 8250782.Reverting back the fix done for bug6142105 .
254
255
256 /* fnd_client_info.set_security_group_context
257 (context => to_char(p_security_group_id)
258 );*/
259 --
260
261 if hr_multi_tenancy_pkg.is_multi_tenant_system then
262 hr_multi_tenancy_pkg.set_security_group_id
263 (p_security_group_id => p_security_group_id);
264 else
265 -- fnd_global.set_security_group_id_context(p_security_group_id);
266 fnd_client_info.set_security_group_context (context => to_char(p_security_group_id) ); --fix for 8250782
267 end if;
268
269
270 --fix for bug6142105 ends here.
271 end set_security_group_id;
272 --
273 -- ------------------------ validate_bus_grp_id ------------------------------
274 --
275 procedure validate_bus_grp_id
276 (p_business_group_id in per_business_groups.business_group_id%TYPE
277 ,p_associated_column1 in varchar2 default null) is
278 --
279 l_column varchar2(70);
280 l_org_id number;
281 l_security_group_id number;
282 l_legislation_code varchar2(30);
283 l_proc varchar2(72) := hr_api.g_package||'validate_bus_grp_id';
284 --
285 Cursor Sel_Bus Is
286 select inf.org_information9
287 , inf.org_information14
288 from hr_organization_information hoi
289 , hr_organization_information inf
290 where hoi.organization_id = p_business_group_id
291 and hoi.org_information_context||'' = 'CLASS' /* disable index */
292 and hoi.org_information1 = 'HR_BG'
293 and hoi.org_information2 = 'Y'
294 and inf.organization_id = hoi.organization_id --Bug 3633231
295 and inf.org_information_context || '' = 'Business Group Information';
296 --
297 Begin
298 --
299 mandatory_arg_error(p_api_name => l_proc,
300 p_argument => 'business_group_id',
301 p_argument_value => p_business_group_id);
302 --
303 -- DK 2002-11-08 PLSQLSTD
304 -- hr_utility.set_location(l_proc, 10);
305 --
306 -- Select the business group Id
307 --
308 Open Sel_Bus;
309 fetch Sel_Bus Into l_legislation_code
310 , l_security_group_id;
311 if Sel_Bus%notfound then
312 Close Sel_Bus;
313 l_column := nvl(p_associated_column1,'BUSINESS_GROUP_ID');
314 hr_utility.set_message(801, 'HR_7208_API_BUS_GRP_INVALID');
315 hr_multi_message.add(p_associated_column1 => l_column);
316 else
317 Close Sel_Bus;
318 --
319 -- As the business_group_id is valid set CLIENT_INFO
320 -- with the corresponding security_group_id
321 --
322 set_security_group_id
323 (p_security_group_id => l_security_group_id
324 );
325 --
326 -- Also set the global variables used by the
327 -- return_legislation_code.
328 -- (The same tables have been visited to validate the
329 -- business group. Setting the values here will save
330 -- another select when return_legislation_code is called
331 -- later on for the same business group.)
332 --
333 hr_api.g_business_group_id := p_business_group_id;
334 hr_api.g_legislation_code := l_legislation_code;
335 --
336 -- Call set_legislation_context to store the legislation_code
337 -- for the session in the 'LEG_CODE' namespace of the 'HR_SESSION_DATA'
338 -- application context, for reference by HR_LOOKUPS.
339 --
340 hr_api.set_legislation_context(l_legislation_code);
341 -- Initialize the session context for bug 8250782.
342 g_session_context := FND_GLOBAL.Get_Session_Context;
343 --
344 end if;
345 End validate_bus_grp_id;
346 --
347 -- --------------------- strip_constraint_name ------------------------------
348 --
349 -- Description: returns the constraint name from the error message
350 --
351 Function strip_constraint_name(p_errmsg in varchar2)
352 Return varchar2 Is
353 --
354 l_proc varchar2(72) := hr_api.g_package||'strip_constraint_name';
355 l_pos1 number;
356 l_pos2 number;
357 l_pos3 number;
358 l_return_str varchar2(61);
359 --
360 Begin
361 --
362 mandatory_arg_error(p_api_name => l_proc,
363 p_argument => 'errmsg',
364 p_argument_value => p_errmsg);
365 --
366 l_pos1 := instr(p_errmsg, '(');
367 l_pos2 := instr(p_errmsg, ')');
368 --
369 If ((l_pos1 = 0) or (l_pos2 = 0)) Then
370 l_return_str := null;
371 Else
372 l_return_str := upper(substr(p_errmsg, l_pos1 + 1, l_pos2 - l_pos1 - 1));
373 --
374 -- Check to see if schema is present
375 -- If it is strip it out!
376 --
377 l_pos3 := instr(l_return_str, '.');
378 If (l_pos3 > 0) then
379 l_return_str := substr(l_return_str, l_pos3 + 1,
380 length(l_return_str) - l_pos3);
381 End If;
382 End If;
383 --
384 Return(l_return_str);
385 --
386 End strip_constraint_name;
387 --
388 -- ----------------------------------------------------------------------------
389 -- |---------------------< return_concat_kf_segments >------------------------|
390 -- ----------------------------------------------------------------------------
391 -- {Start Of Comments}
392 --
393 -- Description:
394 -- Returns the display concatenated string for the segments1..30.
395 -- The function works by selecting all defined segments from the aol fnd
396 -- tables and determining if they have a value or if they are null. if null
397 -- then the concatenated segment delimiter is used.
398 --
399 -- Pre-conditions:
400 -- The id_flex_num and segments have been fully validated.
401 --
402 -- In Arguments:
403 -- p_rec
404 --
405 -- Post Success:
406 --
407 -- Post Failure:
408 --
409 -- Access Status:
410 -- Internal Development Use Only.
411 --
412 -- {End Of Comments}
413 -- ----------------------------------------------------------------------------
414 function return_concat_kf_segments
415 (p_id_flex_num in number,
416 p_application_id in number,
417 p_id_flex_code in varchar2,
418 p_segment1 in varchar2 default null,
419 p_segment2 in varchar2 default null,
420 p_segment3 in varchar2 default null,
421 p_segment4 in varchar2 default null,
422 p_segment5 in varchar2 default null,
423 p_segment6 in varchar2 default null,
424 p_segment7 in varchar2 default null,
425 p_segment8 in varchar2 default null,
426 p_segment9 in varchar2 default null,
427 p_segment10 in varchar2 default null,
428 p_segment11 in varchar2 default null,
429 p_segment12 in varchar2 default null,
430 p_segment13 in varchar2 default null,
431 p_segment14 in varchar2 default null,
432 p_segment15 in varchar2 default null,
433 p_segment16 in varchar2 default null,
434 p_segment17 in varchar2 default null,
435 p_segment18 in varchar2 default null,
436 p_segment19 in varchar2 default null,
437 p_segment20 in varchar2 default null,
438 p_segment21 in varchar2 default null,
439 p_segment22 in varchar2 default null,
440 p_segment23 in varchar2 default null,
441 p_segment24 in varchar2 default null,
442 p_segment25 in varchar2 default null,
443 p_segment26 in varchar2 default null,
444 p_segment27 in varchar2 default null,
445 p_segment28 in varchar2 default null,
446 p_segment29 in varchar2 default null,
447 p_segment30 in varchar2 default null)
448 return varchar2 is
449 --
450 l_proc varchar2(72) := hr_api.g_package||'return_concat_kf_segments';
451 l_cat_str varchar2(1800);
452 l_error exception;
453 l_argn varchar2(30);
454 l_argv varchar2(60);
455 l_lc number := 0;
456 l_seg_ind boolean := false;
457 --
458 cursor kfsel is
459 select idfst.concatenated_segment_delimiter csd,
460 idfsg.application_column_name acn,
461 idfsg.enabled_flag ef
462 from fnd_id_flex_segments idfsg,
463 fnd_id_flex_structures idfst
464 where idfst.id_flex_num = p_id_flex_num
465 and idfst.application_id = p_application_id
466 and idfst.id_flex_code = p_id_flex_code
467 and idfsg.id_flex_num = idfst.id_flex_num
468 and idfsg.application_id = idfst.application_id
469 and idfsg.id_flex_code = idfst.id_flex_code
470 order by idfsg.segment_num;
471 -- ----------------------------------------------------------------------------
472 -- Description:
473 -- Returns the concatenated segment string after processing the current
474 -- segment.
475 --
476 -- Pre-conditions:
477 -- none.
478 --
479 -- In Arguments:
480 -- p_cat_str -> current concatenated string under constrction
481 -- p_segv -> current segment value
482 -- p_del -> keyflex segment delimiter
483 -- p_lc -> current segment loop counter
484 --
485 -- Post Success:
486 -- Concatenated segment string will have the current segment added to the
487 -- build string under construction.
488 --
489 -- Post Failure:
490 -- This function should not raise an error.
491 --
492 -- Access Status:
493 -- Internal Table Handler Use Only (called by parent procedure
494 -- return_concatenated_group_name.
495 -- ----------------------------------------------------------------------------
496 function rtn_del_str(p_cat_str in varchar2,
497 p_segv in varchar2,
498 p_del in varchar2,
499 p_lc in number)
500 return varchar2 is
501 --
502 l_rtn_str varchar2(1800);
503 --
504 begin
505 if (p_segv is not null) then
506 --
507 -- a segment has been set therefore we must set the indicator to true
508 --
509 l_seg_ind := true;
510 --
511 -- as the segment value exists we must determine if it is the
512 -- the first segment
513 --
514 if (p_lc = 1) then
515 --
516 -- as the segment is first we must just assign the segment
517 -- value
518 --
519 l_rtn_str := p_segv;
520 else
521 --
522 -- as the segment is not the first one we must append the
523 -- delimter and segment value to the returning str
524 --
525 l_rtn_str := p_cat_str||p_del||p_segv;
526 end if;
527 else
528 if (p_lc = 1) then
529 --
530 -- as the segment value is null and is the first segment we
531 -- return just a null value
532 --
533 l_rtn_str := null;
534 else
535 --
536 -- the segment value is null but is not the first segment therefore
537 -- we append the delimter to the current string
538 --
539 l_rtn_str := p_cat_str||p_del;
540 end if;
541 end if;
542 return(l_rtn_str);
543 end rtn_del_str;
544 --
545 begin
546 --
547 hr_api.mandatory_arg_error
548 (p_api_name => l_proc,
549 p_argument => 'id_flex_num',
550 p_argument_value => p_id_flex_num);
551 --
552 hr_api.mandatory_arg_error
553 (p_api_name => l_proc,
554 p_argument => 'application_id',
555 p_argument_value => p_application_id);
556 --
557 hr_api.mandatory_arg_error
558 (p_api_name => l_proc,
559 p_argument => 'id_flex_code',
560 p_argument_value => p_id_flex_code);
561 --
562 for kf in kfsel loop
563 --
564 l_lc := l_lc + 1;
565 --
566 if (kf.acn = 'SEGMENT1') then
567 if (kf.ef = 'Y') then
568 l_cat_str := rtn_del_str(l_cat_str, p_segment1, kf.csd, l_lc);
569 elsif (kf.ef = 'N' and p_segment1 is not null) then
570 l_argn := 'P_SEGMENT1'; l_argv := p_segment1; raise l_error;
571 end if;
572 end if;
573 if (kf.acn = 'SEGMENT2') then
574 if (kf.ef = 'Y') then
575 l_cat_str := rtn_del_str(l_cat_str, p_segment2, kf.csd, l_lc);
576 elsif (kf.ef = 'N' and p_segment2 is not null) then
577 l_argn := 'P_SEGMENT2'; l_argv := p_segment2; raise l_error;
578 end if;
579 end if;
580 if (kf.acn = 'SEGMENT3') then
581 if (kf.ef = 'Y') then
582 l_cat_str := rtn_del_str(l_cat_str, p_segment3, kf.csd, l_lc);
583 elsif (kf.ef = 'N' and p_segment3 is not null) then
584 l_argn := 'P_SEGMENT3'; l_argv := p_segment3; raise l_error;
585 end if;
586 end if;
587 if (kf.acn = 'SEGMENT4') then
588 if (kf.ef = 'Y') then
589 l_cat_str := rtn_del_str(l_cat_str, p_segment4, kf.csd, l_lc);
590 elsif (kf.ef = 'N' and p_segment4 is not null) then
591 l_argn := 'P_SEGMENT4'; l_argv := p_segment4; raise l_error;
592 end if;
593 end if;
594 if (kf.acn = 'SEGMENT5') then
595 if (kf.ef = 'Y') then
596 l_cat_str := rtn_del_str(l_cat_str, p_segment5, kf.csd, l_lc);
597 elsif (kf.ef = 'N' and p_segment5 is not null) then
598 l_argn := 'P_SEGMENT5'; l_argv := p_segment5; raise l_error;
599 end if;
600 end if;
601 if (kf.acn = 'SEGMENT6') then
602 if (kf.ef = 'Y') then
603 l_cat_str := rtn_del_str(l_cat_str, p_segment6, kf.csd, l_lc);
604 elsif (kf.ef = 'N' and p_segment6 is not null) then
605 l_argn := 'P_SEGMENT6'; l_argv := p_segment6; raise l_error;
606 end if;
607 end if;
608 if (kf.acn = 'SEGMENT7') then
609 if (kf.ef = 'Y') then
610 l_cat_str := rtn_del_str(l_cat_str, p_segment7, kf.csd, l_lc);
611 elsif (kf.ef = 'N' and p_segment7 is not null) then
612 l_argn := 'P_SEGMENT7'; l_argv := p_segment7; raise l_error;
613 end if;
614 end if;
615 if (kf.acn = 'SEGMENT8') then
616 if (kf.ef = 'Y') then
617 l_cat_str := rtn_del_str(l_cat_str, p_segment8, kf.csd, l_lc);
618 elsif (kf.ef = 'N' and p_segment8 is not null) then
619 l_argn := 'P_SEGMENT8'; l_argv := p_segment8; raise l_error;
620 end if;
621 end if;
622 if (kf.acn = 'SEGMENT9') then
623 if (kf.ef = 'Y') then
624 l_cat_str := rtn_del_str(l_cat_str, p_segment9, kf.csd, l_lc);
625 elsif (kf.ef = 'N' and p_segment9 is not null) then
626 l_argn := 'P_SEGMENT9'; l_argv := p_segment9; raise l_error;
627 end if;
628 end if;
629 if (kf.acn = 'SEGMENT10') then
630 if (kf.ef = 'Y') then
631 l_cat_str := rtn_del_str(l_cat_str, p_segment10, kf.csd, l_lc);
632 elsif (kf.ef = 'N' and p_segment10 is not null) then
633 l_argn := 'P_SEGMENT10'; l_argv := p_segment10; raise l_error;
634 end if;
635 end if;
636 if (kf.acn = 'SEGMENT11') then
637 if (kf.ef = 'Y') then
638 l_cat_str := rtn_del_str(l_cat_str, p_segment11, kf.csd, l_lc);
639 elsif (kf.ef = 'N' and p_segment11 is not null) then
640 l_argn := 'P_SEGMENT11'; l_argv := p_segment11; raise l_error;
641 end if;
642 end if;
643 if (kf.acn = 'SEGMENT12') then
644 if (kf.ef = 'Y') then
645 l_cat_str := rtn_del_str(l_cat_str, p_segment12, kf.csd, l_lc);
646 elsif (kf.ef = 'N' and p_segment12 is not null) then
647 l_argn := 'P_SEGMENT12'; l_argv := p_segment12; raise l_error;
648 end if;
649 end if;
650 if (kf.acn = 'SEGMENT13') then
651 if (kf.ef = 'Y') then
652 l_cat_str := rtn_del_str(l_cat_str, p_segment13, kf.csd, l_lc);
653 elsif (kf.ef = 'N' and p_segment13 is not null) then
654 l_argn := 'P_SEGMENT13'; l_argv := p_segment13; raise l_error;
655 end if;
656 end if;
657 if (kf.acn = 'SEGMENT14') then
658 if (kf.ef = 'Y') then
659 l_cat_str := rtn_del_str(l_cat_str, p_segment14, kf.csd, l_lc);
660 elsif (kf.ef = 'N' and p_segment14 is not null) then
661 l_argn := 'P_SEGMENT14'; l_argv := p_segment14; raise l_error;
662 end if;
663 end if;
664 if (kf.acn = 'SEGMENT15') then
665 if (kf.ef = 'Y') then
666 l_cat_str := rtn_del_str(l_cat_str, p_segment15, kf.csd, l_lc);
667 elsif (kf.ef = 'N' and p_segment15 is not null) then
668 l_argn := 'P_SEGMENT15'; l_argv := p_segment15; raise l_error;
669 end if;
670 end if;
671 if (kf.acn = 'SEGMENT16') then
672 if (kf.ef = 'Y') then
673 l_cat_str := rtn_del_str(l_cat_str, p_segment16, kf.csd, l_lc);
674 elsif (kf.ef = 'N' and p_segment16 is not null) then
675 l_argn := 'P_SEGMENT16'; l_argv := p_segment16; raise l_error;
676 end if;
677 end if;
678 if (kf.acn = 'SEGMENT17') then
679 if (kf.ef = 'Y') then
680 l_cat_str := rtn_del_str(l_cat_str, p_segment17, kf.csd, l_lc);
681 elsif (kf.ef = 'N' and p_segment17 is not null) then
682 l_argn := 'P_SEGMENT17'; l_argv := p_segment17; raise l_error;
683 end if;
684 end if;
685 if (kf.acn = 'SEGMENT18') then
686 if (kf.ef = 'Y') then
687 l_cat_str := rtn_del_str(l_cat_str, p_segment18, kf.csd, l_lc);
688 elsif (kf.ef = 'N' and p_segment18 is not null) then
689 l_argn := 'P_SEGMENT18'; l_argv := p_segment18; raise l_error;
690 end if;
691 end if;
692 if (kf.acn = 'SEGMENT19') then
693 if (kf.ef = 'Y') then
694 l_cat_str := rtn_del_str(l_cat_str, p_segment19, kf.csd, l_lc);
695 elsif (kf.ef = 'N' and p_segment19 is not null) then
696 l_argn := 'P_SEGMENT19'; l_argv := p_segment19; raise l_error;
697 end if;
698 end if;
699 if (kf.acn = 'SEGMENT20') then
700 if (kf.ef = 'Y') then
701 l_cat_str := rtn_del_str(l_cat_str, p_segment20, kf.csd, l_lc);
702 elsif (kf.ef = 'N' and p_segment20 is not null) then
703 l_argn := 'P_SEGMENT20'; l_argv := p_segment20; raise l_error;
704 end if;
705 end if;
706 if (kf.acn = 'SEGMENT21') then
707 if (kf.ef = 'Y') then
708 l_cat_str := rtn_del_str(l_cat_str, p_segment21, kf.csd, l_lc);
709 elsif (kf.ef = 'N' and p_segment21 is not null) then
710 l_argn := 'P_SEGMENT21'; l_argv := p_segment21; raise l_error;
711 end if;
712 end if;
713 if (kf.acn = 'SEGMENT22') then
714 if (kf.ef = 'Y') then
715 l_cat_str := rtn_del_str(l_cat_str, p_segment22, kf.csd, l_lc);
716 elsif (kf.ef = 'N' and p_segment22 is not null) then
717 l_argn := 'P_SEGMENT22'; l_argv := p_segment22; raise l_error;
718 end if;
719 end if;
720 if (kf.acn = 'SEGMENT23') then
721 if (kf.ef = 'Y') then
722 l_cat_str := rtn_del_str(l_cat_str, p_segment23, kf.csd, l_lc);
723 elsif (kf.ef = 'N' and p_segment23 is not null) then
724 l_argn := 'P_SEGMENT23'; l_argv := p_segment23; raise l_error;
725 end if;
726 end if;
727 if (kf.acn = 'SEGMENT24') then
728 if (kf.ef = 'Y') then
729 l_cat_str := rtn_del_str(l_cat_str, p_segment24, kf.csd, l_lc);
730 elsif (kf.ef = 'N' and p_segment24 is not null) then
731 l_argn := 'P_SEGMENT24'; l_argv := p_segment24; raise l_error;
732 end if;
733 end if;
734 if (kf.acn = 'SEGMENT25') then
735 if (kf.ef = 'Y') then
736 l_cat_str := rtn_del_str(l_cat_str, p_segment25, kf.csd, l_lc);
737 elsif (kf.ef = 'N' and p_segment25 is not null) then
738 l_argn := 'P_SEGMENT25'; l_argv := p_segment25; raise l_error;
739 end if;
740 end if;
741 if (kf.acn = 'SEGMENT26') then
742 if (kf.ef = 'Y') then
743 l_cat_str := rtn_del_str(l_cat_str, p_segment26, kf.csd, l_lc);
744 elsif (kf.ef = 'N' and p_segment26 is not null) then
745 l_argn := 'P_SEGMENT26'; l_argv := p_segment26; raise l_error;
746 end if;
747 end if;
748 if (kf.acn = 'SEGMENT27') then
749 if (kf.ef = 'Y') then
750 l_cat_str := rtn_del_str(l_cat_str, p_segment27, kf.csd, l_lc);
751 elsif (kf.ef = 'N' and p_segment27 is not null) then
752 l_argn := 'P_SEGMENT27'; l_argv := p_segment27; raise l_error;
753 end if;
754 end if;
755 if (kf.acn = 'SEGMENT28') then
756 if (kf.ef = 'Y') then
757 l_cat_str := rtn_del_str(l_cat_str, p_segment28, kf.csd, l_lc);
758 elsif (kf.ef = 'N' and p_segment28 is not null) then
759 l_argn := 'P_SEGMENT28'; l_argv := p_segment28; raise l_error;
760 end if;
761 end if;
762 if (kf.acn = 'SEGMENT29') then
763 if (kf.ef = 'Y') then
764 l_cat_str := rtn_del_str(l_cat_str, p_segment29, kf.csd, l_lc);
765 elsif (kf.ef = 'N' and p_segment29 is not null) then
766 l_argn := 'P_SEGMENT29'; l_argv := p_segment29; raise l_error;
767 end if;
768 end if;
769 if (kf.acn = 'SEGMENT30') then
770 if (kf.ef = 'Y') then
771 l_cat_str := rtn_del_str(l_cat_str, p_segment30, kf.csd, l_lc);
772 elsif (kf.ef = 'N' and p_segment30 is not null) then
773 l_argn := 'P_SEGMENT30'; l_argv := p_segment30; raise l_error;
774 end if;
775 end if;
776 --
777 end loop;
778 if (l_lc > 0) then
779 --
780 -- If all the segment values are null then we must replace the delimited
781 -- string will null
782 --
783 if not l_seg_ind then
784 l_cat_str := null;
785 end if;
786 else
787 --
788 -- the flex structure cannot exist therefore error
789 --
790 l_argn := 'id_flex_num';
791 l_argv := p_id_flex_num;
792 raise l_error;
793 end if;
794 return(substr(l_cat_str, 1, 240));
795 exception
796 when l_error then
797 -- *** TEMP error message ***
798 hr_utility.set_message(801, 'HR_7296_API_ARG_NOT_SUP');
799 hr_utility.set_message_token('ARG_NAME', l_argn);
800 hr_utility.set_message_token('ARG_VALUE', l_argv);
801 hr_utility.raise_error;
802 when others then
803 raise;
804 end return_concat_kf_segments;
805 --
806 -- ----------------------------------------------------------------------------
807 -- |----------------------< not_exists_in_hr_lookups >------------------------|
808 -- ----------------------------------------------------------------------------
809 --
810 function not_exists_in_hr_lookups
811 (p_effective_date in date
812 ,p_lookup_type in varchar2
813 ,p_lookup_code in varchar2
814 ) return boolean is
815 --
816 -- Declare Local Variables
817 --
818 l_exists varchar2(1);
819 --
820 -- Declare Local cursors
821 --
822 cursor csr_hr_look is
823 select null
824 from hr_lookups
825 where lookup_code = p_lookup_code
826 and lookup_type = p_lookup_type
827 and enabled_flag = 'Y'
828 and p_effective_date between
829 nvl(start_date_active, p_effective_date)
830 and nvl(end_date_active, p_effective_date);
831 --
832 begin
833 --
834 -- When the lookup_type is YES_NO attempt to validate without
835 -- executing the cursor. This is to reduce checking time for
836 -- valid values in row handlers which have a lot of Yes No flags.
837 --
838 if p_lookup_type = 'YES_NO' then
839 if p_lookup_code = 'Y' or p_lookup_code = 'N' then
840 return false;
841 end if;
842 -- If the value is not known then go onto check against the
843 -- hr_lookups view. Just in case there has been a change to
844 -- the system defined lookup.
845 end if;
846
847
848 -- DK 2002-11-08 PLSQLSTD
849 --hr_utility.set_location(hr_api.g_package||'not_exists_in_hr_lookups', 10);
850
851
852 --
853 open csr_hr_look;
854 fetch csr_hr_look into l_exists;
855 if csr_hr_look%notfound then
856 close csr_hr_look;
857 return true;
858 else
859 close csr_hr_look;
860 return false;
861 end if;
862 end not_exists_in_hr_lookups;
863 --
864 -- ----------------------------------------------------------------------------
865 -- |-------------------< not_exists_in_leg_lookups >-----------------------|
866 -- ----------------------------------------------------------------------------
867 --
868 function not_exists_in_leg_lookups
869 (p_effective_date in date
870 ,p_lookup_type in varchar2
871 ,p_lookup_code in varchar2
872 ) return boolean is
873 --
874 -- Declare Local Variables
875 --
876 l_exists varchar2(1);
877 --
878 -- Declare Local cursors
879 --
880 cursor csr_hr_leg_look is
881 select null
882 from hr_leg_lookups
883 where lookup_code = p_lookup_code
884 and lookup_type = p_lookup_type
885 and enabled_flag = 'Y'
886 and p_effective_date between
887 nvl(start_date_active, p_effective_date)
888 and nvl(end_date_active, p_effective_date);
889 --
890 begin
891 --
892 -- When the lookup_type is YES_NO attempt to validate without
893 -- executing the cursor. This is to reduce checking time for
894 -- valid values in row handlers which have a lot of Yes No flags.
895 --
896 if p_lookup_type = 'YES_NO' then
897 if p_lookup_code = 'Y' or p_lookup_code = 'N' then
898 return false;
899 end if;
900 -- If the value is not known then go onto check against the
901 -- hr_lookups view. Just in case there has been a change to
902 -- the system defined lookup.
903 end if;
904 hr_utility.set_location(hr_api.g_package||'not_exists_in_leg_lookups', 10);
905 --
906 open csr_hr_leg_look;
907 fetch csr_hr_leg_look into l_exists;
908 if csr_hr_leg_look%notfound then
909 close csr_hr_leg_look;
910 return true;
911 else
912 close csr_hr_leg_look;
913 return false;
914 end if;
915 end not_exists_in_leg_lookups;
916 --
917 -- ----------------------------------------------------------------------------
918 -- |---------------------< not_exists_in_hrstanlookups >----------------------|
919 -- ----------------------------------------------------------------------------
920 --
921 function not_exists_in_hrstanlookups
922 (p_effective_date in date
923 ,p_lookup_type in varchar2
924 ,p_lookup_code in varchar2
925 ) return boolean is
926 --
927 -- Declare Local Variables
928 --
929 l_exists varchar2(1);
930 --
931 -- Declare Local cursors
932 --
933 cursor csr_hr_look is
934 select null
935 from hr_standard_lookups
936 where lookup_code = p_lookup_code
937 and lookup_type = p_lookup_type
938 and enabled_flag = 'Y'
939 and p_effective_date between
940 nvl(start_date_active, p_effective_date)
941 and nvl(end_date_active, p_effective_date);
942 --
943 begin
944 --
945 -- When the lookup_type is YES_NO attempt to validate without
946 -- executing the cursor. This is to reduce checking time for
947 -- valid values in row handlers which have a lot of Yes No flags.
948 --
949 if p_lookup_type = 'YES_NO' then
950 if p_lookup_code = 'Y' or p_lookup_code = 'N' then
951 return false;
952 end if;
953 -- If the value is not known then go onto check against the
954 -- hr_lookups view. Just in case there has been a change to
955 -- the system defined lookup.
956 end if;
957 hr_utility.set_location(hr_api.g_package||'not_exists_in_hrstanlookups', 10);
958 --
959 open csr_hr_look;
960 fetch csr_hr_look into l_exists;
961 if csr_hr_look%notfound then
962 close csr_hr_look;
963 return true;
964 else
965 close csr_hr_look;
966 return false;
967 end if;
968 end not_exists_in_hrstanlookups;
969 --
970 -- ----------------------------------------------------------------------------
971 -- |---------------------< not_exists_in_fnd_lookups >------------------------|
972 -- ----------------------------------------------------------------------------
973 --
974 function not_exists_in_fnd_lookups
975 (p_effective_date in date
976 ,p_lookup_type in varchar2
977 ,p_lookup_code in varchar2
978 ) return boolean is
979 --
980 -- Declare Local Variables
981 --
982 l_exists varchar2(1);
983 --
984 -- Declare Local cursors
985 --
986 cursor csr_fnd_look is
987 select null
988 from fnd_lookups
989 where lookup_code = p_lookup_code
990 and lookup_type = p_lookup_type
991 and enabled_flag = 'Y'
992 and p_effective_date between
993 nvl(start_date_active, p_effective_date)
994 and nvl(end_date_active, p_effective_date);
995 --
996 begin
997 --
998 -- When the lookup_type is YES_NO attempt to validate without
999 -- executing the cursor. This is to reduce checking time for
1000 -- valid values in row handlers which have a lot of Yes No flags.
1001 --
1002 if p_lookup_type = 'YES_NO' then
1003 if p_lookup_code = 'Y' or p_lookup_code = 'N' then
1004 return false;
1005 end if;
1006 -- If the value is not known then go onto check against the
1007 -- hr_lookups view. Just in case there has been a change to
1008 -- the system defined lookup.
1009 end if;
1010 hr_utility.set_location(hr_api.g_package||'not_exists_in_fnd_lookups', 10);
1011 --
1012 open csr_fnd_look;
1013 fetch csr_fnd_look into l_exists;
1014 if csr_fnd_look%notfound then
1015 close csr_fnd_look;
1016 return true;
1017 else
1018 close csr_fnd_look;
1019 return false;
1020 end if;
1021 end not_exists_in_fnd_lookups;
1022 --
1023 -- ----------------------------------------------------------------------------
1024 -- |--------------------< not_exists_in_dt_hr_lookups >-----------------------|
1025 -- ----------------------------------------------------------------------------
1026 --
1027 function not_exists_in_dt_hr_lookups
1028 (p_effective_date in date
1029 ,p_validation_start_date in date
1030 ,p_validation_end_date in date
1031 ,p_lookup_type in varchar2
1032 ,p_lookup_code in varchar2
1033 ) return boolean is
1034 --
1035 -- NOTE: At the moment this function does exactly the same validation
1036 -- as the not_exists_in_hr_lookups function. Currently the APIs do the
1037 -- same validation as the Form. i.e. Only check the code exists on the
1038 -- effective_date of the operation. This separate function has been provided
1039 -- because in the future we may want to introduce full date range validation.
1040 -- i.e. Check the lookup_code start_date_active end_date_active values span
1041 -- the vaidation_start_date to validation_end_date range of the DateTrack
1042 -- operation.
1043 -- The same issue applies to the not_exists_in_dt_hrstanlookups and
1044 -- not_exists_in_dt_fnd_lookups functions.
1045 --
1046 begin
1047 --
1048 return not_exists_in_hr_lookups
1049 (p_effective_date => p_effective_date
1050 ,p_lookup_type => p_lookup_type
1051 ,p_lookup_code => p_lookup_code
1052 );
1053 --
1054 end not_exists_in_dt_hr_lookups;
1055 --
1056 -- ----------------------------------------------------------------------------
1057 -- |---------------------< not_exists_in_dt_leg_lookups >---------------------|
1058 -- ----------------------------------------------------------------------------
1059 --
1060 function not_exists_in_dt_leg_lookups
1061 (p_effective_date in date
1062 ,p_validation_start_date in date
1063 ,p_validation_end_date in date
1064 ,p_lookup_type in varchar2
1065 ,p_lookup_code in varchar2
1066 ) return boolean is
1067 --
1068 -- NOTE: At the moment this function does exactly the same validation
1069 -- as the not_exists_in_leg_lookups function. Currently the APIs do the
1070 -- same validation as the Form. i.e. Only check the code exists on the
1071 -- effective_date of the operation. This separate function has been provided
1072 -- because in the future we may want to introduce full date range validation.
1073 -- i.e. Check the lookup_code start_date_active end_date_active values span
1074 -- the vaidation_start_date to validation_end_date range of the DateTrack
1075 -- operation.
1076 -- The same issue applies to the not_exists_in_dt_hr_lookups,
1077 -- and not_exists_in_dt_hrstanlookups and
1078 -- not_exists_in_dt_fnd_lookups functions.
1079 --
1080 begin
1081 --
1082 return not_exists_in_leg_lookups
1083 (p_effective_date => p_effective_date
1084 ,p_lookup_type => p_lookup_type
1085 ,p_lookup_code => p_lookup_code
1086 );
1087 --
1088 end not_exists_in_dt_leg_lookups;
1089 --
1090 -- ----------------------------------------------------------------------------
1091 -- |-------------------< not_exists_in_dt_hrstanlookups >---------------------|
1092 -- ----------------------------------------------------------------------------
1093 --
1094 function not_exists_in_dt_hrstanlookups
1095 (p_effective_date in date
1096 ,p_validation_start_date in date
1097 ,p_validation_end_date in date
1098 ,p_lookup_type in varchar2
1099 ,p_lookup_code in varchar2
1100 ) return boolean is
1101 --
1102 -- Refer to code comments in not_exists_in_dt_hr_lookups for details of
1103 -- why this procedure exists and is currently coded to do the same
1104 -- validation as not_exists_in_hrstanlookups.
1105 --
1106 begin
1107 --
1108 return not_exists_in_hrstanlookups
1109 (p_effective_date => p_effective_date
1110 ,p_lookup_type => p_lookup_type
1111 ,p_lookup_code => p_lookup_code
1112 );
1113 --
1114 end not_exists_in_dt_hrstanlookups;
1115 --
1116 -- ----------------------------------------------------------------------------
1117 -- |--------------------< not_exists_in_dt_fnd_lookups >----------------------|
1118 -- ----------------------------------------------------------------------------
1119 --
1120 function not_exists_in_dt_fnd_lookups
1121 (p_effective_date in date
1122 ,p_validation_start_date in date
1123 ,p_validation_end_date in date
1124 ,p_lookup_type in varchar2
1125 ,p_lookup_code in varchar2
1126 ) return boolean is
1127 --
1128 -- Refer to code comments in not_exists_in_dt_hr_lookups for details of
1129 -- why this procedure exists and is currently coded to do the same
1130 -- validation as not_exists_in_fnd_lookups.
1131 --
1132 begin
1133 --
1134 return not_exists_in_fnd_lookups
1135 (p_effective_date => p_effective_date
1136 ,p_lookup_type => p_lookup_type
1137 ,p_lookup_code => p_lookup_code
1138 );
1139 --
1140 end not_exists_in_dt_fnd_lookups;
1141 --
1142 -- ----------------------------------------------------------------------------
1143 -- |-----------------------< cannot_find_prog_unit_error >--------------------|
1144 -- ----------------------------------------------------------------------------
1145 --
1146 procedure cannot_find_prog_unit_error
1147 (p_module_name in varchar2
1148 ,p_hook_type in varchar2
1149 ) is
1150 --
1151 -- Cursor to obtain the user description for the hook_type
1152 --
1153 cursor csr_hook_type is
1154 select meaning
1155 from hr_lookups
1156 where lookup_type = 'API_HOOK_TYPE'
1157 and enabled_flag = 'Y'
1158 and lookup_code = p_hook_type;
1159 --
1160 -- Local variables
1161 --
1162 l_hook_type varchar2(80);
1163 l_proc varchar2(72) := hr_api.g_package||'cannot_find_prog_unit_error';
1164 begin
1165 hr_utility.set_location(l_proc, 10);
1166 --
1167 -- Attempt to find the user description for the hook type.
1168 -- If it cannot be found just use the internal code value.
1169 --
1170 open csr_hook_type;
1171 fetch csr_hook_type into l_hook_type;
1172 if csr_hook_type%notfound then
1173 l_hook_type := p_hook_type;
1174 end if;
1175 close csr_hook_type;
1176 --
1177 -- Error: The system cannot find the program unit being called. This could
1178 -- be because the application API pre-processor has not been run. Contact
1179 -- your system administrator quoting the following details:
1180 -- Error ORA-06508 in API module *MODULE_NAME at hook *HOOK_TYPE.
1181 --
1182 hr_utility.set_message(800, 'HR_51938_AHK_NOT_FIND_UNIT');
1183 hr_utility.set_message_token('MODULE_NAME', p_module_name);
1184 hr_utility.set_message_token('HOOK_TYPE', l_hook_type);
1185 hr_utility.raise_error;
1186 end cannot_find_prog_unit_error;
1187 --
1188 -- ----------------------------------------------------------------------------
1189 -- |---------------------------< return_commit_unit >-------------------------|
1190 -- ----------------------------------------------------------------------------
1191 --
1192 function return_commit_unit return number is
1193 l_lock_status number;
1194 begin
1195 --
1196 -- Request a RDBMS lock which will be released on commit or rollback.
1197 --
1198 l_lock_status := dbms_lock.request(2147483647, dbms_lock.nl_mode, 0, TRUE);
1199 if l_lock_status = 0 then
1200 --
1201 -- The lock has just been obtained. As far as this function is concerned
1202 -- it is the start of the commit unit. Increment the commit unit number.
1203 --
1204 -- When the l_lock_status is not zero, either there was error (1, 2, 3, 5)
1205 -- or the lock was obtained on a previous call to this function (4). If
1206 -- the lock has already been obtained, the commit unit cannot have
1207 -- changed, so number is not incremented.
1208 --
1209 hr_api.g_commit_unit_number := hr_api.g_commit_unit_number + 1;
1210 end if;
1211 --
1212 return hr_api.g_commit_unit_number;
1213 end return_commit_unit;
1214 --
1215 -- ----------------------------------------------------------------------------
1216 -- |--------------------------< validate_commit_unit >------------------------|
1217 -- ----------------------------------------------------------------------------
1218 --
1219 procedure validate_commit_unit
1220 (p_commit_unit_number in number
1221 ,p_module_name in varchar2
1222 ,p_hook_type in varchar2
1223 ) is
1224 --
1225 -- Cursor to obtain the user description for the hook_type
1226 --
1227 cursor csr_hook_type is
1228 select meaning
1229 from hr_lookups
1230 where lookup_type = 'API_HOOK_TYPE'
1231 and enabled_flag = 'Y'
1232 and lookup_code = p_hook_type;
1233 --
1234 -- Local variables
1235 --
1236 l_hook_type varchar2(80);
1237 l_proc varchar2(72) := hr_api.g_package||'validate_commit_unit';
1238 begin
1239 hr_utility.set_location(l_proc, 10);
1240 --
1241 -- Attempt to find the user description for the hook type.
1242 -- If it cannot be found just use the internal code value.
1243 --
1244 -- Bug fix 3390390:
1245 -- Moved following cursor to inside the following IF..THEN logic
1246 -- open csr_hook_type;
1247 -- fetch csr_hook_type into l_hook_type;
1248 -- if csr_hook_type%notfound then
1249 -- l_hook_type := p_hook_type;
1250 -- end if;
1251 -- close csr_hook_type;
1252 --
1253 -- If the current commit unit number does not equal the number passed to
1254 -- this procedure then raise an error. A commit or full rollback must have
1255 -- been issued since return_commit_unit was last called.
1256 --
1257 if return_commit_unit <> p_commit_unit_number then
1258 -- Error: An internal commit or full rollback has occurred inside this API
1259 -- user hook. These commands are not permitted as they interfere with
1260 -- other logic. Contact your system administrator to resolve this action
1261 -- and to remove the commit or rollback statement. Quote:
1262 -- API module *MODULE_NAME at hook *HOOK_TYPE.
1263 --
1264 -- Execute cursor (fix 3390930)
1265 open csr_hook_type;
1266 fetch csr_hook_type into l_hook_type;
1267 if csr_hook_type%notfound then
1268 l_hook_type := p_hook_type;
1269 end if;
1270 close csr_hook_type;
1271 --
1272 hr_utility.set_message(800, 'HR_51939_AHK_COMMIT_FOUND');
1273 hr_utility.set_message_token('MODULE_NAME', p_module_name);
1274 hr_utility.set_message_token('HOOK_TYPE', l_hook_type);
1275 hr_utility.raise_error;
1276 end if;
1277 end validate_commit_unit;
1278 --
1279 -- ----------------------------------------------------------------------------
1280 -- |-----------------------------< customer_hooks >---------------------------|
1281 -- ----------------------------------------------------------------------------
1282 --
1283 procedure customer_hooks
1284 (p_mode in varchar2
1285 ) is
1286 begin
1287 if p_mode = 'DISABLE' then
1288 hr_api.g_call_cus_api_hooks := false;
1289 elsif p_mode = 'ENABLE' then
1290 hr_api.g_call_cus_api_hooks := true;
1291 else
1292 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1293 hr_utility.set_message_token('PROCEDURE'
1294 ,hr_api.g_package||'customer_hooks'
1295 );
1296 hr_utility.set_message_token('STEP', '20');
1297 hr_utility.raise_error;
1298 end if;
1299 end customer_hooks;
1300 --
1301 -- ----------------------------------------------------------------------------
1302 -- |---------------------------< legislation_hooks >--------------------------|
1303 -- ----------------------------------------------------------------------------
1304 --
1305 procedure legislation_hooks
1306 (p_mode in varchar2
1307 ) is
1308 begin
1309 if p_mode = 'DISABLE' then
1310 hr_api.g_call_leg_api_hooks := false;
1311 elsif p_mode = 'ENABLE' then
1312 hr_api.g_call_leg_api_hooks := true;
1313 else
1314 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1315 hr_utility.set_message_token('PROCEDURE', hr_api.g_package||'leg_hooks');
1316 hr_utility.set_message_token('STEP', '20');
1317 hr_utility.raise_error;
1318 end if;
1319 end legislation_hooks;
1320 --
1321 -- ----------------------------------------------------------------------------
1322 -- |---------------------------< application_hooks >--------------------------|
1323 -- ----------------------------------------------------------------------------
1324 --
1325 procedure application_hooks
1326 (p_mode in varchar2
1327 ) is
1328 begin
1329 if p_mode = 'DISABLE' then
1330 hr_api.g_call_app_api_hooks := false;
1331 elsif p_mode = 'ENABLE' then
1332 hr_api.g_call_app_api_hooks := true;
1333 else
1334 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1335 hr_utility.set_message_token('PROCEDURE', hr_api.g_package||'app_hooks');
1336 hr_utility.set_message_token('STEP', '20');
1337 hr_utility.raise_error;
1338 end if;
1339 end application_hooks;
1340 --
1341 -- ----------------------------------------------------------------------------
1342 -- |----------------------------< call_cus_hooks >----------------------------|
1343 -- ----------------------------------------------------------------------------
1344 --
1345 function call_cus_hooks return boolean is
1346 begin
1347 return hr_api.g_call_cus_api_hooks;
1348 end call_cus_hooks;
1349 --
1350 -- ----------------------------------------------------------------------------
1351 -- |----------------------------< call_leg_hooks >----------------------------|
1355 begin
1352 -- ----------------------------------------------------------------------------
1353 --
1354 function call_leg_hooks return boolean is
1356 return hr_api.g_call_leg_api_hooks;
1357 end call_leg_hooks;
1358 --
1359 -- ----------------------------------------------------------------------------
1360 -- |----------------------------< call_app_hooks >----------------------------|
1361 -- ----------------------------------------------------------------------------
1362 function call_app_hooks return boolean is
1363 begin
1364 return hr_api.g_call_app_api_hooks;
1365 end call_app_hooks;
1366 --
1367 -- ----------------------------------------------------------------------------
1368 -- |-------------------------< return_legislation_code >----------------------|
1369 -- ----------------------------------------------------------------------------
1370 --
1371 function return_legislation_code
1372 (p_business_group_id in number
1373 ) return varchar2 is
1374 --
1375 -- Cursor to find the legislation_code
1376 --
1377 cursor csr_leg_code is
1378 select legislation_code
1379 from per_business_groups_perf
1380 where business_group_id = p_business_group_id;
1381 --
1382 l_legislation_code varchar2(30);
1383 begin
1384 if p_business_group_id is null then
1385 --
1386 -- No business group has been provided to this function
1387 -- so return a null legislation_code
1388 --
1389 l_legislation_code := null;
1390 else
1391 if nvl(hr_api.g_business_group_id, hr_api.g_number) = p_business_group_id
1392 then
1393 --
1394 -- The legislation code for the business group has already
1395 -- been found with a previous call to this function or to
1396 -- validate_bus_grp_id. Just return the value in the global
1397 -- variable to avoid the overhead of executing the cursor statement.
1398 --
1399 l_legislation_code := hr_api.g_legislation_code;
1400 else
1401 hr_utility.set_location(hr_api.g_package||'return_legislation_code', 10);
1402 --
1403 -- The business_group_id is different to the last call to this
1404 -- function or this is the first call to this function.
1405 --
1406 open csr_leg_code;
1407 fetch csr_leg_code into l_legislation_code;
1408 if csr_leg_code%notfound then
1409 close csr_leg_code;
1410 hr_utility.set_message(801, 'HR_7208_API_BUS_GRP_INVALID');
1411 hr_utility.raise_error;
1412 end if;
1413 close csr_leg_code;
1414 --
1415 -- Set the global variables for the next call
1416 --
1417 hr_api.g_business_group_id := p_business_group_id;
1418 hr_api.g_legislation_code := l_legislation_code;
1419 end if;
1420 end if;
1421 return l_legislation_code;
1422 end return_legislation_code;
1423 --
1424 -- ----------------------------------------------------------------------------
1425 -- |---------------------------< userenv_lang >-------------------------------|
1426 -- ----------------------------------------------------------------------------
1427 --
1428 function userenv_lang return varchar2
1429 is
1430 begin
1431 -- DK 2002-11-08 PLSQLSTD
1432 return(userenv('LANG'));
1433 end userenv_lang;
1434 --
1435 -- ----------------------------------------------------------------------------
1436 -- |------------------------< validate_language_code >------------------------|
1437 -- ----------------------------------------------------------------------------
1438 --
1439 procedure validate_language_code
1440 (p_language_code in out nocopy varchar2
1441 ) is
1442 --
1443 -- Language validation cursor
1444 --
1445 cursor csr_val_lang(l_lang varchar2) is
1446 select null
1447 from fnd_languages lan
1448 where lan.installed_flag in ('I', 'B')
1449 and lan.language_code = l_lang;
1450 --
1451 -- Local variables
1452 --
1453 l_language_code varchar2(30);
1454 l_exists varchar2(1);
1455 begin
1456 --
1457 -- When a null or hr_api.g_varchar2 value is
1458 -- provided use userenv('LANG') instead.
1459 --
1460 if (p_language_code is null) or
1461 (p_language_code = hr_api.g_varchar2) then
1462 l_language_code := userenv_lang;
1463 else
1464 l_language_code := p_language_code;
1465 end if;
1466 hr_utility.set_location(hr_api.g_package||'validate_language_code', 10);
1467 --
1468 -- Validate that the language to be used is the application
1469 -- base language or an installed language.
1470 --
1471 open csr_val_lang(l_language_code);
1472 fetch csr_val_lang into l_exists;
1473 if csr_val_lang%notfound then
1474 close csr_val_lang;
1475 -- Error: The language specified must be the base language or an
1476 -- installed language.
1477 hr_utility.set_message(800, 'HR_52499_API_BASE_INSTALL_LANG');
1478 hr_utility.raise_error;
1479 end if;
1480 close csr_val_lang;
1481 --
1482 -- Output the valid language
1483 --
1484 p_language_code := l_language_code;
1485 --
1486 end validate_language_code;
1487
1488 --
1489 -- ----------------------------------------------------------------------------
1490 -- |------------------------< set_legislation_context >------------------------|
1491 -- ----------------------------------------------------------------------------
1492 --
1493 procedure set_legislation_context
1494 (p_legislation_code in varchar2
1495 ) is
1496 --
1497
1498 -- For backward compatibility, continue the initialization of application
1499 -- context HR_SESSION_DATA/LEG_CODE
1500
1501 begin
1502 g_leg_code := p_legislation_code;
1503 -- DK 2002-11-08 PLSQLSTD
1504 DBMS_SESSION.SET_CONTEXT('HR_SESSION_DATA','LEG_CODE',p_legislation_code);
1505 end set_legislation_context;
1506 --
1507 -- ----------------------------------------------------------------------------
1508 -- |------------------------< get_legislation_context >------------------------|
1509 -- ----------------------------------------------------------------------------
1510 --
1511 function get_legislation_context return varchar2 is
1512 --
1513 l_leg_code PER_BUSINESS_GROUPS_PERF.LEGISLATION_CODE%TYPE;
1514 begin
1515 -- Check for session context change and initialize legislation code accordingly
1516 IF NOT (FND_GLOBAL.COMPARE_SESSION_CONTEXT(g_session_context))
1517 THEN
1518 -- Initialize the session context
1519 g_session_context := FND_GLOBAL.Get_Session_Context;
1520
1521 -- Get the legislation code from BG
1522 l_leg_code := hr_api.return_legislation_code(fnd_profile.value('PER_BUSINESS_GROUP_ID'));
1523
1524 -- Set application context HR_SESSION_DATA/LEG_CODE
1528
1525 set_legislation_context(l_leg_code);
1526 --
1527 END IF;
1529 RETURN g_leg_code;
1530 end get_legislation_context;
1531 --
1532 -- ----------------------------------------------------------------------------
1533 -- |-----------------------< constant_to_boolean >----------------------------|
1534 -- ----------------------------------------------------------------------------
1535 --
1536 -- Description:
1537 -- Used in the Self Service API wrappers to convert constant values to the
1538 -- appropriate boolean ones.
1539 --
1540 -- ----------------------------------------------------------------------------
1541 FUNCTION constant_to_boolean(p_constant_value IN number) RETURN boolean IS
1542 BEGIN
1543 IF p_constant_value = hr_api.g_false_num THEN
1544 RETURN false;
1545 ELSE
1546 RETURN true;
1547 END IF;
1548 END constant_to_boolean;
1549 --
1550 -- ----------------------------------------------------------------------------
1551 -- |-----------------------< boolean_to_constant >----------------------------|
1552 -- ----------------------------------------------------------------------------
1553 --
1554 -- Description:
1555 -- Used in the Self Service API wrappers to convert constant values to the
1556 -- appropriate boolean ones.
1557 --
1558 -- ----------------------------------------------------------------------------
1559 FUNCTION boolean_to_constant(p_boolean_value IN boolean) RETURN number IS
1560 BEGIN
1561 IF p_boolean_value THEN
1562 RETURN hr_api.g_true_num;
1563 ELSE
1564 RETURN hr_api.g_false_num;
1565 END IF;
1566 END boolean_to_constant;
1567 --
1568 End HR_Api;