DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PCL_INS

Source


1 Package Body per_pcl_ins as
2 /* $Header: pepclrhi.pkb 115.9 2002/12/09 15:33:43 pkakar noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_pcl_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 per_pcl_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   per_cagr_entitlement_lines_f t
70     where  t.cagr_entitlement_line_id       = p_rec.cagr_entitlement_line_id
71     and    t.effective_start_date =
72              per_pcl_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          per_cagr_entitlement_lines_f.created_by%TYPE;
77   l_creation_date       per_cagr_entitlement_lines_f.creation_date%TYPE;
78   l_last_update_date    per_cagr_entitlement_lines_f.last_update_date%TYPE;
79   l_last_updated_by     per_cagr_entitlement_lines_f.last_updated_by%TYPE;
80   l_last_update_login   per_cagr_entitlement_lines_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 => 'per_cagr_entitlement_lines_f'
90       ,p_base_key_column => 'cagr_entitlement_line_id'
91       ,p_base_key_value  => p_rec.cagr_entitlement_line_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: per_cagr_entitlement_lines_f
133   --
134   insert into per_cagr_entitlement_lines_f
135       (cagr_entitlement_line_id
136       ,cagr_entitlement_id
137       ,mandatory
138       ,value
139       ,range_from
140       ,range_to
141       ,effective_start_date
142       ,effective_end_date
143       ,parent_spine_id
144       ,step_id
145       ,from_step_id
146       ,to_step_id
147       ,status
148       ,oipl_id
149       ,object_version_number
150       ,grade_spine_id
151       ,eligy_prfl_id
152       ,created_by
153       ,creation_date
154       ,last_update_date
155       ,last_updated_by
156       ,last_update_login
157       )
158   Values
159     (p_rec.cagr_entitlement_line_id
160     ,p_rec.cagr_entitlement_id
161     ,p_rec.mandatory
162     ,p_rec.value
163     ,p_rec.range_from
164     ,p_rec.range_to
165     ,p_rec.effective_start_date
166     ,p_rec.effective_end_date
167     ,p_rec.parent_spine_id
168     ,p_rec.step_id
169     ,p_rec.from_step_id
170     ,p_rec.to_step_id
171     ,p_rec.status
172     ,p_rec.oipl_id
173     ,p_rec.object_version_number
174     ,p_rec.grade_spine_id
175     ,p_rec.eligy_prfl_id
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     per_pcl_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     per_pcl_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 per_pcl_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   per_pcl_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 per_pcl_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 per_cagr_entitlement_lines_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.cagr_entitlement_line_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 per_pcl_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     per_pcl_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_cagr_entitlement_line_id
348       => p_rec.cagr_entitlement_line_id
349       ,p_cagr_entitlement_id
350       => p_rec.cagr_entitlement_id
351       ,p_mandatory
352       => p_rec.mandatory
353       ,p_value
354       => p_rec.value
355       ,p_range_from
356       => p_rec.range_from
357       ,p_range_to
358       => p_rec.range_to
359       ,p_effective_start_date
360       => p_rec.effective_start_date
361       ,p_effective_end_date
362       => p_rec.effective_end_date
363       ,p_parent_spine_id
364       => p_rec.parent_spine_id
365       ,p_step_id
366       => p_rec.step_id
367       ,p_from_step_id
368       => p_rec.from_step_id
369       ,p_to_step_id
370       => p_rec.to_step_id
371       ,p_status
372       => p_rec.status
373       ,p_oipl_id
374       => p_rec.oipl_id
375       ,p_object_version_number
376       => p_rec.object_version_number
377       ,p_grade_spine_id
378       => p_rec.grade_spine_id
379       ,p_eligy_prfl_id
380       => p_rec.eligy_prfl_id
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 => 'PER_CAGR_ENTITLEMENT_LINES_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 per_pcl_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         => 'per_cagr_entitlement_lines_f'
454     ,p_base_key_column         => 'cagr_entitlement_line_id'
455     ,p_base_key_value          => p_rec.cagr_entitlement_line_id
456     ,p_parent_table_name1      => 'per_grade_spines_f'
457     ,p_parent_key_column1      => 'grade_spine_id'
458     ,p_parent_key_value1       => p_rec.grade_spine_id
459     ,p_parent_table_name2      => 'per_spinal_point_steps_f'
460     ,p_parent_key_column2      => 'step_id'
461     ,p_parent_key_value2       => p_rec.step_id
462     ,p_parent_table_name3      => 'per_spinal_point_steps_f'
463     ,p_parent_key_column3      => 'step_id'
464     ,p_parent_key_value3       => p_rec.from_step_id
465     ,p_parent_table_name4      => 'per_spinal_point_steps_f'
466     ,p_parent_key_column4      => 'step_id'
467     ,p_parent_key_value4       => p_rec.to_step_id
468     ,p_enforce_foreign_locking => true
469     ,p_validation_start_date   => l_validation_start_date
470     ,p_validation_end_date     => l_validation_end_date
471     );
472   --
473   -- Set the validation start and end date OUT arguments
474   --
475   p_validation_start_date := l_validation_start_date;
476   p_validation_end_date   := l_validation_end_date;
477   --
478   hr_utility.set_location(' Leaving:'||l_proc, 10);
479   --
480 End ins_lck;
481 --
482 -- ----------------------------------------------------------------------------
483 -- |---------------------------------< ins >----------------------------------|
484 -- ----------------------------------------------------------------------------
485 Procedure ins
486   (p_effective_date in     date
487   ,p_rec            in out nocopy per_pcl_shd.g_rec_type
488   ) is
489 --
490   l_proc                        varchar2(72) := g_package||'ins';
491   l_datetrack_mode              varchar2(30) := hr_api.g_insert;
492   l_validation_start_date       date;
493   l_validation_end_date         date;
494 --
495 Begin
496   hr_utility.set_location('Entering:'||l_proc, 5);
497   --
498   -- Call the lock operation
499   --
500   per_pcl_ins.ins_lck
501     (p_effective_date        => p_effective_date
502     ,p_datetrack_mode        => l_datetrack_mode
503     ,p_rec                   => p_rec
504     ,p_validation_start_date => l_validation_start_date
505     ,p_validation_end_date   => l_validation_end_date
506     );
507   --
508   -- Call the supporting insert validate operations
509   --
510   per_pcl_bus.insert_validate
511     (p_rec                   => p_rec
512     ,p_effective_date        => p_effective_date
513     ,p_datetrack_mode        => l_datetrack_mode
514     ,p_validation_start_date => l_validation_start_date
515     ,p_validation_end_date   => l_validation_end_date
516     );
517   --
518   -- Call the supporting pre-insert operation
519   --
520   per_pcl_ins.pre_insert
521     (p_rec                   => p_rec
522     ,p_effective_date        => p_effective_date
523     ,p_datetrack_mode        => l_datetrack_mode
524     ,p_validation_start_date => l_validation_start_date
525     ,p_validation_end_date   => l_validation_end_date
526     );
527   --
528   -- Insert the row
529   --
530   per_pcl_ins.insert_dml
531     (p_rec                   => p_rec
532     ,p_effective_date        => p_effective_date
533     ,p_datetrack_mode        => l_datetrack_mode
534     ,p_validation_start_date => l_validation_start_date
535     ,p_validation_end_date   => l_validation_end_date
536     );
537   --
538   -- Call the supporting post-insert operation
539   --
540   per_pcl_ins.post_insert
541     (p_rec                   => p_rec
542     ,p_effective_date        => p_effective_date
543     ,p_datetrack_mode        => l_datetrack_mode
544     ,p_validation_start_date => l_validation_start_date
545     ,p_validation_end_date   => l_validation_end_date
546     );
547   --
548   hr_utility.set_location('Leaving:'||l_proc,10);
549 end ins;
550 --
551 -- ----------------------------------------------------------------------------
552 -- |---------------------------------< ins >----------------------------------|
553 -- ----------------------------------------------------------------------------
554 Procedure ins
555   (p_effective_date                 in     date
556   ,p_cagr_entitlement_id            in     number
557   ,p_mandatory                      in     varchar2
558   ,p_parent_spine_id                in     number
559   ,p_step_id                        in     number
560   ,p_from_step_id                   in     number
561   ,p_to_step_id                     in     number
562   ,p_status                         in     varchar2
563   ,p_oipl_id                        in     number
564   ,p_grade_spine_id                 in     number
565   ,p_value                          in     varchar2 default null
566   ,p_range_from                     in     varchar2 default null
567   ,p_range_to                       in     varchar2 default null
568   ,p_eligy_prfl_id                  in     number   default null
569   ,p_cagr_entitlement_line_id          out nocopy number
570   ,p_object_version_number             out nocopy number
571   ,p_effective_start_date              out nocopy date
572   ,p_effective_end_date                out nocopy date
573   ) is
574 --
575   l_rec         per_pcl_shd.g_rec_type;
576   l_proc        varchar2(72) := g_package||'ins';
577 --
578 Begin
579   hr_utility.set_location('Entering:'||l_proc, 5);
580   --
581   -- Call conversion function to turn arguments into the
582   -- p_rec structure.
583   --
584   l_rec :=
585   per_pcl_shd.convert_args
586     (null
587     ,p_cagr_entitlement_id
588     ,p_mandatory
589     ,p_value
590     ,p_range_from
591     ,p_range_to
592     ,null
593     ,null
594     ,p_parent_spine_id
595     ,p_step_id
596     ,p_from_step_id
597     ,p_to_step_id
598     ,p_status
599     ,p_oipl_id
600     ,null
601     ,p_grade_spine_id
602     ,p_eligy_prfl_id
603     );
604   --
605   -- Having converted the arguments into the per_pcl_rec
606   -- plsql record structure we call the corresponding record
607   -- business process.
608   --
609   per_pcl_ins.ins
610     (p_effective_date
611     ,l_rec
612     );
613   --
614   -- Set the OUT arguments.
615   --
616   p_cagr_entitlement_line_id         := l_rec.cagr_entitlement_line_id;
617   p_effective_start_date             := l_rec.effective_start_date;
618   p_effective_end_date               := l_rec.effective_end_date;
619   p_object_version_number            := l_rec.object_version_number;
620   --
621   --
622   hr_utility.set_location(' Leaving:'||l_proc, 10);
623 End ins;
624 --
625 end per_pcl_ins;