[Home] [Help]
PACKAGE BODY: APPS.BEN_CWG_INS
Source
1 Package Body ben_cwg_ins as
2 /* $Header: becwgrhi.pkb 120.0 2005/05/28 01:29:54 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_cwg_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_cwb_wksht_grp_id_i number default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19 (p_cwb_wksht_grp_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 ben_cwg_ins.g_cwb_wksht_grp_id_i := p_cwb_wksht_grp_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 ben_cwg_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: ben_cwb_wksht_grp
88 --
89 insert into ben_cwb_wksht_grp
90 (cwb_wksht_grp_id
91 ,business_group_id
92 ,pl_id
93 ,ordr_num
94 ,wksht_grp_cd
95 ,label
96 ,cwg_attribute_category
97 ,cwg_attribute1
98 ,cwg_attribute2
99 ,cwg_attribute3
100 ,cwg_attribute4
101 ,cwg_attribute5
102 ,cwg_attribute6
103 ,cwg_attribute7
104 ,cwg_attribute8
105 ,cwg_attribute9
106 ,cwg_attribute10
107 ,cwg_attribute11
108 ,cwg_attribute12
109 ,cwg_attribute13
110 ,cwg_attribute14
111 ,cwg_attribute15
112 ,cwg_attribute16
113 ,cwg_attribute17
114 ,cwg_attribute18
115 ,cwg_attribute19
116 ,cwg_attribute20
117 ,cwg_attribute21
118 ,cwg_attribute22
119 ,cwg_attribute23
120 ,cwg_attribute24
121 ,cwg_attribute25
122 ,cwg_attribute26
123 ,cwg_attribute27
124 ,cwg_attribute28
125 ,cwg_attribute29
126 ,cwg_attribute30
127 ,status_cd
128 ,hidden_cd
129 ,object_version_number
130 )
131 Values
132 (p_rec.cwb_wksht_grp_id
133 ,p_rec.business_group_id
134 ,p_rec.pl_id
135 ,p_rec.ordr_num
136 ,p_rec.wksht_grp_cd
137 ,p_rec.label
138 ,p_rec.cwg_attribute_category
139 ,p_rec.cwg_attribute1
140 ,p_rec.cwg_attribute2
141 ,p_rec.cwg_attribute3
142 ,p_rec.cwg_attribute4
143 ,p_rec.cwg_attribute5
144 ,p_rec.cwg_attribute6
145 ,p_rec.cwg_attribute7
146 ,p_rec.cwg_attribute8
147 ,p_rec.cwg_attribute9
148 ,p_rec.cwg_attribute10
149 ,p_rec.cwg_attribute11
150 ,p_rec.cwg_attribute12
151 ,p_rec.cwg_attribute13
152 ,p_rec.cwg_attribute14
153 ,p_rec.cwg_attribute15
154 ,p_rec.cwg_attribute16
155 ,p_rec.cwg_attribute17
156 ,p_rec.cwg_attribute18
157 ,p_rec.cwg_attribute19
158 ,p_rec.cwg_attribute20
159 ,p_rec.cwg_attribute21
160 ,p_rec.cwg_attribute22
161 ,p_rec.cwg_attribute23
162 ,p_rec.cwg_attribute24
163 ,p_rec.cwg_attribute25
164 ,p_rec.cwg_attribute26
165 ,p_rec.cwg_attribute27
166 ,p_rec.cwg_attribute28
167 ,p_rec.cwg_attribute29
168 ,p_rec.cwg_attribute30
169 ,p_rec.status_cd
170 ,p_rec.hidden_cd
171 ,p_rec.object_version_number
172 );
173 --
174 --
175 --
176 hr_utility.set_location(' Leaving:'||l_proc, 10);
177 Exception
178 When hr_api.check_integrity_violated Then
179 -- A check constraint has been violated
180 --
181 ben_cwg_shd.constraint_error
182 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
183 When hr_api.parent_integrity_violated Then
184 -- Parent integrity has been violated
185 --
186 ben_cwg_shd.constraint_error
187 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
188 When hr_api.unique_integrity_violated Then
189 -- Unique integrity has been violated
190 --
191 ben_cwg_shd.constraint_error
192 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
193 When Others Then
194 --
195 Raise;
196 End insert_dml;
197 --
198 -- ----------------------------------------------------------------------------
199 -- |------------------------------< pre_insert >------------------------------|
200 -- ----------------------------------------------------------------------------
201 -- {Start Of Comments}
202 --
203 -- Description:
204 -- This private procedure contains any processing which is required before
205 -- the insert dml. Presently, if the entity has a corresponding primary
206 -- key which is maintained by an associating sequence, the primary key for
207 -- the entity will be populated with the next sequence value in
208 -- preparation for the insert dml.
209 --
210 -- Prerequisites:
211 -- This is an internal procedure which is called from the ins procedure.
212 --
213 -- In Parameters:
214 -- A Pl/Sql record structure.
215 --
216 -- Post Success:
217 -- Processing continues.
218 --
219 -- Post Failure:
220 -- If an error has occurred, an error message and exception will be raised
221 -- but not handled.
222 --
223 -- Developer Implementation Notes:
224 -- Any pre-processing required before the insert dml is issued should be
225 -- coded within this procedure. As stated above, a good example is the
226 -- generation of a primary key number via a corresponding sequence.
227 -- It is important to note that any 3rd party maintenance should be reviewed
228 -- before placing in this procedure.
229 --
230 -- Access Status:
231 -- Internal Row Handler Use Only.
232 --
233 -- {End Of Comments}
234 -- ----------------------------------------------------------------------------
235 Procedure pre_insert
236 (p_rec in out nocopy ben_cwg_shd.g_rec_type
237 ) is
238 --
239 Cursor C_Sel1 is select ben_cwb_wksht_grp_s.nextval from sys.dual;
240 --
241 Cursor C_Sel2 is
242 Select null
243 from ben_cwb_wksht_grp
244 where cwb_wksht_grp_id =
245 ben_cwg_ins.g_cwb_wksht_grp_id_i;
246 --
247 l_proc varchar2(72) := g_package||'pre_insert';
248 l_exists varchar2(1);
249 --
250 Begin
251 hr_utility.set_location('Entering:'||l_proc, 5);
252 --
253 If (ben_cwg_ins.g_cwb_wksht_grp_id_i is not null) Then
254 --
255 -- Verify registered primary key values not already in use
256 --
257 Open C_Sel2;
258 Fetch C_Sel2 into l_exists;
259 If C_Sel2%found Then
260 Close C_Sel2;
261 --
262 -- The primary key values are already in use.
263 --
264 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
265 fnd_message.set_token('TABLE_NAME','ben_cwb_wksht_grp');
266 fnd_message.raise_error;
267 End If;
268 Close C_Sel2;
269 --
270 -- Use registered key values and clear globals
271 --
272 p_rec.cwb_wksht_grp_id :=
273 ben_cwg_ins.g_cwb_wksht_grp_id_i;
274 ben_cwg_ins.g_cwb_wksht_grp_id_i := null;
275 Else
276 --
277 -- No registerd key values, so select the next sequence number
278 --
279 --
280 -- Select the next sequence number
281 --
282 Open C_Sel1;
283 Fetch C_Sel1 Into p_rec.cwb_wksht_grp_id;
284 Close C_Sel1;
285 End If;
286 --
287 hr_utility.set_location(' Leaving:'||l_proc, 10);
288 End pre_insert;
289 --
290 -- ----------------------------------------------------------------------------
291 -- |-----------------------------< post_insert >------------------------------|
292 -- ----------------------------------------------------------------------------
293 -- {Start Of Comments}
294 --
295 -- Description:
296 -- This private procedure contains any processing which is required after
297 -- the insert dml.
298 --
299 -- Prerequisites:
300 -- This is an internal procedure which is called from the ins procedure.
301 --
302 -- In Parameters:
303 -- A Pl/Sql record structre.
304 --
305 -- Post Success:
306 -- Processing continues.
307 --
308 -- Post Failure:
309 -- If an error has occurred, an error message and exception will be raised
310 -- but not handled.
311 --
312 -- Developer Implementation Notes:
313 -- Any post-processing required after the insert dml is issued should be
314 -- coded within this procedure. It is important to note that any 3rd party
315 -- maintenance should be reviewed before placing in this procedure.
316 --
317 -- Access Status:
318 -- Internal Row Handler Use Only.
319 --
320 -- {End Of Comments}
321 -- ----------------------------------------------------------------------------
322 Procedure post_insert
323 (p_effective_date in date
324 ,p_rec in ben_cwg_shd.g_rec_type
325 ) is
326 --
327 l_proc varchar2(72) := g_package||'post_insert';
328 --
329 Begin
330 hr_utility.set_location('Entering:'||l_proc, 5);
331 begin
332 --
333 ben_cwg_rki.after_insert
334 (p_effective_date => p_effective_date
335 ,p_cwb_wksht_grp_id
336 => p_rec.cwb_wksht_grp_id
337 ,p_business_group_id
338 => p_rec.business_group_id
339 ,p_pl_id
340 => p_rec.pl_id
341 ,p_ordr_num
342 => p_rec.ordr_num
343 ,p_wksht_grp_cd
344 => p_rec.wksht_grp_cd
345 ,p_label
346 => p_rec.label
347 ,p_cwg_attribute_category
348 => p_rec.cwg_attribute_category
349 ,p_cwg_attribute1
350 => p_rec.cwg_attribute1
351 ,p_cwg_attribute2
352 => p_rec.cwg_attribute2
353 ,p_cwg_attribute3
354 => p_rec.cwg_attribute3
355 ,p_cwg_attribute4
356 => p_rec.cwg_attribute4
357 ,p_cwg_attribute5
358 => p_rec.cwg_attribute5
359 ,p_cwg_attribute6
360 => p_rec.cwg_attribute6
361 ,p_cwg_attribute7
362 => p_rec.cwg_attribute7
363 ,p_cwg_attribute8
364 => p_rec.cwg_attribute8
365 ,p_cwg_attribute9
366 => p_rec.cwg_attribute9
367 ,p_cwg_attribute10
368 => p_rec.cwg_attribute10
369 ,p_cwg_attribute11
370 => p_rec.cwg_attribute11
371 ,p_cwg_attribute12
372 => p_rec.cwg_attribute12
373 ,p_cwg_attribute13
374 => p_rec.cwg_attribute13
375 ,p_cwg_attribute14
376 => p_rec.cwg_attribute14
377 ,p_cwg_attribute15
378 => p_rec.cwg_attribute15
379 ,p_cwg_attribute16
380 => p_rec.cwg_attribute16
381 ,p_cwg_attribute17
382 => p_rec.cwg_attribute17
383 ,p_cwg_attribute18
384 => p_rec.cwg_attribute18
385 ,p_cwg_attribute19
386 => p_rec.cwg_attribute19
387 ,p_cwg_attribute20
388 => p_rec.cwg_attribute20
389 ,p_cwg_attribute21
390 => p_rec.cwg_attribute21
391 ,p_cwg_attribute22
392 => p_rec.cwg_attribute22
393 ,p_cwg_attribute23
394 => p_rec.cwg_attribute23
395 ,p_cwg_attribute24
396 => p_rec.cwg_attribute24
397 ,p_cwg_attribute25
398 => p_rec.cwg_attribute25
399 ,p_cwg_attribute26
400 => p_rec.cwg_attribute26
401 ,p_cwg_attribute27
402 => p_rec.cwg_attribute27
403 ,p_cwg_attribute28
404 => p_rec.cwg_attribute28
405 ,p_cwg_attribute29
406 => p_rec.cwg_attribute29
407 ,p_cwg_attribute30
408 => p_rec.cwg_attribute30
409 ,p_status_cd => p_rec.status_cd
410 ,p_hidden_cd => p_rec.hidden_cd
411 ,p_object_version_number
412 => p_rec.object_version_number
413 );
414 --
415 exception
416 --
417 when hr_api.cannot_find_prog_unit then
418 --
419 hr_api.cannot_find_prog_unit_error
420 (p_module_name => 'BEN_CWB_WKSHT_GRP'
421 ,p_hook_type => 'AI');
422 --
423 end;
424 --
425 hr_utility.set_location(' Leaving:'||l_proc, 10);
426 End post_insert;
427 --
428 -- ----------------------------------------------------------------------------
429 -- |---------------------------------< ins >----------------------------------|
430 -- ----------------------------------------------------------------------------
431 Procedure ins
432 (p_effective_date in date
433 ,p_rec in out nocopy ben_cwg_shd.g_rec_type
434 ) is
435 --
436 l_proc varchar2(72) := g_package||'ins';
437 --
438 Begin
439 hr_utility.set_location('Entering:'||l_proc, 5);
440 --
441 -- Call the supporting insert validate operations
442 --
443 ben_cwg_bus.insert_validate
444 (p_effective_date
445 ,p_rec
446 );
447 --
448 -- Call to raise any errors on multi-message list
449 hr_multi_message.end_validation_set;
450 --
451 -- Call the supporting pre-insert operation
452 --
453 ben_cwg_ins.pre_insert(p_rec);
454 --
455 -- Insert the row
456 --
457 ben_cwg_ins.insert_dml(p_rec);
458 --
459 -- Call the supporting post-insert operation
460 --
461 ben_cwg_ins.post_insert
462 (p_effective_date
463 ,p_rec
464 );
465 --
466 -- Call to raise any errors on multi-message list
467 hr_multi_message.end_validation_set;
468 --
469 hr_utility.set_location('Leaving:'||l_proc, 20);
470 end ins;
471 --
472 -- ----------------------------------------------------------------------------
473 -- |---------------------------------< ins >----------------------------------|
474 -- ----------------------------------------------------------------------------
475 Procedure ins
476 (p_effective_date in date
477 ,p_business_group_id in number
478 ,p_pl_id in number
479 ,p_ordr_num in number
480 ,p_wksht_grp_cd in varchar2
481 ,p_label in varchar2
482 ,p_cwg_attribute_category in varchar2 default null
483 ,p_cwg_attribute1 in varchar2 default null
484 ,p_cwg_attribute2 in varchar2 default null
485 ,p_cwg_attribute3 in varchar2 default null
486 ,p_cwg_attribute4 in varchar2 default null
487 ,p_cwg_attribute5 in varchar2 default null
488 ,p_cwg_attribute6 in varchar2 default null
489 ,p_cwg_attribute7 in varchar2 default null
490 ,p_cwg_attribute8 in varchar2 default null
491 ,p_cwg_attribute9 in varchar2 default null
492 ,p_cwg_attribute10 in varchar2 default null
493 ,p_cwg_attribute11 in varchar2 default null
494 ,p_cwg_attribute12 in varchar2 default null
495 ,p_cwg_attribute13 in varchar2 default null
496 ,p_cwg_attribute14 in varchar2 default null
497 ,p_cwg_attribute15 in varchar2 default null
498 ,p_cwg_attribute16 in varchar2 default null
499 ,p_cwg_attribute17 in varchar2 default null
500 ,p_cwg_attribute18 in varchar2 default null
501 ,p_cwg_attribute19 in varchar2 default null
502 ,p_cwg_attribute20 in varchar2 default null
503 ,p_cwg_attribute21 in varchar2 default null
504 ,p_cwg_attribute22 in varchar2 default null
505 ,p_cwg_attribute23 in varchar2 default null
506 ,p_cwg_attribute24 in varchar2 default null
507 ,p_cwg_attribute25 in varchar2 default null
508 ,p_cwg_attribute26 in varchar2 default null
509 ,p_cwg_attribute27 in varchar2 default null
510 ,p_cwg_attribute28 in varchar2 default null
511 ,p_cwg_attribute29 in varchar2 default null
512 ,p_cwg_attribute30 in varchar2 default null
513 ,p_status_cd in varchar2 default null
514 ,p_hidden_cd in varchar2 default null
515 ,p_cwb_wksht_grp_id out nocopy number
516 ,p_object_version_number out nocopy number
517 ) is
518 --
519 l_rec ben_cwg_shd.g_rec_type;
520 l_proc varchar2(72) := g_package||'ins';
521 --
522 Begin
523 hr_utility.set_location('Entering:'||l_proc, 5);
524 --
525 -- Call conversion function to turn arguments into the
526 -- p_rec structure.
527 --
528 l_rec :=
529 ben_cwg_shd.convert_args
530 (null
531 ,p_business_group_id
532 ,p_pl_id
533 ,p_ordr_num
534 ,p_wksht_grp_cd
535 ,p_label
536 ,p_cwg_attribute_category
537 ,p_cwg_attribute1
538 ,p_cwg_attribute2
539 ,p_cwg_attribute3
540 ,p_cwg_attribute4
541 ,p_cwg_attribute5
542 ,p_cwg_attribute6
543 ,p_cwg_attribute7
544 ,p_cwg_attribute8
545 ,p_cwg_attribute9
546 ,p_cwg_attribute10
547 ,p_cwg_attribute11
548 ,p_cwg_attribute12
549 ,p_cwg_attribute13
550 ,p_cwg_attribute14
551 ,p_cwg_attribute15
552 ,p_cwg_attribute16
553 ,p_cwg_attribute17
554 ,p_cwg_attribute18
555 ,p_cwg_attribute19
556 ,p_cwg_attribute20
557 ,p_cwg_attribute21
558 ,p_cwg_attribute22
559 ,p_cwg_attribute23
560 ,p_cwg_attribute24
561 ,p_cwg_attribute25
562 ,p_cwg_attribute26
563 ,p_cwg_attribute27
564 ,p_cwg_attribute28
565 ,p_cwg_attribute29
566 ,p_cwg_attribute30
567 ,p_status_cd
568 ,p_hidden_cd
569 ,null
570 );
571 --
572 -- Having converted the arguments into the ben_cwg_rec
573 -- plsql record structure we call the corresponding record business process.
574 --
575 ben_cwg_ins.ins
576 (p_effective_date
577 ,l_rec
578 );
579 --
580 -- As the primary key argument(s)
581 -- are specified as an OUT's we must set these values.
582 --
583 p_cwb_wksht_grp_id := l_rec.cwb_wksht_grp_id;
584 p_object_version_number := l_rec.object_version_number;
585 --
586 hr_utility.set_location(' Leaving:'||l_proc, 10);
587 End ins;
588 --
589 end ben_cwg_ins;