1 Package Body pay_liv_ins as
2 /* $Header: pylivrhi.pkb 120.1 2005/07/12 05:24:42 alogue noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_liv_ins.'; -- Global package name
9 --
10 -- The following global variables are only to be used by
11 -- the set_base_key_value and pre_insert procedures.
12 --
13 g_link_input_value_id_i number default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19 (p_link_input_value_id in number) is
20 --
21 l_proc varchar2(72) := g_package||'set_base_key_value';
22 --
23 Begin
24 hr_utility.set_location('Entering:'||l_proc, 10);
25 --
26 pay_liv_ins.g_link_input_value_id_i := p_link_input_value_id;
27 --
28 hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 --
32 -- ----------------------------------------------------------------------------
33 -- |----------------------------< dt_insert_dml >-----------------------------|
34 -- ----------------------------------------------------------------------------
35 -- {Start Of Comments}
36 --
37 -- Description:
38 -- This procedure controls the actual dml insert logic for datetrack. The
39 -- functions of this procedure are as follows:
40 -- 1) Get the object_version_number.
41 -- 2) To set the effective start and end dates to the corresponding
42 -- validation start and end dates. Also, the object version number
43 -- record attribute is set.
44 -- 3) To set and unset the g_api_dml status as required (as we are about to
45 -- perform dml).
46 -- 4) To insert the row into the schema with the derived effective start
47 -- and end dates and the object version number.
48 -- 5) To trap any constraint violations that may have occurred.
49 -- 6) To raise any other errors.
50 --
51 -- Prerequisites:
52 -- This is an internal private procedure which must be called from the
53 -- insert_dml and pre_update (logic permitting) procedure and must have
54 -- all mandatory arguments set.
55 --
56 -- In Parameters:
57 -- A Pl/Sql record structure.
58 --
59 -- Post Success:
60 -- The specified row will be inserted into the schema.
61 --
62 -- Post Failure:
63 -- On the insert dml failure it is important to note that we always reset the
64 -- g_api_dml status to false.
65 -- If a check or unique integrity constraint violation is raised the
66 -- constraint_error procedure will be called.
67 -- If any other error is reported, the error will be raised after the
68 -- g_api_dml status is reset.
69 --
70 -- Developer Implementation Notes:
71 -- This is an internal datetrack maintenance procedure which should
72 -- not be modified in anyway.
73 --
74 -- Access Status:
75 -- Internal Row Handler Use Only.
76 --
77 -- {End Of Comments}
78 -- ----------------------------------------------------------------------------
79 Procedure dt_insert_dml
80 (p_rec in out nocopy pay_liv_shd.g_rec_type
81 ,p_effective_date in date
82 ,p_datetrack_mode in varchar2
83 ,p_validation_start_date in date
84 ,p_validation_end_date in date
85 ) is
86 -- Cursor to select 'old' created AOL who column values
87 --
88 Cursor C_Sel1 Is
89 select t.created_by,
90 t.creation_date
91 from pay_link_input_values_f t
92 where t.link_input_value_id = p_rec.link_input_value_id
93 and t.effective_start_date =
94 pay_liv_shd.g_old_rec.effective_start_date
95 and t.effective_end_date = (p_validation_start_date - 1);
96 --
97 l_proc varchar2(72) := g_package||'dt_insert_dml';
98 l_created_by pay_link_input_values_f.created_by%TYPE;
99 l_creation_date pay_link_input_values_f.creation_date%TYPE;
100 l_last_update_date pay_link_input_values_f.last_update_date%TYPE;
101 l_last_updated_by pay_link_input_values_f.last_updated_by%TYPE;
102 l_last_update_login pay_link_input_values_f.last_update_login%TYPE;
103 --
104 Begin
105 hr_utility.set_location('Entering:'||l_proc, 5);
106 --
107 -- Get the object version number for the insert
108 --
109 p_rec.object_version_number :=
110 dt_api.get_object_version_number
111 (p_base_table_name => 'pay_link_input_values_f'
112 ,p_base_key_column => 'link_input_value_id'
113 ,p_base_key_value => p_rec.link_input_value_id
114 );
115 --
116 -- Set the effective start and end dates to the corresponding
117 -- validation start and end dates
118 --
119 p_rec.effective_start_date := p_validation_start_date;
120 p_rec.effective_end_date := p_validation_end_date;
121 --
122 -- If the datetrack_mode is not INSERT then we must populate the WHO
123 -- columns with the 'old' creation values and 'new' updated values.
124 --
125 If (p_datetrack_mode <> hr_api.g_insert) then
126 hr_utility.set_location(l_proc, 10);
127 --
128 -- Select the 'old' created values
129 --
130 Open C_Sel1;
131 Fetch C_Sel1 Into l_created_by, l_creation_date;
132 If C_Sel1%notfound Then
133 --
134 -- The previous 'old' created row has not been found. We need
135 -- to error as an internal datetrack problem exists.
136 --
137 Close C_Sel1;
138 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
139 fnd_message.set_token('PROCEDURE', l_proc);
140 fnd_message.set_token('STEP','10');
141 fnd_message.raise_error;
142 End If;
143 Close C_Sel1;
144 --
145 -- Set the AOL updated WHO values
146 --
147 l_last_update_date := sysdate;
148 l_last_updated_by := fnd_global.user_id;
149 l_last_update_login := fnd_global.login_id;
150 End If;
151 --
152 pay_liv_shd.g_api_dml := true; -- Set the api dml status
153 --
154 -- Insert the row into: pay_link_input_values_f
155 --
156 insert into pay_link_input_values_f
157 (link_input_value_id
158 ,effective_start_date
159 ,effective_end_date
160 ,element_link_id
161 ,input_value_id
162 ,costed_flag
163 ,default_value
164 ,max_value
165 ,min_value
166 ,warning_or_error
167 ,object_version_number
168 ,created_by
169 ,creation_date
170 ,last_update_date
171 ,last_updated_by
172 ,last_update_login
173 )
174 Values
175 (p_rec.link_input_value_id
176 ,p_rec.effective_start_date
177 ,p_rec.effective_end_date
178 ,p_rec.element_link_id
179 ,p_rec.input_value_id
180 ,p_rec.costed_flag
181 ,p_rec.default_value
182 ,p_rec.max_value
183 ,p_rec.min_value
184 ,p_rec.warning_or_error
185 ,p_rec.object_version_number
186 ,l_created_by
187 ,l_creation_date
188 ,l_last_update_date
189 ,l_last_updated_by
190 ,l_last_update_login
191 );
192 --
193 pay_liv_shd.g_api_dml := false; -- Unset the api dml status
194 hr_utility.set_location(' Leaving:'||l_proc, 15);
195 --
196 Exception
197 When hr_api.check_integrity_violated Then
198 -- A check constraint has been violated
199 pay_liv_shd.g_api_dml := false; -- Unset the api dml status
200 pay_liv_shd.constraint_error
201 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
202 When hr_api.unique_integrity_violated Then
203 -- Unique integrity has been violated
204 pay_liv_shd.g_api_dml := false; -- Unset the api dml status
205 pay_liv_shd.constraint_error
206 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
207 When Others Then
208 pay_liv_shd.g_api_dml := false; -- Unset the api dml status
209 Raise;
210 End dt_insert_dml;
211 --
212 -- ----------------------------------------------------------------------------
213 -- |------------------------------< insert_dml >------------------------------|
214 -- ----------------------------------------------------------------------------
215 Procedure insert_dml
216 (p_rec in out nocopy pay_liv_shd.g_rec_type
217 ,p_effective_date in date
218 ,p_datetrack_mode in varchar2
219 ,p_validation_start_date in date
220 ,p_validation_end_date in date
221 ) is
222 --
223 l_proc varchar2(72) := g_package||'insert_dml';
224 --
225 Begin
226 hr_utility.set_location('Entering:'||l_proc, 5);
227 --
228 pay_liv_ins.dt_insert_dml
229 (p_rec => p_rec
230 ,p_effective_date => p_effective_date
231 ,p_datetrack_mode => p_datetrack_mode
232 ,p_validation_start_date => p_validation_start_date
233 ,p_validation_end_date => p_validation_end_date
234 );
235 --
236 hr_utility.set_location(' Leaving:'||l_proc, 10);
237 End insert_dml;
238 --
239 -- ----------------------------------------------------------------------------
240 -- |------------------------------< pre_insert >------------------------------|
241 -- ----------------------------------------------------------------------------
242 -- {Start Of Comments}
243 --
244 -- Description:
245 -- This private procedure contains any processing which is required before
246 -- the insert dml. Presently, if the entity has a corresponding primary
247 -- key which is maintained by an associating sequence, the primary key for
248 -- the entity will be populated with the next sequence value in
249 -- preparation for the insert dml.
250 -- Also, if comments are defined for this entity, the comments insert
251 -- logic will also be called, generating a comment_id if required.
252 --
253 -- Prerequisites:
254 -- This is an internal procedure which is called from the ins procedure.
255 --
256 -- In Parameters:
257 -- A Pl/Sql record structure.
258 --
259 -- Post Success:
260 -- Processing continues.
261 --
262 -- Post Failure:
263 -- If an error has occurred, an error message and exception will be raised
264 -- but not handled.
265 --
266 -- Developer Implementation Notes:
267 -- Any pre-processing required before the insert dml is issued should be
268 -- coded within this procedure. As stated above, a good example is the
269 -- generation of a primary key number via a corresponding sequence.
270 -- It is important to note that any 3rd party maintenance should be reviewed
271 -- before placing in this procedure.
272 --
273 -- Access Status:
274 -- Internal Row Handler Use Only.
275 --
276 -- {End Of Comments}
277 -- ----------------------------------------------------------------------------
278 Procedure pre_insert
279 (p_rec in out nocopy pay_liv_shd.g_rec_type
280 ,p_effective_date in date
281 ,p_datetrack_mode in varchar2
282 ,p_validation_start_date in date
283 ,p_validation_end_date in date
284 ) is
285 --
286 Cursor C_Sel1 is select pay_link_input_values_s.nextval from sys.dual;
287 --
288 Cursor C_Sel2 is
289 Select null
290 from pay_link_input_values_f
291 where link_input_value_id =
292 pay_liv_ins.g_link_input_value_id_i;
293 --
294 l_proc varchar2(72) := g_package||'pre_insert';
295 l_exists varchar2(1);
296 --
297 Begin
298 hr_utility.set_location('Entering:'||l_proc, 5);
299 --
300 If (pay_liv_ins.g_link_input_value_id_i is not null) Then
301 --
302 -- Verify registered primary key values not already in use
303 --
304 Open C_Sel2;
305 Fetch C_Sel2 into l_exists;
306 If C_Sel2%found Then
307 Close C_Sel2;
308 --
309 -- The primary key values are already in use.
310 --
311 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
312 fnd_message.set_token('TABLE_NAME','pay_link_input_values_f');
313 fnd_message.raise_error;
314 End If;
315 Close C_Sel2;
316 --
317 -- Use registered key values and clear globals
318 --
319 p_rec.link_input_value_id :=
320 pay_liv_ins.g_link_input_value_id_i;
321 pay_liv_ins.g_link_input_value_id_i := null;
322 Else
323 --
324 -- No registerd key values, so select the next sequence number
325 --
326 --
327 -- Select the next sequence number
328 --
329 Open C_Sel1;
330 Fetch C_Sel1 Into p_rec.link_input_value_id;
331 Close C_Sel1;
332 End If;
333 --
334 --
335 hr_utility.set_location(' Leaving:'||l_proc, 10);
336 End pre_insert;
337 --
338 -- ----------------------------------------------------------------------------
339 -- |----------------------------< post_insert >-------------------------------|
340 -- ----------------------------------------------------------------------------
341 -- {Start Of Comments}
342 --
343 -- Description:
344 -- This private procedure contains any processing which is required after
345 -- the insert dml.
346 --
347 -- Prerequisites:
348 -- This is an internal procedure which is called from the ins procedure.
349 --
350 -- In Parameters:
351 -- A Pl/Sql record structure.
352 --
353 -- Post Success:
354 -- Processing continues.
355 --
356 -- Post Failure:
357 -- If an error has occurred, an error message and exception will be raised
358 -- but not handled.
359 --
360 -- Developer Implementation Notes:
361 -- Any post-processing required after the insert dml is issued should be
362 -- coded within this procedure. It is important to note that any 3rd party
363 -- maintenance should be reviewed before placing in this procedure.
364 --
365 -- Access Status:
366 -- Internal Row Handler Use Only.
367 --
368 -- {End Of Comments}
369 -- ----------------------------------------------------------------------------
370 Procedure post_insert
371 (p_rec in pay_liv_shd.g_rec_type
372 ,p_effective_date in date
373 ,p_datetrack_mode in varchar2
374 ,p_validation_start_date in date
375 ,p_validation_end_date in date
376 ) is
377 --
378 l_proc varchar2(72) := g_package||'post_insert';
379 --
380 Begin
381 hr_utility.set_location('Entering:'||l_proc, 5);
382 begin
383 --
384 pay_liv_rki.after_insert
385 (p_effective_date
386 => p_effective_date
387 ,p_validation_start_date
388 => p_validation_start_date
389 ,p_validation_end_date
390 => p_validation_end_date
391 ,p_link_input_value_id
392 => p_rec.link_input_value_id
393 ,p_effective_start_date
394 => p_rec.effective_start_date
395 ,p_effective_end_date
396 => p_rec.effective_end_date
397 ,p_element_link_id
398 => p_rec.element_link_id
399 ,p_input_value_id
400 => p_rec.input_value_id
401 ,p_costed_flag
402 => p_rec.costed_flag
403 ,p_default_value
404 => p_rec.default_value
405 ,p_max_value
406 => p_rec.max_value
407 ,p_min_value
408 => p_rec.min_value
409 ,p_warning_or_error
410 => p_rec.warning_or_error
411 ,p_object_version_number
412 => p_rec.object_version_number
413 );
414 --
415 exception
416 --
417 when hr_api.cannot_find_prog_unit then
418 --
419 hr_api.cannot_find_prog_unit_error
420 (p_module_name => 'PAY_LINK_INPUT_VALUES_F'
421 ,p_hook_type => 'AI');
422 --
423 end;
424 --
425 hr_utility.set_location(' Leaving:'||l_proc, 10);
426 End post_insert;
427 --
428 -- ----------------------------------------------------------------------------
429 -- |-------------------------------< ins_lck >--------------------------------|
430 -- ----------------------------------------------------------------------------
431 -- {Start Of Comments}
432 --
433 -- Description:
434 -- The ins_lck process has one main function to perform. When inserting
435 -- a datetracked row, we must validate the DT mode.
436 --
437 -- Prerequisites:
438 -- This procedure can only be called for the datetrack mode of INSERT.
439 --
440 -- In Parameters:
441 --
442 -- Post Success:
443 -- On successful completion of the ins_lck process the parental
444 -- datetracked rows will be locked providing the p_enforce_foreign_locking
445 -- argument value is TRUE.
446 -- If the p_enforce_foreign_locking argument value is FALSE then the
447 -- parential rows are not locked.
448 --
449 -- Post Failure:
450 -- The Lck process can fail for:
451 -- 1) When attempting to lock the row the row could already be locked by
452 -- another user. This will raise the HR_Api.Object_Locked exception.
453 -- 2) When attempting to the lock the parent which doesn't exist.
454 -- For the entity to be locked the parent must exist!
455 --
456 -- Developer Implementation Notes:
457 -- None.
458 --
459 -- Access Status:
460 -- Internal Row Handler Use Only.
461 --
462 -- {End Of Comments}
463 -- ----------------------------------------------------------------------------
464 Procedure ins_lck
465 (p_effective_date in date
466 ,p_datetrack_mode in varchar2
467 ,p_rec in pay_liv_shd.g_rec_type
468 ,p_validation_start_date out nocopy date
469 ,p_validation_end_date out nocopy date
470 ) is
471 --
472 l_proc varchar2(72) := g_package||'ins_lck';
473 l_validation_start_date date;
474 l_validation_end_date date;
475 --
476 Begin
477 hr_utility.set_location('Entering:'||l_proc, 5);
478 --
479 -- Validate the datetrack mode mode getting the validation start
480 -- and end dates for the specified datetrack operation.
481 --
482 dt_api.validate_dt_mode
483 (p_effective_date => p_effective_date
484 ,p_datetrack_mode => p_datetrack_mode
485 ,p_base_table_name => 'pay_link_input_values_f'
486 ,p_base_key_column => 'link_input_value_id'
487 ,p_base_key_value => p_rec.link_input_value_id
488 ,p_parent_table_name1 => 'pay_input_values_f'
489 ,p_parent_key_column1 => 'input_value_id'
490 ,p_parent_key_value1 => p_rec.input_value_id
491 ,p_parent_table_name2 => 'pay_element_links_f'
492 ,p_parent_key_column2 => 'element_link_id'
493 ,p_parent_key_value2 => p_rec.element_link_id
494 ,p_enforce_foreign_locking => true
495 ,p_validation_start_date => l_validation_start_date
496 ,p_validation_end_date => l_validation_end_date
497 );
498 --
499 -- Set the validation start and end date OUT arguments
500 --
501 p_validation_start_date := l_validation_start_date;
502 p_validation_end_date := l_validation_end_date;
503 --
504 hr_utility.set_location(' Leaving:'||l_proc, 10);
505 --
506 End ins_lck;
507 --
508 -- ----------------------------------------------------------------------------
509 -- |---------------------------------< ins >----------------------------------|
510 -- ----------------------------------------------------------------------------
511 Procedure ins
512 (p_effective_date in date
513 ,p_rec in out nocopy pay_liv_shd.g_rec_type
514 ) is
515 --
516 l_proc varchar2(72) := g_package||'ins';
517 l_datetrack_mode varchar2(30) := hr_api.g_insert;
518 l_validation_start_date date;
519 l_validation_end_date date;
520 --
521 Begin
522 hr_utility.set_location('Entering:'||l_proc, 5);
523 --
524 -- Call the lock operation
525 --
526 pay_liv_ins.ins_lck
527 (p_effective_date => p_effective_date
528 ,p_datetrack_mode => l_datetrack_mode
529 ,p_rec => p_rec
530 ,p_validation_start_date => l_validation_start_date
531 ,p_validation_end_date => l_validation_end_date
532 );
533 --
534 -- Call the supporting insert validate operations
535 --
536 pay_liv_bus.insert_validate
537 (p_rec => p_rec
538 ,p_effective_date => p_effective_date
539 ,p_datetrack_mode => l_datetrack_mode
540 ,p_validation_start_date => l_validation_start_date
541 ,p_validation_end_date => l_validation_end_date
542 );
543
544 --
545 -- Call to raise any errors on multi-message list
546 hr_multi_message.end_validation_set;
547 --
548 -- Call the supporting pre-insert operation
549 --
550 pay_liv_ins.pre_insert
551 (p_rec => p_rec
552 ,p_effective_date => p_effective_date
553 ,p_datetrack_mode => l_datetrack_mode
554 ,p_validation_start_date => l_validation_start_date
555 ,p_validation_end_date => l_validation_end_date
556 );
557 --
558 -- Insert the row
559 --
560 pay_liv_ins.insert_dml
561 (p_rec => p_rec
562 ,p_effective_date => p_effective_date
563 ,p_datetrack_mode => l_datetrack_mode
564 ,p_validation_start_date => l_validation_start_date
565 ,p_validation_end_date => l_validation_end_date
566 );
567 --
568 -- Call the supporting post-insert operation
569 --
570 pay_liv_ins.post_insert
571 (p_rec => p_rec
572 ,p_effective_date => p_effective_date
573 ,p_datetrack_mode => l_datetrack_mode
574 ,p_validation_start_date => l_validation_start_date
575 ,p_validation_end_date => l_validation_end_date
576 );
577 --
578 -- Call to raise any errors on multi-message list
579 hr_multi_message.end_validation_set;
580 --
581 hr_utility.set_location('Leaving:'||l_proc,10);
582 end ins;
583 --
584 -- ----------------------------------------------------------------------------
585 -- |---------------------------------< ins >----------------------------------|
586 -- ----------------------------------------------------------------------------
587 Procedure ins
588 (p_effective_date in date
589 ,p_element_link_id in number
590 ,p_input_value_id in number
591 ,p_costed_flag in varchar2
592 ,p_default_value in varchar2
593 ,p_max_value in varchar2
594 ,p_min_value in varchar2
595 ,p_warning_or_error in varchar2
596 ,p_link_input_value_id out nocopy number
597 ,p_object_version_number out nocopy number
598 ,p_effective_start_date out nocopy date
599 ,p_effective_end_date out nocopy date
600 ) is
601 --
602 l_rec pay_liv_shd.g_rec_type;
603 l_proc varchar2(72) := g_package||'ins';
604 --
605 Begin
606 hr_utility.set_location('Entering:'||l_proc, 5);
607 --
608 -- Call conversion function to turn arguments into the
609 -- p_rec structure.
610 --
611 l_rec :=
612 pay_liv_shd.convert_args
613 (null
614 ,null
615 ,null
616 ,p_element_link_id
617 ,p_input_value_id
618 ,p_costed_flag
619 ,p_default_value
620 ,p_max_value
621 ,p_min_value
622 ,p_warning_or_error
623 ,null
624 );
625 --
626 -- Having converted the arguments into the pay_liv_rec
627 -- plsql record structure we call the corresponding record
628 -- business process.
629 --
630 pay_liv_ins.ins
631 (p_effective_date
632 ,l_rec
633 );
634 --
635 -- Set the OUT arguments.
636 --
637 p_link_input_value_id := l_rec.link_input_value_id;
638 p_effective_start_date := l_rec.effective_start_date;
639 p_effective_end_date := l_rec.effective_end_date;
640 p_object_version_number := l_rec.object_version_number;
641 --
642 --
643 hr_utility.set_location(' Leaving:'||l_proc, 10);
644 End ins;
645 --
646 end pay_liv_ins;