DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_CRT_INS

Source


1 Package Body ben_crt_ins as
2 /* $Header: becrtrhi.pkb 115.11 2004/06/22 07:52:16 rpgupta ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_crt_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_crt_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_crt_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: ben_crt_ordr
64   --
65   insert into ben_crt_ordr
66   (	crt_ordr_id,
67 	crt_ordr_typ_cd,
68 	apls_perd_endg_dt,
69 	apls_perd_strtg_dt,
70 	crt_ident,
71 	description,
72 	detd_qlfd_ordr_dt,
73 	issue_dt,
74 	qdro_amt,
75 	qdro_dstr_mthd_cd,
76 	qdro_pct,
77 	rcvd_dt,
78 	uom,
79 	crt_issng,
80 	pl_id,
81 	person_id,
82 	business_group_id,
83 	crt_attribute_category,
84 	crt_attribute1,
85 	crt_attribute2,
86 	crt_attribute3,
87 	crt_attribute4,
88 	crt_attribute5,
89 	crt_attribute6,
90 	crt_attribute7,
91 	crt_attribute8,
92 	crt_attribute9,
93 	crt_attribute10,
94 	crt_attribute11,
95 	crt_attribute12,
96 	crt_attribute13,
97 	crt_attribute14,
98 	crt_attribute15,
102 	crt_attribute19,
99 	crt_attribute16,
100 	crt_attribute17,
101 	crt_attribute18,
103 	crt_attribute20,
104 	crt_attribute21,
105 	crt_attribute22,
106 	crt_attribute23,
107 	crt_attribute24,
108 	crt_attribute25,
109 	crt_attribute26,
110 	crt_attribute27,
111 	crt_attribute28,
112 	crt_attribute29,
113 	crt_attribute30,
114 	object_version_number,
115 	qdro_num_pymt_val,
116 	qdro_per_perd_cd,
117 	pl_typ_id
118   )
119   Values
120   (	p_rec.crt_ordr_id,
121 	p_rec.crt_ordr_typ_cd,
122 	p_rec.apls_perd_endg_dt,
123 	p_rec.apls_perd_strtg_dt,
124 	p_rec.crt_ident,
125 	p_rec.description,
126 	p_rec.detd_qlfd_ordr_dt,
127 	p_rec.issue_dt,
128 	p_rec.qdro_amt,
129 	p_rec.qdro_dstr_mthd_cd,
130 	p_rec.qdro_pct,
131 	p_rec.rcvd_dt,
132 	p_rec.uom,
133 	p_rec.crt_issng,
134 	p_rec.pl_id,
135 	p_rec.person_id,
136 	p_rec.business_group_id,
137 	p_rec.crt_attribute_category,
138 	p_rec.crt_attribute1,
139 	p_rec.crt_attribute2,
140 	p_rec.crt_attribute3,
141 	p_rec.crt_attribute4,
142 	p_rec.crt_attribute5,
143 	p_rec.crt_attribute6,
144 	p_rec.crt_attribute7,
145 	p_rec.crt_attribute8,
146 	p_rec.crt_attribute9,
147 	p_rec.crt_attribute10,
148 	p_rec.crt_attribute11,
149 	p_rec.crt_attribute12,
150 	p_rec.crt_attribute13,
151 	p_rec.crt_attribute14,
152 	p_rec.crt_attribute15,
153 	p_rec.crt_attribute16,
154 	p_rec.crt_attribute17,
155 	p_rec.crt_attribute18,
156 	p_rec.crt_attribute19,
157 	p_rec.crt_attribute20,
158 	p_rec.crt_attribute21,
159 	p_rec.crt_attribute22,
160 	p_rec.crt_attribute23,
161 	p_rec.crt_attribute24,
162 	p_rec.crt_attribute25,
163 	p_rec.crt_attribute26,
164 	p_rec.crt_attribute27,
165 	p_rec.crt_attribute28,
166 	p_rec.crt_attribute29,
167 	p_rec.crt_attribute30,
168 	p_rec.object_version_number,
169 	p_rec.qdro_num_pymt_val,
170 	p_rec.qdro_per_perd_cd,
171 	p_rec.pl_typ_id
172   );
173   --
174   ben_crt_shd.g_api_dml := false;   -- Unset the api dml status
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     ben_crt_shd.g_api_dml := false;   -- Unset the api dml status
181     ben_crt_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     ben_crt_shd.g_api_dml := false;   -- Unset the api dml status
186     ben_crt_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     ben_crt_shd.g_api_dml := false;   -- Unset the api dml status
191     ben_crt_shd.constraint_error
192       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
193   When Others Then
194     ben_crt_shd.g_api_dml := false;   -- Unset the api dml status
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 structre.
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(p_rec  in out nocopy ben_crt_shd.g_rec_type) is
236 --
237   l_proc  varchar2(72) := g_package||'pre_insert';
238 --
239   Cursor C_Sel1 is select ben_crt_ordr_s.nextval from sys.dual;
240 --
241 Begin
242   hr_utility.set_location('Entering:'||l_proc, 5);
243   --
244   --
245   -- Select the next sequence number
246   --
247   Open C_Sel1;
248   Fetch C_Sel1 Into p_rec.crt_ordr_id;
249   Close C_Sel1;
250   --
251   hr_utility.set_location(' Leaving:'||l_proc, 10);
252 End pre_insert;
253 --
254 -- ----------------------------------------------------------------------------
255 -- |-----------------------------< insert >------------------------------|
256 -- ----------------------------------------------------------------------------
257 -- {Start Of Comments}
258 --
259 -- Description:
263 -- Prerequisites:
260 --   This private procedure contains any processing which is required after the
261 --   insert dml.
262 --
264 --   This is an internal procedure which is called from the ins procedure.
265 --
266 -- In Parameters:
267 --   A Pl/Sql record structre.
268 --
269 -- Post Success:
270 --   Processing continues.
271 --
272 -- Post Failure:
273 --   If an error has occurred, an error message and exception will be raised
274 --   but not handled.
275 --
276 -- Developer Implementation Notes:
277 --   Any post-processing required after the insert dml is issued should be
278 --   coded within this procedure. It is important to note that any 3rd party
279 --   maintenance should be reviewed before placing in this procedure.
280 --
281 -- Access Status:
282 --   Internal Row Handler Use Only.
283 --
284 -- {End Of Comments}
285 -- ----------------------------------------------------------------------------
286 Procedure post_insert(
287 p_effective_date in date,p_rec in ben_crt_shd.g_rec_type) is
288 --
289   l_proc  varchar2(72) := g_package||'post_insert';
290   l_old_rec ben_crt_ler.g_crt_ler_rec  ;
291   l_new_rec ben_crt_ler.g_crt_ler_rec  ;
292 --
293 Begin
294   hr_utility.set_location('Entering:'||l_proc, 5);
295 --
296   --
297   -- Start of API User Hook for post_insert.
298   --
299   begin
300     -- Call the supporting insert validate operations
301     --bug 1408379
302     l_new_rec.business_group_id := p_rec.business_group_id;
303     l_new_rec.person_id         := p_rec.person_id;
304     l_new_rec.apls_perd_strtg_dt:= p_rec.apls_perd_strtg_dt;
305     l_new_rec.apls_perd_endg_dt := p_rec.apls_perd_endg_dt;
306     l_new_rec.crt_ordr_typ_cd   := p_rec.crt_ordr_typ_cd;
307     l_new_rec.rcvd_dt           := p_rec.rcvd_dt;
308     l_new_rec.pl_id             := p_rec.pl_id;
309     l_new_rec.pl_typ_id         := p_rec.pl_typ_id;
310     l_new_rec.crt_ordr_id       := p_rec.crt_ordr_id;
311     --
312     ben_crt_rki.after_insert
313       (
314   p_crt_ordr_id                   =>p_rec.crt_ordr_id
315  ,p_crt_ordr_typ_cd               =>p_rec.crt_ordr_typ_cd
316  ,p_apls_perd_endg_dt             =>p_rec.apls_perd_endg_dt
317  ,p_apls_perd_strtg_dt            =>p_rec.apls_perd_strtg_dt
318  ,p_crt_ident                     =>p_rec.crt_ident
319  ,p_description                   =>p_rec.description
320  ,p_detd_qlfd_ordr_dt             =>p_rec.detd_qlfd_ordr_dt
321  ,p_issue_dt                      =>p_rec.issue_dt
322  ,p_qdro_amt                      =>p_rec.qdro_amt
323  ,p_qdro_dstr_mthd_cd             =>p_rec.qdro_dstr_mthd_cd
324  ,p_qdro_pct                      =>p_rec.qdro_pct
325  ,p_rcvd_dt                       =>p_rec.rcvd_dt
326  ,p_uom                           =>p_rec.uom
327  ,p_crt_issng                     =>p_rec.crt_issng
328  ,p_pl_id                         =>p_rec.pl_id
329  ,p_person_id                     =>p_rec.person_id
330  ,p_business_group_id             =>p_rec.business_group_id
331  ,p_crt_attribute_category        =>p_rec.crt_attribute_category
332  ,p_crt_attribute1                =>p_rec.crt_attribute1
333  ,p_crt_attribute2                =>p_rec.crt_attribute2
334  ,p_crt_attribute3                =>p_rec.crt_attribute3
335  ,p_crt_attribute4                =>p_rec.crt_attribute4
336  ,p_crt_attribute5                =>p_rec.crt_attribute5
337  ,p_crt_attribute6                =>p_rec.crt_attribute6
338  ,p_crt_attribute7                =>p_rec.crt_attribute7
339  ,p_crt_attribute8                =>p_rec.crt_attribute8
340  ,p_crt_attribute9                =>p_rec.crt_attribute9
341  ,p_crt_attribute10               =>p_rec.crt_attribute10
342  ,p_crt_attribute11               =>p_rec.crt_attribute11
343  ,p_crt_attribute12               =>p_rec.crt_attribute12
344  ,p_crt_attribute13               =>p_rec.crt_attribute13
345  ,p_crt_attribute14               =>p_rec.crt_attribute14
346  ,p_crt_attribute15               =>p_rec.crt_attribute15
347  ,p_crt_attribute16               =>p_rec.crt_attribute16
348  ,p_crt_attribute17               =>p_rec.crt_attribute17
349  ,p_crt_attribute18               =>p_rec.crt_attribute18
350  ,p_crt_attribute19               =>p_rec.crt_attribute19
351  ,p_crt_attribute20               =>p_rec.crt_attribute20
352  ,p_crt_attribute21               =>p_rec.crt_attribute21
353  ,p_crt_attribute22               =>p_rec.crt_attribute22
354  ,p_crt_attribute23               =>p_rec.crt_attribute23
355  ,p_crt_attribute24               =>p_rec.crt_attribute24
356  ,p_crt_attribute25               =>p_rec.crt_attribute25
357  ,p_crt_attribute26               =>p_rec.crt_attribute26
358  ,p_crt_attribute27               =>p_rec.crt_attribute27
359  ,p_crt_attribute28               =>p_rec.crt_attribute28
360  ,p_crt_attribute29               =>p_rec.crt_attribute29
361  ,p_crt_attribute30               =>p_rec.crt_attribute30
362  ,p_object_version_number         =>p_rec.object_version_number
363  ,p_qdro_num_pymt_val             =>p_rec.qdro_num_pymt_val
364  ,p_qdro_per_perd_cd              =>p_rec.qdro_per_perd_cd
365  ,p_pl_typ_id                     =>p_rec.pl_typ_id
366  ,p_effective_date                =>p_effective_date
367       );
368     --
369   hr_utility.set_location('D M Modie crt ' ||hr_general.g_data_migrator_mode , 378);
370   if hr_general.g_data_migrator_mode not in ( 'Y','P') then
371      hr_utility.set_location(' calling ler check in iensert  ' , 1408379 );
372      -- bug 1408379 the function calling moved from triiger to here
373      ben_crt_ler.ler_chk(p_old => l_old_rec,
374                       p_new => l_new_rec ,
375                       p_effective_date => p_effective_date  );
376    end if ;
377   exception
378     --
379     when hr_api.cannot_find_prog_unit then
380       --
381       hr_api.cannot_find_prog_unit_error
382         (p_module_name => 'ben_crt_ordr'
383         ,p_hook_type   => 'AI');
384       --
385   end;
386   --
387   -- End of API User Hook for post_insert.
388   --
389   --
390   hr_utility.set_location(' Leaving:'||l_proc, 10);
391 End post_insert;
392 --
393 -- ----------------------------------------------------------------------------
394 -- |---------------------------------< ins >----------------------------------|
395 -- ----------------------------------------------------------------------------
396 Procedure ins
397   (
398   p_effective_date in date,
399   p_rec        in out nocopy ben_crt_shd.g_rec_type
400   ) is
401 --
402   l_proc  varchar2(72) := g_package||'ins';
403 --
404 Begin
405   hr_utility.set_location('Entering:'||l_proc, 5);
406   --
407 
408   ben_crt_bus.insert_validate(p_rec => p_rec
409   ,p_effective_date => p_effective_date);
410   --
411   -- Call the supporting pre-insert operation
412   --
413   pre_insert(p_rec);
414   --
415   -- Insert the row
416   --
417   insert_dml(p_rec);
418   --
419   -- Call the supporting post-insert operation
420   --
421   post_insert(p_rec =>  p_rec,p_effective_Date => p_effective_date);
422 end ins;
423 --
424 -- ----------------------------------------------------------------------------
425 -- |---------------------------------< ins >----------------------------------|
426 -- ----------------------------------------------------------------------------
427 Procedure ins
428   (
429   p_effective_date in date,
430   p_crt_ordr_id                  out nocopy number,
431   p_crt_ordr_typ_cd              in varchar2,
432   p_apls_perd_endg_dt            in date             default null,
433   p_apls_perd_strtg_dt           in date             default null,
434   p_crt_ident                    in varchar2         default null,
435   p_description                  in varchar2         default null,
436   p_detd_qlfd_ordr_dt            in date             default null,
437   p_issue_dt                     in date             default null,
438   p_qdro_amt                     in number           default null,
439   p_qdro_dstr_mthd_cd            in varchar2         default null,
440   p_qdro_pct                     in number           default null,
441   p_rcvd_dt                      in date             default null,
442   p_uom                          in varchar2         default null,
443   p_crt_issng                    in varchar2         default null,
444   p_pl_id                        in number           default null,
445   p_person_id                    in number           default null,
446   p_business_group_id            in number,
447   p_crt_attribute_category       in varchar2         default null,
448   p_crt_attribute1               in varchar2         default null,
449   p_crt_attribute2               in varchar2         default null,
450   p_crt_attribute3               in varchar2         default null,
451   p_crt_attribute4               in varchar2         default null,
452   p_crt_attribute5               in varchar2         default null,
453   p_crt_attribute6               in varchar2         default null,
454   p_crt_attribute7               in varchar2         default null,
455   p_crt_attribute8               in varchar2         default null,
456   p_crt_attribute9               in varchar2         default null,
457   p_crt_attribute10              in varchar2         default null,
458   p_crt_attribute11              in varchar2         default null,
459   p_crt_attribute12              in varchar2         default null,
460   p_crt_attribute13              in varchar2         default null,
461   p_crt_attribute14              in varchar2         default null,
462   p_crt_attribute15              in varchar2         default null,
463   p_crt_attribute16              in varchar2         default null,
464   p_crt_attribute17              in varchar2         default null,
465   p_crt_attribute18              in varchar2         default null,
466   p_crt_attribute19              in varchar2         default null,
467   p_crt_attribute20              in varchar2         default null,
468   p_crt_attribute21              in varchar2         default null,
469   p_crt_attribute22              in varchar2         default null,
470   p_crt_attribute23              in varchar2         default null,
471   p_crt_attribute24              in varchar2         default null,
472   p_crt_attribute25              in varchar2         default null,
473   p_crt_attribute26              in varchar2         default null,
474   p_crt_attribute27              in varchar2         default null,
475   p_crt_attribute28              in varchar2         default null,
476   p_crt_attribute29              in varchar2         default null,
477   p_crt_attribute30              in varchar2         default null,
478   p_object_version_number        out nocopy number,
479   p_qdro_num_pymt_val            in number           default null,
480   p_qdro_per_perd_cd             in varchar2         default null,
481   p_pl_typ_id                    in number           default null
482   ) is
483 --
484   l_rec	  ben_crt_shd.g_rec_type;
485   l_proc  varchar2(72) := g_package||'ins';
486 --
487 Begin
488   hr_utility.set_location('Entering:'||l_proc, 5);
489   --
490   -- Call conversion function to turn arguments into the
491   -- p_rec structure.
492   --
493   l_rec :=
494   ben_crt_shd.convert_args
495   (
496   null,
497   p_crt_ordr_typ_cd,
498   p_apls_perd_endg_dt,
499   p_apls_perd_strtg_dt,
500   p_crt_ident,
501   p_description,
502   p_detd_qlfd_ordr_dt,
503   p_issue_dt,
504   p_qdro_amt,
505   p_qdro_dstr_mthd_cd,
506   p_qdro_pct,
507   p_rcvd_dt,
508   p_uom,
509   p_crt_issng,
510   p_pl_id,
511   p_person_id,
512   p_business_group_id,
513   p_crt_attribute_category,
514   p_crt_attribute1,
515   p_crt_attribute2,
516   p_crt_attribute3,
517   p_crt_attribute4,
518   p_crt_attribute5,
519   p_crt_attribute6,
520   p_crt_attribute7,
521   p_crt_attribute8,
522   p_crt_attribute9,
523   p_crt_attribute10,
524   p_crt_attribute11,
525   p_crt_attribute12,
526   p_crt_attribute13,
527   p_crt_attribute14,
528   p_crt_attribute15,
529   p_crt_attribute16,
530   p_crt_attribute17,
531   p_crt_attribute18,
532   p_crt_attribute19,
533   p_crt_attribute20,
534   p_crt_attribute21,
535   p_crt_attribute22,
536   p_crt_attribute23,
537   p_crt_attribute24,
538   p_crt_attribute25,
539   p_crt_attribute26,
540   p_crt_attribute27,
541   p_crt_attribute28,
542   p_crt_attribute29,
543   p_crt_attribute30,
544   null,
545   p_qdro_num_pymt_val,
546   p_qdro_per_perd_cd,
547   p_pl_typ_id
548   );
549   --
550   -- Having converted the arguments into the ben_crt_rec
551   -- plsql record structure we call the corresponding record business process.
552   --
553   ins(
554     p_effective_date,l_rec);
555   --
556   -- As the primary key argument(s)
557   -- are specified as an OUT's we must set these values.
558   --
559   p_crt_ordr_id := l_rec.crt_ordr_id;
560   p_object_version_number := l_rec.object_version_number;
561   --
562   hr_utility.set_location(' Leaving:'||l_proc, 10);
563 End ins;
564 --
565 end ben_crt_ins;