DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BPI_INS

Source


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