DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_LIP_INS

Source


1 Package Body hr_lip_ins as
2 /* $Header: hrliprhi.pkb 115.5 2002/12/04 05:07:14 hjonnala noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_lip_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 hr_lip_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   hr_de_liability_premiums_f t
70     where  t.liability_premiums_id       = p_rec.liability_premiums_id
71     and    t.effective_start_date =
72              hr_lip_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          hr_de_liability_premiums_f.created_by%TYPE;
77   l_creation_date       hr_de_liability_premiums_f.creation_date%TYPE;
78   l_last_update_date    hr_de_liability_premiums_f.last_update_date%TYPE;
79   l_last_updated_by     hr_de_liability_premiums_f.last_updated_by%TYPE;
80   l_last_update_login   hr_de_liability_premiums_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 => 'hr_de_liability_premiums_f'
90       ,p_base_key_column => 'liability_premiums_id'
91       ,p_base_key_value  => p_rec.liability_premiums_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: hr_de_liability_premiums_f
133   --
134   insert into hr_de_liability_premiums_f
135       (liability_premiums_id
136       ,organization_link_id
137       ,effective_start_date
138       ,effective_end_date
139       ,std_percentage
140       ,calculation_method
141       ,std_working_hours_per_year
142       ,max_remuneration
143       ,attribute_category
144       ,attribute1
145       ,attribute2
146       ,attribute3
147       ,attribute4
148       ,attribute5
149       ,attribute6
150       ,attribute7
151       ,attribute8
152       ,attribute9
153       ,attribute10
154       ,attribute11
155       ,attribute12
156       ,attribute13
157       ,attribute14
158       ,attribute15
159       ,attribute16
160       ,attribute17
161       ,attribute18
162       ,attribute19
163       ,attribute20
164       ,object_version_number
165       ,created_by
166       ,creation_date
167       ,last_update_date
168       ,last_updated_by
169       ,last_update_login
170       )
171   Values
172     (p_rec.liability_premiums_id
173     ,p_rec.organization_link_id
174     ,p_rec.effective_start_date
175     ,p_rec.effective_end_date
176     ,p_rec.std_percentage
177     ,p_rec.calculation_method
178     ,p_rec.std_working_hours_per_year
179     ,p_rec.max_remuneration
180     ,p_rec.attribute_category
181     ,p_rec.attribute1
182     ,p_rec.attribute2
183     ,p_rec.attribute3
184     ,p_rec.attribute4
185     ,p_rec.attribute5
186     ,p_rec.attribute6
187     ,p_rec.attribute7
188     ,p_rec.attribute8
189     ,p_rec.attribute9
190     ,p_rec.attribute10
191     ,p_rec.attribute11
192     ,p_rec.attribute12
193     ,p_rec.attribute13
194     ,p_rec.attribute14
195     ,p_rec.attribute15
196     ,p_rec.attribute16
197     ,p_rec.attribute17
198     ,p_rec.attribute18
199     ,p_rec.attribute19
200     ,p_rec.attribute20
201     ,p_rec.object_version_number
202     ,l_created_by
203     ,l_creation_date
204     ,l_last_update_date
205     ,l_last_updated_by
206     ,l_last_update_login
207     );
208   --
209   --
210   hr_utility.set_location(' Leaving:'||l_proc, 15);
211 --
212 Exception
213   When hr_api.check_integrity_violated Then
214     -- A check constraint has been violated
215     --
216     hr_lip_shd.constraint_error
217       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
218   When hr_api.unique_integrity_violated Then
219     -- Unique integrity has been violated
220     --
221     hr_lip_shd.constraint_error
222       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
223   When Others Then
224     --
225     Raise;
226 End dt_insert_dml;
227 --
228 -- ----------------------------------------------------------------------------
229 -- |------------------------------< insert_dml >------------------------------|
230 -- ----------------------------------------------------------------------------
231 Procedure insert_dml
232   (p_rec                   in out nocopy hr_lip_shd.g_rec_type
233   ,p_effective_date        in date
234   ,p_datetrack_mode        in varchar2
235   ,p_validation_start_date in date
236   ,p_validation_end_date   in date
237   ) is
238 --
239   l_proc        varchar2(72) := g_package||'insert_dml';
240 --
241 Begin
242   hr_utility.set_location('Entering:'||l_proc, 5);
243   --
244   hr_lip_ins.dt_insert_dml
245     (p_rec                   => p_rec
246     ,p_effective_date        => p_effective_date
247     ,p_datetrack_mode        => p_datetrack_mode
248     ,p_validation_start_date => p_validation_start_date
249     ,p_validation_end_date   => p_validation_end_date
250     );
251   --
252   hr_utility.set_location(' Leaving:'||l_proc, 10);
253 End insert_dml;
254 --
255 -- ----------------------------------------------------------------------------
256 -- |------------------------------< pre_insert >------------------------------|
257 -- ----------------------------------------------------------------------------
258 -- {Start Of Comments}
259 --
260 -- Description:
261 --   This private procedure contains any processing which is required before
262 --   the insert dml. Presently, if the entity has a corresponding primary
263 --   key which is maintained by an associating sequence, the primary key for
264 --   the entity will be populated with the next sequence value in
265 --   preparation for the insert dml.
266 --   Also, if comments are defined for this entity, the comments insert
267 --   logic will also be called, generating a comment_id if required.
268 --
269 -- Prerequisites:
270 --   This is an internal procedure which is called from the ins procedure.
271 --
272 -- In Parameters:
273 --   A Pl/Sql record structure.
274 --
275 -- Post Success:
276 --   Processing continues.
277 --
278 -- Post Failure:
279 --   If an error has occurred, an error message and exception will be raised
280 --   but not handled.
281 --
282 -- Developer Implementation Notes:
283 --   Any pre-processing required before the insert dml is issued should be
284 --   coded within this procedure. As stated above, a good example is the
285 --   generation of a primary key number via a corresponding sequence.
286 --   It is important to note that any 3rd party maintenance should be reviewed
287 --   before placing in this procedure.
288 --
289 -- Access Status:
290 --   Internal Row Handler Use Only.
291 --
292 -- {End Of Comments}
293 -- ----------------------------------------------------------------------------
294 Procedure pre_insert
295   (p_rec                   in out nocopy hr_lip_shd.g_rec_type
296   ,p_effective_date        in date
297   ,p_datetrack_mode        in varchar2
298   ,p_validation_start_date in date
299   ,p_validation_end_date   in date
300   ) is
301 --
302   l_proc        varchar2(72) := g_package||'pre_insert';
303 --
304   Cursor C_Sel1 is select hr_de_liability_premiums_s.nextval from sys.dual;
305 --
306 Begin
307   hr_utility.set_location('Entering:'||l_proc, 5);
308   --
309   --
310   -- Select the next sequence number
311   --
312   Open C_Sel1;
313   Fetch C_Sel1 Into p_rec.liability_premiums_id;
314   Close C_Sel1;
315   --
316   --
317   hr_utility.set_location(' Leaving:'||l_proc, 10);
318 End pre_insert;
319 --
320 -- ----------------------------------------------------------------------------
321 -- |----------------------------< post_insert >-------------------------------|
322 -- ----------------------------------------------------------------------------
323 -- {Start Of Comments}
324 --
325 -- Description:
326 --   This private procedure contains any processing which is required after
327 --   the insert dml.
328 --
329 -- Prerequisites:
330 --   This is an internal procedure which is called from the ins procedure.
331 --
332 -- In Parameters:
333 --   A Pl/Sql record structure.
334 --
335 -- Post Success:
336 --   Processing continues.
337 --
338 -- Post Failure:
339 --   If an error has occurred, an error message and exception will be raised
340 --   but not handled.
341 --
342 -- Developer Implementation Notes:
343 --   Any post-processing required after the insert dml is issued should be
344 --   coded within this procedure. It is important to note that any 3rd party
345 --   maintenance should be reviewed before placing in this procedure.
346 --
347 -- Access Status:
348 --   Internal Row Handler Use Only.
349 --
350 -- {End Of Comments}
351 -- ----------------------------------------------------------------------------
352 Procedure post_insert
353   (p_rec                   in hr_lip_shd.g_rec_type
354   ,p_effective_date        in date
355   ,p_datetrack_mode        in varchar2
356   ,p_validation_start_date in date
357   ,p_validation_end_date   in date
358   ) is
359 --
360   l_proc        varchar2(72) := g_package||'post_insert';
361 --
362 Begin
363   hr_utility.set_location('Entering:'||l_proc, 5);
364   begin
365     --
366     hr_lip_rki.after_insert
367       (p_effective_date
368       => p_effective_date
369       ,p_validation_start_date
370       => p_validation_start_date
371       ,p_validation_end_date
372       => p_validation_end_date
373       ,p_liability_premiums_id
374       => p_rec.liability_premiums_id
375       ,p_organization_link_id
376       => p_rec.organization_link_id
377       ,p_effective_start_date
378       => p_rec.effective_start_date
379       ,p_effective_end_date
380       => p_rec.effective_end_date
381       ,p_std_percentage
382       => p_rec.std_percentage
383       ,p_calculation_method
384       => p_rec.calculation_method
385       ,p_std_working_hours_per_year
386       => p_rec.std_working_hours_per_year
387       ,p_max_remuneration
388       => p_rec.max_remuneration
389       ,p_attribute_category
390       => p_rec.attribute_category
391       ,p_attribute1
392       => p_rec.attribute1
393       ,p_attribute2
394       => p_rec.attribute2
395       ,p_attribute3
396       => p_rec.attribute3
397       ,p_attribute4
398       => p_rec.attribute4
399       ,p_attribute5
400       => p_rec.attribute5
401       ,p_attribute6
402       => p_rec.attribute6
403       ,p_attribute7
404       => p_rec.attribute7
405       ,p_attribute8
406       => p_rec.attribute8
407       ,p_attribute9
408       => p_rec.attribute9
409       ,p_attribute10
410       => p_rec.attribute10
411       ,p_attribute11
412       => p_rec.attribute11
413       ,p_attribute12
414       => p_rec.attribute12
415       ,p_attribute13
416       => p_rec.attribute13
417       ,p_attribute14
418       => p_rec.attribute14
419       ,p_attribute15
420       => p_rec.attribute15
421       ,p_attribute16
422       => p_rec.attribute16
423       ,p_attribute17
424       => p_rec.attribute17
425       ,p_attribute18
426       => p_rec.attribute18
427       ,p_attribute19
428       => p_rec.attribute19
429       ,p_attribute20
430       => p_rec.attribute20
431       ,p_object_version_number
432       => p_rec.object_version_number
433       );
434     --
435   exception
436     --
437     when hr_api.cannot_find_prog_unit then
438       --
439       hr_api.cannot_find_prog_unit_error
440         (p_module_name => 'HR_DE_LIABILITY_PREMIUMS_F'
441         ,p_hook_type   => 'AI');
442       --
443   end;
444   --
445   hr_utility.set_location(' Leaving:'||l_proc, 10);
446 End post_insert;
447 --
448 -- ----------------------------------------------------------------------------
449 -- |-------------------------------< ins_lck >--------------------------------|
450 -- ----------------------------------------------------------------------------
451 -- {Start Of Comments}
452 --
453 -- Description:
454 --   The ins_lck process has one main function to perform. When inserting
455 --   a datetracked row, we must validate the DT mode.
456 --
457 -- Prerequisites:
458 --   This procedure can only be called for the datetrack mode of INSERT.
459 --
460 -- In Parameters:
461 --
462 -- Post Success:
463 --   On successful completion of the ins_lck process the parental
464 --   datetracked rows will be locked providing the p_enforce_foreign_locking
465 --   argument value is TRUE.
466 --   If the p_enforce_foreign_locking argument value is FALSE then the
467 --   parential rows are not locked.
468 --
469 -- Post Failure:
470 --   The Lck process can fail for:
471 --   1) When attempting to lock the row the row could already be locked by
472 --      another user. This will raise the HR_Api.Object_Locked exception.
473 --   2) When attempting to the lock the parent which doesn't exist.
474 --      For the entity to be locked the parent must exist!
475 --
476 -- Developer Implementation Notes:
477 --   None.
478 --
479 -- Access Status:
480 --   Internal Row Handler Use Only.
481 --
482 -- {End Of Comments}
483 -- ----------------------------------------------------------------------------
484 Procedure ins_lck
485   (p_effective_date        in date
486   ,p_datetrack_mode        in varchar2
487   ,p_rec                   in hr_lip_shd.g_rec_type
488   ,p_validation_start_date out nocopy date
489   ,p_validation_end_date   out nocopy date
490   ) is
491 --
492   l_proc                  varchar2(72) := g_package||'ins_lck';
493   l_validation_start_date date;
494   l_validation_end_date   date;
495 --
496 Begin
497   hr_utility.set_location('Entering:'||l_proc, 5);
498   --
499   -- Validate the datetrack mode mode getting the validation start
500   -- and end dates for the specified datetrack operation.
501   --
502   dt_api.validate_dt_mode
503     (p_effective_date          => p_effective_date
504     ,p_datetrack_mode          => p_datetrack_mode
505     ,p_base_table_name         => 'hr_de_liability_premiums_f'
506     ,p_base_key_column         => 'liability_premiums_id'
507     ,p_base_key_value          => p_rec.liability_premiums_id
508     ,p_enforce_foreign_locking => true
509     ,p_validation_start_date   => l_validation_start_date
510     ,p_validation_end_date     => l_validation_end_date
511     );
512   --
513   -- Set the validation start and end date OUT arguments
514   --
515   p_validation_start_date := l_validation_start_date;
516   p_validation_end_date   := l_validation_end_date;
517   --
518   hr_utility.set_location(' Leaving:'||l_proc, 10);
519   --
520 End ins_lck;
521 --
522 -- ----------------------------------------------------------------------------
523 -- |---------------------------------< ins >----------------------------------|
524 -- ----------------------------------------------------------------------------
525 Procedure ins
526   (p_effective_date in     date
527   ,p_rec            in out nocopy hr_lip_shd.g_rec_type
528   ) is
529 --
530   l_proc                        varchar2(72) := g_package||'ins';
531   l_datetrack_mode              varchar2(30) := hr_api.g_insert;
532   l_validation_start_date       date;
533   l_validation_end_date         date;
534 --
535 Begin
536   hr_utility.set_location('Entering:'||l_proc, 5);
537   --
538   -- Call the lock operation
539   --
540   hr_lip_ins.ins_lck
541     (p_effective_date        => p_effective_date
542     ,p_datetrack_mode        => l_datetrack_mode
543     ,p_rec                   => p_rec
544     ,p_validation_start_date => l_validation_start_date
545     ,p_validation_end_date   => l_validation_end_date
546     );
547   --
548   -- Call the supporting insert validate operations
549   --
550   hr_lip_bus.insert_validate
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   -- Call the supporting pre-insert operation
559   --
560   hr_lip_ins.pre_insert
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   -- Insert the row
569   --
570   hr_lip_ins.insert_dml
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 the supporting post-insert operation
579   --
580   hr_lip_ins.post_insert
581     (p_rec                   => p_rec
582     ,p_effective_date        => p_effective_date
583     ,p_datetrack_mode        => l_datetrack_mode
584     ,p_validation_start_date => l_validation_start_date
585     ,p_validation_end_date   => l_validation_end_date
586     );
587   --
588   hr_utility.set_location('Leaving:'||l_proc,10);
589 end ins;
590 --
591 -- ----------------------------------------------------------------------------
592 -- |---------------------------------< ins >----------------------------------|
593 -- ----------------------------------------------------------------------------
594 Procedure ins
595   (p_effective_date                 in     date
596   ,p_organization_link_id           in     number
597   ,p_std_percentage                 in     number   default null
598   ,p_calculation_method             in     varchar2 default null
599   ,p_std_working_hours_per_year     in     number   default null
600   ,p_max_remuneration               in     number   default null
601   ,p_attribute_category             in     varchar2 default null
602   ,p_attribute1                     in     varchar2 default null
603   ,p_attribute2                     in     varchar2 default null
604   ,p_attribute3                     in     varchar2 default null
605   ,p_attribute4                     in     varchar2 default null
606   ,p_attribute5                     in     varchar2 default null
607   ,p_attribute6                     in     varchar2 default null
608   ,p_attribute7                     in     varchar2 default null
609   ,p_attribute8                     in     varchar2 default null
610   ,p_attribute9                     in     varchar2 default null
611   ,p_attribute10                    in     varchar2 default null
612   ,p_attribute11                    in     varchar2 default null
613   ,p_attribute12                    in     varchar2 default null
614   ,p_attribute13                    in     varchar2 default null
615   ,p_attribute14                    in     varchar2 default null
616   ,p_attribute15                    in     varchar2 default null
617   ,p_attribute16                    in     varchar2 default null
618   ,p_attribute17                    in     varchar2 default null
619   ,p_attribute18                    in     varchar2 default null
620   ,p_attribute19                    in     varchar2 default null
621   ,p_attribute20                    in     varchar2 default null
622   ,p_liability_premiums_id             out nocopy number
623   ,p_object_version_number             out nocopy number
624   ,p_effective_start_date              out nocopy date
625   ,p_effective_end_date                out nocopy date
626   ) is
627 --
628   l_rec         hr_lip_shd.g_rec_type;
629   l_proc        varchar2(72) := g_package||'ins';
630 --
631 Begin
632   hr_utility.set_location('Entering:'||l_proc, 5);
633   --
634   -- Call conversion function to turn arguments into the
635   -- p_rec structure.
636   --
637   l_rec :=
638   hr_lip_shd.convert_args
639     (null
640     ,p_organization_link_id
641     ,null
642     ,null
643     ,p_std_percentage
644     ,p_calculation_method
645     ,p_std_working_hours_per_year
646     ,p_max_remuneration
647     ,p_attribute_category
648     ,p_attribute1
649     ,p_attribute2
650     ,p_attribute3
651     ,p_attribute4
652     ,p_attribute5
653     ,p_attribute6
654     ,p_attribute7
655     ,p_attribute8
656     ,p_attribute9
657     ,p_attribute10
658     ,p_attribute11
659     ,p_attribute12
660     ,p_attribute13
661     ,p_attribute14
662     ,p_attribute15
663     ,p_attribute16
664     ,p_attribute17
665     ,p_attribute18
666     ,p_attribute19
667     ,p_attribute20
668     ,null
669     );
670   --
671   -- Having converted the arguments into the hr_lip_rec
672   -- plsql record structure we call the corresponding record
673   -- business process.
674   --
675   hr_lip_ins.ins
676     (p_effective_date
677     ,l_rec
678     );
679   --
680   -- Set the OUT arguments.
681   --
682   p_liability_premiums_id            := l_rec.liability_premiums_id;
683   p_effective_start_date             := l_rec.effective_start_date;
684   p_effective_end_date               := l_rec.effective_end_date;
685   p_object_version_number            := l_rec.object_version_number;
686   --
687   --
688   hr_utility.set_location(' Leaving:'||l_proc, 10);
689 End ins;
690 --
691 end hr_lip_ins;