[Home] [Help]
PACKAGE BODY: APPS.PAY_ELEMENT_LINK_API
Source
1 Package Body PAY_ELEMENT_LINK_API as
2 /* $Header: pypelapi.pkb 120.3.12020000.3 2013/02/11 06:02:35 kskoduri ship $ */
3 --
4 -- Package Variables
5 --
6 g_package varchar2(33) := 'pay_element_link_api';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |--------------------------<create_element_link>--------------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 procedure create_element_link
13 (p_validate in boolean default false
14 ,p_effective_date in date
15 ,p_element_type_id in number
16 ,p_business_group_id in number
17 ,p_costable_type in varchar2
18 ,p_payroll_id in number default null
19 ,p_job_id in number default null
20 ,p_position_id in number default null
21 ,p_people_group_id in number default null
22 ,p_cost_allocation_keyflex_id in number default null
23 ,p_organization_id in number default null
24 ,p_location_id in number default null
25 ,p_grade_id in number default null
26 ,p_balancing_keyflex_id in number default null
27 ,p_element_set_id in number default null
28 ,p_pay_basis_id in number default null
29 ,p_link_to_all_payrolls_flag in varchar2 default 'N'
30 ,p_standard_link_flag in varchar2 default null
31 ,p_transfer_to_gl_flag in varchar2 default 'N'
32 ,p_comments in varchar2 default null
33 ,p_employment_category in varchar2 default null
34 ,p_qualifying_age in number default null
35 ,p_qualifying_length_of_service in number default null
36 ,p_qualifying_units in varchar2 default null
37 ,p_attribute_category in varchar2 default null
38 ,p_attribute1 in varchar2 default null
39 ,p_attribute2 in varchar2 default null
40 ,p_attribute3 in varchar2 default null
41 ,p_attribute4 in varchar2 default null
42 ,p_attribute5 in varchar2 default null
43 ,p_attribute6 in varchar2 default null
44 ,p_attribute7 in varchar2 default null
45 ,p_attribute8 in varchar2 default null
46 ,p_attribute9 in varchar2 default null
47 ,p_attribute10 in varchar2 default null
48 ,p_attribute11 in varchar2 default null
49 ,p_attribute12 in varchar2 default null
50 ,p_attribute13 in varchar2 default null
51 ,p_attribute14 in varchar2 default null
52 ,p_attribute15 in varchar2 default null
53 ,p_attribute16 in varchar2 default null
54 ,p_attribute17 in varchar2 default null
55 ,p_attribute18 in varchar2 default null
56 ,p_attribute19 in varchar2 default null
57 ,p_attribute20 in varchar2 default null
58 ,p_cost_segment1 in varchar2 default null
59 ,p_cost_segment2 in varchar2 default null
60 ,p_cost_segment3 in varchar2 default null
61 ,p_cost_segment4 in varchar2 default null
62 ,p_cost_segment5 in varchar2 default null
63 ,p_cost_segment6 in varchar2 default null
64 ,p_cost_segment7 in varchar2 default null
65 ,p_cost_segment8 in varchar2 default null
66 ,p_cost_segment9 in varchar2 default null
67 ,p_cost_segment10 in varchar2 default null
68 ,p_cost_segment11 in varchar2 default null
69 ,p_cost_segment12 in varchar2 default null
70 ,p_cost_segment13 in varchar2 default null
71 ,p_cost_segment14 in varchar2 default null
72 ,p_cost_segment15 in varchar2 default null
73 ,p_cost_segment16 in varchar2 default null
74 ,p_cost_segment17 in varchar2 default null
75 ,p_cost_segment18 in varchar2 default null
76 ,p_cost_segment19 in varchar2 default null
77 ,p_cost_segment20 in varchar2 default null
78 ,p_cost_segment21 in varchar2 default null
79 ,p_cost_segment22 in varchar2 default null
80 ,p_cost_segment23 in varchar2 default null
81 ,p_cost_segment24 in varchar2 default null
82 ,p_cost_segment25 in varchar2 default null
83 ,p_cost_segment26 in varchar2 default null
84 ,p_cost_segment27 in varchar2 default null
85 ,p_cost_segment28 in varchar2 default null
86 ,p_cost_segment29 in varchar2 default null
87 ,p_cost_segment30 in varchar2 default null
88 ,p_balance_segment1 in varchar2 default null
89 ,p_balance_segment2 in varchar2 default null
90 ,p_balance_segment3 in varchar2 default null
91 ,p_balance_segment4 in varchar2 default null
92 ,p_balance_segment5 in varchar2 default null
93 ,p_balance_segment6 in varchar2 default null
94 ,p_balance_segment7 in varchar2 default null
95 ,p_balance_segment8 in varchar2 default null
96 ,p_balance_segment9 in varchar2 default null
97 ,p_balance_segment10 in varchar2 default null
98 ,p_balance_segment11 in varchar2 default null
99 ,p_balance_segment12 in varchar2 default null
100 ,p_balance_segment13 in varchar2 default null
101 ,p_balance_segment14 in varchar2 default null
102 ,p_balance_segment15 in varchar2 default null
103 ,p_balance_segment16 in varchar2 default null
104 ,p_balance_segment17 in varchar2 default null
105 ,p_balance_segment18 in varchar2 default null
106 ,p_balance_segment19 in varchar2 default null
107 ,p_balance_segment20 in varchar2 default null
108 ,p_balance_segment21 in varchar2 default null
109 ,p_balance_segment22 in varchar2 default null
110 ,p_balance_segment23 in varchar2 default null
111 ,p_balance_segment24 in varchar2 default null
112 ,p_balance_segment25 in varchar2 default null
113 ,p_balance_segment26 in varchar2 default null
114 ,p_balance_segment27 in varchar2 default null
115 ,p_balance_segment28 in varchar2 default null
116 ,p_balance_segment29 in varchar2 default null
117 ,p_balance_segment30 in varchar2 default null
118 ,p_cost_concat_segments in varchar2
119 ,p_balance_concat_segments in varchar2
120 ,p_element_link_id out nocopy number
121 ,p_comment_id out nocopy number
122 ,p_object_version_number out nocopy number
123 ,p_effective_start_date out nocopy date
124 ,p_effective_end_date out nocopy date
125 ) is
126 --
127 -- Declare cursors and local variables
128 --
129 l_proc varchar2(72) := g_package||'create_element_link';
130 l_effective_date date;
131
132 l_standard_link_flag pay_element_links_f.standard_link_flag%type
133 := p_standard_link_flag;
134 l_cost_allocation_id number := p_cost_allocation_keyflex_id;
135 l_bal_allocation_id number := p_balancing_keyflex_id;
136
137 --
138 -- Variables to hold the values returned.
139 --
140 l_element_link_id number;
141 l_comment_id number;
142 l_object_version_number number;
143 l_effective_start_date date;
144 l_effective_end_date date;
145 --
146 begin
147 hr_utility.set_location('Entering:'|| l_proc, 10);
148 --
149 -- Issue a savepoint
150 --
151 savepoint create_element_link;
152 --
153 -- Truncate the time portion from all IN date parameters
154 --
155 l_effective_date := trunc(p_effective_date);
156
157 --
158 -- Call Before Process User Hook
159 --
160 begin
161 pay_element_link_BK1.create_element_link_b
162 (p_effective_date => l_effective_date
163 ,p_element_type_id => p_element_type_id
164 ,p_business_group_id => p_business_group_id
165 ,p_costable_type => p_costable_type
166 ,p_payroll_id => p_payroll_id
167 ,p_job_id => p_job_id
168 ,p_position_id => p_position_id
169 ,p_people_group_id => p_people_group_id
170 ,p_cost_allocation_keyflex_id => l_cost_allocation_id
171 ,p_organization_id => p_organization_id
172 ,p_location_id => p_location_id
173 ,p_grade_id => p_grade_id
174 ,p_balancing_keyflex_id => l_bal_allocation_id
175 ,p_element_set_id => p_element_set_id
176 ,p_pay_basis_id => p_pay_basis_id
177 ,p_link_to_all_payrolls_flag => p_link_to_all_payrolls_flag
178 ,p_standard_link_flag => l_standard_link_flag
179 ,p_transfer_to_gl_flag => p_transfer_to_gl_flag
180 ,p_comments => p_comments
181 ,p_employment_category => p_employment_category
182 ,p_qualifying_age => p_qualifying_age
183 ,p_qualifying_length_of_service => p_qualifying_length_of_service
184 ,p_qualifying_units => p_qualifying_units
185 ,p_attribute_category => p_attribute_category
186 ,p_attribute1 => p_attribute1
187 ,p_attribute2 => p_attribute2
188 ,p_attribute3 => p_attribute3
189 ,p_attribute4 => p_attribute4
190 ,p_attribute5 => p_attribute5
191 ,p_attribute6 => p_attribute6
192 ,p_attribute7 => p_attribute7
193 ,p_attribute8 => p_attribute8
194 ,p_attribute9 => p_attribute9
195 ,p_attribute10 => p_attribute10
196 ,p_attribute11 => p_attribute11
197 ,p_attribute12 => p_attribute12
198 ,p_attribute13 => p_attribute13
199 ,p_attribute14 => p_attribute14
200 ,p_attribute15 => p_attribute15
201 ,p_attribute16 => p_attribute16
202 ,p_attribute17 => p_attribute17
203 ,p_attribute18 => p_attribute18
204 ,p_attribute19 => p_attribute19
205 ,p_attribute20 => p_attribute20
206 ,p_cost_segment1 => p_cost_segment1
207 ,p_cost_segment2 => p_cost_segment2
208 ,p_cost_segment3 => p_cost_segment3
209 ,p_cost_segment4 => p_cost_segment4
210 ,p_cost_segment5 => p_cost_segment5
211 ,p_cost_segment6 => p_cost_segment6
212 ,p_cost_segment7 => p_cost_segment7
213 ,p_cost_segment8 => p_cost_segment8
214 ,p_cost_segment9 => p_cost_segment9
215 ,p_cost_segment10 => p_cost_segment10
216 ,p_cost_segment11 => p_cost_segment11
217 ,p_cost_segment12 => p_cost_segment12
218 ,p_cost_segment13 => p_cost_segment13
219 ,p_cost_segment14 => p_cost_segment14
220 ,p_cost_segment15 => p_cost_segment15
221 ,p_cost_segment16 => p_cost_segment16
222 ,p_cost_segment17 => p_cost_segment17
223 ,p_cost_segment18 => p_cost_segment18
224 ,p_cost_segment19 => p_cost_segment19
225 ,p_cost_segment20 => p_cost_segment20
226 ,p_cost_segment21 => p_cost_segment21
227 ,p_cost_segment22 => p_cost_segment22
228 ,p_cost_segment23 => p_cost_segment23
229 ,p_cost_segment24 => p_cost_segment24
230 ,p_cost_segment25 => p_cost_segment25
231 ,p_cost_segment26 => p_cost_segment26
232 ,p_cost_segment27 => p_cost_segment27
233 ,p_cost_segment28 => p_cost_segment28
234 ,p_cost_segment29 => p_cost_segment29
235 ,p_cost_segment30 => p_cost_segment30
236 ,p_balance_segment1 => p_balance_segment1
237 ,p_balance_segment2 => p_balance_segment2
238 ,p_balance_segment3 => p_balance_segment3
239 ,p_balance_segment4 => p_balance_segment4
240 ,p_balance_segment5 => p_balance_segment5
241 ,p_balance_segment6 => p_balance_segment6
242 ,p_balance_segment7 => p_balance_segment7
243 ,p_balance_segment8 => p_balance_segment8
244 ,p_balance_segment9 => p_balance_segment9
245 ,p_balance_segment10 => p_balance_segment10
246 ,p_balance_segment11 => p_balance_segment11
247 ,p_balance_segment12 => p_balance_segment12
248 ,p_balance_segment13 => p_balance_segment13
249 ,p_balance_segment14 => p_balance_segment14
250 ,p_balance_segment15 => p_balance_segment15
251 ,p_balance_segment16 => p_balance_segment16
252 ,p_balance_segment17 => p_balance_segment17
253 ,p_balance_segment18 => p_balance_segment18
254 ,p_balance_segment19 => p_balance_segment19
255 ,p_balance_segment20 => p_balance_segment20
256 ,p_balance_segment21 => p_balance_segment21
257 ,p_balance_segment22 => p_balance_segment22
258 ,p_balance_segment23 => p_balance_segment23
259 ,p_balance_segment24 => p_balance_segment24
260 ,p_balance_segment25 => p_balance_segment25
261 ,p_balance_segment26 => p_balance_segment26
262 ,p_balance_segment27 => p_balance_segment27
263 ,p_balance_segment28 => p_balance_segment28
264 ,p_balance_segment29 => p_balance_segment29
265 ,p_balance_segment30 => p_balance_segment30
266 ,p_cost_concat_segments => p_cost_concat_segments
267 ,p_balance_concat_segments => p_balance_concat_segments
268 );
269 exception
270 when hr_api.cannot_find_prog_unit then
271 hr_api.cannot_find_prog_unit_error
272 (p_module_name => 'create_element_link'
273 ,p_hook_type => 'BP'
274 );
275 end;
276
277 hr_utility.set_location(l_proc, 20);
278 --
279 -- The main creation process has been moved to pypelbsi.pkb.
280 --
281 pay_element_link_internal.create_element_link
282 (p_effective_date => l_effective_date
283 ,p_element_type_id => p_element_type_id
284 ,p_business_group_id => p_business_group_id
285 ,p_costable_type => p_costable_type
286 ,p_payroll_id => p_payroll_id
287 ,p_job_id => p_job_id
288 ,p_position_id => p_position_id
289 ,p_people_group_id => p_people_group_id
290 ,p_cost_allocation_keyflex_id => l_cost_allocation_id
291 ,p_organization_id => p_organization_id
292 ,p_location_id => p_location_id
293 ,p_grade_id => p_grade_id
294 ,p_balancing_keyflex_id => l_bal_allocation_id
295 ,p_element_set_id => p_element_set_id
296 ,p_pay_basis_id => p_pay_basis_id
297 ,p_link_to_all_payrolls_flag => p_link_to_all_payrolls_flag
298 ,p_standard_link_flag => l_standard_link_flag
299 ,p_transfer_to_gl_flag => p_transfer_to_gl_flag
300 ,p_comments => p_comments
301 ,p_employment_category => p_employment_category
302 ,p_qualifying_age => p_qualifying_age
303 ,p_qualifying_length_of_service => p_qualifying_length_of_service
304 ,p_qualifying_units => p_qualifying_units
305 ,p_attribute_category => p_attribute_category
306 ,p_attribute1 => p_attribute1
307 ,p_attribute2 => p_attribute2
308 ,p_attribute3 => p_attribute3
309 ,p_attribute4 => p_attribute4
310 ,p_attribute5 => p_attribute5
311 ,p_attribute6 => p_attribute6
312 ,p_attribute7 => p_attribute7
313 ,p_attribute8 => p_attribute8
314 ,p_attribute9 => p_attribute9
315 ,p_attribute10 => p_attribute10
316 ,p_attribute11 => p_attribute11
317 ,p_attribute12 => p_attribute12
318 ,p_attribute13 => p_attribute13
319 ,p_attribute14 => p_attribute14
320 ,p_attribute15 => p_attribute15
321 ,p_attribute16 => p_attribute16
322 ,p_attribute17 => p_attribute17
323 ,p_attribute18 => p_attribute18
324 ,p_attribute19 => p_attribute19
325 ,p_attribute20 => p_attribute20
326 ,p_cost_segment1 => p_cost_segment1
327 ,p_cost_segment2 => p_cost_segment2
328 ,p_cost_segment3 => p_cost_segment3
329 ,p_cost_segment4 => p_cost_segment4
330 ,p_cost_segment5 => p_cost_segment5
331 ,p_cost_segment6 => p_cost_segment6
332 ,p_cost_segment7 => p_cost_segment7
333 ,p_cost_segment8 => p_cost_segment8
334 ,p_cost_segment9 => p_cost_segment9
335 ,p_cost_segment10 => p_cost_segment10
336 ,p_cost_segment11 => p_cost_segment11
337 ,p_cost_segment12 => p_cost_segment12
338 ,p_cost_segment13 => p_cost_segment13
339 ,p_cost_segment14 => p_cost_segment14
340 ,p_cost_segment15 => p_cost_segment15
341 ,p_cost_segment16 => p_cost_segment16
342 ,p_cost_segment17 => p_cost_segment17
343 ,p_cost_segment18 => p_cost_segment18
344 ,p_cost_segment19 => p_cost_segment19
345 ,p_cost_segment20 => p_cost_segment20
346 ,p_cost_segment21 => p_cost_segment21
347 ,p_cost_segment22 => p_cost_segment22
348 ,p_cost_segment23 => p_cost_segment23
349 ,p_cost_segment24 => p_cost_segment24
350 ,p_cost_segment25 => p_cost_segment25
351 ,p_cost_segment26 => p_cost_segment26
352 ,p_cost_segment27 => p_cost_segment27
353 ,p_cost_segment28 => p_cost_segment28
354 ,p_cost_segment29 => p_cost_segment29
355 ,p_cost_segment30 => p_cost_segment30
356 ,p_balance_segment1 => p_balance_segment1
357 ,p_balance_segment2 => p_balance_segment2
358 ,p_balance_segment3 => p_balance_segment3
359 ,p_balance_segment4 => p_balance_segment4
360 ,p_balance_segment5 => p_balance_segment5
361 ,p_balance_segment6 => p_balance_segment6
362 ,p_balance_segment7 => p_balance_segment7
363 ,p_balance_segment8 => p_balance_segment8
364 ,p_balance_segment9 => p_balance_segment9
365 ,p_balance_segment10 => p_balance_segment10
366 ,p_balance_segment11 => p_balance_segment11
367 ,p_balance_segment12 => p_balance_segment12
368 ,p_balance_segment13 => p_balance_segment13
369 ,p_balance_segment14 => p_balance_segment14
370 ,p_balance_segment15 => p_balance_segment15
371 ,p_balance_segment16 => p_balance_segment16
372 ,p_balance_segment17 => p_balance_segment17
373 ,p_balance_segment18 => p_balance_segment18
374 ,p_balance_segment19 => p_balance_segment19
375 ,p_balance_segment20 => p_balance_segment20
376 ,p_balance_segment21 => p_balance_segment21
377 ,p_balance_segment22 => p_balance_segment22
378 ,p_balance_segment23 => p_balance_segment23
379 ,p_balance_segment24 => p_balance_segment24
380 ,p_balance_segment25 => p_balance_segment25
381 ,p_balance_segment26 => p_balance_segment26
382 ,p_balance_segment27 => p_balance_segment27
383 ,p_balance_segment28 => p_balance_segment28
384 ,p_balance_segment29 => p_balance_segment29
385 ,p_balance_segment30 => p_balance_segment30
386 ,p_cost_concat_segments => p_cost_concat_segments
387 ,p_balance_concat_segments => p_balance_concat_segments
388 ,p_element_link_id => l_element_link_id
389 ,p_comment_id => l_comment_id
390 ,p_object_version_number => l_object_version_number
391 ,p_effective_start_date => l_effective_start_date
392 ,p_effective_end_date => l_effective_end_date
393 );
394
395 -- Creates assignment link usages if people group criteria is specified
396 if p_people_group_id is not null then
397 pay_pel_bus.chk_asg_link_usages
398 (p_business_group_id => p_business_group_id
399 ,p_people_group_id => p_people_group_id
400 ,p_element_link_id => l_element_link_id
401 ,p_effective_start_date => l_effective_start_date
402 ,p_effective_end_date => l_effective_end_date
403 );
404 end if;
405
406 -- Creates Standard Entries in case Standard link flag is 'Y'
407 if l_standard_link_flag = 'Y' then
408 pay_pel_bus.chk_standard_entries
409 (p_business_group_id => p_business_group_id
410 ,p_element_link_id => l_element_link_id
411 ,p_element_type_id => p_element_type_id
412 ,p_effective_start_date => l_effective_start_date
413 ,p_effective_end_date => l_effective_end_date
414 ,p_payroll_id => p_payroll_id
415 ,p_link_to_all_payrolls_flag => p_link_to_all_payrolls_flag
416 ,p_job_id => p_job_id
417 ,p_grade_id => p_grade_id
418 ,p_position_id => p_position_id
419 ,p_organization_id => p_organization_id
420 ,p_location_id => p_location_id
421 ,p_pay_basis_id => p_pay_basis_id
422 ,p_employment_category => p_employment_category
423 ,p_people_group_id => p_people_group_id
424 );
425 end if;
426
427 --
428 -- Call After Process User Hook
429 --
430 begin
431 pay_element_link_BK1.create_element_link_a
432 (p_effective_date => l_effective_date
433 ,p_element_type_id => p_element_type_id
434 ,p_business_group_id => p_business_group_id
435 ,p_costable_type => p_costable_type
436 ,p_payroll_id => p_payroll_id
437 ,p_job_id => p_job_id
438 ,p_position_id => p_position_id
439 ,p_people_group_id => p_people_group_id
440 ,p_cost_allocation_keyflex_id => l_cost_allocation_id
441 ,p_organization_id => p_organization_id
442 ,p_location_id => p_location_id
443 ,p_grade_id => p_grade_id
444 ,p_balancing_keyflex_id => l_bal_allocation_id
445 ,p_element_set_id => p_element_set_id
446 ,p_pay_basis_id => p_pay_basis_id
447 ,p_link_to_all_payrolls_flag => p_link_to_all_payrolls_flag
448 ,p_standard_link_flag => p_standard_link_flag
449 ,p_transfer_to_gl_flag => p_transfer_to_gl_flag
450 ,p_comments => p_comments
451 ,p_employment_category => p_employment_category
452 ,p_qualifying_age => p_qualifying_age
453 ,p_qualifying_length_of_service => p_qualifying_length_of_service
454 ,p_qualifying_units => p_qualifying_units
455 ,p_attribute_category => p_attribute_category
456 ,p_attribute1 => p_attribute1
457 ,p_attribute2 => p_attribute2
458 ,p_attribute3 => p_attribute3
459 ,p_attribute4 => p_attribute4
460 ,p_attribute5 => p_attribute5
461 ,p_attribute6 => p_attribute6
462 ,p_attribute7 => p_attribute7
463 ,p_attribute8 => p_attribute8
464 ,p_attribute9 => p_attribute9
465 ,p_attribute10 => p_attribute10
466 ,p_attribute11 => p_attribute11
467 ,p_attribute12 => p_attribute12
468 ,p_attribute13 => p_attribute13
469 ,p_attribute14 => p_attribute14
470 ,p_attribute15 => p_attribute15
471 ,p_attribute16 => p_attribute16
472 ,p_attribute17 => p_attribute17
473 ,p_attribute18 => p_attribute18
474 ,p_attribute19 => p_attribute19
475 ,p_attribute20 => p_attribute20
476 ,p_cost_segment1 => p_cost_segment1
477 ,p_cost_segment2 => p_cost_segment2
478 ,p_cost_segment3 => p_cost_segment3
479 ,p_cost_segment4 => p_cost_segment4
480 ,p_cost_segment5 => p_cost_segment5
481 ,p_cost_segment6 => p_cost_segment6
482 ,p_cost_segment7 => p_cost_segment7
483 ,p_cost_segment8 => p_cost_segment8
484 ,p_cost_segment9 => p_cost_segment9
485 ,p_cost_segment10 => p_cost_segment10
486 ,p_cost_segment11 => p_cost_segment11
487 ,p_cost_segment12 => p_cost_segment12
488 ,p_cost_segment13 => p_cost_segment13
489 ,p_cost_segment14 => p_cost_segment14
490 ,p_cost_segment15 => p_cost_segment15
491 ,p_cost_segment16 => p_cost_segment16
492 ,p_cost_segment17 => p_cost_segment17
493 ,p_cost_segment18 => p_cost_segment18
494 ,p_cost_segment19 => p_cost_segment19
495 ,p_cost_segment20 => p_cost_segment20
496 ,p_cost_segment21 => p_cost_segment21
497 ,p_cost_segment22 => p_cost_segment22
498 ,p_cost_segment23 => p_cost_segment23
499 ,p_cost_segment24 => p_cost_segment24
500 ,p_cost_segment25 => p_cost_segment25
501 ,p_cost_segment26 => p_cost_segment26
502 ,p_cost_segment27 => p_cost_segment27
503 ,p_cost_segment28 => p_cost_segment28
504 ,p_cost_segment29 => p_cost_segment29
505 ,p_cost_segment30 => p_cost_segment30
506 ,p_balance_segment1 => p_balance_segment1
507 ,p_balance_segment2 => p_balance_segment2
508 ,p_balance_segment3 => p_balance_segment3
509 ,p_balance_segment4 => p_balance_segment4
510 ,p_balance_segment5 => p_balance_segment5
511 ,p_balance_segment6 => p_balance_segment6
512 ,p_balance_segment7 => p_balance_segment7
513 ,p_balance_segment8 => p_balance_segment8
514 ,p_balance_segment9 => p_balance_segment9
515 ,p_balance_segment10 => p_balance_segment10
516 ,p_balance_segment11 => p_balance_segment11
517 ,p_balance_segment12 => p_balance_segment12
518 ,p_balance_segment13 => p_balance_segment13
519 ,p_balance_segment14 => p_balance_segment14
520 ,p_balance_segment15 => p_balance_segment15
521 ,p_balance_segment16 => p_balance_segment16
522 ,p_balance_segment17 => p_balance_segment17
523 ,p_balance_segment18 => p_balance_segment18
524 ,p_balance_segment19 => p_balance_segment19
525 ,p_balance_segment20 => p_balance_segment20
526 ,p_balance_segment21 => p_balance_segment21
527 ,p_balance_segment22 => p_balance_segment22
528 ,p_balance_segment23 => p_balance_segment23
529 ,p_balance_segment24 => p_balance_segment24
530 ,p_balance_segment25 => p_balance_segment25
531 ,p_balance_segment26 => p_balance_segment26
532 ,p_balance_segment27 => p_balance_segment27
533 ,p_balance_segment28 => p_balance_segment28
534 ,p_balance_segment29 => p_balance_segment29
535 ,p_balance_segment30 => p_balance_segment30
536 ,p_cost_concat_segments => p_cost_concat_segments
537 ,p_balance_concat_segments => p_balance_concat_segments
538 ,p_element_link_id => l_element_link_id
539 ,p_comment_id => l_comment_id
540 ,p_object_version_number => l_object_version_number
541 ,p_effective_start_date => l_effective_start_date
542 ,p_effective_end_date => l_effective_end_date
543 );
544 exception
545 when hr_api.cannot_find_prog_unit then
546 hr_api.cannot_find_prog_unit_error
547 (p_module_name => 'create_element_link'
548 ,p_hook_type => 'AP'
549 );
550 end;
551 --
552 -- When in validation only mode raise the Validate_Enabled exception
553 --
554 if p_validate then
555 raise hr_api.validate_enabled;
556 end if;
557
558 --
559 -- Set out variables
560 --
561 p_element_link_id := l_element_link_id;
562 p_comment_id := l_comment_id;
563 p_object_version_number := l_object_version_number;
564 p_effective_start_date := l_effective_start_date;
565 p_effective_end_date := l_effective_end_date;
566
567 hr_utility.set_location(' Leaving:'||l_proc, 70);
568 exception
569 when hr_api.validate_enabled then
570 --
571 -- As the Validate_Enabled exception has been raised
572 -- we must rollback to the savepoint
573 --
574 rollback to create_element_link;
575 --
576 -- Only set output warning arguments
577 -- (Any key or derived arguments must be set to null
578 -- when validation only mode is being used.)
579 --
580 p_element_link_id := null;
581 p_object_version_number := null;
582
583
584 hr_utility.set_location(' Leaving:'||l_proc, 80);
585 when others then
586 --
587 -- A validation or unexpected error has occured
588 --
589 rollback to create_element_link;
590 hr_utility.set_location(' Leaving:'||l_proc, 90);
591 raise;
592 end create_element_link;
593 -- ----------------------------------------------------------------------------
594 -- |--------------------------<update_element_link>--------------------------|
595 -- ----------------------------------------------------------------------------
596 --
597 procedure update_element_link
598 (p_validate in boolean default false
599 ,p_effective_date in date
600 ,p_element_link_id in number
601 ,p_datetrack_mode in varchar2
602 ,p_costable_type in varchar2 default hr_api.g_varchar2
603 ,p_element_set_id in number default hr_api.g_number
604 ,p_multiply_value_flag in varchar2 default hr_api.g_varchar2
605 ,p_standard_link_flag in varchar2 default hr_api.g_varchar2
606 ,p_transfer_to_gl_flag in varchar2 default hr_api.g_varchar2
607 ,p_comments in varchar2 default hr_api.g_varchar2
608 ,p_comment_id in varchar2 default hr_api.g_varchar2
609 ,p_employment_category in varchar2 default hr_api.g_varchar2
610 ,p_qualifying_age in number default hr_api.g_number
611 ,p_qualifying_length_of_service in number default hr_api.g_number
612 ,p_qualifying_units in varchar2 default hr_api.g_varchar2
613 ,p_attribute_category in varchar2 default hr_api.g_varchar2
614 ,p_attribute1 in varchar2 default hr_api.g_varchar2
615 ,p_attribute2 in varchar2 default hr_api.g_varchar2
616 ,p_attribute3 in varchar2 default hr_api.g_varchar2
617 ,p_attribute4 in varchar2 default hr_api.g_varchar2
618 ,p_attribute5 in varchar2 default hr_api.g_varchar2
619 ,p_attribute6 in varchar2 default hr_api.g_varchar2
620 ,p_attribute7 in varchar2 default hr_api.g_varchar2
621 ,p_attribute8 in varchar2 default hr_api.g_varchar2
622 ,p_attribute9 in varchar2 default hr_api.g_varchar2
623 ,p_attribute10 in varchar2 default hr_api.g_varchar2
624 ,p_attribute11 in varchar2 default hr_api.g_varchar2
625 ,p_attribute12 in varchar2 default hr_api.g_varchar2
626 ,p_attribute13 in varchar2 default hr_api.g_varchar2
627 ,p_attribute14 in varchar2 default hr_api.g_varchar2
628 ,p_attribute15 in varchar2 default hr_api.g_varchar2
629 ,p_attribute16 in varchar2 default hr_api.g_varchar2
630 ,p_attribute17 in varchar2 default hr_api.g_varchar2
631 ,p_attribute18 in varchar2 default hr_api.g_varchar2
632 ,p_attribute19 in varchar2 default hr_api.g_varchar2
633 ,p_attribute20 in varchar2 default hr_api.g_varchar2
634 ,p_cost_segment1 in varchar2 default hr_api.g_varchar2
635 ,p_cost_segment2 in varchar2 default hr_api.g_varchar2
636 ,p_cost_segment3 in varchar2 default hr_api.g_varchar2
637 ,p_cost_segment4 in varchar2 default hr_api.g_varchar2
638 ,p_cost_segment5 in varchar2 default hr_api.g_varchar2
639 ,p_cost_segment6 in varchar2 default hr_api.g_varchar2
640 ,p_cost_segment7 in varchar2 default hr_api.g_varchar2
641 ,p_cost_segment8 in varchar2 default hr_api.g_varchar2
642 ,p_cost_segment9 in varchar2 default hr_api.g_varchar2
643 ,p_cost_segment10 in varchar2 default hr_api.g_varchar2
644 ,p_cost_segment11 in varchar2 default hr_api.g_varchar2
645 ,p_cost_segment12 in varchar2 default hr_api.g_varchar2
646 ,p_cost_segment13 in varchar2 default hr_api.g_varchar2
647 ,p_cost_segment14 in varchar2 default hr_api.g_varchar2
648 ,p_cost_segment15 in varchar2 default hr_api.g_varchar2
649 ,p_cost_segment16 in varchar2 default hr_api.g_varchar2
650 ,p_cost_segment17 in varchar2 default hr_api.g_varchar2
651 ,p_cost_segment18 in varchar2 default hr_api.g_varchar2
652 ,p_cost_segment19 in varchar2 default hr_api.g_varchar2
653 ,p_cost_segment20 in varchar2 default hr_api.g_varchar2
654 ,p_cost_segment21 in varchar2 default hr_api.g_varchar2
655 ,p_cost_segment22 in varchar2 default hr_api.g_varchar2
656 ,p_cost_segment23 in varchar2 default hr_api.g_varchar2
657 ,p_cost_segment24 in varchar2 default hr_api.g_varchar2
658 ,p_cost_segment25 in varchar2 default hr_api.g_varchar2
659 ,p_cost_segment26 in varchar2 default hr_api.g_varchar2
660 ,p_cost_segment27 in varchar2 default hr_api.g_varchar2
661 ,p_cost_segment28 in varchar2 default hr_api.g_varchar2
662 ,p_cost_segment29 in varchar2 default hr_api.g_varchar2
663 ,p_cost_segment30 in varchar2 default hr_api.g_varchar2
664 ,p_balance_segment1 in varchar2 default hr_api.g_varchar2
665 ,p_balance_segment2 in varchar2 default hr_api.g_varchar2
666 ,p_balance_segment3 in varchar2 default hr_api.g_varchar2
667 ,p_balance_segment4 in varchar2 default hr_api.g_varchar2
668 ,p_balance_segment5 in varchar2 default hr_api.g_varchar2
669 ,p_balance_segment6 in varchar2 default hr_api.g_varchar2
670 ,p_balance_segment7 in varchar2 default hr_api.g_varchar2
671 ,p_balance_segment8 in varchar2 default hr_api.g_varchar2
672 ,p_balance_segment9 in varchar2 default hr_api.g_varchar2
673 ,p_balance_segment10 in varchar2 default hr_api.g_varchar2
674 ,p_balance_segment11 in varchar2 default hr_api.g_varchar2
675 ,p_balance_segment12 in varchar2 default hr_api.g_varchar2
676 ,p_balance_segment13 in varchar2 default hr_api.g_varchar2
677 ,p_balance_segment14 in varchar2 default hr_api.g_varchar2
678 ,p_balance_segment15 in varchar2 default hr_api.g_varchar2
679 ,p_balance_segment16 in varchar2 default hr_api.g_varchar2
680 ,p_balance_segment17 in varchar2 default hr_api.g_varchar2
681 ,p_balance_segment18 in varchar2 default hr_api.g_varchar2
682 ,p_balance_segment19 in varchar2 default hr_api.g_varchar2
683 ,p_balance_segment20 in varchar2 default hr_api.g_varchar2
684 ,p_balance_segment21 in varchar2 default hr_api.g_varchar2
685 ,p_balance_segment22 in varchar2 default hr_api.g_varchar2
686 ,p_balance_segment23 in varchar2 default hr_api.g_varchar2
687 ,p_balance_segment24 in varchar2 default hr_api.g_varchar2
688 ,p_balance_segment25 in varchar2 default hr_api.g_varchar2
689 ,p_balance_segment26 in varchar2 default hr_api.g_varchar2
690 ,p_balance_segment27 in varchar2 default hr_api.g_varchar2
691 ,p_balance_segment28 in varchar2 default hr_api.g_varchar2
692 ,p_balance_segment29 in varchar2 default hr_api.g_varchar2
693 ,p_balance_segment30 in varchar2 default hr_api.g_varchar2
694 ,p_cost_concat_segments_in in varchar2 default hr_api.g_varchar2
695 ,p_balance_concat_segments_in in varchar2 default hr_api.g_varchar2
696 ,p_object_version_number in out nocopy number
697 ,p_cost_allocation_keyflex_id out nocopy number
698 ,p_balancing_keyflex_id out nocopy number
699 ,p_cost_concat_segments_out out nocopy varchar2
700 ,p_balance_concat_segments_out out nocopy varchar2
701 ,p_effective_start_date out nocopy date
702 ,p_effective_end_date out nocopy date
703 ) is
704 --
705 -- Declare cursors and local variables
706 --
707 l_proc varchar2(72) := g_package||'update_element_link';
708 l_effective_date date;
709
710 -- The variables to get the cost/balance id and structure number
711 l_flex_num number;
712 l_cost_allocation_id number;
713 l_bal_allocation_id number;
714
715 -- cursor to fetch the current values of the element link record
716 cursor csr_bg_et is
717 select business_group_id
718 ,element_type_id
719 ,standard_link_flag
720 ,payroll_id
721 ,link_to_all_payrolls_flag
722 ,job_id
723 ,grade_id
724 ,position_id
725 ,organization_id
726 ,location_id
727 ,pay_basis_id
728 ,employment_category
729 ,people_group_id
730 from pay_element_links_f
731 where element_link_id = p_element_link_id
732 and l_effective_date between effective_start_date
733 and effective_end_date;
734
735 -- Cursor to get the structure number to be passed to get the cost/balance id
736 cursor csr_flexnum(p_business_group_id number) is
737 select cost_allocation_structure
738 from per_business_groups
739 where business_group_id = p_business_group_id;
740 --
741 l_element_link_rec csr_bg_et%rowtype;
742 --
743 begin
744 hr_utility.set_location('Entering:'|| l_proc, 10);
745 --
746 -- Issue a savepoint
747 --
748 savepoint update_element_link;
749 --
750 hr_utility.set_location('Entering:'|| l_proc, 20);
751 --
752 -- Truncate the time portion from all IN date parameters
753 --
754 l_effective_date := trunc(p_effective_date);
755 --
756 open csr_bg_et;
757 fetch csr_bg_et into l_element_link_rec;
758 close csr_bg_et;
759 --
760 -- Call Before Process User Hook
761 --
762 begin
763 pay_element_link_BK2.update_element_link_b
764 (l_effective_date
765 ,p_element_link_id
766 ,p_datetrack_mode
767 ,p_costable_type
768 ,p_element_set_id
769 ,p_multiply_value_flag
770 ,p_standard_link_flag
771 ,p_transfer_to_gl_flag
772 ,p_comments
773 ,p_comment_id
774 ,p_employment_category
775 ,p_qualifying_age
776 ,p_qualifying_length_of_service
777 ,p_qualifying_units
778 ,p_attribute_category
779 ,p_attribute1
780 ,p_attribute2
781 ,p_attribute3
782 ,p_attribute4
783 ,p_attribute5
784 ,p_attribute6
785 ,p_attribute7
786 ,p_attribute8
787 ,p_attribute9
788 ,p_attribute10
789 ,p_attribute11
790 ,p_attribute12
791 ,p_attribute13
792 ,p_attribute14
793 ,p_attribute15
794 ,p_attribute16
795 ,p_attribute17
796 ,p_attribute18
797 ,p_attribute19
798 ,p_attribute20
799 ,p_cost_segment1
800 ,p_cost_segment2
801 ,p_cost_segment3
802 ,p_cost_segment4
803 ,p_cost_segment5
804 ,p_cost_segment6
805 ,p_cost_segment7
806 ,p_cost_segment8
807 ,p_cost_segment9
808 ,p_cost_segment10
809 ,p_cost_segment11
810 ,p_cost_segment12
811 ,p_cost_segment13
812 ,p_cost_segment14
813 ,p_cost_segment15
814 ,p_cost_segment16
815 ,p_cost_segment17
816 ,p_cost_segment18
817 ,p_cost_segment19
818 ,p_cost_segment20
819 ,p_cost_segment21
820 ,p_cost_segment22
821 ,p_cost_segment23
822 ,p_cost_segment24
823 ,p_cost_segment25
824 ,p_cost_segment26
825 ,p_cost_segment27
826 ,p_cost_segment28
827 ,p_cost_segment29
828 ,p_cost_segment30
829 ,p_balance_segment1
830 ,p_balance_segment2
831 ,p_balance_segment3
832 ,p_balance_segment4
833 ,p_balance_segment5
834 ,p_balance_segment6
835 ,p_balance_segment7
836 ,p_balance_segment8
837 ,p_balance_segment9
838 ,p_balance_segment10
839 ,p_balance_segment11
840 ,p_balance_segment12
841 ,p_balance_segment13
842 ,p_balance_segment14
843 ,p_balance_segment15
844 ,p_balance_segment16
845 ,p_balance_segment17
846 ,p_balance_segment18
847 ,p_balance_segment19
848 ,p_balance_segment20
849 ,p_balance_segment21
850 ,p_balance_segment22
851 ,p_balance_segment23
852 ,p_balance_segment24
853 ,p_balance_segment25
854 ,p_balance_segment26
855 ,p_balance_segment27
856 ,p_balance_segment28
857 ,p_balance_segment29
858 ,p_balance_segment30
859 ,p_cost_concat_segments_in
860 ,p_balance_concat_segments_in
861 ,p_object_version_number
862 );
863 exception
864 when hr_api.cannot_find_prog_unit then
865 hr_api.cannot_find_prog_unit_error
866 (p_module_name => 'update_element_link'
867 ,p_hook_type => 'BP'
868 );
869 end;
870 --
871 -- If the costable type is Distributed/Costed/Fixed Costed then call
872 -- hr_kflex_utility for mandatory balancing segments
873
874 if (p_costable_type = 'D' or p_costable_type = 'C'
875 or p_costable_type = 'F') then
876
877 hr_utility.set_location('Entering:'|| l_proc, 30);
878
879 -- Get the structure number for the business_group id supplied
880 open csr_Flexnum(l_element_link_rec.business_group_id);
881 fetch csr_Flexnum into l_flex_num;
882 if csr_Flexnum%notfound then
883 close csr_Flexnum;
884 hr_utility.set_message(801,'HR_7471_FLEX_PEA_INVALID_ID');
885 hr_utility.raise_error;
886 end if;
887
888 hr_kflex_utility.upd_or_sel_keyflex_comb
889 (p_appl_short_name => 'PAY'
890 ,p_flex_code => 'COST'
891 ,p_flex_num => l_flex_num
892 ,p_segment1 => p_balance_segment1
893 ,p_segment2 => p_balance_segment2
894 ,p_segment3 => p_balance_segment3
895 ,p_segment4 => p_balance_segment4
896 ,p_segment5 => p_balance_segment5
897 ,p_segment6 => p_balance_segment6
898 ,p_segment7 => p_balance_segment7
899 ,p_segment8 => p_balance_segment8
900 ,p_segment9 => p_balance_segment9
901 ,p_segment10 => p_balance_segment10
902 ,p_segment11 => p_balance_segment11
903 ,p_segment12 => p_balance_segment12
904 ,p_segment13 => p_balance_segment13
905 ,p_segment14 => p_balance_segment14
906 ,p_segment15 => p_balance_segment15
907 ,p_segment16 => p_balance_segment16
908 ,p_segment17 => p_balance_segment17
909 ,p_segment18 => p_balance_segment18
910 ,p_segment19 => p_balance_segment19
911 ,p_segment20 => p_balance_segment20
912 ,p_segment21 => p_balance_segment21
913 ,p_segment22 => p_balance_segment22
914 ,p_segment23 => p_balance_segment23
915 ,p_segment24 => p_balance_segment24
916 ,p_segment25 => p_balance_segment25
917 ,p_segment26 => p_balance_segment26
918 ,p_segment27 => p_balance_segment27
919 ,p_segment28 => p_balance_segment28
920 ,p_segment29 => p_balance_segment29
921 ,p_segment30 => p_balance_segment30
922 ,p_concat_segments_in => p_balance_concat_segments_in
923 ,p_ccid => l_bal_allocation_id
924 ,p_concat_segments_out => p_balance_concat_segments_out
925 );
926
927 -- Call the hr_kflex_untility for optional costing if that info is
928 -- supplied
929 if (p_cost_segment1 is not null or p_cost_segment2 is not null or
930 p_cost_segment3 is not null or p_cost_segment4 is not null or
931 p_cost_segment5 is not null or p_cost_segment6 is not null or
932 p_cost_segment7 is not null or p_cost_segment8 is not null or
933 p_cost_segment9 is not null or p_cost_segment10 is not null or
934 p_cost_segment11 is not null or p_cost_segment12 is not null or
935 p_cost_segment13 is not null or p_cost_segment14 is not null or
936 p_cost_segment15 is not null or p_cost_segment16 is not null or
937 p_cost_segment17 is not null or p_cost_segment18 is not null or
938 p_cost_segment19 is not null or p_cost_segment20 is not null or
939 p_cost_segment21 is not null or p_cost_segment22 is not null or
940 p_cost_segment23 is not null or p_cost_segment24 is not null or
941 p_cost_segment25 is not null or p_cost_segment26 is not null or
942 p_cost_segment27 is not null or p_cost_segment28 is not null or
943 p_cost_segment29 is not null or p_cost_segment30 is not null) then
944
945 hr_kflex_utility.upd_or_sel_keyflex_comb
946 (p_appl_short_name => 'PAY'
947 ,p_flex_code => 'COST'
948 ,p_flex_num => l_flex_num
949 ,p_segment1 => p_cost_segment1
950 ,p_segment2 => p_cost_segment2
951 ,p_segment3 => p_cost_segment3
952 ,p_segment4 => p_cost_segment4
953 ,p_segment5 => p_cost_segment5
954 ,p_segment6 => p_cost_segment6
955 ,p_segment7 => p_cost_segment7
956 ,p_segment8 => p_cost_segment8
957 ,p_segment9 => p_cost_segment9
958 ,p_segment10 => p_cost_segment10
959 ,p_segment11 => p_cost_segment11
960 ,p_segment12 => p_cost_segment12
961 ,p_segment13 => p_cost_segment13
962 ,p_segment14 => p_cost_segment14
963 ,p_segment15 => p_cost_segment15
964 ,p_segment16 => p_cost_segment16
965 ,p_segment17 => p_cost_segment17
966 ,p_segment18 => p_cost_segment18
967 ,p_segment19 => p_cost_segment19
968 ,p_segment20 => p_cost_segment20
969 ,p_segment21 => p_cost_segment21
970 ,p_segment22 => p_cost_segment22
971 ,p_segment23 => p_cost_segment23
972 ,p_segment24 => p_cost_segment24
973 ,p_segment25 => p_cost_segment25
974 ,p_segment26 => p_cost_segment26
975 ,p_segment27 => p_cost_segment27
976 ,p_segment28 => p_cost_segment28
977 ,p_segment29 => p_cost_segment29
978 ,p_segment30 => p_cost_segment30
979 ,p_concat_segments_in => p_cost_concat_segments_in
980 ,p_ccid => l_cost_allocation_id
981 ,p_concat_segments_out => p_cost_concat_segments_out
982 );
983
984 -- Bug 14468848 : Update concatenated_sgements field of the new segment combination in
985 -- in pay_cost_allocation_keyflex table after successful validation of segment combination
986 update pay_cost_allocation_keyflex
987 set concatenated_segments = p_cost_concat_segments_out
988 where cost_allocation_keyflex_id = l_cost_allocation_id;
989 --
990 end if;
991
992 end if;
993 --
994 l_cost_allocation_id := nvl(l_cost_allocation_id,hr_api.g_number);
995 l_bal_allocation_id := nvl(l_bal_allocation_id,hr_api.g_number);
996 --
997 -- Process Logic
998 --
999 pay_pel_upd.upd(
1000 p_effective_date => l_effective_date
1001 ,p_element_type_id => l_element_link_rec.element_type_id
1002 ,p_business_group_id => l_element_link_rec.business_group_id
1003 ,p_costable_type => p_costable_type
1004 ,p_multiply_value_flag => p_multiply_value_flag
1005 ,p_standard_link_flag => p_standard_link_flag
1006 ,p_transfer_to_gl_flag => p_transfer_to_gl_flag
1007 ,p_cost_allocation_keyflex_id => l_cost_allocation_id
1008 ,p_balancing_keyflex_id => l_bal_allocation_id
1009 ,p_element_set_id => p_element_set_id
1010 ,p_comments => p_comments
1011 ,p_employment_category => p_employment_category
1012 ,p_qualifying_age => p_qualifying_age
1013 ,p_qualifying_length_of_service => p_qualifying_length_of_service
1014 ,p_qualifying_units => p_qualifying_units
1015 ,p_attribute_category => p_attribute_category
1016 ,p_attribute1 => p_attribute1
1017 ,p_attribute2 => p_attribute2
1018 ,p_attribute3 => p_attribute3
1019 ,p_attribute4 => p_attribute4
1020 ,p_attribute5 => p_attribute5
1021 ,p_attribute6 => p_attribute6
1022 ,p_attribute7 => p_attribute7
1023 ,p_attribute8 => p_attribute8
1024 ,p_attribute9 => p_attribute9
1025 ,p_attribute10 => p_attribute10
1026 ,p_attribute11 => p_attribute11
1027 ,p_attribute12 => p_attribute12
1028 ,p_attribute13 => p_attribute13
1029 ,p_attribute14 => p_attribute14
1030 ,p_attribute15 => p_attribute15
1031 ,p_attribute16 => p_attribute16
1032 ,p_attribute17 => p_attribute17
1033 ,p_attribute18 => p_attribute18
1034 ,p_attribute19 => p_attribute19
1035 ,p_attribute20 => p_attribute20
1036 ,p_element_link_id => p_element_link_id
1037 ,p_datetrack_mode => p_datetrack_mode
1038 ,p_object_version_number => p_object_version_number
1039 ,p_effective_start_date => p_effective_start_date
1040 ,p_effective_end_date => p_effective_end_date
1041 );
1042 --
1043 -- Create element entries if the standard_link_flag is changed from 'N' to 'Y',
1044 -- with the following conditions -
1045 -- 1. Entries for the link should not exist.
1046 -- 2. All required input values should have a default value.
1047 --
1048 if ((l_element_link_rec.standard_link_flag = 'N' and
1049 p_standard_link_flag = 'Y')) and
1050 (NOT pay_element_links_pkg.element_entries_exist(p_element_link_id,
1051 TRUE))
1052 then
1053 --
1054 pay_link_input_values_pkg.check_required_defaults
1055 (p_element_link_id,
1056 p_effective_date);
1057 --
1058 pay_pel_bus.chk_standard_entries
1059 (p_business_group_id => l_element_link_rec.business_group_id
1060 ,p_element_link_id => p_element_link_id
1061 ,p_element_type_id => l_element_link_rec.element_type_id
1062 ,p_effective_start_date => p_effective_start_date
1063 ,p_effective_end_date => p_effective_end_date
1064 ,p_payroll_id => l_element_link_rec.payroll_id
1065 ,p_link_to_all_payrolls_flag => l_element_link_rec.link_to_all_payrolls_flag
1066 ,p_job_id => l_element_link_rec.job_id
1067 ,p_grade_id => l_element_link_rec.grade_id
1068 ,p_position_id => l_element_link_rec.position_id
1069 ,p_organization_id => l_element_link_rec.organization_id
1070 ,p_location_id => l_element_link_rec.location_id
1071 ,p_pay_basis_id => l_element_link_rec.pay_basis_id
1072 ,p_employment_category => l_element_link_rec.employment_category
1073 ,p_people_group_id => l_element_link_rec.people_group_id
1074 );
1075 --
1076 end if;
1077 --
1078 -- Call After Process User Hook
1079 --
1080 begin
1081 pay_element_link_BK2.update_element_link_a
1082 (l_effective_date
1083 ,p_element_link_id
1084 ,p_datetrack_mode
1085 ,p_costable_type
1086 ,p_element_set_id
1087 ,p_multiply_value_flag
1088 ,p_standard_link_flag
1089 ,p_transfer_to_gl_flag
1090 ,p_comments
1091 ,p_comment_id
1092 ,p_employment_category
1093 ,p_qualifying_age
1094 ,p_qualifying_length_of_service
1095 ,p_qualifying_units
1096 ,p_attribute_category
1097 ,p_attribute1
1098 ,p_attribute2
1099 ,p_attribute3
1100 ,p_attribute4
1101 ,p_attribute5
1102 ,p_attribute6
1103 ,p_attribute7
1104 ,p_attribute8
1105 ,p_attribute9
1106 ,p_attribute10
1107 ,p_attribute11
1108 ,p_attribute12
1109 ,p_attribute13
1110 ,p_attribute14
1111 ,p_attribute15
1112 ,p_attribute16
1113 ,p_attribute17
1114 ,p_attribute18
1115 ,p_attribute19
1116 ,p_attribute20
1117 ,p_cost_segment1
1118 ,p_cost_segment2
1119 ,p_cost_segment3
1120 ,p_cost_segment4
1121 ,p_cost_segment5
1122 ,p_cost_segment6
1123 ,p_cost_segment7
1124 ,p_cost_segment8
1125 ,p_cost_segment9
1126 ,p_cost_segment10
1127 ,p_cost_segment11
1128 ,p_cost_segment12
1129 ,p_cost_segment13
1130 ,p_cost_segment14
1131 ,p_cost_segment15
1132 ,p_cost_segment16
1133 ,p_cost_segment17
1134 ,p_cost_segment18
1135 ,p_cost_segment19
1136 ,p_cost_segment20
1137 ,p_cost_segment21
1138 ,p_cost_segment22
1139 ,p_cost_segment23
1140 ,p_cost_segment24
1141 ,p_cost_segment25
1142 ,p_cost_segment26
1143 ,p_cost_segment27
1144 ,p_cost_segment28
1145 ,p_cost_segment29
1146 ,p_cost_segment30
1147 ,p_balance_segment1
1148 ,p_balance_segment2
1149 ,p_balance_segment3
1150 ,p_balance_segment4
1151 ,p_balance_segment5
1152 ,p_balance_segment6
1153 ,p_balance_segment7
1154 ,p_balance_segment8
1155 ,p_balance_segment9
1156 ,p_balance_segment10
1157 ,p_balance_segment11
1158 ,p_balance_segment12
1159 ,p_balance_segment13
1160 ,p_balance_segment14
1161 ,p_balance_segment15
1162 ,p_balance_segment16
1163 ,p_balance_segment17
1164 ,p_balance_segment18
1165 ,p_balance_segment19
1166 ,p_balance_segment20
1167 ,p_balance_segment21
1168 ,p_balance_segment22
1169 ,p_balance_segment23
1170 ,p_balance_segment24
1171 ,p_balance_segment25
1172 ,p_balance_segment26
1173 ,p_balance_segment27
1174 ,p_balance_segment28
1175 ,p_balance_segment29
1176 ,p_balance_segment30
1177 ,p_cost_concat_segments_in
1178 ,p_balance_concat_segments_in
1179 ,p_object_version_number
1180 ,l_cost_allocation_id
1181 ,l_bal_allocation_id
1182 ,p_cost_concat_segments_out
1183 ,p_balance_concat_segments_out
1184 ,p_effective_start_date
1185 ,p_effective_end_date
1186 );
1187 exception
1188 when hr_api.cannot_find_prog_unit then
1189 hr_api.cannot_find_prog_unit_error
1190 (p_module_name => 'update_element_link'
1191 ,p_hook_type => 'AP'
1192 );
1193 end;
1194 --
1195 -- When in validation only mode raise the Validate_Enabled exception
1196 --
1197 if p_validate then
1198 raise hr_api.validate_enabled;
1199 end if;
1200 --
1201 -- Set all output arguments
1202 --
1203 p_cost_allocation_keyflex_id := l_cost_allocation_id;
1204 p_balancing_keyflex_id := l_bal_allocation_id;
1205
1206 hr_utility.set_location(' Leaving:'||l_proc, 70);
1207 exception
1208 when hr_api.validate_enabled then
1209 --
1210 -- As the Validate_Enabled exception has been raised
1211 -- we must rollback to the savepoint
1212 --
1213 rollback to update_element_link;
1214 --
1215 -- Only set output warning arguments
1216 -- (Any key or derived arguments must be set to null
1217 -- when validation only mode is being used.)
1218 --
1219 p_object_version_number := null;
1220
1221 hr_utility.set_location(' Leaving:'||l_proc, 80);
1222 when others then
1223 --
1224 -- A validation or unexpected error has occured
1225 --
1226 rollback to update_element_link;
1227 hr_utility.set_location(' Leaving:'||l_proc, 90);
1228 raise;
1229 end update_element_link;
1230 --
1231 -- ----------------------------------------------------------------------------
1232 -- |-----------------------< delete_element_link_int >------------------------|
1233 -- ----------------------------------------------------------------------------
1234 procedure delete_element_link_int
1235 (p_effective_date in date
1236 ,p_element_link_id in number
1237 ,p_datetrack_delete_mode in varchar2
1238 ,p_object_version_number in out nocopy number
1239 ,p_effective_start_date out nocopy date
1240 ,p_effective_end_date out nocopy date
1241 ,p_entries_warning out nocopy boolean
1242 )
1243 is
1244 --
1245 l_proc varchar2(72) := g_package||'delete_element_link_int';
1246 l_validation_start_date date;
1247 l_validation_end_date date;
1248 l_object_version_number number:= p_object_version_number;
1249 l_effective_start_date date;
1250 l_effective_end_date date;
1251 l_entries_warning boolean;
1252 l_liv_ovn number;
1253 l_liv_esd date;
1254 l_liv_eed date;
1255 l_business_group_id number;
1256 l_people_group_id number;
1257 l_old_esd date;
1258 l_old_eed date;
1259 l_old_min_esd date;
1260 l_old_max_eed date;
1261 l_new_min_esd date;
1262 l_new_max_eed date;
1263 --
1264 cursor csr_links_entries is
1265 select element_entry_id
1266 from pay_element_entries_f
1267 where element_link_id = p_element_link_id
1268 and p_effective_date between effective_start_date
1269 and effective_end_date;
1270
1271 cursor csr_all_inputs_for_link is
1272 select link_input_value_id, object_version_number
1273 from pay_link_input_values_f pliv
1274 where element_link_id = p_element_link_id
1275 and p_effective_date between effective_start_date
1276 and effective_end_date;
1277
1278 cursor csr_last_liv is
1279 select link_input_value_id
1280 ,object_version_number
1281 ,effective_start_date
1282 ,effective_end_date
1283 from pay_link_input_values_f pliv
1284 where element_link_id = p_element_link_id
1285 and effective_end_date >= p_effective_date
1286 and not exists
1287 (select null
1288 from pay_link_input_values_f pliv2
1289 where pliv2.element_link_id = pliv.element_link_id
1290 and pliv2.input_value_id = pliv.input_value_id
1291 and pliv2.effective_start_date > pliv.effective_start_date);
1292
1293 cursor csr_link_date_range is
1294 select min(effective_start_date) min_effective_start_date
1295 ,max(effective_end_date) max_effective_end_date
1296 from pay_element_links_f
1297 where element_link_id = p_element_link_id
1298 ;
1299 --
1300 begin
1301 hr_utility.set_location('Entering:'||l_proc, 5);
1302 --
1303 -- Process Logic
1304 --
1305 -- 1) Lock the element link and identify the validation date range.
1306 -- 2) Validation in addition to the row handler.
1307 -- 3) Delete non datetrack child rows.
1308 -- 4) ZAP or End Date child rows.
1309 -- 5) Delete the element link.
1310 -- 6) Next Change or Future Change child rows.
1311 --
1312
1313 --
1314 -- Ensure that the DateTrack delete mode is valid
1315 --
1316 dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_delete_mode);
1317
1318
1319 hr_utility.set_location(l_proc, 10);
1320 --
1321 -- 1) Lock the element link and identify the validation date range.
1322 --
1323 pay_pel_shd.lck
1324 (p_effective_date => p_effective_date
1325 ,p_datetrack_mode => p_datetrack_delete_mode
1326 ,p_element_link_id => p_element_link_id
1327 ,p_object_version_number => l_object_version_number
1328 ,p_validation_start_date => l_validation_start_date
1329 ,p_validation_end_date => l_validation_end_date
1330 ,p_enforce_foreign_locking => false
1331 );
1332
1333 --
1334 -- Set the element link information obtained by the lock.
1335 --
1336 l_business_group_id := pay_pel_shd.g_old_rec.business_group_id;
1337 l_people_group_id := pay_pel_shd.g_old_rec.people_group_id;
1338 l_old_esd := pay_pel_shd.g_old_rec.effective_start_date;
1339 l_old_eed := pay_pel_shd.g_old_rec.effective_end_date;
1340
1341 --
1342 -- Remember the date range of the element link.
1343 --
1344 open csr_link_date_range;
1345 fetch csr_link_date_range into l_old_min_esd, l_old_max_eed;
1346 close csr_link_date_range;
1347
1348 hr_utility.set_location(l_proc, 20);
1349 --
1350 -- 2) Validation in addition to the row handler.
1351 --
1352 -- Check to see if this delete is allowed.
1353 -- ie. We allow the cascade delete only when no element entry rows are
1354 -- to be deleted.
1355 --
1356 pay_pel_bus.chk_date_eff_delete
1357 (p_element_link_id => p_element_link_id
1358 ,p_delete_mode => p_datetrack_delete_mode
1359 ,p_validation_start_date => l_validation_start_date
1360 );
1361
1362 hr_utility.set_location(l_proc, 30);
1363 --
1364 -- 3) Delete non datetrack child rows.
1365 -- Bug 5512101. Batch Element Link support.
1366 --
1367 if p_datetrack_delete_mode = hr_api.g_zap then
1368 -- Delete the batch object status.
1369 pay_batch_object_status_pkg.delete_object_status
1370 (p_object_type => 'EL'
1371 ,p_object_id => p_element_link_id
1372 ,p_payroll_action_id => null
1373 );
1374 else
1375 -- Ensure that the batch object status is complete.
1376 pay_batch_object_status_pkg.chk_complete_status
1377 (p_object_type => 'EL'
1378 ,p_object_id => p_element_link_id
1379 );
1380 end if;
1381
1382 hr_utility.set_location(l_proc, 40);
1383 --
1384 -- 4) ZAP or End Date child rows.
1385 --
1386 if p_datetrack_delete_mode in (hr_api.g_zap, hr_api.g_delete) then
1387
1388 -- Delete element entries
1389 for fetched_entry in csr_links_entries
1390 loop
1391 hr_entry_api.delete_element_entry
1392 (p_datetrack_delete_mode,
1393 p_effective_date,
1394 fetched_entry.element_entry_id
1395 );
1396 end loop;
1397
1398 -- Delete link input values
1399 for fetched_input_value in csr_all_inputs_for_link
1400 loop
1401 l_liv_ovn := fetched_input_value.object_version_number;
1402 l_liv_esd := null;
1403 l_liv_eed := null;
1404 pay_liv_del.del
1405 (p_effective_date => p_effective_date
1406 ,p_datetrack_mode => p_datetrack_delete_mode
1407 ,p_link_input_value_id => fetched_input_value.link_input_value_id
1408 ,p_object_version_number => l_liv_ovn
1409 ,p_effective_start_date => l_liv_esd
1410 ,p_effective_end_date => l_liv_eed
1411 );
1412 end loop;
1413
1414 -- Delete assignment link usuages
1415 pay_asg_link_usages_pkg.cascade_link_deletion
1416 (p_element_link_id => p_element_link_id
1417 ,p_business_group_id => l_business_group_id
1418 ,p_people_group_id => l_people_group_id
1419 ,p_delete_mode => p_datetrack_delete_mode
1420 ,p_effective_start_date => l_old_esd
1421 ,p_effective_end_date => l_old_eed
1422 ,p_validation_start_date => l_validation_start_date
1423 ,p_validation_end_date => l_validation_end_date
1424 );
1425
1426 end if;
1427
1428 hr_utility.set_location(l_proc, 80);
1429 --
1430 -- 5) Delete the element link.
1431 --
1432 pay_pel_del.del
1433 (p_effective_date => p_effective_date
1434 ,p_element_link_id => p_element_link_id
1435 ,p_datetrack_delete_mode => p_datetrack_delete_mode
1436 ,p_object_version_number => l_object_version_number
1437 ,p_effective_start_date => l_effective_start_date
1438 ,p_effective_end_date => l_effective_end_date
1439 ,p_warning => l_entries_warning
1440 );
1441
1442 hr_utility.set_location(l_proc, 90);
1443 --
1444 -- 6) Next Change or Future Change child rows.
1445 --
1446 if p_datetrack_delete_mode in (hr_api.g_delete_next_change
1447 ,hr_api.g_future_change) then
1448
1449 --
1450 -- We should extend the duration of child records only when
1451 -- the effective end date of the parent element link is extended.
1452 --
1453
1454 -- Obtain the new date range.
1455 --
1456 open csr_link_date_range;
1457 fetch csr_link_date_range into l_new_min_esd, l_new_max_eed;
1458 close csr_link_date_range;
1459
1460 if l_new_max_eed > l_old_max_eed then
1461
1462 -- Delete assignment link usuages
1463
1464 pay_asg_link_usages_pkg.cascade_link_deletion
1465 (p_element_link_id => p_element_link_id
1466 ,p_business_group_id => l_business_group_id
1467 ,p_people_group_id => l_people_group_id
1468 ,p_delete_mode => hr_api.g_delete_next_change
1469 ,p_effective_start_date => l_new_min_esd
1470 ,p_effective_end_date => l_new_max_eed
1471 ,p_validation_start_date => l_validation_start_date
1472 ,p_validation_end_date => l_validation_end_date
1473 );
1474
1475 -- Delete link input values
1476 --
1477 for last_liv_rec in csr_last_liv
1478 loop
1479 l_liv_ovn := last_liv_rec.object_version_number;
1480 l_liv_esd := null;
1481 l_liv_eed := null;
1482 if last_liv_rec.effective_end_date < l_new_max_eed then
1483 pay_liv_del.del
1484 (p_effective_date => last_liv_rec.effective_end_date
1485 ,p_datetrack_mode => hr_api.g_delete_next_change
1486 ,p_link_input_value_id => last_liv_rec.link_input_value_id
1487 ,p_object_version_number => l_liv_ovn
1488 ,p_effective_start_date => l_liv_esd
1489 ,p_effective_end_date => l_liv_eed
1490 );
1491 end if;
1492 end loop;
1493
1494 -- Delete element entries
1495 for fetched_entry in csr_links_entries
1496 loop
1497 hr_entry_api.delete_element_entry
1498 (p_datetrack_delete_mode,
1499 p_effective_date,
1500 fetched_entry.element_entry_id
1501 );
1502 end loop;
1503
1504 end if;
1505 end if;
1506
1507 --
1508 -- Set out variables
1509 --
1510 p_object_version_number := l_object_version_number;
1511 p_effective_start_date := l_effective_start_date;
1512 p_effective_end_date := l_effective_end_date;
1513 p_entries_warning := l_entries_warning;
1514 --
1515 hr_utility.set_location(' Leaving:'||l_proc, 100);
1516 end delete_element_link_int;
1517 --
1518 -- ----------------------------------------------------------------------------
1519 -- |--------------------------<delete_element_link> -------------------------|
1520 -- ----------------------------------------------------------------------------
1521 --
1522 procedure delete_element_link
1523 (p_validate in boolean default false
1524 ,p_effective_date in date
1525 ,p_element_link_id in number
1526 ,p_datetrack_delete_mode in varchar2
1527 ,p_object_version_number in out nocopy number
1528 ,p_effective_start_date out nocopy date
1529 ,p_effective_end_date out nocopy date
1530 ,p_entries_warning out nocopy boolean
1531 ) is
1532 --
1533 -- Declare cursors and local variables
1534 --
1535 l_proc varchar2(72) := g_package||'delete_element_link';
1536 l_effective_date date;
1537
1538 begin
1539 hr_utility.set_location('Entering:'|| l_proc, 10);
1540 --
1541 -- Issue a savepoint
1542 --
1543 savepoint delete_element_link;
1544
1545 --
1546 -- Truncate the time portion from all IN date parameters
1547 --
1548 l_effective_date := trunc(p_effective_date);
1549 --
1550 -- Call Before Process User Hook
1551 --
1552 begin
1553 pay_element_link_BK3.delete_element_link_b
1554 (l_effective_date
1555 ,p_element_link_id
1556 ,p_datetrack_delete_mode
1557 ,p_object_version_number
1558 );
1559 exception
1560 when hr_api.cannot_find_prog_unit then
1561 hr_api.cannot_find_prog_unit_error
1562 (p_module_name => 'delete_element_link'
1563 ,p_hook_type => 'BP'
1564 );
1565 end;
1566
1567 --
1568 -- Validation in addition to Row Handlers
1569 --
1570 -- Bug 6004788. Replaced the call to pay_pel_del.del with call to
1571 -- delete_element_link_int.
1572 -- Process Logic
1573 --
1574 delete_element_link_int
1575 (p_effective_date => l_effective_date
1576 ,p_element_link_id => p_element_link_id
1577 ,p_datetrack_delete_mode => p_datetrack_delete_mode
1578 ,p_object_version_number => p_object_version_number
1579 ,p_effective_start_date => p_effective_start_date
1580 ,p_effective_end_date => p_effective_end_date
1581 ,p_entries_warning => p_entries_warning
1582 );
1583 --
1584 -- Call After Process User Hook
1585 --
1586 begin
1587 pay_element_link_BK3.delete_element_link_a
1588 (l_effective_date
1589 ,p_element_link_id
1590 ,p_datetrack_delete_mode
1591 ,p_object_version_number
1592 ,p_effective_start_date
1593 ,p_effective_end_date
1594 ,p_entries_warning
1595 );
1596 exception
1597 when hr_api.cannot_find_prog_unit then
1598 hr_api.cannot_find_prog_unit_error
1599 (p_module_name => 'delete_element_link'
1600 ,p_hook_type => 'AP'
1601 );
1602 end;
1603
1604 --
1605 -- When in validation only mode raise the Validate_Enabled exception
1606 --
1607 if p_validate then
1608 raise hr_api.validate_enabled;
1609 end if;
1610
1611 hr_utility.set_location(' Leaving:'||l_proc, 70);
1612 exception
1613 when hr_api.validate_enabled then
1614 --
1615 -- As the Validate_Enabled exception has been raised
1616 -- we must rollback to the savepoint
1617 --
1618 rollback to delete_element_link;
1619 --
1620 -- Only set output warning arguments
1621 -- (Any key or derived arguments must be set to null
1622 -- when validation only mode is being used.)
1623 --
1624
1625 hr_utility.set_location(' Leaving:'||l_proc, 80);
1626 when others then
1627 --
1628 -- A validation or unexpected error has occured
1629 --
1630 rollback to delete_element_link;
1631 hr_utility.set_location(' Leaving:'||l_proc, 90);
1632 raise;
1633 end delete_element_link;
1634 --
1635
1636 end PAY_ELEMENT_LINK_API;