DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_PDT_INS

Source


1 Package Body hr_pdt_ins as
2 /* $Header: hrpdtrhi.pkb 120.4.12010000.2 2008/08/06 08:46:56 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_pdt_ins.';  -- Global package name
9 --
10 -- The following global variables are only to be used by
11 -- the set_base_key_value and pre_insert procedures.
12 --
13 g_person_deployment_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_person_deployment_id  in  number) is
20 --
21   l_proc       varchar2(72) := g_package||'set_base_key_value';
22 --
23 Begin
24   hr_utility.set_location('Entering:'||l_proc, 10);
25   --
26   hr_pdt_ins.g_person_deployment_id_i := p_person_deployment_id;
27   --
28   hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 --
32 -- ----------------------------------------------------------------------------
33 -- |------------------------------< insert_dml >------------------------------|
34 -- ----------------------------------------------------------------------------
35 -- {Start Of Comments}
36 --
37 -- Description:
38 --   This procedure controls the actual dml insert logic. The processing of
39 --   this procedure are as follows:
40 --   1) Initialise the object_version_number to 1 if the object_version_number
41 --      is defined as an attribute for this entity.
42 --   2) To set and unset the g_api_dml status as required (as we are about to
43 --      perform dml).
44 --   3) To insert the row into the schema.
45 --   4) To trap any constraint violations that may have occurred.
46 --   5) To raise any other errors.
47 --
48 -- Prerequisites:
49 --   This is an internal private procedure which must be called from the ins
50 --   procedure and must have all mandatory attributes set (except the
51 --   object_version_number which is initialised within this procedure).
52 --
53 -- In Parameters:
54 --   A Pl/Sql record structre.
55 --
56 -- Post Success:
57 --   The specified row will be inserted into the schema.
58 --
59 -- Post Failure:
60 --   On the insert dml failure it is important to note that we always reset the
61 --   g_api_dml status to false.
62 --   If a check, unique or parent integrity constraint violation is raised the
63 --   constraint_error procedure will be called.
64 --   If any other error is reported, the error will be raised after the
65 --   g_api_dml status is reset.
66 --
67 -- Developer Implementation Notes:
68 --   None.
69 --
70 -- Access Status:
71 --   Internal Row Handler Use Only.
72 --
73 -- {End Of Comments}
74 -- ----------------------------------------------------------------------------
75 Procedure insert_dml
76   (p_rec in out nocopy hr_pdt_shd.g_rec_type
77   ) is
78 --
79   l_proc  varchar2(72) := g_package||'insert_dml';
80 --
81 Begin
82   hr_utility.set_location('Entering:'||l_proc, 5);
83   p_rec.object_version_number := 1;  -- Initialise the object version
84   --
85   --
86   --
87   -- Insert the row into: hr_person_deployments
88   --
89   insert into hr_person_deployments
90       (person_deployment_id
91       ,object_version_number
92       ,from_business_group_id
93       ,to_business_group_id
94       ,from_person_id
95       ,to_person_id
96       ,person_type_id
97       ,start_date
98       ,end_date
99       ,deployment_reason
100       ,employee_number
101       ,leaving_reason
102       ,leaving_person_type_id
103       ,permanent
104       ,status
105       ,status_change_reason
106       ,status_change_date
107       ,deplymt_policy_id
108       ,organization_id
109       ,location_id
110       ,job_id
111       ,position_id
112       ,grade_id
113       ,supervisor_id
114       ,supervisor_assignment_id
115       ,retain_direct_reports
116       ,payroll_id
117       ,pay_basis_id
118       ,proposed_salary
119       ,people_group_id
120       ,soft_coding_keyflex_id
121       ,assignment_status_type_id
122       ,ass_status_change_reason
123       ,assignment_category
124       ,per_information_category
125       ,per_information1
126       ,per_information2
127       ,per_information3
128       ,per_information4
129       ,per_information5
130       ,per_information6
131       ,per_information7
132       ,per_information8
133       ,per_information9
134       ,per_information10
135       ,per_information11
136       ,per_information12
137       ,per_information13
138       ,per_information14
139       ,per_information15
140       ,per_information16
141       ,per_information17
142       ,per_information18
143       ,per_information19
144       ,per_information20
145       ,per_information21
146       ,per_information22
147       ,per_information23
148       ,per_information24
149       ,per_information25
150       ,per_information26
151       ,per_information27
152       ,per_information28
153       ,per_information29
154       ,per_information30
155       )
156   Values
157     (p_rec.person_deployment_id
158     ,p_rec.object_version_number
159     ,p_rec.from_business_group_id
160     ,p_rec.to_business_group_id
161     ,p_rec.from_person_id
162     ,p_rec.to_person_id
163     ,p_rec.person_type_id
164     ,p_rec.start_date
165     ,p_rec.end_date
166     ,p_rec.deployment_reason
167     ,p_rec.employee_number
168     ,p_rec.leaving_reason
169     ,p_rec.leaving_person_type_id
170     ,p_rec.permanent
171     ,p_rec.status
172     ,p_rec.status_change_reason
173     ,p_rec.status_change_date
174     ,p_rec.deplymt_policy_id
175     ,p_rec.organization_id
176     ,p_rec.location_id
177     ,p_rec.job_id
178     ,p_rec.position_id
179     ,p_rec.grade_id
180     ,p_rec.supervisor_id
181     ,p_rec.supervisor_assignment_id
182     ,p_rec.retain_direct_reports
183     ,p_rec.payroll_id
184     ,p_rec.pay_basis_id
185     ,p_rec.proposed_salary
186     ,p_rec.people_group_id
187     ,p_rec.soft_coding_keyflex_id
188     ,p_rec.assignment_status_type_id
189     ,p_rec.ass_status_change_reason
190     ,p_rec.assignment_category
191     ,p_rec.per_information_category
192     ,p_rec.per_information1
193     ,p_rec.per_information2
194     ,p_rec.per_information3
195     ,p_rec.per_information4
196     ,p_rec.per_information5
197     ,p_rec.per_information6
198     ,p_rec.per_information7
199     ,p_rec.per_information8
200     ,p_rec.per_information9
201     ,p_rec.per_information10
202     ,p_rec.per_information11
203     ,p_rec.per_information12
204     ,p_rec.per_information13
205     ,p_rec.per_information14
206     ,p_rec.per_information15
207     ,p_rec.per_information16
208     ,p_rec.per_information17
209     ,p_rec.per_information18
210     ,p_rec.per_information19
211     ,p_rec.per_information20
212     ,p_rec.per_information21
213     ,p_rec.per_information22
214     ,p_rec.per_information23
215     ,p_rec.per_information24
216     ,p_rec.per_information25
217     ,p_rec.per_information26
218     ,p_rec.per_information27
219     ,p_rec.per_information28
220     ,p_rec.per_information29
221     ,p_rec.per_information30
222     );
223   --
224   --
225   --
226   hr_utility.set_location(' Leaving:'||l_proc, 10);
227 Exception
228   When hr_api.check_integrity_violated Then
229     -- A check constraint has been violated
230     --
231     hr_pdt_shd.constraint_error
232       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
233   When hr_api.parent_integrity_violated Then
234     -- Parent integrity has been violated
235     --
236     hr_pdt_shd.constraint_error
237       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
238   When hr_api.unique_integrity_violated Then
239     -- Unique integrity has been violated
240     --
241     hr_pdt_shd.constraint_error
242       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
243   When Others Then
244     --
245     Raise;
246 End insert_dml;
247 --
248 -- ----------------------------------------------------------------------------
249 -- |------------------------------< pre_insert >------------------------------|
250 -- ----------------------------------------------------------------------------
251 -- {Start Of Comments}
252 --
253 -- Description:
254 --   This private procedure contains any processing which is required before
255 --   the insert dml. Presently, if the entity has a corresponding primary
256 --   key which is maintained by an associating sequence, the primary key for
257 --   the entity will be populated with the next sequence value in
258 --   preparation for the insert dml.
259 --
260 -- Prerequisites:
261 --   This is an internal procedure which is called from the ins procedure.
262 --
263 -- In Parameters:
264 --   A Pl/Sql record structure.
265 --
266 -- Post Success:
267 --   Processing continues.
268 --
269 -- Post Failure:
270 --   If an error has occurred, an error message and exception will be raised
271 --   but not handled.
272 --
273 -- Developer Implementation Notes:
274 --   Any pre-processing required before the insert dml is issued should be
275 --   coded within this procedure. As stated above, a good example is the
276 --   generation of a primary key number via a corresponding sequence.
277 --   It is important to note that any 3rd party maintenance should be reviewed
278 --   before placing in this procedure.
279 --
280 -- Access Status:
281 --   Internal Row Handler Use Only.
282 --
283 -- {End Of Comments}
284 -- ----------------------------------------------------------------------------
285 Procedure pre_insert
286   (p_rec  in out nocopy hr_pdt_shd.g_rec_type
287   ) is
288 --
289   Cursor C_Sel1 is select hr_person_deployments_s.nextval from sys.dual;
290 --
291   Cursor C_Sel2 is
292     Select null
293       from hr_person_deployments
294      where person_deployment_id =
295              hr_pdt_ins.g_person_deployment_id_i;
296 --
297   l_proc   varchar2(72) := g_package||'pre_insert';
298   l_exists varchar2(1);
299 --
300 Begin
301   hr_utility.set_location('Entering:'||l_proc, 5);
302   --
303   If (hr_pdt_ins.g_person_deployment_id_i is not null) Then
304     --
305     -- Verify registered primary key values not already in use
306     --
307     Open C_Sel2;
308     Fetch C_Sel2 into l_exists;
309     If C_Sel2%found Then
310        Close C_Sel2;
311        --
312        -- The primary key values are already in use.
313        --
314        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
315        fnd_message.set_token('TABLE_NAME','hr_person_deployments');
316        fnd_message.raise_error;
317     End If;
318     Close C_Sel2;
319     --
320     -- Use registered key values and clear globals
321     --
322     p_rec.person_deployment_id :=
323       hr_pdt_ins.g_person_deployment_id_i;
324     hr_pdt_ins.g_person_deployment_id_i := null;
325   Else
326     --
327     -- No registerd key values, so select the next sequence number
328     --
329     --
330     -- Select the next sequence number
331     --
332     Open C_Sel1;
333     Fetch C_Sel1 Into p_rec.person_deployment_id;
334     Close C_Sel1;
335   End If;
336   --
337   hr_utility.set_location(' Leaving:'||l_proc, 10);
338 End pre_insert;
339 --
340 -- ----------------------------------------------------------------------------
341 -- |-----------------------------< post_insert >------------------------------|
342 -- ----------------------------------------------------------------------------
343 -- {Start Of Comments}
344 --
345 -- Description:
346 --   This private procedure contains any processing which is required after
347 --   the insert dml.
348 --
349 -- Prerequisites:
350 --   This is an internal procedure which is called from the ins procedure.
351 --
352 -- In Parameters:
353 --   A Pl/Sql record structre.
354 --
355 -- Post Success:
356 --   Processing continues.
357 --
358 -- Post Failure:
359 --   If an error has occurred, an error message and exception will be raised
360 --   but not handled.
361 --
362 -- Developer Implementation Notes:
363 --   Any post-processing required after the insert dml is issued should be
364 --   coded within this procedure. It is important to note that any 3rd party
365 --   maintenance should be reviewed before placing in this procedure.
366 --
367 -- Access Status:
368 --   Internal Row Handler Use Only.
369 --
370 -- {End Of Comments}
371 -- ----------------------------------------------------------------------------
372 Procedure post_insert
373   (p_rec                          in hr_pdt_shd.g_rec_type
374   ) is
375 --
376   l_proc  varchar2(72) := g_package||'post_insert';
377 --
378 Begin
379   hr_utility.set_location('Entering:'||l_proc, 5);
380   begin
381     --
382     hr_pdt_rki.after_insert
383       (p_person_deployment_id
384       => p_rec.person_deployment_id
385       ,p_object_version_number
386       => p_rec.object_version_number
387       ,p_from_business_group_id
388       => p_rec.from_business_group_id
389       ,p_to_business_group_id
390       => p_rec.to_business_group_id
391       ,p_from_person_id
392       => p_rec.from_person_id
393       ,p_to_person_id
394       => p_rec.to_person_id
395       ,p_person_type_id
396       => p_rec.person_type_id
397       ,p_start_date
398       => p_rec.start_date
399       ,p_end_date
400       => p_rec.end_date
401       ,p_deployment_reason
402       => p_rec.deployment_reason
403       ,p_employee_number
404       => p_rec.employee_number
405       ,p_leaving_reason
406       => p_rec.leaving_reason
407       ,p_leaving_person_type_id
408       => p_rec.leaving_person_type_id
409       ,p_permanent
410       => p_rec.permanent
411       ,p_status
412       => p_rec.status
413       ,p_status_change_reason
414       => p_rec.status_change_reason
415       ,p_status_change_date
416       => p_rec.status_change_date
417       ,p_deplymt_policy_id
418       => p_rec.deplymt_policy_id
419       ,p_organization_id
420       => p_rec.organization_id
421       ,p_location_id
422       => p_rec.location_id
423       ,p_job_id
424       => p_rec.job_id
425       ,p_position_id
426       => p_rec.position_id
427       ,p_grade_id
428       => p_rec.grade_id
429       ,p_supervisor_id
430       => p_rec.supervisor_id
431       ,p_supervisor_assignment_id
432       => p_rec.supervisor_assignment_id
433       ,p_retain_direct_reports
434       => p_rec.retain_direct_reports
435       ,p_payroll_id
436       => p_rec.payroll_id
437       ,p_pay_basis_id
438       => p_rec.pay_basis_id
439       ,p_proposed_salary
440       => p_rec.proposed_salary
441       ,p_people_group_id
442       => p_rec.people_group_id
443       ,p_soft_coding_keyflex_id
444       => p_rec.soft_coding_keyflex_id
445       ,p_assignment_status_type_id
446       => p_rec.assignment_status_type_id
447       ,p_ass_status_change_reason
448       => p_rec.ass_status_change_reason
449       ,p_assignment_category
450       => p_rec.assignment_category
451       ,p_per_information_category
452       => p_rec.per_information_category
453       ,p_per_information1
454       => p_rec.per_information1
455       ,p_per_information2
456       => p_rec.per_information2
457       ,p_per_information3
458       => p_rec.per_information3
459       ,p_per_information4
460       => p_rec.per_information4
461       ,p_per_information5
462       => p_rec.per_information5
463       ,p_per_information6
464       => p_rec.per_information6
465       ,p_per_information7
466       => p_rec.per_information7
467       ,p_per_information8
468       => p_rec.per_information8
469       ,p_per_information9
470       => p_rec.per_information9
471       ,p_per_information10
472       => p_rec.per_information10
473       ,p_per_information11
474       => p_rec.per_information11
475       ,p_per_information12
476       => p_rec.per_information12
477       ,p_per_information13
478       => p_rec.per_information13
479       ,p_per_information14
480       => p_rec.per_information14
481       ,p_per_information15
482       => p_rec.per_information15
483       ,p_per_information16
484       => p_rec.per_information16
485       ,p_per_information17
486       => p_rec.per_information17
487       ,p_per_information18
488       => p_rec.per_information18
489       ,p_per_information19
490       => p_rec.per_information19
491       ,p_per_information20
492       => p_rec.per_information20
493       ,p_per_information21
494       => p_rec.per_information21
495       ,p_per_information22
496       => p_rec.per_information22
497       ,p_per_information23
498       => p_rec.per_information23
499       ,p_per_information24
500       => p_rec.per_information24
501       ,p_per_information25
502       => p_rec.per_information25
503       ,p_per_information26
504       => p_rec.per_information26
505       ,p_per_information27
506       => p_rec.per_information27
507       ,p_per_information28
508       => p_rec.per_information28
509       ,p_per_information29
510       => p_rec.per_information29
511       ,p_per_information30
512       => p_rec.per_information30
513       );
514     --
515   exception
516     --
517     when hr_api.cannot_find_prog_unit then
518       --
519       hr_api.cannot_find_prog_unit_error
520         (p_module_name => 'HR_PERSON_DEPLOYMENTS'
521         ,p_hook_type   => 'AI');
522       --
523   end;
524   --
525   hr_utility.set_location(' Leaving:'||l_proc, 10);
526 End post_insert;
527 --
528 -- ----------------------------------------------------------------------------
529 -- |---------------------------------< ins >----------------------------------|
530 -- ----------------------------------------------------------------------------
531 Procedure ins
532   (p_rec                          in out nocopy hr_pdt_shd.g_rec_type
533   ) is
534 --
535   l_proc  varchar2(72) := g_package||'ins';
536 --
537 Begin
538   hr_utility.set_location('Entering:'||l_proc, 5);
539   --
540   -- Call the supporting insert validate operations
541   --
542   hr_pdt_bus.insert_validate
543      (p_rec
544      );
545   --
546   -- Call to raise any errors on multi-message list
547   hr_multi_message.end_validation_set;
548   --
549   -- Set the status_change_date
550   --
551   p_rec.status_change_date := trunc(sysdate);
552   --
553   -- Call the supporting pre-insert operation
554   --
555   hr_pdt_ins.pre_insert(p_rec);
556   --
557   -- Insert the row
558   --
559   hr_pdt_ins.insert_dml(p_rec);
560   --
561   -- Call the supporting post-insert operation
562   --
563   hr_pdt_ins.post_insert
564      (p_rec
565      );
566   --
567   -- Call to raise any errors on multi-message list
568   hr_multi_message.end_validation_set;
569   --
570   hr_utility.set_location('Leaving:'||l_proc, 20);
571 end ins;
572 --
573 -- ----------------------------------------------------------------------------
574 -- |---------------------------------< ins >----------------------------------|
575 -- ----------------------------------------------------------------------------
576 Procedure ins
577   (p_from_business_group_id         in     number
578   ,p_to_business_group_id           in     number
579   ,p_from_person_id                 in     number
580   ,p_person_type_id                 in     number
581   ,p_start_date                     in     date
582   ,p_status                         in     varchar2
583   ,p_to_person_id                   in     number   default null
584   ,p_end_date                       in     date     default null
585   ,p_deployment_reason              in     varchar2 default null
586   ,p_employee_number                in     varchar2 default null
587   ,p_leaving_reason                 in     varchar2 default null
588   ,p_leaving_person_type_id         in     number   default null
589   ,p_permanent                      in     varchar2 default null
590   ,p_status_change_reason           in     varchar2 default null
591   ,p_deplymt_policy_id              in     number   default null
592   ,p_organization_id                in     number   default null
593   ,p_location_id                    in     number   default null
594   ,p_job_id                         in     number   default null
595   ,p_position_id                    in     number   default null
596   ,p_grade_id                       in     number   default null
597   ,p_supervisor_id                  in     number   default null
598   ,p_supervisor_assignment_id       in     number   default null
599   ,p_retain_direct_reports          in     varchar2 default null
600   ,p_payroll_id                     in     number   default null
601   ,p_pay_basis_id                   in     number   default null
602   ,p_proposed_salary                in     varchar2 default null
603   ,p_people_group_id                in     number   default null
604   ,p_soft_coding_keyflex_id         in     number   default null
605   ,p_assignment_status_type_id      in     number   default null
606   ,p_ass_status_change_reason       in     varchar2 default null
607   ,p_assignment_category            in     varchar2 default null
608   ,p_per_information_category       in     varchar2 default null
609   ,p_per_information1               in     varchar2 default null
610   ,p_per_information2               in     varchar2 default null
611   ,p_per_information3               in     varchar2 default null
612   ,p_per_information4               in     varchar2 default null
613   ,p_per_information5               in     varchar2 default null
614   ,p_per_information6               in     varchar2 default null
615   ,p_per_information7               in     varchar2 default null
616   ,p_per_information8               in     varchar2 default null
617   ,p_per_information9               in     varchar2 default null
618   ,p_per_information10              in     varchar2 default null
619   ,p_per_information11              in     varchar2 default null
620   ,p_per_information12              in     varchar2 default null
621   ,p_per_information13              in     varchar2 default null
622   ,p_per_information14              in     varchar2 default null
623   ,p_per_information15              in     varchar2 default null
624   ,p_per_information16              in     varchar2 default null
625   ,p_per_information17              in     varchar2 default null
626   ,p_per_information18              in     varchar2 default null
627   ,p_per_information19              in     varchar2 default null
628   ,p_per_information20              in     varchar2 default null
629   ,p_per_information21              in     varchar2 default null
630   ,p_per_information22              in     varchar2 default null
631   ,p_per_information23              in     varchar2 default null
632   ,p_per_information24              in     varchar2 default null
633   ,p_per_information25              in     varchar2 default null
634   ,p_per_information26              in     varchar2 default null
635   ,p_per_information27              in     varchar2 default null
636   ,p_per_information28              in     varchar2 default null
637   ,p_per_information29              in     varchar2 default null
638   ,p_per_information30              in     varchar2 default null
639   ,p_person_deployment_id              out nocopy number
640   ,p_object_version_number             out nocopy number
641   ) is
642 --
643   l_rec   hr_pdt_shd.g_rec_type;
644   l_proc  varchar2(72) := g_package||'ins';
645 --
646 Begin
647   hr_utility.set_location('Entering:'||l_proc, 5);
648   --
649   -- Call conversion function to turn arguments into the
650   -- p_rec structure.
651   --
652   l_rec :=
653   hr_pdt_shd.convert_args
654     (null
655     ,null
656     ,p_from_business_group_id
657     ,p_to_business_group_id
658     ,p_from_person_id
659     ,p_to_person_id
660     ,p_person_type_id
661     ,p_start_date
662     ,p_end_date
663     ,p_deployment_reason
664     ,p_employee_number
665     ,p_leaving_reason
666     ,p_leaving_person_type_id
667     ,p_permanent
668     ,p_status
669     ,p_status_change_reason
670     ,null
671     ,p_deplymt_policy_id
672     ,p_organization_id
673     ,p_location_id
674     ,p_job_id
675     ,p_position_id
676     ,p_grade_id
677     ,p_supervisor_id
678     ,p_supervisor_assignment_id
679     ,p_retain_direct_reports
680     ,p_payroll_id
681     ,p_pay_basis_id
682     ,p_proposed_salary
683     ,p_people_group_id
684     ,p_soft_coding_keyflex_id
685     ,p_assignment_status_type_id
686     ,p_ass_status_change_reason
687     ,p_assignment_category
688     ,p_per_information_category
689     ,p_per_information1
690     ,p_per_information2
691     ,p_per_information3
692     ,p_per_information4
693     ,p_per_information5
694     ,p_per_information6
695     ,p_per_information7
696     ,p_per_information8
697     ,p_per_information9
698     ,p_per_information10
699     ,p_per_information11
700     ,p_per_information12
701     ,p_per_information13
702     ,p_per_information14
703     ,p_per_information15
704     ,p_per_information16
705     ,p_per_information17
706     ,p_per_information18
707     ,p_per_information19
708     ,p_per_information20
709     ,p_per_information21
710     ,p_per_information22
711     ,p_per_information23
712     ,p_per_information24
713     ,p_per_information25
714     ,p_per_information26
715     ,p_per_information27
716     ,p_per_information28
717     ,p_per_information29
718     ,p_per_information30
719     );
720   --
721   -- Having converted the arguments into the hr_pdt_rec
722   -- plsql record structure we call the corresponding record business process.
723   --
724   hr_pdt_ins.ins
725      (l_rec
726      );
727   --
728   -- As the primary key argument(s)
729   -- are specified as an OUT's we must set these values.
730   --
731   p_person_deployment_id := l_rec.person_deployment_id;
732   p_object_version_number := l_rec.object_version_number;
733   --
734   hr_utility.set_location(' Leaving:'||l_proc, 10);
735 End ins;
736 --
737 end hr_pdt_ins;