DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_WYP_INS

Source


1 Package Body ben_wyp_ins as
2 /* $Header: bewyprhi.pkb 115.12 2003/01/01 00:03:22 mmudigon ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ben_wyp_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_wyp_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_wyp_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: ben_wthn_yr_perd
64   --
65   insert into ben_wthn_yr_perd
66   ( wthn_yr_perd_id,
67     strt_day,
68     end_day,
69     strt_mo,
70     end_mo,
71         tm_uom,
72     yr_perd_id,
73     business_group_id,
74     wyp_attribute_category,
75     wyp_attribute1,
76     wyp_attribute2,
77     wyp_attribute3,
78     wyp_attribute4,
79     wyp_attribute5,
80     wyp_attribute6,
81     wyp_attribute7,
82     wyp_attribute8,
83     wyp_attribute9,
84     wyp_attribute10,
85     wyp_attribute11,
86     wyp_attribute12,
87     wyp_attribute13,
88     wyp_attribute14,
89     wyp_attribute15,
90     wyp_attribute16,
91     wyp_attribute17,
92     wyp_attribute18,
93     wyp_attribute19,
94     wyp_attribute20,
95     wyp_attribute21,
96     wyp_attribute22,
97     wyp_attribute23,
98     wyp_attribute24,
99     wyp_attribute25,
100     wyp_attribute26,
101     wyp_attribute27,
102     wyp_attribute28,
103     wyp_attribute29,
104     wyp_attribute30,
105     object_version_number
106   )
107   Values
108   ( p_rec.wthn_yr_perd_id,
109     p_rec.strt_day,
110     p_rec.end_day,
111     p_rec.strt_mo,
112     p_rec.end_mo,
113         p_rec.tm_uom,
114     p_rec.yr_perd_id,
115     p_rec.business_group_id,
116     p_rec.wyp_attribute_category,
117     p_rec.wyp_attribute1,
118     p_rec.wyp_attribute2,
119     p_rec.wyp_attribute3,
120     p_rec.wyp_attribute4,
121     p_rec.wyp_attribute5,
122     p_rec.wyp_attribute6,
123     p_rec.wyp_attribute7,
124     p_rec.wyp_attribute8,
125     p_rec.wyp_attribute9,
126     p_rec.wyp_attribute10,
127     p_rec.wyp_attribute11,
128     p_rec.wyp_attribute12,
129     p_rec.wyp_attribute13,
130     p_rec.wyp_attribute14,
131     p_rec.wyp_attribute15,
132     p_rec.wyp_attribute16,
133     p_rec.wyp_attribute17,
134     p_rec.wyp_attribute18,
135     p_rec.wyp_attribute19,
136     p_rec.wyp_attribute20,
137     p_rec.wyp_attribute21,
138     p_rec.wyp_attribute22,
139     p_rec.wyp_attribute23,
140     p_rec.wyp_attribute24,
141     p_rec.wyp_attribute25,
142     p_rec.wyp_attribute26,
143     p_rec.wyp_attribute27,
144     p_rec.wyp_attribute28,
145     p_rec.wyp_attribute29,
146     p_rec.wyp_attribute30,
147     p_rec.object_version_number
148   );
149   --
150   ben_wyp_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_wyp_shd.g_api_dml := false;   -- Unset the api dml status
157     ben_wyp_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_wyp_shd.g_api_dml := false;   -- Unset the api dml status
162     ben_wyp_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_wyp_shd.g_api_dml := false;   -- Unset the api dml status
167     ben_wyp_shd.constraint_error
168       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
169   When Others Then
170     ben_wyp_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_wyp_shd.g_rec_type) is
212 --
213   l_proc  varchar2(72) := g_package||'pre_insert';
214 --
215   Cursor C_Sel1 is select ben_wthn_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.wthn_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_effective_date in date,
263                       p_rec in ben_wyp_shd.g_rec_type) is
264 --
265   l_proc  varchar2(72) := g_package||'post_insert';
266 --
267 Begin
268   hr_utility.set_location('Entering:'||l_proc, 5);
269 --
270   --
271   -- Start of API User Hook for post_insert.
272   --
273   begin
274     --
275     ben_wyp_rki.after_insert
276       (
277   p_wthn_yr_perd_id               =>p_rec.wthn_yr_perd_id
278  ,p_strt_day                      =>p_rec.strt_day
279  ,p_end_day                       =>p_rec.end_day
280  ,p_strt_mo                       =>p_rec.strt_mo
281  ,p_end_mo                        =>p_rec.end_mo
282  ,p_tm_uom                        =>p_rec.tm_uom
283  ,p_yr_perd_id                    =>p_rec.yr_perd_id
284  ,p_business_group_id             =>p_rec.business_group_id
285  ,p_wyp_attribute_category        =>p_rec.wyp_attribute_category
286  ,p_wyp_attribute1                =>p_rec.wyp_attribute1
287  ,p_wyp_attribute2                =>p_rec.wyp_attribute2
288  ,p_wyp_attribute3                =>p_rec.wyp_attribute3
289  ,p_wyp_attribute4                =>p_rec.wyp_attribute4
290  ,p_wyp_attribute5                =>p_rec.wyp_attribute5
291  ,p_wyp_attribute6                =>p_rec.wyp_attribute6
292  ,p_wyp_attribute7                =>p_rec.wyp_attribute7
293  ,p_wyp_attribute8                =>p_rec.wyp_attribute8
294  ,p_wyp_attribute9                =>p_rec.wyp_attribute9
295  ,p_wyp_attribute10               =>p_rec.wyp_attribute10
296  ,p_wyp_attribute11               =>p_rec.wyp_attribute11
297  ,p_wyp_attribute12               =>p_rec.wyp_attribute12
298  ,p_wyp_attribute13               =>p_rec.wyp_attribute13
299  ,p_wyp_attribute14               =>p_rec.wyp_attribute14
300  ,p_wyp_attribute15               =>p_rec.wyp_attribute15
301  ,p_wyp_attribute16               =>p_rec.wyp_attribute16
302  ,p_wyp_attribute17               =>p_rec.wyp_attribute17
303  ,p_wyp_attribute18               =>p_rec.wyp_attribute18
304  ,p_wyp_attribute19               =>p_rec.wyp_attribute19
305  ,p_wyp_attribute20               =>p_rec.wyp_attribute20
306  ,p_wyp_attribute21               =>p_rec.wyp_attribute21
307  ,p_wyp_attribute22               =>p_rec.wyp_attribute22
308  ,p_wyp_attribute23               =>p_rec.wyp_attribute23
309  ,p_wyp_attribute24               =>p_rec.wyp_attribute24
310  ,p_wyp_attribute25               =>p_rec.wyp_attribute25
311  ,p_wyp_attribute26               =>p_rec.wyp_attribute26
312  ,p_wyp_attribute27               =>p_rec.wyp_attribute27
313  ,p_wyp_attribute28               =>p_rec.wyp_attribute28
314  ,p_wyp_attribute29               =>p_rec.wyp_attribute29
315  ,p_wyp_attribute30               =>p_rec.wyp_attribute30
316  ,p_object_version_number         =>p_rec.object_version_number
317  ,p_effective_date                =>p_effective_date
318       );
319     --
320   exception
321     --
322     when hr_api.cannot_find_prog_unit then
323       --
324       hr_api.cannot_find_prog_unit_error
325         (p_module_name => 'ben_wthn_yr_perd'
326         ,p_hook_type   => 'AI');
327       --
328   end;
329   --
330   -- End of API User Hook for post_insert.
331   --
332   --
333   hr_utility.set_location(' Leaving:'||l_proc, 10);
334 End post_insert;
335 --
336 -- ----------------------------------------------------------------------------
337 -- |---------------------------------< ins >----------------------------------|
338 -- ----------------------------------------------------------------------------
339 Procedure ins
340   (
341   p_effective_date in date,
342   p_rec        in out nocopy ben_wyp_shd.g_rec_type
343   ) is
344 --
345   l_proc  varchar2(72) := g_package||'ins';
346 --
347 Begin
348   hr_utility.set_location('Entering:'||l_proc, 5);
349   --
350   -- Call the supporting insert validate operations
351   --
352   ben_wyp_bus.insert_validate(p_rec
353   ,p_effective_date);
354   --
355   -- Call the supporting pre-insert operation
356   --
357   pre_insert(p_rec);
358   --
359   -- Insert the row
360   --
361   insert_dml(p_rec);
362   --
363   -- Call the supporting post-insert operation
364   --
365   post_insert(p_effective_date,
366               p_rec);
367 end ins;
368 --
369 -- ----------------------------------------------------------------------------
370 -- |---------------------------------< ins >----------------------------------|
371 -- ----------------------------------------------------------------------------
372 Procedure ins
373   (
374   p_effective_date               in date,
375   p_wthn_yr_perd_id              out nocopy number,
376   p_strt_day                     in number           default null,
377   p_end_day                      in number           default null,
378   p_strt_mo                      in number           default null,
379   p_end_mo                       in number           default null,
380   p_tm_uom                       in varchar2         default null,
381   p_yr_perd_id                   in number           default null,
382   p_business_group_id            in number           default null,
383   p_wyp_attribute_category       in varchar2         default null,
384   p_wyp_attribute1               in varchar2         default null,
385   p_wyp_attribute2               in varchar2         default null,
386   p_wyp_attribute3               in varchar2         default null,
387   p_wyp_attribute4               in varchar2         default null,
388   p_wyp_attribute5               in varchar2         default null,
389   p_wyp_attribute6               in varchar2         default null,
390   p_wyp_attribute7               in varchar2         default null,
391   p_wyp_attribute8               in varchar2         default null,
392   p_wyp_attribute9               in varchar2         default null,
393   p_wyp_attribute10              in varchar2         default null,
394   p_wyp_attribute11              in varchar2         default null,
395   p_wyp_attribute12              in varchar2         default null,
396   p_wyp_attribute13              in varchar2         default null,
397   p_wyp_attribute14              in varchar2         default null,
398   p_wyp_attribute15              in varchar2         default null,
399   p_wyp_attribute16              in varchar2         default null,
400   p_wyp_attribute17              in varchar2         default null,
401   p_wyp_attribute18              in varchar2         default null,
402   p_wyp_attribute19              in varchar2         default null,
403   p_wyp_attribute20              in varchar2         default null,
404   p_wyp_attribute21              in varchar2         default null,
405   p_wyp_attribute22              in varchar2         default null,
406   p_wyp_attribute23              in varchar2         default null,
407   p_wyp_attribute24              in varchar2         default null,
408   p_wyp_attribute25              in varchar2         default null,
409   p_wyp_attribute26              in varchar2         default null,
410   p_wyp_attribute27              in varchar2         default null,
411   p_wyp_attribute28              in varchar2         default null,
412   p_wyp_attribute29              in varchar2         default null,
413   p_wyp_attribute30              in varchar2         default null,
414   p_object_version_number        out nocopy number
415   ) is
416 --
417   l_rec   ben_wyp_shd.g_rec_type;
418   l_proc  varchar2(72) := g_package||'ins';
419 --
420 Begin
421   hr_utility.set_location('Entering:'||l_proc, 5);
422   --
423   -- Call conversion function to turn arguments into the
424   -- p_rec structure.
425   --
426   l_rec :=
427   ben_wyp_shd.convert_args
428   (
429   null,
430   p_strt_day,
431   p_end_day,
432   p_strt_mo,
433   p_end_mo,
434   p_tm_uom,
435   p_yr_perd_id,
436   p_business_group_id,
437   p_wyp_attribute_category,
438   p_wyp_attribute1,
439   p_wyp_attribute2,
440   p_wyp_attribute3,
441   p_wyp_attribute4,
442   p_wyp_attribute5,
443   p_wyp_attribute6,
444   p_wyp_attribute7,
445   p_wyp_attribute8,
446   p_wyp_attribute9,
447   p_wyp_attribute10,
448   p_wyp_attribute11,
449   p_wyp_attribute12,
450   p_wyp_attribute13,
451   p_wyp_attribute14,
452   p_wyp_attribute15,
453   p_wyp_attribute16,
454   p_wyp_attribute17,
455   p_wyp_attribute18,
456   p_wyp_attribute19,
457   p_wyp_attribute20,
458   p_wyp_attribute21,
459   p_wyp_attribute22,
460   p_wyp_attribute23,
461   p_wyp_attribute24,
462   p_wyp_attribute25,
463   p_wyp_attribute26,
464   p_wyp_attribute27,
465   p_wyp_attribute28,
466   p_wyp_attribute29,
467   p_wyp_attribute30,
468   null
469   );
470   --
471   -- Having converted the arguments into the ben_wyp_rec
472   -- plsql record structure we call the corresponding record business process.
473   --
474   ins(p_effective_date,
475       l_rec);
476   --
477   -- As the primary key argument(s)
478   -- are specified as an OUT's we must set these values.
479   --
480   p_wthn_yr_perd_id := l_rec.wthn_yr_perd_id;
481   p_object_version_number := l_rec.object_version_number;
482   --
483   hr_utility.set_location(' Leaving:'||l_proc, 10);
484 End ins;
485 --
486 end ben_wyp_ins;