DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BEI_INS

Source


1 Package Body ben_bei_ins as
2 /* $Header: bebeirhi.pkb 120.0 2005/05/28 00:38:07 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_bei_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_bei_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_bei_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: ben_batch_elig_info
64   --
65   insert into ben_batch_elig_info
66   (	batch_elig_id,
67 	benefit_action_id,
68 	person_id,
69 	pgm_id,
70 	pl_id,
71 	oipl_id,
72 	elig_flag,
73 	inelig_text,
74 	business_group_id,
75 	object_version_number
76   )
77   Values
78   (	p_rec.batch_elig_id,
79 	p_rec.benefit_action_id,
80 	p_rec.person_id,
81 	p_rec.pgm_id,
82 	p_rec.pl_id,
83 	p_rec.oipl_id,
84 	p_rec.elig_flag,
85 	p_rec.inelig_text,
86 	p_rec.business_group_id,
87 	p_rec.object_version_number
88   );
89   --
90   ben_bei_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_bei_shd.g_api_dml := false;   -- Unset the api dml status
97     ben_bei_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_bei_shd.g_api_dml := false;   -- Unset the api dml status
102     ben_bei_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_bei_shd.g_api_dml := false;   -- Unset the api dml status
107     ben_bei_shd.constraint_error
108       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
109   When Others Then
110     ben_bei_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_bei_shd.g_rec_type) is
152 --
153   l_proc  varchar2(72) := g_package||'pre_insert';
154 --
155   Cursor C_Sel1 is select ben_batch_elig_info_s.nextval from sys.dual;
156 --
157 Begin
158   hr_utility.set_location('Entering:'||l_proc, 5);
159   --
160   --
161   -- Select the next sequence number
162   --
163   Open C_Sel1;
164   Fetch C_Sel1 Into p_rec.batch_elig_id;
165   Close C_Sel1;
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(p_effective_date in date,
203                       p_rec in ben_bei_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_bei_rki.after_insert
216       (p_batch_elig_id                 =>p_rec.batch_elig_id
217       ,p_benefit_action_id             =>p_rec.benefit_action_id
218       ,p_person_id                     =>p_rec.person_id
219       ,p_pgm_id                        =>p_rec.pgm_id
220       ,p_pl_id                         =>p_rec.pl_id
221       ,p_oipl_id                       =>p_rec.oipl_id
222       ,p_elig_flag                     =>p_rec.elig_flag
223       ,p_inelig_text                   =>p_rec.inelig_text
224       ,p_business_group_id             =>p_rec.business_group_id
225       ,p_object_version_number         =>p_rec.object_version_number
226       ,p_effective_date                =>p_effective_date);
227     --
228   exception
229     --
230     when hr_api.cannot_find_prog_unit then
231       --
232       hr_api.cannot_find_prog_unit_error
233         (p_module_name => 'ben_batch_elig_info'
234         ,p_hook_type   => 'AI');
235       --
236   end;
237   --
238   -- End of API User Hook for post_insert.
239   --
240   --
241   hr_utility.set_location(' Leaving:'||l_proc, 10);
242 End post_insert;
243 --
244 -- ----------------------------------------------------------------------------
245 -- |---------------------------------< ins >----------------------------------|
246 -- ----------------------------------------------------------------------------
247 Procedure ins
248   (
249   p_effective_date in date,
250   p_rec        in out nocopy ben_bei_shd.g_rec_type
251   ) is
252 --
253   l_proc  varchar2(72) := g_package||'ins';
254 --
255 Begin
256   hr_utility.set_location('Entering:'||l_proc, 5);
257   --
258   -- Call the supporting insert validate operations
259   --
260   ben_bei_bus.insert_validate(p_rec,p_effective_date);
261   --
262   -- Call the supporting pre-insert operation
263   --
264   pre_insert(p_rec);
265   --
266   -- Insert the row
267   --
268   insert_dml(p_rec);
269   --
270   -- Call the supporting post-insert operation
271   --
272   post_insert(p_effective_date,p_rec);
273   --
274 end ins;
275 --
276 -- ----------------------------------------------------------------------------
277 -- |---------------------------------< ins >----------------------------------|
278 -- ----------------------------------------------------------------------------
279 Procedure ins
280   (
281   p_effective_date in date,
282   p_batch_elig_id                out nocopy number,
283   p_benefit_action_id            in number,
284   p_person_id                    in number,
285   p_pgm_id                       in number           default null,
286   p_pl_id                        in number           default null,
287   p_oipl_id                      in number           default null,
288   p_elig_flag                    in varchar2,
289   p_inelig_text                  in varchar2         default null,
290   p_business_group_id            in number,
291   p_object_version_number        out nocopy number
292   ) is
293 --
294   l_rec	  ben_bei_shd.g_rec_type;
295   l_proc  varchar2(72) := g_package||'ins';
296 --
297 Begin
298   hr_utility.set_location('Entering:'||l_proc, 5);
299   --
300   -- Call conversion function to turn arguments into the
301   -- p_rec structure.
302   --
303   l_rec :=
304   ben_bei_shd.convert_args
305   (
306   null,
307   p_benefit_action_id,
308   p_person_id,
309   p_pgm_id,
310   p_pl_id,
311   p_oipl_id,
312   p_elig_flag,
313   p_inelig_text,
314   p_business_group_id,
315   null
316   );
317   --
318   -- Having converted the arguments into the ben_bei_rec
319   -- plsql record structure we call the corresponding record business process.
320   --
321   ins(p_effective_date,l_rec);
322   --
323   -- As the primary key argument(s)
324   -- are specified as an OUT's we must set these values.
325   --
326   p_batch_elig_id := l_rec.batch_elig_id;
327   p_object_version_number := l_rec.object_version_number;
328   --
329   hr_utility.set_location(' Leaving:'||l_proc, 10);
330 End ins;
331 --
332 end ben_bei_ins;