DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BAI_INS

Source


1 Package Body ben_bai_ins as
2 /* $Header: bebairhi.pkb 115.7 2002/12/13 06:21:35 hmani ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_bai_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_bai_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_bai_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: ben_batch_actn_item_info
64   --
65   insert into ben_batch_actn_item_info
66   (	batch_actn_item_id,
67 	benefit_action_id,
68 	person_id,
69 	actn_typ_id,
70 	cmpltd_dt,
71 	due_dt,
72 	rqd_flag,
73 	actn_cd,
74 	business_group_id,
75 	object_version_number
76   )
77   Values
78   (	p_rec.batch_actn_item_id,
79 	p_rec.benefit_action_id,
80 	p_rec.person_id,
81 	p_rec.actn_typ_id,
82 	p_rec.cmpltd_dt,
83 	p_rec.due_dt,
84 	p_rec.rqd_flag,
85 	p_rec.actn_cd,
86 	p_rec.business_group_id,
87 	p_rec.object_version_number
88   );
89   --
90   ben_bai_shd.g_api_dml := false;   -- Unset the api dml status
91   --
92   hr_utility.set_location(' Leaving:'||l_proc, 10);
93 Exception
94   When hr_api.check_integrity_violated Then
95     -- A check constraint has been violated
96     ben_bai_shd.g_api_dml := false;   -- Unset the api dml status
97     ben_bai_shd.constraint_error
98       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
99   When hr_api.parent_integrity_violated Then
100     -- Parent integrity has been violated
101     ben_bai_shd.g_api_dml := false;   -- Unset the api dml status
102     ben_bai_shd.constraint_error
103       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
104   When hr_api.unique_integrity_violated Then
105     -- Unique integrity has been violated
106     ben_bai_shd.g_api_dml := false;   -- Unset the api dml status
107     ben_bai_shd.constraint_error
108       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
109   When Others Then
110     ben_bai_shd.g_api_dml := false;   -- Unset the api dml status
111     Raise;
112 End insert_dml;
113 --
114 -- ----------------------------------------------------------------------------
115 -- |------------------------------< pre_insert >------------------------------|
116 -- ----------------------------------------------------------------------------
117 -- {Start Of Comments}
118 --
119 -- Description:
120 --   This private procedure contains any processing which is required before
121 --   the insert dml. Presently, if the entity has a corresponding primary
122 --   key which is maintained by an associating sequence, the primary key for
123 --   the entity will be populated with the next sequence value in
124 --   preparation for the insert dml.
125 --
126 -- Prerequisites:
127 --   This is an internal procedure which is called from the ins procedure.
128 --
129 -- In Parameters:
130 --   A Pl/Sql record structre.
131 --
132 -- Post Success:
133 --   Processing continues.
134 --
135 -- Post Failure:
136 --   If an error has occurred, an error message and exception will be raised
137 --   but not handled.
138 --
139 -- Developer Implementation Notes:
140 --   Any pre-processing required before the insert dml is issued should be
141 --   coded within this procedure. As stated above, a good example is the
142 --   generation of a primary key number via a corresponding sequence.
143 --   It is important to note that any 3rd party maintenance should be reviewed
144 --   before placing in this procedure.
145 --
146 -- Access Status:
147 --   Internal Row Handler Use Only.
148 --
149 -- {End Of Comments}
150 -- ----------------------------------------------------------------------------
151 Procedure pre_insert(p_rec  in out nocopy ben_bai_shd.g_rec_type) is
152 --
153   l_proc  varchar2(72) := g_package||'pre_insert';
154 --
155   cursor c1 is
156     select ben_batch_bnft_cert_info_s.nextval from sys.dual;
157 --
158 --
159 Begin
160   hr_utility.set_location('Entering:'||l_proc, 5);
161   --
162   open c1;
163   fetch c1 into p_rec.batch_actn_item_id;
164   close c1;
165   --
166   --
167   hr_utility.set_location(' Leaving:'||l_proc, 10);
168 End pre_insert;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |-----------------------------< post_insert >------------------------------|
172 -- ----------------------------------------------------------------------------
173 -- {Start Of Comments}
174 --
175 -- Description:
176 --   This private procedure contains any processing which is required after the
177 --   insert dml.
178 --
179 -- Prerequisites:
180 --   This is an internal procedure which is called from the ins procedure.
181 --
182 -- In Parameters:
183 --   A Pl/Sql record structre.
184 --
185 -- Post Success:
186 --   Processing continues.
187 --
188 -- Post Failure:
189 --   If an error has occurred, an error message and exception will be raised
190 --   but not handled.
191 --
192 -- Developer Implementation Notes:
193 --   Any post-processing required after the insert dml is issued should be
194 --   coded within this procedure. It is important to note that any 3rd party
195 --   maintenance should be reviewed before placing in this procedure.
196 --
197 -- Access Status:
198 --   Internal Row Handler Use Only.
199 --
200 -- {End Of Comments}
201 -- ----------------------------------------------------------------------------
202 Procedure post_insert(
203 p_effective_date in date,p_rec in ben_bai_shd.g_rec_type) is
204 --
205   l_proc  varchar2(72) := g_package||'post_insert';
206 --
207 Begin
208   hr_utility.set_location('Entering:'||l_proc, 5);
209 --
210   --
211   -- Start of API User Hook for post_insert.
212   --
213   begin
214     --
215     ben_bai_rki.after_insert
216       (
217   p_batch_actn_item_id            =>p_rec.batch_actn_item_id
218  ,p_benefit_action_id             =>p_rec.benefit_action_id
219  ,p_person_id                     =>p_rec.person_id
220  ,p_actn_typ_id                   =>p_rec.actn_typ_id
224  ,p_actn_cd                       =>p_rec.actn_cd
221  ,p_cmpltd_dt                     =>p_rec.cmpltd_dt
222  ,p_due_dt                        =>p_rec.due_dt
223  ,p_rqd_flag                      =>p_rec.rqd_flag
225  ,p_business_group_id             =>p_rec.business_group_id
226  ,p_object_version_number         =>p_rec.object_version_number
227  ,p_effective_date                =>p_effective_date
228       );
229     --
230   exception
231     --
232     when hr_api.cannot_find_prog_unit then
233       --
234       hr_api.cannot_find_prog_unit_error
235         (p_module_name => 'ben_batch_actn_item_info'
236         ,p_hook_type   => 'AI');
237       --
238   end;
239   --
240   -- End of API User Hook for post_insert.
241   --
242   --
243   hr_utility.set_location(' Leaving:'||l_proc, 10);
244 End post_insert;
245 --
246 -- ----------------------------------------------------------------------------
247 -- |---------------------------------< ins >----------------------------------|
248 -- ----------------------------------------------------------------------------
249 Procedure ins
250   (
251   p_effective_date in date,
252   p_rec        in out nocopy ben_bai_shd.g_rec_type
253   ) is
254 --
255   l_proc  varchar2(72) := g_package||'ins';
256 --
257 Begin
258   hr_utility.set_location('Entering:'||l_proc, 5);
259   --
260   -- Call the supporting insert validate operations
261   --
262   ben_bai_bus.insert_validate(p_rec
263   ,p_effective_date);
264   --
265   -- Call the supporting pre-insert operation
266   --
267   pre_insert(p_rec);
268   --
269   -- Insert the row
270   --
271   insert_dml(p_rec);
272   --
273   -- Call the supporting post-insert operation
274   --
275   post_insert(
276 p_effective_date,p_rec);
277 end ins;
278 --
279 -- ----------------------------------------------------------------------------
280 -- |---------------------------------< ins >----------------------------------|
281 -- ----------------------------------------------------------------------------
282 Procedure ins
283   (
284   p_effective_date in date,
285   p_batch_actn_item_id           out nocopy number,
286   p_benefit_action_id            in number,
287   p_person_id                    in number,
288   p_actn_typ_id                  in number           default null,
289   p_cmpltd_dt                    in date             default null,
290   p_due_dt                       in date             default null,
291   p_rqd_flag                     in varchar2         default null,
292   p_actn_cd                      in varchar2         default null,
293   p_business_group_id            in number,
294   p_object_version_number        out nocopy number
295   ) is
296 --
297   l_rec	  ben_bai_shd.g_rec_type;
298   l_proc  varchar2(72) := g_package||'ins';
299 --
300 Begin
301   hr_utility.set_location('Entering:'||l_proc, 5);
302   --
303   -- Call conversion function to turn arguments into the
304   -- p_rec structure.
305   --
306   l_rec :=
307   ben_bai_shd.convert_args
308   (
309   null,
310   p_benefit_action_id,
311   p_person_id,
312   p_actn_typ_id,
313   p_cmpltd_dt,
314   p_due_dt,
315   p_rqd_flag,
316   p_actn_cd,
317   p_business_group_id,
318   null
319   );
320   --
321   -- Having converted the arguments into the ben_bai_rec
322   -- plsql record structure we call the corresponding record business process.
323   --
324   ins(
325     p_effective_date,l_rec);
326   --
327   -- As the primary key argument(s)
328   -- are specified as an OUT's we must set these values.
329   --
330   p_batch_actn_item_id := l_rec.batch_actn_item_id;
331   p_object_version_number := l_rec.object_version_number;
332   --
333   hr_utility.set_location(' Leaving:'||l_proc, 10);
334 End ins;
335 --
336 end ben_bai_ins;