DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_CPY_INS

Source


1 Package Body ben_cpy_ins as
2 /* $Header: becpyrhi.pkb 120.2 2005/12/19 12:34:35 kmahendr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_cpy_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_cpy_shd.g_rec_type) is
54 --
55   l_proc  varchar2(72) := g_package||'insert_dml';
56 --
57 Begin
58   hr_utility.set_location('Entering:'||l_proc, 5);
59   p_rec.object_version_number := 1;  -- Initialise the object version
60   --
61   ben_cpy_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: ben_popl_yr_perd
64   --
65   insert into ben_popl_yr_perd
66   (	popl_yr_perd_id,
67 	yr_perd_id,
68 	business_group_id,
69 	pl_id,
70 	pgm_id,
71 	ordr_num,
72 	acpt_clm_rqsts_thru_dt,
73 	py_clms_thru_dt,
74 	cpy_attribute_category,
75 	cpy_attribute1,
76 	cpy_attribute2,
77 	cpy_attribute3,
78 	cpy_attribute4,
79 	cpy_attribute5,
80 	cpy_attribute6,
81 	cpy_attribute7,
82 	cpy_attribute8,
83 	cpy_attribute9,
84 	cpy_attribute10,
85 	cpy_attribute11,
86 	cpy_attribute12,
87 	cpy_attribute13,
88 	cpy_attribute14,
89 	cpy_attribute15,
90 	cpy_attribute16,
91 	cpy_attribute17,
92 	cpy_attribute18,
93 	cpy_attribute19,
94 	cpy_attribute20,
95 	cpy_attribute21,
96 	cpy_attribute22,
97 	cpy_attribute23,
98 	cpy_attribute24,
99 	cpy_attribute25,
100 	cpy_attribute26,
101 	cpy_attribute27,
102 	cpy_attribute28,
103 	cpy_attribute29,
104 	cpy_attribute30,
105 	object_version_number
106   )
107   Values
108   (	p_rec.popl_yr_perd_id,
109 	p_rec.yr_perd_id,
110 	p_rec.business_group_id,
111 	p_rec.pl_id,
112 	p_rec.pgm_id,
113 	p_rec.ordr_num,
114 	p_rec.acpt_clm_rqsts_thru_dt,
115 	p_rec.py_clms_thru_dt,
116 	p_rec.cpy_attribute_category,
117 	p_rec.cpy_attribute1,
118 	p_rec.cpy_attribute2,
119 	p_rec.cpy_attribute3,
120 	p_rec.cpy_attribute4,
121 	p_rec.cpy_attribute5,
122 	p_rec.cpy_attribute6,
123 	p_rec.cpy_attribute7,
124 	p_rec.cpy_attribute8,
125 	p_rec.cpy_attribute9,
126 	p_rec.cpy_attribute10,
127 	p_rec.cpy_attribute11,
128 	p_rec.cpy_attribute12,
129 	p_rec.cpy_attribute13,
130 	p_rec.cpy_attribute14,
131 	p_rec.cpy_attribute15,
132 	p_rec.cpy_attribute16,
133 	p_rec.cpy_attribute17,
134 	p_rec.cpy_attribute18,
135 	p_rec.cpy_attribute19,
136 	p_rec.cpy_attribute20,
137 	p_rec.cpy_attribute21,
138 	p_rec.cpy_attribute22,
139 	p_rec.cpy_attribute23,
140 	p_rec.cpy_attribute24,
141 	p_rec.cpy_attribute25,
142 	p_rec.cpy_attribute26,
143 	p_rec.cpy_attribute27,
144 	p_rec.cpy_attribute28,
145 	p_rec.cpy_attribute29,
146 	p_rec.cpy_attribute30,
147 	p_rec.object_version_number
148   );
149   --
150   ben_cpy_shd.g_api_dml := false;   -- Unset the api dml status
151   --
152   hr_utility.set_location(' Leaving:'||l_proc, 10);
153 Exception
154   When hr_api.check_integrity_violated Then
155     -- A check constraint has been violated
156     ben_cpy_shd.g_api_dml := false;   -- Unset the api dml status
157     ben_cpy_shd.constraint_error
158       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
159   When hr_api.parent_integrity_violated Then
160     -- Parent integrity has been violated
161     ben_cpy_shd.g_api_dml := false;   -- Unset the api dml status
162     ben_cpy_shd.constraint_error
163       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
164   When hr_api.unique_integrity_violated Then
165     -- Unique integrity has been violated
166     ben_cpy_shd.g_api_dml := false;   -- Unset the api dml status
167     ben_cpy_shd.constraint_error
168       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
169   When Others Then
170     ben_cpy_shd.g_api_dml := false;   -- Unset the api dml status
171     Raise;
172 End insert_dml;
173 --
174 -- ----------------------------------------------------------------------------
175 -- |------------------------------< pre_insert >------------------------------|
176 -- ----------------------------------------------------------------------------
177 -- {Start Of Comments}
178 --
179 -- Description:
180 --   This private procedure contains any processing which is required before
181 --   the insert dml. Presently, if the entity has a corresponding primary
182 --   key which is maintained by an associating sequence, the primary key for
183 --   the entity will be populated with the next sequence value in
184 --   preparation for the insert dml.
185 --
186 -- Prerequisites:
187 --   This is an internal procedure which is called from the ins procedure.
188 --
189 -- In Parameters:
190 --   A Pl/Sql record structre.
191 --
192 -- Post Success:
193 --   Processing continues.
194 --
195 -- Post Failure:
196 --   If an error has occurred, an error message and exception will be raised
197 --   but not handled.
198 --
199 -- Developer Implementation Notes:
200 --   Any pre-processing required before the insert dml is issued should be
201 --   coded within this procedure. As stated above, a good example is the
202 --   generation of a primary key number via a corresponding sequence.
203 --   It is important to note that any 3rd party maintenance should be reviewed
204 --   before placing in this procedure.
205 --
206 -- Access Status:
207 --   Internal Row Handler Use Only.
208 --
209 -- {End Of Comments}
210 -- ----------------------------------------------------------------------------
211 Procedure pre_insert(p_rec  in out nocopy ben_cpy_shd.g_rec_type) is
212 --
213   l_proc  varchar2(72) := g_package||'pre_insert';
214 --
215   Cursor C_Sel1 is select ben_popl_yr_perd_s.nextval from sys.dual;
216 --
217 Begin
218   hr_utility.set_location('Entering:'||l_proc, 5);
219   --
220   --
221   -- Select the next sequence number
222   --
223   Open C_Sel1;
224   Fetch C_Sel1 Into p_rec.popl_yr_perd_id;
225   Close C_Sel1;
226   --
227   hr_utility.set_location(' Leaving:'||l_proc, 10);
228 End pre_insert;
229 --
230 -- ----------------------------------------------------------------------------
231 -- |-----------------------------< post_insert >------------------------------|
232 -- ----------------------------------------------------------------------------
233 -- {Start Of Comments}
234 --
235 -- Description:
236 --   This private procedure contains any processing which is required after the
237 --   insert dml.
238 --
239 -- Prerequisites:
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 post-processing required after the insert dml is issued should be
254 --   coded within this procedure. It is important to note that any 3rd party
255 --   maintenance should be reviewed before placing in this procedure.
256 --
257 -- Access Status:
258 --   Internal Row Handler Use Only.
259 --
260 -- {End Of Comments}
261 -- ----------------------------------------------------------------------------
262 Procedure post_insert(p_rec in ben_cpy_shd.g_rec_type) is
263 --
264   l_proc  varchar2(72) := g_package||'post_insert';
265 --
266 Begin
267   hr_utility.set_location('Entering:'||l_proc, 5);
268 --
269   --
270   -- Start of API User Hook for post_insert.
271   --
272   begin
273     --
274     ben_cpy_rki.after_insert
275       (
276        p_popl_yr_perd_id               =>p_rec.popl_yr_perd_id
277       ,p_yr_perd_id                    =>p_rec.yr_perd_id
278       ,p_business_group_id             =>p_rec.business_group_id
279       ,p_pl_id                         =>p_rec.pl_id
280       ,p_pgm_id                        =>p_rec.pgm_id
281       ,p_ordr_num                      =>p_rec.ordr_num
282       ,p_acpt_clm_rqsts_thru_dt        =>p_rec.acpt_clm_rqsts_thru_dt
283       ,p_py_clms_thru_dt               =>p_rec.py_clms_thru_dt
284       ,p_cpy_attribute_category        =>p_rec.cpy_attribute_category
285       ,p_cpy_attribute1                =>p_rec.cpy_attribute1
286       ,p_cpy_attribute2                =>p_rec.cpy_attribute2
287       ,p_cpy_attribute3                =>p_rec.cpy_attribute3
288       ,p_cpy_attribute4                =>p_rec.cpy_attribute4
289       ,p_cpy_attribute5                =>p_rec.cpy_attribute5
290       ,p_cpy_attribute6                =>p_rec.cpy_attribute6
291       ,p_cpy_attribute7                =>p_rec.cpy_attribute7
292       ,p_cpy_attribute8                =>p_rec.cpy_attribute8
293       ,p_cpy_attribute9                =>p_rec.cpy_attribute9
294       ,p_cpy_attribute10               =>p_rec.cpy_attribute10
295       ,p_cpy_attribute11               =>p_rec.cpy_attribute11
296       ,p_cpy_attribute12               =>p_rec.cpy_attribute12
297       ,p_cpy_attribute13               =>p_rec.cpy_attribute13
298       ,p_cpy_attribute14               =>p_rec.cpy_attribute14
299       ,p_cpy_attribute15               =>p_rec.cpy_attribute15
300       ,p_cpy_attribute16               =>p_rec.cpy_attribute16
301       ,p_cpy_attribute17               =>p_rec.cpy_attribute17
302       ,p_cpy_attribute18               =>p_rec.cpy_attribute18
303       ,p_cpy_attribute19               =>p_rec.cpy_attribute19
304       ,p_cpy_attribute20               =>p_rec.cpy_attribute20
305       ,p_cpy_attribute21               =>p_rec.cpy_attribute21
306       ,p_cpy_attribute22               =>p_rec.cpy_attribute22
307       ,p_cpy_attribute23               =>p_rec.cpy_attribute23
308       ,p_cpy_attribute24               =>p_rec.cpy_attribute24
309       ,p_cpy_attribute25               =>p_rec.cpy_attribute25
310       ,p_cpy_attribute26               =>p_rec.cpy_attribute26
311       ,p_cpy_attribute27               =>p_rec.cpy_attribute27
312       ,p_cpy_attribute28               =>p_rec.cpy_attribute28
313       ,p_cpy_attribute29               =>p_rec.cpy_attribute29
314       ,p_cpy_attribute30               =>p_rec.cpy_attribute30
315       ,p_object_version_number         =>p_rec.object_version_number
316       );
317     --
318   exception
319     --
320     when hr_api.cannot_find_prog_unit then
321       --
322       hr_api.cannot_find_prog_unit_error
323         (p_module_name => 'ben_popl_yr_perd'
324         ,p_hook_type   => 'AI');
325       --
326   end;
327   --
328   -- End of API User Hook for post_insert.
329   --
330   --
331   hr_utility.set_location(' Leaving:'||l_proc, 10);
332 End post_insert;
333 --
334 -- ----------------------------------------------------------------------------
335 -- |---------------------------------< ins >----------------------------------|
336 -- ----------------------------------------------------------------------------
337 Procedure ins
338   (
339   p_rec        in out nocopy ben_cpy_shd.g_rec_type
340   ) is
341 --
342   l_proc  varchar2(72) := g_package||'ins';
343 --
344 Begin
345   hr_utility.set_location('Entering:'||l_proc, 5);
346   --
347   -- Call the supporting insert validate operations
348   --
349   ben_cpy_bus.insert_validate(p_rec);
350   --
351   -- Call the supporting pre-insert operation
352   --
353   pre_insert(p_rec);
354   --
355   -- Insert the row
356   --
357   insert_dml(p_rec);
358   --
359   -- Call the supporting post-insert operation
360   --
361   post_insert(p_rec);
362 end ins;
363 --
364 -- ----------------------------------------------------------------------------
365 -- |---------------------------------< ins >----------------------------------|
366 -- ----------------------------------------------------------------------------
367 Procedure ins
368   (
369   p_popl_yr_perd_id              out nocopy number,
370   p_yr_perd_id                   in number,
371   p_business_group_id            in number,
372   p_pl_id                        in number           default null,
373   p_pgm_id                       in number           default null,
374   p_ordr_num                     in number           default null,
375   p_acpt_clm_rqsts_thru_dt       in date             default null,
376   p_py_clms_thru_dt              in date             default null,
377   p_cpy_attribute_category       in varchar2         default null,
378   p_cpy_attribute1               in varchar2         default null,
379   p_cpy_attribute2               in varchar2         default null,
380   p_cpy_attribute3               in varchar2         default null,
381   p_cpy_attribute4               in varchar2         default null,
382   p_cpy_attribute5               in varchar2         default null,
383   p_cpy_attribute6               in varchar2         default null,
384   p_cpy_attribute7               in varchar2         default null,
385   p_cpy_attribute8               in varchar2         default null,
386   p_cpy_attribute9               in varchar2         default null,
387   p_cpy_attribute10              in varchar2         default null,
388   p_cpy_attribute11              in varchar2         default null,
389   p_cpy_attribute12              in varchar2         default null,
390   p_cpy_attribute13              in varchar2         default null,
391   p_cpy_attribute14              in varchar2         default null,
392   p_cpy_attribute15              in varchar2         default null,
393   p_cpy_attribute16              in varchar2         default null,
394   p_cpy_attribute17              in varchar2         default null,
395   p_cpy_attribute18              in varchar2         default null,
396   p_cpy_attribute19              in varchar2         default null,
397   p_cpy_attribute20              in varchar2         default null,
398   p_cpy_attribute21              in varchar2         default null,
399   p_cpy_attribute22              in varchar2         default null,
400   p_cpy_attribute23              in varchar2         default null,
401   p_cpy_attribute24              in varchar2         default null,
402   p_cpy_attribute25              in varchar2         default null,
403   p_cpy_attribute26              in varchar2         default null,
404   p_cpy_attribute27              in varchar2         default null,
405   p_cpy_attribute28              in varchar2         default null,
406   p_cpy_attribute29              in varchar2         default null,
407   p_cpy_attribute30              in varchar2         default null,
408   p_object_version_number        out nocopy number
409   ) is
410 --
411   l_rec	  ben_cpy_shd.g_rec_type;
412   l_proc  varchar2(72) := g_package||'ins';
413 --
414 Begin
415   hr_utility.set_location('Entering:'||l_proc, 5);
416   --
417   -- Call conversion function to turn arguments into the
418   -- p_rec structure.
419   --
420   l_rec :=
421   ben_cpy_shd.convert_args
422   (
423   null,
424   p_yr_perd_id,
425   p_business_group_id,
426   p_pl_id,
427   p_pgm_id,
428   p_ordr_num,
429   p_acpt_clm_rqsts_thru_dt,
430   p_py_clms_thru_dt,
431   p_cpy_attribute_category,
432   p_cpy_attribute1,
433   p_cpy_attribute2,
434   p_cpy_attribute3,
435   p_cpy_attribute4,
436   p_cpy_attribute5,
437   p_cpy_attribute6,
438   p_cpy_attribute7,
439   p_cpy_attribute8,
440   p_cpy_attribute9,
441   p_cpy_attribute10,
442   p_cpy_attribute11,
443   p_cpy_attribute12,
444   p_cpy_attribute13,
445   p_cpy_attribute14,
446   p_cpy_attribute15,
447   p_cpy_attribute16,
448   p_cpy_attribute17,
449   p_cpy_attribute18,
450   p_cpy_attribute19,
451   p_cpy_attribute20,
452   p_cpy_attribute21,
453   p_cpy_attribute22,
454   p_cpy_attribute23,
455   p_cpy_attribute24,
456   p_cpy_attribute25,
457   p_cpy_attribute26,
458   p_cpy_attribute27,
459   p_cpy_attribute28,
460   p_cpy_attribute29,
461   p_cpy_attribute30,
462   null
463   );
464   --
465   -- Having converted the arguments into the ben_cpy_rec
466   -- plsql record structure we call the corresponding record business process.
467   --
468   ins(l_rec);
469   --
470   -- As the primary key argument(s)
471   -- are specified as an OUT's we must set these values.
472   --
473   p_popl_yr_perd_id := l_rec.popl_yr_perd_id;
474   p_object_version_number := l_rec.object_version_number;
475   --
476   hr_utility.set_location(' Leaving:'||l_proc, 10);
477 End ins;
478 --
479 end ben_cpy_ins;