DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PMS_INS

Source


1 Package Body per_pms_ins as
2 /* $Header: pepmsrhi.pkb 120.2.12010000.2 2008/09/02 10:51:07 arumukhe ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_pms_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_scorecard_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_scorecard_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   per_pms_ins.g_scorecard_id_i := p_scorecard_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 per_pms_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: per_personal_scorecards
88   --
89   insert into per_personal_scorecards
90       (scorecard_id
91       ,object_version_number
92       ,scorecard_name
93       ,person_id
94       ,assignment_id
95       ,start_date
96       ,end_date
97       ,plan_id
98       ,status_code
99       ,creator_type
100       ,error_log
101       ,attribute_category
102       ,attribute1
103       ,attribute2
104       ,attribute3
105       ,attribute4
106       ,attribute5
107       ,attribute6
108       ,attribute7
109       ,attribute8
110       ,attribute9
111       ,attribute10
112       ,attribute11
113       ,attribute12
114       ,attribute13
115       ,attribute14
116       ,attribute15
117       ,attribute16
118       ,attribute17
119       ,attribute18
120       ,attribute19
121       ,attribute20
122       ,attribute21
123       ,attribute22
124       ,attribute23
125       ,attribute24
126       ,attribute25
127       ,attribute26
128       ,attribute27
129       ,attribute28
130       ,attribute29
131       ,attribute30
132       )
133   Values
134     (p_rec.scorecard_id
135     ,p_rec.object_version_number
136     ,p_rec.scorecard_name
137     ,p_rec.person_id
138     ,p_rec.assignment_id
139     ,p_rec.start_date
140     ,p_rec.end_date
141     ,p_rec.plan_id
142     ,p_rec.status_code
143     ,p_rec.creator_type
144     ,p_rec.error_log
145     ,p_rec.attribute_category
146     ,p_rec.attribute1
147     ,p_rec.attribute2
148     ,p_rec.attribute3
149     ,p_rec.attribute4
150     ,p_rec.attribute5
151     ,p_rec.attribute6
152     ,p_rec.attribute7
153     ,p_rec.attribute8
154     ,p_rec.attribute9
155     ,p_rec.attribute10
156     ,p_rec.attribute11
157     ,p_rec.attribute12
158     ,p_rec.attribute13
159     ,p_rec.attribute14
160     ,p_rec.attribute15
161     ,p_rec.attribute16
162     ,p_rec.attribute17
163     ,p_rec.attribute18
164     ,p_rec.attribute19
165     ,p_rec.attribute20
166     ,p_rec.attribute21
167     ,p_rec.attribute22
168     ,p_rec.attribute23
169     ,p_rec.attribute24
170     ,p_rec.attribute25
171     ,p_rec.attribute26
172     ,p_rec.attribute27
173     ,p_rec.attribute28
174     ,p_rec.attribute29
175     ,p_rec.attribute30
176     );
177   --
178   --
179   --
180   hr_utility.set_location(' Leaving:'||l_proc, 10);
181 Exception
182   When hr_api.check_integrity_violated Then
183     -- A check constraint has been violated
184     --
185     per_pms_shd.constraint_error
186       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
187   When hr_api.parent_integrity_violated Then
188     -- Parent integrity has been violated
189     --
190     per_pms_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_pms_shd.constraint_error
196       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
197   When Others Then
198     --
199     Raise;
200 End insert_dml;
201 --
202 -- ----------------------------------------------------------------------------
203 -- |------------------------------< pre_insert >------------------------------|
204 -- ----------------------------------------------------------------------------
205 -- {Start Of Comments}
206 --
207 -- Description:
208 --   This private procedure contains any processing which is required before
209 --   the insert dml. Presently, if the entity has a corresponding primary
210 --   key which is maintained by an associating sequence, the primary key for
211 --   the entity will be populated with the next sequence value in
212 --   preparation for the insert dml.
213 --
214 -- Prerequisites:
215 --   This is an internal procedure which is called from the ins procedure.
216 --
217 -- In Parameters:
218 --   A Pl/Sql record structure.
219 --
220 -- Post Success:
221 --   Processing continues.
222 --
223 -- Post Failure:
224 --   If an error has occurred, an error message and exception will be raised
225 --   but not handled.
226 --
227 -- Developer Implementation Notes:
228 --   Any pre-processing required before the insert dml is issued should be
229 --   coded within this procedure. As stated above, a good example is the
230 --   generation of a primary key number via a corresponding sequence.
231 --   It is important to note that any 3rd party maintenance should be reviewed
232 --   before placing in this procedure.
233 --
234 -- Access Status:
235 --   Internal Row Handler Use Only.
236 --
237 -- {End Of Comments}
238 -- ----------------------------------------------------------------------------
239 Procedure pre_insert
240   (p_rec  in out nocopy per_pms_shd.g_rec_type
241   ) is
242 --
243   Cursor C_Sel1 is select per_personal_scorecards_s.nextval from sys.dual;
244 --
245   Cursor C_Sel2 is
246     Select null
247       from per_personal_scorecards
248      where scorecard_id =
249              per_pms_ins.g_scorecard_id_i;
250 --
251   l_proc   varchar2(72) := g_package||'pre_insert';
252   l_exists varchar2(1);
253 --
254 Begin
255   hr_utility.set_location('Entering:'||l_proc, 5);
256   --
257   If (per_pms_ins.g_scorecard_id_i is not null) Then
258     --
259     -- Verify registered primary key values not already in use
260     --
261     Open C_Sel2;
262     Fetch C_Sel2 into l_exists;
263     If C_Sel2%found Then
264        Close C_Sel2;
265        --
266        -- The primary key values are already in use.
267        --
268        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
269        fnd_message.set_token('TABLE_NAME','per_personal_scorecards');
270        fnd_message.raise_error;
271     End If;
272     Close C_Sel2;
273     --
274     -- Use registered key values and clear globals
275     --
276     p_rec.scorecard_id :=
277       per_pms_ins.g_scorecard_id_i;
278     per_pms_ins.g_scorecard_id_i := null;
279   Else
280     --
281     -- No registerd key values, so select the next sequence number
282     --
283     --
284     -- Select the next sequence number
285     --
286     Open C_Sel1;
287     Fetch C_Sel1 Into p_rec.scorecard_id;
288     Close C_Sel1;
289   End If;
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 structre.
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_effective_date               in date
328   ,p_rec                          in per_pms_shd.g_rec_type
329   ,p_duplicate_name_warning       in boolean
330   ) is
331 --
332   l_proc  varchar2(72) := g_package||'post_insert';
333 --
334 Begin
335   hr_utility.set_location('Entering:'||l_proc, 5);
336   begin
337     --
338     per_pms_rki.after_insert
339       (p_effective_date              => p_effective_date
340       ,p_scorecard_id
341       => p_rec.scorecard_id
342       ,p_object_version_number
343       => p_rec.object_version_number
344       ,p_scorecard_name
345       => p_rec.scorecard_name
346       ,p_person_id
347       => p_rec.person_id
348       ,p_assignment_id
349       => p_rec.assignment_id
350       ,p_start_date
351       => p_rec.start_date
352       ,p_end_date
353       => p_rec.end_date
354       ,p_plan_id
355       => p_rec.plan_id
356       ,p_creator_type
357       => p_rec.creator_type
358       ,p_error_log
359       => p_rec.error_log
360       ,p_attribute_category
361       => p_rec.attribute_category
362       ,p_attribute1
363       => p_rec.attribute1
364       ,p_attribute2
365       => p_rec.attribute2
366       ,p_attribute3
367       => p_rec.attribute3
368       ,p_attribute4
369       => p_rec.attribute4
370       ,p_attribute5
371       => p_rec.attribute5
372       ,p_attribute6
373       => p_rec.attribute6
374       ,p_attribute7
375       => p_rec.attribute7
376       ,p_attribute8
377       => p_rec.attribute8
378       ,p_attribute9
379       => p_rec.attribute9
380       ,p_attribute10
381       => p_rec.attribute10
382       ,p_attribute11
383       => p_rec.attribute11
384       ,p_attribute12
385       => p_rec.attribute12
386       ,p_attribute13
387       => p_rec.attribute13
388       ,p_attribute14
389       => p_rec.attribute14
390       ,p_attribute15
391       => p_rec.attribute15
392       ,p_attribute16
393       => p_rec.attribute16
394       ,p_attribute17
395       => p_rec.attribute17
396       ,p_attribute18
397       => p_rec.attribute18
398       ,p_attribute19
399       => p_rec.attribute19
400       ,p_attribute20
401       => p_rec.attribute20
402       ,p_attribute21
403       => p_rec.attribute21
404       ,p_attribute22
405       => p_rec.attribute22
406       ,p_attribute23
407       => p_rec.attribute23
408       ,p_attribute24
409       => p_rec.attribute24
410       ,p_attribute25
411       => p_rec.attribute25
412       ,p_attribute26
413       => p_rec.attribute26
414       ,p_attribute27
415       => p_rec.attribute27
416       ,p_attribute28
417       => p_rec.attribute28
418       ,p_attribute29
419       => p_rec.attribute29
420       ,p_attribute30
421       => p_rec.attribute30
422       ,p_status_code
423       => p_rec.status_code
424       ,p_duplicate_name_warning
425       => p_duplicate_name_warning
426       );
427     --
428   exception
429     --
430     when hr_api.cannot_find_prog_unit then
431       --
432       hr_api.cannot_find_prog_unit_error
433         (p_module_name => 'PER_PERSONAL_SCORECARDS'
434         ,p_hook_type   => 'AI');
435       --
436   end;
437   --
438   hr_utility.set_location(' Leaving:'||l_proc, 10);
442 -- |---------------------------------< ins >----------------------------------|
439 End post_insert;
440 --
441 -- ----------------------------------------------------------------------------
443 -- ----------------------------------------------------------------------------
444 Procedure ins
445   (p_effective_date               in date
446   ,p_rec                          in out nocopy per_pms_shd.g_rec_type
447   ,p_duplicate_name_warning          out nocopy boolean
448   ) is
449 --
450   l_proc      varchar2(72) := g_package||'ins';
451   l_person_id number;
452 --
453 Begin
454   hr_utility.set_location('Entering:'||l_proc, 5);
455   --
456   -- Call the supporting insert validate operations
457   --
458 
459   -- While inserting the status code should be one of the following two only.
460   IF (p_rec.status_code = 'NOT_STARTED_WITH_MGR' OR
461       p_rec.status_code = 'NOT_STARTED_WITH_WKR')
462   THEN
463      null;
464   ELSE
465      fnd_message.set_name('PER','HR_50271_PMS_STATUS_TP');
466      fnd_message.raise_error;
467   end if;
468   per_pms_bus.insert_validate
469      (p_effective_date         => p_effective_date
470      ,p_rec                    => p_rec
471      ,p_person_id              => l_person_id
472      ,p_duplicate_name_warning => p_duplicate_name_warning
473      );
474   --
475   -- person_id is not passed in, it is derived.
476   -- This is fetched during chk_assignment_id to prevent another
477   -- hit to per_all_assignments_f.
478   --
479   p_rec.person_id := l_person_id;
480 
481   --
482   -- Call to raise any errors on multi-message list
483   hr_multi_message.end_validation_set;
484   --
485   -- Call the supporting pre-insert operation
486   --
487   per_pms_ins.pre_insert(p_rec);
488   --
489   -- Insert the row
490   --
491   per_pms_ins.insert_dml(p_rec);
492   --
493   -- Call the supporting post-insert operation
494   --
495   per_pms_ins.post_insert
496      (p_effective_date         => p_effective_date
497      ,p_rec                    => p_rec
498      ,p_duplicate_name_warning => p_duplicate_name_warning
499      );
500   --
501   -- Call to raise any errors on multi-message list
502   hr_multi_message.end_validation_set;
503   --
504   hr_utility.set_location('Leaving:'||l_proc, 20);
505 end ins;
506 --
507 -- ----------------------------------------------------------------------------
508 -- |---------------------------------< ins >----------------------------------|
509 -- ----------------------------------------------------------------------------
510 Procedure ins
511   (p_effective_date               in     date
512   ,p_scorecard_name                 in     varchar2
513   ,p_assignment_id                  in     number
514   ,p_start_date                     in     date
515   ,p_end_date                       in     date
516   ,p_creator_type                   in     varchar2
517   ,p_plan_id                        in     number   default null
518   ,p_error_log                      in     varchar2 default null
519   ,p_attribute_category             in     varchar2 default null
520   ,p_attribute1                     in     varchar2 default null
521   ,p_attribute2                     in     varchar2 default null
522   ,p_attribute3                     in     varchar2 default null
523   ,p_attribute4                     in     varchar2 default null
524   ,p_attribute5                     in     varchar2 default null
525   ,p_attribute6                     in     varchar2 default null
526   ,p_attribute7                     in     varchar2 default null
527   ,p_attribute8                     in     varchar2 default null
528   ,p_attribute9                     in     varchar2 default null
529   ,p_attribute10                    in     varchar2 default null
530   ,p_attribute11                    in     varchar2 default null
531   ,p_attribute12                    in     varchar2 default null
532   ,p_attribute13                    in     varchar2 default null
533   ,p_attribute14                    in     varchar2 default null
534   ,p_attribute15                    in     varchar2 default null
535   ,p_attribute16                    in     varchar2 default null
536   ,p_attribute17                    in     varchar2 default null
537   ,p_attribute18                    in     varchar2 default null
538   ,p_attribute19                    in     varchar2 default null
539   ,p_attribute20                    in     varchar2 default null
540   ,p_attribute21                    in     varchar2 default null
541   ,p_attribute22                    in     varchar2 default null
542   ,p_attribute23                    in     varchar2 default null
543   ,p_attribute24                    in     varchar2 default null
544   ,p_attribute25                    in     varchar2 default null
545   ,p_attribute26                    in     varchar2 default null
546   ,p_attribute27                    in     varchar2 default null
547   ,p_attribute28                    in     varchar2 default null
548   ,p_attribute29                    in     varchar2 default null
549   ,p_attribute30                    in     varchar2 default null
550   ,p_scorecard_id                      out nocopy number
551   ,p_object_version_number             out nocopy number
552   ,p_status_code                    in     varchar2
553   ,p_duplicate_name_warning            out nocopy boolean
554   ) is
555 --
556   l_rec   per_pms_shd.g_rec_type;
557   l_proc  varchar2(72) := g_package||'ins';
558 --  l_STATUS_CODE  CONSTANT varchar2(11) := 'NOT_STARTED';
559 --
560 Begin
561   hr_utility.set_location('Entering:'||l_proc, 5);
562   --
563   -- Call conversion function to turn arguments into the
564   -- p_rec structure.
565   --
566   l_rec :=
567   per_pms_shd.convert_args
568     (null
569     ,null
570     ,p_scorecard_name
571     ,null --p_person_id (derived)
572     ,p_assignment_id
573     ,p_start_date
574     ,p_end_date
575     ,p_plan_id
576     ,p_status_code
577     ,p_creator_type
578     ,p_error_log
579     ,p_attribute_category
580     ,p_attribute1
581     ,p_attribute2
582     ,p_attribute3
583     ,p_attribute4
584     ,p_attribute5
585     ,p_attribute6
586     ,p_attribute7
587     ,p_attribute8
588     ,p_attribute9
589     ,p_attribute10
590     ,p_attribute11
591     ,p_attribute12
592     ,p_attribute13
593     ,p_attribute14
594     ,p_attribute15
595     ,p_attribute16
596     ,p_attribute17
597     ,p_attribute18
598     ,p_attribute19
599     ,p_attribute20
600     ,p_attribute21
601     ,p_attribute22
602     ,p_attribute23
603     ,p_attribute24
604     ,p_attribute25
605     ,p_attribute26
606     ,p_attribute27
607     ,p_attribute28
608     ,p_attribute29
609     ,p_attribute30
610     );
611   --
612   -- Having converted the arguments into the per_pms_rec
613   -- plsql record structure we call the corresponding record business process.
614   --
615   per_pms_ins.ins
616      (p_effective_date         => p_effective_date
617      ,p_rec                    => l_rec
618      ,p_duplicate_name_warning => p_duplicate_name_warning
619      );
620   --
621   -- As the primary key argument(s)
622   -- are specified as an OUT's we must set these values.
623   --
624   p_scorecard_id := l_rec.scorecard_id;
625   p_object_version_number := l_rec.object_version_number;
626   --p_status_code := l_rec.status_code;
627   --
628   hr_utility.set_location(' Leaving:'||l_proc, 10);
629 End ins;
630 --
631 end per_pms_ins;