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