DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BLI_INS

Source


1 Package Body ben_bli_ins as
2 /* $Header: beblirhi.pkb 115.7 2002/12/10 15:17:02 bmanyam ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_bli_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_bli_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_bli_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: ben_batch_ler_info
64   --
65   insert into ben_batch_ler_info
66   (	batch_ler_id,
67 	benefit_action_id,
68 	person_id,
69 	ler_id,
70 	lf_evt_ocrd_dt,
71 	replcd_flag,
72 	crtd_flag,
73 	tmprl_flag,
74 	dltd_flag,
75         open_and_clsd_flag,
76         clsd_flag,
77         not_crtd_flag,
78         stl_actv_flag,
79         clpsd_flag,
80         clsn_flag,
81         no_effect_flag,
82         cvrge_rt_prem_flag,
83 	per_in_ler_id,
84 	business_group_id,
85 	object_version_number
86   )
87   Values
88   (	p_rec.batch_ler_id,
89 	p_rec.benefit_action_id,
90 	p_rec.person_id,
91 	p_rec.ler_id,
92 	p_rec.lf_evt_ocrd_dt,
93 	p_rec.replcd_flag,
94 	p_rec.crtd_flag,
95 	p_rec.tmprl_flag,
96 	p_rec.dltd_flag,
97         p_rec.open_and_clsd_flag,
98         p_rec.clsd_flag,
99         p_rec.not_crtd_flag,
100         p_rec.stl_actv_flag,
101         p_rec.clpsd_flag,
102         p_rec.clsn_flag,
103         p_rec.no_effect_flag,
104         p_rec.cvrge_rt_prem_flag,
105 	p_rec.per_in_ler_id,
106 	p_rec.business_group_id,
107 	p_rec.object_version_number
108   );
109   --
110   ben_bli_shd.g_api_dml := false;   -- Unset the api dml status
111   --
112   hr_utility.set_location(' Leaving:'||l_proc, 10);
113 Exception
114   When hr_api.check_integrity_violated Then
115     -- A check constraint has been violated
116     ben_bli_shd.g_api_dml := false;   -- Unset the api dml status
117     ben_bli_shd.constraint_error
118       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
119   When hr_api.parent_integrity_violated Then
120     -- Parent integrity has been violated
121     ben_bli_shd.g_api_dml := false;   -- Unset the api dml status
122     ben_bli_shd.constraint_error
123       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
124   When hr_api.unique_integrity_violated Then
125     -- Unique integrity has been violated
126     ben_bli_shd.g_api_dml := false;   -- Unset the api dml status
127     ben_bli_shd.constraint_error
128       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
129   When Others Then
130     ben_bli_shd.g_api_dml := false;   -- Unset the api dml status
131     Raise;
132 End insert_dml;
133 --
134 -- ----------------------------------------------------------------------------
135 -- |------------------------------< pre_insert >------------------------------|
136 -- ----------------------------------------------------------------------------
137 -- {Start Of Comments}
138 --
139 -- Description:
140 --   This private procedure contains any processing which is required before
141 --   the insert dml. Presently, if the entity has a corresponding primary
145 --
142 --   key which is maintained by an associating sequence, the primary key for
143 --   the entity will be populated with the next sequence value in
144 --   preparation for the insert dml.
146 -- Prerequisites:
147 --   This is an internal procedure which is called from the ins procedure.
148 --
149 -- In Parameters:
150 --   A Pl/Sql record structre.
151 --
152 -- Post Success:
153 --   Processing continues.
154 --
155 -- Post Failure:
156 --   If an error has occurred, an error message and exception will be raised
157 --   but not handled.
158 --
159 -- Developer Implementation Notes:
160 --   Any pre-processing required before the insert dml is issued should be
161 --   coded within this procedure. As stated above, a good example is the
162 --   generation of a primary key number via a corresponding sequence.
163 --   It is important to note that any 3rd party maintenance should be reviewed
164 --   before placing in this procedure.
165 --
166 -- Access Status:
167 --   Internal Row Handler Use Only.
168 --
169 -- {End Of Comments}
170 -- ----------------------------------------------------------------------------
171 Procedure pre_insert(p_rec  in out nocopy ben_bli_shd.g_rec_type) is
172 --
173   l_proc  varchar2(72) := g_package||'pre_insert';
174 --
175   Cursor C_Sel1 is select ben_batch_ler_info_s.nextval from sys.dual;
176 --
177 Begin
178   hr_utility.set_location('Entering:'||l_proc, 5);
179   --
180   --
181   -- Select the next sequence number
182   --
183   Open C_Sel1;
184   Fetch C_Sel1 Into p_rec.batch_ler_id;
185   Close C_Sel1;
186   --
187   hr_utility.set_location(' Leaving:'||l_proc, 10);
188 End pre_insert;
189 --
190 -- ----------------------------------------------------------------------------
191 -- |-----------------------------< post_insert >------------------------------|
192 -- ----------------------------------------------------------------------------
193 -- {Start Of Comments}
194 --
195 -- Description:
196 --   This private procedure contains any processing which is required after the
197 --   insert dml.
198 --
199 -- Prerequisites:
200 --   This is an internal procedure which is called from the ins procedure.
201 --
202 -- In Parameters:
203 --   A Pl/Sql record structre.
204 --
205 -- Post Success:
206 --   Processing continues.
207 --
208 -- Post Failure:
209 --   If an error has occurred, an error message and exception will be raised
210 --   but not handled.
211 --
212 -- Developer Implementation Notes:
213 --   Any post-processing required after the insert dml is issued should be
214 --   coded within this procedure. It is important to note that any 3rd party
215 --   maintenance should be reviewed before placing in this procedure.
216 --
217 -- Access Status:
218 --   Internal Row Handler Use Only.
219 --
220 -- {End Of Comments}
221 -- ----------------------------------------------------------------------------
222 Procedure post_insert(
223 p_effective_date in date,p_rec in ben_bli_shd.g_rec_type) is
224 --
225   l_proc  varchar2(72) := g_package||'post_insert';
226 --
227 Begin
228   hr_utility.set_location('Entering:'||l_proc, 5);
229 --
230   --
231   -- Start of API User Hook for post_insert.
232   --
233   begin
234     --
235     ben_bli_rki.after_insert
236       (p_batch_ler_id                  =>p_rec.batch_ler_id
237       ,p_benefit_action_id             =>p_rec.benefit_action_id
238       ,p_person_id                     =>p_rec.person_id
239       ,p_ler_id                        =>p_rec.ler_id
240       ,p_lf_evt_ocrd_dt                =>p_rec.lf_evt_ocrd_dt
241       ,p_replcd_flag                   =>p_rec.replcd_flag
242       ,p_crtd_flag                     =>p_rec.crtd_flag
243       ,p_tmprl_flag                    =>p_rec.tmprl_flag
244       ,p_dltd_flag                     =>p_rec.dltd_flag
245       ,p_open_and_clsd_flag            =>p_rec.open_and_clsd_flag
246       ,p_clsd_flag                     =>p_rec.clsd_flag
247       ,p_not_crtd_flag                 =>p_rec.not_crtd_flag
248       ,p_stl_actv_flag                 =>p_rec.stl_actv_flag
249       ,p_clpsd_flag                    =>p_rec.clpsd_flag
250       ,p_clsn_flag                     =>p_rec.clsn_flag
251       ,p_no_effect_flag                =>p_rec.no_effect_flag
252       ,p_cvrge_rt_prem_flag            =>p_rec.cvrge_rt_prem_flag
253       ,p_per_in_ler_id                 =>p_rec.per_in_ler_id
254       ,p_business_group_id             =>p_rec.business_group_id
255       ,p_object_version_number         =>p_rec.object_version_number
256       ,p_effective_date                =>p_effective_date);
257     --
258   exception
259     --
260     when hr_api.cannot_find_prog_unit then
261       --
262       hr_api.cannot_find_prog_unit_error
263         (p_module_name => 'ben_batch_ler_info'
264         ,p_hook_type   => 'AI');
265       --
266   end;
267   --
268   -- End of API User Hook for post_insert.
269   --
270   --
271   hr_utility.set_location(' Leaving:'||l_proc, 10);
272 End post_insert;
273 --
274 -- ----------------------------------------------------------------------------
275 -- |---------------------------------< ins >----------------------------------|
276 -- ----------------------------------------------------------------------------
277 Procedure ins
278   (
279   p_effective_date in date,
280   p_rec        in out nocopy ben_bli_shd.g_rec_type
281   ) is
282 --
283   l_proc  varchar2(72) := g_package||'ins';
284 --
285 Begin
286   hr_utility.set_location('Entering:'||l_proc, 5);
287   --
288   -- Call the supporting insert validate operations
289   --
293   --
290   ben_bli_bus.insert_validate(p_rec,p_effective_date);
291   --
292   -- Call the supporting pre-insert operation
294   pre_insert(p_rec);
295   --
296   -- Insert the row
297   --
298   insert_dml(p_rec);
299   --
300   -- Call the supporting post-insert operation
301   --
302   post_insert(p_effective_date,p_rec);
303   --
304 end ins;
305 --
306 -- ----------------------------------------------------------------------------
307 -- |---------------------------------< ins >----------------------------------|
308 -- ----------------------------------------------------------------------------
309 Procedure ins
310   (
311   p_effective_date in date,
312   p_batch_ler_id                 out nocopy number,
313   p_benefit_action_id            in number,
314   p_person_id                    in number,
315   p_ler_id                       in number,
316   p_lf_evt_ocrd_dt               in date,
317   p_replcd_flag                  in varchar2,
318   p_crtd_flag                    in varchar2,
319   p_tmprl_flag                   in varchar2,
320   p_dltd_flag                    in varchar2,
321   p_open_and_clsd_flag           in varchar2,
322   p_clsd_flag                    in varchar2,
323   p_not_crtd_flag                in varchar2,
324   p_stl_actv_flag                in varchar2,
325   p_clpsd_flag                   in varchar2,
326   p_clsn_flag                    in varchar2,
327   p_no_effect_flag               in varchar2,
328   p_cvrge_rt_prem_flag           in varchar2,
329   p_per_in_ler_id                in number,
330   p_business_group_id            in number,
331   p_object_version_number        out nocopy number
332   ) is
333 --
334   l_rec	  ben_bli_shd.g_rec_type;
335   l_proc  varchar2(72) := g_package||'ins';
336 --
337 Begin
338   hr_utility.set_location('Entering:'||l_proc, 5);
339   --
340   -- Call conversion function to turn arguments into the
341   -- p_rec structure.
342   --
343   l_rec :=
344   ben_bli_shd.convert_args
345   (
346   null,
347   p_benefit_action_id,
348   p_person_id,
349   p_ler_id,
350   p_lf_evt_ocrd_dt,
351   p_replcd_flag,
352   p_crtd_flag,
353   p_tmprl_flag,
354   p_dltd_flag,
355   p_open_and_clsd_flag,
356   p_clsd_flag,
357   p_not_crtd_flag,
358   p_stl_actv_flag,
359   p_clpsd_flag,
360   p_clsn_flag,
361   p_no_effect_flag,
362   p_cvrge_rt_prem_flag,
363   p_per_in_ler_id,
364   p_business_group_id,
365   null
366   );
367   --
368   -- Having converted the arguments into the ben_bli_rec
369   -- plsql record structure we call the corresponding record business process.
370   --
371   ins(p_effective_date,l_rec);
372   --
373   -- As the primary key argument(s)
374   -- are specified as an OUT's we must set these values.
375   --
376   p_batch_ler_id := l_rec.batch_ler_id;
377   p_object_version_number := l_rec.object_version_number;
378   --
379   hr_utility.set_location(' Leaving:'||l_proc, 10);
380 End ins;
381 --
382 end ben_bli_ins;