[Home] [Help]
PACKAGE BODY: APPS.PAY_COST_ALLOCATION_API
Source
1 Package Body PAY_COST_ALLOCATION_API as
2 /* $Header: pycalapi.pkb 120.5 2006/07/31 09:29:46 susivasu noship $ */
3 --
4 -- Package Variables
5 --
6 g_package varchar2(33) := ' PAY_COST_ALLOCATION_API.';
7 -- bug no 3829293. Local variable to hold segment value
8 type segment_value is varray(30) of varchar2(150);
9 l_segment_value segment_value ;
10 --
11 -- ----------------------------------------------------------------------------
12 -- |-----------------------< update_cak_concat_segs >-------------------------|
13 -- ----------------------------------------------------------------------------
14 -- {Start Of Comments}
15 --
16 -- Description:
17 -- When required this procedure updates the pay_cost_allocation_keyflex table
18 -- after the flexfield segments have been inserted to keep the concatenated
19 -- segment string up-to-date.
20 --
21 -- Prerequisites:
22 -- A row must exist in the pay_cost_allocation_keyflex table for the
23 -- given cost_allocation_keyflex_id.
24 --
25 -- In Parameters:
26 -- Name Reqd Type Description
27 -- p_cost_allocation_keyflex_id Yes number The primary key
28 -- p_concatenated_segments Yes varchar2 The concatenated segments
29 --
30 -- Post Success:
31 -- If required the row is updated and committed.
32 --
33 -- Post Failure:
34 -- The procedure will raise an error.
35 --
36 -- Access Status:
37 -- Internal use only.
38 --
39 -- {End Of Comments}
40 --
41 procedure update_cak_concat_segs
42 (p_cost_allocation_keyflex_id in number
43 ,p_concatenated_segments in varchar2
44 ) is
45 --
46 CURSOR csr_chk_cak is
47 SELECT null
48 FROM pay_cost_allocation_keyflex
49 where cost_allocation_keyflex_id = p_cost_allocation_keyflex_id
50 and (concatenated_segments <> p_concatenated_segments
51 or concatenated_segments is null);
52 --
53 l_exists varchar2(30);
54 l_proc varchar2(72) := g_package||'update_cak_concat_segs';
55 --
56 procedure update_cak_concat_segs_auto
57 (p_cost_allocation_keyflex_id in number
58 ,p_concatenated_segments in varchar2
59 ) is
60 PRAGMA AUTONOMOUS_TRANSACTION;
61 --
62 CURSOR csr_cak_lock is
63 SELECT null
64 FROM pay_cost_allocation_keyflex
65 where cost_allocation_keyflex_id = p_cost_allocation_keyflex_id
66 for update nowait;
67 --
68 l_exists varchar2(30);
69 l_proc varchar2(72) := g_package||'update_cak_concat_segs_auto';
70 --
71 begin
72 hr_utility.set_location('Entering:'|| l_proc, 10);
73 --
74 -- The outer procedure has already establish that an update is
75 -- required. This sub-procedure uses an autonomous transaction
76 -- to ensure that any commits do not impact the main transaction.
77 -- If the row is successfully locked then continue and update the
78 -- row. If the row cannot be locked then another transaction must
79 -- be performing the update. So it is acceptable for this
80 -- transaction to silently trap the error and continue.
81 --
82 -- Note: It is necessary to perform the lock test because in
83 -- a batch data upload scenario multiple sessions could be
84 -- attempting to insert or update the same Key Flexfield
85 -- combination at the same time. Just directly updating the row,
86 -- without first locking, can cause sessions to hang and reduce
87 -- batch throughput.
88 --
89 open csr_cak_lock;
90 fetch csr_cak_lock into l_exists;
91 if csr_cak_lock%found then
92 close csr_cak_lock;
93 hr_utility.set_location(l_proc, 20);
94 --
95 -- Lock obtained by this transaction, updating the concatenated
96 -- segment string should be performed.
97 --
98 update pay_cost_allocation_keyflex
99 set concatenated_segments = p_concatenated_segments
100 where cost_allocation_keyflex_id = p_cost_allocation_keyflex_id
101 and (concatenated_segments <> p_concatenated_segments
102 or concatenated_segments is null);
103 --
104 -- Commit this change so the change is immediately visible to
105 -- other transactions. Also ensuring that it is not undone if
106 -- the main transaction is rolled back. This commit is only
107 -- acceptable inside an API because it is being performed inside
108 -- an autonomous transaction and AOL code has previously
109 -- inserted the Key Flexfield combination row in another
110 -- autonomous transaction.
111 commit;
112 else
113 close csr_cak_lock;
114 end if;
115 --
116 hr_utility.set_location('Leaving:'|| l_proc, 30);
117 Exception
118 When HR_Api.Object_Locked then
119 --
120 -- This autonomous transaction was unable to lock the row.
121 -- It can be assumed that another transaction has locked the
122 -- row and is performing the update. Hence the error can
123 -- be suppressed without raising it to the end user.
124 --
125 hr_utility.set_location('Leaving:'|| l_proc, 40);
126 end update_cak_concat_segs_auto;
127 begin
128 hr_utility.set_location('Entering:'|| l_proc, 10);
129 --
130 -- First find out if it is necessary to update the concatenated
131 -- segment string column. This select is being done to avoid the
132 -- performance unnecessary overhead of set-up an autonomous
133 -- transaction when an update is not required. Updates are only
134 -- expected immediately after the combination row was first inserted.
135 --
136 open csr_chk_cak;
137 fetch csr_chk_cak into l_exists;
138 if csr_chk_cak%found then
139 close csr_chk_cak;
140 update_cak_concat_segs_auto
141 (p_cost_allocation_keyflex_id => p_cost_allocation_keyflex_id
142 ,p_concatenated_segments => p_concatenated_segments
143 );
144 else
145 close csr_chk_cak;
146 end if;
147 --
148 hr_utility.set_location('Leaving:'|| l_proc, 40);
149 --
150 end update_cak_concat_segs;
151 --
152 --
153 -- ----------------------------------------------------------------------------
154 -- |-----------------------< check_mandatory_segments >-----------------------|
155 -- ----------------------------------------------------------------------------
156 -- {Start Of Comments}
157 --
158 -- Description:
159 -- This procedure will check any segment which is not required for
160 -- particular level and have been assigned any value. Procedure will
161 -- error out in case any extra segment have been assigned value.
162 -- This procedure will also check the segments which are mandatory and qualified
163 -- for particular level.
164 --
165 -- Prerequisites:
166 -- None.
167 --
168 -- In Parameters:
169 -- Name Reqd Type Description
170 -- p_level Yes varchar2 The Qualifier level.
171 -- p_cost_id_flex_num Yes varchar2 The concatenated flex number.
172 -- p_segment No segment_value.
173 --
174 -- Post Success:
175 -- If none of required segments are not null then row is inserted or updated
176 -- successfully.
177 --
178 -- Post Failure:
179 -- The procedure will raise an error.
180 --
181 -- Access Status:
182 -- Internal use only.
183 --
184 -- {End Of Comments}
185 --
186 Procedure check_mandatory_segments(
187 p_level IN VARCHAR2,
188 p_cost_id_flex_num IN NUMBER,
189 p_segment IN segment_value,
190 p_cost_allocation_keyflex_id IN NUMBER
191 ) is
192 l_proc VARCHAR2(72) := g_package||'check_mandatory_segments';
193 --
194
195 type segment_no_array is table
196 of number(2) INDEX BY Binary_integer;
197 type application_column_array is table
198 of fnd_id_flex_segments.application_column_name%type INDEX BY Binary_integer;
199 type application_segment_array is table
200 of fnd_id_flex_segments.segment_name%type INDEX BY Binary_integer;
201 type required_flag_array is table
202 of fnd_id_flex_segments.required_flag%type INDEX BY Binary_integer;
203
204 l_segment_no segment_no_array;
205 l_application_column application_column_array;
206 l_application_segment application_segment_array;
207 l_required_flag required_flag_array;
208 l_value_passed varchar2(1);
209
210
211 cursor csr_segment is
212 SELECT substr(fs.application_column_name,8,2) segment_no,
213 fs.application_column_name application_column_name,
214 fs.segment_name application_segment_name,
215 fs.required_flag required_flag
216 FROM FND_ID_FLEX_SEGMENTS fs,
217 FND_SEGMENT_ATTRIBUTE_VALUES sa1
218 WHERE sa1.id_flex_num = p_cost_id_flex_num
219 and sa1.id_flex_code = 'COST'
220 and sa1.attribute_value = 'Y'
221 and sa1.segment_attribute_type <> 'BALANCING'
222 and sa1.segment_attribute_type = p_level
223 and fs.id_flex_num = p_cost_id_flex_num
224 and fs.id_flex_code = 'COST'
225 and fs.enabled_flag = 'Y'
226 and fs.application_id = 801
227 and fs.application_column_name =
228 sa1.application_column_name
229 order by substr(fs.application_column_name,8,2);
230
231
232
233 -- local variable to hold segments needed for the particular level
234 -- initialy mark all segment as not required
235 l_required_segment Segment_value
236 := segment_value('N','N','N','N','N','N','N','N','N','N',
237 'N','N','N','N','N','N','N','N','N','N',
238 'N','N','N','N','N','N','N','N','N','N'
239 );
240 --
241 v_cal_cost_segs varchar2(3);
242 --
243
244 Begin
245
246 l_value_passed := 'N';
247 for i in 1..30 loop
248 if p_segment(i) is not null then
249 --
250 l_value_passed := 'Y';
251 --
252 end if;
253 end loop;
254 --
255 if (l_value_passed = 'N'
256 and (p_cost_allocation_keyflex_id is null
257 or p_cost_allocation_keyflex_id = -1)) then
258 fnd_message.set_name('PER','HR_51342_COST_COST_CODE_REQ');
259 hr_utility.raise_error;
260 end if;
261 --
262
263 OPEN csr_segment;
264 FETCH csr_segment BULK COLLECT INTO l_Segment_no,l_application_column,
265 l_application_segment,l_required_flag;
266 close csr_segment;
267
268 --
269 -- Perform Flexfield Validation: if COST_VAL_SEGS pay_action_parameter = 'Y'
270 --
271 begin
272 select parameter_value
273 into v_cal_cost_segs
274 from pay_action_parameters
275 where parameter_name = 'COST_VAL_SEGS';
276 exception
277 when others then
278 v_cal_cost_segs := 'N';
279 end;
280 --
281
282 -- Only carry out the mandatory check if the COST_VAL_SEGS is set as 'Y'.
283 if ( l_segment_no.COUNT <> 0 and v_cal_cost_segs = 'Y') then
284
285 FOR i IN l_segment_no.FIRST..l_segment_no.LAST
286 LOOP
287 -- mark those segment which is needed for flexfield
288 --
289 l_required_segment(l_segment_no(i)) := 'Y';
290 --
291 -- Check for mandatoy segment
292 --
293 If (l_required_flag(i) = 'Y' and p_segment(l_segment_no(i)) is null) then
294 fnd_message.set_name('PER','HR_FLEX_VALUE_MISSING');
295 fnd_message.set_token('COLUMN',l_application_column(i));
296 fnd_message.set_token('PROMPT',l_application_segment(i));
297 hr_utility.raise_error;
298 end if;
299 END LOOP;
300
301 end if;
302
303 -- -- check whether any segment is not required for flexfield and value has been
304 -- -- assigned for the same.
305 -- for i in 1..30 loop
306 -- if l_required_segment(i) = 'N' then
307 -- if (p_segment(i) is not null or p_segment(i) = hr_api.g_varchar2) then
308 -- --
309 -- hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
310 -- hr_utility.set_message_token('PROCEDURE', l_proc);
311 -- hr_utility.set_message_token('STEP','20');
312 -- hr_utility.raise_error;
313 -- --
314 -- end if;
315 -- end if;
316 -- end loop;
317
318 end check_mandatory_segments;
319 --
320 -- ----------------------------------------------------------------------------
321 -- |------------------------< CREATE_COST_ALLOCATION >------------------------|
322 -- ----------------------------------------------------------------------------
323 --
324 procedure CREATE_COST_ALLOCATION
325 (p_validate in boolean default false
326 ,p_effective_date in date
327 ,p_assignment_id in number
328 ,p_proportion in number
329 ,p_business_group_id in number
330 ,p_segment1 in varchar2 default null
331 ,p_segment2 in varchar2 default null
332 ,p_segment3 in varchar2 default null
333 ,p_segment4 in varchar2 default null
334 ,p_segment5 in varchar2 default null
335 ,p_segment6 in varchar2 default null
336 ,p_segment7 in varchar2 default null
337 ,p_segment8 in varchar2 default null
338 ,p_segment9 in varchar2 default null
339 ,p_segment10 in varchar2 default null
340 ,p_segment11 in varchar2 default null
341 ,p_segment12 in varchar2 default null
342 ,p_segment13 in varchar2 default null
343 ,p_segment14 in varchar2 default null
344 ,p_segment15 in varchar2 default null
345 ,p_segment16 in varchar2 default null
346 ,p_segment17 in varchar2 default null
347 ,p_segment18 in varchar2 default null
348 ,p_segment19 in varchar2 default null
349 ,p_segment20 in varchar2 default null
350 ,p_segment21 in varchar2 default null
351 ,p_segment22 in varchar2 default null
352 ,p_segment23 in varchar2 default null
353 ,p_segment24 in varchar2 default null
354 ,p_segment25 in varchar2 default null
355 ,p_segment26 in varchar2 default null
356 ,p_segment27 in varchar2 default null
357 ,p_segment28 in varchar2 default null
358 ,p_segment29 in varchar2 default null
359 ,p_segment30 in varchar2 default null
360 ,p_concat_segments in varchar2 default null
361 ,p_request_id in number default null
362 ,p_program_application_id in number default null
363 ,p_program_id in number default null
364 ,p_program_update_date in date default null
365 ,p_combination_name out nocopy varchar2
366 ,p_cost_allocation_id out nocopy number
367 ,p_effective_start_date out nocopy date
368 ,p_effective_end_date out nocopy date
369 ,p_cost_allocation_keyflex_id in out nocopy number
370 ,p_object_version_number out nocopy number
371 ) is
372 --
373 -- Declare cursors and local variables
374 --
375 l_proc varchar2(72) := g_package||'CREATE_COST_ALLOCATION';
376 l_effective_date date;
377 l_flex_num fnd_id_flex_segments.id_flex_num%TYPE;
378 -- bug no. 3829293.
379 -- l_cost_allocation_keyflex_id number(15);
380 l_cost_allocation_keyflex_id number(15):= -1;
381 --
382 -- Initialize segment varray from passed parameter values
383 l_new_segment segment_value
384 :=segment_value(p_segment1 ,p_segment2 ,p_segment3 ,p_segment4 ,p_segment5,
385 p_segment6 ,p_segment7 ,p_segment8 ,p_segment9 ,p_segment10,
386 p_segment11 ,p_segment12,p_segment13 ,p_segment14 ,p_segment15,
387 p_segment16 ,p_segment17,p_segment18 ,p_segment19 ,p_segment20,
388 p_segment21 ,p_segment22,p_segment23 ,p_segment24 ,p_segment25,
389 p_segment26 ,p_segment27,p_segment28 ,p_segment29 ,p_segment30
390 );
391 --
392 l_combination_name varchar2(240);
393 l_cost_allocation_id pay_cost_allocations_f.cost_allocation_id%TYPE;
394 l_object_version_number pay_cost_allocations_f.object_version_number%TYPE;
395 l_effective_start_date pay_cost_allocations_f.effective_start_date%TYPE;
396 l_effective_end_date pay_cost_allocations_f.effective_end_date%TYPE;
397 l_concat_segs pay_cost_allocation_keyflex.concatenated_segments%TYPE;
398 --
399 cursor csr_cost_structure is
400 select pbg.cost_allocation_structure
401 from per_business_groups pbg
402 where pbg.business_group_id = p_business_group_id;
403 --
404 begin
405 hr_utility.set_location('Entering:'|| l_proc, 10);
406 --
407 -- Issue a savepoint
408 --
409 savepoint CREATE_COST_ALLOCATION;
410 --
411 -- Truncate the time portion from all IN date parameters
412 --
413 l_effective_date := trunc(p_effective_date);
414 --
415 -- Call Before Process User Hook
416 --
417 begin
418 PAY_COST_ALLOCATION_BK1.create_cost_allocation_b
419 (p_effective_date => l_effective_date
420 ,p_assignment_id => p_assignment_id
421 ,p_proportion => p_proportion
422 ,p_business_group_id => p_business_group_id
423 ,p_segment1 => p_segment1
424 ,p_segment2 => p_segment2
425 ,p_segment3 => p_segment3
426 ,p_segment4 => p_segment4
427 ,p_segment5 => p_segment5
428 ,p_segment6 => p_segment6
429 ,p_segment7 => p_segment7
430 ,p_segment8 => p_segment8
431 ,p_segment9 => p_segment9
432 ,p_segment10 => p_segment10
433 ,p_segment11 => p_segment11
434 ,p_segment12 => p_segment12
435 ,p_segment13 => p_segment13
436 ,p_segment14 => p_segment14
437 ,p_segment15 => p_segment15
438 ,p_segment16 => p_segment16
439 ,p_segment17 => p_segment17
440 ,p_segment18 => p_segment18
441 ,p_segment19 => p_segment19
442 ,p_segment20 => p_segment20
443 ,p_segment21 => p_segment21
444 ,p_segment22 => p_segment22
445 ,p_segment23 => p_segment23
446 ,p_segment24 => p_segment24
447 ,p_segment25 => p_segment25
448 ,p_segment26 => p_segment26
449 ,p_segment27 => p_segment27
450 ,p_segment28 => p_segment28
451 ,p_segment29 => p_segment29
452 ,p_segment30 => p_segment30
453 ,p_concat_segments => p_concat_segments
454 ,p_request_id => p_request_id
455 ,p_program_application_id => p_program_application_id
456 ,p_program_id => p_program_id
457 ,p_program_update_date => p_program_update_date
458
459 );
460 exception
461 when hr_api.cannot_find_prog_unit then
462 hr_api.cannot_find_prog_unit_error
463 (p_module_name => 'CREATE_COST_ALLOCATION'
464 ,p_hook_type => 'BP'
465 );
466 end;
467 --
468 -- Need to set CLIENT_INFO as HR_LOOKUPS may be referenced
469 -- by SEGMENT Value Sets.
470 --
471 hr_api.validate_bus_grp_id(p_business_group_id);
472 --
473 open csr_cost_structure;
474 fetch csr_cost_structure into l_flex_num;
475 if csr_cost_structure%notfound then
476 close csr_cost_structure;
477 --
478 -- the flex structure has not been found
479 --
480 fnd_message.set_name('PAY', 'HR_7471_FLEX_PEA_INVALID_ID');
481 fnd_message.raise_error;
482 end if;
483 close csr_cost_structure;
484 --
485 -- bug no. 3829293. Use hr_entry.maintain_cost_flexfield instead of
486 -- below procedure
487 /*
488 --
489 -- Determine the cost allocation definition by calling ins_or_sel
490 --
491 hr_kflex_utility.ins_or_sel_keyflex_comb
492 (p_appl_short_name => 'PAY'
493 ,p_flex_code => 'COST'
494 ,p_flex_num => l_flex_num
495 ,p_segment1 => p_segment1
496 ,p_segment2 => p_segment2
497 ,p_segment3 => p_segment3
498 ,p_segment4 => p_segment4
499 ,p_segment5 => p_segment5
500 ,p_segment6 => p_segment6
501 ,p_segment7 => p_segment7
502 ,p_segment8 => p_segment8
503 ,p_segment9 => p_segment9
504 ,p_segment10 => p_segment10
505 ,p_segment11 => p_segment11
506 ,p_segment12 => p_segment12
507 ,p_segment13 => p_segment13
508 ,p_segment14 => p_segment14
509 ,p_segment15 => p_segment15
510 ,p_segment16 => p_segment16
511 ,p_segment17 => p_segment17
512 ,p_segment18 => p_segment18
513 ,p_segment19 => p_segment19
514 ,p_segment20 => p_segment20
515 ,p_segment21 => p_segment21
516 ,p_segment22 => p_segment22
517 ,p_segment23 => p_segment23
518 ,p_segment24 => p_segment24
519 ,p_segment25 => p_segment25
520 ,p_segment26 => p_segment26
521 ,p_segment27 => p_segment27
522 ,p_segment28 => p_segment28
523 ,p_segment29 => p_segment29
524 ,p_segment30 => p_segment30
525 ,p_concat_segments_in => p_concat_segments
526 ,p_ccid => l_cost_allocation_keyflex_id
527 ,p_concat_segments_out => l_combination_name
528 );
529 --
530 -- Set CONCATENATED_SEGMENTS column in pay_cost_allocation_keyflex
531 -- bug 2620309
532 --
533 -- The update of the concatenated_segments column is executed
534 -- in a separate procedure. (Bug #3177656)
535 --
536 update_cak_concat_segs
537 (p_cost_allocation_keyflex_id => l_cost_allocation_keyflex_id
538 ,p_concatenated_segments => l_combination_name
539 );
540
541 */
542 -- check mandatory segment
543 --
544 check_mandatory_segments(
545 p_level =>'ASSIGNMENT',
546 p_cost_id_flex_num =>l_flex_num,
547 p_segment =>l_new_segment,
548 p_cost_allocation_keyflex_id => p_cost_allocation_keyflex_id
549 );
550
551 -- insert flexfield segment
552 --
553 l_cost_allocation_keyflex_id :=
554 hr_entry.maintain_cost_keyflex(
555 p_cost_keyflex_structure => l_flex_num,
556 p_cost_allocation_keyflex_id => nvl(p_cost_allocation_keyflex_id,l_cost_allocation_keyflex_id),
557 p_concatenated_segments => p_concat_segments,
558 p_summary_flag =>'N',
559 p_start_date_active => NULL,
560 p_end_date_active => NULL,
561 p_segment1 =>p_segment1,
562 p_segment2 =>p_segment2,
563 p_segment3 =>p_segment3,
564 p_segment4 =>p_segment4,
565 p_segment5 =>p_segment5,
566 p_segment6 =>p_segment6,
567 p_segment7 =>p_segment7,
568 p_segment8 =>p_segment8,
569 p_segment9 =>p_segment9,
570 p_segment10 =>p_segment10,
571 p_segment11 =>p_segment11,
572 p_segment12 =>p_segment12,
573 p_segment13 =>p_segment13,
574 p_segment14 =>p_segment14,
575 p_segment15 =>p_segment15,
576 p_segment16 =>p_segment16,
577 p_segment17 =>p_segment17,
578 p_segment18 =>p_segment18,
579 p_segment19 =>p_segment19,
580 p_segment20 =>p_segment20,
581 p_segment21 =>p_segment21,
582 p_segment22 =>p_segment22,
583 p_segment23 =>p_segment23,
584 p_segment24 =>p_segment24,
585 p_segment25 =>p_segment25,
586 p_segment26 =>p_segment26,
587 p_segment27 =>p_segment27,
588 p_segment28 =>p_segment28,
589 p_segment29 =>p_segment29,
590 p_segment30 =>p_segment30);
591
592 -- end of bug no. 3829293.
593 --
594 -- Process Logic
595 --
596 pay_cal_ins.ins
597 (p_effective_date => l_effective_date
598 ,p_business_group_id => p_business_group_id
599 ,p_cost_allocation_keyflex_id => l_cost_allocation_keyflex_id
600 ,p_assignment_id => p_assignment_id
601 ,p_proportion => p_proportion
602 ,p_request_id => p_request_id
603 ,p_program_application_id => p_program_application_id
604 ,p_program_id => p_program_id
605 ,p_program_update_date => p_program_update_date
606 ,p_cost_allocation_id => l_cost_allocation_id
607 ,p_object_version_number => l_object_version_number
608 ,p_effective_start_date => l_effective_start_date
609 ,p_effective_end_date => l_effective_end_date
610 );
611 --
612 -- Call After Process User Hook
613 --
614 begin
615 PAY_COST_ALLOCATION_BK1.create_cost_allocation_a
616 (p_effective_date => l_effective_date
617 ,p_assignment_id => p_assignment_id
618 ,p_proportion => p_proportion
619 ,p_business_group_id => p_business_group_id
620 ,p_segment1 => p_segment1
621 ,p_segment2 => p_segment2
622 ,p_segment3 => p_segment3
623 ,p_segment4 => p_segment4
624 ,p_segment5 => p_segment5
625 ,p_segment6 => p_segment6
626 ,p_segment7 => p_segment7
627 ,p_segment8 => p_segment8
628 ,p_segment9 => p_segment9
629 ,p_segment10 => p_segment10
630 ,p_segment11 => p_segment11
631 ,p_segment12 => p_segment12
632 ,p_segment13 => p_segment13
633 ,p_segment14 => p_segment14
634 ,p_segment15 => p_segment15
635 ,p_segment16 => p_segment16
636 ,p_segment17 => p_segment17
637 ,p_segment18 => p_segment18
638 ,p_segment19 => p_segment19
639 ,p_segment20 => p_segment20
640 ,p_segment21 => p_segment21
641 ,p_segment22 => p_segment22
642 ,p_segment23 => p_segment23
643 ,p_segment24 => p_segment24
644 ,p_segment25 => p_segment25
645 ,p_segment26 => p_segment26
646 ,p_segment27 => p_segment27
647 ,p_segment28 => p_segment28
648 ,p_segment29 => p_segment29
649 ,p_segment30 => p_segment30
650 ,p_concat_segments => p_concat_segments
651 ,p_request_id => p_request_id
652 ,p_program_application_id => p_program_application_id
653 ,p_program_id => p_program_id
654 ,p_program_update_date => p_program_update_date
655 ,p_combination_name => l_combination_name
656 ,p_cost_allocation_id => l_cost_allocation_id
657 ,p_effective_start_date => l_effective_start_date
658 ,p_effective_end_date => l_effective_end_date
659 ,p_object_version_number => l_object_version_number
660 ,p_cost_allocation_keyflex_id => l_cost_allocation_keyflex_id
661 );
662 exception
663 when hr_api.cannot_find_prog_unit then
664 hr_api.cannot_find_prog_unit_error
665 (p_module_name => 'CREATE_COST_ALLOCATION'
666 ,p_hook_type => 'AP'
667 );
668 end;
669 --
670 -- When in validation only mode raise the Validate_Enabled exception
671 --
672 if p_validate then
673 raise hr_api.validate_enabled;
674 end if;
675 --
676 -- Set all output arguments
677 --
678 p_combination_name := l_combination_name;
679 p_cost_allocation_id := l_cost_allocation_id;
680 p_effective_start_date := l_effective_start_date;
681 p_effective_end_date := l_effective_end_date;
682 p_cost_allocation_keyflex_id := l_cost_allocation_keyflex_id;
683 p_object_version_number := l_object_version_number;
684 --
685 hr_utility.set_location(' Leaving:'||l_proc, 70);
686 exception
687 when hr_api.validate_enabled then
688 --
689 -- As the Validate_Enabled exception has been raised
690 -- we must rollback to the savepoint
691 --
692 rollback to CREATE_COST_ALLOCATION;
693 --
694 -- Only set output warning arguments
695 -- (Any key or derived arguments must be set to null
696 -- when validation only mode is being used.)
697 --
698 p_combination_name := null;
699 p_cost_allocation_id := null;
700 p_effective_start_date := null;
701 p_effective_end_date := null;
702 p_cost_allocation_keyflex_id := null;
703 p_object_version_number := null;
704 hr_utility.set_location(' Leaving:'||l_proc, 80);
705 when others then
706 --
707 -- A validation or unexpected error has occured
708 --
709 rollback to CREATE_COST_ALLOCATION;
710 --
711 -- Reset IN OUT params and set OUT params.
712 --
713 p_combination_name := null;
714 p_cost_allocation_id := null;
715 p_effective_start_date := null;
716 p_effective_end_date := null;
717 p_cost_allocation_keyflex_id := null;
718 p_object_version_number := null;
719 --
720 hr_utility.set_location(' Leaving:'||l_proc, 90);
721 raise;
722 end CREATE_COST_ALLOCATION;
723 --
724 -- ----------------------------------------------------------------------------
725 -- |------------------------< UPDATE_COST_ALLOCATION >------------------------|
726 -- ----------------------------------------------------------------------------
727 --
728 procedure UPDATE_COST_ALLOCATION
729 (p_validate in boolean default false
730 ,p_effective_date in date
731 ,p_datetrack_update_mode in varchar2
732 ,p_cost_allocation_id in number
733 ,p_object_version_number in out nocopy number
734 ,p_proportion in number default hr_api.g_number
735 ,p_segment1 in varchar2 default hr_api.g_varchar2
736 ,p_segment2 in varchar2 default hr_api.g_varchar2
737 ,p_segment3 in varchar2 default hr_api.g_varchar2
738 ,p_segment4 in varchar2 default hr_api.g_varchar2
739 ,p_segment5 in varchar2 default hr_api.g_varchar2
740 ,p_segment6 in varchar2 default hr_api.g_varchar2
741 ,p_segment7 in varchar2 default hr_api.g_varchar2
742 ,p_segment8 in varchar2 default hr_api.g_varchar2
743 ,p_segment9 in varchar2 default hr_api.g_varchar2
744 ,p_segment10 in varchar2 default hr_api.g_varchar2
745 ,p_segment11 in varchar2 default hr_api.g_varchar2
746 ,p_segment12 in varchar2 default hr_api.g_varchar2
747 ,p_segment13 in varchar2 default hr_api.g_varchar2
748 ,p_segment14 in varchar2 default hr_api.g_varchar2
749 ,p_segment15 in varchar2 default hr_api.g_varchar2
750 ,p_segment16 in varchar2 default hr_api.g_varchar2
751 ,p_segment17 in varchar2 default hr_api.g_varchar2
752 ,p_segment18 in varchar2 default hr_api.g_varchar2
753 ,p_segment19 in varchar2 default hr_api.g_varchar2
754 ,p_segment20 in varchar2 default hr_api.g_varchar2
755 ,p_segment21 in varchar2 default hr_api.g_varchar2
756 ,p_segment22 in varchar2 default hr_api.g_varchar2
757 ,p_segment23 in varchar2 default hr_api.g_varchar2
758 ,p_segment24 in varchar2 default hr_api.g_varchar2
759 ,p_segment25 in varchar2 default hr_api.g_varchar2
760 ,p_segment26 in varchar2 default hr_api.g_varchar2
761 ,p_segment27 in varchar2 default hr_api.g_varchar2
762 ,p_segment28 in varchar2 default hr_api.g_varchar2
763 ,p_segment29 in varchar2 default hr_api.g_varchar2
764 ,p_segment30 in varchar2 default hr_api.g_varchar2
765 ,p_concat_segments in varchar2 default hr_api.g_varchar2
766 ,p_request_id in number default hr_api.g_number
767 ,p_program_application_id in number default hr_api.g_number
768 ,p_program_id in number default hr_api.g_number
769 ,p_program_update_date in date default hr_api.g_date
770 ,p_combination_name out nocopy varchar2
771 ,p_cost_allocation_keyflex_id in out nocopy number
772 ,p_effective_start_date out nocopy date
773 ,p_effective_end_date out nocopy date
774 ) is
775 --
776 -- bug no 3829293.Initialize segment varray to passed parameter value
777 --
778 l_new_segment segment_value
779 :=segment_value(p_segment1 ,p_segment2 ,p_segment3 ,p_segment4 ,p_segment5,
780 p_segment6 ,p_segment7 ,p_segment8 ,p_segment9 ,p_segment10,
781 p_segment11 ,p_segment12,p_segment13 ,p_segment14 ,p_segment15,
782 p_segment16 ,p_segment17,p_segment18 ,p_segment19 ,p_segment20,
783 p_segment21 ,p_segment22,p_segment23 ,p_segment24 ,p_segment25,
784 p_segment26 ,p_segment27,p_segment28 ,p_segment29 ,p_segment30
785 );
786 l_previous_segment segment_value
787 :=segment_value(null ,null ,null ,null ,null, null ,null ,null ,null ,null,
788 null ,null ,null ,null ,null, null ,null ,null ,null ,null,
789 null ,null ,null ,null ,null, null ,null ,null ,null ,null
790 );
791 l_concat_segments varchar2(700);
792 l_validate_flex boolean := FALSE;
793 --
794 --
795 -- Declare cursors and local variables
796 --
797 l_proc varchar2(72) := g_package||'UPDATE_COST_ALLOCATION';
798 l_effective_date date;
799 l_flex_num fnd_id_flex_segments.id_flex_num%TYPE;
800 l_cost_allocation_keyflex_id number;
801 l_combination_name varchar2(240);
802 l_object_version_number pay_cost_allocations_f.object_version_number%TYPE;
803 l_effective_start_date pay_cost_allocations_f.effective_start_date%TYPE;
804 l_effective_end_date pay_cost_allocations_f.effective_end_date%TYPE;
805 l_business_group_id pay_cost_allocations_f.business_group_id%TYPE;
806 l_concat_segs pay_cost_allocation_keyflex.concatenated_segments%TYPE;
807 --
808 cursor csr_cost_structure(p_bg_id number) is
809 select pbg.cost_allocation_structure
810 from per_business_groups pbg
811 where pbg.business_group_id = p_bg_id;
812 --
813 cursor csr_old_ccid is
814 select pca.cost_allocation_keyflex_id
815 , pca.business_group_id
816 from pay_cost_allocations_f pca
817 where pca.cost_allocation_id = p_cost_Allocation_id
818 and p_effective_date between pca.effective_start_date
819 and pca.effective_end_date;
820 --
821 --cursor to hold old segment values from database
822 cursor csr_old_values is
823 select pca.segment1,
824 pca.segment2,
825 pca.segment3,
826 pca.segment4,
827 pca.segment5,
828 pca.segment6,
829 pca.segment7,
830 pca.segment8,
831 pca.segment9,
832 pca.segment10,
833 pca.segment11,
834 pca.segment12,
835 pca.segment13,
836 pca.segment14,
837 pca.segment15,
838 pca.segment16,
839 pca.segment17,
840 pca.segment18,
841 pca.segment19,
842 pca.segment20,
843 pca.segment21,
844 pca.segment22,
845 pca.segment23,
846 pca.segment24,
847 pca.segment25,
848 pca.segment26,
849 pca.segment27,
850 pca.segment28,
851 pca.segment29,
852 pca.segment30
853 from pay_cost_allocation_keyflex pca,
854 pay_cost_allocations_f pac
855 where pac.cost_allocation_id = p_cost_Allocation_id
856 and p_effective_date between pac.effective_start_date
857 and pac.effective_end_date
858 and pac.cost_allocation_keyflex_id = pca.cost_allocation_keyflex_id;
859 --
860 begin
861 hr_utility.set_location('Entering:'|| l_proc, 10);
862 --
863 -- Issue a savepoint
864 --
865 savepoint UPDATE_COST_ALLOCATION;
866 --
867 -- Truncate the time portion from all IN date parameters
868 --
869 l_effective_date := trunc(p_effective_date);
870 --
871 -- Initialise all IN/OUT parameters
872 --
873 l_object_version_number := p_object_version_number;
874 --
875 --
876 -- previous value of segment from database
877 --
878 if p_cost_allocation_id is not null then
879 open csr_old_values;
880 fetch csr_old_values into l_previous_segment(1) ,l_previous_segment(2),
881 l_previous_segment(3) ,l_previous_segment(4),
882 l_previous_segment(5) ,l_previous_segment(6),
883 l_previous_segment(7) ,l_previous_segment(8),
884 l_previous_segment(9) ,l_previous_segment(10),
885 l_previous_segment(11),l_previous_segment(12),
886 l_previous_segment(13),l_previous_segment(14),
887 l_previous_segment(15),l_previous_segment(16),
888 l_previous_segment(17),l_previous_segment(18),
889 l_previous_segment(19),l_previous_segment(20),
890 l_previous_segment(21),l_previous_segment(22),
891 l_previous_segment(23),l_previous_segment(24),
892 l_previous_segment(25),l_previous_segment(26),
893 l_previous_segment(27),l_previous_segment(28),
894 l_previous_segment(29),l_previous_segment(30);
895
896 close csr_old_values;
897 end if;
898 --
899 -- Make null to all segment default value
900 --
901 for i in 1..30 loop
902 if (l_new_segment(i) = hr_api.g_varchar2) then
903 -- if default value then retain previous value from database
904 l_new_segment(i) := nvl(l_previous_segment(i),null);
905 else
906 -- call the flex code if and only if any one of the segment or the
907 -- concatenated segment is not hr_api.g_varchar2.
908 --
909 l_validate_flex := TRUE;
910 end if;
911 end loop;
912 --
913 -- Call Before Process User Hook
914 --
915 begin
916 PAY_COST_ALLOCATION_BK2.update_cost_allocation_b
917 (p_effective_date => l_effective_date
918 ,p_datetrack_update_mode => p_datetrack_update_mode
919 ,p_cost_allocation_id => p_cost_allocation_id
920 ,p_object_version_number => l_object_version_number
921 ,p_proportion => p_proportion
922 ,p_segment1 => p_segment1
923 ,p_segment2 => p_segment2
924 ,p_segment3 => p_segment3
925 ,p_segment4 => p_segment4
926 ,p_segment5 => p_segment5
927 ,p_segment6 => p_segment6
928 ,p_segment7 => p_segment7
929 ,p_segment8 => p_segment8
930 ,p_segment9 => p_segment9
931 ,p_segment10 => p_segment10
932 ,p_segment11 => p_segment11
933 ,p_segment12 => p_segment12
934 ,p_segment13 => p_segment13
935 ,p_segment14 => p_segment14
936 ,p_segment15 => p_segment15
937 ,p_segment16 => p_segment16
938 ,p_segment17 => p_segment17
939 ,p_segment18 => p_segment18
940 ,p_segment19 => p_segment19
941 ,p_segment20 => p_segment20
942 ,p_segment21 => p_segment21
943 ,p_segment22 => p_segment22
944 ,p_segment23 => p_segment23
945 ,p_segment24 => p_segment24
946 ,p_segment25 => p_segment25
947 ,p_segment26 => p_segment26
948 ,p_segment27 => p_segment27
949 ,p_segment28 => p_segment28
950 ,p_segment29 => p_segment29
951 ,p_segment30 => p_segment30
952 ,p_concat_segments => p_concat_segments
953 ,p_request_id => p_request_id
954 ,p_program_application_id => p_program_application_id
955 ,p_program_id => p_program_id
956 ,p_program_update_date => p_program_update_date
957 );
958 exception
959 when hr_api.cannot_find_prog_unit then
960 hr_api.cannot_find_prog_unit_error
961 (p_module_name => 'UPDATE_COST_ALLOCATION'
962 ,p_hook_type => 'BP'
963 );
964 end;
965 --
966 -- Need to return existing ccid and business_group_id for
967 -- the row being updated.
968 --
969 open csr_old_ccid;
970 fetch csr_old_ccid into l_cost_allocation_keyflex_id, l_business_group_id;
971 if csr_old_ccid%notfound then
972 close csr_old_ccid;
973 --
974 -- The primary key is invalid
975 --
976 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
977 fnd_message.raise_error;
978 end if;
979 close csr_old_ccid;
980 --
981 -- Need to set CLIENT_INFO as HR_LOOKUPS may be referenced
982 -- by SEGMENT Value Sets.
983 --
984 hr_api.validate_bus_grp_id(l_business_group_id);
985 --
986 open csr_cost_structure(l_business_group_id);
987 fetch csr_cost_structure into l_flex_num;
988 if csr_cost_structure%notfound then
989 close csr_cost_structure;
990 --
991 -- the flex structure has not been found
992 --
993 fnd_message.set_name('PAY', 'HR_7471_FLEX_PEA_INVALID_ID');
994 fnd_message.raise_error;
995 end if;
996 close csr_cost_structure;
997 --
998 /* bug no. 3829293. call hr_entry.maintain_cost_flexfield
999 -- instead of above procedure
1000 --
1001 -- Determine the cost allocation definition by calling upd_or_sel
1002 --
1003 hr_kflex_utility.upd_or_sel_keyflex_comb
1004 (p_appl_short_name => 'PAY'
1005 ,p_flex_code => 'COST'
1006 ,p_flex_num => l_flex_num
1007 ,p_ccid => l_cost_allocation_keyflex_id
1008 ,p_segment1 => p_segment1
1009 ,p_segment2 => p_segment2
1010 ,p_segment3 => p_segment3
1011 ,p_segment4 => p_segment4
1012 ,p_segment5 => p_segment5
1013 ,p_segment6 => p_segment6
1014 ,p_segment7 => p_segment7
1015 ,p_segment8 => p_segment8
1016 ,p_segment9 => p_segment9
1017 ,p_segment10 => p_segment10
1018 ,p_segment11 => p_segment11
1019 ,p_segment12 => p_segment12
1020 ,p_segment13 => p_segment13
1021 ,p_segment14 => p_segment14
1022 ,p_segment15 => p_segment15
1023 ,p_segment16 => p_segment16
1024 ,p_segment17 => p_segment17
1025 ,p_segment18 => p_segment18
1026 ,p_segment19 => p_segment19
1027 ,p_segment20 => p_segment20
1028 ,p_segment21 => p_segment21
1029 ,p_segment22 => p_segment22
1030 ,p_segment23 => p_segment23
1031 ,p_segment24 => p_segment24
1032 ,p_segment25 => p_segment25
1033 ,p_segment26 => p_segment26
1034 ,p_segment27 => p_segment27
1035 ,p_segment28 => p_segment28
1036 ,p_segment29 => p_segment29
1037 ,p_segment30 => p_segment30
1038 ,p_concat_segments_in => p_concat_segments
1039 ,p_concat_segments_out => l_combination_name
1040 );
1041 --
1042 -- Set CONCATENATED_SEGMENTS column in pay_cost_allocation_keyflex
1043 -- bug 2620309
1044 --
1045 -- The update of the concatenated_segments column is executed
1046 -- in a separate procedure. (Bug #3177656)
1047 --
1048 update_cak_concat_segs
1049 (p_cost_allocation_keyflex_id => l_cost_allocation_keyflex_id
1050 ,p_concatenated_segments => l_combination_name
1051 );
1052 */
1053 -- Validate the key flex field only if any one of the segment or the
1054 -- concatenated segment is not hr_api.g_varchar2.
1055
1056 if (l_validate_flex or (p_concat_segments <> hr_api.g_varchar2)) then
1057
1058 -- check mandatory segment
1059 check_mandatory_segments(
1060 p_level =>'ASSIGNMENT',
1061 p_cost_id_flex_num =>l_flex_num,
1062 p_segment =>l_new_segment,
1063 p_cost_allocation_keyflex_id => p_cost_allocation_keyflex_id);
1064
1065 -- if concatenated segment has default value then assign it null
1066 --
1067 if p_concat_segments = hr_api.g_varchar2 then
1068 l_concat_segments := null;
1069 else
1070 l_concat_segments := p_concat_segments;
1071 end if;
1072 --
1073
1074 l_cost_allocation_keyflex_id := -1;
1075 hr_utility.set_location('Entering Update API', 10);
1076 hr_utility.set_location('p_cost_allocation_keyflex_id:'|| p_cost_allocation_keyflex_id, 10);
1077 hr_utility.set_location('l_cost_allocation_keyflex_id:'|| l_cost_allocation_keyflex_id, 10);
1078 hr_utility.set_location('l_flex_num:'|| l_flex_num, 10);
1079 hr_utility.set_location('l_concat_segments:'|| l_concat_segments, 10);
1080
1081
1082 l_cost_allocation_keyflex_id :=
1083 hr_entry.maintain_cost_keyflex(
1084 p_cost_keyflex_structure => l_flex_num,
1085 p_cost_allocation_keyflex_id => nvl(p_cost_allocation_keyflex_id,l_cost_allocation_keyflex_id),
1086 p_concatenated_segments => l_concat_segments,
1087 p_summary_flag =>'N',
1088 p_start_date_active => NULL,
1089 p_end_date_active => NULL,
1090 p_segment1 =>l_new_segment(1),
1091 p_segment2 =>l_new_segment(2),
1092 p_segment3 =>l_new_segment(3),
1093 p_segment4 =>l_new_segment(4),
1094 p_segment5 =>l_new_segment(5),
1095 p_segment6 =>l_new_segment(6),
1096 p_segment7 =>l_new_segment(7),
1097 p_segment8 =>l_new_segment(8),
1098 p_segment9 =>l_new_segment(9),
1099 p_segment10 =>l_new_segment(10),
1100 p_segment11 =>l_new_segment(11),
1101 p_segment12 =>l_new_segment(12),
1102 p_segment13 =>l_new_segment(13),
1103 p_segment14 =>l_new_segment(14),
1104 p_segment15 =>l_new_segment(15),
1105 p_segment16 =>l_new_segment(16),
1106 p_segment17 =>l_new_segment(17),
1107 p_segment18 =>l_new_segment(18),
1108 p_segment19 =>l_new_segment(19),
1109 p_segment20 =>l_new_segment(20),
1110 p_segment21 =>l_new_segment(21),
1111 p_segment22 =>l_new_segment(22),
1112 p_segment23 =>l_new_segment(23),
1113 p_segment24 =>l_new_segment(24),
1114 p_segment25 =>l_new_segment(25),
1115 p_segment26 =>l_new_segment(26),
1116 p_segment27 =>l_new_segment(27),
1117 p_segment28 =>l_new_segment(28),
1118 p_segment29 =>l_new_segment(29),
1119 p_segment30 =>l_new_segment(30));
1120 end if;
1121 --
1122 -- end of bug no. 3829293
1123 --
1124 --
1125 hr_utility.set_location('Entering Update API', 20);
1126 hr_utility.set_location('l_cost_allocation_keyflex_id:'|| l_cost_allocation_keyflex_id, 20);
1127 -- Process Logic
1128 --
1129 pay_cal_upd.upd
1130 (p_effective_date => l_effective_date
1131 ,p_datetrack_mode => p_datetrack_update_mode
1132 ,p_cost_allocation_id => p_cost_allocation_id
1133 ,p_object_version_number => l_object_version_number
1134 ,p_cost_allocation_keyflex_id => l_cost_allocation_keyflex_id
1135 ,p_proportion => p_proportion
1136 ,p_request_id => p_request_id
1137 ,p_program_application_id => p_program_application_id
1138 ,p_program_id => p_program_id
1139 ,p_program_update_date => p_program_update_date
1140 ,p_effective_start_date => l_effective_start_date
1141 ,p_effective_end_date => l_effective_end_date
1142 );
1143 --
1144 -- Call After Process User Hook
1145 --
1146 begin
1147 PAY_COST_ALLOCATION_BK2.update_cost_allocation_a
1148 (p_effective_date => l_effective_date
1149 ,p_datetrack_update_mode => p_datetrack_update_mode
1150 ,p_cost_allocation_id => p_cost_allocation_id
1151 ,p_object_version_number => l_object_version_number
1152 ,p_proportion => p_proportion
1153 ,p_segment1 => p_segment1
1154 ,p_segment2 => p_segment2
1155 ,p_segment3 => p_segment3
1156 ,p_segment4 => p_segment4
1157 ,p_segment5 => p_segment5
1158 ,p_segment6 => p_segment6
1159 ,p_segment7 => p_segment7
1160 ,p_segment8 => p_segment8
1161 ,p_segment9 => p_segment9
1162 ,p_segment10 => p_segment10
1163 ,p_segment11 => p_segment11
1164 ,p_segment12 => p_segment12
1165 ,p_segment13 => p_segment13
1166 ,p_segment14 => p_segment14
1167 ,p_segment15 => p_segment15
1168 ,p_segment16 => p_segment16
1169 ,p_segment17 => p_segment17
1170 ,p_segment18 => p_segment18
1171 ,p_segment19 => p_segment19
1172 ,p_segment20 => p_segment20
1173 ,p_segment21 => p_segment21
1174 ,p_segment22 => p_segment22
1175 ,p_segment23 => p_segment23
1176 ,p_segment24 => p_segment24
1177 ,p_segment25 => p_segment25
1178 ,p_segment26 => p_segment26
1179 ,p_segment27 => p_segment27
1180 ,p_segment28 => p_segment28
1181 ,p_segment29 => p_segment29
1182 ,p_segment30 => p_segment30
1183 ,p_concat_segments => p_concat_segments
1184 ,p_request_id => p_request_id
1185 ,p_program_application_id => p_program_application_id
1186 ,p_program_id => p_program_id
1187 ,p_program_update_date => p_program_update_date
1188 ,p_combination_name => l_combination_name
1189 ,p_effective_start_date => l_effective_start_date
1190 ,p_effective_end_date => l_effective_end_date
1191 ,p_cost_allocation_keyflex_id => l_cost_allocation_keyflex_id
1192 );
1193 exception
1194 when hr_api.cannot_find_prog_unit then
1195 hr_api.cannot_find_prog_unit_error
1196 (p_module_name => 'UPDATE_COST_ALLOCATION'
1197 ,p_hook_type => 'AP'
1198 );
1199 end;
1200 --
1201 -- When in validation only mode raise the Validate_Enabled exception
1202 --
1203 if p_validate then
1204 raise hr_api.validate_enabled;
1205 end if;
1206 --
1207 -- Set all output arguments
1208 --
1209 p_combination_name := l_combination_name;
1210 p_effective_start_date := l_effective_start_date;
1211 p_effective_end_date := l_effective_end_date;
1212 p_cost_allocation_keyflex_id := l_cost_allocation_keyflex_id;
1213 p_object_version_number := l_object_version_number;
1214 --
1215 hr_utility.set_location(' Leaving:'||l_proc, 70);
1216 exception
1217 when hr_api.validate_enabled then
1218 --
1219 -- As the Validate_Enabled exception has been raised
1220 -- we must rollback to the savepoint
1221 --
1222 rollback to UPDATE_COST_ALLOCATION;
1223 --
1224 -- Only set output warning arguments
1225 -- (Any key or derived arguments must be set to null
1226 -- when validation only mode is being used.)
1227 --
1228 p_combination_name := null;
1229 p_effective_start_date := null;
1230 p_effective_end_date := null;
1231 p_cost_allocation_keyflex_id := null;
1232 p_object_version_number := p_object_version_number;
1233 hr_utility.set_location(' Leaving:'||l_proc, 80);
1234 when others then
1235 --
1236 -- A validation or unexpected error has occured
1237 --
1238 rollback to UPDATE_COST_ALLOCATION;
1239 --
1240 -- Reset IN OUT params and set OUT params.
1241 --
1242 p_combination_name := null;
1243 p_effective_start_date := null;
1244 p_effective_end_date := null;
1245 p_cost_allocation_keyflex_id := null;
1246 p_object_version_number := l_object_version_number;
1247 --
1248 hr_utility.set_location(' Leaving:'||l_proc, 90);
1249 raise;
1250 end UPDATE_COST_ALLOCATION;
1251 --
1252 -- ----------------------------------------------------------------------------
1253 -- |------------------------< DELETE_COST_ALLOCATION >------------------------|
1254 -- ----------------------------------------------------------------------------
1255 --
1256 procedure DELETE_COST_ALLOCATION
1257 (p_validate in boolean default false
1258 ,p_effective_date in date
1259 ,p_datetrack_delete_mode in varchar2
1260 ,p_cost_allocation_id in number
1261 ,p_object_version_number in out nocopy number
1262 ,p_effective_start_date out nocopy date
1263 ,p_effective_end_date out nocopy date
1264 ) is
1265 --
1266 -- Declare cursors and local variables
1267 --
1268 l_proc varchar2(72) := g_package||'DELETE_COST_ALLOCATION';
1269 l_effective_date date;
1270 l_object_version_number pay_cost_allocations_f.object_version_number%TYPE;
1271 l_effective_start_date pay_cost_allocations_f.effective_start_date%TYPE;
1272 l_effective_end_date pay_cost_allocations_f.effective_end_date%TYPE;
1273 --
1274 begin
1275 hr_utility.set_location('Entering:'|| l_proc, 10);
1276 --
1277 -- Issue a savepoint
1278 --
1279 savepoint DELETE_COST_ALLOCATION;
1280 --
1281 -- Truncate the time portion from all IN date parameters
1282 --
1283 l_effective_date := trunc(p_effective_date);
1284 --
1285 -- Initialise all IN/OUT parameters
1286 --
1287 l_object_version_number := p_object_version_number;
1288 --
1289 -- Call Before Process User Hook
1290 --
1291 begin
1292 PAY_COST_ALLOCATION_BK3.delete_cost_allocation_b
1293 (p_effective_date => l_effective_date
1294 ,p_datetrack_delete_mode => p_datetrack_delete_mode
1295 ,p_cost_allocation_id => p_cost_allocation_id
1296 ,p_object_version_number => l_object_version_number
1297 );
1298 exception
1299 when hr_api.cannot_find_prog_unit then
1300 hr_api.cannot_find_prog_unit_error
1301 (p_module_name => 'DELETE_COST_ALLOCATION'
1302 ,p_hook_type => 'BP'
1303 );
1304 end;
1305 --
1306 -- Process Logic
1307 --
1308 pay_cal_del.del
1309 (p_effective_date => l_effective_date
1310 ,p_datetrack_mode => p_datetrack_delete_mode
1311 ,p_cost_allocation_id => p_cost_allocation_id
1312 ,p_object_version_number => l_object_version_number
1313 ,p_effective_start_date => l_effective_start_date
1314 ,p_effective_end_date => l_effective_end_date
1315 );
1316 --
1317 -- Call After Process User Hook
1318 --
1319 begin
1320 PAY_COST_ALLOCATION_BK3.delete_cost_allocation_a
1321 (p_effective_date => l_effective_date
1322 ,p_datetrack_delete_mode => p_datetrack_delete_mode
1323 ,p_cost_allocation_id => p_cost_allocation_id
1324 ,p_object_version_number => l_object_version_number
1325 ,p_effective_start_date => l_effective_start_date
1326 ,p_effective_end_date => l_effective_end_date
1327 );
1328 exception
1329 when hr_api.cannot_find_prog_unit then
1330 hr_api.cannot_find_prog_unit_error
1331 (p_module_name => 'DELETE_COST_ALLOCATION'
1332 ,p_hook_type => 'AP'
1333 );
1334 end;
1335 --
1336 -- When in validation only mode raise the Validate_Enabled exception
1337 --
1338 if p_validate then
1339 raise hr_api.validate_enabled;
1340 end if;
1341 --
1342 -- Set all output arguments
1343 --
1344 p_effective_start_date := l_effective_start_date;
1345 p_effective_end_date := l_effective_end_date;
1346 p_object_version_number := l_object_version_number;
1347 --
1348 hr_utility.set_location(' Leaving:'||l_proc, 70);
1349 exception
1350 when hr_api.validate_enabled then
1351 --
1352 -- As the Validate_Enabled exception has been raised
1353 -- we must rollback to the savepoint
1354 --
1355 rollback to DELETE_COST_ALLOCATION;
1356 --
1357 -- Only set output warning arguments
1358 -- (Any key or derived arguments must be set to null
1359 -- when validation only mode is being used.)
1360 --
1361 p_effective_start_date := null;
1362 p_effective_end_date := null;
1363 p_object_version_number := p_object_version_number;
1364 hr_utility.set_location(' Leaving:'||l_proc, 80);
1365 when others then
1366 --
1367 -- A validation or unexpected error has occured
1368 --
1369 rollback to DELETE_COST_ALLOCATION;
1370 --
1371 -- Reset IN OUT params and set OUT params.
1372 --
1373 p_effective_start_date := null;
1374 p_effective_end_date := null;
1375 p_object_version_number := l_object_version_number;
1376 --
1377 hr_utility.set_location(' Leaving:'||l_proc, 90);
1378 raise;
1379 end DELETE_COST_ALLOCATION;
1380 --
1381 end PAY_COST_ALLOCATION_API;