DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XRS_INS

Source


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