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