DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_SID_INS

Source


1 Package Body pay_sid_ins as
2 /* $Header: pysidrhi.pkb 120.1 2005/07/05 06:26:10 vikgupta noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_sid_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_sid_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_prsi_details_f t
70     where  t.prsi_details_id       = p_rec.prsi_details_id
71     and    t.effective_start_date =
72              pay_sid_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_prsi_details_f.created_by%TYPE;
77   l_creation_date       pay_ie_prsi_details_f.creation_date%TYPE;
78   l_last_update_date    pay_ie_prsi_details_f.last_update_date%TYPE;
79   l_last_updated_by     pay_ie_prsi_details_f.last_updated_by%TYPE;
80   l_last_update_login   pay_ie_prsi_details_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_prsi_details_f'
90       ,p_base_key_column => 'prsi_details_id'
91       ,p_base_key_value  => p_rec.prsi_details_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_prsi_details_f
133   --
134   insert into pay_ie_prsi_details_f
135       (prsi_details_id
136       ,effective_start_date
137       ,effective_end_date
138       ,object_version_number
139       ,assignment_id
140       ,contribution_class
141       ,overridden_subclass
142       ,soc_ben_flag
143       ,soc_ben_start_date
144       ,overridden_ins_weeks
145       ,non_standard_ins_weeks
146       ,exemption_start_date
147       ,exemption_end_date
148       ,cert_issued_by
149       ,director_flag
150       ,request_id
151       ,program_application_id
152       ,program_id
153       ,program_update_date
154       ,community_flag
155       ,created_by
156       ,creation_date
157       ,last_update_date
158       ,last_updated_by
159       ,last_update_login
160       )
161   Values
162     (p_rec.prsi_details_id
163     ,p_rec.effective_start_date
164     ,p_rec.effective_end_date
165     ,p_rec.object_version_number
166     ,p_rec.assignment_id
167     ,p_rec.contribution_class
168     ,p_rec.overridden_subclass
169     ,p_rec.soc_ben_flag
170     ,p_rec.soc_ben_start_date
171     ,p_rec.overridden_ins_weeks
172     ,p_rec.non_standard_ins_weeks
173     ,p_rec.exemption_start_date
174     ,p_rec.exemption_end_date
175     ,p_rec.cert_issued_by
176     ,p_rec.director_flag
177     ,p_rec.request_id
178     ,p_rec.program_application_id
179     ,p_rec.program_id
180     ,p_rec.program_update_date
181     ,p_rec.community_flag
182     ,l_created_by
183     ,l_creation_date
184     ,l_last_update_date
185     ,l_last_updated_by
186     ,l_last_update_login
187     );
188   --
189   --
190   hr_utility.set_location(' Leaving:'||l_proc, 15);
191 --
192 Exception
193   When hr_api.check_integrity_violated Then
194     -- A check constraint has been violated
195     --
196     pay_sid_shd.constraint_error
197       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
198   When hr_api.unique_integrity_violated Then
199     -- Unique integrity has been violated
200     --
201     pay_sid_shd.constraint_error
202       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
203   When Others Then
204     --
205     Raise;
206 End dt_insert_dml;
207 --
208 -- ----------------------------------------------------------------------------
209 -- |------------------------------< insert_dml >------------------------------|
210 -- ----------------------------------------------------------------------------
211 Procedure insert_dml
212   (p_rec                   in out nocopy pay_sid_shd.g_rec_type
213   ,p_effective_date        in date
214   ,p_datetrack_mode        in varchar2
215   ,p_validation_start_date in date
216   ,p_validation_end_date   in date
217   ) is
218 --
219   l_proc        varchar2(72) := g_package||'insert_dml';
220 --
221 Begin
222   hr_utility.set_location('Entering:'||l_proc, 5);
223   --
224   pay_sid_ins.dt_insert_dml
225     (p_rec                   => p_rec
226     ,p_effective_date        => p_effective_date
227     ,p_datetrack_mode        => p_datetrack_mode
228     ,p_validation_start_date => p_validation_start_date
229     ,p_validation_end_date   => p_validation_end_date
230     );
231   --
232   hr_utility.set_location(' Leaving:'||l_proc, 10);
233 End insert_dml;
234 --
235 -- ----------------------------------------------------------------------------
236 -- |------------------------------< pre_insert >------------------------------|
237 -- ----------------------------------------------------------------------------
238 -- {Start Of Comments}
239 --
240 -- Description:
241 --   This private procedure contains any processing which is required before
242 --   the insert dml. Presently, if the entity has a corresponding primary
243 --   key which is maintained by an associating sequence, the primary key for
244 --   the entity will be populated with the next sequence value in
245 --   preparation for the insert dml.
246 --   Also, if comments are defined for this entity, the comments insert
247 --   logic will also be called, generating a comment_id if required.
248 --
249 -- Prerequisites:
250 --   This is an internal procedure which is called from the ins procedure.
251 --
252 -- In Parameters:
253 --   A Pl/Sql record structure.
254 --
255 -- Post Success:
256 --   Processing continues.
257 --
258 -- Post Failure:
259 --   If an error has occurred, an error message and exception will be raised
260 --   but not handled.
261 --
262 -- Developer Implementation Notes:
263 --   Any pre-processing required before the insert dml is issued should be
264 --   coded within this procedure. As stated above, a good example is the
265 --   generation of a primary key number via a corresponding sequence.
266 --   It is important to note that any 3rd party maintenance should be reviewed
267 --   before placing in this procedure.
268 --
269 -- Access Status:
270 --   Internal Row Handler Use Only.
271 --
272 -- {End Of Comments}
273 -- ----------------------------------------------------------------------------
274 Procedure pre_insert
275   (p_rec                   in out nocopy pay_sid_shd.g_rec_type
276   ,p_effective_date        in date
277   ,p_datetrack_mode        in varchar2
278   ,p_validation_start_date in date
279   ,p_validation_end_date   in date
280   ) is
281 --
282   l_proc        varchar2(72) := g_package||'pre_insert';
283 --
284   Cursor C_Sel1 is select pay_ie_prsi_details_s.nextval from sys.dual;
285 --
286 Begin
287   hr_utility.set_location('Entering:'||l_proc, 5);
288   --
289   --
290   -- Select the next sequence number
291   --
292   Open C_Sel1;
293   Fetch C_Sel1 Into p_rec.prsi_details_id;
294   Close C_Sel1;
295   --
296   --
297   hr_utility.set_location(' Leaving:'||l_proc, 10);
298 End pre_insert;
299 --
300 -- ----------------------------------------------------------------------------
301 -- |----------------------------< post_insert >-------------------------------|
302 -- ----------------------------------------------------------------------------
303 -- {Start Of Comments}
304 --
305 -- Description:
306 --   This private procedure contains any processing which is required after
307 --   the insert dml.
308 --
309 -- Prerequisites:
310 --   This is an internal procedure which is called from the ins procedure.
311 --
312 -- In Parameters:
313 --   A Pl/Sql record structure.
314 --
315 -- Post Success:
316 --   Processing continues.
317 --
318 -- Post Failure:
319 --   If an error has occurred, an error message and exception will be raised
320 --   but not handled.
321 --
322 -- Developer Implementation Notes:
323 --   Any post-processing required after the insert dml is issued should be
324 --   coded within this procedure. It is important to note that any 3rd party
325 --   maintenance should be reviewed before placing in this procedure.
326 --
327 -- Access Status:
328 --   Internal Row Handler Use Only.
329 --
330 -- {End Of Comments}
331 -- ----------------------------------------------------------------------------
332 Procedure post_insert
333   (p_rec                   in pay_sid_shd.g_rec_type
334   ,p_effective_date        in date
335   ,p_datetrack_mode        in varchar2
336   ,p_validation_start_date in date
337   ,p_validation_end_date   in date
338   ) is
339 --
340   l_proc        varchar2(72) := g_package||'post_insert';
341 --
342 Begin
343   hr_utility.set_location('Entering:'||l_proc, 5);
344   begin
345     --
346     pay_sid_rki.after_insert
347       (p_effective_date
348       => p_effective_date
349       ,p_validation_start_date
350       => p_validation_start_date
351       ,p_validation_end_date
352       => p_validation_end_date
353       ,p_prsi_details_id
354       => p_rec.prsi_details_id
355       ,p_effective_start_date
356       => p_rec.effective_start_date
357       ,p_effective_end_date
358       => p_rec.effective_end_date
359       ,p_object_version_number
360       => p_rec.object_version_number
361       ,p_assignment_id
362       => p_rec.assignment_id
363       ,p_contribution_class
364       => p_rec.contribution_class
365       ,p_overridden_subclass
366       => p_rec.overridden_subclass
367       ,p_soc_ben_flag
368       => p_rec.soc_ben_flag
369       ,p_soc_ben_start_date
370       => p_rec.soc_ben_start_date
371       ,p_overridden_ins_weeks
372       => p_rec.overridden_ins_weeks
373       ,p_non_standard_ins_weeks
374       => p_rec.non_standard_ins_weeks
375       ,p_exemption_start_date
376       => p_rec.exemption_start_date
377       ,p_exemption_end_date
378       => p_rec.exemption_end_date
379       ,p_cert_issued_by
380       => p_rec.cert_issued_by
381       ,p_director_flag
382       => p_rec.director_flag
383       ,p_request_id
384       => p_rec.request_id
385       ,p_program_application_id
386       => p_rec.program_application_id
387       ,p_program_id
388       => p_rec.program_id
389       ,p_program_update_date
390       => p_rec.program_update_date
391       ,p_community_flag
392       => p_rec.community_flag
393       );
394     --
395   exception
396     --
397     when hr_api.cannot_find_prog_unit then
398       --
399       hr_api.cannot_find_prog_unit_error
400         (p_module_name => 'PAY_IE_PRSI_DETAILS_F'
401         ,p_hook_type   => 'AI');
402       --
403   end;
404   --
405   hr_utility.set_location(' Leaving:'||l_proc, 10);
406 End post_insert;
407 --
408 -- ----------------------------------------------------------------------------
409 -- |-------------------------------< ins_lck >--------------------------------|
410 -- ----------------------------------------------------------------------------
411 -- {Start Of Comments}
412 --
413 -- Description:
414 --   The ins_lck process has one main function to perform. When inserting
415 --   a datetracked row, we must validate the DT mode.
416 --
417 -- Prerequisites:
418 --   This procedure can only be called for the datetrack mode of INSERT.
419 --
420 -- In Parameters:
421 --
422 -- Post Success:
423 --   On successful completion of the ins_lck process the parental
424 --   datetracked rows will be locked providing the p_enforce_foreign_locking
425 --   argument value is TRUE.
426 --   If the p_enforce_foreign_locking argument value is FALSE then the
427 --   parential rows are not locked.
428 --
429 -- Post Failure:
430 --   The Lck process can fail for:
431 --   1) When attempting to lock the row the row could already be locked by
432 --      another user. This will raise the HR_Api.Object_Locked exception.
433 --   2) When attempting to the lock the parent which doesn't exist.
434 --      For the entity to be locked the parent must exist!
435 --
436 -- Developer Implementation Notes:
437 --   None.
438 --
439 -- Access Status:
440 --   Internal Row Handler Use Only.
441 --
442 -- {End Of Comments}
443 -- ----------------------------------------------------------------------------
444 Procedure ins_lck
445   (p_effective_date        in date
446   ,p_datetrack_mode        in varchar2
447   ,p_rec                   in pay_sid_shd.g_rec_type
448   ,p_validation_start_date out nocopy date
449   ,p_validation_end_date   out nocopy date
450   ) is
451 --
452   l_proc                  varchar2(72) := g_package||'ins_lck';
453   l_validation_start_date date;
454   l_validation_end_date   date;
455 --
456 Begin
457   hr_utility.set_location('Entering:'||l_proc, 5);
458   --
459   -- Validate the datetrack mode mode getting the validation start
460   -- and end dates for the specified datetrack operation.
461   --
462   dt_api.validate_dt_mode
463     (p_effective_date          => p_effective_date
464     ,p_datetrack_mode          => p_datetrack_mode
465     ,p_base_table_name         => 'pay_ie_prsi_details_f'
466     ,p_base_key_column         => 'prsi_details_id'
467     ,p_base_key_value          => p_rec.prsi_details_id
468     ,p_parent_table_name1      => 'per_all_assignments_f'
469     ,p_parent_key_column1      => 'assignment_id'
470     ,p_parent_key_value1       => p_rec.assignment_id
471     ,p_enforce_foreign_locking => true
472     ,p_validation_start_date   => l_validation_start_date
473     ,p_validation_end_date     => l_validation_end_date
474     );
475   --
476   -- Set the validation start and end date OUT arguments
477   --
478   p_validation_start_date := l_validation_start_date;
479   p_validation_end_date   := l_validation_end_date;
480   --
481   hr_utility.set_location(' Leaving:'||l_proc, 10);
482   --
483 End ins_lck;
484 --
485 -- ----------------------------------------------------------------------------
486 -- |---------------------------------< ins >----------------------------------|
487 -- ----------------------------------------------------------------------------
488 Procedure ins
489   (p_effective_date in     date
490   ,p_rec            in out nocopy pay_sid_shd.g_rec_type
491   ) is
492 --
493   l_proc                        varchar2(72) := g_package||'ins';
494   l_datetrack_mode              varchar2(30) := hr_api.g_insert;
495   l_validation_start_date       date;
496   l_validation_end_date         date;
497 --
498 Begin
499   hr_utility.set_location('Entering:'||l_proc, 5);
500   --
501   -- Call the lock operation
502   --
503   pay_sid_ins.ins_lck
504     (p_effective_date        => p_effective_date
505     ,p_datetrack_mode        => l_datetrack_mode
506     ,p_rec                   => p_rec
507     ,p_validation_start_date => l_validation_start_date
508     ,p_validation_end_date   => l_validation_end_date
509     );
510   --
511   -- Call the supporting insert validate operations
512   --
513   pay_sid_bus.insert_validate
514     (p_rec                   => p_rec
515     ,p_effective_date        => p_effective_date
516     ,p_datetrack_mode        => l_datetrack_mode
517     ,p_validation_start_date => l_validation_start_date
518     ,p_validation_end_date   => l_validation_end_date
519     );
520   --
521   -- Call the supporting pre-insert operation
522   --
523   pay_sid_ins.pre_insert
524     (p_rec                   => p_rec
525     ,p_effective_date        => p_effective_date
526     ,p_datetrack_mode        => l_datetrack_mode
527     ,p_validation_start_date => l_validation_start_date
528     ,p_validation_end_date   => l_validation_end_date
529     );
530   --
531   -- Insert the row
532   --
533   pay_sid_ins.insert_dml
534     (p_rec                   => p_rec
535     ,p_effective_date        => p_effective_date
536     ,p_datetrack_mode        => l_datetrack_mode
537     ,p_validation_start_date => l_validation_start_date
538     ,p_validation_end_date   => l_validation_end_date
539     );
540   --
541   -- Call the supporting post-insert operation
542   --
543   pay_sid_ins.post_insert
544     (p_rec                   => p_rec
545     ,p_effective_date        => p_effective_date
546     ,p_datetrack_mode        => l_datetrack_mode
547     ,p_validation_start_date => l_validation_start_date
548     ,p_validation_end_date   => l_validation_end_date
549     );
550   --
551   hr_utility.set_location('Leaving:'||l_proc,10);
552 end ins;
553 --
554 -- ----------------------------------------------------------------------------
555 -- |---------------------------------< ins >----------------------------------|
556 -- ----------------------------------------------------------------------------
557 Procedure ins
558   (p_effective_date                 in     date
559   ,p_assignment_id                  in     number
560   ,p_contribution_class             in     varchar2
561   ,p_overridden_subclass            in     varchar2 default null
562   ,p_soc_ben_flag                   in     varchar2 default null
563   ,p_soc_ben_start_date             in     date     default null
564   ,p_overridden_ins_weeks           in     number   default null
565   ,p_non_standard_ins_weeks         in     number   default null
566   ,p_exemption_start_date           in     date     default null
567   ,p_exemption_end_date             in     date     default null
568   ,p_cert_issued_by                 in     varchar2 default null
569   ,p_director_flag                  in     varchar2 default null
570   ,p_request_id                     in     number   default null
571   ,p_program_application_id         in     number   default null
572   ,p_program_id                     in     number   default null
573   ,p_program_update_date            in     date     default null
574   ,p_community_flag                 in     varchar2 default null
575   ,p_prsi_details_id                   out nocopy number
576   ,p_object_version_number             out nocopy number
577   ,p_effective_start_date              out nocopy date
578   ,p_effective_end_date                out nocopy date
579   ) is
580 --
581   l_rec         pay_sid_shd.g_rec_type;
582   l_proc        varchar2(72) := g_package||'ins';
583 --
584 Begin
585   hr_utility.set_location('Entering:'||l_proc, 5);
586   --
587   -- Call conversion function to turn arguments into the
588   -- p_rec structure.
589   --
590   l_rec :=
591   pay_sid_shd.convert_args
592     (null
593     ,null
594     ,null
595     ,null
596     ,p_assignment_id
597     ,p_contribution_class
598     ,p_overridden_subclass
599     ,p_soc_ben_flag
600     ,p_soc_ben_start_date
601     ,p_overridden_ins_weeks
602     ,p_non_standard_ins_weeks
603     ,p_exemption_start_date
604     ,p_exemption_end_date
605     ,p_cert_issued_by
606     ,p_director_flag
607     ,p_request_id
608     ,p_program_application_id
609     ,p_program_id
610     ,p_program_update_date
611     ,p_community_flag
612     );
613   --
614   -- Having converted the arguments into the pay_sid_rec
615   -- plsql record structure we call the corresponding record
616   -- business process.
617   --
618   pay_sid_ins.ins
619     (p_effective_date
620     ,l_rec
621     );
622   --
623   -- Set the OUT arguments.
624   --
625   p_prsi_details_id                  := l_rec.prsi_details_id;
626   p_effective_start_date             := l_rec.effective_start_date;
627   p_effective_end_date               := l_rec.effective_end_date;
628   p_object_version_number            := l_rec.object_version_number;
629   --
630   --
631   hr_utility.set_location(' Leaving:'||l_proc, 10);
632 End ins;
633 --
634 end pay_sid_ins;