1 Package Body psp_prt_ins as
2 /* $Header: PSPRTRHB.pls 120.1 2005/07/05 23:50 dpaudel noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' psp_prt_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_template_id_i number default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19 (p_template_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 psp_prt_ins.g_template_id_i := p_template_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 psp_prt_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 psp_prt_shd.g_api_dml := true; -- Set the api dml status
86 --
87 -- Insert the row into: psp_report_templates
88 --
89 insert into psp_report_templates
90 (template_id
91 ,template_name
92 ,business_group_id
93 ,set_of_books_id
94 ,object_version_number
95 ,report_type
96 ,period_frequency_id
97 ,report_template_code
98 ,display_all_emp_distrib_flag
99 ,manual_entry_override_flag
100 ,approval_type
101 ,custom_approval_code
102 ,sup_levels
103 ,preview_effort_report_flag
104 ,notification_reminder_in_days
105 ,sprcd_tolerance_amt
106 ,sprcd_tolerance_percent
107 ,description
108 ,legislation_code
109 ,hundred_pcent_eff_at_per_asg
110 ,selection_match_level
111 )
112 Values
113 (p_rec.template_id
114 ,p_rec.template_name
115 ,p_rec.business_group_id
116 ,p_rec.set_of_books_id
117 ,p_rec.object_version_number
118 ,p_rec.report_type
119 ,p_rec.period_frequency_id
120 ,p_rec.report_template_code
121 ,p_rec.display_all_emp_distrib_flag
122 ,p_rec.manual_entry_override_flag
123 ,p_rec.approval_type
124 ,p_rec.custom_approval_code
125 ,p_rec.sup_levels
126 ,p_rec.preview_effort_report_flag
127 ,p_rec.notification_reminder_in_days
128 ,p_rec.sprcd_tolerance_amt
129 ,p_rec.sprcd_tolerance_percent
130 ,p_rec.description
131 ,p_rec.legislation_code
132 ,p_rec.hundred_pcent_eff_at_per_asg
133 ,p_rec.selection_match_level
134 );
135 --
136 psp_prt_shd.g_api_dml := false; -- Unset the api dml status
137 --
138 hr_utility.set_location(' Leaving:'||l_proc, 10);
139 Exception
140 When hr_api.check_integrity_violated Then
141 -- A check constraint has been violated
142 psp_prt_shd.g_api_dml := false; -- Unset the api dml status
143 psp_prt_shd.constraint_error
144 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
145 When hr_api.parent_integrity_violated Then
146 -- Parent integrity has been violated
147 psp_prt_shd.g_api_dml := false; -- Unset the api dml status
148 psp_prt_shd.constraint_error
149 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
150 When hr_api.unique_integrity_violated Then
151 -- Unique integrity has been violated
152 psp_prt_shd.g_api_dml := false; -- Unset the api dml status
153 psp_prt_shd.constraint_error
154 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
155 When Others Then
156 psp_prt_shd.g_api_dml := false; -- Unset the api dml status
157 Raise;
158 End insert_dml;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |------------------------------< pre_insert >------------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 -- This private procedure contains any processing which is required before
167 -- the insert dml. Presently, if the entity has a corresponding primary
168 -- key which is maintained by an associating sequence, the primary key for
169 -- the entity will be populated with the next sequence value in
170 -- preparation for the insert dml.
171 --
172 -- Prerequisites:
173 -- This is an internal procedure which is called from the ins procedure.
174 --
175 -- In Parameters:
176 -- A Pl/Sql record structure.
177 --
178 -- Post Success:
179 -- Processing continues.
180 --
181 -- Post Failure:
182 -- If an error has occurred, an error message and exception will be raised
183 -- but not handled.
184 --
185 -- Developer Implementation Notes:
186 -- Any pre-processing required before the insert dml is issued should be
187 -- coded within this procedure. As stated above, a good example is the
188 -- generation of a primary key number via a corresponding sequence.
189 -- It is important to note that any 3rd party maintenance should be reviewed
190 -- before placing in this procedure.
191 --
192 -- Access Status:
193 -- Internal Row Handler Use Only.
194 --
195 -- {End Of Comments}
196 -- ----------------------------------------------------------------------------
197 Procedure pre_insert
198 (p_rec in out nocopy psp_prt_shd.g_rec_type
199 ) is
200 --
201 Cursor C_Sel1 is select psp_report_templates_s.nextval from sys.dual;
202 --
203 Cursor C_Sel2 is
204 Select null
205 from psp_report_templates
206 where template_id =
207 psp_prt_ins.g_template_id_i;
208 --
209 l_proc varchar2(72) := g_package||'pre_insert';
210 l_exists varchar2(1);
211 --
212 Begin
213 hr_utility.set_location('Entering:'||l_proc, 5);
214 --
215 If (psp_prt_ins.g_template_id_i is not null) Then
216 --
217 -- Verify registered primary key values not already in use
218 --
219 Open C_Sel2;
220 Fetch C_Sel2 into l_exists;
221 If C_Sel2%found Then
222 Close C_Sel2;
223 --
224 -- The primary key values are already in use.
225 --
226 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
227 fnd_message.set_token('TABLE_NAME','psp_report_templates');
228 fnd_message.raise_error;
229 End If;
230 Close C_Sel2;
231 --
232 -- Use registered key values and clear globals
233 --
234 p_rec.template_id :=
235 psp_prt_ins.g_template_id_i;
236 psp_prt_ins.g_template_id_i := null;
237 Else
238 --
239 -- No registerd key values, so select the next sequence number
240 --
241 --
242 -- Select the next sequence number
243 --
244 Open C_Sel1;
245 Fetch C_Sel1 Into p_rec.template_id;
246 Close C_Sel1;
247 End If;
248 --
249 hr_utility.set_location(' Leaving:'||l_proc, 10);
250 End pre_insert;
251 --
252 -- ----------------------------------------------------------------------------
253 -- |-----------------------------< post_insert >------------------------------|
254 -- ----------------------------------------------------------------------------
255 -- {Start Of Comments}
256 --
257 -- Description:
258 -- This private procedure contains any processing which is required after
259 -- the insert dml.
260 --
261 -- Prerequisites:
262 -- This is an internal procedure which is called from the ins procedure.
263 --
264 -- In Parameters:
265 -- A Pl/Sql record structre.
266 --
267 -- Post Success:
268 -- Processing continues.
269 --
270 -- Post Failure:
271 -- If an error has occurred, an error message and exception will be raised
272 -- but not handled.
273 --
274 -- Developer Implementation Notes:
275 -- Any post-processing required after the insert dml is issued should be
276 -- coded within this procedure. It is important to note that any 3rd party
277 -- maintenance should be reviewed before placing in this procedure.
278 --
279 -- Access Status:
280 -- Internal Row Handler Use Only.
281 --
282 -- {End Of Comments}
283 -- ----------------------------------------------------------------------------
284 Procedure post_insert
285 (p_rec in psp_prt_shd.g_rec_type
286 ) is
287 --
288 l_proc varchar2(72) := g_package||'post_insert';
289 --
290 Begin
291 hr_utility.set_location('Entering:'||l_proc, 5);
292 begin
293 --
294 psp_prt_rki.after_insert
295 (p_template_id
296 => p_rec.template_id
297 ,p_template_name
298 => p_rec.template_name
299 ,p_business_group_id
300 => p_rec.business_group_id
301 ,p_set_of_books_id
302 => p_rec.set_of_books_id
303 ,p_object_version_number
304 => p_rec.object_version_number
305 ,p_report_type
306 => p_rec.report_type
307 ,p_period_frequency_id
308 => p_rec.period_frequency_id
309 ,p_report_template_code
310 => p_rec.report_template_code
311 ,p_display_all_emp_distrib_flag
312 => p_rec.display_all_emp_distrib_flag
313 ,p_manual_entry_override_flag
314 => p_rec.manual_entry_override_flag
315 ,p_approval_type
316 => p_rec.approval_type
317 ,p_custom_approval_code
318 => p_rec.custom_approval_code
319 ,p_sup_levels
320 => p_rec.sup_levels
321 ,p_preview_effort_report_flag
322 => p_rec.preview_effort_report_flag
323 ,p_notification_reminder_in_day
324 => p_rec.notification_reminder_in_days
325 ,p_sprcd_tolerance_amt
326 => p_rec.sprcd_tolerance_amt
327 ,p_sprcd_tolerance_percent
328 => p_rec.sprcd_tolerance_percent
329 ,p_description
330 => p_rec.description
331 ,p_legislation_code
332 => p_rec.legislation_code
333 ,p_hundred_pcent_eff_at_per_asg
334 => p_rec.hundred_pcent_eff_at_per_asg
335 ,p_selection_match_level
336 => p_rec.selection_match_level
337 );
338 --
339 exception
340 --
341 when hr_api.cannot_find_prog_unit then
342 --
343 hr_api.cannot_find_prog_unit_error
344 (p_module_name => 'PSP_REPORT_TEMPLATES'
345 ,p_hook_type => 'AI');
346 --
347 end;
348 --
349 hr_utility.set_location(' Leaving:'||l_proc, 10);
350 End post_insert;
351 --
352 -- ----------------------------------------------------------------------------
353 -- |---------------------------------< ins >----------------------------------|
354 -- ----------------------------------------------------------------------------
355 Procedure ins
356 (p_rec in out nocopy psp_prt_shd.g_rec_type
357 ) is
358 --
359 l_proc varchar2(72) := g_package||'ins';
360 --
361 Begin
362 hr_utility.set_location('Entering:'||l_proc, 5);
363 --
364 -- Call the supporting insert validate operations
365 --
366 psp_prt_bus.insert_validate
367 (p_rec
368 );
369 --
370 -- Call to raise any errors on multi-message list
371 hr_multi_message.end_validation_set;
372 --
373 -- Call the supporting pre-insert operation
374 --
375 psp_prt_ins.pre_insert(p_rec);
376 --
377 -- Insert the row
378 --
379 psp_prt_ins.insert_dml(p_rec);
380 --
381 -- Call the supporting post-insert operation
382 --
383 psp_prt_ins.post_insert
384 (p_rec
385 );
386 --
387 -- Call to raise any errors on multi-message list
388 hr_multi_message.end_validation_set;
389 --
390 hr_utility.set_location('Leaving:'||l_proc, 20);
391 end ins;
392 --
393 -- ----------------------------------------------------------------------------
394 -- |---------------------------------< ins >----------------------------------|
395 -- ----------------------------------------------------------------------------
396 Procedure ins
397 (p_template_name in varchar2
398 ,p_business_group_id in number
399 ,p_set_of_books_id in number
400 ,p_report_type in varchar2
401 ,p_period_frequency_id in number
402 ,p_report_template_code in varchar2
403 ,p_approval_type in varchar2
404 ,p_preview_effort_report_flag in varchar2
405 ,p_hundred_pcent_eff_at_per_asg in varchar2
406 ,p_selection_match_level in varchar2
407 ,p_display_all_emp_distrib_flag in varchar2 default null
408 ,p_manual_entry_override_flag in varchar2 default null
409 ,p_custom_approval_code in varchar2 default null
410 ,p_sup_levels in number default null
411 ,p_notification_reminder_in_day in number default null
412 ,p_sprcd_tolerance_amt in number default null
413 ,p_sprcd_tolerance_percent in number default null
414 ,p_description in varchar2 default null
415 ,p_legislation_code in varchar2 default null
416 ,p_template_id in number
417 ,p_object_version_number out nocopy number
418 ) is
419 --
420 l_rec psp_prt_shd.g_rec_type;
421 l_proc varchar2(72) := g_package||'ins';
422 --
423 Begin
424 hr_utility.set_location('Entering:'||l_proc, 5);
425 --
426 -- Call conversion function to turn arguments into the
427 -- p_rec structure.
428 --
429 l_rec :=
430 psp_prt_shd.convert_args
431 (null
432 ,p_template_name
433 ,p_business_group_id
434 ,p_set_of_books_id
435 ,null
436 ,p_report_type
437 ,p_period_frequency_id
438 ,p_report_template_code
439 ,p_display_all_emp_distrib_flag
440 ,p_manual_entry_override_flag
441 ,p_approval_type
442 ,p_custom_approval_code
443 ,p_sup_levels
444 ,p_preview_effort_report_flag
445 ,p_notification_reminder_in_day
446 ,p_sprcd_tolerance_amt
447 ,p_sprcd_tolerance_percent
448 ,p_description
449 ,p_legislation_code
450 ,p_hundred_pcent_eff_at_per_asg
451 ,p_selection_match_level
452 );
453 --
454 -- Having converted the arguments into the psp_prt_rec
455 -- plsql record structure we call the corresponding record business process.
456 --
457 psp_prt_ins.ins
458 (l_rec
459 );
460 --
461 -- As the primary key argument(s)
462 -- are specified as an OUT's we must set these values.
463 --
464 -- p_template_id := l_rec.template_id;
465 p_object_version_number := l_rec.object_version_number;
466 --
467 hr_utility.set_location(' Leaving:'||l_proc, 10);
468 End ins;
469 --
470 end psp_prt_ins;