DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BNR_INS

Source


1 Package Body ben_bnr_ins as
2 /* $Header: bebnrrhi.pkb 120.0 2005/05/28 00:46:03 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_bnr_ins.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< insert_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the actual dml insert logic. The processing of
17 --   this procedure are as follows:
18 --   1) Initialise the object_version_number to 1 if the object_version_number
19 --      is defined as an attribute for this entity.
20 --   2) To set and unset the g_api_dml status as required (as we are about to
21 --      perform dml).
22 --   3) To insert the row into the schema.
23 --   4) To trap any constraint violations that may have occurred.
24 --   5) To raise any other errors.
25 --
26 -- Prerequisites:
27 --   This is an internal private procedure which must be called from the ins
28 --   procedure and must have all mandatory attributes set (except the
29 --   object_version_number which is initialised within this procedure).
30 --
31 -- In Parameters:
32 --   A Pl/Sql record structre.
33 --
34 -- Post Success:
35 --   The specified row will be inserted into the schema.
36 --
37 -- Post Failure:
38 --   On the insert dml failure it is important to note that we always reset the
39 --   g_api_dml status to false.
40 --   If a check, unique or parent integrity constraint violation is raised the
41 --   constraint_error procedure will be called.
42 --   If any other error is reported, the error will be raised after the
43 --   g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 --   None.
47 --
48 -- Access Status:
49 --   Internal Row Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml(p_rec in out nocopy ben_bnr_shd.g_rec_type) is
54 --
55   l_proc  varchar2(72) := g_package||'insert_dml';
56   l_last_update_date   date := sysdate;
57   l_last_updated_by    number := fnd_global.user_id;
58   l_last_update_login  number := fnd_global.login_id;
59 
60 --
61 Begin
62   hr_utility.set_location('Entering:'||l_proc, 5);
63   p_rec.object_version_number := 1;  -- Initialise the object version
64   --
65   ben_bnr_shd.g_api_dml := true;  -- Set the api dml status
66   --
67   -- Insert the row into: ben_rptg_grp
68   --
69   insert into ben_rptg_grp
70   (	rptg_grp_id,
71 	name,
72 	business_group_id,
73 	rptg_prps_cd,
74 	rpg_desc,
75 	bnr_attribute_category,
76 	bnr_attribute1,
77 	bnr_attribute2,
78 	bnr_attribute3,
79 	bnr_attribute4,
80 	bnr_attribute5,
81 	bnr_attribute6,
82 	bnr_attribute7,
83 	bnr_attribute8,
84 	bnr_attribute9,
85 	bnr_attribute10,
86 	bnr_attribute11,
87 	bnr_attribute12,
88 	bnr_attribute13,
89 	bnr_attribute14,
90 	bnr_attribute15,
91 	bnr_attribute16,
92 	bnr_attribute17,
93 	bnr_attribute18,
94 	bnr_attribute19,
95 	bnr_attribute20,
96 	bnr_attribute21,
97 	bnr_attribute22,
98 	bnr_attribute23,
99 	bnr_attribute24,
100 	bnr_attribute25,
101 	bnr_attribute26,
102 	bnr_attribute27,
103 	bnr_attribute28,
104 	bnr_attribute29,
105 	bnr_attribute30,
106         function_code,
107         legislation_code,
108 	object_version_number,
109 	ordr_num                      --iRec
110   )
111   Values
112   (	p_rec.rptg_grp_id,
113 	p_rec.name,
114 	p_rec.business_group_id,
115 	p_rec.rptg_prps_cd,
116 	p_rec.rpg_desc,
117 	p_rec.bnr_attribute_category,
118 	p_rec.bnr_attribute1,
119 	p_rec.bnr_attribute2,
120 	p_rec.bnr_attribute3,
121 	p_rec.bnr_attribute4,
122 	p_rec.bnr_attribute5,
123 	p_rec.bnr_attribute6,
124 	p_rec.bnr_attribute7,
125 	p_rec.bnr_attribute8,
126 	p_rec.bnr_attribute9,
127 	p_rec.bnr_attribute10,
128 	p_rec.bnr_attribute11,
129 	p_rec.bnr_attribute12,
130 	p_rec.bnr_attribute13,
131 	p_rec.bnr_attribute14,
132 	p_rec.bnr_attribute15,
133 	p_rec.bnr_attribute16,
134 	p_rec.bnr_attribute17,
135 	p_rec.bnr_attribute18,
136 	p_rec.bnr_attribute19,
137 	p_rec.bnr_attribute20,
138 	p_rec.bnr_attribute21,
139 	p_rec.bnr_attribute22,
140 	p_rec.bnr_attribute23,
141 	p_rec.bnr_attribute24,
142 	p_rec.bnr_attribute25,
143 	p_rec.bnr_attribute26,
144 	p_rec.bnr_attribute27,
145 	p_rec.bnr_attribute28,
146 	p_rec.bnr_attribute29,
147 	p_rec.bnr_attribute30,
148         p_rec.function_code,
149         p_rec.legislation_code,
150 	p_rec.object_version_number,
151 	p_rec.ordr_num                      --iRec
152   );
153   --
154   -- insert into translation table
155    insert into ben_rptg_grp_tl (
156     rptg_grp_id,
157     function_code,
158     name,
159     language,
160     source_lang,
161     last_update_date,
162     last_updated_by,
163     last_update_login,
164     created_by,
165     creation_date
166   )
167   select
168     p_rec.rptg_grp_id,
169     p_rec.function_code,
170     p_rec.name,
171     l.language_code,
172     userenv('LANG'),
173     l_last_update_date,
174     l_last_updated_by,
175     l_last_update_login,
176     fnd_global.user_id,
177     sysdate
178   from fnd_languages l
179   where l.installed_flag in ('I', 'B')
180   and not exists
181     (select null
182     from ben_rptg_grp_tl t
183     where t.rptg_grp_id = p_rec.rptg_grp_id
184     and   t.language = l.language_code);
185   --
186   ben_bnr_shd.g_api_dml := false;   -- Unset the api dml status
187   --
188   hr_utility.set_location(' Leaving:'||l_proc, 10);
189 Exception
190   When hr_api.check_integrity_violated Then
191     -- A check constraint has been violated
192     ben_bnr_shd.g_api_dml := false;   -- Unset the api dml status
193     ben_bnr_shd.constraint_error
194       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
195   When hr_api.parent_integrity_violated Then
196     -- Parent integrity has been violated
197     ben_bnr_shd.g_api_dml := false;   -- Unset the api dml status
198     ben_bnr_shd.constraint_error
199       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
200   When hr_api.unique_integrity_violated Then
201     -- Unique integrity has been violated
202     ben_bnr_shd.g_api_dml := false;   -- Unset the api dml status
203     ben_bnr_shd.constraint_error
204       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
205   When Others Then
206     ben_bnr_shd.g_api_dml := false;   -- Unset the api dml status
207     Raise;
208 End insert_dml;
209 --
210 -- ----------------------------------------------------------------------------
211 -- |------------------------------< pre_insert >------------------------------|
212 -- ----------------------------------------------------------------------------
213 -- {Start Of Comments}
214 --
215 -- Description:
216 --   This private procedure contains any processing which is required before
217 --   the insert dml. Presently, if the entity has a corresponding primary
218 --   key which is maintained by an associating sequence, the primary key for
219 --   the entity will be populated with the next sequence value in
220 --   preparation for the insert dml.
221 --
222 -- Prerequisites:
223 --   This is an internal procedure which is called from the ins procedure.
224 --
225 -- In Parameters:
226 --   A Pl/Sql record structre.
227 --
228 -- Post Success:
229 --   Processing continues.
230 --
231 -- Post Failure:
232 --   If an error has occurred, an error message and exception will be raised
233 --   but not handled.
234 --
235 -- Developer Implementation Notes:
236 --   Any pre-processing required before the insert dml is issued should be
237 --   coded within this procedure. As stated above, a good example is the
238 --   generation of a primary key number via a corresponding sequence.
239 --   It is important to note that any 3rd party maintenance should be reviewed
240 --   before placing in this procedure.
241 --
242 -- Access Status:
243 --   Internal Row Handler Use Only.
244 --
245 -- {End Of Comments}
246 -- ----------------------------------------------------------------------------
247 Procedure pre_insert(p_rec  in out nocopy ben_bnr_shd.g_rec_type) is
248 --
249   l_proc  varchar2(72) := g_package||'pre_insert';
250 --
251   Cursor C_Sel1 is select ben_rptg_grp_s.nextval from sys.dual;
252   --
253   cursor  c_legislation is
254      select legislation_code
255      from   per_business_groups
256      where  business_group_id = p_rec.business_group_id;
257 --
258 Begin
259   hr_utility.set_location('Entering:'||l_proc, 5);
260   --
261   --
262   -- Select the next sequence number
263   --
264   Open C_Sel1;
265   Fetch C_Sel1 Into p_rec.rptg_grp_id;
266   Close C_Sel1;
267   --
268   Open c_legislation;
269   fetch c_legislation into p_rec.legislation_code;
270   close c_legislation;
271   --
272   hr_utility.set_location(' Leaving:'||l_proc, 10);
273 End pre_insert;
274 --
275 -- ----------------------------------------------------------------------------
276 -- |-----------------------------< post_insert >------------------------------|
277 -- ----------------------------------------------------------------------------
278 -- {Start Of Comments}
279 --
280 -- Description:
281 --   This private procedure contains any processing which is required after the
282 --   insert dml.
283 --
284 -- Prerequisites:
285 --   This is an internal procedure which is called from the ins procedure.
286 --
287 -- In Parameters:
288 --   A Pl/Sql record structre.
289 --
290 -- Post Success:
291 --   Processing continues.
292 --
293 -- Post Failure:
294 --   If an error has occurred, an error message and exception will be raised
295 --   but not handled.
296 --
297 -- Developer Implementation Notes:
298 --   Any post-processing required after the insert dml is issued should be
299 --   coded within this procedure. It is important to note that any 3rd party
300 --   maintenance should be reviewed before placing in this procedure.
301 --
302 -- Access Status:
303 --   Internal Row Handler Use Only.
304 --
305 -- {End Of Comments}
306 -- ----------------------------------------------------------------------------
307 Procedure post_insert(
308 p_effective_date in date,p_rec in ben_bnr_shd.g_rec_type) is
309 --
310   l_proc  varchar2(72) := g_package||'post_insert';
311 --
312 Begin
313   hr_utility.set_location('Entering:'||l_proc, 5);
314 --
315   --
316   -- Start of API User Hook for post_insert.
317   --
318   begin
319     --
320     ben_bnr_rki.after_insert
321       (
322   p_rptg_grp_id                   =>p_rec.rptg_grp_id
323  ,p_name                          =>p_rec.name
324  ,p_business_group_id             =>p_rec.business_group_id
325  ,p_rptg_prps_cd                  =>p_rec.rptg_prps_cd
326  ,p_rpg_desc                      =>p_rec.rpg_desc
327  ,p_bnr_attribute_category        =>p_rec.bnr_attribute_category
328  ,p_bnr_attribute1                =>p_rec.bnr_attribute1
329  ,p_bnr_attribute2                =>p_rec.bnr_attribute2
330  ,p_bnr_attribute3                =>p_rec.bnr_attribute3
331  ,p_bnr_attribute4                =>p_rec.bnr_attribute4
332  ,p_bnr_attribute5                =>p_rec.bnr_attribute5
333  ,p_bnr_attribute6                =>p_rec.bnr_attribute6
334  ,p_bnr_attribute7                =>p_rec.bnr_attribute7
335  ,p_bnr_attribute8                =>p_rec.bnr_attribute8
336  ,p_bnr_attribute9                =>p_rec.bnr_attribute9
337  ,p_bnr_attribute10               =>p_rec.bnr_attribute10
338  ,p_bnr_attribute11               =>p_rec.bnr_attribute11
339  ,p_bnr_attribute12               =>p_rec.bnr_attribute12
340  ,p_bnr_attribute13               =>p_rec.bnr_attribute13
341  ,p_bnr_attribute14               =>p_rec.bnr_attribute14
342  ,p_bnr_attribute15               =>p_rec.bnr_attribute15
343  ,p_bnr_attribute16               =>p_rec.bnr_attribute16
344  ,p_bnr_attribute17               =>p_rec.bnr_attribute17
345  ,p_bnr_attribute18               =>p_rec.bnr_attribute18
346  ,p_bnr_attribute19               =>p_rec.bnr_attribute19
347  ,p_bnr_attribute20               =>p_rec.bnr_attribute20
348  ,p_bnr_attribute21               =>p_rec.bnr_attribute21
349  ,p_bnr_attribute22               =>p_rec.bnr_attribute22
350  ,p_bnr_attribute23               =>p_rec.bnr_attribute23
351  ,p_bnr_attribute24               =>p_rec.bnr_attribute24
352  ,p_bnr_attribute25               =>p_rec.bnr_attribute25
353  ,p_bnr_attribute26               =>p_rec.bnr_attribute26
354  ,p_bnr_attribute27               =>p_rec.bnr_attribute27
355  ,p_bnr_attribute28               =>p_rec.bnr_attribute28
356  ,p_bnr_attribute29               =>p_rec.bnr_attribute29
357  ,p_bnr_attribute30               =>p_rec.bnr_attribute30
358  ,p_function_code                 =>p_rec.function_code
359  ,p_legislation_code              =>p_rec.legislation_code
360  ,p_object_version_number         =>p_rec.object_version_number
361  ,p_ordr_num                      =>p_rec.ordr_num                      --iRec
362  ,p_effective_date                =>p_effective_date
363       );
364     --
365   exception
366     --
367     when hr_api.cannot_find_prog_unit then
368       --
369       hr_api.cannot_find_prog_unit_error
370         (p_module_name => 'ben_rptg_grp'
371         ,p_hook_type   => 'AI');
372       --
373   end;
374   --
375   -- End of API User Hook for post_insert.
376   --
377   --
378   hr_utility.set_location(' Leaving:'||l_proc, 10);
379 End post_insert;
380 --
381 -- ----------------------------------------------------------------------------
382 -- |---------------------------------< ins >----------------------------------|
383 -- ----------------------------------------------------------------------------
384 Procedure ins
385   (
386   p_effective_date in date,
387   p_rec        in out nocopy ben_bnr_shd.g_rec_type
388   ) is
389 --
390   l_proc  varchar2(72) := g_package||'ins';
391 --
392 Begin
393   hr_utility.set_location('Entering:'||l_proc, 5);
394   --
395   -- Call the supporting insert validate operations
396   --
397   ben_bnr_bus.insert_validate(p_rec
398   ,p_effective_date);
399   --
400   -- Call the supporting pre-insert operation
401   --
402   pre_insert(p_rec);
403   --
404   -- Insert the row
405   --
406   insert_dml(p_rec);
407   --
408   -- Call the supporting post-insert operation
409   --
410   post_insert(
411 p_effective_date,p_rec);
412 end ins;
413 --
414 -- ----------------------------------------------------------------------------
415 -- |---------------------------------< ins >----------------------------------|
416 -- ----------------------------------------------------------------------------
417 Procedure ins
418   (
419   p_effective_date in date,
420   p_rptg_grp_id                  out nocopy number,
421   p_name                         in varchar2,
422   p_business_group_id            in number,
423   p_rptg_prps_cd                 in varchar2         default null,
424   p_rpg_desc                     in varchar2         default null,
425   p_bnr_attribute_category       in varchar2         default null,
429   p_bnr_attribute4               in varchar2         default null,
426   p_bnr_attribute1               in varchar2         default null,
427   p_bnr_attribute2               in varchar2         default null,
428   p_bnr_attribute3               in varchar2         default null,
430   p_bnr_attribute5               in varchar2         default null,
431   p_bnr_attribute6               in varchar2         default null,
432   p_bnr_attribute7               in varchar2         default null,
433   p_bnr_attribute8               in varchar2         default null,
434   p_bnr_attribute9               in varchar2         default null,
435   p_bnr_attribute10              in varchar2         default null,
436   p_bnr_attribute11              in varchar2         default null,
437   p_bnr_attribute12              in varchar2         default null,
438   p_bnr_attribute13              in varchar2         default null,
439   p_bnr_attribute14              in varchar2         default null,
440   p_bnr_attribute15              in varchar2         default null,
441   p_bnr_attribute16              in varchar2         default null,
442   p_bnr_attribute17              in varchar2         default null,
443   p_bnr_attribute18              in varchar2         default null,
444   p_bnr_attribute19              in varchar2         default null,
445   p_bnr_attribute20              in varchar2         default null,
446   p_bnr_attribute21              in varchar2         default null,
447   p_bnr_attribute22              in varchar2         default null,
448   p_bnr_attribute23              in varchar2         default null,
449   p_bnr_attribute24              in varchar2         default null,
450   p_bnr_attribute25              in varchar2         default null,
451   p_bnr_attribute26              in varchar2         default null,
452   p_bnr_attribute27              in varchar2         default null,
453   p_bnr_attribute28              in varchar2         default null,
454   p_bnr_attribute29              in varchar2         default null,
455   p_bnr_attribute30              in varchar2         default null,
456   p_function_code                in varchar2         default null,
457   p_legislation_code             in varchar2         default null,
458   p_object_version_number        out nocopy number,
459   p_ordr_num                     in number           default null                      --iRec
460   ) is
461 --
462   l_rec	  ben_bnr_shd.g_rec_type;
463   l_proc  varchar2(72) := g_package||'ins';
464 --
465 Begin
466   hr_utility.set_location('Entering:'||l_proc, 5);
467   --
468   -- Call conversion function to turn arguments into the
469   -- p_rec structure.
470   --
471   l_rec :=
472   ben_bnr_shd.convert_args
473   (
474   null,
475   p_name,
476   p_business_group_id,
477   p_rptg_prps_cd,
478   p_rpg_desc,
479   p_bnr_attribute_category,
480   p_bnr_attribute1,
481   p_bnr_attribute2,
482   p_bnr_attribute3,
483   p_bnr_attribute4,
484   p_bnr_attribute5,
485   p_bnr_attribute6,
486   p_bnr_attribute7,
487   p_bnr_attribute8,
488   p_bnr_attribute9,
489   p_bnr_attribute10,
490   p_bnr_attribute11,
491   p_bnr_attribute12,
492   p_bnr_attribute13,
493   p_bnr_attribute14,
494   p_bnr_attribute15,
495   p_bnr_attribute16,
496   p_bnr_attribute17,
497   p_bnr_attribute18,
498   p_bnr_attribute19,
499   p_bnr_attribute20,
500   p_bnr_attribute21,
501   p_bnr_attribute22,
502   p_bnr_attribute23,
503   p_bnr_attribute24,
504   p_bnr_attribute25,
505   p_bnr_attribute26,
506   p_bnr_attribute27,
507   p_bnr_attribute28,
508   p_bnr_attribute29,
509   p_bnr_attribute30,
510   p_function_code,
511   p_legislation_code,
512   null,
513   p_ordr_num                        --iRec
514   );
515   --
516   -- Having converted the arguments into the ben_bnr_rec
517   -- plsql record structure we call the corresponding record business process.
518   --
519   ins(
520     p_effective_date,l_rec);
521   --
522   -- As the primary key argument(s)
523   -- are specified as an OUT's we must set these values.
524   --
525   p_rptg_grp_id := l_rec.rptg_grp_id;
526   p_object_version_number := l_rec.object_version_number;
527   --
528   hr_utility.set_location(' Leaving:'||l_proc, 10);
529 End ins;
530 --
531 end ben_bnr_ins;