DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_APT_INS

Source


1 Package Body per_apt_ins as
2 /* $Header: peaptrhi.pkb 120.10.12020000.1 2012/06/29 00:43:57 appldev ship $ */
3 
4 -- ---------------------------------------------------------------------------+
5 -- |                     Private Global Definitions                           |
9 --
6 -- ---------------------------------------------------------------------------+
7 
8 g_package  varchar2(33)	:= '  per_apt_ins.';  -- Global package name
10 -- The following global variables are only to be used by
11 -- the set_base_key_value and pre_insert procedures.
12 --
13 g_appraisal_template_id_i number default null;
14 --
15 --
16 -- ----------------------------------------------------------------------------
17 -- |------------------------< set_base_key_value >----------------------------|
18 -- ----------------------------------------------------------------------------
19 procedure set_base_key_value
20   (p_appraisal_template_id  in  number) is
21 --
22   l_proc       varchar2(72) := g_package||'set_base_key_value';
23 --
24 Begin
25   hr_utility.set_location('Entering:'||l_proc, 10);
26   --
27   per_apt_ins.g_appraisal_template_id_i := p_appraisal_template_id;
28   --
29   hr_utility.set_location(' Leaving:'||l_proc, 20);
30 End set_base_key_value;
31 --
32 --
33 
34 -- ---------------------------------------------------------------------------+
35 -- |------------------------------< insert_dml >------------------------------|
36 -- ---------------------------------------------------------------------------+
37 -- {Start Of Comments}
38 
39 -- Description:
40 --   This procedure controls the actual dml insert logic. The processing of
41 --   this procedure are as follows:
42 --   1) Initialise the object_version_number to 1 if the object_version_number
43 --      is defined as an attribute for this entity.
44 --   2) To insert the row into the schema.
45 --   3) To trap any constraint violations that may have occurred.
46 --   4) To raise any other errors.
47 
48 -- Pre Conditions:
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 --   If a check, unique or parent integrity constraint violation is raised the
61 --   constraint_error procedure will be called.
62 
63 -- Developer Implementation Notes:
64 --   None.
65 
66 -- Access Status:
67 --   Internal Table Handler Use Only.
68 
69 -- {End Of Comments}
70 -- ---------------------------------------------------------------------------+
71 Procedure insert_dml(p_rec in out nocopy per_apt_shd.g_rec_type) is
72 
73   l_proc  varchar2(72) := g_package||'insert_dml';
74 
75 Begin
76   hr_utility.set_location('Entering:'||l_proc, 5);
77   p_rec.object_version_number := 1;  -- Initialise the object version
78 
79 
80   -- Insert the row into: per_appraisal_templates
81 
82   insert into per_appraisal_templates
83   (	appraisal_template_id,
84 	business_group_id,
85 	object_version_number,
86 	name,
87 	description,
88 	instructions,
89 	date_from,
90 	date_to,
91 	assessment_type_id,
92 	rating_scale_id,
93 	questionnaire_template_id,
94 	attribute_category,
95 	attribute1,
96 	attribute2,
97 	attribute3,
98 	attribute4,
99 	attribute5,
100 	attribute6,
101 	attribute7,
102 	attribute8,
103 	attribute9,
104 	attribute10,
105 	attribute11,
106 	attribute12,
107 	attribute13,
108 	attribute14,
109 	attribute15,
110 	attribute16,
111 	attribute17,
112 	attribute18,
113 	attribute19,
114 	attribute20,
115 	objective_asmnt_type_id,
116         ma_quest_template_id,
117         link_appr_to_learning_path,
118         final_score_formula_id,
119         update_personal_comp_profile,
120         comp_profile_source_type,
121         show_competency_ratings,
122         show_objective_ratings,
123         show_overall_ratings,
124         show_overall_comments,
125         provide_overall_feedback,
126         show_participant_details,
127         allow_add_participant,
128         show_additional_details,
129         show_participant_names,
130         show_participant_ratings,
131         available_flag,
132 	show_questionnaire_info,
133   ma_off_template_code,
134 	appraisee_off_template_code,
135 	other_part_off_template_code,
136 	part_app_off_template_code,
137 	part_rev_off_template_code,
138                           show_participant_comments -- 8651478 bug fix
139 ,show_term_employee
140 ,show_term_contigent
141 ,disp_term_emp_period_from
142 ,show_future_term_employee
143 
144   )
145   Values
146   (	p_rec.appraisal_template_id,
147 	p_rec.business_group_id,
148 	p_rec.object_version_number,
149 	p_rec.name,
150 	p_rec.description,
151 	p_rec.instructions,
152 	p_rec.date_from,
153 	p_rec.date_to,
154 	p_rec.assessment_type_id,
155 	p_rec.rating_scale_id,
156 	p_rec.questionnaire_template_id,
157 	p_rec.attribute_category,
158 	p_rec.attribute1,
159 	p_rec.attribute2,
160 	p_rec.attribute3,
161 	p_rec.attribute4,
162 	p_rec.attribute5,
163 	p_rec.attribute6,
164 	p_rec.attribute7,
165 	p_rec.attribute8,
166 	p_rec.attribute9,
167 	p_rec.attribute10,
168 	p_rec.attribute11,
169 	p_rec.attribute12,
170 	p_rec.attribute13,
171 	p_rec.attribute14,
172 	p_rec.attribute15,
173 	p_rec.attribute16,
174 	p_rec.attribute17,
175 	p_rec.attribute18,
176 	p_rec.attribute19,
177 	p_rec.attribute20,
178 	p_rec.objective_asmnt_type_id,
179         p_rec.ma_quest_template_id,
180         p_rec.link_appr_to_learning_path,
181         p_rec.final_score_formula_id,
182         p_rec.update_personal_comp_profile,
183         p_rec.comp_profile_source_type,
184         p_rec.show_competency_ratings,
185         p_rec.show_objective_ratings,
186         p_rec.show_overall_ratings,
187         p_rec.show_overall_comments,
188         p_rec.provide_overall_feedback,
189         p_rec.show_participant_details,
190         p_rec.allow_add_participant,
191         p_rec.show_additional_details,
192         p_rec.show_participant_names,
193         p_rec.show_participant_ratings,
194         p_rec.available_flag,
195 	p_rec.show_questionnaire_info,
196   p_rec.ma_off_template_code,
197 	p_rec.appraisee_off_template_code,
198 	p_rec.other_part_off_template_code,
199 	p_rec.part_app_off_template_code,
200 	p_rec.part_rev_off_template_code,
201                          p_rec.show_participant_comments  -- 8651478 bug fix
202 ,p_rec.show_term_employee
203 ,p_rec.show_term_contigent
204 ,p_rec.disp_term_emp_period_from
205 ,p_rec.show_future_term_employee
206 
207   );
208 
209   hr_utility.set_location(' Leaving:'||l_proc, 10);
210 Exception
211   When hr_api.check_integrity_violated Then
212     -- A check constraint has been violated
213     per_apt_shd.constraint_error
214       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
215   When hr_api.parent_integrity_violated Then
216     -- Parent integrity has been violated
217     per_apt_shd.constraint_error
218       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
219   When hr_api.unique_integrity_violated Then
220     -- Unique integrity has been violated
221     per_apt_shd.constraint_error
222       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
223   When Others Then
224     Raise;
225 End insert_dml;
226 
227 -- ---------------------------------------------------------------------------+
228 -- |------------------------------< pre_insert >------------------------------|
229 -- ---------------------------------------------------------------------------+
230 -- {Start Of Comments}
231 
232 -- Description:
233 --   This private procedure contains any processing which is required before
234 --   the insert dml. Presently, if the entity has a corresponding primary
235 --   key which is maintained by an associating sequence, the primary key for
236 --   the entity will be populated with the next sequence value in
237 --   preparation for the insert dml.
238 
239 -- Pre Conditions:
240 --   This is an internal procedure which is called from the ins procedure.
241 
242 -- In Parameters:
243 --   A Pl/Sql record structre.
244 
245 -- Post Success:
246 --   Processing continues.
247 
248 -- Post Failure:
249 --   If an error has occurred, an error message and exception will be raised
250 --   but not handled.
251 
252 -- Developer Implementation Notes:
253 --   Any pre-processing required before the insert dml is issued should be
254 --   coded within this procedure. As stated above, a good example is the
255 --   generation of a primary key number via a corresponding sequence.
256 --   It is important to note that any 3rd party maintenance should be reviewed
257 --   before placing in this procedure.
258 
259 -- Access Status:
260 --   Internal Table Handler Use Only.
261 
262 -- {End Of Comments}
263 -- ---------------------------------------------------------------------------+
264 Procedure pre_insert(p_rec  in out nocopy per_apt_shd.g_rec_type) is
265 
266   l_proc  varchar2(72) := g_package||'pre_insert';
267   l_exists      varchar2(1);
268 
269   Cursor C_Sel1 is select per_appraisal_templates_s.nextval from sys.dual;
270 
271 Cursor C_Sel2 is
272    select null from per_appraisal_templates
273         where appraisal_template_id  = per_apt_ins.g_appraisal_template_id_i;
274 
275 Begin
276   hr_utility.set_location('Entering:'||l_proc, 5);
277 
278 
279   -- Select the next sequence number
280 if (per_apt_ins.g_appraisal_template_id_i is not null ) then
281  Open C_Sel2;
282    Fetch C_Sel2 Into l_exists;
283    if C_Sel2%Found then
284       Close C_Sel2;
285       --
286       -- The primary key values are already in use.
287       --
288       fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
289       fnd_message.set_token('TABLE_NAME','PER_APPRAISAL_TEMPLATES');
290       fnd_message.raise_error;
291     End If;
292     Close C_Sel2;
293     --
294     -- Use registered key values and clear globals
295     --
296     p_rec.appraisal_template_id  := per_apt_ins.g_appraisal_template_id_i;
297     per_apt_ins.g_appraisal_template_id_i := null;
298 
299  Else
300   Open C_Sel1;
301   Fetch C_Sel1 Into p_rec.appraisal_template_id;
302   Close C_Sel1;
303  end if;
304   hr_utility.set_location(' Leaving:'||l_proc, 10);
305 End pre_insert;
306 
307 -- ---------------------------------------------------------------------------+
308 -- |-----------------------------< post_insert >------------------------------|
309 -- ---------------------------------------------------------------------------+
310 -- {Start Of Comments}
311 
312 -- Description:
313 --   This private procedure contains any processing which is required after the
314 --   insert dml.
315 
316 -- Pre Conditions:
317 --   This is an internal procedure which is called from the ins procedure.
318 
319 -- In Parameters:
320 --   A Pl/Sql record structre.
321 
322 -- Post Success:
323 --   Processing continues.
324 
325 -- Post Failure:
326 --   If an error has occurred, an error message and exception will be raised
327 --   but not handled.
328 
329 -- Developer Implementation Notes:
330 --   Any post-processing required after the insert dml is issued should be
331 --   coded within this procedure. It is important to note that any 3rd party
332 --   maintenance should be reviewed before placing in this procedure.
333 
334 -- Access Status:
335 --   Internal Table Handler Use Only.
336 
337 -- {End Of Comments}
338 -- ---------------------------------------------------------------------------+
339 Procedure post_insert(p_rec in per_apt_shd.g_rec_type) is
340 
341   l_proc  varchar2(72) := g_package||'post_insert';
342 
343 Begin
344   hr_utility.set_location('Entering:'||l_proc, 5);
345 
346   -- This is a hook point and the user hook for post_insert is called here.
347 
348   begin
349      per_apt_rki.after_insert	(
350        p_appraisal_template_id        => p_rec.appraisal_template_id  ,
351        p_business_group_id            => p_rec.business_group_id      ,
352        p_object_version_number        => p_rec.object_version_number  ,
353        p_name                         => p_rec.name                   ,
354        p_description                  => p_rec.description            ,
355        p_instructions                 => p_rec.instructions           ,
356        p_date_from                    => p_rec.date_from              ,
357        p_date_to                      => p_rec.date_to                ,
358        p_assessment_type_id           => p_rec.assessment_type_id        ,
359        p_rating_scale_id              => p_rec.rating_scale_id           ,
360        p_questionnaire_template_id    => p_rec.questionnaire_template_id ,
361        p_attribute_category           => p_rec.attribute_category        ,
362        p_attribute1                   => p_rec.attribute1   ,
363        p_attribute2                   => p_rec.attribute2   ,
364        p_attribute3                   => p_rec.attribute3   ,
365        p_attribute4                   => p_rec.attribute4   ,
366        p_attribute5                   => p_rec.attribute5   ,
367        p_attribute6                   => p_rec.attribute6   ,
368        p_attribute7                   => p_rec.attribute7   ,
369        p_attribute8                   => p_rec.attribute8   ,
370        p_attribute9                   => p_rec.attribute9   ,
371        p_attribute10                  => p_rec.attribute10  ,
372        p_attribute11                  => p_rec.attribute11  ,
373        p_attribute12                  => p_rec.attribute12  ,
374        p_attribute13                  => p_rec.attribute13  ,
375        p_attribute14                  => p_rec.attribute14  ,
376        p_attribute15                  => p_rec.attribute15  ,
377        p_attribute16                  => p_rec.attribute16  ,
378        p_attribute17                  => p_rec.attribute17  ,
379        p_attribute18                  => p_rec.attribute18  ,
380        p_attribute19                  => p_rec.attribute19  ,
381        p_attribute20                  => p_rec.attribute20 ,
382       p_objective_asmnt_type_id      => p_rec.objective_asmnt_type_id,
383       p_ma_quest_template_id      => p_rec.ma_quest_template_id,
384       p_link_appr_to_learning_path      => p_rec.link_appr_to_learning_path,
385       p_final_score_formula_id      => p_rec.final_score_formula_id,
386       p_update_personal_comp_profile      => p_rec.update_personal_comp_profile,
387       p_comp_profile_source_type      => p_rec.comp_profile_source_type,
388       p_show_competency_ratings      => p_rec.show_competency_ratings,
389       p_show_objective_ratings      => p_rec.show_objective_ratings,
390       p_show_overall_ratings      => p_rec.show_overall_ratings,
391       p_show_overall_comments      => p_rec.show_overall_comments,
392       p_provide_overall_feedback      => p_rec.provide_overall_feedback,
393       p_show_participant_details      => p_rec.show_participant_details,
394       p_allow_add_participant      => p_rec.allow_add_participant,
395       p_show_additional_details      => p_rec.show_additional_details,
396       p_show_participant_names      => p_rec.show_participant_names,
397       p_show_participant_ratings      => p_rec.show_participant_ratings,
398       p_available_flag      => p_rec.available_flag,
399       p_show_questionnaire_info      => p_rec.show_questionnaire_info,
400       p_ma_off_template_code			   =>	p_rec.ma_off_template_code,
401 	    p_appraisee_off_template_code	 =>	p_rec.appraisee_off_template_code,
402 	    p_other_part_off_template_code	 =>	p_rec.other_part_off_template_code,
403 	    p_part_app_off_template_code	 =>	p_rec.part_app_off_template_code,
404 	    p_part_rev_off_template_code	 =>	p_rec.part_rev_off_template_code,
405                               p_show_participant_comments     => p_rec.show_participant_comments -- 8651478 bug fix
406 
407     ,p_show_term_employee           => p_rec.show_term_employee  -- 6181267 bug fix
408     ,p_show_term_contigent          => p_rec.show_term_contigent   -- 6181267 bug fix
409     ,p_disp_term_emp_period_from    => p_rec.disp_term_emp_period_from   -- 6181267 bug fix
410     ,p_show_future_term_employee         => p_rec.show_future_term_employee -- 6181267 bug fix
411 
412       );
413      exception
414         when hr_api.cannot_find_prog_unit then
415              hr_api.cannot_find_prog_unit_error
416 		 (	 p_module_name => 'PER_APPRAISAL_TEMPLATES'
417 			,p_hook_type   => 'AI'
418 	        );
419   end;
420   -- End of API User Hook for post_insert.
421 
422   hr_utility.set_location(' Leaving:'||l_proc, 10);
423 End post_insert;
424 
425 -- ---------------------------------------------------------------------------+
426 -- |---------------------------------< ins >----------------------------------|
427 -- ---------------------------------------------------------------------------+
428 Procedure ins
429   (
430   p_rec        		in out nocopy per_apt_shd.g_rec_type,
431   p_effective_date	in date ,
432   p_validate   		in boolean default false
433   ) is
434 
435   l_proc  varchar2(72) := g_package||'ins';
436 
437 Begin
438   hr_utility.set_location('Entering:'||l_proc, 5);
439 
440   -- Determine if the business process is to be validated.
441 
442   If p_validate then
443 
444     -- Issue the savepoint.
445 
446     SAVEPOINT ins_per_apt;
447   End If;
448 
449   -- Call the supporting insert validate operations
450 
451   per_apt_bus.insert_validate(p_rec,p_effective_date);
452 
453   -- Call the supporting pre-insert operation
454 
455   pre_insert(p_rec);
456 
457   -- Insert the row
458 
459   insert_dml(p_rec);
460 
461   -- Call the supporting post-insert operation
462 
463   post_insert(p_rec);
464 
465   -- If we are validating then raise the Validate_Enabled exception
466 
467   If p_validate then
468     Raise HR_Api.Validate_Enabled;
469   End If;
470 
471   hr_utility.set_location(' Leaving:'||l_proc, 10);
472 Exception
473   When HR_Api.Validate_Enabled Then
474 
475     -- As the Validate_Enabled exception has been raised
476     -- we must rollback to the savepoint
477 
478     ROLLBACK TO ins_per_apt;
479 end ins;
480 
481 -- ---------------------------------------------------------------------------+
482 -- |---------------------------------< ins >----------------------------------|
483 -- ---------------------------------------------------------------------------+
484 Procedure ins
485   (
486   p_appraisal_template_id        out nocopy number,
487   p_business_group_id            in number,
488   p_object_version_number        out nocopy number,
489   p_name                         in varchar2,
490   p_description                  in varchar2         default null,
491   p_instructions                 in varchar2         default null,
492   p_date_from                    in date             default null,
493   p_date_to                      in date             default null,
494   p_assessment_type_id           in number           default null,
495   p_rating_scale_id              in number           default null,
496   p_questionnaire_template_id    in number           default null,
497   p_attribute_category           in varchar2         default null,
498   p_attribute1                   in varchar2         default null,
499   p_attribute2                   in varchar2         default null,
500   p_attribute3                   in varchar2         default null,
501   p_attribute4                   in varchar2         default null,
502   p_attribute5                   in varchar2         default null,
503   p_attribute6                   in varchar2         default null,
504   p_attribute7                   in varchar2         default null,
505   p_attribute8                   in varchar2         default null,
506   p_attribute9                   in varchar2         default null,
507   p_attribute10                  in varchar2         default null,
508   p_attribute11                  in varchar2         default null,
509   p_attribute12                  in varchar2         default null,
510   p_attribute13                  in varchar2         default null,
511   p_attribute14                  in varchar2         default null,
512   p_attribute15                  in varchar2         default null,
513   p_attribute16                  in varchar2         default null,
514   p_attribute17                  in varchar2         default null,
515   p_attribute18                  in varchar2         default null,
516   p_attribute19                  in varchar2         default null,
517   p_attribute20                  in varchar2         default null,
518   p_objective_asmnt_type_id        in     number   default null,
519   p_ma_quest_template_id           in     number   default null,
520   p_link_appr_to_learning_path     in     varchar2 default null,
521   p_final_score_formula_id         in     number   default null,
522   p_update_personal_comp_profile   in     varchar2 default null,
523   p_comp_profile_source_type       in     varchar2 default null,
524   p_show_competency_ratings        in     varchar2 default null,
525   p_show_objective_ratings         in     varchar2 default null,
526   p_show_overall_ratings           in     varchar2 default null,
527   p_show_overall_comments          in     varchar2 default null,
528   p_provide_overall_feedback       in     varchar2 default null,
529   p_show_participant_details       in     varchar2 default null,
530   p_allow_add_participant          in     varchar2 default null,
531   p_show_additional_details        in     varchar2 default null,
532   p_show_participant_names         in     varchar2 default null,
533   p_show_participant_ratings       in     varchar2 default null,
534   p_available_flag                 in     varchar2 default null,
535   p_show_questionnaire_info       in     varchar2 default null,
536   p_effective_date		 in date
537   ,p_ma_off_template_code		      in varchar2	  default null
538   ,p_appraisee_off_template_code	in varchar2	  default null
539   ,p_other_part_off_template_code in varchar2	  default null
540   ,p_part_app_off_template_code	  in varchar2	  default null
541   ,p_part_rev_off_template_code	  in varchar2	  default null,
542   p_validate                     in boolean   default false ,
543   p_show_participant_comments     in varchar2            default null  -- 8651478 bug fix
544   ,p_show_term_employee            in varchar2            default null  -- 6181267 bug fix
545   ,p_show_term_contigent           in varchar2            default null  -- 6181267 bug fix
546   ,p_disp_term_emp_period_from     in     number            default null  -- 6181267 bug fix
547   ,p_show_future_term_employee          in varchar2            default null  -- 6181267 bug fix
548 
549   ) is
550 
551   l_rec	  per_apt_shd.g_rec_type;
552   l_proc  varchar2(72) := g_package||'ins';
553 
554 Begin
555   hr_utility.set_location('Entering:'||l_proc, 5);
556 
557   -- Call conversion function to turn arguments into the
558   -- p_rec structure.
559 
560   l_rec :=
561   per_apt_shd.convert_args
562   (
563   null,
564   p_business_group_id,
565   null,
566   p_name,
567   p_description,
568   p_instructions,
569   p_date_from,
570   p_date_to,
571   p_assessment_type_id,
572   p_rating_scale_id,
573   p_questionnaire_template_id,
574   p_attribute_category,
575   p_attribute1,
576   p_attribute2,
577   p_attribute3,
578   p_attribute4,
579   p_attribute5,
580   p_attribute6,
581   p_attribute7,
582   p_attribute8,
583   p_attribute9,
584   p_attribute10,
585   p_attribute11,
586   p_attribute12,
587   p_attribute13,
588   p_attribute14,
589   p_attribute15,
590   p_attribute16,
591   p_attribute17,
592   p_attribute18,
593   p_attribute19,
594   p_attribute20,
595   p_objective_asmnt_type_id,
596   p_ma_quest_template_id,
597   p_link_appr_to_learning_path,
598   p_final_score_formula_id,
599   p_update_personal_comp_profile,
600   p_comp_profile_source_type,
601   p_show_competency_ratings,
602   p_show_objective_ratings,
603   p_show_overall_ratings,
604   p_show_overall_comments,
605   p_provide_overall_feedback,
606   p_show_participant_details,
607   p_allow_add_participant,
608   p_show_additional_details,
609   p_show_participant_names,
610   p_show_participant_ratings,
611   p_available_flag,
612   p_show_questionnaire_info,
613   p_ma_off_template_code,
614   p_appraisee_off_template_code,
615   p_other_part_off_template_code,
616   p_part_app_off_template_code,
617   p_part_rev_off_template_code,
618   p_show_participant_comments    -- 8651478 bug fix
619     ,p_show_term_employee        -- 6181267 bug fix
620     ,p_show_term_contigent         -- 6181267 bug fix
621     ,p_disp_term_emp_period_from    -- 6181267 bug fix
622     ,p_show_future_term_employee        -- 6181267 bug fix
623   );
624 
625   -- Having converted the arguments into the per_apt_rec
626   -- plsql record structure we call the corresponding record business process.
627 
628   ins(l_rec,p_effective_date, p_validate);
629 
630   -- As the primary key argument(s)
631   -- are specified as an OUT's we must set these values.
632 
633   p_appraisal_template_id := l_rec.appraisal_template_id;
634   p_object_version_number := l_rec.object_version_number;
635 
636   hr_utility.set_location(' Leaving:'||l_proc, 10);
637 End ins;
638 
639 end per_apt_ins;