[Home] [Help]
PACKAGE BODY: APPS.IRC_PARTY_API
Source
1 package body IRC_PARTY_API as
2 /* $Header: irhzpapi.pkb 120.65.12020000.7 2013/01/01 17:33:43 nivsubra ship $ */
3 --Package Variables
4 --
5 g_package varchar2(33) := 'irc_party_api.';
6 --
7 -- -------------------------------------------------------------------------
8 -- |------------------------< create_candidate_internal >------------------|
9 -- -------------------------------------------------------------------------
10 --
11 procedure create_candidate_internal
12 (p_validate IN boolean default false
13 ,p_business_group_id IN number
14 ,p_last_name IN varchar2
15 ,p_first_name IN varchar2 default null
16 ,p_date_of_birth IN date default null
17 ,p_email_address IN varchar2 default null
18 ,p_title IN varchar2 default null
19 ,p_gender IN varchar2 default null
20 ,p_marital_status IN varchar2 default null
21 ,p_previous_last_name IN varchar2 default null
22 ,p_middle_name IN varchar2 default null
23 ,p_name_suffix IN varchar2 default null
24 ,p_known_as IN varchar2 default null
25 ,p_first_name_phonetic IN varchar2 default null
26 ,p_last_name_phonetic IN varchar2 default null
27 ,p_attribute_category IN varchar2 default null
28 ,p_attribute1 IN varchar2 default null
29 ,p_attribute2 IN varchar2 default null
30 ,p_attribute3 IN varchar2 default null
31 ,p_attribute4 IN varchar2 default null
32 ,p_attribute5 IN varchar2 default null
33 ,p_attribute6 IN varchar2 default null
34 ,p_attribute7 IN varchar2 default null
35 ,p_attribute8 IN varchar2 default null
36 ,p_attribute9 IN varchar2 default null
37 ,p_attribute10 IN varchar2 default null
38 ,p_attribute11 IN varchar2 default null
39 ,p_attribute12 IN varchar2 default null
40 ,p_attribute13 IN varchar2 default null
41 ,p_attribute14 IN varchar2 default null
42 ,p_attribute15 IN varchar2 default null
43 ,p_attribute16 IN varchar2 default null
44 ,p_attribute17 IN varchar2 default null
45 ,p_attribute18 IN varchar2 default null
46 ,p_attribute19 IN varchar2 default null
47 ,p_attribute20 IN varchar2 default null
48 ,p_attribute21 IN varchar2 default null
49 ,p_attribute22 IN varchar2 default null
50 ,p_attribute23 IN varchar2 default null
51 ,p_attribute24 IN varchar2 default null
52 ,p_attribute25 IN varchar2 default null
53 ,p_attribute26 IN varchar2 default null
54 ,p_attribute27 IN varchar2 default null
55 ,p_attribute28 IN varchar2 default null
56 ,p_attribute29 IN varchar2 default null
57 ,p_attribute30 IN varchar2 default null
58 ,p_per_information_category IN varchar2 default null
59 ,p_per_information1 IN varchar2 default null
60 ,p_per_information2 IN varchar2 default null
61 ,p_per_information3 IN varchar2 default null
62 ,p_per_information4 IN varchar2 default null
63 ,p_per_information5 IN varchar2 default null
64 ,p_per_information6 IN varchar2 default null
65 ,p_per_information7 IN varchar2 default null
66 ,p_per_information8 IN varchar2 default null
67 ,p_per_information9 IN varchar2 default null
68 ,p_per_information10 IN varchar2 default null
69 ,p_per_information11 IN varchar2 default null
70 ,p_per_information12 IN varchar2 default null
71 ,p_per_information13 IN varchar2 default null
72 ,p_per_information14 IN varchar2 default null
73 ,p_per_information15 IN varchar2 default null
74 ,p_per_information16 IN varchar2 default null
75 ,p_per_information17 IN varchar2 default null
76 ,p_per_information18 IN varchar2 default null
77 ,p_per_information19 IN varchar2 default null
78 ,p_per_information20 IN varchar2 default null
79 ,p_per_information21 IN varchar2 default null
80 ,p_per_information22 IN varchar2 default null
81 ,p_per_information23 IN varchar2 default null
82 ,p_per_information24 IN varchar2 default null
83 ,p_per_information25 IN varchar2 default null
84 ,p_per_information26 IN varchar2 default null
85 ,p_per_information27 IN varchar2 default null
86 ,p_per_information28 IN varchar2 default null
87 ,p_per_information29 IN varchar2 default null
88 ,p_per_information30 IN varchar2 default null
89 ,p_nationality IN varchar2 default null
90 ,p_national_identifier IN varchar2 default null
91 ,p_town_of_birth IN varchar2 default null
92 ,p_region_of_birth IN varchar2 default null
93 ,p_country_of_birth IN varchar2 default null
94 ,p_allow_access IN varchar2 default null
95 ,p_party_id IN number default null
96 ,p_start_date IN date default null
97 ,p_effective_start_date OUT NOCOPY date
98 ,p_effective_end_date OUT NOCOPY date
99 ,p_person_id OUT NOCOPY number) IS
100 --
101 l_proc varchar2(72) := g_package||'create_candidate_internal';
102 l_person_id PER_ALL_PEOPLE_F.PERSON_ID%TYPE;
103 l_date_of_birth per_all_people_f.date_of_birth%type;
104 l_business_group_id per_all_people_f.business_group_id%type;
105 l_person_type_id per_all_people_f.person_type_id%type;
106 l_last_name_phonetic hz_person_profiles.person_last_name_phonetic%type
107 := p_last_name_phonetic;
108 --
109 -- dummy variables
110 --
111 l_object_version_number per_all_people_f.object_version_number%type;
112 l_effective_start_date per_all_people_f.effective_start_date%type;
113 l_effective_end_date per_all_people_f.effective_end_date%type;
114 l_full_name per_all_people_f.full_name%type;
115 l_comment_id per_all_people_f.comment_id%type;
116 l_name_combination_warning boolean;
117 l_orig_hire_warning boolean;
118 l_assign_payroll_warning boolean;
119 l_legislation_code per_business_groups_perf.legislation_code%type;
120 l_ptu_person_type_id number(15);
121 l_employee_number per_all_people_f.employee_number%type := hr_api.g_varchar2;
122 --
123 -- for disabling the descriptive flex field
124 l_add_struct_d hr_dflex_utility.l_ignore_dfcode_varray :=
125 hr_dflex_utility.l_ignore_dfcode_varray();
126 --
127 -- cursor to select the legislation from per_business_groups_perf
128 -- corresponding to the business group
129 --
130 cursor csr_legislation_code(p_business_group_id number) is
131 select legislation_code
132 from per_business_groups_perf
133 where business_group_id = p_business_group_id;
134 --
135 -- cursor to select the person_type_id from hr_organization_inforamtion
136 -- corresponding to the recruiting flexfield on the business group
137 --
138 cursor csr_get_person_type_id(p_business_group_id number) is
139 select org_information8
140 from hr_organization_information
141 where organization_id=p_business_group_id
142 and ORG_INFORMATION_CONTEXT='BG Recruitment';
143 --
144 l_notification_preference_id number;
145 l_search_criteria_id number;
146 --
147 l_start_date date;
148 begin
149 hr_utility.set_location(' Entering: '||l_proc, 10);
150 --
151 -- Issue a savepoint
152 --
153 savepoint CREATE_CANDIDATE_INTERNAL;
154 --
155 -- Truncate the time portion from all IN date parameters
156 --
157 l_date_of_birth := trunc(p_date_of_birth);
158 --
159 -- if the input p_start_date is NULL then
160 -- set the start date of the person record to two days in the past to allow the person to
161 -- made an applicant today, and for them to be hired today, pushing the apply date one
162 -- day in to the past if neccesary
163 --
164 if (p_start_date is NULL) then
165 l_start_date:=trunc(sysdate-2);
166 else
167 l_start_date:=trunc(p_start_date-2);
168 end if;
169 --
170 -- Call Before Process User Hook
171 --
172 begin
173 IRC_PARTY_BK5.CREATE_CANDIDATE_INTERNAL_B
174 (p_business_group_id => p_business_group_id
175 ,p_last_name => p_last_name
176 ,p_first_name => p_first_name
177 ,p_email_address => p_email_address
178 ,p_date_of_birth => l_date_of_birth
179 ,p_title => p_title
180 ,p_gender => p_gender
181 ,p_marital_status => p_marital_status
182 ,p_previous_last_name => p_previous_last_name
183 ,p_middle_name => p_middle_name
184 ,p_name_suffix => p_name_suffix
185 ,p_known_as => p_known_as
186 ,p_first_name_phonetic => p_first_name_phonetic
187 ,p_last_name_phonetic => p_last_name_phonetic
188 ,p_attribute_category => p_attribute_category
189 ,p_attribute1 => p_attribute1
190 ,p_attribute2 => p_attribute2
191 ,p_attribute3 => p_attribute3
192 ,p_attribute4 => p_attribute4
193 ,p_attribute5 => p_attribute5
194 ,p_attribute6 => p_attribute6
195 ,p_attribute7 => p_attribute7
196 ,p_attribute8 => p_attribute8
197 ,p_attribute9 => p_attribute9
198 ,p_attribute10 => p_attribute10
199 ,p_attribute11 => p_attribute11
200 ,p_attribute12 => p_attribute12
201 ,p_attribute13 => p_attribute13
202 ,p_attribute14 => p_attribute14
203 ,p_attribute15 => p_attribute15
204 ,p_attribute16 => p_attribute16
205 ,p_attribute17 => p_attribute17
206 ,p_attribute18 => p_attribute18
207 ,p_attribute19 => p_attribute19
208 ,p_attribute20 => p_attribute20
209 ,p_attribute21 => p_attribute21
210 ,p_attribute22 => p_attribute22
211 ,p_attribute23 => p_attribute23
212 ,p_attribute24 => p_attribute24
213 ,p_attribute25 => p_attribute25
214 ,p_attribute26 => p_attribute26
215 ,p_attribute27 => p_attribute27
216 ,p_attribute28 => p_attribute28
217 ,p_attribute29 => p_attribute29
218 ,p_attribute30 => p_attribute30
219 ,p_per_information_category => p_per_information_category
220 ,p_per_information1 => p_per_information1
221 ,p_per_information2 => p_per_information2
222 ,p_per_information3 => p_per_information3
223 ,p_per_information4 => p_per_information4
224 ,p_per_information5 => p_per_information5
225 ,p_per_information6 => p_per_information6
226 ,p_per_information7 => p_per_information7
227 ,p_per_information8 => p_per_information8
228 ,p_per_information9 => p_per_information9
229 ,p_per_information10 => p_per_information10
230 ,p_per_information11 => p_per_information11
231 ,p_per_information12 => p_per_information12
232 ,p_per_information13 => p_per_information13
233 ,p_per_information14 => p_per_information14
234 ,p_per_information15 => p_per_information15
235 ,p_per_information16 => p_per_information16
236 ,p_per_information17 => p_per_information17
237 ,p_per_information18 => p_per_information18
238 ,p_per_information19 => p_per_information19
239 ,p_per_information20 => p_per_information20
240 ,p_per_information21 => p_per_information21
241 ,p_per_information22 => p_per_information22
242 ,p_per_information23 => p_per_information23
243 ,p_per_information24 => p_per_information24
244 ,p_per_information25 => p_per_information25
245 ,p_per_information26 => p_per_information26
246 ,p_per_information27 => p_per_information27
247 ,p_per_information28 => p_per_information28
248 ,p_per_information29 => p_per_information29
249 ,p_per_information30 => p_per_information30
250 ,p_nationality => p_nationality
251 ,p_national_identifier => p_national_identifier
252 ,p_town_of_birth => p_town_of_birth
253 ,p_region_of_birth => p_region_of_birth
254 ,p_country_of_birth => p_country_of_birth
255 ,p_allow_access => p_allow_access
256 ,p_start_date => l_start_date
257 ,p_party_id => p_party_id
258 );
259 exception
260 when hr_api.cannot_find_prog_unit then
261 hr_api.cannot_find_prog_unit_error
262 (p_module_name => 'CREATE_CANDIDATE_INTERNAL'
263 ,p_hook_type => 'BP'
264 );
265 end;
266 --
267 -- Process Logic
268 -- code for disabling the descriptive flex field
269 --
270 l_add_struct_d.extend(1);
271 l_add_struct_d(l_add_struct_d.count) := 'IRC_SEARCH_CRITERIA';
272 l_add_struct_d.extend(1);
273 l_add_struct_d(l_add_struct_d.count) := 'IRC_SEARCH_CRITERIA_DDF';
274 l_add_struct_d.extend(1);
275 l_add_struct_d(l_add_struct_d.count) := 'IRC_NOTIFICATION_PREFERENCES';
276 l_add_struct_d.extend(1);
277 l_add_struct_d(l_add_struct_d.count) := 'PER_PEOPLE';
278 l_add_struct_d.extend(1);
279 l_add_struct_d(l_add_struct_d.count) := 'Person Developer DF';
280 --
281 hr_dflex_utility.create_ignore_df_validation(p_rec => l_add_struct_d);
282 --
283 --
284 --
285 -- Get the legislation code corrsponding to the business group id
286 --
287 open csr_legislation_code(p_business_group_id);
288 fetch csr_legislation_code into l_legislation_code;
289 close csr_legislation_code;
290 --
291 -- Get the person type id
292 --
293 open csr_get_person_type_id(p_business_group_id);
294 fetch csr_get_person_type_id into l_person_type_id;
295 close csr_get_person_type_id;
296 --
297 if l_person_type_id is null then
298 fnd_message.set_name('PER','IRC_412156_PERS_TYPE_NOT_SET');
299 fnd_message.raise_error;
300 end if;
301 --
302 -- get the PTU person type for iRecruitment Candidate
303 --
304 l_ptu_person_type_id:=hr_person_type_usage_info.get_default_person_type_id
305 (p_business_group_id,
306 'IRC_REG_USER');
307 --
308 -- Handle Kana and Kanji names for Japan legislation
309 --
310 if (l_legislation_code = 'JP') then
311
312 hr_contact_api.create_irec_person
313 (p_validate => p_validate
314 ,p_start_date => l_start_date
315 ,p_business_group_id => p_business_group_id
316 ,p_last_name => p_last_name
317 ,p_sex => p_gender
318 ,p_person_type_id => l_person_type_id
319 ,p_date_of_birth => l_date_of_birth
320 ,p_email_address => p_email_address
321 ,p_first_name => p_first_name
322 ,p_known_as => p_known_as
323 ,p_marital_status => p_marital_status
324 ,p_previous_last_name => p_previous_last_name
325 ,p_title => p_title
326 ,p_middle_names => p_middle_name
327 ,p_attribute_category => p_attribute_category
328 ,p_attribute1 => p_attribute1
329 ,p_attribute2 => p_attribute2
330 ,p_attribute3 => p_attribute3
331 ,p_attribute4 => p_attribute4
332 ,p_attribute5 => p_attribute5
333 ,p_attribute6 => p_attribute6
334 ,p_attribute7 => p_attribute7
335 ,p_attribute8 => p_attribute8
336 ,p_attribute9 => p_attribute9
337 ,p_attribute10 => p_attribute10
338 ,p_attribute11 => p_attribute11
339 ,p_attribute12 => p_attribute12
340 ,p_attribute13 => p_attribute13
341 ,p_attribute14 => p_attribute14
342 ,p_attribute15 => p_attribute15
343 ,p_attribute16 => p_attribute16
344 ,p_attribute17 => p_attribute17
345 ,p_attribute18 => p_attribute18
346 ,p_attribute19 => p_attribute19
347 ,p_attribute20 => p_attribute20
348 ,p_attribute21 => p_attribute21
349 ,p_attribute22 => p_attribute22
350 ,p_attribute23 => p_attribute23
351 ,p_attribute24 => p_attribute24
352 ,p_attribute25 => p_attribute25
353 ,p_attribute26 => p_attribute26
354 ,p_attribute27 => p_attribute27
355 ,p_attribute28 => p_attribute28
356 ,p_attribute29 => p_attribute29
357 ,p_attribute30 => p_attribute30
358 ,p_per_information_category => l_legislation_code
359 ,p_per_information1 => p_per_information1
360 ,p_per_information2 => p_per_information2
361 ,p_per_information3 => p_per_information3
362 ,p_per_information4 => p_per_information4
363 ,p_per_information5 => p_per_information5
364 ,p_per_information6 => p_per_information6
365 ,p_per_information7 => p_per_information7
366 ,p_per_information8 => p_per_information8
367 ,p_per_information9 => p_per_information9
368 ,p_per_information10 => p_per_information10
369 ,p_per_information11 => p_per_information11
370 ,p_per_information12 => p_per_information12
371 ,p_per_information13 => p_per_information13
372 ,p_per_information14 => p_per_information14
373 ,p_per_information15 => p_per_information15
374 ,p_per_information16 => p_per_information16
375 ,p_per_information17 => p_per_information17
376 ,p_per_information18 => p_per_information18
377 ,p_per_information19 => p_per_information19
378 ,p_per_information20 => p_per_information20
379 ,p_per_information21 => p_per_information21
380 ,p_per_information22 => p_per_information22
381 ,p_per_information23 => p_per_information23
382 ,p_per_information24 => p_per_information24
383 ,p_per_information25 => p_per_information25
384 ,p_per_information26 => p_per_information26
385 ,p_per_information27 => p_per_information27
386 ,p_per_information28 => p_per_information28
387 ,p_per_information29 => p_per_information29
388 ,p_per_information30 => p_per_information30
389 ,p_nationality => p_nationality
390 ,p_national_identifier => p_national_identifier
391 ,p_town_of_birth => p_town_of_birth
392 ,p_region_of_birth => p_region_of_birth
393 ,p_country_of_birth => p_country_of_birth
394 ,p_suffix => p_name_suffix
395 ,p_person_id => l_person_id
396 ,p_object_version_number => l_object_version_number
397 ,p_effective_start_date => l_effective_start_date
398 ,p_effective_end_date => l_effective_end_date
399 ,p_full_name => l_full_name
400 ,p_comment_id => l_comment_id
401 ,p_name_combination_warning => l_name_combination_warning
402 ,p_orig_hire_warning => l_orig_hire_warning
403 );
404 --
405 -- Handle phonetic names for Korean legislation
406 --
407 elsif (l_legislation_code = 'KR') then
408 hr_contact_api.create_irec_person
409 (p_validate => p_validate
410 ,p_start_date => l_start_date
411 ,p_business_group_id => p_business_group_id
412 ,p_last_name => p_last_name
413 ,p_sex => p_gender
414 ,p_person_type_id => l_person_type_id
415 ,p_email_address => p_email_address
416 ,p_date_of_birth => l_date_of_birth
417 ,p_first_name => p_first_name
418 ,p_known_as => p_known_as
419 ,p_marital_status => p_marital_status
420 ,p_previous_last_name => p_previous_last_name
421 ,p_title => p_title
422 ,p_middle_names => p_middle_name
423 ,p_attribute_category => p_attribute_category
424 ,p_attribute1 => p_attribute1
425 ,p_attribute2 => p_attribute2
426 ,p_attribute3 => p_attribute3
427 ,p_attribute4 => p_attribute4
428 ,p_attribute5 => p_attribute5
429 ,p_attribute6 => p_attribute6
430 ,p_attribute7 => p_attribute7
431 ,p_attribute8 => p_attribute8
432 ,p_attribute9 => p_attribute9
433 ,p_attribute10 => p_attribute10
434 ,p_attribute11 => p_attribute11
435 ,p_attribute12 => p_attribute12
436 ,p_attribute13 => p_attribute13
437 ,p_attribute14 => p_attribute14
438 ,p_attribute15 => p_attribute15
439 ,p_attribute16 => p_attribute16
440 ,p_attribute17 => p_attribute17
441 ,p_attribute18 => p_attribute18
442 ,p_attribute19 => p_attribute19
443 ,p_attribute20 => p_attribute20
444 ,p_attribute21 => p_attribute21
445 ,p_attribute22 => p_attribute22
446 ,p_attribute23 => p_attribute23
447 ,p_attribute24 => p_attribute24
448 ,p_attribute25 => p_attribute25
449 ,p_attribute26 => p_attribute26
450 ,p_attribute27 => p_attribute27
451 ,p_attribute28 => p_attribute28
452 ,p_attribute29 => p_attribute29
453 ,p_attribute30 => p_attribute30
454 ,p_per_information_category => l_legislation_code
455 ,p_per_information1 => l_last_name_phonetic
456 ,p_per_information2 => p_first_name_phonetic
457 ,p_per_information3 => p_per_information3
458 ,p_per_information4 => p_per_information4
459 ,p_per_information5 => p_per_information5
460 ,p_per_information6 => p_per_information6
461 ,p_per_information7 => p_per_information7
462 ,p_per_information8 => p_per_information8
463 ,p_per_information9 => p_per_information9
464 ,p_per_information10 => p_per_information10
465 ,p_per_information11 => p_per_information11
466 ,p_per_information12 => p_per_information12
467 ,p_per_information13 => p_per_information13
468 ,p_per_information14 => p_per_information14
469 ,p_per_information15 => p_per_information15
470 ,p_per_information16 => p_per_information16
471 ,p_per_information17 => p_per_information17
472 ,p_per_information18 => p_per_information18
473 ,p_per_information19 => p_per_information19
474 ,p_per_information20 => p_per_information20
475 ,p_per_information21 => p_per_information21
476 ,p_per_information22 => p_per_information22
477 ,p_per_information23 => p_per_information23
478 ,p_per_information24 => p_per_information24
479 ,p_per_information25 => p_per_information25
480 ,p_per_information26 => p_per_information26
481 ,p_per_information27 => p_per_information27
482 ,p_per_information28 => p_per_information28
483 ,p_per_information29 => p_per_information29
484 ,p_per_information30 => p_per_information30
485 ,p_nationality => p_nationality
486 ,p_national_identifier => p_national_identifier
487 ,p_town_of_birth => p_town_of_birth
488 ,p_region_of_birth => p_region_of_birth
489 ,p_country_of_birth => p_country_of_birth
490 ,p_suffix => p_name_suffix
491 ,p_person_id => l_person_id
492 ,p_object_version_number => l_object_version_number
493 ,p_effective_start_date => l_effective_start_date
494 ,p_effective_end_date => l_effective_end_date
495 ,p_full_name => l_full_name
496 ,p_comment_id => l_comment_id
497 ,p_name_combination_warning => l_name_combination_warning
498 ,p_orig_hire_warning => l_orig_hire_warning
499 );
500 else
501 hr_contact_api.create_irec_person
502 (p_validate => p_validate
503 ,p_start_date => l_start_date
504 ,p_business_group_id => p_business_group_id
505 ,p_last_name => p_last_name
506 ,p_sex => p_gender
507 ,p_person_type_id => l_person_type_id
508 ,p_email_address => p_email_address
509 ,p_date_of_birth => l_date_of_birth
510 ,p_first_name => p_first_name
511 ,p_known_as => p_known_as
512 ,p_marital_status => p_marital_status
513 ,p_previous_last_name => p_previous_last_name
514 ,p_title => p_title
515 ,p_middle_names => p_middle_name
516 ,p_attribute_category => p_attribute_category
517 ,p_attribute1 => p_attribute1
518 ,p_attribute2 => p_attribute2
519 ,p_attribute3 => p_attribute3
520 ,p_attribute4 => p_attribute4
521 ,p_attribute5 => p_attribute5
522 ,p_attribute6 => p_attribute6
523 ,p_attribute7 => p_attribute7
524 ,p_attribute8 => p_attribute8
525 ,p_attribute9 => p_attribute9
526 ,p_attribute10 => p_attribute10
527 ,p_attribute11 => p_attribute11
528 ,p_attribute12 => p_attribute12
529 ,p_attribute13 => p_attribute13
530 ,p_attribute14 => p_attribute14
531 ,p_attribute15 => p_attribute15
532 ,p_attribute16 => p_attribute16
533 ,p_attribute17 => p_attribute17
534 ,p_attribute18 => p_attribute18
535 ,p_attribute19 => p_attribute19
536 ,p_attribute20 => p_attribute20
537 ,p_attribute21 => p_attribute21
538 ,p_attribute22 => p_attribute22
539 ,p_attribute23 => p_attribute23
540 ,p_attribute24 => p_attribute24
541 ,p_attribute25 => p_attribute25
542 ,p_attribute26 => p_attribute26
543 ,p_attribute27 => p_attribute27
544 ,p_attribute28 => p_attribute28
545 ,p_attribute29 => p_attribute29
546 ,p_attribute30 => p_attribute30
547 ,p_per_information_category => l_legislation_code
548 ,p_per_information1 => p_per_information1
549 ,p_per_information2 => p_per_information2
550 ,p_per_information3 => p_per_information3
551 ,p_per_information4 => p_per_information4
552 ,p_per_information5 => p_per_information5
553 ,p_per_information6 => p_per_information6
554 ,p_per_information7 => p_per_information7
555 ,p_per_information8 => p_per_information8
556 ,p_per_information9 => p_per_information9
557 ,p_per_information10 => p_per_information10
558 ,p_per_information11 => p_per_information11
559 ,p_per_information12 => p_per_information12
560 ,p_per_information13 => p_per_information13
561 ,p_per_information14 => p_per_information14
562 ,p_per_information15 => p_per_information15
563 ,p_per_information16 => p_per_information16
564 ,p_per_information17 => p_per_information17
565 ,p_per_information18 => p_per_information18
566 ,p_per_information19 => p_per_information19
567 ,p_per_information20 => p_per_information20
568 ,p_per_information21 => p_per_information21
569 ,p_per_information22 => p_per_information22
570 ,p_per_information23 => p_per_information23
571 ,p_per_information24 => p_per_information24
572 ,p_per_information25 => p_per_information25
573 ,p_per_information26 => p_per_information26
574 ,p_per_information27 => p_per_information27
575 ,p_per_information28 => p_per_information28
576 ,p_per_information29 => p_per_information29
577 ,p_per_information30 => p_per_information30
578 ,p_nationality => p_nationality
579 ,p_national_identifier => p_national_identifier
580 ,p_town_of_birth => p_town_of_birth
581 ,p_region_of_birth => p_region_of_birth
582 ,p_country_of_birth => p_country_of_birth
583 ,p_suffix => p_name_suffix
584 ,p_person_id => l_person_id
585 ,p_object_version_number => l_object_version_number
586 ,p_effective_start_date => l_effective_start_date
587 ,p_effective_end_date => l_effective_end_date
588 ,p_full_name => l_full_name
589 ,p_comment_id => l_comment_id
590 ,p_name_combination_warning => l_name_combination_warning
591 ,p_orig_hire_warning => l_orig_hire_warning
592 );
593 end if;
594 hr_utility.set_location(l_proc, 40);
595
596 -- calling this will associate the TCA party with the newly created Candidate and prevent PTU code from
597 -- creating a new TCA record
598 if p_party_id is not NULL then
599 hr_person_api.update_person(p_effective_date => l_start_date
600 ,p_datetrack_update_mode => 'CORRECTION'
601 ,p_person_id => l_person_id
602 ,p_party_id => p_party_id
603 ,p_employee_number => l_employee_number /* CHECK THIS*/
604 ,p_object_version_number => l_object_version_number
605 ,p_effective_start_date => l_effective_start_date
606 ,p_effective_end_date => l_effective_end_date
607 ,p_full_name => l_full_name
608 ,p_comment_id => l_comment_id
609 ,p_name_combination_warning => l_name_combination_warning
610 ,p_assign_payroll_warning => l_assign_payroll_warning
611 ,p_orig_hire_warning => l_orig_hire_warning
612 );
613 end if;
614
615 --
616 -- create the extra PTU entry for iRecruitment Candidate
617 --
618 hr_per_type_usage_internal.maintain_person_type_usage
619 (p_effective_date => l_start_date
620 ,p_person_id => l_person_id
621 ,p_person_type_id => l_ptu_person_type_id
622 );
623 hr_utility.set_location(l_proc, 45);
624 --
625 -- Call After Process User Hook
626 --
627 begin
628 IRC_PARTY_BK5.CREATE_CANDIDATE_INTERNAL_A
629 (p_business_group_id => p_business_group_id
630 ,p_last_name => p_last_name
631 ,p_first_name => p_first_name
632 ,p_email_address => p_email_address
633 ,p_date_of_birth => l_date_of_birth
634 ,p_title => p_title
635 ,p_gender => p_gender
636 ,p_marital_status => p_marital_status
637 ,p_previous_last_name => p_previous_last_name
638 ,p_middle_name => p_middle_name
639 ,p_name_suffix => p_name_suffix
640 ,p_known_as => p_known_as
641 ,p_first_name_phonetic => p_first_name_phonetic
642 ,p_last_name_phonetic => p_last_name_phonetic
643 ,p_attribute_category => p_attribute_category
644 ,p_attribute1 => p_attribute1
645 ,p_attribute2 => p_attribute2
646 ,p_attribute3 => p_attribute3
647 ,p_attribute4 => p_attribute4
648 ,p_attribute5 => p_attribute5
649 ,p_attribute6 => p_attribute6
650 ,p_attribute7 => p_attribute7
651 ,p_attribute8 => p_attribute8
652 ,p_attribute9 => p_attribute9
653 ,p_attribute10 => p_attribute10
654 ,p_attribute11 => p_attribute11
655 ,p_attribute12 => p_attribute12
656 ,p_attribute13 => p_attribute13
657 ,p_attribute14 => p_attribute14
658 ,p_attribute15 => p_attribute15
659 ,p_attribute16 => p_attribute16
660 ,p_attribute17 => p_attribute17
661 ,p_attribute18 => p_attribute18
662 ,p_attribute19 => p_attribute19
663 ,p_attribute20 => p_attribute20
664 ,p_attribute21 => p_attribute21
665 ,p_attribute22 => p_attribute22
666 ,p_attribute23 => p_attribute23
667 ,p_attribute24 => p_attribute24
668 ,p_attribute25 => p_attribute25
669 ,p_attribute26 => p_attribute26
670 ,p_attribute27 => p_attribute27
671 ,p_attribute28 => p_attribute28
672 ,p_attribute29 => p_attribute29
673 ,p_attribute30 => p_attribute30
674 ,p_per_information_category => p_per_information_category
675 ,p_per_information1 => p_per_information1
676 ,p_per_information2 => p_per_information2
677 ,p_per_information3 => p_per_information3
678 ,p_per_information4 => p_per_information4
679 ,p_per_information5 => p_per_information5
680 ,p_per_information6 => p_per_information6
681 ,p_per_information7 => p_per_information7
682 ,p_per_information8 => p_per_information8
683 ,p_per_information9 => p_per_information9
684 ,p_per_information10 => p_per_information10
685 ,p_per_information11 => p_per_information11
686 ,p_per_information12 => p_per_information12
687 ,p_per_information13 => p_per_information13
688 ,p_per_information14 => p_per_information14
689 ,p_per_information15 => p_per_information15
690 ,p_per_information16 => p_per_information16
691 ,p_per_information17 => p_per_information17
692 ,p_per_information18 => p_per_information18
693 ,p_per_information19 => p_per_information19
694 ,p_per_information20 => p_per_information20
695 ,p_per_information21 => p_per_information21
696 ,p_per_information22 => p_per_information22
697 ,p_per_information23 => p_per_information23
698 ,p_per_information24 => p_per_information24
699 ,p_per_information25 => p_per_information25
700 ,p_per_information26 => p_per_information26
701 ,p_per_information27 => p_per_information27
702 ,p_per_information28 => p_per_information28
703 ,p_per_information29 => p_per_information29
704 ,p_per_information30 => p_per_information30
705 ,p_nationality => p_nationality
706 ,p_national_identifier => p_national_identifier
707 ,p_town_of_birth => p_town_of_birth
708 ,p_region_of_birth => p_region_of_birth
709 ,p_country_of_birth => p_country_of_birth
710 ,p_person_id => l_person_id
711 ,p_effective_start_date => l_effective_start_date
712 ,p_effective_end_date => l_effective_end_date
713 ,p_allow_access => p_allow_access
714 ,p_start_date => l_start_date
715 ,p_party_id => p_party_id
716 );
717 exception
718 when hr_api.cannot_find_prog_unit then
719 hr_api.cannot_find_prog_unit_error
720 (p_module_name => 'CREATE_CANDIDATE_INTERNAL'
721 ,p_hook_type => 'AP'
722 );
723 end;
724 --
725 -- When IN validation only mode raise the Validate_Enabled exception
726 --
727 if p_validate then
728 raise hr_api.validate_enabled;
729 end if;
730 --
731 -- Set all output arguments
732 --
733 p_person_id := l_person_id;
734 p_effective_start_date := l_effective_start_date;
735 p_effective_end_date := l_effective_end_date;
736 --
737 hr_utility.set_location(' Leaving:'||l_proc, 70);
738
739 exception
740 when hr_Api.validate_enabled then
741 --
742 -- As the Validate_Enabled exception has been raised
743 -- we must rollback to the savepoint
744 --
745 rollback to CREATE_CANDIDATE_INTERNAL;
746 --
747 -- Only set output warning arguments
748 -- (Any key or derived arguments must be set to null
749 -- when validation only mode is beINg used.)
750 --
751 p_person_id := null;
752 p_effective_start_date := null;
753 p_effective_start_date := null;
754 hr_utility.set_location(' Leaving:'||l_proc, 80);
755 when others then
756 --
757 -- A validation or unexpected error has occured
758 --
759 rollback to CREATE_CANDIDATE_INTERNAL;
760 --
761 p_person_id := null;
762 p_effective_start_date := null;
763 p_effective_start_date := null;
764 --
765 hr_utility.set_location(' Leaving:'||l_proc, 90);
766 raise;
767 end create_candidate_internal;
768 --
769 -- -------------------------------------------------------------------------
770 -- |------------------------< create_registered_user >----------------------|
771 -- -------------------------------------------------------------------------
772 --
773 procedure create_registered_user
774 (p_validate IN boolean default false
775 ,p_last_name IN varchar2
776 ,p_first_name IN varchar2 default null
777 ,p_date_of_birth IN date default null
778 ,p_email_address IN varchar2 default null
779 ,p_title IN varchar2 default null
780 ,p_gender IN varchar2 default null
781 ,p_marital_status IN varchar2 default null
782 ,p_previous_last_name IN varchar2 default null
783 ,p_middle_name IN varchar2 default null
784 ,p_name_suffix IN varchar2 default null
785 ,p_known_as IN varchar2 default null
786 ,p_first_name_phonetic IN varchar2 default null
787 ,p_last_name_phonetic IN varchar2 default null
788 ,p_attribute_category IN varchar2 default null
789 ,p_attribute1 IN varchar2 default null
790 ,p_attribute2 IN varchar2 default null
791 ,p_attribute3 IN varchar2 default null
792 ,p_attribute4 IN varchar2 default null
793 ,p_attribute5 IN varchar2 default null
794 ,p_attribute6 IN varchar2 default null
795 ,p_attribute7 IN varchar2 default null
796 ,p_attribute8 IN varchar2 default null
797 ,p_attribute9 IN varchar2 default null
798 ,p_attribute10 IN varchar2 default null
799 ,p_attribute11 IN varchar2 default null
800 ,p_attribute12 IN varchar2 default null
801 ,p_attribute13 IN varchar2 default null
802 ,p_attribute14 IN varchar2 default null
803 ,p_attribute15 IN varchar2 default null
804 ,p_attribute16 IN varchar2 default null
805 ,p_attribute17 IN varchar2 default null
806 ,p_attribute18 IN varchar2 default null
807 ,p_attribute19 IN varchar2 default null
808 ,p_attribute20 IN varchar2 default null
809 ,p_attribute21 IN varchar2 default null
810 ,p_attribute22 IN varchar2 default null
811 ,p_attribute23 IN varchar2 default null
812 ,p_attribute24 IN varchar2 default null
813 ,p_attribute25 IN varchar2 default null
814 ,p_attribute26 IN varchar2 default null
815 ,p_attribute27 IN varchar2 default null
816 ,p_attribute28 IN varchar2 default null
817 ,p_attribute29 IN varchar2 default null
818 ,p_attribute30 IN varchar2 default null
819 ,p_per_information_category IN varchar2 default null
820 ,p_per_information1 IN varchar2 default null
821 ,p_per_information2 IN varchar2 default null
822 ,p_per_information3 IN varchar2 default null
823 ,p_per_information4 IN varchar2 default null
824 ,p_per_information5 IN varchar2 default null
825 ,p_per_information6 IN varchar2 default null
826 ,p_per_information7 IN varchar2 default null
827 ,p_per_information8 IN varchar2 default null
828 ,p_per_information9 IN varchar2 default null
829 ,p_per_information10 IN varchar2 default null
830 ,p_per_information11 IN varchar2 default null
831 ,p_per_information12 IN varchar2 default null
832 ,p_per_information13 IN varchar2 default null
833 ,p_per_information14 IN varchar2 default null
834 ,p_per_information15 IN varchar2 default null
835 ,p_per_information16 IN varchar2 default null
836 ,p_per_information17 IN varchar2 default null
837 ,p_per_information18 IN varchar2 default null
838 ,p_per_information19 IN varchar2 default null
839 ,p_per_information20 IN varchar2 default null
840 ,p_per_information21 IN varchar2 default null
841 ,p_per_information22 IN varchar2 default null
842 ,p_per_information23 IN varchar2 default null
843 ,p_per_information24 IN varchar2 default null
844 ,p_per_information25 IN varchar2 default null
845 ,p_per_information26 IN varchar2 default null
846 ,p_per_information27 IN varchar2 default null
847 ,p_per_information28 IN varchar2 default null
848 ,p_per_information29 IN varchar2 default null
849 ,p_per_information30 IN varchar2 default null
850 ,p_allow_access IN varchar2 default null
851 ,p_start_date IN date default null
852 ,p_effective_start_date OUT NOCOPY date
853 ,p_effective_end_date OUT NOCOPY date
854 ,p_person_id OUT NOCOPY number) IS
855 --
856 l_proc varchar2(72) := g_package||'create_registered_user';
857 l_person_id PER_ALL_PEOPLE_F.PERSON_ID%TYPE;
858 l_date_of_birth per_all_people_f.date_of_birth%type;
859 l_business_group_id per_all_people_f.business_group_id%type;
860 l_person_type_id per_all_people_f.person_type_id%type;
861 l_last_name_phonetic hz_person_profiles.person_last_name_phonetic%type
862 := p_last_name_phonetic;
863 --
864 -- dummy variables
865 --
866 l_object_version_number per_all_people_f.object_version_number%type;
867 l_effective_start_date per_all_people_f.effective_start_date%type;
868 l_effective_end_date per_all_people_f.effective_end_date%type;
869 l_full_name per_all_people_f.full_name%type;
870 l_comment_id per_all_people_f.comment_id%type;
871 l_name_combination_warning boolean;
872 l_orig_hire_warning boolean;
873 l_legislation_code per_business_groups_perf.legislation_code%type;
874 l_ptu_person_type_id number(15);
875 --
876 -- for disabling the descriptive flex field
877 l_add_struct_d hr_dflex_utility.l_ignore_dfcode_varray :=
878 hr_dflex_utility.l_ignore_dfcode_varray();
879 --
880 -- cursor to select the legislation from per_business_groups_perf
881 -- corresponding to the business group
882 --
883 cursor csr_legislation_code(p_business_group_id number) is
884 select legislation_code
885 from per_business_groups_perf
886 where business_group_id = p_business_group_id;
887 --
888 -- cursor to select the person_type_id from hr_organization_inforamtion
889 -- corresponding to the recruiting flexfield on the business group
890 --
891 cursor csr_get_person_type_id(p_business_group_id number) is
892 select org_information8
893 from hr_organization_information
894 where organization_id=p_business_group_id
895 and ORG_INFORMATION_CONTEXT='BG Recruitment';
896 --
897 l_notification_preference_id number;
898 l_search_criteria_id number;
899 --
900 l_start_date date;
901 begin
902 hr_utility.set_location(' Entering: '||l_proc, 10);
903 --
904 -- Issue a savepoint
905 --
906 savepoint CREATE_REGISTERED_USER;
907 --
908 -- Truncate the time portion from all IN date parameters
909 --
910 l_date_of_birth := trunc(p_date_of_birth);
911 --
912 -- set the start date of the person record to two days in the past to allow the person to
913 -- made an applicant today, and for them to be hired today, pushing the apply date one
914 -- day in to the past if neccesary
915 --
916 l_start_date:=trunc(sysdate-2);
917 --
918 -- Call Before Process User Hook
919 --
920 begin
921 IRC_PARTY_BK1.CREATE_REGISTERED_USER_B
922 (p_last_name => p_last_name
923 ,p_first_name => p_first_name
924 ,p_email_address => p_email_address
925 ,p_date_of_birth => l_date_of_birth
926 ,p_title => p_title
927 ,p_gender => p_gender
928 ,p_marital_status => p_marital_status
929 ,p_previous_last_name => p_previous_last_name
930 ,p_middle_name => p_middle_name
931 ,p_name_suffix => p_name_suffix
932 ,p_known_as => p_known_as
933 ,p_first_name_phonetic => p_first_name_phonetic
934 ,p_last_name_phonetic => p_last_name_phonetic
935 ,p_attribute_category => p_attribute_category
936 ,p_attribute1 => p_attribute1
937 ,p_attribute2 => p_attribute2
938 ,p_attribute3 => p_attribute3
939 ,p_attribute4 => p_attribute4
940 ,p_attribute5 => p_attribute5
941 ,p_attribute6 => p_attribute6
942 ,p_attribute7 => p_attribute7
943 ,p_attribute8 => p_attribute8
944 ,p_attribute9 => p_attribute9
945 ,p_attribute10 => p_attribute10
946 ,p_attribute11 => p_attribute11
947 ,p_attribute12 => p_attribute12
948 ,p_attribute13 => p_attribute13
949 ,p_attribute14 => p_attribute14
950 ,p_attribute15 => p_attribute15
951 ,p_attribute16 => p_attribute16
952 ,p_attribute17 => p_attribute17
953 ,p_attribute18 => p_attribute18
954 ,p_attribute19 => p_attribute19
955 ,p_attribute20 => p_attribute20
956 ,p_attribute21 => p_attribute21
957 ,p_attribute22 => p_attribute22
958 ,p_attribute23 => p_attribute23
959 ,p_attribute24 => p_attribute24
960 ,p_attribute25 => p_attribute25
961 ,p_attribute26 => p_attribute26
962 ,p_attribute27 => p_attribute27
963 ,p_attribute28 => p_attribute28
964 ,p_attribute29 => p_attribute29
965 ,p_attribute30 => p_attribute30
966 ,p_per_information_category => p_per_information_category
967 ,p_per_information1 => p_per_information1
968 ,p_per_information2 => p_per_information2
969 ,p_per_information3 => p_per_information3
970 ,p_per_information4 => p_per_information4
971 ,p_per_information5 => p_per_information5
972 ,p_per_information6 => p_per_information6
973 ,p_per_information7 => p_per_information7
974 ,p_per_information8 => p_per_information8
975 ,p_per_information9 => p_per_information9
976 ,p_per_information10 => p_per_information10
977 ,p_per_information11 => p_per_information11
978 ,p_per_information12 => p_per_information12
979 ,p_per_information13 => p_per_information13
980 ,p_per_information14 => p_per_information14
981 ,p_per_information15 => p_per_information15
982 ,p_per_information16 => p_per_information16
983 ,p_per_information17 => p_per_information17
984 ,p_per_information18 => p_per_information18
985 ,p_per_information19 => p_per_information19
986 ,p_per_information20 => p_per_information20
987 ,p_per_information21 => p_per_information21
988 ,p_per_information22 => p_per_information22
989 ,p_per_information23 => p_per_information23
990 ,p_per_information24 => p_per_information24
991 ,p_per_information25 => p_per_information25
992 ,p_per_information26 => p_per_information26
993 ,p_per_information27 => p_per_information27
994 ,p_per_information28 => p_per_information28
995 ,p_per_information29 => p_per_information29
996 ,p_per_information30 => p_per_information30
997 ,p_allow_access => p_allow_access
998 ,p_start_date => p_start_date
999 );
1000 exception
1001 when hr_api.cannot_find_prog_unit then
1002 hr_api.cannot_find_prog_unit_error
1003 (p_module_name => 'CREATE_REGISTERED_USER'
1004 ,p_hook_type => 'BP'
1005 );
1006 end;
1007 --
1008 hr_utility.set_location(l_proc, 10);
1009 --
1010 -- Process Logic
1011 -- code for disabling the descriptive flex field
1012 --
1013 l_add_struct_d.extend(1);
1014 l_add_struct_d(l_add_struct_d.count) := 'IRC_SEARCH_CRITERIA';
1015 l_add_struct_d.extend(1);
1016 l_add_struct_d(l_add_struct_d.count) := 'IRC_SEARCH_CRITERIA_DDF';
1017 l_add_struct_d.extend(1);
1018 l_add_struct_d(l_add_struct_d.count) := 'IRC_NOTIFICATION_PREFERENCES';
1019 l_add_struct_d.extend(1);
1020 l_add_struct_d(l_add_struct_d.count) := 'PER_PEOPLE';
1021 l_add_struct_d.extend(1);
1022 l_add_struct_d(l_add_struct_d.count) := 'Person Developer DF';
1023 --
1024 hr_dflex_utility.create_ignore_df_validation(p_rec => l_add_struct_d);
1025 --
1026 hr_utility.set_location(l_proc, 20);
1027 --
1028 --
1029 -- Get the business group id from profile
1030 --
1031 l_business_group_id := fnd_profile.value('IRC_REGISTRATION_BG_ID');
1032 --
1033 if l_business_group_id is null then
1034 fnd_message.set_name('PER','IRC_412155_REG_BG_NOT_SET');
1035 fnd_message.raise_error;
1036 end if;
1037 --
1038 hr_utility.set_location(l_proc, 30);
1039 --
1040 IRC_PARTY_API.CREATE_CANDIDATE_INTERNAL
1041 (p_business_group_id => l_business_group_id
1042 ,p_last_name => p_last_name
1043 ,p_first_name => p_first_name
1044 ,p_email_address => p_email_address
1045 ,p_date_of_birth => p_date_of_birth
1046 ,p_title => p_title
1047 ,p_gender => p_gender
1048 ,p_marital_status => p_marital_status
1049 ,p_previous_last_name => p_previous_last_name
1050 ,p_middle_name => p_middle_name
1051 ,p_name_suffix => p_name_suffix
1052 ,p_known_as => p_known_as
1053 ,p_first_name_phonetic => p_first_name_phonetic
1054 ,p_last_name_phonetic => p_last_name_phonetic
1055 ,p_attribute_category => p_attribute_category
1056 ,p_attribute1 => p_attribute1
1057 ,p_attribute2 => p_attribute2
1058 ,p_attribute3 => p_attribute3
1059 ,p_attribute4 => p_attribute4
1060 ,p_attribute5 => p_attribute5
1061 ,p_attribute6 => p_attribute6
1062 ,p_attribute7 => p_attribute7
1063 ,p_attribute8 => p_attribute8
1064 ,p_attribute9 => p_attribute9
1065 ,p_attribute10 => p_attribute10
1066 ,p_attribute11 => p_attribute11
1067 ,p_attribute12 => p_attribute12
1068 ,p_attribute13 => p_attribute13
1069 ,p_attribute14 => p_attribute14
1070 ,p_attribute15 => p_attribute15
1071 ,p_attribute16 => p_attribute16
1072 ,p_attribute17 => p_attribute17
1073 ,p_attribute18 => p_attribute18
1074 ,p_attribute19 => p_attribute19
1075 ,p_attribute20 => p_attribute20
1076 ,p_attribute21 => p_attribute21
1077 ,p_attribute22 => p_attribute22
1078 ,p_attribute23 => p_attribute23
1079 ,p_attribute24 => p_attribute24
1080 ,p_attribute25 => p_attribute25
1081 ,p_attribute26 => p_attribute26
1082 ,p_attribute27 => p_attribute27
1083 ,p_attribute28 => p_attribute28
1084 ,p_attribute29 => p_attribute29
1085 ,p_attribute30 => p_attribute30
1086 ,p_per_information_category => p_per_information_category
1087 ,p_per_information1 => p_per_information1
1088 ,p_per_information2 => p_per_information2
1089 ,p_per_information3 => p_per_information3
1090 ,p_per_information4 => p_per_information4
1091 ,p_per_information5 => p_per_information5
1092 ,p_per_information6 => p_per_information6
1093 ,p_per_information7 => p_per_information7
1094 ,p_per_information8 => p_per_information8
1095 ,p_per_information9 => p_per_information9
1096 ,p_per_information10 => p_per_information10
1097 ,p_per_information11 => p_per_information11
1098 ,p_per_information12 => p_per_information12
1099 ,p_per_information13 => p_per_information13
1100 ,p_per_information14 => p_per_information14
1101 ,p_per_information15 => p_per_information15
1102 ,p_per_information16 => p_per_information16
1103 ,p_per_information17 => p_per_information17
1104 ,p_per_information18 => p_per_information18
1105 ,p_per_information19 => p_per_information19
1106 ,p_per_information20 => p_per_information20
1107 ,p_per_information21 => p_per_information21
1108 ,p_per_information22 => p_per_information22
1109 ,p_per_information23 => p_per_information23
1110 ,p_per_information24 => p_per_information24
1111 ,p_per_information25 => p_per_information25
1112 ,p_per_information26 => p_per_information26
1113 ,p_per_information27 => p_per_information27
1114 ,p_per_information28 => p_per_information28
1115 ,p_per_information29 => p_per_information29
1116 ,p_per_information30 => p_per_information30
1117 ,p_allow_access => p_allow_access
1118 ,p_start_date => p_start_date
1119 ,p_effective_start_date => l_effective_start_date
1120 ,p_effective_end_date => l_effective_end_date
1121 ,p_person_id => l_person_id
1122 );
1123 --
1124 hr_utility.set_location(l_proc, 40);
1125 --
1126 -- create notification preferences
1127 --
1128 irc_notification_prefs_api.create_notification_prefs
1129 (p_validate=>p_validate
1130 ,p_person_id =>l_person_id
1131 ,p_effective_date=>trunc(sysdate)
1132 ,p_notification_preference_id=>l_notification_preference_id
1133 ,p_object_version_number =>l_object_version_number
1134 ,p_allow_access => p_allow_access);
1135 --
1136 --
1137 -- create a work preference row
1138 --
1139 irc_search_criteria_api.create_work_choices
1140 (p_validate=>p_validate
1141 ,p_effective_date=>trunc(sysdate)
1142 ,p_person_id =>l_person_id
1143 ,p_employee=>'Y'
1144 ,p_contractor=>'Y'
1145 ,p_object_version_number=>l_object_version_number
1146 ,p_search_criteria_id=>l_search_criteria_id);
1147 --
1148 -- Call After Process User Hook
1149 --
1150 begin
1151 IRC_PARTY_BK1.CREATE_REGISTERED_USER_A
1152 (
1153 p_last_name => p_last_name
1154 ,p_first_name => p_first_name
1155 ,p_email_address => p_email_address
1156 ,p_date_of_birth => l_date_of_birth
1157 ,p_title => p_title
1158 ,p_gender => p_gender
1159 ,p_marital_status => p_marital_status
1160 ,p_previous_last_name => p_previous_last_name
1161 ,p_middle_name => p_middle_name
1162 ,p_name_suffix => p_name_suffix
1163 ,p_known_as => p_known_as
1164 ,p_first_name_phonetic => p_first_name_phonetic
1165 ,p_last_name_phonetic => p_last_name_phonetic
1166 ,p_attribute_category => p_attribute_category
1167 ,p_attribute1 => p_attribute1
1168 ,p_attribute2 => p_attribute2
1169 ,p_attribute3 => p_attribute3
1170 ,p_attribute4 => p_attribute4
1171 ,p_attribute5 => p_attribute5
1172 ,p_attribute6 => p_attribute6
1173 ,p_attribute7 => p_attribute7
1174 ,p_attribute8 => p_attribute8
1175 ,p_attribute9 => p_attribute9
1176 ,p_attribute10 => p_attribute10
1177 ,p_attribute11 => p_attribute11
1178 ,p_attribute12 => p_attribute12
1179 ,p_attribute13 => p_attribute13
1180 ,p_attribute14 => p_attribute14
1181 ,p_attribute15 => p_attribute15
1182 ,p_attribute16 => p_attribute16
1183 ,p_attribute17 => p_attribute17
1184 ,p_attribute18 => p_attribute18
1185 ,p_attribute19 => p_attribute19
1186 ,p_attribute20 => p_attribute20
1187 ,p_attribute21 => p_attribute21
1188 ,p_attribute22 => p_attribute22
1189 ,p_attribute23 => p_attribute23
1190 ,p_attribute24 => p_attribute24
1191 ,p_attribute25 => p_attribute25
1192 ,p_attribute26 => p_attribute26
1193 ,p_attribute27 => p_attribute27
1194 ,p_attribute28 => p_attribute28
1195 ,p_attribute29 => p_attribute29
1196 ,p_attribute30 => p_attribute30
1197 ,p_per_information_category => p_per_information_category
1198 ,p_per_information1 => p_per_information1
1199 ,p_per_information2 => p_per_information2
1200 ,p_per_information3 => p_per_information3
1201 ,p_per_information4 => p_per_information4
1202 ,p_per_information5 => p_per_information5
1203 ,p_per_information6 => p_per_information6
1204 ,p_per_information7 => p_per_information7
1205 ,p_per_information8 => p_per_information8
1206 ,p_per_information9 => p_per_information9
1207 ,p_per_information10 => p_per_information10
1208 ,p_per_information11 => p_per_information11
1209 ,p_per_information12 => p_per_information12
1210 ,p_per_information13 => p_per_information13
1211 ,p_per_information14 => p_per_information14
1212 ,p_per_information15 => p_per_information15
1213 ,p_per_information16 => p_per_information16
1214 ,p_per_information17 => p_per_information17
1215 ,p_per_information18 => p_per_information18
1216 ,p_per_information19 => p_per_information19
1217 ,p_per_information20 => p_per_information20
1218 ,p_per_information21 => p_per_information21
1219 ,p_per_information22 => p_per_information22
1220 ,p_per_information23 => p_per_information23
1221 ,p_per_information24 => p_per_information24
1222 ,p_per_information25 => p_per_information25
1223 ,p_per_information26 => p_per_information26
1224 ,p_per_information27 => p_per_information27
1225 ,p_per_information28 => p_per_information28
1226 ,p_per_information29 => p_per_information29
1227 ,p_per_information30 => p_per_information30
1228 ,p_person_id => l_person_id
1229 ,p_effective_start_date => l_effective_start_date
1230 ,p_effective_end_date => l_effective_end_date
1231 ,p_allow_access => p_allow_access
1232 ,p_start_date => p_start_date
1233 );
1234 exception
1235 when hr_api.cannot_find_prog_unit then
1236 hr_api.cannot_find_prog_unit_error
1237 (p_module_name => 'CREATE_REGISTERED_USER'
1238 ,p_hook_type => 'AP'
1239 );
1240 end;
1241 --
1242 -- When IN validation only mode raise the Validate_Enabled exception
1243 --
1244 if p_validate then
1245 raise hr_api.validate_enabled;
1246 end if;
1247 --
1248 -- Set all output arguments
1249 --
1250 p_person_id := l_person_id;
1251 p_effective_start_date := l_effective_start_date;
1252 p_effective_end_date := l_effective_end_date;
1253 --
1254 hr_utility.set_location(' Leaving:'||l_proc, 70);
1255 --
1256 exception
1257 when hr_Api.validate_enabled then
1258 --
1259 -- As the Validate_Enabled exception has been raised
1260 -- we must rollback to the savepoint
1261 --
1262 rollback to CREATE_REGISTERED_USER;
1263 --
1264 -- Only set output warning arguments
1265 -- (Any key or derived arguments must be set to null
1266 -- when validation only mode is beINg used.)
1267 --
1268 p_person_id := null;
1269 p_effective_start_date := null;
1270 p_effective_start_date := null;
1271 hr_utility.set_location(' Leaving:'||l_proc, 80);
1272 when others then
1273 --
1274 -- A validation or unexpected error has occured
1275 --
1276 rollback to CREATE_REGISTERED_USER;
1277 --
1278 p_person_id := null;
1279 p_effective_start_date := null;
1280 p_effective_start_date := null;
1281 --
1282 hr_utility.set_location(' Leaving:'||l_proc, 90);
1283 raise;
1284 end create_registered_user;
1285 --
1286 -- -------------------------------------------------------------------------
1287 -- |-----------------------< update_registered_user >----------------------|
1288 -- -------------------------------------------------------------------------
1289 --
1290 procedure update_registered_user
1291 (p_validate IN boolean default false
1292 ,p_effective_date IN date
1293 ,p_person_id IN number
1294 ,p_first_name IN varchar2 default hr_api.g_varchar2
1295 ,p_last_name IN varchar2 default hr_api.g_varchar2
1296 ,p_date_of_birth IN date default hr_api.g_date
1297 ,p_title IN varchar2 default hr_api.g_varchar2
1298 ,p_gender IN varchar2 default hr_api.g_varchar2
1299 ,p_marital_status IN varchar2 default hr_api.g_varchar2
1300 ,p_previous_last_name IN varchar2 default hr_api.g_varchar2
1301 ,p_middle_name IN varchar2 default hr_api.g_varchar2
1302 ,p_name_suffix IN varchar2 default hr_api.g_varchar2
1303 ,p_known_as IN varchar2 default hr_api.g_varchar2
1304 ,p_first_name_phonetic IN varchar2 default hr_api.g_varchar2
1305 ,p_last_name_phonetic IN varchar2 default hr_api.g_varchar2
1306 ,p_attribute_category IN varchar2 default hr_api.g_varchar2
1307 ,p_attribute1 IN varchar2 default hr_api.g_varchar2
1308 ,p_attribute2 IN varchar2 default hr_api.g_varchar2
1309 ,p_attribute3 IN varchar2 default hr_api.g_varchar2
1310 ,p_attribute4 IN varchar2 default hr_api.g_varchar2
1311 ,p_attribute5 IN varchar2 default hr_api.g_varchar2
1312 ,p_attribute6 IN varchar2 default hr_api.g_varchar2
1313 ,p_attribute7 IN varchar2 default hr_api.g_varchar2
1314 ,p_attribute8 IN varchar2 default hr_api.g_varchar2
1315 ,p_attribute9 IN varchar2 default hr_api.g_varchar2
1316 ,p_attribute10 IN varchar2 default hr_api.g_varchar2
1317 ,p_attribute11 IN varchar2 default hr_api.g_varchar2
1318 ,p_attribute12 IN varchar2 default hr_api.g_varchar2
1319 ,p_attribute13 IN varchar2 default hr_api.g_varchar2
1320 ,p_attribute14 IN varchar2 default hr_api.g_varchar2
1321 ,p_attribute15 IN varchar2 default hr_api.g_varchar2
1322 ,p_attribute16 IN varchar2 default hr_api.g_varchar2
1323 ,p_attribute17 IN varchar2 default hr_api.g_varchar2
1324 ,p_attribute18 IN varchar2 default hr_api.g_varchar2
1325 ,p_attribute19 IN varchar2 default hr_api.g_varchar2
1326 ,p_attribute20 IN varchar2 default hr_api.g_varchar2
1327 ,p_attribute21 IN varchar2 default hr_api.g_varchar2
1328 ,p_attribute22 IN varchar2 default hr_api.g_varchar2
1329 ,p_attribute23 IN varchar2 default hr_api.g_varchar2
1330 ,p_attribute24 IN varchar2 default hr_api.g_varchar2
1331 ,p_attribute25 IN varchar2 default hr_api.g_varchar2
1332 ,p_attribute26 IN varchar2 default hr_api.g_varchar2
1333 ,p_attribute27 IN varchar2 default hr_api.g_varchar2
1334 ,p_attribute28 IN varchar2 default hr_api.g_varchar2
1335 ,p_attribute29 IN varchar2 default hr_api.g_varchar2
1336 ,p_attribute30 IN varchar2 default hr_api.g_varchar2
1337 ,p_per_information_category IN varchar2 default hr_api.g_varchar2
1338 ,p_per_information1 IN varchar2 default hr_api.g_varchar2
1339 ,p_per_information2 IN varchar2 default hr_api.g_varchar2
1340 ,p_per_information3 IN varchar2 default hr_api.g_varchar2
1341 ,p_per_information4 IN varchar2 default hr_api.g_varchar2
1342 ,p_per_information5 IN varchar2 default hr_api.g_varchar2
1343 ,p_per_information6 IN varchar2 default hr_api.g_varchar2
1344 ,p_per_information7 IN varchar2 default hr_api.g_varchar2
1345 ,p_per_information8 IN varchar2 default hr_api.g_varchar2
1346 ,p_per_information9 IN varchar2 default hr_api.g_varchar2
1347 ,p_per_information10 IN varchar2 default hr_api.g_varchar2
1348 ,p_per_information11 IN varchar2 default hr_api.g_varchar2
1349 ,p_per_information12 IN varchar2 default hr_api.g_varchar2
1350 ,p_per_information13 IN varchar2 default hr_api.g_varchar2
1351 ,p_per_information14 IN varchar2 default hr_api.g_varchar2
1352 ,p_per_information15 IN varchar2 default hr_api.g_varchar2
1353 ,p_per_information16 IN varchar2 default hr_api.g_varchar2
1354 ,p_per_information17 IN varchar2 default hr_api.g_varchar2
1355 ,p_per_information18 IN varchar2 default hr_api.g_varchar2
1356 ,p_per_information19 IN varchar2 default hr_api.g_varchar2
1357 ,p_per_information20 IN varchar2 default hr_api.g_varchar2
1358 ,p_per_information21 IN varchar2 default hr_api.g_varchar2
1359 ,p_per_information22 IN varchar2 default hr_api.g_varchar2
1360 ,p_per_information23 IN varchar2 default hr_api.g_varchar2
1361 ,p_per_information24 IN varchar2 default hr_api.g_varchar2
1362 ,p_per_information25 IN varchar2 default hr_api.g_varchar2
1363 ,p_per_information26 IN varchar2 default hr_api.g_varchar2
1364 ,p_per_information27 IN varchar2 default hr_api.g_varchar2
1365 ,p_per_information28 IN varchar2 default hr_api.g_varchar2
1366 ,p_per_information29 IN varchar2 default hr_api.g_varchar2
1367 ,p_per_information30 IN varchar2 default hr_api.g_varchar2
1368 ) IS
1369 --
1370 l_proc varchar2(72) := g_package||'update_registered_user';
1371 l_object_version_number per_all_people_f.object_version_number%TYPE;
1372 l_employee_number per_all_people_f.employee_number%TYPE;
1373 l_effective_date date;
1374 l_legislation_code per_business_groups.legislation_code%type;
1375 -- sex is defaulted to null - it is set to the value of sex
1376 -- on per_all_people_f if p_gender exists in hr_lookups
1377 l_sex per_all_people_f.sex%TYPE := hr_api.g_varchar2;
1378 l_last_name_phonetic hz_person_profiles.person_last_name_phonetic%type
1379 := p_last_name_phonetic;
1380 --
1381 -- dummy variables
1382 --
1383 l_profile_id number;
1384 l_effective_start_date date;
1385 l_effective_end_date date;
1386 l_full_name per_all_people_f.full_name%type;
1387 l_comment_id number;
1388 l_name_combination_warning boolean;
1389 l_assign_payroll_warning boolean;
1390 l_orig_hire_warning boolean;
1391 l_date_of_birth date;
1392 l_marital_status hz_person_profiles.marital_status%type;
1393 --
1394 -- for disabling the descriptive flex field
1395 l_add_struct_d hr_dflex_utility.l_ignore_dfcode_varray :=
1396 hr_dflex_utility.l_ignore_dfcode_varray();
1397 -- for disabling the key flex field
1398 l_add_struct_k hr_kflex_utility.l_ignore_kfcode_varray :=
1399 hr_kflex_utility.l_ignore_kfcode_varray();
1400 --
1401 --
1402 -- cursor to select entries IN per_all_people_f
1403 -- relating to registered user
1404 --
1405 cursor csr_person_id(p_person_id number,p_effective_date date) is
1406 select effective_start_date,object_version_number,employee_number
1407 from per_all_people_f
1408 where person_id = p_person_id
1409 and l_effective_date between effective_start_date and effective_end_date;
1410 --
1411 begin
1412 hr_utility.set_location(' Entering: ' || l_proc, 10);
1413 --
1414 -- Issue a savepoint
1415 --
1416 savepoint UPDATE_REGISTERED_USER;
1417 --
1418 l_date_of_birth := trunc(p_date_of_birth);
1419 l_effective_date := trunc(p_effective_date);
1420 l_marital_status := p_marital_status;
1421 --
1422 --
1423 -- Call Before Process User Hook
1424 --
1425 begin
1426 irc_party_bk2.update_registered_user_b
1427 (
1428 p_effective_date => l_effective_date
1429 ,p_person_id => p_person_id
1430 ,p_first_name => p_first_name
1431 ,p_last_name => p_last_name
1432 ,p_date_of_birth => l_date_of_birth
1433 ,p_title => p_title
1434 ,p_gender => p_gender
1435 ,p_marital_status => p_marital_status
1436 ,p_previous_last_name => p_previous_last_name
1437 ,p_middle_name => p_middle_name
1438 ,p_name_suffix => p_name_suffix
1439 ,p_known_as => p_known_as
1440 ,p_first_name_phonetic => p_first_name_phonetic
1441 ,p_last_name_phonetic => p_last_name_phonetic
1442 ,p_attribute_category => p_attribute_category
1443 ,p_attribute1 => p_attribute1
1444 ,p_attribute2 => p_attribute2
1445 ,p_attribute3 => p_attribute3
1446 ,p_attribute4 => p_attribute4
1447 ,p_attribute5 => p_attribute5
1448 ,p_attribute6 => p_attribute6
1449 ,p_attribute7 => p_attribute7
1450 ,p_attribute8 => p_attribute8
1451 ,p_attribute9 => p_attribute9
1452 ,p_attribute10 => p_attribute10
1453 ,p_attribute11 => p_attribute11
1454 ,p_attribute12 => p_attribute12
1455 ,p_attribute13 => p_attribute13
1456 ,p_attribute14 => p_attribute14
1457 ,p_attribute15 => p_attribute15
1458 ,p_attribute16 => p_attribute16
1459 ,p_attribute17 => p_attribute17
1460 ,p_attribute18 => p_attribute18
1461 ,p_attribute19 => p_attribute19
1462 ,p_attribute20 => p_attribute20
1463 ,p_attribute21 => p_attribute21
1464 ,p_attribute22 => p_attribute22
1465 ,p_attribute23 => p_attribute23
1466 ,p_attribute24 => p_attribute24
1467 ,p_attribute25 => p_attribute25
1468 ,p_attribute26 => p_attribute26
1469 ,p_attribute27 => p_attribute27
1470 ,p_attribute28 => p_attribute28
1471 ,p_attribute29 => p_attribute29
1472 ,p_attribute30 => p_attribute30
1473 ,p_per_information_category => p_per_information_category
1474 ,p_per_information1 => p_per_information1
1475 ,p_per_information2 => p_per_information2
1476 ,p_per_information3 => p_per_information3
1477 ,p_per_information4 => p_per_information4
1478 ,p_per_information5 => p_per_information5
1479 ,p_per_information6 => p_per_information6
1480 ,p_per_information7 => p_per_information7
1481 ,p_per_information8 => p_per_information8
1482 ,p_per_information9 => p_per_information9
1483 ,p_per_information10 => p_per_information10
1484 ,p_per_information11 => p_per_information11
1485 ,p_per_information12 => p_per_information12
1486 ,p_per_information13 => p_per_information13
1487 ,p_per_information14 => p_per_information14
1488 ,p_per_information15 => p_per_information15
1489 ,p_per_information16 => p_per_information16
1490 ,p_per_information17 => p_per_information17
1491 ,p_per_information18 => p_per_information18
1492 ,p_per_information19 => p_per_information19
1493 ,p_per_information20 => p_per_information20
1494 ,p_per_information21 => p_per_information21
1495 ,p_per_information22 => p_per_information22
1496 ,p_per_information23 => p_per_information23
1497 ,p_per_information24 => p_per_information24
1498 ,p_per_information25 => p_per_information25
1499 ,p_per_information26 => p_per_information26
1500 ,p_per_information27 => p_per_information27
1501 ,p_per_information28 => p_per_information28
1502 ,p_per_information29 => p_per_information29
1503 ,p_per_information30 => p_per_information30
1504 );
1505 exception
1506 when hr_api.cannot_find_prog_unit then
1507 hr_api.cannot_find_prog_unit_error
1508 (p_module_name => 'UPDATE_REGISTERED_USER'
1509 ,p_hook_type => 'BP'
1510 );
1511 end;
1512 --
1513 -- Process Logic
1514 --
1515 --
1516 -- Set profile option
1517 fnd_profile.put('HZ_CREATED_BY_MODULE','HR API');
1518 hr_utility.set_location(l_proc, 40);
1519 --
1520 -- Added for turn off key flex field validation
1521 --
1522 l_add_struct_k.extend(1);
1523 l_add_struct_k(l_add_struct_k.count) := 'GRP';
1524 l_add_struct_k.extend(1);
1525 l_add_struct_k(l_add_struct_k.count) := 'CAGR';
1526 l_add_struct_k.extend(1);
1527 l_add_struct_k(l_add_struct_k.count) := 'SCL';
1528 --
1529 hr_kflex_utility.create_ignore_kf_validation(p_rec => l_add_struct_k);
1530 --
1531 -- code for disabling the descriptive flex field
1532 --
1533 l_add_struct_d.extend(1);
1534 l_add_struct_d(l_add_struct_d.count) := 'PER_ASSIGNMENTS';
1535 l_add_struct_d.extend(1);
1536 l_add_struct_d(l_add_struct_d.count) := 'Person Developer DF';
1537 l_add_struct_d.extend(1);
1538 l_add_struct_d(l_add_struct_d.count) := 'PER_PEOPLE';
1539 --
1540 hr_dflex_utility.create_ignore_df_validation(p_rec => l_add_struct_d);
1541
1542 open csr_person_id(p_person_id,p_effective_date);
1543 fetch csr_person_id into l_effective_start_date,l_object_version_number,l_employee_number;
1544 close csr_person_id;
1545 --
1546 l_legislation_code := per_per_bus.return_legislation_code(p_person_id);
1547 --
1548 if (l_legislation_code = 'JP') then
1549
1550 hr_person_api.update_person
1551 (p_validate => false
1552 ,p_effective_date => l_effective_date
1553 ,p_datetrack_update_mode => 'CORRECTION'
1554 ,p_person_id => p_person_id
1555 ,p_employee_number => l_employee_number
1556 ,p_object_version_number => l_object_version_number
1557 ,p_last_name => p_last_name
1558 ,p_previous_last_name => p_previous_last_name
1559 ,p_date_of_birth => l_date_of_birth
1560 ,p_first_name => p_first_name
1561 ,p_known_as => p_known_as
1562 ,p_sex => p_gender
1563 ,p_marital_status => l_marital_status
1564 ,p_middle_names => p_middle_name
1565 ,p_suffix => p_name_suffix
1566 ,p_attribute_category => p_attribute_category
1567 ,p_attribute1 => p_attribute1
1568 ,p_attribute2 => p_attribute2
1569 ,p_attribute3 => p_attribute3
1570 ,p_attribute4 => p_attribute4
1571 ,p_attribute5 => p_attribute5
1572 ,p_attribute6 => p_attribute6
1573 ,p_attribute7 => p_attribute7
1574 ,p_attribute8 => p_attribute8
1575 ,p_attribute9 => p_attribute9
1576 ,p_attribute10 => p_attribute10
1577 ,p_attribute11 => p_attribute11
1578 ,p_attribute12 => p_attribute12
1579 ,p_attribute13 => p_attribute13
1580 ,p_attribute14 => p_attribute14
1581 ,p_attribute15 => p_attribute15
1582 ,p_attribute16 => p_attribute16
1583 ,p_attribute17 => p_attribute17
1584 ,p_attribute18 => p_attribute18
1585 ,p_attribute19 => p_attribute19
1586 ,p_attribute20 => p_attribute20
1587 ,p_attribute21 => p_attribute21
1588 ,p_attribute22 => p_attribute22
1589 ,p_attribute23 => p_attribute23
1590 ,p_attribute24 => p_attribute24
1591 ,p_attribute25 => p_attribute25
1592 ,p_attribute26 => p_attribute26
1593 ,p_attribute27 => p_attribute27
1594 ,p_attribute28 => p_attribute28
1595 ,p_attribute29 => p_attribute29
1596 ,p_attribute30 => p_attribute30
1597 ,p_per_information_category => p_per_information_category
1598 ,p_per_information1 => p_per_information1
1599 ,p_per_information2 => p_per_information2
1600 ,p_per_information3 => p_per_information3
1601 ,p_per_information4 => p_per_information4
1602 ,p_per_information5 => p_per_information5
1603 ,p_per_information6 => p_per_information6
1604 ,p_per_information7 => p_per_information7
1605 ,p_per_information8 => p_per_information8
1606 ,p_per_information9 => p_per_information9
1607 ,p_per_information10 => p_per_information10
1608 ,p_per_information11 => p_per_information11
1609 ,p_per_information12 => p_per_information12
1610 ,p_per_information13 => p_per_information13
1611 ,p_per_information14 => p_per_information14
1612 ,p_per_information15 => p_per_information15
1613 ,p_per_information16 => p_per_information16
1614 ,p_per_information17 => p_per_information17
1615 ,p_per_information18 => p_per_information18
1616 ,p_per_information19 => p_per_information19
1617 ,p_per_information20 => p_per_information20
1618 ,p_per_information21 => p_per_information21
1619 ,p_per_information22 => p_per_information22
1620 ,p_per_information23 => p_per_information23
1621 ,p_per_information24 => p_per_information24
1622 ,p_per_information25 => p_per_information25
1623 ,p_per_information26 => p_per_information26
1624 ,p_per_information27 => p_per_information27
1625 ,p_per_information28 => p_per_information28
1626 ,p_per_information29 => p_per_information29
1627 ,p_per_information30 => p_per_information30
1628 ,p_effective_start_date => l_effective_start_date
1629 ,p_effective_end_date => l_effective_end_date
1630 ,p_full_name => l_full_name
1631 ,p_comment_id => l_comment_id
1632 ,p_name_combination_warning => l_name_combination_warning
1633 ,p_assign_payroll_warning => l_assign_payroll_warning
1634 ,p_orig_hire_warning => l_orig_hire_warning
1635 );
1636 elsif (l_legislation_code = 'KR') then
1637 hr_person_api.update_person
1638 (p_validate => false
1639 ,p_effective_date => l_effective_date
1640 ,p_datetrack_update_mode => 'CORRECTION'
1641 ,p_person_id => p_person_id
1642 ,p_employee_number => l_employee_number
1643 ,p_object_version_number => l_object_version_number
1644 ,p_last_name => p_last_name
1645 ,p_previous_last_name => p_previous_last_name
1646 ,p_date_of_birth => l_date_of_birth
1647 ,p_first_name => p_first_name
1648 ,p_known_as => p_known_as
1649 ,p_sex => p_gender
1650 ,p_marital_status => l_marital_status
1651 ,p_middle_names => p_middle_name
1652 ,p_suffix => p_name_suffix
1653 ,p_attribute_category => p_attribute_category
1654 ,p_attribute1 => p_attribute1
1655 ,p_attribute2 => p_attribute2
1656 ,p_attribute3 => p_attribute3
1657 ,p_attribute4 => p_attribute4
1658 ,p_attribute5 => p_attribute5
1659 ,p_attribute6 => p_attribute6
1660 ,p_attribute7 => p_attribute7
1661 ,p_attribute8 => p_attribute8
1662 ,p_attribute9 => p_attribute9
1663 ,p_attribute10 => p_attribute10
1664 ,p_attribute11 => p_attribute11
1665 ,p_attribute12 => p_attribute12
1666 ,p_attribute13 => p_attribute13
1667 ,p_attribute14 => p_attribute14
1668 ,p_attribute15 => p_attribute15
1669 ,p_attribute16 => p_attribute16
1670 ,p_attribute17 => p_attribute17
1671 ,p_attribute18 => p_attribute18
1672 ,p_attribute19 => p_attribute19
1673 ,p_attribute20 => p_attribute20
1674 ,p_attribute21 => p_attribute21
1675 ,p_attribute22 => p_attribute22
1676 ,p_attribute23 => p_attribute23
1677 ,p_attribute24 => p_attribute24
1678 ,p_attribute25 => p_attribute25
1679 ,p_attribute26 => p_attribute26
1680 ,p_attribute27 => p_attribute27
1681 ,p_attribute28 => p_attribute28
1682 ,p_attribute29 => p_attribute29
1683 ,p_attribute30 => p_attribute30
1684 ,p_per_information_category => p_per_information_category
1685 ,p_per_information1 => l_last_name_phonetic
1686 ,p_per_information2 => p_first_name_phonetic
1687 ,p_per_information3 => p_per_information3
1688 ,p_per_information4 => p_per_information4
1689 ,p_per_information5 => p_per_information5
1690 ,p_per_information6 => p_per_information6
1691 ,p_per_information7 => p_per_information7
1692 ,p_per_information8 => p_per_information8
1693 ,p_per_information9 => p_per_information9
1694 ,p_per_information10 => p_per_information10
1695 ,p_per_information11 => p_per_information11
1696 ,p_per_information12 => p_per_information12
1697 ,p_per_information13 => p_per_information13
1698 ,p_per_information14 => p_per_information14
1699 ,p_per_information15 => p_per_information15
1700 ,p_per_information16 => p_per_information16
1701 ,p_per_information17 => p_per_information17
1702 ,p_per_information18 => p_per_information18
1703 ,p_per_information19 => p_per_information19
1704 ,p_per_information20 => p_per_information20
1705 ,p_per_information21 => p_per_information21
1706 ,p_per_information22 => p_per_information22
1707 ,p_per_information23 => p_per_information23
1708 ,p_per_information24 => p_per_information24
1709 ,p_per_information25 => p_per_information25
1710 ,p_per_information26 => p_per_information26
1711 ,p_per_information27 => p_per_information27
1712 ,p_per_information28 => p_per_information28
1713 ,p_per_information29 => p_per_information29
1714 ,p_per_information30 => p_per_information30
1715 ,p_effective_start_date => l_effective_start_date
1716 ,p_effective_end_date => l_effective_end_date
1717 ,p_full_name => l_full_name
1718 ,p_comment_id => l_comment_id
1719 ,p_name_combination_warning => l_name_combination_warning
1720 ,p_assign_payroll_warning => l_assign_payroll_warning
1721 ,p_orig_hire_warning => l_orig_hire_warning
1722 );
1723 else
1724 hr_person_api.update_person
1725 (p_validate => false
1726 ,p_effective_date => l_effective_date
1727 ,p_datetrack_update_mode => 'CORRECTION'
1728 ,p_person_id => p_person_id
1729 ,p_employee_number => l_employee_number
1730 ,p_object_version_number => l_object_version_number
1731 ,p_last_name => p_last_name
1732 ,p_previous_last_name => p_previous_last_name
1733 ,p_date_of_birth => l_date_of_birth
1734 ,p_first_name => p_first_name
1735 ,p_known_as => p_known_as
1736 ,p_sex => p_gender
1737 ,p_marital_status => l_marital_status
1738 ,p_middle_names => p_middle_name
1739 ,p_suffix => p_name_suffix
1740 ,p_attribute_category => p_attribute_category
1741 ,p_attribute1 => p_attribute1
1742 ,p_attribute2 => p_attribute2
1743 ,p_attribute3 => p_attribute3
1744 ,p_attribute4 => p_attribute4
1745 ,p_attribute5 => p_attribute5
1746 ,p_attribute6 => p_attribute6
1747 ,p_attribute7 => p_attribute7
1748 ,p_attribute8 => p_attribute8
1749 ,p_attribute9 => p_attribute9
1750 ,p_attribute10 => p_attribute10
1751 ,p_attribute11 => p_attribute11
1752 ,p_attribute12 => p_attribute12
1753 ,p_attribute13 => p_attribute13
1754 ,p_attribute14 => p_attribute14
1755 ,p_attribute15 => p_attribute15
1756 ,p_attribute16 => p_attribute16
1757 ,p_attribute17 => p_attribute17
1758 ,p_attribute18 => p_attribute18
1759 ,p_attribute19 => p_attribute19
1760 ,p_attribute20 => p_attribute20
1761 ,p_attribute21 => p_attribute21
1762 ,p_attribute22 => p_attribute22
1763 ,p_attribute23 => p_attribute23
1764 ,p_attribute24 => p_attribute24
1765 ,p_attribute25 => p_attribute25
1766 ,p_attribute26 => p_attribute26
1767 ,p_attribute27 => p_attribute27
1768 ,p_attribute28 => p_attribute28
1769 ,p_attribute29 => p_attribute29
1770 ,p_attribute30 => p_attribute30
1771 ,p_per_information_category => p_per_information_category
1772 ,p_per_information1 => p_per_information1
1773 ,p_per_information2 => p_per_information2
1774 ,p_per_information3 => p_per_information3
1775 ,p_per_information4 => p_per_information4
1776 ,p_per_information5 => p_per_information5
1777 ,p_per_information6 => p_per_information6
1778 ,p_per_information7 => p_per_information7
1779 ,p_per_information8 => p_per_information8
1780 ,p_per_information9 => p_per_information9
1781 ,p_per_information10 => p_per_information10
1782 ,p_per_information11 => p_per_information11
1783 ,p_per_information12 => p_per_information12
1784 ,p_per_information13 => p_per_information13
1785 ,p_per_information14 => p_per_information14
1786 ,p_per_information15 => p_per_information15
1787 ,p_per_information16 => p_per_information16
1788 ,p_per_information17 => p_per_information17
1789 ,p_per_information18 => p_per_information18
1790 ,p_per_information19 => p_per_information19
1791 ,p_per_information20 => p_per_information20
1792 ,p_per_information21 => p_per_information21
1793 ,p_per_information22 => p_per_information22
1794 ,p_per_information23 => p_per_information23
1795 ,p_per_information24 => p_per_information24
1796 ,p_per_information25 => p_per_information25
1797 ,p_per_information26 => p_per_information26
1798 ,p_per_information27 => p_per_information27
1799 ,p_per_information28 => p_per_information28
1800 ,p_per_information29 => p_per_information29
1801 ,p_per_information30 => p_per_information30
1802 ,p_effective_start_date => l_effective_start_date
1803 ,p_effective_end_date => l_effective_end_date
1804 ,p_full_name => l_full_name
1805 ,p_comment_id => l_comment_id
1806 ,p_name_combination_warning => l_name_combination_warning
1807 ,p_assign_payroll_warning => l_assign_payroll_warning
1808 ,p_orig_hire_warning => l_orig_hire_warning
1809 );
1810 end if;
1811 hr_utility.set_Location(l_proc, 60);
1812 -- Save person ovn to global
1813 if ( p_person_id = g_person_id ) then
1814 g_ovn_for_person := l_object_version_number;
1815 end if;
1816 --
1817 -- Call After Process User Hook
1818 --
1819 begin
1820 irc_party_bk2.update_registered_user_a
1821 (
1822 p_effective_date => l_effective_date
1823 ,p_person_id => p_person_id
1824 ,p_first_name => p_first_name
1825 ,p_last_name => p_last_name
1826 ,p_date_of_birth => l_date_of_birth
1827 ,p_title => p_title
1828 ,p_gender => p_gender
1829 ,p_marital_status => l_marital_status
1830 ,p_previous_last_name => p_previous_last_name
1831 ,p_middle_name => p_middle_name
1832 ,p_name_suffix => p_name_suffix
1833 ,p_known_as => p_known_as
1834 ,p_first_name_phonetic => p_first_name_phonetic
1835 ,p_last_name_phonetic => p_last_name_phonetic
1836 ,p_attribute_category => p_attribute_category
1837 ,p_attribute1 => p_attribute1
1838 ,p_attribute2 => p_attribute2
1839 ,p_attribute3 => p_attribute3
1840 ,p_attribute4 => p_attribute4
1841 ,p_attribute5 => p_attribute5
1842 ,p_attribute6 => p_attribute6
1843 ,p_attribute7 => p_attribute7
1844 ,p_attribute8 => p_attribute8
1845 ,p_attribute9 => p_attribute9
1846 ,p_attribute10 => p_attribute10
1847 ,p_attribute11 => p_attribute11
1848 ,p_attribute12 => p_attribute12
1849 ,p_attribute13 => p_attribute13
1850 ,p_attribute14 => p_attribute14
1851 ,p_attribute15 => p_attribute15
1852 ,p_attribute16 => p_attribute16
1853 ,p_attribute17 => p_attribute17
1854 ,p_attribute18 => p_attribute18
1855 ,p_attribute19 => p_attribute19
1856 ,p_attribute20 => p_attribute20
1857 ,p_attribute21 => p_attribute21
1858 ,p_attribute22 => p_attribute22
1859 ,p_attribute23 => p_attribute23
1860 ,p_attribute24 => p_attribute24
1861 ,p_attribute25 => p_attribute25
1862 ,p_attribute26 => p_attribute26
1863 ,p_attribute27 => p_attribute27
1864 ,p_attribute28 => p_attribute28
1865 ,p_attribute29 => p_attribute29
1866 ,p_attribute30 => p_attribute30
1867 ,p_per_information_category => p_per_information_category
1868 ,p_per_information1 => p_per_information1
1869 ,p_per_information2 => p_per_information2
1870 ,p_per_information3 => p_per_information3
1871 ,p_per_information4 => p_per_information4
1872 ,p_per_information5 => p_per_information5
1873 ,p_per_information6 => p_per_information6
1874 ,p_per_information7 => p_per_information7
1875 ,p_per_information8 => p_per_information8
1876 ,p_per_information9 => p_per_information9
1877 ,p_per_information10 => p_per_information10
1878 ,p_per_information11 => p_per_information11
1879 ,p_per_information12 => p_per_information12
1880 ,p_per_information13 => p_per_information13
1881 ,p_per_information14 => p_per_information14
1882 ,p_per_information15 => p_per_information15
1883 ,p_per_information16 => p_per_information16
1884 ,p_per_information17 => p_per_information17
1885 ,p_per_information18 => p_per_information18
1886 ,p_per_information19 => p_per_information19
1887 ,p_per_information20 => p_per_information20
1888 ,p_per_information21 => p_per_information21
1889 ,p_per_information22 => p_per_information22
1890 ,p_per_information23 => p_per_information23
1891 ,p_per_information24 => p_per_information24
1892 ,p_per_information25 => p_per_information25
1893 ,p_per_information26 => p_per_information26
1894 ,p_per_information27 => p_per_information27
1895 ,p_per_information28 => p_per_information28
1896 ,p_per_information29 => p_per_information29
1897 ,p_per_information30 => p_per_information30
1898 );
1899 exception
1900 when hr_api.cannot_find_prog_unit then
1901 hr_api.cannot_find_prog_unit_error
1902 (p_module_name => 'UPDATE_REGISTERED_USER'
1903 ,p_hook_type => 'AP'
1904 );
1905 end;
1906 --
1907 -- When IN validation only mode raise the Validate_Enabled exception
1908 --
1909 if p_validate then
1910 raise hr_api.validate_enabled;
1911 end if;
1912 --
1913 -- Set all output arguments
1914 --
1915 --
1916 hr_utility.set_location(' Leaving:'||l_proc, 70);
1917
1918 exception
1919 when hr_api.validate_enabled then
1920 --
1921 -- As the Validate_Enabled exception has been raised
1922 -- we must rollback to the savepoint
1923 --
1924 rollback to UPDATE_REGISTERED_USER;
1925 --
1926 -- Only set output warning arguments
1927 -- (Any key or derived arguments must be set to null
1928 -- when validation only mode is beINg used.)
1929 --
1930 hr_utility.set_location(' Leaving:'||l_proc, 80);
1931 when others then
1932 --
1933 -- A validation or unexpected error has occured
1934 --
1935 rollback to UPDATE_REGISTERED_USER;
1936 hr_utility.set_location(' Leaving:'||l_proc, 90);
1937 raise;
1938
1939 end update_registered_user;
1940 --
1941 -- -------------------------------------------------------------------------
1942 -- |---------------------< chk_agency_application_limit >-------------------|
1943 -- -------------------------------------------------------------------------
1944 --
1945 procedure chk_agency_application_limit
1946 (p_vacancy_id IN number default null
1947 ,p_effective_date IN date) IS
1948 --
1949 cursor csr_application_count(p_vacancy_id number, p_effective_date date) is
1950 select count(*)
1951 from per_all_assignments_f paaf
1952 , IRC_AGENCY_VACANCIES AGV1
1953 ,per_all_people_f per1
1954 ,irc_notification_preferences prefs
1955 where paaf.vacancy_id = p_vacancy_id and paaf.assignment_type = 'A'
1956 and p_effective_date between PAAF.EFFECTIVE_START_DATE
1957 AND PAAF.EFFECTIVE_END_DATE
1958 and paaf.VACANCY_ID = AGV1.VACANCY_ID
1959 and AGV1.AGENCY_ID = FND_PROFILE.VALUE('IRC_AGENCY_NAME')
1960 and per1.person_id=paaf.person_id
1961 and p_effective_date between per1.effective_start_date and per1.effective_end_date
1962 and per1.party_id=prefs.party_id
1963 and prefs.agency_id=agv1.agency_id
1964 and p_effective_date between nvl(agv1.start_date,p_effective_date)
1965 and nvl(agv1.end_date,p_effective_date);
1966 --
1967 cursor csr_application_count_limit(p_vacancy_id number) is
1968 select AGV.MAX_ALLOWED_APPLICANTS
1969 from IRC_AGENCY_VACANCIES AGV
1970 where agv.vacancy_id = p_vacancy_id
1971 and AGV.AGENCY_ID = FND_PROFILE.VALUE('IRC_AGENCY_NAME');
1972 --
1973 l_application_count_limit IRC_AGENCY_VACANCIES.MAX_ALLOWED_APPLICANTS%TYPE;
1974 l_application_count Number;
1975 l_agency_id IRC_AGENCY_VACANCIES.AGENCY_ID%TYPE;
1976 begin
1977 --
1978 -- only check if Agency profile is set
1979 --
1980 if ( FND_PROFILE.VALUE('IRC_AGENCY_NAME') is not null ) then
1981 --
1982 -- get the applicant count limit for the vacancy
1983 --
1984 open csr_application_count_limit(p_vacancy_id);
1985 fetch csr_application_count_limit into l_application_count_limit;
1986 --
1987 if ( csr_application_count_limit%found ) then
1988 if ( l_application_count_limit is null ) then
1989 l_application_count_limit := FND_PROFILE.VALUE('IRC_MAX_APPLICANTS_DFT');
1990 end if;
1991 end if;
1992 close csr_application_count_limit;
1993 --
1994 -- only do check if applicant count limit has been set
1995 --
1996 if ( l_application_count_limit is not null ) then
1997 open csr_application_count(p_vacancy_id, p_effective_date);
1998 fetch csr_application_count into l_application_count;
1999 if ( l_application_count >= l_application_count_limit ) then
2000 fnd_message.set_name('PER','IRC_MAX_APPLICATIONS_LIMIT');
2001 hr_multi_message.add();
2002 hr_multi_message.end_validation_set();
2003 end if;
2004 close csr_application_count;
2005 end if;
2006 end if;
2007 end chk_agency_application_limit;
2008
2009 --
2010 -- -------------------------------------------------------------------------
2011 -- |---------------------< registered_user_application >-------------------|
2012 -- -------------------------------------------------------------------------
2013 --
2014 procedure registered_user_application
2015 (p_validate IN boolean default false
2016 ,p_effective_date IN date
2017 ,p_recruitment_person_id IN number
2018 ,p_person_id IN number
2019 ,p_assignment_id IN number
2020 ,p_application_received_date IN date default null
2021 ,p_vacancy_id IN number default null
2022 ,p_posting_content_id IN number default null
2023 ,p_per_information4 IN per_all_people_f.per_information4%type default null
2024 ,p_per_object_version_number OUT NOCOPY number
2025 ,p_asg_object_version_number OUT NOCOPY number
2026 ,p_applicant_number OUT NOCOPY varchar2) IS
2027 --
2028 l_proc varchar2(72) := g_package||'registered_user_application';
2029 l_per_object_version_number per_all_people_f.object_version_number%TYPE;
2030 l_asg_object_version_number per_all_assignments_f.object_version_number%TYPE;
2031 l_person_id per_all_people_f.person_id%TYPE;
2032 l_party_id per_all_people_f.party_id%TYPE;
2033 l_rec_person_id per_all_people_f.person_id%TYPE;
2034 l_assignment_id per_all_assignments_f.assignment_id%TYPE;
2035 l_effective_date date;
2036 l_application_received_date date;
2037 l_party_last_update_date date;
2038 l_return_status varchar2(10);
2039 l_applicant_number per_all_people_f.applicant_number%type;
2040 l_person_type_id per_person_types.person_type_id%type;
2041 l_current_employee_flag per_all_people_f.current_employee_flag%type;
2042 l_current_applicant_flag per_all_people_f.current_applicant_flag%type;
2043 l_current_npw_flag per_all_people_f.current_npw_flag%type;
2044
2045 l_last_name per_all_people_f.last_name%type;
2046 l_first_name per_all_people_f.first_name%type;
2047 l_per_information1 per_all_people_f.per_information1%type;
2048 l_per_information2 per_all_people_f.per_information2%type;
2049 l_per_information18 per_all_people_f.per_information18%type;
2050 l_per_information19 per_all_people_f.per_information19%type;
2051 l_date_of_birth per_all_people_f.date_of_birth%type;
2052 l_title per_all_people_f.title%type;
2053 l_gender per_all_people_f.sex%type;
2054 l_marital_status per_all_people_f.marital_status%type;
2055 l_previous_last_name per_all_people_f.last_name%type;
2056 l_middle_name per_all_people_f.middle_names%type;
2057 l_name_suffix per_all_people_f.suffix%type;
2058 l_known_as per_all_people_f.known_as%type;
2059 l_business_group_id per_all_vacancies.business_group_id%type;
2060 l_organization_id per_all_vacancies.organization_id%type;
2061 l_job_id per_all_vacancies.job_id%type;
2062 l_position_id per_all_vacancies.position_id%type;
2063 l_manager_id per_all_vacancies.manager_id%type;
2064 l_grade_id per_all_vacancies.grade_id%type;
2065 l_location_id per_all_vacancies.location_id%type;
2066 l_recruiter_id per_all_vacancies.recruiter_id%type;
2067 l_people_group_id per_all_vacancies.people_group_id%type;
2068 l_legislation_code per_business_groups.legislation_code%type;
2069 --
2070 -- variables for hr_person_api.update_person
2071 --
2072 l_object_version_number per_all_people_f.object_version_number%TYPE;
2073 l_employee_number per_all_people_f.employee_number%TYPE;
2074 --
2075 -- dummy variables
2076 --
2077 l_msg_count number;
2078 l_msg_data varchar2(2000);
2079 l_var varchar2(1);
2080 l_party_number hz_parties.party_number%type;
2081 l_profile_id number;
2082 l_effective_start_date date;
2083 l_effective_end_date date;
2084 l_comment_id number;
2085 l_name_combination_warning boolean;
2086 l_assign_payroll_warning boolean;
2087 l_orig_hire_warning boolean;
2088 l_object_version_number_d per_all_people_f.object_version_number%TYPE;
2089 -- those required for hr_assignment_api.create_secondary_apl_asg
2090 l_concatenated_segments varchar2(2000);
2091 l_cagr_grade_def_id number;
2092 l_cagr_concatenated_segments varchar2(2000);
2093 l_group_name pay_people_groups.group_name%type;
2094 l_soft_coding_keyflex_id number;
2095 l_assignment_sequence per_all_assignments_f.assignment_sequence%type;
2096 -- those required for hr_applicant_api.create_applicant
2097 l_application_id number;
2098 l_full_name per_all_people_f.full_name%type;
2099 l_person_type per_person_types.system_person_type%type;
2100 l_ptu_person_type_id number;
2101 -- for disabling the descriptive flex field
2102 l_add_struct_d hr_dflex_utility.l_ignore_dfcode_varray :=
2103 hr_dflex_utility.l_ignore_dfcode_varray();
2104 -- for disabling the key flex field
2105 l_add_struct_k hr_kflex_utility.l_ignore_kfcode_varray :=
2106 hr_kflex_utility.l_ignore_kfcode_varray();
2107 --
2108 l_time_normal_finish per_business_groups.default_end_time%TYPE;
2109 l_time_normal_start per_business_groups.default_start_time%TYPE;
2110 l_normal_hours number;
2111 l_frequency per_business_groups.frequency%TYPE;
2112 --
2113 -- cursor to select entries IN per_all_people_f
2114 -- relating to registered user
2115 --
2116 cursor csr_person_id(p_party_id number
2117 ,p_effective_date date
2118 ,p_business_group_id number) is
2119 select per.person_id
2120 ,per.object_version_number
2121 ,per.current_employee_flag
2122 ,per.current_applicant_flag
2123 ,per.current_npw_flag
2124 ,per.applicant_number
2125 from per_all_people_f per
2126 where per.party_id = p_party_id
2127 and p_effective_date between per.effective_start_date and per.effective_end_date
2128 and business_group_id=p_business_group_id;
2129 --
2130 -- cursor to select entries IN per_all_people_f
2131 -- for a given person over all dates
2132 --
2133 cursor csr_person_all_dates(p_party_id number
2134 ,p_business_group_id number) is
2135 select null
2136 from per_all_people_f per
2137 where per.party_id = p_party_id
2138 and business_group_id=p_business_group_id;
2139 --
2140 -- cursor to select person details for the registered user
2141 --
2142 cursor csr_party_details(p_person_id number,p_effective_date date) is
2143 select last_update_date
2144 ,party_id
2145 ,last_name
2146 ,first_name
2147 ,date_of_birth
2148 ,title
2149 ,sex
2150 ,marital_status
2151 ,previous_last_name
2152 ,middle_names
2153 ,suffix
2154 ,known_as
2155 ,per_information1
2156 ,per_information2
2157 ,per_information18
2158 ,per_information19
2159 from per_all_people_f
2160 where person_id = p_person_id
2161 and p_effective_date between effective_start_date and effective_end_date;
2162 -- cursor to select business_group relating to a vacancy
2163 cursor csr_get_vac(p_vacancy_id number) is
2164 select business_group_id
2165 ,organization_id
2166 ,job_id
2167 ,position_id
2168 ,grade_id
2169 ,people_group_id
2170 ,location_id
2171 ,recruiter_id
2172 ,manager_id
2173 from per_all_vacancies
2174 where vacancy_id = p_vacancy_id;
2175 --
2176 cursor get_new_asg(p_person_id number, p_effective_date date) is
2177 select assignment_id,object_version_number
2178 from per_all_assignments_f
2179 where person_id=p_person_id
2180 and effective_start_date = p_effective_date
2181 and assignment_type='A';
2182 --
2183 -- Cursors to get work schedule
2184 --
2185 CURSOR csr_pos_default_details(p_position_id Number) IS
2186 SELECT pos.TIME_NORMAL_START
2187 , pos.TIME_NORMAL_FINISH
2188 , pos.working_hours
2189 , pos.frequency
2190 FROM hr_all_positions_f pos
2191 WHERE pos.position_id = p_position_id
2192 AND p_effective_date between effective_start_date and effective_end_date;
2193 --
2194 CURSOR csr_org_default_details(p_organization_id Number) IS
2195 SELECT org.org_information1
2196 , org.org_information2
2197 , fnd_number.canonical_to_number(org.org_information3) normal_hours
2198 , org.org_information4
2199 FROM HR_ORGANIZATION_INFORMATION org
2200 WHERE org.organization_id = p_organization_id
2201 AND org.org_information_context(+) = 'Work Day Information';
2202 --
2203 CURSOR csr_get_bg_default_details(p_business_group_id number) IS
2204 SELECT bus.default_start_time
2205 , bus.default_end_time
2206 , fnd_number.canonical_to_number(bus.working_hours)
2207 , bus.frequency
2208 FROM per_business_groups bus
2209 WHERE bus.business_group_id = p_business_group_id;
2210 --
2211 --
2212 begin
2213 hr_utility.set_location(' Entering: ' || l_proc, 10);
2214 --
2215 -- Issue a savepoint
2216 --
2217 savepoint REGISTERED_USER_APPLICATION;
2218 --
2219 -- Truncate time portion from date
2220 --
2221 l_effective_date := trunc(p_effective_date);
2222 --
2223 -- check if an agency is applying and if the application count is exceeded
2224 --
2225 irc_party_api.chk_agency_application_limit(p_vacancy_id => p_vacancy_id
2226 ,p_effective_date => l_effective_date);
2227 --
2228 -- If no application received date passed, then assume application received
2229 -- on effective_date
2230 --
2231 l_application_received_date:=trunc(nvl(p_application_received_date
2232 ,l_effective_date));
2233 --
2234 -- Added for turn off key flex field validation
2235 l_add_struct_k.extend(1);
2236 l_add_struct_k(l_add_struct_k.count) := 'GRP';
2237 l_add_struct_k.extend(1);
2238 l_add_struct_k(l_add_struct_k.count) := 'CAGR';
2239 l_add_struct_k.extend(1);
2240 l_add_struct_k(l_add_struct_k.count) := 'SCL';
2241 --
2242 hr_kflex_utility.create_ignore_kf_validation(p_rec => l_add_struct_k);
2243 --
2244 -- code for disabling the descriptive flex field
2245 l_add_struct_d.extend(1);
2246 l_add_struct_d(l_add_struct_d.count) := 'PER_ASSIGNMENTS';
2247 l_add_struct_d.extend(1);
2248 l_add_struct_d(l_add_struct_d.count) := 'Person Developer DF';
2249 l_add_struct_d.extend(1);
2250 l_add_struct_d(l_add_struct_d.count) := 'PER_PEOPLE';
2251 --
2252 hr_dflex_utility.create_ignore_df_validation(p_rec => l_add_struct_d);
2253 --
2254 -- Call Before Process User Hook
2255 --
2256 begin
2257 irc_party_bk3.registered_user_application_b
2258 (
2259 p_effective_date => l_effective_date
2260 ,p_person_id => p_person_id
2261 ,p_applicant_number => l_applicant_number
2262 ,p_application_received_date => l_application_received_date
2263 ,p_vacancy_id => p_vacancy_id
2264 ,p_posting_content_id => p_posting_content_id
2265 );
2266 exception
2267 when hr_api.cannot_find_prog_unit then
2268 hr_api.cannot_find_prog_unit_error
2269 (p_module_name => 'REGISTERED_USER_APPLICATION'
2270 ,p_hook_type => 'BP'
2271 );
2272 end;
2273 --
2274 -- Process Logic
2275 --
2276 -- get person info for recruitment person
2277 --
2278 open csr_party_details(p_recruitment_person_id,l_effective_date);
2279 fetch csr_party_details into l_party_last_update_date
2280 ,l_party_id
2281 ,l_last_name
2282 ,l_first_name
2283 ,l_date_of_birth
2284 ,l_title
2285 ,l_gender
2286 ,l_marital_status
2287 ,l_previous_last_name
2288 ,l_middle_name
2289 ,l_name_suffix
2290 ,l_known_as
2291 ,l_per_information1
2292 ,l_per_information2
2293 ,l_per_information18
2294 ,l_per_information19;
2295 close csr_party_details;
2296 --
2297 open csr_get_vac(p_vacancy_id);
2298 fetch csr_get_vac into l_business_group_id
2299 ,l_organization_id
2300 ,l_job_id
2301 ,l_position_id
2302 ,l_grade_id
2303 ,l_people_group_id
2304 ,l_location_id
2305 ,l_recruiter_id
2306 ,l_manager_id;
2307 close csr_get_vac;
2308 --
2309 open csr_person_id(l_party_id, l_effective_date,l_business_group_id);
2310 fetch csr_person_id into l_person_id
2311 ,l_per_object_version_number
2312 ,l_current_employee_flag
2313 ,l_current_applicant_flag
2314 ,l_current_npw_flag
2315 ,l_applicant_number;
2316 --
2317 -- check if there is an out of date person
2318 --
2319 open csr_person_all_dates(l_party_id, l_business_group_id);
2320 fetch csr_person_all_dates into l_var;
2321 --
2322 if ( csr_person_id%notfound and csr_person_all_dates%found ) then
2323 --
2324 close csr_person_id;
2325 close csr_person_all_dates;
2326 fnd_message.set_name('PER','IRC_412099_CANNOT_APPLY');
2327 hr_multi_message.add();
2328 end if;
2329 close csr_person_all_dates;
2330 --
2331 -- Register Assignment ID
2332 --
2333 per_asg_ins.set_base_key_value
2334 (p_assignment_id => p_assignment_id
2335 );
2336 --
2337 -- Get the work schedule.
2338 --
2339 IF(l_position_id IS NOT NULL) THEN
2340 open csr_pos_default_details(l_position_id);
2341 fetch csr_pos_default_details into l_time_normal_start
2342 , l_time_normal_finish
2343 , l_normal_hours
2344 , l_frequency;
2345 close csr_pos_default_details;
2346 END IF;
2347 --
2348 IF (l_organization_id IS NOT NULL AND
2349 l_time_normal_start IS NULL AND l_time_normal_finish IS NULL AND
2350 l_normal_hours IS NULL AND l_frequency iS NULL) THEN
2351 open csr_org_default_details(l_organization_id);
2352 fetch csr_org_default_details into l_time_normal_start
2353 , l_time_normal_finish
2354 , l_normal_hours
2355 , l_frequency;
2356 close csr_org_default_details;
2357 END IF;
2358 --
2359 IF (l_time_normal_start IS NULL AND l_time_normal_finish IS NULL AND
2360 l_normal_hours IS NULL AND l_frequency iS NULL) THEN
2361 open csr_get_bg_default_details(l_business_group_id);
2362 fetch csr_get_bg_default_details into l_time_normal_start
2363 , l_time_normal_finish
2364 , l_normal_hours
2365 , l_frequency;
2366 if csr_get_bg_default_details%NOTFOUND then
2367 --
2368 close csr_get_bg_default_details;
2369 --
2370 hr_utility.set_message(801, 'HR_7208_API_BUS_GRP_INVALID');
2371 hr_utility.raise_error;
2372 end if;
2373 close csr_get_bg_default_details;
2374 END IF;
2375 --
2376 if csr_person_id%found then
2377 --
2378 if (l_current_applicant_flag = 'Y') then
2379 hr_assignment_api.create_secondary_apl_asg
2380 (p_validate => false
2381 ,p_effective_date => l_effective_date
2382 ,p_person_id => l_person_id
2383 ,p_organization_id => nvl(l_organization_id,l_business_group_id)
2384 ,p_job_id => l_job_id
2385 ,p_position_id => l_position_id
2386 ,p_grade_id => l_grade_id
2387 ,p_people_group_id => l_people_group_id
2388 ,p_frequency => l_frequency
2389 ,p_normal_hours => l_normal_hours
2390 ,p_time_normal_finish => l_time_normal_finish
2391 ,p_time_normal_start => l_time_normal_start
2392 ,p_location_id => l_location_id
2393 ,p_recruiter_id => l_recruiter_id
2394 ,p_supervisor_id => l_manager_id
2395 ,p_vacancy_id => p_vacancy_id
2396 ,p_posting_content_id => p_posting_content_id
2397 ,p_concatenated_segments => l_concatenated_segments
2398 ,p_cagr_grade_def_id => l_cagr_grade_def_id
2399 ,p_cagr_concatenated_segments=> l_cagr_concatenated_segments
2400 ,p_group_name => l_group_name
2401 ,p_assignment_id => l_assignment_id
2402 ,p_soft_coding_keyflex_id => l_soft_coding_keyflex_id
2403 ,p_comment_id => l_comment_id
2404 ,p_object_version_number => l_asg_object_version_number
2405 ,p_effective_start_date => l_effective_start_date
2406 ,p_effective_end_date => l_effective_end_date
2407 ,p_assignment_sequence => l_assignment_sequence
2408 );
2409 elsif (l_current_employee_flag = 'Y') then
2410 hr_utility.set_location(l_proc,20);
2411 --
2412 hr_employee_api.apply_for_internal_vacancy
2413 (p_validate => false
2414 ,p_effective_date => l_effective_date
2415 ,p_person_id => l_person_id
2416 ,p_applicant_number => l_applicant_number
2417 ,p_per_object_version_number => l_per_object_version_number
2418 ,p_vacancy_id => p_vacancy_id
2419 ,p_application_id => l_application_id
2420 ,p_assignment_id => l_assignment_id
2421 ,p_apl_object_version_number => l_object_version_number_d
2422 ,p_asg_object_version_number => l_asg_object_version_number
2423 ,p_assignment_sequence => l_assignment_sequence
2424 ,p_per_effective_start_date => l_effective_start_date
2425 ,p_per_effective_end_date => l_effective_end_date);
2426 --
2427 hr_assignment_api.update_apl_asg
2428 (p_effective_date => l_effective_date
2429 ,p_datetrack_update_mode => 'CORRECTION'
2430 ,p_assignment_id => l_assignment_id
2431 ,p_object_version_number => l_asg_object_version_number
2432 ,p_posting_content_id => p_posting_content_id
2433 ,p_supervisor_id => l_manager_id
2434 ,p_concatenated_segments => l_concatenated_segments
2435 ,p_cagr_grade_def_id => l_cagr_grade_def_id
2436 ,p_cagr_concatenated_segments=> l_cagr_concatenated_segments
2437 ,p_group_name => l_group_name
2438 ,p_comment_id => l_comment_id
2439 ,p_soft_coding_keyflex_id => l_soft_coding_keyflex_id
2440 ,p_people_group_id => l_people_group_id
2441 ,p_frequency => l_frequency
2442 ,p_normal_hours => l_normal_hours
2443 ,p_time_normal_finish => l_time_normal_finish
2444 ,p_time_normal_start => l_time_normal_start
2445 ,p_effective_start_date => l_effective_start_date
2446 ,p_effective_end_date => l_effective_end_date
2447 );
2448 --
2449 else
2450 hr_utility.set_location(l_proc,30);
2451 --
2452 hr_applicant_api.convert_to_applicant
2453 (p_validate => false
2454 ,p_effective_date => l_effective_date
2455 ,p_person_id => l_person_id
2456 ,p_object_version_number => l_per_object_version_number
2457 ,p_applicant_number => l_applicant_number
2458 ,p_person_type_id => l_person_type_id
2459 ,p_effective_start_date => l_effective_start_date
2460 ,p_effective_end_date => l_effective_end_date);
2461 --
2462 open get_new_asg(l_person_id,l_effective_date);
2463 fetch get_new_asg into l_assignment_id,l_asg_object_version_number;
2464 close get_new_asg;
2465 --
2466 hr_assignment_api.update_apl_asg
2467 (p_effective_date => l_effective_date
2468 ,p_datetrack_update_mode => 'CORRECTION'
2469 ,p_assignment_id => l_assignment_id
2470 ,p_object_version_number => l_asg_object_version_number
2471 ,p_vacancy_id => p_vacancy_id
2472 ,p_posting_content_id => p_posting_content_id
2473 ,p_organization_id => nvl(l_organization_id,l_business_group_id)
2474 ,p_job_id => l_job_id
2475 ,p_position_id => l_position_id
2476 ,p_grade_id => l_grade_id
2477 ,p_people_group_id => l_people_group_id
2478 ,p_location_id => l_location_id
2479 ,p_recruiter_id => l_recruiter_id
2480 ,p_supervisor_id => l_manager_id
2481 ,p_concatenated_segments => l_concatenated_segments
2482 ,p_cagr_grade_def_id => l_cagr_grade_def_id
2483 ,p_cagr_concatenated_segments=> l_cagr_concatenated_segments
2484 ,p_group_name => l_group_name
2485 ,p_comment_id => l_comment_id
2486 ,p_soft_coding_keyflex_id => l_soft_coding_keyflex_id
2487 ,p_frequency => l_frequency
2488 ,p_normal_hours => l_normal_hours
2489 ,p_time_normal_finish => l_time_normal_finish
2490 ,p_time_normal_start => l_time_normal_start
2491 ,p_effective_start_date => l_effective_start_date
2492 ,p_effective_end_date => l_effective_end_date
2493 );
2494 end if;
2495 else
2496 hr_utility.set_location(l_proc, 40);
2497 --
2498 -- Register Person ID
2499 --
2500 per_per_ins.set_base_key_value
2501 (p_person_id => p_person_id);
2502 --
2503 l_legislation_code := per_vac_bus.return_legislation_code(p_vacancy_id);
2504 l_applicant_number:=null;
2505 if (l_legislation_code = 'JP') then
2506 hr_applicant_api.create_applicant
2507 (p_validate => false
2508 ,p_date_received => l_application_received_date
2509 ,p_business_group_id => l_business_group_id
2510 ,p_last_name => l_last_name
2511 ,p_first_name => l_first_name
2512 ,p_per_information18 => l_per_information18
2513 ,p_per_information19 => l_per_information19
2514 ,p_date_of_birth => l_date_of_birth
2515 ,p_applicant_number => l_applicant_number
2516 ,p_previous_last_name => l_previous_last_name
2517 ,p_known_as => l_known_as
2518 ,p_marital_status => l_marital_status
2519 ,p_middle_names => l_middle_name
2520 ,p_suffix => l_name_suffix
2521 ,p_person_id => l_person_id
2522 ,p_assignment_id => l_assignment_id
2523 ,p_application_id => l_application_id
2524 ,p_per_object_version_number => l_per_object_version_number
2525 ,p_asg_object_version_number => l_asg_object_version_number
2526 ,p_apl_object_version_number => l_object_version_number_d
2527 ,p_per_effective_start_date => l_effective_start_date
2528 ,p_per_effective_end_date => l_effective_end_date
2529 ,p_full_name => l_full_name
2530 ,p_per_comment_id => l_comment_id
2531 ,p_assignment_sequence => l_assignment_sequence
2532 ,p_name_combination_warning => l_name_combination_warning
2533 ,p_orig_hire_warning => l_orig_hire_warning
2534 ,p_party_id => l_party_id
2535 );
2536 elsif (l_legislation_code = 'KR') then
2537 hr_applicant_api.create_applicant
2538 (p_validate => false
2539 ,p_date_received => l_application_received_date
2540 ,p_business_group_id => l_business_group_id
2541 ,p_last_name => l_last_name
2542 ,p_first_name => l_first_name
2543 ,p_per_information1 => l_per_information1
2544 ,p_per_information2 => l_per_information2
2545 ,p_date_of_birth => l_date_of_birth
2546 ,p_applicant_number => l_applicant_number
2547 ,p_previous_last_name => l_previous_last_name
2548 ,p_known_as => l_known_as
2549 ,p_marital_status => l_marital_status
2550 ,p_middle_names => l_middle_name
2551 ,p_suffix => l_name_suffix
2552 ,p_person_id => l_person_id
2553 ,p_assignment_id => l_assignment_id
2554 ,p_application_id => l_application_id
2555 ,p_per_object_version_number => l_per_object_version_number
2556 ,p_asg_object_version_number => l_asg_object_version_number
2557 ,p_apl_object_version_number => l_object_version_number_d
2558 ,p_per_effective_start_date => l_effective_start_date
2559 ,p_per_effective_end_date => l_effective_end_date
2560 ,p_full_name => l_full_name
2561 ,p_per_comment_id => l_comment_id
2562 ,p_assignment_sequence => l_assignment_sequence
2563 ,p_name_combination_warning => l_name_combination_warning
2564 ,p_orig_hire_warning => l_orig_hire_warning
2565 ,p_party_id => l_party_id
2566 );
2567 elsif (l_legislation_code = 'ZA') then
2568 hr_applicant_api.create_applicant
2569 (p_validate => false
2570 ,p_date_received => l_application_received_date
2571 ,p_business_group_id => l_business_group_id
2572 ,p_last_name => l_last_name
2573 ,p_first_name => l_first_name
2574 ,p_per_information4 => p_per_information4
2575 ,p_date_of_birth => l_date_of_birth
2576 ,p_applicant_number => l_applicant_number
2577 ,p_previous_last_name => l_previous_last_name
2578 ,p_known_as => l_known_as
2579 ,p_marital_status => l_marital_status
2580 ,p_middle_names => l_middle_name
2581 ,p_suffix => l_name_suffix
2582 ,p_person_id => l_person_id
2583 ,p_assignment_id => l_assignment_id
2584 ,p_application_id => l_application_id
2585 ,p_per_object_version_number => l_per_object_version_number
2586 ,p_asg_object_version_number => l_asg_object_version_number
2587 ,p_apl_object_version_number => l_object_version_number_d
2588 ,p_per_effective_start_date => l_effective_start_date
2589 ,p_per_effective_end_date => l_effective_end_date
2590 ,p_full_name => l_full_name
2591 ,p_per_comment_id => l_comment_id
2592 ,p_assignment_sequence => l_assignment_sequence
2593 ,p_name_combination_warning => l_name_combination_warning
2594 ,p_orig_hire_warning => l_orig_hire_warning
2595 ,p_party_id => l_party_id
2596 );
2597 else
2598 hr_applicant_api.create_applicant
2599 (p_validate => false
2600 ,p_date_received => l_application_received_date
2601 ,p_business_group_id => l_business_group_id
2602 ,p_last_name => l_last_name
2603 ,p_first_name => l_first_name
2604 ,p_date_of_birth => l_date_of_birth
2605 ,p_applicant_number => l_applicant_number
2606 ,p_previous_last_name => l_previous_last_name
2607 ,p_known_as => l_known_as
2608 ,p_marital_status => l_marital_status
2609 ,p_middle_names => l_middle_name
2610 ,p_suffix => l_name_suffix
2611 ,p_person_id => l_person_id
2612 ,p_assignment_id => l_assignment_id
2613 ,p_application_id => l_application_id
2614 ,p_per_object_version_number => l_per_object_version_number
2615 ,p_asg_object_version_number => l_asg_object_version_number
2616 ,p_apl_object_version_number => l_object_version_number_d
2617 ,p_per_effective_start_date => l_effective_start_date
2618 ,p_per_effective_end_date => l_effective_end_date
2619 ,p_full_name => l_full_name
2620 ,p_per_comment_id => l_comment_id
2621 ,p_assignment_sequence => l_assignment_sequence
2622 ,p_name_combination_warning => l_name_combination_warning
2623 ,p_orig_hire_warning => l_orig_hire_warning
2624 ,p_party_id => l_party_id
2625 );
2626 end if;
2627 --
2628 -- get the PTU person type for iRecruitment Candidate
2629 --
2630 l_ptu_person_type_id:=hr_person_type_usage_info.get_default_person_type_id
2631 (l_business_group_id,
2632 'IRC_REG_USER');
2633 --
2634 -- create the extra PTU entry for iRecruitment Candidate
2635 --
2636 hr_per_type_usage_internal.maintain_person_type_usage
2637 (p_effective_date => l_effective_start_date
2638 ,p_person_id => l_person_id
2639 ,p_person_type_id => l_ptu_person_type_id
2640 );
2641 hr_utility.set_location(l_proc, 45);
2642 --
2643 hr_assignment_api.update_apl_asg
2644 (p_effective_date => l_application_received_date
2645 ,p_datetrack_update_mode => 'CORRECTION'
2646 ,p_assignment_id => l_assignment_id
2647 ,p_object_version_number => l_asg_object_version_number
2648 ,p_vacancy_id => p_vacancy_id
2649 ,p_posting_content_id => p_posting_content_id
2650 ,p_organization_id => nvl(l_organization_id,l_business_group_id)
2651 ,p_job_id => l_job_id
2652 ,p_position_id => l_position_id
2653 ,p_grade_id => l_grade_id
2654 ,p_people_group_id => l_people_group_id
2655 ,p_location_id => l_location_id
2656 ,p_recruiter_id => l_recruiter_id
2657 ,p_supervisor_id => l_manager_id
2658 ,p_concatenated_segments => l_concatenated_segments
2659 ,p_cagr_grade_def_id => l_cagr_grade_def_id
2660 ,p_cagr_concatenated_segments=> l_cagr_concatenated_segments
2661 ,p_group_name => l_group_name
2662 ,p_comment_id => l_comment_id
2663 ,p_soft_coding_keyflex_id => l_soft_coding_keyflex_id
2664 ,p_frequency => l_frequency
2665 ,p_normal_hours => l_normal_hours
2666 ,p_time_normal_finish => l_time_normal_finish
2667 ,p_time_normal_start => l_time_normal_start
2668 ,p_effective_start_date => l_effective_start_date
2669 ,p_effective_end_date => l_effective_end_date
2670 );
2671 end if;
2672 close csr_person_id;
2673 --
2674 -- Call After Process User Hook
2675 --
2676 begin
2677 irc_party_bk3.registered_user_application_a
2678 (
2679 p_effective_date => l_effective_date
2680 ,p_person_id => p_person_id
2681 ,p_applicant_number => l_applicant_number
2682 ,p_application_received_date => l_application_received_date
2683 ,p_vacancy_id => p_vacancy_id
2684 ,p_posting_content_id => p_posting_content_id
2685 ,p_assignment_id => l_assignment_id
2686 ,p_asg_object_version_number => l_asg_object_version_number
2687 );
2688 exception
2689 when hr_api.cannot_find_prog_unit then
2690 hr_api.cannot_find_prog_unit_error
2691 (p_module_name => 'REGISTERED_USER_APPLICATION'
2692 ,p_hook_type => 'AP'
2693 );
2694 end;
2695 --
2696 -- When IN validation only mode raise the Validate_Enabled exception
2697 --
2698 if p_validate then
2699 raise hr_api.validate_enabled;
2700 end if;
2701 --
2702 -- Set all output arguments
2703 --
2704 p_asg_object_version_number := l_asg_object_version_number;
2705 p_per_object_version_number := l_per_object_version_number;
2706 p_applicant_number := l_applicant_number;
2707 --
2708 hr_utility.set_location(' Leaving:'||l_proc, 70);
2709
2710 exception
2711 when hr_api.validate_enabled then
2712 --
2713 -- As the Validate_Enabled exception has been raised
2714 -- we must rollback to the savepoint
2715 --
2716 rollback to REGISTERED_USER_APPLICATION;
2717 --
2718 -- Only set output warning arguments
2719 -- (Any key or derived arguments must be set to null
2720 -- when validation only mode is beINg used.)
2721 --
2722 p_asg_object_version_number := null;
2723 p_per_object_version_number := null;
2724 hr_utility.set_location(' Leaving:'||l_proc, 80);
2725 when others then
2726 --
2727 -- A validation or unexpected error has occured
2728 --
2729
2730 -- Check whether csr_person_id is open or not. If open, close it.
2731
2732 if csr_person_id%isopen then
2733 close csr_person_id;
2734 end if;
2735
2736 rollback to REGISTERED_USER_APPLICATION;
2737 --
2738 p_asg_object_version_number := null;
2739 p_per_object_version_number := null;
2740 --
2741 hr_utility.set_location(' Leaving:'||l_proc, 90);
2742 raise;
2743 end registered_user_application;
2744 -- -------------------------------------------------------------------------
2745 -- |------------------------< grant_access >-------------------------------|
2746 -- -------------------------------------------------------------------------
2747 procedure grant_access
2748 (p_user_name IN varchar2
2749 ,p_user_id IN number
2750 ,p_menu_id IN number
2751 ,p_resp_id IN number
2752 ,p_resp_appl_id IN number
2753 ,p_sec_group_id IN number
2754 ,p_grant_name IN varchar2
2755 ,p_description IN varchar2 default null
2756 ) is
2757 srowId VARCHAR2(100);
2758 l_guid raw(16);
2759 begin
2760 select sys_guid() into l_guid from dual;
2761 fnd_grants_pkg.insert_row
2762 (
2763 X_ROWID => srowId,
2764 X_GRANT_GUID => l_guid,
2765 X_GRANTEE_TYPE => 'USER',
2766 X_GRANTEE_KEY => upper(p_user_name),
2767 X_MENU_ID => p_menu_id,
2768 X_START_DATE => trunc(sysdate),
2769 X_END_DATE => null,
2770 X_OBJECT_ID => '-1',
2771 X_INSTANCE_TYPE => 'GLOBAL',
2772 X_INSTANCE_SET_ID => null,
2773 X_INSTANCE_PK1_VALUE => '*NULL*',
2774 X_INSTANCE_PK2_VALUE => '*NULL*',
2775 X_INSTANCE_PK3_VALUE => '*NULL*',
2776 X_INSTANCE_PK4_VALUE => '*NULL*',
2777 X_INSTANCE_PK5_VALUE => '*NULL*',
2778 X_PROGRAM_NAME => 'IRC_API',
2779 X_PROGRAM_TAG => null,
2780 X_CREATION_DATE => sysdate,
2781 X_CREATED_BY => p_user_id,
2782 X_LAST_UPDATE_DATE => sysdate,
2783 X_LAST_UPDATED_BY => p_user_id,
2784 X_LAST_UPDATE_LOGIN => p_user_id,
2785 X_CTX_SECGRP_ID => p_sec_group_id,
2786 X_CTX_RESP_ID => p_resp_id,
2787 X_CTX_RESP_APPL_ID => p_resp_appl_id,
2788 X_NAME => p_grant_name,
2789 X_DESCRIPTION => p_description
2790 );
2791 end grant_access;
2792 --
2793 -- -------------------------------------------------------------------------
2794 -- |------------------------< create_user_internal >-----------------------|
2795 -- -------------------------------------------------------------------------
2796 --
2797 procedure create_user_internal
2798 (p_user_name IN varchar2
2799 ,p_password IN varchar2
2800 ,p_start_date IN date
2801 ,p_responsibility_id IN number
2802 ,p_resp_appl_id IN number
2803 ,p_security_group_id IN number
2804 ,p_email IN varchar2 default null
2805 ,p_language IN varchar2 default null
2806 ,p_last_name IN varchar2 default null
2807 ,p_first_name IN varchar2 default null
2808 ,p_allow_access IN varchar2 default null
2809 ,p_per_information_category IN varchar2 default null
2810 ,p_per_information1 IN varchar2 default null
2811 ,p_per_information2 IN varchar2 default null
2812 ,p_per_information3 IN varchar2 default null
2813 ,p_per_information4 IN varchar2 default null
2814 ,p_per_information5 IN varchar2 default null
2815 ,p_per_information6 IN varchar2 default null
2816 ,p_per_information7 IN varchar2 default null
2817 ,p_per_information8 IN varchar2 default null
2818 ,p_per_information9 IN varchar2 default null
2819 ,p_per_information10 IN varchar2 default null
2820 ,p_per_information11 IN varchar2 default null
2821 ,p_per_information12 IN varchar2 default null
2822 ,p_per_information13 IN varchar2 default null
2823 ,p_per_information14 IN varchar2 default null
2824 ,p_per_information15 IN varchar2 default null
2825 ,p_per_information16 IN varchar2 default null
2826 ,p_per_information17 IN varchar2 default null
2827 ,p_per_information18 IN varchar2 default null
2828 ,p_per_information19 IN varchar2 default null
2829 ,p_per_information20 IN varchar2 default null
2830 ,p_per_information21 IN varchar2 default null
2831 ,p_per_information22 IN varchar2 default null
2832 ,p_per_information23 IN varchar2 default null
2833 ,p_per_information24 IN varchar2 default null
2834 ,p_per_information25 IN varchar2 default null
2835 ,p_per_information26 IN varchar2 default null
2836 ,p_per_information27 IN varchar2 default null
2837 ,p_per_information28 IN varchar2 default null
2838 ,p_per_information29 IN varchar2 default null
2839 ,p_per_information30 IN varchar2 default null
2840 ) IS
2841 --
2842 PRAGMA autonomous_transaction;
2843 l_proc varchar2(72) := g_package||'create_user';
2844 l_person_id per_all_people_f.person_id%type;
2845 l_user_id number;
2846 l_profile_check boolean;
2847 l_user_name fnd_user.user_name%type;
2848 l_default_last_name per_all_people_f.last_name%type;
2849 l_effective_start_date date;
2850 l_effective_end_date date;
2851 l_sec_profile_assignment_id number;
2852 l_business_group_id number;
2853 l_sec_profile_id number;
2854 l_ovn number;
2855 l_menu_name varchar2(30);
2856 l_menu_id number;
2857 l_grant_name varchar2(80);
2858 --
2859 cursor get_menu_id (p_menu_name varchar2) is
2860 select menu_id from fnd_menus where menu_name=upper(p_menu_name);
2861 --
2862 begin
2863 hr_utility.set_location(' Entering: '||l_proc, 10);
2864 --
2865 -- Create Person
2866 l_default_last_name := nvl(p_last_name,fnd_message.get_string('PER','IRC_412108_UNKNOWN_NAME'));
2867
2868 irc_party_api.create_registered_user
2869 (p_last_name => l_default_last_name
2870 ,p_first_name => p_first_name
2871 ,p_email_address => p_email
2872 ,p_effective_start_date => l_effective_start_date
2873 ,p_effective_end_date => l_effective_end_date
2874 ,p_person_id => l_person_id
2875 ,p_allow_access => p_allow_access
2876 ,p_start_date => p_start_date
2877 ,p_per_information_category => p_per_information_category
2878 ,p_per_information1 => p_per_information1
2879 ,p_per_information2 => p_per_information2
2880 ,p_per_information3 => p_per_information3
2881 ,p_per_information4 => p_per_information4
2882 ,p_per_information5 => p_per_information5
2883 ,p_per_information6 => p_per_information6
2884 ,p_per_information7 => p_per_information7
2885 ,p_per_information8 => p_per_information8
2886 ,p_per_information9 => p_per_information9
2887 ,p_per_information10 => p_per_information10
2888 ,p_per_information11 => p_per_information11
2889 ,p_per_information12 => p_per_information12
2890 ,p_per_information13 => p_per_information13
2891 ,p_per_information14 => p_per_information14
2892 ,p_per_information15 => p_per_information15
2893 ,p_per_information16 => p_per_information16
2894 ,p_per_information17 => p_per_information17
2895 ,p_per_information18 => p_per_information18
2896 ,p_per_information19 => p_per_information19
2897 ,p_per_information20 => p_per_information20
2898 ,p_per_information21 => p_per_information21
2899 ,p_per_information22 => p_per_information22
2900 ,p_per_information23 => p_per_information23
2901 ,p_per_information24 => p_per_information24
2902 ,p_per_information25 => p_per_information25
2903 ,p_per_information26 => p_per_information26
2904 ,p_per_information27 => p_per_information27
2905 ,p_per_information28 => p_per_information28
2906 ,p_per_information29 => p_per_information29
2907 ,p_per_information30 => p_per_information30
2908 );
2909
2910 --
2911 hr_utility.set_location(l_proc,20);
2912 --
2913 -- Create User and set person_id to employee_id
2914 --
2915 l_user_id := fnd_user_pkg.CreateUserId (
2916 x_user_name => p_user_name,
2917 x_owner => 'CUST',
2918 x_unencrypted_password => p_password,
2919 x_email_address => p_email,
2920 x_employee_id => l_person_id,
2921 x_password_date => trunc(sysdate));
2922 --
2923 hr_utility.set_location(l_proc,30);
2924 --
2925 -- set the language profile option
2926 --
2927 l_profile_check := fnd_profile.save (
2928 x_name => 'ICX_LANGUAGE',
2929 x_value => p_language,
2930 x_level_name => 'USER',
2931 x_level_value => l_user_id );
2932 --
2933 hr_utility.set_location(l_proc,40);
2934 --
2935 --
2936 -- add the appropriate responsibility
2937 --
2938 fnd_user_resp_groups_api.Insert_Assignment
2939 (user_id => l_user_id
2940 ,responsibility_id => p_responsibility_id
2941 ,responsibility_application_id => p_resp_appl_id
2942 ,security_group_id => p_security_group_id
2943 ,start_date => trunc(sysdate)
2944 ,end_date => null
2945 ,description => ' ' -- ### description was supposed to default
2946 -- to null... but does not look like it has
2947 );
2948 hr_utility.set_location(l_proc,50);
2949 --
2950 -- look to see if we are using multiple security groups
2951 --
2952 if (fnd_profile.value('ENABLE_SECURITY_GROUPS')='Y') then
2953 hr_utility.set_location(l_proc,60);
2954 l_sec_profile_id:=fnd_profile.value_specific
2955 (name=>'PER_SECURITY_PROFILE_ID'
2956 ,user_id=>l_user_id
2957 ,responsibility_id=>p_responsibility_id
2958 ,application_id=>p_resp_appl_id);
2959 l_business_group_id:=fnd_profile.value_specific
2960 (name=>'PER_BUSINESS_GROUP_ID'
2961 ,user_id=>l_user_id
2962 ,responsibility_id=>p_responsibility_id
2963 ,application_id=>p_resp_appl_id);
2964 --
2965 hr_utility.set_location(l_proc,70);
2966 per_sec_profile_asg_api.create_security_profile_asg
2967 (p_sec_profile_assignment_id => l_sec_profile_assignment_id
2968 ,p_user_id => l_user_id
2969 ,p_security_group_id => p_security_group_id
2970 ,p_business_group_id => l_business_group_id
2971 ,p_security_profile_id => l_sec_profile_id
2972 ,p_responsibility_id => p_responsibility_id
2973 ,p_responsibility_application_i => p_resp_appl_id
2974 ,p_start_date => trunc(sysdate)
2975 ,p_object_version_number => l_ovn
2976 );
2977 end if;
2978 hr_utility.set_location(l_proc,90);
2979 --
2980 -- Assign the grant to the User
2981 --
2982 l_menu_name:=fnd_profile.value_specific
2983 (name=>'IRC_CANDIDATE_PSET'
2984 ,user_id=>l_user_id
2985 ,responsibility_id=>p_responsibility_id
2986 ,application_id=>p_resp_appl_id);
2987
2988 open get_menu_id(l_menu_name);
2989 fetch get_menu_id into l_menu_id;
2990 close get_menu_id;
2991
2992 if l_menu_id is not null then
2993 if length(p_user_name) > 65 then
2994 l_grant_name := 'IRC_'||substr(p_user_name,1,65)||'_CAND_GRANT';
2995 else
2996 l_grant_name := 'IRC_'||upper(p_user_name)||'_CAND_GRANT';
2997 end if;
2998 irc_party_api.grant_access(p_user_name=> p_user_name,
2999 p_user_id=> l_user_id,
3000 p_menu_id=> l_menu_id,
3001 p_resp_id=> p_responsibility_id,
3002 p_resp_appl_id=> p_resp_appl_id,
3003 p_sec_group_id=> p_security_group_id,
3004 p_grant_name=> l_grant_name,
3005 p_description=>' ');
3006 end if;
3007 hr_utility.set_location(l_proc,100);
3008 --
3009 -- commit autonomous transaction
3010 --
3011 commit;
3012 --
3013 hr_utility.set_location(' Leaving:'||l_proc, 110);
3014 end create_user_internal;
3015 --
3016 -- -------------------------------------------------------------------------
3017 -- |------------------------< create_user >--------------------------------|
3018 -- -------------------------------------------------------------------------
3019 --
3020 procedure create_user
3021 (p_user_name IN varchar2
3022 ,p_password IN varchar2
3023 ,p_start_date IN date
3024 ,p_responsibility_id IN number
3025 ,p_resp_appl_id IN number
3026 ,p_security_group_id IN number
3027 ,p_email IN varchar2 default null
3028 ,p_language IN varchar2 default null
3029 ,p_last_name IN varchar2 default null
3030 ,p_first_name IN varchar2 default null
3031 ,p_allow_access IN varchar2 default null
3032 ,p_per_information_category IN varchar2 default null
3033 ,p_per_information1 IN varchar2 default null
3034 ,p_per_information2 IN varchar2 default null
3035 ,p_per_information3 IN varchar2 default null
3036 ,p_per_information4 IN varchar2 default null
3037 ,p_per_information5 IN varchar2 default null
3038 ,p_per_information6 IN varchar2 default null
3039 ,p_per_information7 IN varchar2 default null
3040 ,p_per_information8 IN varchar2 default null
3041 ,p_per_information9 IN varchar2 default null
3042 ,p_per_information10 IN varchar2 default null
3043 ,p_per_information11 IN varchar2 default null
3044 ,p_per_information12 IN varchar2 default null
3045 ,p_per_information13 IN varchar2 default null
3046 ,p_per_information14 IN varchar2 default null
3047 ,p_per_information15 IN varchar2 default null
3048 ,p_per_information16 IN varchar2 default null
3049 ,p_per_information17 IN varchar2 default null
3050 ,p_per_information18 IN varchar2 default null
3051 ,p_per_information19 IN varchar2 default null
3052 ,p_per_information20 IN varchar2 default null
3053 ,p_per_information21 IN varchar2 default null
3054 ,p_per_information22 IN varchar2 default null
3055 ,p_per_information23 IN varchar2 default null
3056 ,p_per_information24 IN varchar2 default null
3057 ,p_per_information25 IN varchar2 default null
3058 ,p_per_information26 IN varchar2 default null
3059 ,p_per_information27 IN varchar2 default null
3060 ,p_per_information28 IN varchar2 default null
3061 ,p_per_information29 IN varchar2 default null
3062 ,p_per_information30 IN varchar2 default null
3063 ) IS
3064 --
3065 l_password_check varchar2(1);
3066 l_password_change_check varchar2(1);
3067 l_allow_access irc_notification_preferences.allow_access%type;
3068 l_start_date date;
3069 cursor get_nls_language is
3070 select nls_language
3071 from fnd_languages
3072 where language_code=p_language;
3073 --
3074 l_nls_language fnd_languages.nls_language%type;
3075 --
3076 begin
3077 --
3078 -- Truncate time portion from date
3079 --
3080 l_start_date := trunc(p_start_date);
3081 --
3082 -- default Allow Access if input value is NULL
3083 --
3084 l_allow_access := nvl(p_allow_access,nvl(fnd_profile.value('IRC_VISIBLE_PREF_DEFAULT'),'N'));
3085 --
3086 -- Call Before Process User Hook
3087 --
3088 begin
3089 irc_party_bk4.create_user_b
3090 (
3091 p_user_name => p_user_name
3092 ,p_password => p_password
3093 ,p_start_date => l_start_date
3094 ,p_email => p_email
3095 ,p_language => p_language
3096 ,p_last_name => p_last_name
3097 ,p_first_name => p_first_name
3098 ,p_allow_access => l_allow_access
3099 ,p_per_information_category => p_per_information_category
3100 ,p_per_information1 => p_per_information1
3101 ,p_per_information2 => p_per_information2
3102 ,p_per_information3 => p_per_information3
3103 ,p_per_information4 => p_per_information4
3104 ,p_per_information5 => p_per_information5
3105 ,p_per_information6 => p_per_information6
3106 ,p_per_information7 => p_per_information7
3107 ,p_per_information8 => p_per_information8
3108 ,p_per_information9 => p_per_information9
3109 ,p_per_information10 => p_per_information10
3110 ,p_per_information11 => p_per_information11
3111 ,p_per_information12 => p_per_information12
3112 ,p_per_information13 => p_per_information13
3113 ,p_per_information14 => p_per_information14
3114 ,p_per_information15 => p_per_information15
3115 ,p_per_information16 => p_per_information16
3116 ,p_per_information17 => p_per_information17
3117 ,p_per_information18 => p_per_information18
3118 ,p_per_information19 => p_per_information19
3119 ,p_per_information20 => p_per_information20
3120 ,p_per_information21 => p_per_information21
3121 ,p_per_information22 => p_per_information22
3122 ,p_per_information23 => p_per_information23
3123 ,p_per_information24 => p_per_information24
3124 ,p_per_information25 => p_per_information25
3125 ,p_per_information26 => p_per_information26
3126 ,p_per_information27 => p_per_information27
3127 ,p_per_information28 => p_per_information28
3128 ,p_per_information29 => p_per_information29
3129 ,p_per_information30 => p_per_information30
3130 );
3131 exception
3132 when hr_api.cannot_find_prog_unit then
3133 hr_api.cannot_find_prog_unit_error
3134 (p_module_name => 'CREATE_USER'
3135 ,p_hook_type => 'BP'
3136 );
3137 end;
3138 --
3139 -- get NLS_LANGUAGE
3140 --
3141 open get_nls_language;
3142 fetch get_nls_language into l_nls_language;
3143 if get_nls_language%notfound then
3144 close get_nls_language;
3145 l_nls_language:=p_language;
3146 else
3147 close get_nls_language;
3148 end if;
3149 --
3150 -- Validate the password
3151 --
3152 l_password_check := fnd_web_sec.validate_password(username => p_user_name
3153 ,password => p_password);
3154
3155 if (l_password_check = 'N') then
3156 fnd_message.raise_error;
3157 end if;
3158 --
3159 -- create party and user
3160 --
3161 irc_party_api.create_user_internal(p_user_name => p_user_name
3162 ,p_password => p_password
3163 ,p_start_date => l_start_date
3164 ,p_email => p_email
3165 ,p_responsibility_id => p_responsibility_id
3166 ,p_resp_appl_id => p_resp_appl_id
3167 ,p_security_group_id => p_security_group_id
3168 ,p_language => l_nls_language
3169 ,p_last_name => p_last_name
3170 ,p_first_name => p_first_name
3171 ,p_allow_access => l_allow_access
3172 ,p_per_information_category => p_per_information_category
3173 ,p_per_information1 => p_per_information1
3174 ,p_per_information2 => p_per_information2
3175 ,p_per_information3 => p_per_information3
3176 ,p_per_information4 => p_per_information4
3177 ,p_per_information5 => p_per_information5
3178 ,p_per_information6 => p_per_information6
3179 ,p_per_information7 => p_per_information7
3180 ,p_per_information8 => p_per_information8
3181 ,p_per_information9 => p_per_information9
3182 ,p_per_information10 => p_per_information10
3183 ,p_per_information11 => p_per_information11
3184 ,p_per_information12 => p_per_information12
3185 ,p_per_information13 => p_per_information13
3186 ,p_per_information14 => p_per_information14
3187 ,p_per_information15 => p_per_information15
3188 ,p_per_information16 => p_per_information16
3189 ,p_per_information17 => p_per_information17
3190 ,p_per_information18 => p_per_information18
3191 ,p_per_information19 => p_per_information19
3192 ,p_per_information20 => p_per_information20
3193 ,p_per_information21 => p_per_information21
3194 ,p_per_information22 => p_per_information22
3195 ,p_per_information23 => p_per_information23
3196 ,p_per_information24 => p_per_information24
3197 ,p_per_information25 => p_per_information25
3198 ,p_per_information26 => p_per_information26
3199 ,p_per_information27 => p_per_information27
3200 ,p_per_information28 => p_per_information28
3201 ,p_per_information29 => p_per_information29
3202 ,p_per_information30 => p_per_information30
3203 );
3204 --
3205 -- Call After Process User Hook
3206 --
3207 begin
3208 irc_party_bk4.create_user_a
3209 (
3210 p_user_name => p_user_name
3211 ,p_password => p_password
3212 ,p_start_date => l_start_date
3213 ,p_email => p_email
3214 ,p_language => p_language
3215 ,p_last_name => p_last_name
3216 ,p_first_name => p_first_name
3217 ,p_allow_access => l_allow_access
3218 ,p_per_information_category => p_per_information_category
3219 ,p_per_information1 => p_per_information1
3220 ,p_per_information2 => p_per_information2
3221 ,p_per_information3 => p_per_information3
3222 ,p_per_information4 => p_per_information4
3223 ,p_per_information5 => p_per_information5
3224 ,p_per_information6 => p_per_information6
3225 ,p_per_information7 => p_per_information7
3226 ,p_per_information8 => p_per_information8
3227 ,p_per_information9 => p_per_information9
3228 ,p_per_information10 => p_per_information10
3229 ,p_per_information11 => p_per_information11
3230 ,p_per_information12 => p_per_information12
3231 ,p_per_information13 => p_per_information13
3232 ,p_per_information14 => p_per_information14
3233 ,p_per_information15 => p_per_information15
3234 ,p_per_information16 => p_per_information16
3235 ,p_per_information17 => p_per_information17
3236 ,p_per_information18 => p_per_information18
3237 ,p_per_information19 => p_per_information19
3238 ,p_per_information20 => p_per_information20
3239 ,p_per_information21 => p_per_information21
3240 ,p_per_information22 => p_per_information22
3241 ,p_per_information23 => p_per_information23
3242 ,p_per_information24 => p_per_information24
3243 ,p_per_information25 => p_per_information25
3244 ,p_per_information26 => p_per_information26
3245 ,p_per_information27 => p_per_information27
3246 ,p_per_information28 => p_per_information28
3247 ,p_per_information29 => p_per_information29
3248 ,p_per_information30 => p_per_information30
3249 );
3250 exception
3251 when hr_api.cannot_find_prog_unit then
3252 hr_api.cannot_find_prog_unit_error
3253 (p_module_name => 'CREATE_USER'
3254 ,p_hook_type => 'AP'
3255 );
3256 end;
3257 --
3258 end create_user;
3259 --
3260 -- Function to encrypt a string using a specified key.
3261 --
3262 function encrypt
3263 (p_key in varchar2,
3264 p_value in varchar2)
3265 return varchar2
3266 as language java name 'oracle.apps.fnd.security.WebSessionManagerProc.encrypt(java.lang.String,java.lang.String) return
3267 java.lang.String';
3268 --
3269 -- Function to decrypt an encrypted string using a specified key.
3270 --
3271 function decrypt
3272 (p_key in varchar2,
3273 p_value in varchar2)
3274 return varchar2
3275 as language java name 'oracle.apps.fnd.security.WebSessionManagerProc.decrypt(java.lang.String,java.lang.String) return
3276 java.lang.String';
3277 --
3278 -- Returns the foundation password.
3279 --
3280 function get_foundation_password
3281 return varchar2
3282 is
3283 guestUserPwd varchar2(200);
3284 guestUserName varchar2(100);
3285 guestUserPwdOnly varchar2(100);
3286 guestFndPwd varchar2(100);
3287 delim number;
3288 bad_guest_user exception;
3289
3290 cursor get_pwd(p_guestUserName varchar2) is
3291 select encrypted_foundation_password
3292 from fnd_user
3293 where user_name = p_guestUserName
3294 and trunc(sysdate) between start_date and
3295 nvl(end_date,trunc(sysdate));
3296 --
3297 guestEncFndPwd fnd_user.encrypted_foundation_password%type;
3298 --
3299 begin
3300 --
3301 guestUserPwd := upper(FND_WEB_SEC.GET_GUEST_USERNAME_PWD());
3302 --
3303 delim := instr(guestUserPwd,'/');
3304 --
3305 if(delim = 0) then
3306 raise bad_guest_user;
3307 else
3308 guestUserName := upper(substr(guestUserPwd,1,delim-1));
3309 guestUserPwdOnly := upper(substr(guestUserPwd,delim+1));
3310 end if;
3311 --
3312 if(fnd_web_sec.validate_login(guestUserName,guestUserPwdOnly) = 'N') then
3313 raise bad_guest_user;
3314 end if;
3315 --
3316 open get_pwd(guestUserName);
3317 fetch get_pwd into guestEncFndPwd;
3318 close get_pwd;
3319 --
3320 guestFndPwd := decrypt(guestUserPwd,guestEncFndPwd);
3321 --
3322 if(guestFndPwd is null) then
3323 raise bad_guest_user;
3324 end if;
3325 --
3326 return guestFndPwd;
3327 --
3328 exception
3329 when others then
3330 fnd_message.set_encoded('MRP'||fnd_global.local_chr(0)||
3331 'GEN-INVALID PROFILE'||fnd_global.local_chr(0)||
3332 'N'||fnd_global.local_chr(0)||
3333 'PROFILE'||fnd_global.local_chr(0)||
3334 'GUEST_USER_PWD'||fnd_global.local_chr(0)||
3335 'N'||fnd_global.local_chr(0)||
3336 'VALUE'||fnd_global.local_chr(0)||
3337 guestUserPwd||fnd_global.local_chr(0));
3338 return null;
3339 end;
3340 --
3341 -- -------------------------------------------------------------------------
3342 -- |------------------------< update_user >--------------------------------|
3343 -- -------------------------------------------------------------------------
3344 --
3345 procedure update_user (
3346 p_user_name in varchar2,
3347 p_owner in varchar2,
3348 p_unencrypted_password in varchar2 default null,
3349 p_encrypted_user_password in varchar2 default null,
3350 p_session_number in number default null,
3351 p_start_date in date default null,
3352 p_end_date in date default null,
3353 p_last_logon_date in date default null,
3354 p_description in varchar2 default null,
3355 p_password_date in date default null,
3356 p_password_accesses_left in number default null,
3357 p_password_lifespan_accesses in number default null,
3358 p_password_lifespan_days in number default null,
3359 p_employee_id in number default null,
3360 p_email_address in varchar2 default null,
3361 p_fax in varchar2 default null,
3362 p_customer_id in number default null,
3363 p_supplier_id in number default null,
3364 p_old_password in varchar2 default null) is
3365 l_new_user_name fnd_user.user_name%type;
3366 l_current_email_address fnd_user.email_address%type;
3367 l_central_registration_url varchar2(4000);
3368 --
3369 cursor csr_get_email(p_user_name varchar2) is
3370 select upper(email_address)
3371 from fnd_user
3372 where user_name = p_user_name;
3373 --
3374 begin
3375 -- get existing email address
3376 --
3377 open csr_get_email(p_user_name);
3378 fetch csr_get_email into l_current_email_address;
3379 close csr_get_email;
3380 --
3381 l_central_registration_url:=fnd_profile.value('APPS_CENTRAL_REGISTER_URL');
3382 --
3383 if l_central_registration_url is null then
3384 --
3385 fnd_user_pkg.UpdateUser (
3386 x_user_name => p_user_name,
3387 x_owner => p_owner,
3388 x_unencrypted_password => p_unencrypted_password,
3389 x_session_number => p_session_number,
3390 x_start_date => p_start_date,
3391 x_end_date => p_end_date,
3392 x_last_logon_date => p_last_logon_date,
3393 x_description => p_description,
3394 x_password_date => p_password_date,
3395 x_password_accesses_left => p_password_accesses_left,
3396 x_password_lifespan_accesses => p_password_lifespan_accesses,
3397 x_password_lifespan_days => p_password_lifespan_days,
3398 x_employee_id => p_employee_id,
3399 x_email_address => p_email_address,
3400 x_fax => p_fax,
3401 x_customer_id => p_customer_id,
3402 x_supplier_id => p_supplier_id);
3403 --
3404 end if;
3405 --
3406 -- if email address is updated then update user_name
3407 -- if the existing user_name and email_address match
3408 --
3409 l_new_user_name := upper(p_email_address);
3410 if p_user_name <> l_new_user_name
3411 and l_current_email_address = p_user_name then
3412 fnd_user_pkg.change_user_name(p_user_name,l_new_user_name);
3413 end if;
3414 end update_user;
3415 -- -------------------------------------------------------------------------
3416 -- |------------------------< self_register_user >-------------------------|
3417 -- -------------------------------------------------------------------------
3418 --
3419 procedure self_register_user
3420 (p_validate IN boolean default false
3421 ,p_current_email_address IN varchar2
3422 ,p_responsibility_id IN number
3423 ,p_resp_appl_id IN number
3424 ,p_security_group_id IN number
3425 ,p_first_name IN varchar2 default null
3426 ,p_last_name IN varchar2 default null
3427 ,p_middle_names IN varchar2 default null
3428 ,p_previous_last_name IN varchar2 default null
3429 ,p_employee_number IN varchar2 default null
3430 ,p_national_identifier IN varchar2 default null
3431 ,p_date_of_birth IN date default null
3432 ,p_email_address IN varchar2 default null
3433 ,p_home_phone_number IN varchar2 default null
3434 ,p_work_phone_number IN varchar2 default null
3435 ,p_address_line_1 IN varchar2 default null
3436 ,p_manager_last_name IN varchar2 default null
3437 ,p_allow_access IN varchar2 default null
3438 ,p_language IN varchar2 default null
3439 ,p_user_name IN varchar2 default null
3440 ) is
3441
3442 cursor email_exists is
3443 select 1 from fnd_user
3444 where user_name=upper(p_current_email_address);
3445
3446 l_date_of_birth date;
3447
3448 cursor get_prev_emp is
3449 select per1.party_id,count(*)
3450 from per_all_people_f per1
3451 where UPPER(per1.last_name)=UPPER(p_last_name)
3452 and ( UPPER(per1.first_name)=UPPER(nvl(p_first_name,per1.first_name))
3453 or (per1.first_name is null and p_first_name is null))
3454 and ( UPPER(per1.middle_names)= UPPER(nvl(p_middle_names,per1.middle_names))
3455 or (per1.middle_names is null and p_middle_names is null))
3456 and ( UPPER(per1.previous_last_name)= UPPER(nvl(p_previous_last_name,per1.previous_last_name))
3457 or (per1.previous_last_name is null and p_previous_last_name is null))
3458 and ( UPPER(per1.employee_number)= UPPER(nvl(p_employee_number,per1.employee_number))
3459 or (per1.employee_number is null and p_employee_number is null))
3460 and ( UPPER(per1.national_identifier)= UPPER(nvl(p_national_identifier,per1.national_identifier))
3461 or (per1.national_identifier is null and p_national_identifier is null))
3462 and (per1.date_of_birth=nvl(l_date_of_birth,per1.date_of_birth)
3463 or (per1.date_of_birth is null and p_date_of_birth is null))
3464 and ( UPPER(per1.email_address)= UPPER(nvl(p_email_address,per1.email_address))
3465 or (per1.email_address is null and p_email_address is null))
3466 and (p_home_phone_number is null
3467 or exists (select 1 from per_phones phns
3468 where phns.parent_id=per1.person_id
3469 and phns.parent_table='PER_ALL_PEOPLE_F'
3470 and phns.phone_type in ('H1','H2','H3')
3471 and phns.phone_number = p_home_phone_number))
3472 and (p_work_phone_number is null
3473 or exists (select 1 from per_phones phns
3474 where phns.parent_id=per1.person_id
3475 and phns.parent_table='PER_ALL_PEOPLE_F'
3476 and phns.phone_type in ('W1','W2','W3')
3477 and phns.phone_number = p_work_phone_number))
3478 and (p_address_line_1 is null
3479 or exists (select 1 from per_addresses addr
3480 where addr.person_id=per1.person_id
3481 and addr.address_type in ('H','REC','HOME')))
3482 and (p_manager_last_name is null
3483 or exists (select 1 from per_all_people_f per2
3484 ,per_all_assignments_f asg2
3485 where asg2.person_id=per1.person_id
3486 and asg2.assignment_type in ('E','C')
3487 and asg2.supervisor_id=per2.person_id
3488 and asg2.effective_start_date between per2.effective_start_date and per2.effective_end_date
3489 and UPPER(per2.last_name)=UPPER(p_manager_last_name)))
3490 and exists(SELECT 1
3491 FROM per_person_types typ
3492 ,per_person_type_usages_f ptu
3493 WHERE typ.system_person_type = 'EX_EMP'
3494 AND typ.person_type_id = ptu.person_type_id
3495 AND sysdate BETWEEN ptu.effective_start_date
3496 AND ptu.effective_end_date
3497 AND ptu.person_id = per1.person_id)
3498 group by per1.party_id;
3499
3500 l_party_id number;
3501 l_count number;
3502 l_party_id2 number;
3503 l_count2 number;
3504
3505 cursor current_emp(p_party_id number) is
3506 select 1
3507 from per_all_people_f per1
3508 where per1.party_id=p_party_id
3509 and trunc(sysdate) between per1.effective_start_date and per1.effective_end_date
3510 and current_employee_flag='Y';
3511
3512 l_dummy number;
3513
3514 cursor in_reg_bg(p_party_id number) is
3515 select per1.person_id
3516 from per_all_people_f per1
3517 where per1.party_id=p_party_id
3518 and trunc(sysdate) between per1.effective_start_date and per1.effective_end_date
3519 and per1.business_group_id = fnd_profile.value('IRC_REGISTRATION_BG_ID');
3520
3521 l_person_id number;
3522
3523 cursor has_notification_prefs(p_party_id number) is
3524 select notif.person_id
3525 from irc_notification_preferences notif
3526 where notif.party_id=p_party_id;
3527
3528 l_notif_person_id number;
3529 l_object_version_number number;
3530 l_notification_preference_id number;
3531 l_search_criteria_id number;
3532
3533 cursor has_work_prefs(p_person_id number) is
3534 select prefs.object_id
3535 from irc_search_criteria prefs
3536 where prefs.object_id=p_person_id
3537 and prefs.object_type='WPREF';
3538
3539 cursor get_last_emp_rec(p_party_id number) is
3540 select per1.person_id
3541 from per_all_people_f per1
3542 where per1.party_id=p_party_id
3543 and per1.current_employee_flag='Y'
3544 and per1.effective_start_date<sysdate
3545 order by per1.effective_end_date desc;
3546
3547 cursor get_last_per_rec(p_party_id number) is
3548 select per1.person_id
3549 from per_all_people_f per1
3550 where per1.party_id=p_party_id
3551 and per1.effective_start_date<sysdate
3552 order by per1.effective_end_date desc;
3553
3554 cursor get_bg(p_person_id number) is
3555 select per1.business_group_id
3556 ,per1.object_version_number
3557 ,per1.employee_number
3558 ,per1.effective_start_date
3559 from per_all_people_f per1
3560 where per1.person_id=p_person_id
3561 and trunc(sysdate) between per1.effective_start_date and per1.effective_end_date;
3562
3563 l_person_ovn number;
3564 l_employee_number varchar2(255);
3565 l_business_group_id number;
3566 l_ptu_person_type_id number;
3567 l_person_start_date date;
3568 l_dt_mode varchar2(30);
3569
3570 cursor ptu_exists(p_person_id number,p_person_type_id number) is
3571 select 1 from per_person_type_usages_f ptuf
3572 where ptuf.person_id=p_person_id
3573 and ptuf.person_type_id=p_person_type_id
3574 and trunc(sysdate) between ptuf.effective_start_date and ptuf.effective_end_date;
3575
3576 cursor existing_emails(p_person_id number,p_party_id number) is
3577 select fusr.user_name
3578 from fnd_user fusr
3579 where fusr.employee_id=p_person_id
3580 and trunc(sysdate) between fusr.start_date and
3581 nvl(fusr.end_date,trunc(sysdate))
3582 union
3583 select fusr.user_name
3584 from fnd_user fusr
3585 where fusr.customer_id=p_party_id
3586 and trunc(sysdate) between fusr.start_date and
3587 nvl(fusr.end_date,trunc(sysdate));
3588
3589 cursor user_association_exists(p_user_name varchar2) is
3590 select 1
3591 from fnd_user fusr
3592 where fusr.user_name=p_user_name
3593 and fusr.employee_id is not null;
3594
3595 cursor get_user_id(p_user_name varchar2) is
3596 select fusr.user_id
3597 from fnd_user fusr
3598 where fusr.user_name=p_user_name;
3599 --
3600 cursor get_menu_id (p_menu_name varchar2)is
3601 select menu_id from fnd_menus where menu_name=upper(p_menu_name);
3602 --
3603 cursor get_party_id(p_user_name varchar2) is
3604 select fusr.person_party_id
3605 from fnd_user fusr
3606 where fusr.user_name=p_user_name;
3607 --
3608 l_user_id number;
3609 l_profile_check boolean;
3610 l_sec_profile_assignment_id number;
3611 l_business_group_id2 number;
3612 l_sec_profile_id number;
3613 l_password varchar2(30);
3614 l_effective_start_date date;
3615 l_effective_end_date date;
3616 l_full_name per_all_people_f.full_name%type;
3617 l_comment_id number;
3618 l_name_combination_warning boolean;
3619 l_assign_payroll_warning boolean;
3620 l_orig_hire_warning boolean;
3621 l_nid number;
3622 l_subject varchar2(32000);
3623 l_html_body varchar2(32000);
3624 l_text_body varchar2(32000);
3625 l_passchar varchar2(1);
3626 l_oldpasschar varchar2(1);
3627 l_num number;
3628 l_function_name varchar2(30);
3629 l_func_check varchar2(1);
3630 l_menu_name varchar2(30);
3631 l_menu_id number;
3632 l_grant_name varchar2(80);
3633 l_resp_exists boolean;
3634 l_allow_access irc_notification_preferences.allow_access%type;
3635 l_sso_enabled varchar2(30);
3636 l_central_registration_url varchar2(4000);
3637 l_purge_party_id number;
3638 --
3639 cursor get_nls_language is
3640 select nls_language
3641 from fnd_languages
3642 where language_code=p_language;
3643 --
3644 l_nls_language fnd_languages.nls_language%type;
3645 --
3646 l_proc varchar2(72) := g_package||'self_register_user';
3647 --
3648 l_password_length number;
3649 l_min_password_length number := 8;
3650 --
3651 -- for disabling the descriptive flex field
3652 l_add_struct_d hr_dflex_utility.l_ignore_dfcode_varray :=
3653 hr_dflex_utility.l_ignore_dfcode_varray();
3654 --
3655 begin
3656
3657 hr_utility.set_location(' Entering: '||l_proc, 10);
3658 --
3659 -- Issue a savepoint
3660 --
3661 savepoint SELF_REGISTER_USER;
3662 --
3663 -- Truncate the time portion from all IN date parameters
3664 --
3665 l_date_of_birth := trunc(p_date_of_birth);
3666 --
3667 -- default Allow Access if input value is NULL
3668 --
3669 if p_allow_access is NULL then
3670 l_allow_access := nvl(fnd_profile.value_specific
3671 (name=>'IRC_VISIBLE_PREF_DEFAULT'
3672 ,responsibility_id=>p_responsibility_id
3673 ,application_id=>p_resp_appl_id), 'N');
3674 else
3675 l_allow_access := p_allow_access;
3676 end if;
3677 --
3678 -- Call Before Process User Hook
3679 --
3680 begin
3681 IRC_PARTY_BK6.SELF_REGISTER_USER_B
3682 (p_current_email_address => p_current_email_address
3683 ,p_responsibility_id => p_responsibility_id
3684 ,p_resp_appl_id => p_resp_appl_id
3685 ,p_security_group_id => p_security_group_id
3686 ,p_first_name => p_first_name
3687 ,p_last_name => p_last_name
3688 ,p_middle_names => p_middle_names
3689 ,p_previous_last_name => p_previous_last_name
3690 ,p_employee_number => p_employee_number
3691 ,p_national_identifier => p_national_identifier
3692 ,p_date_of_birth => l_date_of_birth
3693 ,p_email_address => p_email_address
3694 ,p_home_phone_number => p_home_phone_number
3695 ,p_work_phone_number => p_work_phone_number
3696 ,p_address_line_1 => p_address_line_1
3697 ,p_manager_last_name => p_manager_last_name
3698 ,p_allow_access => l_allow_access
3699 ,p_language => p_language
3700 ,p_user_name => p_user_name
3701 );
3702 exception
3703 when hr_api.cannot_find_prog_unit then
3704 hr_api.cannot_find_prog_unit_error
3705 (p_module_name => 'SELF_REGISTER_USER'
3706 ,p_hook_type => 'BP'
3707 );
3708 end;
3709 hr_utility.set_location(l_proc,20);
3710 --
3711 -- Process Logic
3712 -- code for disabling the descriptive flex field
3713 --
3714 l_add_struct_d.extend(1);
3715 l_add_struct_d(l_add_struct_d.count) := 'IRC_SEARCH_CRITERIA';
3716 l_add_struct_d.extend(1);
3717 l_add_struct_d(l_add_struct_d.count) := 'IRC_SEARCH_CRITERIA_DDF';
3718 l_add_struct_d.extend(1);
3719 l_add_struct_d(l_add_struct_d.count) := 'IRC_NOTIFICATION_PREFERENCES';
3720 l_add_struct_d.extend(1);
3721 l_add_struct_d(l_add_struct_d.count) := 'PER_PEOPLE';
3722 l_add_struct_d.extend(1);
3723 l_add_struct_d(l_add_struct_d.count) := 'Person Developer DF';
3724 --
3725 hr_dflex_utility.create_ignore_df_validation(p_rec => l_add_struct_d);
3726 --
3727 hr_utility.set_location(l_proc, 21);
3728 --
3729 --
3730 -- Process Logic
3731 --
3732 if p_user_name is null then
3733 --
3734 hr_utility.set_location(l_proc || ' p_user_name is null.',22);
3735 -- use the FND API to determine if a user exists with the same user name
3736 hr_utility.set_location(l_proc,23);
3737 l_num := TestUserName(p_user_name=>upper(p_current_email_address));
3738 if l_num = 2 or l_num = 4 then
3739 -- the e-mail address is already in use. Raise an error
3740 fnd_message.set_name('PER','IRC_EXEMP_EMAIL_IN_USE');
3741 fnd_message.raise_error;
3742 elsif l_num = 3 then
3743 fnd_message.set_name('PER','IRC_412220_USER_SYNCH_MSG');
3744 fnd_message.raise_error;
3745 elsif l_num = 1 then
3746 fnd_message.set_name('FND','INVALID_USER_NAME');
3747 fnd_message.set_token('UNAME',p_current_email_address);
3748 fnd_message.raise_error;
3749 end if;
3750 else
3751 hr_utility.set_location(l_proc|| ' p_user_name is not null.',23);
3752 -- check if the user account is already associated to a person
3753 open user_association_exists(p_user_name);
3754 fetch user_association_exists into l_dummy;
3755 if user_association_exists%found then
3756 close user_association_exists;
3757 fnd_message.set_name('PER','IRC_EXEMP_PERSON_LINK_EXISTS');
3758 fnd_message.raise_error;
3759 else
3760 close user_association_exists;
3761 end if;
3762 end if;
3763 hr_utility.set_location(l_proc,30);
3764
3765 open get_prev_emp;
3766 fetch get_prev_emp into l_party_id,l_count;
3767 if get_prev_emp%notfound then
3768 hr_utility.set_location(l_proc, 31);
3769 -- we have not found a match at all, so error out
3770 close get_prev_emp;
3771 fnd_message.set_name('PER','IRC_EXEMP_NO_RECORD_FOUND');
3772 fnd_message.raise_error;
3773 end if;
3774 hr_utility.set_location(l_proc,40);
3775
3776 fetch get_prev_emp into l_party_id2,l_count2;
3777 if get_prev_emp%found then
3778 -- we have found more than one match, so error out
3779 close get_prev_emp;
3780 fnd_message.set_name('PER','IRC_EXEMP_MANY_RECORDS_FOUND');
3781 fnd_message.raise_error;
3782 end if;
3783 close get_prev_emp;
3784 hr_utility.set_location(l_proc,50);
3785
3786 -- we have only one match, so check their credentials.
3787 open current_emp(l_party_id);
3788 fetch current_emp into l_dummy;
3789 if current_emp%found then
3790 close current_emp;
3791 hr_utility.set_location(l_proc,51);
3792 -- the person is a current employee, so error
3793 fnd_message.set_name('PER','IRC_EXEMP_CURRENT_EMP');
3794 fnd_message.raise_error;
3795 end if;
3796 close current_emp;
3797 --
3798 hr_utility.set_location(l_proc,60);
3799 --
3800 -- the person is not a current employee, so good to go.
3801 -- look to see if they have any notification preferences already
3802 open has_notification_prefs(l_party_id);
3803 fetch has_notification_prefs into l_person_id;
3804 if has_notification_prefs%found then
3805 hr_utility.set_location(l_proc,61);
3806 close has_notification_prefs;
3807 -- we have notification preferences already for this person, so use that as
3808 -- the primary person
3809 else
3810 close has_notification_prefs;
3811 hr_utility.set_location(l_proc,70);
3812 open in_reg_bg(l_party_id);
3813 fetch in_reg_bg into l_person_id;
3814 if in_reg_bg%found then
3815 close in_reg_bg;
3816 -- the person exists in the registration business group, so use that
3817 -- as the primary person record
3818 else
3819 close in_reg_bg;
3820 hr_utility.set_location(l_proc,80);
3821
3822 -- the person is not in the registration business group, look to
3823 -- find their last employee record
3824 open get_last_emp_rec(l_party_id);
3825 fetch get_last_emp_rec into l_person_id;
3826 if get_last_emp_rec%notfound then
3827 --could not find an old employee record, so find the last record
3828 close get_last_emp_rec;
3829 hr_utility.set_location(l_proc,90);
3830
3831 open get_last_per_rec(l_party_id);
3832 fetch get_last_per_rec into l_person_id;
3833 close get_last_per_rec;
3834 else
3835 close get_last_emp_rec;
3836 end if;
3837 end if;
3838 -- we have gone through all of the options, and found the best person_id
3839 -- for this person, so now create their notification preferences
3840 hr_utility.set_location(l_proc,100);
3841
3842 irc_notification_prefs_api.create_notification_prefs
3843 (p_validate => p_validate
3844 ,p_person_id => l_person_id
3845 ,p_effective_date => trunc(sysdate)
3846 ,p_notification_preference_id => l_notification_preference_id
3847 ,p_object_version_number => l_object_version_number
3848 ,p_allow_access => l_allow_access);
3849
3850 end if;
3851 hr_utility.set_location(l_proc,110);
3852
3853 -- look for work preferences for the person
3854 open has_work_prefs(l_person_id);
3855 fetch has_work_prefs into l_dummy;
3856 if has_work_prefs%notfound then
3857 -- no work preferences, so create some
3858 close has_work_prefs;
3859 --
3860 hr_utility.set_location(l_proc,120);
3861
3862 irc_search_criteria_api.create_work_choices
3863 (p_validate => p_validate
3864 ,p_effective_date => trunc(sysdate)
3865 ,p_person_id => l_person_id
3866 ,p_employee => 'Y'
3867 ,p_contractor => 'Y'
3868 ,p_object_version_number => l_object_version_number
3869 ,p_search_criteria_id => l_search_criteria_id);
3870 else
3871 close has_work_prefs;
3872 end if;
3873
3874 -- get the PTU person type for iRecruitment Candidate
3875 --
3876 hr_utility.set_location(l_proc,130);
3877 --
3878 open get_bg(l_person_id);
3879 fetch get_bg into l_business_group_id
3880 ,l_person_ovn
3881 ,l_employee_number
3882 ,l_person_start_date;
3883 close get_bg;
3884
3885 l_ptu_person_type_id:=hr_person_type_usage_info.get_default_person_type_id
3886 (l_business_group_id,
3887 'IRC_REG_USER');
3888 open ptu_exists(l_person_id,l_ptu_person_type_id);
3889 fetch ptu_exists into l_dummy;
3890 if ptu_exists%notfound then
3891 close ptu_exists;
3892 hr_utility.set_location(l_proc,140);
3893
3894 hr_per_type_usage_internal.maintain_person_type_usage
3895 (p_effective_date => trunc(sysdate)
3896 ,p_person_id => l_person_id
3897 ,p_person_type_id => l_ptu_person_type_id
3898 );
3899 else
3900 close ptu_exists;
3901 end if;
3902 --
3903 hr_utility.set_location(l_proc,145);
3904 --
3905 if trunc(sysdate)=l_person_start_date then
3906 l_dt_mode:='CORRECTION';
3907 else
3908 l_dt_mode:='UPDATE';
3909 end if;
3910 -- now update the person record to set the e-mail address
3911 hr_person_api.update_person
3912 (p_validate => p_validate
3913 ,p_effective_date => trunc(sysdate)
3914 ,p_datetrack_update_mode => l_dt_mode
3915 ,p_person_id => l_person_id
3916 ,p_employee_number => l_employee_number
3917 ,p_email_address => p_current_email_address
3918 ,p_object_version_number => l_person_ovn
3919 ,p_effective_start_date => l_effective_start_date
3920 ,p_effective_end_date => l_effective_end_date
3921 ,p_full_name => l_full_name
3922 ,p_comment_id => l_comment_id
3923 ,p_name_combination_warning => l_name_combination_warning
3924 ,p_assign_payroll_warning => l_assign_payroll_warning
3925 ,p_orig_hire_warning => l_orig_hire_warning
3926 );
3927 --
3928 -- Raise error before creating user as data is getting committed to OID.
3929 --
3930 if p_validate then
3931 raise hr_api.validate_enabled;
3932 end if;
3933 --
3934 -- close off the old user accounts for this person
3935 --
3936 hr_utility.set_location(l_proc,150);
3937
3938 for user_rec in existing_emails(l_person_id,l_party_id) loop
3939 fnd_user_pkg.disableUser(user_rec.user_name);
3940 end loop;
3941 --
3942 -- Get the Password Length from the profile
3943 --
3944 begin
3945 if fnd_profile.value('SIGNON_PASSWORD_LENGTH') is not null then
3946 l_password_length := fnd_profile.value('SIGNON_PASSWORD_LENGTH');
3947 else
3948 l_password_length := l_min_password_length;
3949 end if;
3950 exception
3951 when others then
3952 l_password_length := l_min_password_length;
3953 end;
3954 --
3955 -- Ensure password length is minumum of 8
3956 --
3957 if ( l_password_length < l_min_password_length ) then
3958 l_password_length := l_min_password_length;
3959 end if;
3960 --
3961 --
3962 -- create the new user account
3963 --
3964 if p_user_name is null then
3965 --
3966 -- if comply with 'hard to guess password' and pwd length set, the logic is
3967 -- 1. generate the pwd of length as 'SIGNON_PASSWORD_LENGTH'
3968 -- 2. ensure that must contain at least 1 number
3969 -- 3. there are no consecutive repeating characts like 'AA1' or X22C'
3970 --
3971
3972
3973 -- l_oldpasschar:=floor(dbms_random.value(0,9));
3974 -- the following line has an ATG CU3 dependency. If you need to update and
3975 -- release the patch before that, comment it out and replace with the line above
3976
3977 l_oldpasschar:=mod(fnd_crypto.randomnumber,10);
3978 l_password:=l_oldpasschar;
3979
3980 loop
3981 --l_passchar:=dbms_random.string('U',1);
3982 -- the following line has an ATG CU3 dependency. If you need to update and
3983 -- release the patch before that, comment it out and replace with the line above
3984
3985 l_passchar:=fnd_crypto.RandomString(len=>1);
3986 if (l_passchar<>l_oldpasschar) then
3987 l_password:=l_password||l_passchar;
3988 l_oldpasschar:=l_passchar;
3989 end if;
3990 if length(l_password)=l_password_length then
3991 exit;
3992 end if;
3993 end loop;
3994
3995 hr_utility.set_location(l_proc,160);
3996
3997 l_user_id := fnd_user_pkg.CreateUserId (
3998 x_user_name => upper(p_current_email_address),
3999 x_owner => 'CUST',
4000 x_unencrypted_password => l_password,
4001 x_employee_id => l_person_id);
4002
4003 else
4004 -- associate the previous employee record to the fnd user
4005 hr_utility.set_location(l_proc,165);
4006 open get_party_id(p_user_name =>p_user_name) ;
4007 fetch get_party_id into l_purge_party_id;
4008 close get_party_id;
4009 hr_utility.set_location(l_proc,166);
4010 --
4011 fnd_user_pkg.UpdateUserParty(
4012 x_user_name => p_user_name,
4013 x_owner => 'CUST',
4014 x_person_party_id => l_party_id);
4015 --
4016 fnd_user_pkg.UpdateUser(
4017 x_user_name => p_user_name,
4018 x_owner => 'CUST',
4019 x_employee_id => l_person_id);
4020 --
4021 hr_utility.set_location(l_proc,167);
4022
4023 if l_purge_party_id is not null then
4024 hr_utility.set_location(l_proc,168);
4025 per_hrtca_merge.purge_person(p_person_id=>-1 ,p_party_id=>l_purge_party_id );
4026 end if;
4027 hr_utility.set_location(l_proc,169);
4028 -- get the user ID for the given user name
4029 open get_user_id(p_user_name);
4030 fetch get_user_id into l_user_id;
4031 close get_user_id;
4032 end if;
4033 --
4034 -- get NLS_LANGUAGE
4035 --
4036 open get_nls_language;
4037 fetch get_nls_language into l_nls_language;
4038 if get_nls_language%notfound then
4039 close get_nls_language;
4040 l_nls_language:=p_language;
4041 else
4042 close get_nls_language;
4043 end if;
4044
4045 -- set the language prefs if required
4046 if (p_language is not null) then
4047 l_profile_check := fnd_profile.save (
4048 x_name => 'ICX_LANGUAGE',
4049 x_value => l_nls_language,
4050 x_level_name => 'USER',
4051 x_level_value => l_user_id );
4052 end if;
4053 hr_utility.set_location(l_proc,170);
4054 -- If this is an existing user, check if he has the required responsibility
4055 if p_user_name is null then
4056 l_resp_exists := false;
4057 else
4058 hr_utility.set_location(l_proc,175);
4059 l_resp_exists := fnd_user_resp_groups_api.Assignment_Exists(l_user_id,
4060 p_responsibility_id, p_resp_appl_id, p_security_group_id);
4061 end if;
4062 -- if the User doesn't have the responsibility, assign it.
4063 if NOT l_resp_exists then
4064 --
4065 -- add the appropriate responsibility
4066 --
4067 fnd_user_resp_groups_api.Insert_Assignment
4068 (user_id => l_user_id
4069 ,responsibility_id => p_responsibility_id
4070 ,responsibility_application_id => p_resp_appl_id
4071 ,security_group_id => p_security_group_id
4072 ,start_date => trunc(sysdate)
4073 ,end_date => null
4074 ,description => ' ' -- ### description was supposed to default
4075 -- to null... but does not look like it has
4076 );
4077 hr_utility.set_location(l_proc,180);
4078 --
4079 -- look to see if we are using multiple security groups
4080 --
4081 if (fnd_profile.value('ENABLE_SECURITY_GROUPS')='Y') then
4082 hr_utility.set_location(l_proc,190);
4083 l_sec_profile_id:=fnd_profile.value_specific
4084 (name=>'PER_SECURITY_PROFILE_ID'
4085 ,user_id=>l_user_id
4086 ,responsibility_id=>p_responsibility_id
4087 ,application_id=>p_resp_appl_id);
4088 l_business_group_id2:=fnd_profile.value_specific
4089 (name=>'PER_BUSINESS_GROUP_ID'
4090 ,user_id=>l_user_id
4091 ,responsibility_id=>p_responsibility_id
4092 ,application_id=>p_resp_appl_id);
4093 --
4094 hr_utility.set_location(l_proc,200);
4095 per_sec_profile_asg_api.create_security_profile_asg
4096 (p_sec_profile_assignment_id => l_sec_profile_assignment_id
4097 ,p_user_id => l_user_id
4098 ,p_security_group_id => p_security_group_id
4099 ,p_business_group_id => l_business_group_id2
4100 ,p_security_profile_id => l_sec_profile_id
4101 ,p_responsibility_id => p_responsibility_id
4102 ,p_responsibility_application_i => p_resp_appl_id
4103 ,p_start_date => trunc(sysdate)
4104 ,p_object_version_number => l_object_version_number
4105 );
4106 end if;
4107 else
4108 hr_utility.set_location(l_proc, 205);
4109 --
4110 -- reopen the candidate responsibility
4111 --
4112 fnd_user_resp_groups_api.Update_Assignment
4113 (user_id => l_user_id
4114 ,responsibility_id => p_responsibility_id
4115 ,responsibility_application_id => p_resp_appl_id
4116 ,security_group_id => p_security_group_id
4117 ,start_date => trunc(sysdate)
4118 ,end_date => null
4119 ,description => ' ' -- ### description was supposed to default
4120 -- to null... but does not look like it has
4121 );
4122 -- REVISIT, what about Security Profile Assignment
4123 end if;
4124 --
4125 hr_utility.set_location(l_proc,210);
4126 --
4127 -- now send an e-mail to the user confirming that this has been done
4128 --
4129 hr_utility.set_location(l_proc,220);
4130 l_sso_enabled:=fnd_profile.value('APPS_SSO');
4131
4132 l_central_registration_url:=fnd_profile.value('APPS_CENTRAL_REGISTER_URL');
4133
4134 l_nid:=wf_notification.send( upper(p_current_email_address)
4135 , fnd_profile.value('IRC_WORKFLOW_ITEM_TYPE')
4136 , 'IRC_TEXT_HTML_MSG'
4137 );
4138 --
4139 fnd_message.set_name('PER','IRC_EXEMP_SUBJECT');
4140 l_subject:=fnd_message.get;
4141 wf_notification.setAttrText ( l_nid , 'SUBJECT' , l_subject);
4142
4143 if p_user_name is null
4144 and (l_sso_enabled<>'SSWA_SSO' and l_sso_enabled<>'SSO_SDK') then
4145 fnd_message.set_name('PER','IRC_EXEMP_HTML');
4146 elsif l_central_registration_url is not null then
4147 fnd_message.set_name('PER','IRC_EXEMP_REGISTERED_HTML');
4148 else
4149 fnd_message.set_name('PER','IRC_412581_EXEMP_SSO_REG_HTML');
4150 end if;
4151 l_html_body:=fnd_message.get;
4152
4153 if p_user_name is null
4154 and (l_sso_enabled<>'SSWA_SSO' and l_sso_enabled<>'SSO_SDK') then
4155 fnd_message.set_name('PER','IRC_EXEMP_HTML');
4156 elsif l_central_registration_url is not null then
4157 fnd_message.set_name('PER','IRC_EXEMP_REGISTERED_HTML');
4158 else
4159 fnd_message.set_name('PER','IRC_412581_EXEMP_SSO_REG_HTML');
4160 end if;
4161
4162 if (instrb(l_html_body,'&'||'PASSWORD')>0) then
4163 fnd_message.set_token('PASSWORD', l_password);
4164 end if;
4165 if (instrb(l_html_body,'&'||'FIRST_NAME')>0) then
4166 fnd_message.set_token('FIRST_NAME', p_first_name);
4167 end if;
4168 if (instrb(l_html_body,'&'||'LAST_NAME')>0) then
4169 fnd_message.set_token('LAST_NAME', p_last_name);
4170 end if;
4171 if (instrb(l_html_body,'&'||'EMAIL')>0) then
4172 fnd_message.set_token('EMAIL', p_current_email_address);
4173 end if;
4174 if (instrb(l_html_body,'&'||'USER_NAME')>0) then
4175 fnd_message.set_token('USER_NAME', p_user_name);
4176 end if;
4177 l_html_body:=fnd_message.get;
4178 irc_notification_helper_pkg.set_v2_attributes
4179 (p_wf_attribute_value => l_html_body
4180 ,p_wf_attribute_name => 'HTML_BODY'
4181 ,p_nid => l_nid);
4182
4183
4184 if p_user_name is null
4185 and (l_sso_enabled<>'SSWA_SSO' and l_sso_enabled<>'SSO_SDK') then
4186 fnd_message.set_name('PER','IRC_EXEMP_TEXT');
4187 elsif l_central_registration_url is not null then
4188 fnd_message.set_name('PER','IRC_EXEMP_REGISTERED_TEXT');
4189 else
4190 fnd_message.set_name('PER','IRC_412582_EXEMP_SSO_REG_TEXT');
4191 end if;
4192
4193 l_text_body:=fnd_message.get;
4194
4195 if p_user_name is null
4196 and (l_sso_enabled<>'SSWA_SSO' and l_sso_enabled<>'SSO_SDK') then
4197 fnd_message.set_name('PER','IRC_EXEMP_TEXT');
4198 elsif l_central_registration_url is not null then
4199 fnd_message.set_name('PER','IRC_EXEMP_REGISTERED_TEXT');
4200 else
4201 fnd_message.set_name('PER','IRC_412582_EXEMP_SSO_REG_TEXT');
4202 end if;
4203
4204 if (instrb(l_text_body,'&'||'PASSWORD')>0) then
4205 fnd_message.set_token('PASSWORD', l_password);
4206 end if;
4207 if (instrb(l_text_body,'&'||'FIRST_NAME')>0) then
4208 fnd_message.set_token('FIRST_NAME', p_first_name);
4209 end if;
4210 if (instrb(l_text_body,'&'||'LAST_NAME')>0) then
4211 fnd_message.set_token('LAST_NAME', p_last_name);
4212 end if;
4213 if (instrb(l_text_body,'&'||'EMAIL')>0) then
4214 fnd_message.set_token('EMAIL', p_current_email_address);
4215 end if;
4216 if (instrb(l_text_body,'&'||'USER_NAME')>0) then
4217 fnd_message.set_token('USER_NAME', p_user_name);
4218 end if;
4219 l_text_body:=fnd_message.get;
4220 irc_notification_helper_pkg.set_v2_attributes
4221 (p_wf_attribute_value => l_text_body
4222 ,p_wf_attribute_name => 'TEXT_BODY'
4223 ,p_nid => l_nid);
4224 wf_notification.denormalize_notification(l_nid);
4225 hr_utility.set_location(l_proc,230);
4226 --
4227 -- Call After Process User Hook
4228 --
4229 begin
4230 IRC_PARTY_BK6.SELF_REGISTER_USER_A
4231 (p_current_email_address => p_current_email_address
4232 ,p_responsibility_id => p_responsibility_id
4233 ,p_resp_appl_id => p_resp_appl_id
4234 ,p_security_group_id => p_security_group_id
4235 ,p_first_name => p_first_name
4236 ,p_last_name => p_last_name
4237 ,p_middle_names => p_middle_names
4238 ,p_previous_last_name => p_previous_last_name
4239 ,p_employee_number => p_employee_number
4240 ,p_national_identifier => p_national_identifier
4241 ,p_date_of_birth => l_date_of_birth
4242 ,p_email_address => p_email_address
4243 ,p_home_phone_number => p_home_phone_number
4244 ,p_work_phone_number => p_work_phone_number
4245 ,p_address_line_1 => p_address_line_1
4246 ,p_manager_last_name => p_manager_last_name
4247 ,p_allow_access => l_allow_access
4248 ,p_language => p_language
4249 ,p_user_name => p_user_name
4250 );
4251 exception
4252 when hr_api.cannot_find_prog_unit then
4253 hr_api.cannot_find_prog_unit_error
4254 (p_module_name => 'SELF_REGISTER_USER'
4255 ,p_hook_type => 'AP'
4256 );
4257 end;
4258 --
4259 -- When IN validation only mode raise the Validate_Enabled exception
4260 --
4261 if p_validate then
4262 raise hr_api.validate_enabled;
4263 end if;
4264 hr_utility.set_location(' Leaving:'||l_proc, 240);
4265
4266 exception
4267 when hr_api.validate_enabled then
4268 --
4269 -- As the Validate_Enabled exception has been raised
4270 -- we must rollback to the savepoint
4271 --
4272 rollback to SELF_REGISTER_USER;
4273 --
4274 hr_utility.set_location(' Leaving:'||l_proc, 250);
4275 when others then
4276 --
4277 -- A validation or unexpected error has occured
4278 --
4279 rollback to SELF_REGISTER_USER;
4280 --
4281 --
4282 hr_utility.set_location(' Leaving:'||l_proc, 260);
4283 raise;
4284
4285 end self_register_user;
4286
4287 -- -------------------------------------------------------------------------
4288 -- |------------------------< create_partial_user >-------------------------|
4289 -- -------------------------------------------------------------------------
4290 --
4291 PROCEDURE create_partial_user
4292 (p_user_name IN varchar2
4293 ,p_start_date IN date default null
4294 ,p_email IN varchar2 default null
4295 ,p_language IN varchar2 default null
4296 ,p_last_name IN varchar2 default null
4297 ,p_first_name IN varchar2 default null
4298 ,p_reg_bg_id IN number
4299 ,p_responsibility_id IN number
4300 ,p_resp_appl_id IN number
4301 ,p_security_group_id IN number
4302 ,p_allow_access IN varchar2 default null
4303 )is
4304 --
4305 l_allow_access irc_notification_preferences.allow_access%type;
4306 l_start_date date;
4307 --
4308 cursor get_nls_language is
4309 select nls_language
4310 from fnd_languages
4311 where language_code=p_language;
4312 --
4313 l_user_id number;
4314 l_person_id number;
4315 l_person_party_id number;
4316 l_first_name per_all_people_f.first_name%type;
4317 l_last_name per_all_people_f.last_name%type;
4318 l_email_address per_all_people_f.email_address%type;
4319 l_default_last_name per_all_people_f.last_name%type;
4320 --
4321 cursor get_person_party_info is
4322 select user_id, employee_id, person_party_id
4323 from fnd_user
4324 where user_name=upper(p_user_name);
4325 --
4326 cursor get_email_address is
4327 select nvl(fu.email_address, hzp.email_address)
4328 from fnd_user fu, hz_parties hzp
4329 where user_name=upper(p_user_name)
4330 and fu.person_party_id=hzp.party_id(+);
4331 --
4332 cursor get_notif_prefs(p_party_id number) is
4333 select notification_preference_id
4334 from irc_notification_preferences
4335 where party_id=p_party_id;
4336 --
4337 cursor get_bg(p_person_id number) is
4338 select per1.business_group_id,per1.object_version_number,per1.employee_number
4339 ,per1.effective_start_date
4340 from per_all_people_f per1
4341 where per1.person_id=p_person_id
4342 and trunc(sysdate) between per1.effective_start_date and per1.effective_end_date;
4343 --
4344 cursor ptu_exists(p_person_id number,p_person_type_id number) is
4345 select 1 from per_person_type_usages_f ptuf
4346 where ptuf.person_id=p_person_id
4347 and ptuf.person_type_id=p_person_type_id
4348 and trunc(sysdate) between ptuf.effective_start_date and ptuf.effective_end_date;
4349 --
4350 cursor get_menu_id (p_menu_name varchar2)is
4351 select menu_id from fnd_menus where menu_name=upper(p_menu_name);
4352 --
4353 l_nls_language fnd_languages.nls_language%type;
4354 --
4355 --
4356 -- dummy variables
4357 --
4358 l_tmp_resp_id number;
4359 l_object_version_number per_all_people_f.object_version_number%type;
4360 l_effective_start_date per_all_people_f.effective_start_date%type;
4361 l_effective_end_date per_all_people_f.effective_end_date%type;
4362 l_new_person_id PER_ALL_PEOPLE_F.PERSON_ID%TYPE;
4363 l_profile_check boolean;
4364 l_search_criteria_id number;
4365 l_sc_ovn number;
4366 l_notif_preference_id number;
4367 l_notif_ovn number;
4368 l_per_type varchar2(100);
4369 l_sec_profile_assignment_id number;
4370 l_business_group_id number;
4371 l_sec_profile_id number;
4372 l_ovn number;
4373 l_ptu_person_type_id number;
4374 l_pers_business_group_id number;
4375 l_person_ovn number;
4376 l_employee_number varchar2(255);
4377 l_person_start_date date;
4378 l_dt_mode varchar2(30);
4379 l_full_name per_all_people_f.full_name%type;
4380 l_comment_id number;
4381 l_name_combination_warning boolean;
4382 l_assign_payroll_warning boolean;
4383 l_orig_hire_warning boolean;
4384 l_resp_exists boolean;
4385 l_dummy number;
4386 l_function_name varchar2(30);
4387 l_func_check varchar2(1);
4388 l_menu_name varchar2(30);
4389 l_menu_id number;
4390 l_grant_name varchar2(80);
4391 --
4392 l_proc varchar2(72) := g_package||'create_partial_user';
4393 --
4394 begin
4395 hr_utility.set_location(' Entering: '||l_proc, 10);
4396 --
4397 -- Truncate time portion from date
4398 --
4399 l_start_date := trunc(p_start_date);
4400 --
4401 -- get NLS_LANGUAGE
4402 --
4403 open get_nls_language;
4404 fetch get_nls_language into l_nls_language;
4405 if get_nls_language%notfound then
4406 close get_nls_language;
4407 l_nls_language:=p_language;
4408 else
4409 close get_nls_language;
4410 end if;
4411 --
4412 hr_utility.set_location(l_proc, 20);
4413 --
4414 -- default Allow Access if input value is NULL
4415 --
4416 l_allow_access := nvl(p_allow_access,nvl(fnd_profile.value('IRC_VISIBLE_PREF_DEFAULT'),'N'));
4417 --
4418 open get_person_party_info;
4419 fetch get_person_party_info into l_user_id, l_person_id, l_person_party_id;
4420 close get_person_party_info;
4421 --
4422 -- if input email address is not null, use it rather than one from fnd_user
4423 --
4424 if p_email is not null then
4425 l_email_address := p_email;
4426 else
4427 -- if input email is NULL, try getting it from FND_USER
4428 -- and if it is NULL try getting it from HZ_PARTIES
4429 -- and if that is NULL, use the UserName
4430 open get_email_address;
4431 fetch get_email_address into l_email_address;
4432 close get_email_address;
4433
4434 if l_email_address is null then
4435 l_email_address := p_user_name;
4436 end if;
4437 end if;
4438 --
4439 hr_utility.set_location(l_proc, 30);
4440 -- Disable Partial Registration for Employees
4441 -- we have to REVISIT after using UMX support for Registration
4442 if l_person_id is not null then
4443 l_per_type := irc_utilities_pkg.get_emp_spt_for_person(l_person_id, trunc(p_start_date));
4444 if (l_per_type = 'EMP') then
4445 fnd_message.set_name('PER','IRC_412224_EMP_PARTIAL_REG');
4446 fnd_message.raise_error;
4447 end if;
4448 end if;
4449 --
4450 hr_utility.set_location(l_proc, 40);
4451 --intialize the first name
4452 l_first_name := p_first_name;
4453 -- there is no person attached to this FND_USER. We need to create a new
4454 -- iRecruitment Candidate, update FND user with the person_id,
4455 -- set Language profile and Create Work Preferences
4456 if l_person_id is NULL then
4457 l_default_last_name := nvl(p_last_name,fnd_message.get_string('PER','IRC_412108_UNKNOWN_NAME'));
4458
4459 IRC_PARTY_API.CREATE_CANDIDATE_INTERNAL
4460 (p_business_group_id => p_reg_bg_id
4461 ,p_last_name => l_default_last_name
4462 ,p_first_name => l_first_name
4463 ,p_email_address => l_email_address
4464 ,p_allow_access => l_allow_access
4465 ,p_effective_start_date => l_effective_start_date
4466 ,p_effective_end_date => l_effective_end_date
4467 ,p_person_id => l_person_id
4468 ,p_party_id => l_person_party_id
4469 ,p_start_date => l_start_date
4470 );
4471 --
4472 hr_utility.set_location(l_proc, 50);
4473 --
4474 fnd_user_pkg.UpdateUser
4475 (x_user_name => p_user_name
4476 ,x_owner => 'CUST'
4477 ,x_employee_id => l_person_id);
4478 --
4479 hr_utility.set_location(l_proc, 60);
4480 --
4481 l_profile_check := fnd_profile.save (
4482 x_name => 'ICX_LANGUAGE',
4483 x_value => l_nls_language,
4484 x_level_name => 'USER',
4485 x_level_value => l_user_id );
4486 --
4487 hr_utility.set_location(l_proc, 70);
4488 --
4489 -- create work preferences
4490 irc_search_criteria_api.create_work_choices
4491 (p_effective_date=>trunc(sysdate)
4492 ,p_person_id =>l_person_id
4493 ,p_employee=>'Y'
4494 ,p_contractor=>'Y'
4495 ,p_object_version_number=>l_sc_ovn
4496 ,p_search_criteria_id=>l_search_criteria_id);
4497 --
4498 hr_utility.set_location(l_proc, 80);
4499 else
4500 hr_utility.set_location(l_proc, 45);
4501 open get_bg(l_person_id);
4502 fetch get_bg into l_pers_business_group_id, l_person_ovn,
4503 l_employee_number,l_person_start_date;
4504 close get_bg;
4505 if trunc(sysdate)=l_person_start_date then
4506 l_dt_mode:='CORRECTION';
4507 else
4508 l_dt_mode:='UPDATE';
4509 end if;
4510 -- update the person record with the email address
4511 hr_person_api.update_person
4512 (p_validate => false
4513 ,p_effective_date => trunc(sysdate)
4514 ,p_datetrack_update_mode => l_dt_mode
4515 ,p_person_id => l_person_id
4516 ,p_object_version_number => l_person_ovn
4517 ,p_employee_number => l_employee_number
4518 ,p_email_address => l_email_address
4519 ,p_effective_start_date => l_effective_start_date
4520 ,p_effective_end_date => l_effective_end_date
4521 ,p_full_name => l_full_name
4522 ,p_comment_id => l_comment_id
4523 ,p_name_combination_warning => l_name_combination_warning
4524 ,p_assign_payroll_warning => l_assign_payroll_warning
4525 ,p_orig_hire_warning => l_orig_hire_warning
4526 );
4527 --
4528 l_ptu_person_type_id:=hr_person_type_usage_info.get_default_person_type_id
4529 (l_pers_business_group_id, 'IRC_REG_USER');
4530 if l_ptu_person_type_id is not null then
4531 open ptu_exists(l_person_id,l_ptu_person_type_id);
4532 fetch ptu_exists into l_dummy;
4533 if ptu_exists%notfound then
4534 close ptu_exists;
4535 hr_utility.set_location(l_proc,140);
4536 hr_per_type_usage_internal.maintain_person_type_usage
4537 (p_effective_date => trunc(sysdate)
4538 ,p_person_id => l_person_id
4539 ,p_person_type_id => l_ptu_person_type_id
4540 );
4541 else
4542 close ptu_exists;
4543 end if;
4544 end if;
4545 hr_utility.set_location(l_proc, 55);
4546 end if;
4547
4548 -- check if the Party has Notification preferences
4549 open get_notif_prefs(l_person_party_id);
4550 fetch get_notif_prefs into l_notif_preference_id;
4551 close get_notif_prefs;
4552
4553 -- create Notification Preferences if the Party doesn't have one
4554 if l_notif_preference_id is NULL then
4555 -- create doesn't take a party_id ?
4556 irc_notification_prefs_api.create_notification_prefs
4557 (p_person_id =>l_person_id
4558 ,p_effective_date=>trunc(sysdate)
4559 ,p_notification_preference_id=>l_notif_preference_id
4560 ,p_object_version_number =>l_notif_ovn
4561 ,p_allow_access => l_allow_access);
4562 end if;
4563 hr_utility.set_location(l_proc, 90);
4564 -- check if the User has the required responsibility
4565 l_resp_exists := fnd_user_resp_groups_api.Assignment_Exists(l_user_id,
4566 p_responsibility_id, p_resp_appl_id, p_security_group_id);
4567 -- if the User doesn't have the responsibility, assign it.
4568 if NOT l_resp_exists then
4569 --
4570 -- add the appropriate responsibility
4571 --
4572 fnd_user_resp_groups_api.Insert_Assignment
4573 (user_id => l_user_id
4574 ,responsibility_id => p_responsibility_id
4575 ,responsibility_application_id => p_resp_appl_id
4576 ,security_group_id => p_security_group_id
4577 ,start_date => trunc(sysdate)
4578 ,end_date => null
4579 ,description => ' ' -- ### description was supposed to default
4580 -- to null... but does not look like it has
4581 );
4582 hr_utility.set_location(l_proc, 100);
4583 --
4584 -- look to see if we are using multiple security groups
4585 --
4586 if (fnd_profile.value('ENABLE_SECURITY_GROUPS')='Y') then
4587 l_sec_profile_id:=fnd_profile.value_specific
4588 (name=>'PER_SECURITY_PROFILE_ID'
4589 ,user_id=>l_user_id
4590 ,responsibility_id=>p_responsibility_id
4591 ,application_id=>p_resp_appl_id);
4592 l_business_group_id:=fnd_profile.value_specific
4593 (name=>'PER_BUSINESS_GROUP_ID'
4594 ,user_id=>l_user_id
4595 ,responsibility_id=>p_responsibility_id
4596 ,application_id=>p_resp_appl_id);
4597 --
4598 per_sec_profile_asg_api.create_security_profile_asg
4599 (p_sec_profile_assignment_id => l_sec_profile_assignment_id
4600 ,p_user_id => l_user_id
4601 ,p_security_group_id => p_security_group_id
4602 ,p_business_group_id => l_business_group_id
4603 ,p_security_profile_id => l_sec_profile_id
4604 ,p_responsibility_id => p_responsibility_id
4605 ,p_responsibility_application_i => p_resp_appl_id
4606 ,p_start_date => trunc(sysdate)
4607 ,p_object_version_number => l_ovn
4608 );
4609 hr_utility.set_location(l_proc, 110);
4610 end if;
4611 else
4612 hr_utility.set_location(l_proc, 95);
4613 --
4614 -- reopen the candidate responsibility
4615 --
4616 fnd_user_resp_groups_api.Update_Assignment
4617 (user_id => l_user_id
4618 ,responsibility_id => p_responsibility_id
4619 ,responsibility_application_id => p_resp_appl_id
4620 ,security_group_id => p_security_group_id
4621 ,start_date => trunc(sysdate)
4622 ,end_date => null
4623 ,description => ' ' -- ### description was supposed to default
4624 -- to null... but does not look like it has
4625 );
4626 -- REVISIT, what about Security Profile Assignment
4627 end if;
4628 --
4629 -- check if User has access to Candidate Homepage function
4630 l_function_name:=fnd_profile.value_specific
4631 (name=>'IRC_HOME_PAGE_FUNCTION'
4632 ,user_id=>l_user_id
4633 ,responsibility_id=>p_responsibility_id
4634 ,application_id=>p_resp_appl_id);
4635 l_func_check := fnd_data_security.check_function(1.0,l_function_name,
4636 'GLOBAL',null,null,null,null,null,upper(p_user_name));
4637 -- if user doesn't have the access, create the Grant
4638 if l_func_check <> 'T' then
4639 l_menu_name:=fnd_profile.value_specific
4640 (name=>'IRC_CANDIDATE_PSET'
4641 ,user_id=>l_user_id
4642 ,responsibility_id=>p_responsibility_id
4643 ,application_id=>p_resp_appl_id);
4644 open get_menu_id(l_menu_name);
4645 fetch get_menu_id into l_menu_id;
4646 close get_menu_id;
4647
4648 if l_menu_id is not null then
4649 if length(p_user_name) > 65 then
4650 l_grant_name := 'IRC_'||substr(p_user_name,1,65)||'_CAND_GRANT';
4651 else
4652 l_grant_name := 'IRC_'||upper(p_user_name)||'_CAND_GRANT';
4653 end if;
4654 irc_party_api.grant_access(p_user_name=> p_user_name,
4655 p_user_id=> l_user_id,
4656 p_menu_id=> l_menu_id,
4657 p_resp_id=> p_responsibility_id,
4658 p_resp_appl_id=> p_resp_appl_id,
4659 p_sec_group_id=> p_security_group_id,
4660 p_grant_name=> l_grant_name,
4661 p_description=>' ');
4662 end if;
4663 end if;
4664 --
4665 hr_utility.set_location('Leaving'||l_proc, 120);
4666 --
4667 end create_partial_user;
4668 -- -------------------------------------------------------------------------
4669 -- |------------------------< irec_profile_exists >-------------------------|
4670 -- -------------------------------------------------------------------------
4671 FUNCTION irec_profile_exists
4672 (p_user_name IN varchar2
4673 ,p_reg_bg_id IN number
4674 ,p_responsibility_id IN number
4675 ,p_resp_appl_id IN number
4676 ,p_security_group_id IN number
4677 ) return VARCHAR2
4678 --
4679 is
4680 --
4681 l_user_id number;
4682 l_person_id number;
4683 l_person_party_id number;
4684 l_notif_preference_id number;
4685 l_tmp_resp_id number;
4686 l_ptu_person_type_id number;
4687 l_pers_business_group_id number;
4688 l_dummy number;
4689 l_function_name varchar2(30);
4690 l_func_check varchar2(1);
4691 --
4692 cursor get_person_party_info is
4693 select user_id, employee_id, person_party_id
4694 from fnd_user
4695 where user_name=upper(p_user_name);
4696 --
4697 cursor get_bg(p_person_id number) is
4698 select per1.business_group_id
4699 from per_all_people_f per1
4700 where per1.person_id=p_person_id
4701 and trunc(sysdate) between per1.effective_start_date and per1.effective_end_date;
4702 --
4703 cursor ptu_exists(p_person_id number,p_person_type_id number) is
4704 select 1 from per_person_type_usages_f ptuf
4705 where ptuf.person_id=p_person_id
4706 and ptuf.person_type_id=p_person_type_id
4707 and trunc(sysdate) between ptuf.effective_start_date and ptuf.effective_end_date;
4708 --
4709 cursor get_user_responsibility(p_user_id number, p_responsibility_id number,
4710 p_resp_appl_id number, p_security_group_id number) is
4711 select responsibility_id
4712 from fnd_user_resp_groups
4713 where user_id=p_user_id and responsibility_id=p_responsibility_id
4714 and responsibility_application_id = p_resp_appl_id
4715 and security_group_id = p_security_group_id;
4716 --
4717 cursor get_notif_prefs(p_party_id number) is
4718 select notification_preference_id
4719 from irc_notification_preferences
4720 where party_id=p_party_id;
4721 --
4722 l_proc varchar2(72) := g_package||'irec_profile_exists';
4723 --
4724 begin
4725 --
4726 hr_utility.set_location(' Entering: '||l_proc, 10);
4727 --
4728 open get_person_party_info;
4729 fetch get_person_party_info into l_user_id, l_person_id, l_person_party_id;
4730 close get_person_party_info;
4731
4732 if l_person_id is NULL then
4733 return 'NO_PROFILE';
4734 else
4735 if irc_utilities_pkg.is_internal_person(p_user_name,trunc(sysdate)) <> 'TRUE' then
4736 open get_bg(l_person_id);
4737 fetch get_bg into l_pers_business_group_id;
4738 close get_bg;
4739 l_ptu_person_type_id:=hr_person_type_usage_info.get_default_person_type_id
4740 (l_pers_business_group_id, 'IRC_REG_USER');
4741 hr_utility.set_location(l_proc, 15);
4742 -- if the person's BG doesn't have the iRecruitment Candidate defined
4743 -- ignore??
4744 if l_ptu_person_type_id is not null then
4745 open ptu_exists(l_person_id,l_ptu_person_type_id);
4746 fetch ptu_exists into l_dummy;
4747 if ptu_exists%notfound then
4748 close ptu_exists;
4749 return 'NO_PROFILE';
4750 else
4751 close ptu_exists;
4752 end if;
4753 end if;
4754 --
4755 hr_utility.set_location(l_proc, 20);
4756 --
4757 if l_person_party_id IS NOT NULL then
4758 -- check if the Party has Notification preferences
4759 open get_notif_prefs(l_person_party_id);
4760 fetch get_notif_prefs into l_notif_preference_id;
4761 close get_notif_prefs;
4762 -- check if ID is NULL
4763 if l_notif_preference_id is NULL then
4764 return 'NO_PROFILE';
4765 end if;
4766 else
4767 return 'NO_PROFILE';
4768 end if;
4769 end if;
4770 end if;
4771 hr_utility.set_location(l_proc, 30);
4772
4773 -- check if user has the Candidate Responsibility
4774 open get_user_responsibility(l_user_id, p_responsibility_id, p_resp_appl_id, p_security_group_id);
4775 fetch get_user_responsibility into l_tmp_resp_id;
4776 -- if the User doesn't have the responsibility, assign it.
4777 if get_user_responsibility%notfound then
4778 return 'NO_PROFILE';
4779 end if;
4780 close get_user_responsibility;
4781 -- check if User has access to Candidate Homepage function
4782 l_function_name:=fnd_profile.value_specific
4783 (name=>'IRC_HOME_PAGE_FUNCTION'
4784 ,user_id=>l_user_id
4785 ,responsibility_id=>p_responsibility_id
4786 ,application_id=>p_resp_appl_id);
4787 l_func_check := fnd_data_security.check_function(1.0,l_function_name,
4788 'GLOBAL',null,null,null,null,null,upper(p_user_name));
4789 -- if user doesn't have the access, create the Grant
4790 if l_func_check <> 'T' then
4791 return 'NO_PROFILE';
4792 end if;
4793 --
4794 hr_utility.set_location('Leaving: '||l_proc, 40);
4795
4796 return 'PROFILE_EXISTS';
4797 end irec_profile_exists;
4798 -- -------------------------------------------------------------------------
4799 -- |------------------------< create_ha_processed_user >--------------------|
4800 -- -------------------------------------------------------------------------
4801 PROCEDURE create_ha_processed_user
4802 (p_user_name IN varchar2
4803 ,p_password IN varchar2
4804 ,p_email IN varchar2
4805 ,p_start_date IN date
4806 ,p_last_name IN varchar2
4807 ,p_first_name IN varchar2
4808 ,p_user_guid IN RAW
4809 ,p_reg_bg_id IN number
4810 ,p_responsibility_id IN number
4811 ,p_resp_appl_id IN number
4812 ,p_security_group_id IN number
4813 ,p_language IN varchar2 default null
4814 ,p_allow_access IN varchar2 default null
4815 ,p_server_id IN varchar2 default null
4816 ) is
4817 l_user_id number;
4818 l_decrypted_password varchar2(100) := null;
4819 l_password_change_check varchar2(1);
4820 l_num number;
4821 l_bool boolean;
4822 l_found boolean;
4823 l_resp_exists boolean;
4824 l_business_group_id number;
4825 l_sec_profile_id number;
4826 l_ovn number;
4827 l_sec_profile_assignment_id number;
4828 password_update_failed exception;
4829 --
4830 l_proc varchar2(72) := g_package||'create_ha_processed_user';
4831
4832 begin
4833 --
4834 hr_utility.set_location(' Entering: '||l_proc, 10);
4835
4836 l_num := TestUserName(p_user_name=>p_user_name);
4837 -- creating a brand new user. This happens when SSO is not enabled and user
4838 -- registered on HA instance
4839 if l_num = 0 then
4840 hr_utility.set_location(' Entering: '||l_proc, 20);
4841 -- create the iRecruitment user with standard password
4842 irc_party_api.create_user(p_user_name => p_user_name,
4843 p_password => 'j3ke678to',
4844 p_start_date => p_start_date,
4845 p_responsibility_id => p_responsibility_id,
4846 p_resp_appl_id => p_resp_appl_id,
4847 p_security_group_id => p_security_group_id,
4848 p_last_name => p_last_name,
4849 p_first_name => p_first_name,
4850 p_email => p_email,
4851 p_allow_access => p_allow_access);
4852 hr_utility.set_location(' Entering: '||l_proc, 30);
4853 -- update the user password
4854 l_bool := fnd_user_pkg.setreencryptedpassword(username => p_user_name,
4855 reencpwd => p_password,
4856 newkey => 'LOADER');
4857 if NOT l_bool then
4858 raise PASSWORD_UPDATE_FAILED;
4859 end if;
4860 --
4861 hr_utility.set_location(l_proc, 40);
4862 --
4863 fnd_sso_manager.synch_user_from_LDAP(p_user_name);
4864 --
4865 hr_utility.set_location(l_proc, 50);
4866 --
4867 -- this case happens when user is present in SSO and applied for a job through
4868 -- HA and for this we have to create a local user who points to SSO user
4869 -- note that we are passing in FND_WEB_SEC.EXTERNAL_PWD which is checked by
4870 -- ATG routine and treats this as an SSO user
4871 elsif l_num = 3 then
4872 hr_utility.set_location(l_proc, 15);
4873 l_user_id := fnd_user_pkg.CreateUserId(
4874 x_user_name => p_user_name
4875 ,x_owner => 'CUST'
4876 ,x_unencrypted_password => FND_WEB_SEC.EXTERNAL_PWD
4877 ,x_email_address => p_email
4878 ,x_user_guid => p_user_guid
4879 );
4880 hr_utility.set_location(l_proc, 25);
4881 -- fix for bug 4765406
4882 -- set the profile to SSO
4883 l_found := fnd_profile.save(x_name => 'APPS_SSO_LOCAL_LOGIN'
4884 , x_value => 'SSO'
4885 , x_level_name => 'USER'
4886 , x_level_value => l_user_id);
4887
4888 hr_utility.set_location(l_proc, 30);
4889 --
4890 fnd_sso_manager.synch_user_from_LDAP(p_user_name);
4891 hr_utility.set_location(l_proc, 35);
4892 --
4893 -- check if User has Resp
4894 irc_party_api.process_ha_resp_check(p_user_id => l_user_id,
4895 p_responsibility_id => p_responsibility_id,
4896 p_resp_appl_id => p_resp_appl_id,
4897 p_security_group_id => p_security_group_id,
4898 p_start_date => p_start_date,
4899 p_server_id => p_server_id);
4900 -- complete the partial registration
4901 create_partial_user(p_user_name => p_user_name
4902 ,p_last_name => p_last_name
4903 ,p_first_name => p_first_name
4904 ,p_email => p_email
4905 ,p_start_date => p_start_date
4906 ,p_reg_bg_id => p_reg_bg_id
4907 ,p_responsibility_id => p_responsibility_id
4908 ,p_resp_appl_id => p_resp_appl_id
4909 ,p_security_group_id => p_security_group_id
4910 ,p_language => p_language
4911 ,p_allow_access => p_allow_access
4912 );
4913 end if;
4914 hr_utility.set_location('Leaving: '||l_proc, 60);
4915 end create_ha_processed_user;
4916 --
4917 -- -------------------------------------------------------------------------
4918 -- |------------------------< process_ha_resp_check >----------------------|
4919 -- -------------------------------------------------------------------------
4920 --
4921 procedure process_ha_resp_check
4922 (
4923 p_user_id IN number,
4924 p_responsibility_id IN number,
4925 p_resp_appl_id IN number,
4926 p_security_group_id IN number,
4927 p_start_date IN date,
4928 p_server_id IN number default null
4929 )is
4930 --
4931 cursor get_person_party_info is
4932 select employee_id, person_party_id
4933 from fnd_user
4934 where user_id=p_user_id;
4935
4936 l_person_id number;
4937 l_person_party_id number;
4938 l_per_type varchar2(100);
4939 l_num number;
4940 l_bool boolean;
4941 l_found boolean;
4942 l_resp_exists boolean;
4943 l_business_group_id number;
4944 l_sec_profile_id number;
4945 l_ovn number;
4946 l_sec_profile_assignment_id number;
4947 --
4948 l_proc varchar2(72) := g_package||'process_ha_resp_check';
4949 begin
4950 --
4951 open get_person_party_info;
4952 fetch get_person_party_info into l_person_id, l_person_party_id;
4953 close get_person_party_info;
4954 -- Disable Partial Registration for Employees
4955 if l_person_id is not null then
4956 l_per_type := irc_utilities_pkg.get_emp_spt_for_person(l_person_id, trunc(p_start_date));
4957 end if;
4958 -- check if the User has the required responsibility
4959 l_resp_exists := fnd_user_resp_groups_api.Assignment_Exists(p_user_id,
4960 p_responsibility_id, p_resp_appl_id, p_security_group_id);
4961 -- if the User doesn't have the responsibility, assign it.
4962 if NOT l_resp_exists then
4963 if (l_per_type = 'EMP') then
4964 fnd_message.set_name('PER','IRC_412224_EMP_PARTIAL_REG');
4965 fnd_message.raise_error;
4966 end if;
4967 --
4968 -- add the appropriate responsibility
4969 --
4970 fnd_user_resp_groups_api.Insert_Assignment
4971 (user_id => p_user_id
4972 ,responsibility_id => p_responsibility_id
4973 ,responsibility_application_id => p_resp_appl_id
4974 ,security_group_id => p_security_group_id
4975 ,start_date => trunc(sysdate)
4976 ,end_date => null
4977 ,description => ' ' -- ### description was supposed to default
4978 -- to null... but does not look like it has
4979 );
4980 hr_utility.set_location(l_proc, 100);
4981 --
4982 -- look to see if we are using multiple security groups
4983 --
4984 if (fnd_profile.value('ENABLE_SECURITY_GROUPS')='Y') then
4985 l_sec_profile_id:=fnd_profile.value_specific
4986 (name=>'PER_SECURITY_PROFILE_ID'
4987 ,user_id=>p_user_id
4988 ,responsibility_id=>p_responsibility_id
4989 ,application_id=>p_resp_appl_id);
4990 l_business_group_id:=fnd_profile.value_specific
4991 (name=>'PER_BUSINESS_GROUP_ID'
4992 ,user_id=>p_user_id
4993 ,responsibility_id=>p_responsibility_id
4994 ,application_id=>p_resp_appl_id);
4995 --
4996 per_sec_profile_asg_api.create_security_profile_asg
4997 (p_sec_profile_assignment_id => l_sec_profile_assignment_id
4998 ,p_user_id => p_user_id
4999 ,p_security_group_id => p_security_group_id
5000 ,p_business_group_id => l_business_group_id
5001 ,p_security_profile_id => l_sec_profile_id
5002 ,p_responsibility_id => p_responsibility_id
5003 ,p_responsibility_application_i => p_resp_appl_id
5004 ,p_start_date => trunc(sysdate)
5005 ,p_object_version_number => l_ovn
5006 );
5007 hr_utility.set_location(l_proc, 110);
5008 end if;
5009 else
5010 hr_utility.set_location(l_proc, 95);
5011 if (l_per_type <> 'EMP') then
5012 --
5013 -- reopen the candidate responsibility
5014 --
5015 fnd_user_resp_groups_api.Update_Assignment
5016 (user_id => p_user_id
5017 ,responsibility_id => p_responsibility_id
5018 ,responsibility_application_id => p_resp_appl_id
5019 ,security_group_id => p_security_group_id
5020 ,start_date => trunc(sysdate)
5021 ,end_date => null
5022 ,description => ' ' -- ### description was supposed to default
5023 -- to null... but does not look like it has
5024 );
5025 -- REVISIT, what about Security Profile Assignment
5026 end if;
5027 end if;
5028 --
5029 if p_server_id is null then
5030 fnd_global.apps_initialize
5031 (user_id => p_user_id
5032 ,resp_id => p_responsibility_id
5033 ,resp_appl_id => p_resp_appl_id
5034 ,security_group_id=> p_security_group_id);
5035 else
5036 fnd_global.apps_initialize
5037 (user_id => p_user_id
5038 ,resp_id => p_responsibility_id
5039 ,resp_appl_id => p_resp_appl_id
5040 ,security_group_id=> p_security_group_id
5041 ,server_id => p_server_id);
5042 end if;
5043 end;
5044 --
5045 -- -------------------------------------------------------------------------
5046 -- |------------------------< TestUserName >-------------------------------|
5047 -- -------------------------------------------------------------------------
5048 function TestUserName
5049 (
5050 p_user_name IN varchar2
5051 ) return NUMBER
5052 is
5053 begin
5054 return fnd_user_pkg.testusername(x_user_name=>p_user_name);
5055 end TestUserName;
5056 --
5057 -- -------------------------------------------------------------------------
5058 -- |------------------------< assign_responsibility >----------------------|
5059 -- -------------------------------------------------------------------------
5060 procedure assign_responsibility
5061 (p_user_id IN number
5062 ,p_resp_id IN number
5063 ,p_resp_appl_id IN number
5064 ,p_sec_group_id IN number
5065 ) is
5066 --
5067 PRAGMA autonomous_transaction;
5068
5069 l_resp_exists boolean;
5070 l_sec_profile_assignment_id number;
5071 l_business_group_id number;
5072 l_sec_profile_id number;
5073 l_ovn number;
5074 --
5075 l_proc varchar2(72) := g_package||'assign_responsibility';
5076
5077 begin
5078 -- check if the User has the required responsibility
5079 l_resp_exists := fnd_user_resp_groups_api.Assignment_Exists(p_user_id,
5080 p_resp_id, p_resp_appl_id, p_sec_group_id);
5081 -- if the User doesn't have the responsibility, assign it.
5082 if NOT l_resp_exists then
5083 --
5084 -- add the appropriate responsibility
5085 --
5086 fnd_user_resp_groups_api.Insert_Assignment
5087 (user_id => p_user_id
5088 ,responsibility_id => p_resp_id
5089 ,responsibility_application_id => p_resp_appl_id
5090 ,security_group_id => p_sec_group_id
5091 ,start_date => trunc(sysdate)
5092 ,end_date => null
5093 ,description => ' ' -- ### description was supposed to default
5094 -- to null... but does not look like it has
5095 );
5096 hr_utility.set_location(l_proc, 100);
5097 --
5098 -- look to see if we are using multiple security groups
5099 --
5100 if(fnd_profile.value('ENABLE_SECURITY_GROUPS')='Y') then
5101 l_sec_profile_id:=fnd_profile.value_specific
5102 (name=>'PER_SECURITY_PROFILE_ID'
5103 ,user_id=>p_user_id
5104 ,responsibility_id=>p_resp_id
5105 ,application_id=>p_resp_appl_id);
5106 l_business_group_id:=fnd_profile.value_specific
5107 (name=>'PER_BUSINESS_GROUP_ID'
5108 ,user_id=>p_user_id
5109 ,responsibility_id=>p_resp_id
5110 ,application_id=>p_resp_appl_id);
5111 --
5112 per_sec_profile_asg_api.create_security_profile_asg
5113 (p_sec_profile_assignment_id => l_sec_profile_assignment_id
5114 ,p_user_id => p_user_id
5115 ,p_security_group_id => p_sec_group_id
5116 ,p_business_group_id => l_business_group_id
5117 ,p_security_profile_id => l_sec_profile_id
5118 ,p_responsibility_id => p_resp_id
5119 ,p_responsibility_application_i => p_resp_appl_id
5120 ,p_start_date => trunc(sysdate)
5121 ,p_object_version_number => l_ovn
5122 );
5123 hr_utility.set_location(l_proc, 110);
5124 end if;
5125 else
5126 hr_utility.set_location(l_proc, 95);
5127 --
5128 -- reopen the candidate responsibility
5129 --
5130 fnd_user_resp_groups_api.Update_Assignment
5131 (user_id => p_user_id
5132 ,responsibility_id => p_resp_id
5133 ,responsibility_application_id => p_resp_appl_id
5134 ,security_group_id => p_sec_group_id
5135 ,start_date => trunc(sysdate)
5136 ,end_date => null
5137 ,description => ' ' -- ### description was supposed to default
5138 -- to null... but does not look like it has
5139 );
5140 -- REVISIT, what about Security Profile Assignment
5141 end if;
5142 commit;
5143 hr_utility.set_location('Leaving:'||l_proc, 110);
5144 end assign_responsibility;
5145 --
5146 --
5147 --
5148 -- -------------------------------------------------------------------------
5149 -- |------------------------< create_user_internal_byRef >------------------|
5150 -- -------------------------------------------------------------------------
5151 --
5152 procedure create_user_internal_byRef
5153 (p_user_name IN varchar2
5154 ,p_password IN varchar2
5155 ,p_start_date IN date
5156 ,p_responsibility_id IN number
5157 ,p_resp_appl_id IN number
5158 ,p_security_group_id IN number
5159 ,p_email IN varchar2 default null
5160 ,p_language IN varchar2 default null
5161 ,p_last_name IN varchar2 default null
5162 ,p_first_name IN varchar2 default null
5163 ,p_allow_access IN varchar2 default null
5164 ,p_per_information_category IN varchar2 default null
5165 ,p_per_information1 IN varchar2 default null
5166 ,p_per_information2 IN varchar2 default null
5167 ,p_per_information3 IN varchar2 default null
5168 ,p_per_information4 IN varchar2 default null
5169 ,p_per_information5 IN varchar2 default null
5170 ,p_per_information6 IN varchar2 default null
5171 ,p_per_information7 IN varchar2 default null
5172 ,p_per_information8 IN varchar2 default null
5173 ,p_per_information9 IN varchar2 default null
5174 ,p_per_information10 IN varchar2 default null
5175 ,p_per_information11 IN varchar2 default null
5176 ,p_per_information12 IN varchar2 default null
5177 ,p_per_information13 IN varchar2 default null
5178 ,p_per_information14 IN varchar2 default null
5179 ,p_per_information15 IN varchar2 default null
5180 ,p_per_information16 IN varchar2 default null
5181 ,p_per_information17 IN varchar2 default null
5182 ,p_per_information18 IN varchar2 default null
5183 ,p_per_information19 IN varchar2 default null
5184 ,p_per_information20 IN varchar2 default null
5185 ,p_per_information21 IN varchar2 default null
5186 ,p_per_information22 IN varchar2 default null
5187 ,p_per_information23 IN varchar2 default null
5188 ,p_per_information24 IN varchar2 default null
5189 ,p_per_information25 IN varchar2 default null
5190 ,p_per_information26 IN varchar2 default null
5191 ,p_per_information27 IN varchar2 default null
5192 ,p_per_information28 IN varchar2 default null
5193 ,p_per_information29 IN varchar2 default null
5194 ,p_per_information30 IN varchar2 default null
5195 ,p_person_id IN per_all_people_f.person_id%type default null
5196 ) IS
5197 --
5198 PRAGMA autonomous_transaction;
5199 l_proc varchar2(72) := g_package||'create_user_internal_byReferral';
5200 l_person_id per_all_people_f.person_id%type;
5201 l_user_id number;
5202 l_profile_check boolean;
5203 l_user_name fnd_user.user_name%type;
5204 l_default_last_name per_all_people_f.last_name%type;
5205 l_effective_start_date date;
5206 l_effective_end_date date;
5207 l_sec_profile_assignment_id number;
5208 l_business_group_id number;
5209 l_sec_profile_id number;
5210 l_ovn number;
5211 l_menu_name varchar2(30);
5212 l_menu_id number;
5213 l_grant_name varchar2(80);
5214 --
5215 cursor get_menu_id (p_menu_name varchar2) is
5216 select menu_id from fnd_menus where menu_name=upper(p_menu_name);
5217 --
5218 begin
5219 hr_utility.set_location(' Entering: '||l_proc, 10);
5220 --
5221 -- Create Person
5222 l_default_last_name := nvl(p_last_name,fnd_message.get_string('PER','IRC_412108_UNKNOWN_NAME'));
5223
5224 l_person_id := p_person_id;
5225 --
5226 hr_utility.set_location(l_proc,20);
5227 --
5228 -- Create User and set person_id to employee_id
5229 --
5230 l_user_id := fnd_user_pkg.CreateUserId (
5231 x_user_name => p_user_name,
5232 x_owner => 'CUST',
5233 x_unencrypted_password => null,
5234 x_email_address => p_email,
5235 x_employee_id => l_person_id,
5236 x_password_date => trunc(sysdate));
5237 --
5238 hr_utility.set_location(l_proc,30);
5239 l_user_name := fnd_web_sec.set_reencrypted_password(username => p_user_name
5240 ,reencpwd => fnd_web_sec.encrypt(key => 'LOADER',value => p_password)
5241 , new_key =>'LOADER' );
5242 --
5243 -- set the language profile option
5244 --
5245 l_profile_check := fnd_profile.save (
5246 x_name => 'ICX_LANGUAGE',
5247 x_value => p_language,
5248 x_level_name => 'USER',
5249 x_level_value => l_user_id );
5250 --
5251 hr_utility.set_location(l_proc,40);
5252 --
5253 -- Set the password date Column to Null for the created user
5254 -- As the password is system generated, it should be changed
5255 -- by candidate when he first logs in
5256 UPDATE fnd_user
5257 SET password_date=NULL
5258 WHERE user_name=upper(p_user_name);
5259 --
5260 -- commit autonomous transaction
5261 --
5262 --
5263 commit;
5264 --
5265 hr_utility.set_location(' Leaving:'||l_proc, 50);
5266 end create_user_internal_byRef;
5267 --
5268 --
5269 -- -------------------------------------------------------------------------
5270 -- |------------------------< create_user_byReferral >--------------------------------|
5271 -- -------------------------------------------------------------------------
5272 --
5273 procedure create_user_byReferral
5274 (p_user_name IN varchar2
5275 ,p_password IN varchar2
5276 ,p_start_date IN date
5277 ,p_responsibility_id IN number
5278 ,p_resp_appl_id IN number
5279 ,p_security_group_id IN number
5280 ,p_email IN varchar2 default null
5281 ,p_language IN varchar2 default null
5282 ,p_last_name IN varchar2 default null
5283 ,p_first_name IN varchar2 default null
5284 ,p_allow_access IN varchar2 default null
5285 ,p_per_information_category IN varchar2 default null
5286 ,p_per_information1 IN varchar2 default null
5287 ,p_per_information2 IN varchar2 default null
5288 ,p_per_information3 IN varchar2 default null
5289 ,p_per_information4 IN varchar2 default null
5290 ,p_per_information5 IN varchar2 default null
5291 ,p_per_information6 IN varchar2 default null
5292 ,p_per_information7 IN varchar2 default null
5293 ,p_per_information8 IN varchar2 default null
5294 ,p_per_information9 IN varchar2 default null
5295 ,p_per_information10 IN varchar2 default null
5296 ,p_per_information11 IN varchar2 default null
5297 ,p_per_information12 IN varchar2 default null
5298 ,p_per_information13 IN varchar2 default null
5299 ,p_per_information14 IN varchar2 default null
5300 ,p_per_information15 IN varchar2 default null
5301 ,p_per_information16 IN varchar2 default null
5302 ,p_per_information17 IN varchar2 default null
5303 ,p_per_information18 IN varchar2 default null
5304 ,p_per_information19 IN varchar2 default null
5305 ,p_per_information20 IN varchar2 default null
5306 ,p_per_information21 IN varchar2 default null
5307 ,p_per_information22 IN varchar2 default null
5308 ,p_per_information23 IN varchar2 default null
5309 ,p_per_information24 IN varchar2 default null
5310 ,p_per_information25 IN varchar2 default null
5311 ,p_per_information26 IN varchar2 default null
5312 ,p_per_information27 IN varchar2 default null
5313 ,p_per_information28 IN varchar2 default null
5314 ,p_per_information29 IN varchar2 default null
5315 ,p_per_information30 IN varchar2 default null
5316 ,p_person_id IN number default null
5317 ) IS
5318 --
5319 l_password_check varchar2(1);
5320 l_password_change_check varchar2(1);
5321 l_customer_pwd_check fnd_profile_option_values.profile_option_value%type;
5322 l_allow_access irc_notification_preferences.allow_access%type;
5323 l_start_date date;
5324 cursor get_nls_language is
5325 select nls_language
5326 from fnd_languages
5327 where language_code=p_language;
5328 --
5329 l_nls_language fnd_languages.nls_language%type;
5330 --
5331 begin
5332 --
5333 -- Truncate time portion from date
5334 --
5335 l_start_date := trunc(p_start_date);
5336 --
5337 -- default Allow Access if input value is NULL
5338 --
5339 l_allow_access := nvl(p_allow_access,nvl(fnd_profile.value('IRC_VISIBLE_PREF_DEFAULT'),'N'));
5340 --
5341 -- Call Before Process User Hook
5342 --
5343 begin
5344 irc_party_bk4.create_user_b
5345 (
5346 p_user_name => p_user_name
5347 ,p_password => p_password
5348 ,p_start_date => l_start_date
5349 ,p_email => p_email
5350 ,p_language => p_language
5351 ,p_last_name => p_last_name
5352 ,p_first_name => p_first_name
5353 ,p_allow_access => l_allow_access
5354 ,p_per_information_category => p_per_information_category
5355 ,p_per_information1 => p_per_information1
5356 ,p_per_information2 => p_per_information2
5357 ,p_per_information3 => p_per_information3
5358 ,p_per_information4 => p_per_information4
5359 ,p_per_information5 => p_per_information5
5360 ,p_per_information6 => p_per_information6
5361 ,p_per_information7 => p_per_information7
5362 ,p_per_information8 => p_per_information8
5363 ,p_per_information9 => p_per_information9
5364 ,p_per_information10 => p_per_information10
5365 ,p_per_information11 => p_per_information11
5366 ,p_per_information12 => p_per_information12
5367 ,p_per_information13 => p_per_information13
5368 ,p_per_information14 => p_per_information14
5369 ,p_per_information15 => p_per_information15
5370 ,p_per_information16 => p_per_information16
5371 ,p_per_information17 => p_per_information17
5372 ,p_per_information18 => p_per_information18
5373 ,p_per_information19 => p_per_information19
5374 ,p_per_information20 => p_per_information20
5375 ,p_per_information21 => p_per_information21
5376 ,p_per_information22 => p_per_information22
5377 ,p_per_information23 => p_per_information23
5378 ,p_per_information24 => p_per_information24
5379 ,p_per_information25 => p_per_information25
5380 ,p_per_information26 => p_per_information26
5381 ,p_per_information27 => p_per_information27
5382 ,p_per_information28 => p_per_information28
5383 ,p_per_information29 => p_per_information29
5384 ,p_per_information30 => p_per_information30
5385 );
5386 exception
5387 when hr_api.cannot_find_prog_unit then
5388 hr_api.cannot_find_prog_unit_error
5389 (p_module_name => 'CREATE_USER'
5390 ,p_hook_type => 'BP'
5391 );
5392 end;
5393 --
5394 -- get NLS_LANGUAGE
5395 --
5396 open get_nls_language;
5397 fetch get_nls_language into l_nls_language;
5398 if get_nls_language%notfound then
5399 close get_nls_language;
5400 l_nls_language:=p_language;
5401 else
5402 close get_nls_language;
5403 end if;
5404 --
5405 l_customer_pwd_check := nvl(fnd_profile.value('SIGNON_PASSWORD_CUSTOM'),'N');
5406 IF l_customer_pwd_check = 'N' THEN
5407 -- Validate the password
5408 --
5409 l_password_check := fnd_web_sec.validate_password(username => p_user_name
5410 ,password => p_password);
5411
5412 if (l_password_check = 'N') then
5413 fnd_message.raise_error;
5414 end if;
5415 end if;
5416 --
5417 -- create party and user
5418 --
5419 irc_party_api.create_user_internal_byRef(p_user_name => p_user_name
5420 ,p_password => p_password
5421 ,p_start_date => l_start_date
5422 ,p_email => p_email
5423 ,p_responsibility_id => p_responsibility_id
5424 ,p_resp_appl_id => p_resp_appl_id
5425 ,p_security_group_id => p_security_group_id
5426 ,p_language => l_nls_language
5427 ,p_last_name => p_last_name
5428 ,p_first_name => p_first_name
5429 ,p_allow_access => l_allow_access
5430 ,p_per_information_category => p_per_information_category
5431 ,p_per_information1 => p_per_information1
5432 ,p_per_information2 => p_per_information2
5433 ,p_per_information3 => p_per_information3
5434 ,p_per_information4 => p_per_information4
5435 ,p_per_information5 => p_per_information5
5436 ,p_per_information6 => p_per_information6
5437 ,p_per_information7 => p_per_information7
5438 ,p_per_information8 => p_per_information8
5439 ,p_per_information9 => p_per_information9
5440 ,p_per_information10 => p_per_information10
5441 ,p_per_information11 => p_per_information11
5442 ,p_per_information12 => p_per_information12
5443 ,p_per_information13 => p_per_information13
5444 ,p_per_information14 => p_per_information14
5445 ,p_per_information15 => p_per_information15
5446 ,p_per_information16 => p_per_information16
5447 ,p_per_information17 => p_per_information17
5448 ,p_per_information18 => p_per_information18
5449 ,p_per_information19 => p_per_information19
5450 ,p_per_information20 => p_per_information20
5451 ,p_per_information21 => p_per_information21
5452 ,p_per_information22 => p_per_information22
5453 ,p_per_information23 => p_per_information23
5454 ,p_per_information24 => p_per_information24
5455 ,p_per_information25 => p_per_information25
5456 ,p_per_information26 => p_per_information26
5457 ,p_per_information27 => p_per_information27
5458 ,p_per_information28 => p_per_information28
5459 ,p_per_information29 => p_per_information29
5460 ,p_per_information30 => p_per_information30
5461 ,p_person_id => p_person_id
5462 );
5463 --
5464 -- Call After Process User Hook
5465 --
5466 begin
5467 irc_party_bk4.create_user_a
5468 (
5469 p_user_name => p_user_name
5470 ,p_password => p_password
5471 ,p_start_date => l_start_date
5472 ,p_email => p_email
5473 ,p_language => p_language
5474 ,p_last_name => p_last_name
5475 ,p_first_name => p_first_name
5476 ,p_allow_access => l_allow_access
5477 ,p_per_information_category => p_per_information_category
5478 ,p_per_information1 => p_per_information1
5479 ,p_per_information2 => p_per_information2
5480 ,p_per_information3 => p_per_information3
5481 ,p_per_information4 => p_per_information4
5482 ,p_per_information5 => p_per_information5
5483 ,p_per_information6 => p_per_information6
5484 ,p_per_information7 => p_per_information7
5485 ,p_per_information8 => p_per_information8
5486 ,p_per_information9 => p_per_information9
5487 ,p_per_information10 => p_per_information10
5488 ,p_per_information11 => p_per_information11
5489 ,p_per_information12 => p_per_information12
5490 ,p_per_information13 => p_per_information13
5491 ,p_per_information14 => p_per_information14
5492 ,p_per_information15 => p_per_information15
5493 ,p_per_information16 => p_per_information16
5494 ,p_per_information17 => p_per_information17
5495 ,p_per_information18 => p_per_information18
5496 ,p_per_information19 => p_per_information19
5497 ,p_per_information20 => p_per_information20
5498 ,p_per_information21 => p_per_information21
5499 ,p_per_information22 => p_per_information22
5500 ,p_per_information23 => p_per_information23
5501 ,p_per_information24 => p_per_information24
5502 ,p_per_information25 => p_per_information25
5503 ,p_per_information26 => p_per_information26
5504 ,p_per_information27 => p_per_information27
5505 ,p_per_information28 => p_per_information28
5506 ,p_per_information29 => p_per_information29
5507 ,p_per_information30 => p_per_information30
5508 );
5509 exception
5510 when hr_api.cannot_find_prog_unit then
5511 hr_api.cannot_find_prog_unit_error
5512 (p_module_name => 'CREATE_USER'
5513 ,p_hook_type => 'AP'
5514 );
5515 end;
5516 --
5517 end create_user_byReferral;
5518 --
5519 procedure merge_profile
5520 (p_validate IN boolean default false
5521 ,p_target_party_id IN number
5522 ,p_source_party_id IN number
5523 ,p_term_or_purge_s IN varchar2 default null
5524 ,p_disable_user_acc IN varchar2 default null
5525 ,p_create_new_application IN varchar2 default null
5526 )
5527 is
5528 l_proc varchar2(72) := g_package||'merge_profile';
5529 l_term_or_purge_s varchar2(10) := null;
5530 l_create_new_application varchar2(10) := null;
5531 l_disable_user_acc varchar2(10) := null;
5532 --
5533 -- Cursor declarations
5534 cursor get_user_name(p_party_id number) is
5535 select fu.user_name
5536 from fnd_user fu
5537 where fu.person_party_id=p_party_id
5538 and trunc(sysdate) between fu.start_date and nvl(fu.end_date,trunc(sysdate));
5539 --
5540 begin
5541 --
5542 hr_utility.set_location(' Entering: '||l_proc, 10);
5543 --
5544 -- Issue a savepoint
5545 --
5546 savepoint MERGE_PROFILE;
5547 --
5548 -- We are terminating the applications by default
5549 -- not leaving this option to the end user
5550 l_term_or_purge_s := 'TERM';
5551 --
5552 -- We are Copying the applications by default
5553 -- when the target person deos not exist as of application start date
5554 l_create_new_application := 'Y';
5555 --
5556 -- We are disabling all the user accounts of the source party
5557 -- not leaving this option to the end user
5558 l_disable_user_acc := 'Y';
5559 --
5560 --
5561 hr_person_api.merge_party
5562 (p_validate => p_validate
5563 ,p_target_party_id => p_target_party_id
5564 ,p_source_party_id => p_source_party_id
5565 ,p_term_or_purge_s => l_term_or_purge_s
5566 ,p_create_new_application => l_create_new_application
5567 );
5568 --
5569 --
5570 if l_disable_user_acc='Y' then
5571 --
5572 -- close off the user accounts for the source party
5573 --
5574 hr_utility.set_location(l_proc,20);
5575 --
5576 for user_rec in get_user_name(p_source_party_id) loop
5577 fnd_user_pkg.disableUser(user_rec.user_name);
5578 end loop;
5579 --
5580 hr_utility.set_location(l_proc,30);
5581 --
5582 end if;
5583 --
5584 hr_utility.set_location(' Leaving: '||l_proc, 40);
5585 --
5586 exception
5587 when others then
5588 --
5589 -- A validation or unexpected error has occured
5590 --
5591 rollback to MERGE_PROFILE;
5592 --
5593 --
5594 hr_utility.set_location(' Leaving:'||l_proc, 50);
5595 --
5596 raise;
5597 end merge_profile;
5598 --
5599 --
5600 FUNCTION check_copy_applications_exist
5601 (p_party_id IN number
5602 ) return VARCHAR2
5603 --
5604 is
5605 --
5606 -- Cursor declarations
5607 cursor csr_appl is
5608 select 1
5609 from per_all_people_f ppf,
5610 per_all_assignments_f paf
5611 where ppf.party_id = p_party_id
5612 and paf.person_id = ppf.person_id
5613 and trunc(sysdate) between paf.effective_start_date and paf.effective_end_date;
5614 --Variable declarations
5615 l_dummy number;
5616 begin
5617 --
5618 open csr_appl;
5619 fetch csr_appl into l_dummy;
5620 if csr_appl%found then
5621 close csr_appl;
5622 return 'TRUE';
5623 else
5624 close csr_appl;
5625 return 'FALSE';
5626 end if;
5627 --
5628 end check_copy_applications_exist;
5629 --
5630 --
5631 FUNCTION is_user_account_available
5632 (p_party_id IN number
5633 ) return VARCHAR2
5634 --
5635 is
5636 --
5637 -- Cursor declarations
5638 cursor get_user_name(p_party_id number) is
5639 select fu.user_name
5640 from fnd_user fu
5641 where fu.person_party_id=p_party_id
5642 and trunc(sysdate) between fu.start_date and nvl(fu.end_date,trunc(sysdate));
5643 --
5644 -- Variable declarations
5645 l_user_name fnd_user.user_name%type;
5646 begin
5647 --
5648 open get_user_name(p_party_id);
5649 fetch get_user_name into l_user_name;
5650 if get_user_name%found then
5651 close get_user_name;
5652 RETURN 'TRUE';
5653 else
5654 close get_user_name;
5655 RETURN 'FALSE';
5656 end if;
5657 --
5658 end is_user_account_available;
5659 --
5660 --
5661 FUNCTION check_offer_exist
5662 (p_party_id IN number
5663 ) return VARCHAR2
5664 --
5665 is
5666 --
5667 -- Cursor Declarations
5668 cursor csr_offers is
5669 select paf.assignment_id
5670 from per_all_people_f ppf,
5671 per_all_assignments_f paf,
5672 irc_offers iof,
5673 irc_offer_status_history history
5674 where ppf.party_id = p_party_id
5675 and trunc(sysdate) between ppf.effective_start_date and ppf.effective_end_date
5676 and paf.person_id = ppf.person_id
5677 and paf.assignment_type = 'O'
5678 and paf.ASSIGNMENT_ID = iof.OFFER_ASSIGNMENT_ID
5679 and iof.LATEST_OFFER = 'Y'
5680 AND history.offer_id = iof.offer_id
5681 and not exists
5682 (SELECT 1
5683 FROM irc_offer_status_history iosh1
5684 WHERE iosh1.offer_id = HISTORY.offer_id
5685 AND iosh1.status_change_date > HISTORY.status_change_date
5686 )
5687 AND HISTORY.offer_status_history_id =
5688 (SELECT MAX(iosh2.offer_status_history_id)
5689 FROM irc_offer_status_history iosh2
5690 WHERE iosh2.offer_id = HISTORY.offer_id
5691 AND iosh2.status_change_date = HISTORY.status_change_date
5692 )
5693 and (iof.OFFER_STATUS <> 'CLOSED' OR (iof.OFFER_STATUS = 'CLOSED' AND HISTORY.change_reason ='APL_ACCEPTED'));
5694 -- When the offer close reason is 'APL_HIRED' it should not coming upto this place
5695 -- as we are not allowing to copy when employee exists in the copy applications page.
5696 -- Variable declarations
5697 l_dummy number;
5698 begin
5699 --
5700 open csr_offers;
5701 fetch csr_offers into l_dummy;
5702 if csr_offers%found then
5703 close csr_offers;
5704 return 'TRUE';
5705 else
5706 close csr_offers;
5707 return 'FALSE';
5708 end if;
5709 --
5710 end check_offer_exist;
5711 --
5712 --
5713 FUNCTION check_security
5714 (p_party_id IN number
5715 ) return VARCHAR2
5716 is
5717 --
5718 -- Cursor declarations
5719 Cursor csr_view_all_apl_count is
5720 select count(pav.vacancy_id)
5721 from per_all_people_f ppf,
5722 per_all_assignments_f paf,
5723 per_all_vacancies pav
5724 where ppf.party_id = p_party_id
5725 and paf.person_id = ppf.person_id
5726 and trunc(sysdate) between paf.effective_start_date and paf.effective_end_date
5727 and trunc(sysdate) between ppf.effective_start_date and ppf.effective_end_date
5728 and paf.vacancy_id = pav.vacancy_id;
5729 --
5730 Cursor csr_secured_apl_count is
5731 select count(pav.vacancy_id)
5732 from per_people_f ppf,
5733 per_assignments_f2 paf,
5734 per_vacancies pav
5735 where ppf.party_id = p_party_id
5736 and paf.person_id = ppf.person_id
5737 and trunc(sysdate) between paf.effective_start_date and paf.effective_end_date
5738 and trunc(sysdate) between ppf.effective_start_date and ppf.effective_end_date
5739 and paf.vacancy_id = pav.vacancy_id;
5740 -- Variable declarations
5741 --
5742 l_view_all_count number := -1;
5743 l_secure_apl_count number := -1;
5744 --
5745 begin
5746 --
5747 open csr_view_all_apl_count;
5748 fetch csr_view_all_apl_count into l_view_all_count;
5749 close csr_view_all_apl_count;
5750 --
5751 open csr_secured_apl_count;
5752 fetch csr_secured_apl_count into l_secure_apl_count;
5753 close csr_secured_apl_count;
5754 --
5755 if l_view_all_count<>l_secure_apl_count then
5756 RETURN 'TRUE';
5757 else
5758 RETURN 'FALSE';
5759 end if;
5760 --
5761 end check_security;
5762 --
5763 --
5764 FUNCTION is_master_new
5765 (p_target_party_id IN number
5766 ,p_souce_party_id IN number
5767 ) return VARCHAR2
5768 --
5769 is
5770 --
5771 -- Cursor declarations
5772 --
5773 cursor csr_master_new is
5774 select 1
5775 from per_all_people_f ppf_source
5776 , per_all_people_f ppf_target
5777 where ppf_source.party_id = p_souce_party_id
5778 and ppf_target.party_id = p_target_party_id
5779 and ppf_target.effective_start_date > ppf_source.effective_start_date
5780 and ppf_target.effective_start_date = (select min(effective_start_date) from per_all_people_f where party_id = ppf_target.party_id)
5781 and ppf_source.effective_start_date = (select min(effective_start_date) from per_all_people_f where party_id = ppf_source.party_id);
5782 -- Variable declarations
5783 l_dummy number;
5784 begin
5785 --
5786 open csr_master_new;
5787 fetch csr_master_new into l_dummy;
5788 if csr_master_new%found then
5789 close csr_master_new;
5790 return 'TRUE';
5791 else
5792 close csr_master_new;
5793 return 'FALSE';
5794 end if;
5795 --
5796 end is_master_new;
5797 --
5798 --
5799 FUNCTION is_dup_appl_exists
5800 (p_target_party_id IN number
5801 ,p_souce_party_id IN number
5802 ) return VARCHAR2
5803 --
5804 is
5805 --
5806 -- Cursor declarations
5807 cursor csr_applications is
5808 select paf.assignment_id
5809 from per_all_people_f ppf,
5810 per_all_assignments_f paf
5811 where ppf.party_id = p_target_party_id
5812 and paf.person_id = ppf.person_id
5813 and trunc(sysdate) between paf.effective_start_date and paf.effective_end_date
5814 and exists (select null
5815 from per_all_people_f ppf1,
5816 per_all_assignments_f paf1
5817 where ppf1.party_id = p_souce_party_id
5818 and paf1.person_id = ppf1.person_id
5819 and trunc(sysdate) between paf1.effective_start_date and paf1.effective_end_date
5820 and paf.vacancy_id = nvl(paf1.vacancy_id, -99));
5821 -- Variable declarations
5822 l_dummy number;
5823 --
5824 begin
5825 --
5826 open csr_applications;
5827 fetch csr_applications into l_dummy;
5828 if csr_applications%found then
5829 close csr_applications;
5830 return 'TRUE';
5831 else
5832 close csr_applications;
5833 return 'FALSE';
5834 end if;
5835 --
5836 end is_dup_appl_exists;
5837 --
5838 --
5839 FUNCTION future_person_type_exists
5840 (p_party_id IN number
5841 ) return VARCHAR2
5842 --
5843 is
5844 --
5845 -- Cursor declarations
5846 cursor csr_get_persons_for_party (c_party_id number) is
5847 select person_id
5848 from per_all_people_f
5849 where party_id = c_party_id
5850 and trunc(sysdate) between effective_start_date and effective_end_date;
5851 --
5852 cursor csr_sys_person_type(c_person_id number) is
5853 select pet.system_person_type
5854 from per_all_people_f per,
5855 per_person_types pet
5856 where per.person_type_id = pet.person_type_id
5857 and per.person_id = c_person_id
5858 and trunc(sysdate) between per.effective_start_date and per.effective_end_date;
5859 --
5860 cursor csr_ptu_details(c_person_id number) is
5861 select person_type_usage_id
5862 from per_person_type_usages_f
5863 where person_id = c_person_id
5864 and trunc(sysdate) between effective_start_date and effective_end_date;
5865 --
5866 -- Variable declarations
5867 --
5868 l_s_person_type per_person_types.system_person_type%type;
5869 l_ptu_id per_person_type_usages_f.person_type_usage_id%type;
5870 --
5871 --
5872 begin
5873 --
5874 for csr_persons in csr_get_persons_for_party (p_party_id) loop
5875 --
5876 open csr_sys_person_type(csr_persons.person_id);
5877 fetch csr_sys_person_type into l_s_person_type;
5878 close csr_sys_person_type;
5879 --
5880 open csr_ptu_details(csr_persons.person_id);
5881 fetch csr_ptu_details into l_ptu_id;
5882 close csr_ptu_details;
5883 --
5884 if (l_s_person_type = 'APL') then
5885 --
5886 if(hr_person_type_usage_info.Futsyspertypechgexists(l_ptu_id
5887 ,trunc(sysdate)
5888 ,csr_persons.person_id)
5889 ) then
5890 --
5891 RETURN 'TRUE';
5892 --
5893 end if;
5894 --
5895 end if;
5896 end loop;
5897 --
5898 RETURN 'FALSE';
5899 --
5900 end future_person_type_exists;
5901 --
5902 --
5903 FUNCTION is_person_created_today
5904 (p_party_id IN number
5905 ) return VARCHAR2
5906 --
5907 is
5908 --
5909 -- Cursor declarations
5910 --
5911 Cursor csr_created is
5912 Select 1
5913 From PER_ALL_PEOPLE_F ppf
5914 Where trunc(sysdate) = (select min(effective_start_date) from per_all_people_f where party_id=ppf.party_id)
5915 AND ppf.party_id=p_party_id;
5916 --Variable declarations
5917 l_dummy number;
5918 begin
5919 --
5920 open csr_created;
5921 fetch csr_created into l_dummy;
5922 if csr_created%found then
5923 close csr_created;
5924 return 'TRUE';
5925 else
5926 close csr_created;
5927 return 'FALSE';
5928 end if;
5929 --
5930 end is_person_created_today;
5931 --
5932 --
5933 --
5934 -- ----------------------------------------------------------------------------
5935 -- |-----------------------< validate_copy_applications >----------------------|
5936 -- ----------------------------------------------------------------------------
5937 --
5938 -- {Start Of Comments}
5939 --
5940 -- {End Of Comments}
5941 --
5942 procedure validate_copy_applications
5943 (p_validate IN boolean default false
5944 ,p_target_party_id IN number
5945 ,p_source_party_list IN varchar2
5946 ,p_return_status OUT NOCOPY varchar2
5947 )
5948 is
5949 --
5950 errorExists boolean;
5951 warningExists boolean;
5952 sourcePartyList irc_party_api.idList;
5953 workStr VARCHAR2(4000);
5954 singleVal VARCHAR2(400);
5955 charPos BINARY_INTEGER;
5956 sep VARCHAR2(1) := ',';
5957 l_index number;
5958 --
5959 l_target_user_exists varchar2(10);
5960 l_source_user_exists varchar2(10);
5961 l_active_offer_exists varchar2(10);
5962 l_future_person_exists varchar2(10);
5963 l_target_fut_person_exists varchar2(10);
5964 l_check_vacancy_security varchar2(10);
5965 l_source_created_today varchar2(10);
5966 l_no_applications_to_copy varchar2(10);
5967 l_master_profile_new varchar2(10);
5968 l_duplicate_appl_exists varchar2(10);
5969 --
5970 begin
5971 --
5972 -- Enable multi message
5973 hr_multi_message.enable_message_list;
5974 --
5975 --
5976 workStr := p_source_party_list;
5977 l_index := 1;
5978 WHILE (INSTR(workStr,sep) > 0 ) LOOP
5979 charPos := INSTR(workStr,sep);
5980 singleVal := SUBSTR(workStr,0,charPos - 1);
5981 workStr := SUBSTR(workStr,charPos + 1);
5982 sourcePartyList(l_index) := to_number(singleVal);
5983 l_index := l_index+1;
5984 END LOOP;
5985 --
5986 --Last value, or THE value if there is only one.
5987 singleVal := workStr;
5988 sourcePartyList(l_index) := to_number(singleVal);
5989 --
5990 --
5991 -- All the validations goes here
5992 --
5993 -- User Account Check
5994 l_target_user_exists := is_user_account_available(p_target_party_id);
5995 --
5996 for i in 1 .. sourcePartyList.count loop
5997 --
5998 l_source_user_exists := is_user_account_available(sourcePartyList(i));
5999 if l_source_user_exists='TRUE' then
6000 exit;
6001 end if;
6002 --
6003 end loop;
6004 --
6005 -- Raise error when target user does not exist and source user exists
6006 if l_source_user_exists='TRUE' and l_target_user_exists='FALSE' then
6007 fnd_message.set_name('PER','IRC_412645_FD_MASTER_NO_USER');
6008 hr_multi_message.add (p_message_type => hr_multi_message.g_error_msg);
6009 errorExists := true;
6010 end if;
6011 --
6012 -- Active Offer Check
6013 for i in 1 .. sourcePartyList.count loop
6014 --
6015 l_active_offer_exists := check_offer_exist(sourcePartyList(i));
6016 if l_active_offer_exists='TRUE' then
6017 exit;
6018 end if;
6019 --
6020 end loop;
6021 --
6022 -- Raise error when active offer exists for the source
6023 if l_active_offer_exists='TRUE' then
6024 fnd_message.set_name('PER','IRC_412641_FD_ACTIVE_OFFER');
6025 hr_multi_message.add (p_message_type => hr_multi_message.g_error_msg);
6026 errorExists := true;
6027 end if;
6028 --
6029 -- Future Person Type Check
6030 --
6031 l_target_fut_person_exists := future_person_type_exists(p_target_party_id);
6032 for i in 1 .. sourcePartyList.count loop
6033 --
6034 l_future_person_exists := future_person_type_exists(sourcePartyList(i));
6035 if l_future_person_exists='TRUE' then
6036 exit;
6037 end if;
6038 --
6039 end loop;
6040 --
6041 -- Raise error if future person types exist for source or target
6042 if l_future_person_exists='TRUE' or l_target_fut_person_exists='TRUE' then
6043 fnd_message.set_name('PER','IRC_412647_FD_FUTURE_PER_TYPE');
6044 hr_multi_message.add (p_message_type => hr_multi_message.g_error_msg);
6045 errorExists := true;
6046 end if;
6047 --
6048 -- Vacancy Security Check
6049 for i in 1 .. sourcePartyList.count loop
6050 --
6051 l_check_vacancy_security := check_security(sourcePartyList(i));
6052 if l_check_vacancy_security='TRUE' then
6053 exit;
6054 end if;
6055 --
6056 end loop;
6057 --
6058 -- Raise error if security restrictions exists for applications,vacancy
6059 if l_check_vacancy_security='TRUE' then
6060 fnd_message.set_name('PER','IRC_412642_FD_SECURITY');
6061 hr_multi_message.add (p_message_type => hr_multi_message.g_error_msg);
6062 errorExists := true;
6063 end if;
6064 --
6065 -- Source created today check
6066 for i in 1 .. sourcePartyList.count loop
6067 --
6068 l_source_created_today := is_person_created_today(sourcePartyList(i));
6069 if l_source_created_today='TRUE' then
6070 exit;
6071 end if;
6072 --
6073 end loop;
6074 -- Raise error if source person is created today
6075 if l_source_created_today='TRUE' then
6076 fnd_message.set_name('PER','IRC_412648_FD_SOURCE_CR_TODAY');
6077 hr_multi_message.add (p_message_type => hr_multi_message.g_error_msg);
6078 errorExists := true;
6079 end if;
6080 --
6081 --
6082 -- No applications to copy check
6083 for i in 1 .. sourcePartyList.count loop
6084 --
6085 l_no_applications_to_copy := check_copy_applications_exist(sourcePartyList(i));
6086 if l_source_created_today='TRUE' then
6087 exit;
6088 end if;
6089 --
6090 end loop;
6091 -- Raise warning if source person is created today
6092 if l_source_created_today='TRUE' then
6093 fnd_message.set_name('PER','IRC_412646_FD_NO_APPL_TO_COPY');
6094 hr_multi_message.add (p_message_type => hr_multi_message.g_warning_msg);
6095 warningExists := true;
6096 end if;
6097 --
6098 --
6099 -- Master profile new check
6100 for i in 1 .. sourcePartyList.count loop
6101 --
6102 l_master_profile_new := is_master_new(p_target_party_id,sourcePartyList(i));
6103 if l_master_profile_new='TRUE' then
6104 exit;
6105 end if;
6106 --
6107 end loop;
6108 --
6109 -- Raise warning if source person is created today
6110 if l_master_profile_new='TRUE' then
6111 fnd_message.set_name('PER','IRC_412643_FD_MASTER_NEW');
6112 hr_multi_message.add (p_message_type => hr_multi_message.g_warning_msg);
6113 warningExists := true;
6114 end if;
6115 --
6116 -- Application exists for same vacancy check
6117 for i in 1 .. sourcePartyList.count loop
6118 --
6119 l_duplicate_appl_exists := is_dup_appl_exists(p_target_party_id,sourcePartyList(i));
6120 if l_duplicate_appl_exists='TRUE' then
6121 exit;
6122 end if;
6123 --
6124 end loop;
6125 --
6126 -- Raise warning if source person is created today
6127 if l_duplicate_appl_exists='TRUE' then
6128 fnd_message.set_name('PER','IRC_412644_FD_DUPLICATE_APPL');
6129 hr_multi_message.add (p_message_type => hr_multi_message.g_warning_msg);
6130 warningExists := true;
6131 end if;
6132 --
6133 if errorExists then
6134 p_return_status := 'E';
6135 elsif warningExists then
6136 p_return_status := 'W';
6137 else
6138 p_return_status := 'S';
6139 end if;
6140 --
6141 if errorExists or warningExists then
6142 fnd_message.raise_error;
6143 end if;
6144 --
6145 --
6146 exception
6147 --
6148 when others then
6149 null;
6150 --
6151 end validate_copy_applications;
6152 --
6153 -- -------------------------------------------------------------------------
6154 -- |---------------------< ofr_reg_user_application >-----------------------|
6155 -- -------------------------------------------------------------------------
6156 --
6157 procedure ofr_reg_user_application
6158 (p_effective_date IN date
6159 ,p_recruitment_person_id IN number
6160 ,p_business_group_id IN number
6161 ,p_organization_id IN number default null
6162 ,p_manager_id IN number default null
6163 ,p_asg_id OUT NOCOPY number ) is
6164 PRAGMA autonomous_transaction;
6165 --
6166 l_proc varchar2(72) := g_package||'ofr_reg_user_application';
6167 l_per_object_version_number per_all_people_f.object_version_number%TYPE;
6168 l_asg_object_version_number per_all_assignments_f.object_version_number%TYPE;
6169 l_person_id per_all_people_f.person_id%TYPE;
6170 l_party_id per_all_people_f.party_id%TYPE;
6171 l_assignment_id per_all_assignments_f.assignment_id%TYPE;
6172 l_application_received_date date;
6173 l_party_last_update_date date;
6174 l_applicant_number per_all_people_f.applicant_number%type;
6175 l_person_type_id per_person_types.person_type_id%type;
6176 l_current_employee_flag per_all_people_f.current_employee_flag%type;
6177 l_current_applicant_flag per_all_people_f.current_applicant_flag%type;
6178 l_current_npw_flag per_all_people_f.current_npw_flag%type;
6179 --
6180 l_last_name per_all_people_f.last_name%type;
6181 l_first_name per_all_people_f.first_name%type;
6182 l_per_information1 per_all_people_f.per_information1%type;
6183 l_per_information2 per_all_people_f.per_information2%type;
6184 l_per_information18 per_all_people_f.per_information18%type;
6185 l_per_information19 per_all_people_f.per_information19%type;
6186 l_date_of_birth per_all_people_f.date_of_birth%type;
6187 l_title per_all_people_f.title%type;
6188 l_gender per_all_people_f.sex%type;
6189 l_marital_status per_all_people_f.marital_status%type;
6190 l_previous_last_name per_all_people_f.last_name%type;
6191 l_middle_name per_all_people_f.middle_names%type;
6192 l_name_suffix per_all_people_f.suffix%type;
6193 l_known_as per_all_people_f.known_as%type;
6194 l_job_id per_all_vacancies.job_id%type;
6195 l_position_id per_all_vacancies.position_id%type;
6196 l_grade_id per_all_vacancies.grade_id%type;
6197 l_location_id per_all_vacancies.location_id%type;
6198 l_recruiter_id per_all_vacancies.recruiter_id%type;
6199 l_people_group_id per_all_vacancies.people_group_id%type;
6200 l_legislation_code per_business_groups.legislation_code%type;
6201 l_effective_date date;
6202 --
6203 -- variables for hr_person_api.update_person
6204 --
6205 l_object_version_number per_all_people_f.object_version_number%TYPE;
6206 --
6207 -- dummy variables
6208 --
6209 l_var varchar2(1);
6210 l_effective_start_date date;
6211 l_effective_end_date date;
6212 l_comment_id number;
6213 l_name_combination_warning boolean;
6214 l_orig_hire_warning boolean;
6215 l_object_version_number_d per_all_people_f.object_version_number%TYPE;
6216 -- those required for hr_assignment_api.create_secondary_apl_asg
6217 l_concatenated_segments varchar2(2000);
6218 l_cagr_grade_def_id number;
6219 l_cagr_concatenated_segments varchar2(2000);
6220 l_group_name pay_people_groups.group_name%type;
6221 l_soft_coding_keyflex_id number;
6222 l_assignment_sequence per_all_assignments_f.assignment_sequence%type;
6223 -- those required for hr_applicant_api.create_applicant
6224 l_application_id number;
6225 l_full_name per_all_people_f.full_name%type;
6226 l_person_type per_person_types.system_person_type%type;
6227 l_ptu_person_type_id number;
6228 -- for disabling the descriptive flex field
6229 l_add_struct_d hr_dflex_utility.l_ignore_dfcode_varray :=
6230 hr_dflex_utility.l_ignore_dfcode_varray();
6231 -- for disabling the key flex field
6232 l_add_struct_k hr_kflex_utility.l_ignore_kfcode_varray :=
6233 hr_kflex_utility.l_ignore_kfcode_varray();
6234 --
6235 l_time_normal_finish per_business_groups.default_end_time%TYPE;
6236 l_time_normal_start per_business_groups.default_start_time%TYPE;
6237 l_normal_hours number;
6238 l_frequency per_business_groups.frequency%TYPE;
6239 l_per_information4 per_all_people_f.per_information4%type;
6240
6241 --
6242 -- cursor to select entries IN per_all_people_f
6243 -- relating to registered user
6244 --
6245 cursor csr_person_id(p_party_id number
6246 ,p_effective_date date
6247 ,p_business_group_id number) is
6248 select per.person_id
6249 ,per.object_version_number
6250 ,per.current_employee_flag
6251 ,per.current_applicant_flag
6252 ,per.current_npw_flag
6253 ,per.applicant_number
6254 from per_all_people_f per
6255 where per.party_id = p_party_id
6256 and p_effective_date between per.effective_start_date and per.effective_end_date
6257 and business_group_id = p_business_group_id;
6258 --
6259 -- cursor to select entries IN per_all_people_f
6260 -- for a given person over all dates
6261 --
6262 cursor csr_person_all_dates(p_party_id number
6263 ,p_business_group_id number) is
6264 select null
6265 from per_all_people_f per
6266 where per.party_id = p_party_id
6267 and business_group_id=p_business_group_id;
6268 --
6269 --
6270 -- cursor to select person details for the registered user
6271 --
6272 cursor csr_party_details(p_person_id number,p_effective_date date) is
6273 select last_update_date
6274 ,party_id
6275 ,last_name
6276 ,first_name
6277 ,date_of_birth
6278 ,title
6279 ,sex
6280 ,marital_status
6281 ,previous_last_name
6282 ,middle_names
6283 ,suffix
6284 ,known_as
6285 ,per_information1
6286 ,per_information2
6287 ,per_information18
6288 ,per_information19
6289 from per_all_people_f
6290 where person_id = p_person_id
6291 and p_effective_date between effective_start_date and effective_end_date;
6292 --
6293 cursor get_new_asg(p_person_id number, p_effective_date date) is
6294 select assignment_id,object_version_number
6295 from per_all_assignments_f
6296 where person_id = p_person_id
6297 and effective_start_date = p_effective_date
6298 and assignment_type='A';
6299 --
6300 -- Cursors to get work schedule
6301 --
6302 CURSOR csr_org_default_details(p_organization_id Number) IS
6303 SELECT org.org_information1
6304 , org.org_information2
6305 , fnd_number.canonical_to_number(org.org_information3) normal_hours
6306 , org.org_information4
6307 FROM HR_ORGANIZATION_INFORMATION org
6308 WHERE org.organization_id = p_organization_id
6309 AND org.org_information_context(+) = 'Work Day Information';
6310 --
6311 CURSOR csr_get_bg_default_details(p_business_group_id number) IS
6312 SELECT bus.default_start_time
6313 , bus.default_end_time
6314 , fnd_number.canonical_to_number(bus.working_hours)
6315 , bus.frequency
6316 FROM per_business_groups bus
6317 WHERE bus.business_group_id = p_business_group_id;
6318 --
6319 begin
6320 --
6321 hr_utility.set_location('Entering: ' || l_proc, 10);
6322 hr_utility.set_location('p_effective_date '||p_effective_date, 20);
6323 hr_utility.set_location('p_recruitment_person_id '||p_recruitment_person_id, 30);
6324 hr_utility.set_location('p_business_group_id '||p_business_group_id, 40);
6325 hr_utility.set_location('p_organization_id '||p_organization_id, 50);
6326 hr_utility.set_location('p_manager_id '||p_manager_id, 60);
6327 --
6328 -- Issue a savepoint
6329 --
6330 savepoint OFR_REG_USER_APPLICATION;
6331 --
6332 l_effective_date := p_effective_date;
6333 l_application_received_date := l_effective_date;
6334 --
6335 -- Added for turn off key flex field validation
6336 --
6337 l_add_struct_k.extend(1);
6338 l_add_struct_k(l_add_struct_k.count) := 'GRP';
6339 l_add_struct_k.extend(1);
6340 l_add_struct_k(l_add_struct_k.count) := 'CAGR';
6341 l_add_struct_k.extend(1);
6342 l_add_struct_k(l_add_struct_k.count) := 'SCL';
6343 --
6344 hr_kflex_utility.create_ignore_kf_validation(p_rec => l_add_struct_k);
6345 hr_utility.set_location(' After Calling hr_kflex_utility.create_ignore_kf_validation ', 70);
6346 --
6347 -- code for disabling the descriptive flex field
6348 l_add_struct_d.extend(1);
6349 l_add_struct_d(l_add_struct_d.count) := 'PER_ASSIGNMENTS';
6350 l_add_struct_d.extend(1);
6351 l_add_struct_d(l_add_struct_d.count) := 'Person Developer DF';
6352 l_add_struct_d.extend(1);
6353 l_add_struct_d(l_add_struct_d.count) := 'PER_PEOPLE';
6354 --
6355 hr_dflex_utility.create_ignore_df_validation(p_rec => l_add_struct_d);
6356 hr_utility.set_location(' After Calling hr_dflex_utility.create_ignore_df_validation ', 80);
6357 --
6358 --
6359 -- Process Logic
6360 --
6361 -- get person info for recruitment person
6362 --
6363 open csr_party_details(p_recruitment_person_id,l_effective_date);
6364 fetch csr_party_details into l_party_last_update_date
6365 ,l_party_id
6366 ,l_last_name
6367 ,l_first_name
6368 ,l_date_of_birth
6369 ,l_title
6370 ,l_gender
6371 ,l_marital_status
6372 ,l_previous_last_name
6373 ,l_middle_name
6374 ,l_name_suffix
6375 ,l_known_as
6376 ,l_per_information1
6377 ,l_per_information2
6378 ,l_per_information18
6379 ,l_per_information19;
6380 close csr_party_details;
6381 --
6382 --
6383 open csr_person_id(l_party_id, l_effective_date,p_business_group_id);
6384 fetch csr_person_id into l_person_id
6385 ,l_per_object_version_number
6386 ,l_current_employee_flag
6387 ,l_current_applicant_flag
6388 ,l_current_npw_flag
6389 ,l_applicant_number;
6390 --
6391 -- check if there is an out of date person
6392 --
6393 open csr_person_all_dates(l_party_id, p_business_group_id);
6394 fetch csr_person_all_dates into l_var;
6395 --
6396 if ( csr_person_id%notfound and csr_person_all_dates%found ) then
6397 --
6398 close csr_person_id;
6399 close csr_person_all_dates;
6400 fnd_message.set_name('PER','IRC_412099_CANNOT_APPLY');
6401 hr_multi_message.add();
6402 end if;
6403 close csr_person_all_dates;
6404 --
6405 --
6406 -- Get the work schedule.
6407 --
6408 open csr_org_default_details(p_organization_id);
6409 fetch csr_org_default_details into l_time_normal_start
6410 , l_time_normal_finish
6411 , l_normal_hours
6412 , l_frequency;
6413 close csr_org_default_details;
6414 --
6415 --
6416 IF (l_time_normal_start IS NULL AND l_time_normal_finish IS NULL AND
6417 l_normal_hours IS NULL AND l_frequency iS NULL) THEN
6418 open csr_get_bg_default_details(p_business_group_id);
6419 fetch csr_get_bg_default_details into l_time_normal_start
6420 , l_time_normal_finish
6421 , l_normal_hours
6422 , l_frequency;
6423 if csr_get_bg_default_details%NOTFOUND then
6424 --
6425 close csr_get_bg_default_details;
6426 --
6427 hr_utility.set_message(801, 'HR_7208_API_BUS_GRP_INVALID');
6428 hr_utility.raise_error;
6429 end if;
6430 close csr_get_bg_default_details;
6431 END IF;
6432 --
6433 if csr_person_id%found then
6434 --
6435 if (l_current_applicant_flag = 'Y') then
6436 hr_utility.set_location('Calling hr_assignment_api.create_secondary_apl_asg ', 90);
6437 hr_assignment_api.create_secondary_apl_asg
6438 (p_validate => false
6439 ,p_effective_date => l_effective_date
6440 ,p_person_id => l_person_id
6441 ,p_organization_id => nvl(p_organization_id,p_business_group_id)
6442 ,p_job_id => l_job_id
6443 ,p_position_id => l_position_id
6444 ,p_grade_id => l_grade_id
6445 ,p_people_group_id => l_people_group_id
6446 ,p_frequency => l_frequency
6447 ,p_normal_hours => l_normal_hours
6448 ,p_time_normal_finish => l_time_normal_finish
6449 ,p_time_normal_start => l_time_normal_start
6450 ,p_location_id => l_location_id
6451 ,p_recruiter_id => l_recruiter_id
6452 ,p_supervisor_id => p_manager_id
6453 ,p_concatenated_segments => l_concatenated_segments
6454 ,p_cagr_grade_def_id => l_cagr_grade_def_id
6455 ,p_cagr_concatenated_segments=> l_cagr_concatenated_segments
6456 ,p_group_name => l_group_name
6457 ,p_assignment_id => l_assignment_id
6458 ,p_soft_coding_keyflex_id => l_soft_coding_keyflex_id
6459 ,p_comment_id => l_comment_id
6460 ,p_object_version_number => l_asg_object_version_number
6461 ,p_effective_start_date => l_effective_start_date
6462 ,p_effective_end_date => l_effective_end_date
6463 ,p_assignment_sequence => l_assignment_sequence
6464 );
6465 elsif (l_current_employee_flag = 'Y') then
6466 hr_utility.set_location('hr_employee_api.apply_for_internal_vacancy ', 100);
6467 hr_employee_api.apply_for_internal_vacancy
6468 (p_validate => false
6469 ,p_effective_date => l_effective_date
6470 ,p_person_id => l_person_id
6471 ,p_applicant_number => l_applicant_number
6472 ,p_per_object_version_number => l_per_object_version_number
6473 ,p_application_id => l_application_id
6474 ,p_assignment_id => l_assignment_id
6475 ,p_apl_object_version_number => l_object_version_number_d
6476 ,p_asg_object_version_number => l_asg_object_version_number
6477 ,p_assignment_sequence => l_assignment_sequence
6478 ,p_per_effective_start_date => l_effective_start_date
6479 ,p_per_effective_end_date => l_effective_end_date);
6480 --
6481 hr_utility.set_location('Calling hr_assignment_api.update_apl_asg ', 110);
6482 hr_assignment_api.update_apl_asg
6483 (p_effective_date => l_effective_date
6484 ,p_datetrack_update_mode => 'CORRECTION'
6485 ,p_assignment_id => l_assignment_id
6486 ,p_object_version_number => l_asg_object_version_number
6487 ,p_supervisor_id => p_manager_id
6488 ,p_concatenated_segments => l_concatenated_segments
6489 ,p_cagr_grade_def_id => l_cagr_grade_def_id
6490 ,p_cagr_concatenated_segments=> l_cagr_concatenated_segments
6491 ,p_group_name => l_group_name
6492 ,p_comment_id => l_comment_id
6493 ,p_soft_coding_keyflex_id => l_soft_coding_keyflex_id
6494 ,p_people_group_id => l_people_group_id
6495 ,p_frequency => l_frequency
6496 ,p_normal_hours => l_normal_hours
6497 ,p_time_normal_finish => l_time_normal_finish
6498 ,p_time_normal_start => l_time_normal_start
6499 ,p_effective_start_date => l_effective_start_date
6500 ,p_effective_end_date => l_effective_end_date
6501 );
6502 elsif (l_current_npw_flag = 'Y') then
6503 hr_utility.set_location('Calling hr_contingent_worker_api.apply_for_job ', 120);
6504 hr_contingent_worker_api.apply_for_job
6505 (p_validate => false
6506 ,p_effective_date => l_effective_date
6507 ,p_person_id => l_person_id
6508 ,p_object_version_number => l_per_object_version_number
6509 ,p_applicant_number => l_applicant_number
6510 ,p_per_effective_start_date => l_effective_start_date
6511 ,p_per_effective_end_date => l_effective_end_date
6512 ,p_application_id => l_application_id
6513 ,p_apl_object_version_number => l_object_version_number_d
6514 ,p_assignment_id => l_assignment_id
6515 ,p_asg_object_version_number => l_asg_object_version_number
6516 ,p_assignment_sequence => l_assignment_sequence
6517 );
6518 --
6519 hr_utility.set_location('Calling hr_assignment_api.update_apl_asg ', 130);
6520 hr_assignment_api.update_apl_asg
6521 (p_effective_date => l_effective_date
6522 ,p_datetrack_update_mode => 'CORRECTION'
6523 ,p_assignment_id => l_assignment_id
6524 ,p_object_version_number => l_asg_object_version_number
6525 ,p_supervisor_id => p_manager_id
6526 ,p_concatenated_segments => l_concatenated_segments
6527 ,p_cagr_grade_def_id => l_cagr_grade_def_id
6528 ,p_cagr_concatenated_segments=> l_cagr_concatenated_segments
6529 ,p_group_name => l_group_name
6530 ,p_comment_id => l_comment_id
6531 ,p_soft_coding_keyflex_id => l_soft_coding_keyflex_id
6532 ,p_people_group_id => l_people_group_id
6533 ,p_frequency => l_frequency
6534 ,p_normal_hours => l_normal_hours
6535 ,p_time_normal_finish => l_time_normal_finish
6536 ,p_time_normal_start => l_time_normal_start
6537 ,p_effective_start_date => l_effective_start_date
6538 ,p_effective_end_date => l_effective_end_date
6539 );
6540 else
6541 hr_utility.set_location('Calling hr_applicant_api.convert_to_applicant ', 140);
6542 hr_applicant_api.convert_to_applicant
6543 (p_validate => false
6544 ,p_effective_date => l_effective_date
6545 ,p_person_id => l_person_id
6546 ,p_object_version_number => l_per_object_version_number
6547 ,p_applicant_number => l_applicant_number
6548 ,p_person_type_id => l_person_type_id
6549 ,p_effective_start_date => l_effective_start_date
6550 ,p_effective_end_date => l_effective_end_date);
6551 --
6552 open get_new_asg(l_person_id,l_effective_date);
6553 fetch get_new_asg into l_assignment_id,l_asg_object_version_number;
6554 close get_new_asg;
6555 --
6556 hr_utility.set_location('Calling hr_assignment_api.update_apl_asg ', 150);
6557 hr_assignment_api.update_apl_asg
6558 (p_effective_date => l_effective_date
6559 ,p_datetrack_update_mode => 'CORRECTION'
6560 ,p_assignment_id => l_assignment_id
6561 ,p_object_version_number => l_asg_object_version_number
6562 ,p_organization_id => nvl(p_organization_id,p_business_group_id)
6563 ,p_job_id => l_job_id
6564 ,p_position_id => l_position_id
6565 ,p_grade_id => l_grade_id
6566 ,p_people_group_id => l_people_group_id
6567 ,p_location_id => l_location_id
6568 ,p_recruiter_id => l_recruiter_id
6569 ,p_supervisor_id => p_manager_id
6570 ,p_concatenated_segments => l_concatenated_segments
6571 ,p_cagr_grade_def_id => l_cagr_grade_def_id
6572 ,p_cagr_concatenated_segments=> l_cagr_concatenated_segments
6573 ,p_group_name => l_group_name
6574 ,p_comment_id => l_comment_id
6575 ,p_soft_coding_keyflex_id => l_soft_coding_keyflex_id
6576 ,p_frequency => l_frequency
6577 ,p_normal_hours => l_normal_hours
6578 ,p_time_normal_finish => l_time_normal_finish
6579 ,p_time_normal_start => l_time_normal_start
6580 ,p_effective_start_date => l_effective_start_date
6581 ,p_effective_end_date => l_effective_end_date
6582 );
6583 end if;
6584 else
6585 select pbg.legislation_code into l_legislation_code
6586 from per_business_groups pbg
6587 where pbg.business_group_id = p_business_group_id;
6588 --
6589 l_applicant_number:=null;
6590 if (l_legislation_code = 'JP') then
6591 hr_utility.set_location('Calling hr_applicant_api.create_applicant ', 160);
6592 hr_applicant_api.create_applicant
6593 (p_validate => false
6594 ,p_date_received => l_application_received_date
6595 ,p_business_group_id => p_business_group_id
6596 ,p_last_name => l_last_name
6597 ,p_first_name => l_first_name
6598 ,p_per_information18 => l_per_information18
6599 ,p_per_information19 => l_per_information19
6600 ,p_date_of_birth => l_date_of_birth
6601 ,p_applicant_number => l_applicant_number
6602 ,p_previous_last_name => l_previous_last_name
6603 ,p_known_as => l_known_as
6604 ,p_marital_status => l_marital_status
6605 ,p_middle_names => l_middle_name
6606 ,p_suffix => l_name_suffix
6607 ,p_person_id => l_person_id
6608 ,p_assignment_id => l_assignment_id
6609 ,p_application_id => l_application_id
6610 ,p_per_object_version_number => l_per_object_version_number
6611 ,p_asg_object_version_number => l_asg_object_version_number
6612 ,p_apl_object_version_number => l_object_version_number_d
6613 ,p_per_effective_start_date => l_effective_start_date
6614 ,p_per_effective_end_date => l_effective_end_date
6615 ,p_full_name => l_full_name
6616 ,p_per_comment_id => l_comment_id
6617 ,p_assignment_sequence => l_assignment_sequence
6618 ,p_name_combination_warning => l_name_combination_warning
6619 ,p_orig_hire_warning => l_orig_hire_warning
6620 ,p_party_id => l_party_id
6621 );
6622 elsif (l_legislation_code = 'KR') then
6623 hr_utility.set_location('Calling hr_applicant_api.create_applicant ', 170);
6624 hr_applicant_api.create_applicant
6625 (p_validate => false
6626 ,p_date_received => l_application_received_date
6627 ,p_business_group_id => p_business_group_id
6628 ,p_last_name => l_last_name
6629 ,p_first_name => l_first_name
6630 ,p_per_information1 => l_per_information1
6631 ,p_per_information2 => l_per_information2
6632 ,p_date_of_birth => l_date_of_birth
6633 ,p_applicant_number => l_applicant_number
6634 ,p_previous_last_name => l_previous_last_name
6635 ,p_known_as => l_known_as
6636 ,p_marital_status => l_marital_status
6637 ,p_middle_names => l_middle_name
6638 ,p_suffix => l_name_suffix
6639 ,p_person_id => l_person_id
6640 ,p_assignment_id => l_assignment_id
6641 ,p_application_id => l_application_id
6642 ,p_per_object_version_number => l_per_object_version_number
6643 ,p_asg_object_version_number => l_asg_object_version_number
6644 ,p_apl_object_version_number => l_object_version_number_d
6645 ,p_per_effective_start_date => l_effective_start_date
6646 ,p_per_effective_end_date => l_effective_end_date
6647 ,p_full_name => l_full_name
6648 ,p_per_comment_id => l_comment_id
6649 ,p_assignment_sequence => l_assignment_sequence
6650 ,p_name_combination_warning => l_name_combination_warning
6651 ,p_orig_hire_warning => l_orig_hire_warning
6652 ,p_party_id => l_party_id
6653 );
6654 elsif (l_legislation_code = 'ZA') then
6655 hr_utility.set_location('Calling hr_applicant_api.create_applicant ', 180);
6656 hr_applicant_api.create_applicant
6657 (p_validate => false
6658 ,p_date_received => l_application_received_date
6659 ,p_business_group_id => p_business_group_id
6660 ,p_last_name => l_last_name
6661 ,p_first_name => l_first_name
6662 ,p_per_information4 => l_per_information4
6663 ,p_date_of_birth => l_date_of_birth
6664 ,p_applicant_number => l_applicant_number
6665 ,p_previous_last_name => l_previous_last_name
6666 ,p_known_as => l_known_as
6667 ,p_marital_status => l_marital_status
6668 ,p_middle_names => l_middle_name
6669 ,p_suffix => l_name_suffix
6670 ,p_person_id => l_person_id
6671 ,p_assignment_id => l_assignment_id
6672 ,p_application_id => l_application_id
6673 ,p_per_object_version_number => l_per_object_version_number
6674 ,p_asg_object_version_number => l_asg_object_version_number
6675 ,p_apl_object_version_number => l_object_version_number_d
6676 ,p_per_effective_start_date => l_effective_start_date
6677 ,p_per_effective_end_date => l_effective_end_date
6678 ,p_full_name => l_full_name
6679 ,p_per_comment_id => l_comment_id
6680 ,p_assignment_sequence => l_assignment_sequence
6681 ,p_name_combination_warning => l_name_combination_warning
6682 ,p_orig_hire_warning => l_orig_hire_warning
6683 ,p_party_id => l_party_id
6684 );
6685 else
6686 hr_utility.set_location('Calling hr_applicant_api.create_applicant ', 190);
6687 hr_applicant_api.create_applicant
6688 (p_validate => false
6689 ,p_date_received => l_application_received_date
6690 ,p_business_group_id => p_business_group_id
6691 ,p_last_name => l_last_name
6692 ,p_first_name => l_first_name
6693 ,p_date_of_birth => l_date_of_birth
6694 ,p_applicant_number => l_applicant_number
6695 ,p_previous_last_name => l_previous_last_name
6696 ,p_known_as => l_known_as
6697 ,p_marital_status => l_marital_status
6698 ,p_middle_names => l_middle_name
6699 ,p_suffix => l_name_suffix
6700 ,p_person_id => l_person_id
6701 ,p_assignment_id => l_assignment_id
6702 ,p_application_id => l_application_id
6703 ,p_per_object_version_number => l_per_object_version_number
6704 ,p_asg_object_version_number => l_asg_object_version_number
6705 ,p_apl_object_version_number => l_object_version_number_d
6706 ,p_per_effective_start_date => l_effective_start_date
6707 ,p_per_effective_end_date => l_effective_end_date
6708 ,p_full_name => l_full_name
6709 ,p_per_comment_id => l_comment_id
6710 ,p_assignment_sequence => l_assignment_sequence
6711 ,p_name_combination_warning => l_name_combination_warning
6712 ,p_orig_hire_warning => l_orig_hire_warning
6713 ,p_party_id => l_party_id
6714 );
6715 end if;
6716 --
6717 -- get the PTU person type for iRecruitment Candidate
6718 --
6719 l_ptu_person_type_id:=hr_person_type_usage_info.get_default_person_type_id
6720 (p_business_group_id,
6721 'IRC_REG_USER');
6722 hr_utility.set_location('Value of IRC_REG_USER person_type_id: '|| l_ptu_person_type_id,200);
6723 --
6724 -- create the extra PTU entry for iRecruitment Candidate
6725 --
6726 hr_utility.set_location('Calling hr_per_type_usage_internal.maintain_person_type_usage ',210);
6727 hr_per_type_usage_internal.maintain_person_type_usage
6728 (p_effective_date => l_effective_start_date
6729 ,p_person_id => l_person_id
6730 ,p_person_type_id => l_ptu_person_type_id
6731 );
6732 --
6733 hr_utility.set_location('Calling hr_assignment_api.update_apl_asg ',220);
6734 hr_assignment_api.update_apl_asg
6735 (p_effective_date => l_application_received_date
6736 ,p_datetrack_update_mode => 'CORRECTION'
6737 ,p_assignment_id => l_assignment_id
6738 ,p_object_version_number => l_asg_object_version_number
6739 ,p_organization_id => nvl(p_organization_id,p_business_group_id)
6740 ,p_job_id => l_job_id
6741 ,p_position_id => l_position_id
6742 ,p_grade_id => l_grade_id
6743 ,p_people_group_id => l_people_group_id
6744 ,p_location_id => l_location_id
6745 ,p_recruiter_id => l_recruiter_id
6746 ,p_supervisor_id => p_manager_id
6747 ,p_concatenated_segments => l_concatenated_segments
6748 ,p_cagr_grade_def_id => l_cagr_grade_def_id
6749 ,p_cagr_concatenated_segments=> l_cagr_concatenated_segments
6750 ,p_group_name => l_group_name
6751 ,p_comment_id => l_comment_id
6752 ,p_soft_coding_keyflex_id => l_soft_coding_keyflex_id
6753 ,p_frequency => l_frequency
6754 ,p_normal_hours => l_normal_hours
6755 ,p_time_normal_finish => l_time_normal_finish
6756 ,p_time_normal_start => l_time_normal_start
6757 ,p_effective_start_date => l_effective_start_date
6758 ,p_effective_end_date => l_effective_end_date
6759 );
6760 end if;
6761 close csr_person_id;
6762 --
6763 -- Set all output arguments
6764 --
6765 p_asg_id := l_assignment_id;
6766 --
6767 -- commit autonmous transaction
6768 --
6769 commit;
6770 --
6771 hr_utility.set_location(' Leaving:'||l_proc, 230);
6772 --
6773 exception
6774 when others then
6775 --
6776 -- A validation or unexpected error has occured
6777 --
6778 -- Check whether csr_person_id is open or not. If open, close it.
6779 if csr_person_id%isopen then
6780 close csr_person_id;
6781 end if;
6782
6783 rollback to OFR_REG_USER_APPLICATION;
6784 --
6785 p_asg_id := null;
6786 --
6787 hr_utility.set_location(' Leaving:'||l_proc, 240);
6788 raise;
6789 end ofr_reg_user_application;
6790 --
6791 --
6792 procedure create_linking
6793 (p_src_apl_asg_id IN number
6794 ,p_tgt_apl_asg_id IN number
6795 ,p_vacancy_id IN number
6796 ,p_link_id OUT NOCOPY number ) is
6797 pragma autonomous_transaction;
6798 --
6799 l_link_id number default -1;
6800 --
6801 begin
6802 l_link_id := PER_VAC_LINKED_ASSIGNMENTS_S.nextval;
6803 insert into per_vac_linked_assignments(
6804 VAC_ASG_LINK_ID ,
6805 VACANCY_ID ,
6806 SRC_APL_ASG_ID ,
6807 TGT_APL_ASG_ID ,
6808 START_DATE ,
6809 END_DATE,
6810 OBJECT_VERSION_NUMBER
6811 ) values( l_link_id
6812 ,p_vacancy_id
6813 ,p_src_apl_asg_id
6814 ,p_tgt_apl_asg_id
6815 ,sysdate
6816 ,sysdate
6817 ,1);
6818 commit;
6819 p_link_id := l_link_id;
6820 exception
6821 when others then
6822 raise;
6823 end;
6824
6825 end irc_party_api;