DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQP_DET_INS

Source


1 Package Body pqp_det_ins as
2 /* $Header: pqdetrhi.pkb 115.8 2003/02/17 22:14:03 tmehra ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqp_det_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 pqp_det_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   pqp_det_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: pqp_analyzed_alien_details
64   --
65   insert into pqp_analyzed_alien_details
66   (	analyzed_data_details_id,
67 	analyzed_data_id,
68 	income_code,
69 	withholding_rate,
70 	income_code_sub_type,
71 	exemption_code,
72 	maximum_benefit_amount,
73 	retro_lose_ben_amt_flag,
74 	date_benefit_ends,
75 	retro_lose_ben_date_flag,
76 	nra_exempt_from_ss,
77 	nra_exempt_from_medicare,
78 	student_exempt_from_ss,
79 	student_exempt_from_medicare,
80 	addl_withholding_flag,
81 	constant_addl_tax,
82 	addl_withholding_amt,
83 	addl_wthldng_amt_period_type,
84 	personal_exemption,
85 	addl_exemption_allowed,
86 	treaty_ben_allowed_flag,
87 	treaty_benefits_start_date,
88 	object_version_number,
89         retro_loss_notification_sent,
90         current_analysis,
91         forecast_income_code
92   )
93   Values
94   (	p_rec.analyzed_data_details_id,
95 	p_rec.analyzed_data_id,
96 	p_rec.income_code,
97 	p_rec.withholding_rate,
98 	p_rec.income_code_sub_type,
99 	p_rec.exemption_code,
100 	p_rec.maximum_benefit_amount,
101 	p_rec.retro_lose_ben_amt_flag,
102 	p_rec.date_benefit_ends,
103 	p_rec.retro_lose_ben_date_flag,
104 	p_rec.nra_exempt_from_ss,
105 	p_rec.nra_exempt_from_medicare,
106 	p_rec.student_exempt_from_ss,
107 	p_rec.student_exempt_from_medicare,
108 	p_rec.addl_withholding_flag,
109 	p_rec.constant_addl_tax,
110 	p_rec.addl_withholding_amt,
111 	p_rec.addl_wthldng_amt_period_type,
112 	p_rec.personal_exemption,
113 	p_rec.addl_exemption_allowed,
114 	p_rec.treaty_ben_allowed_flag,
115 	p_rec.treaty_benefits_start_date,
116 	p_rec.object_version_number,
117         p_rec.retro_loss_notification_sent,
118         p_rec.current_analysis,
119         p_rec.forecast_income_code
120   );
121   --
122   pqp_det_shd.g_api_dml := false;   -- Unset the api dml status
123   --
124   hr_utility.set_location(' Leaving:'||l_proc, 10);
125 Exception
126   When hr_api.check_integrity_violated Then
127     -- A check constraint has been violated
128     pqp_det_shd.g_api_dml := false;   -- Unset the api dml status
129     pqp_det_shd.constraint_error
130       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
131   When hr_api.parent_integrity_violated Then
132     -- Parent integrity has been violated
133     pqp_det_shd.g_api_dml := false;   -- Unset the api dml status
134     pqp_det_shd.constraint_error
135       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
136   When hr_api.unique_integrity_violated Then
137     -- Unique integrity has been violated
138     pqp_det_shd.g_api_dml := false;   -- Unset the api dml status
139     pqp_det_shd.constraint_error
140       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
141   When Others Then
142     pqp_det_shd.g_api_dml := false;   -- Unset the api dml status
143     Raise;
144 End insert_dml;
145 --
146 -- ----------------------------------------------------------------------------
147 -- |------------------------------< pre_insert >------------------------------|
148 -- ----------------------------------------------------------------------------
149 -- {Start Of Comments}
150 --
151 -- Description:
152 --   This private procedure contains any processing which is required before
153 --   the insert dml. Presently, if the entity has a corresponding primary
154 --   key which is maintained by an associating sequence, the primary key for
155 --   the entity will be populated with the next sequence value in
156 --   preparation for the insert dml.
157 --
158 -- Prerequisites:
159 --   This is an internal procedure which is called from the ins procedure.
160 --
161 -- In Parameters:
162 --   A Pl/Sql record structre.
163 --
164 -- Post Success:
165 --   Processing continues.
166 --
167 -- Post Failure:
168 --   If an error has occurred, an error message and exception will be raised
169 --   but not handled.
170 --
171 -- Developer Implementation Notes:
172 --   Any pre-processing required before the insert dml is issued should be
173 --   coded within this procedure. As stated above, a good example is the
174 --   generation of a primary key number via a corresponding sequence.
175 --   It is important to note that any 3rd party maintenance should be reviewed
176 --   before placing in this procedure.
177 --
178 -- Access Status:
179 --   Internal Row Handler Use Only.
180 --
181 -- {End Of Comments}
182 -- ----------------------------------------------------------------------------
183 Procedure pre_insert(p_rec  in out nocopy pqp_det_shd.g_rec_type) is
184 --
185   l_proc  varchar2(72) := g_package||'pre_insert';
186 --
187   Cursor C_Sel1 is select pqp_analyzed_alien_details_s.nextval from sys.dual;
188 --
189 Begin
190   hr_utility.set_location('Entering:'||l_proc, 5);
191   --
192   --
193   -- Select the next sequence number
194   --
195   Open C_Sel1;
196   Fetch C_Sel1 Into p_rec.analyzed_data_details_id;
197   Close C_Sel1;
198   --
199   hr_utility.set_location(' Leaving:'||l_proc, 10);
200 End pre_insert;
201 --
202 -- ----------------------------------------------------------------------------
203 -- |-----------------------------< post_insert >------------------------------|
204 -- ----------------------------------------------------------------------------
205 -- {Start Of Comments}
206 --
207 -- Description:
208 --   This private procedure contains any processing which is required after the
209 --   insert dml.
210 --
211 -- Prerequisites:
212 --   This is an internal procedure which is called from the ins procedure.
213 --
214 -- In Parameters:
215 --   A Pl/Sql record structre.
216 --
217 -- Post Success:
218 --   Processing continues.
219 --
220 -- Post Failure:
221 --   If an error has occurred, an error message and exception will be raised
222 --   but not handled.
223 --
224 -- Developer Implementation Notes:
225 --   Any post-processing required after the insert dml is issued should be
226 --   coded within this procedure. It is important to note that any 3rd party
227 --   maintenance should be reviewed before placing in this procedure.
228 --
229 -- Access Status:
230 --   Internal Row Handler Use Only.
231 --
232 -- {End Of Comments}
233 -- ----------------------------------------------------------------------------
234 Procedure post_insert(
235 p_effective_date in date,p_rec in pqp_det_shd.g_rec_type) is
236 --
237   l_proc  varchar2(72) := g_package||'post_insert';
238 --
239 Begin
240   hr_utility.set_location('Entering:'||l_proc, 5);
241 --
242   --
243   -- Start of API User Hook for post_insert.
244   --
245   begin
246     --
247     pqp_det_rki.after_insert
248       (
249   p_analyzed_data_details_id      =>p_rec.analyzed_data_details_id
250  ,p_analyzed_data_id              =>p_rec.analyzed_data_id
251  ,p_income_code                   =>p_rec.income_code
252  ,p_withholding_rate              =>p_rec.withholding_rate
253  ,p_income_code_sub_type          =>p_rec.income_code_sub_type
254  ,p_exemption_code                =>p_rec.exemption_code
255  ,p_maximum_benefit_amount        =>p_rec.maximum_benefit_amount
256  ,p_retro_lose_ben_amt_flag       =>p_rec.retro_lose_ben_amt_flag
257  ,p_date_benefit_ends             =>p_rec.date_benefit_ends
258  ,p_retro_lose_ben_date_flag      =>p_rec.retro_lose_ben_date_flag
259  ,p_nra_exempt_from_ss            =>p_rec.nra_exempt_from_ss
260  ,p_nra_exempt_from_medicare      =>p_rec.nra_exempt_from_medicare
261  ,p_student_exempt_from_ss        =>p_rec.student_exempt_from_ss
262  ,p_student_exempt_from_medi      =>p_rec.student_exempt_from_medicare
263  ,p_addl_withholding_flag         =>p_rec.addl_withholding_flag
264  ,p_constant_addl_tax             =>p_rec.constant_addl_tax
265  ,p_addl_withholding_amt          =>p_rec.addl_withholding_amt
266  ,p_addl_wthldng_amt_period_type  =>p_rec.addl_wthldng_amt_period_type
267  ,p_personal_exemption            =>p_rec.personal_exemption
268  ,p_addl_exemption_allowed        =>p_rec.addl_exemption_allowed
269  ,p_treaty_ben_allowed_flag       =>p_rec.treaty_ben_allowed_flag
270  ,p_treaty_benefits_start_date    =>p_rec.treaty_benefits_start_date
271  ,p_object_version_number         =>p_rec.object_version_number
272  ,p_effective_date                =>p_effective_date
273  ,p_retro_loss_notification_sent  =>p_rec.retro_loss_notification_sent
274  ,p_current_analysis              =>p_rec.current_analysis
275  ,p_forecast_income_code          =>p_rec.forecast_income_code
276       );
277     --
278   exception
279     --
280     when hr_api.cannot_find_prog_unit then
281       --
282       hr_api.cannot_find_prog_unit_error
283         (p_module_name => 'PQP_ANALYZED_ALIEN_DET'
284         ,p_hook_type   => 'AI');
285       --
286   end;
287   --
288   -- End of API User Hook for post_insert.
289   --
290   --
291   hr_utility.set_location(' Leaving:'||l_proc, 10);
292 End post_insert;
293 --
294 -- ----------------------------------------------------------------------------
295 -- |---------------------------------< ins >----------------------------------|
296 -- ----------------------------------------------------------------------------
297 Procedure ins
298   (
299   p_effective_date in date,
300   p_rec        in out nocopy pqp_det_shd.g_rec_type
301   ) is
302 --
303   l_proc  varchar2(72) := g_package||'ins';
304 --
305 Begin
306   hr_utility.set_location('Entering:'||l_proc, 5);
307   --
308   -- Call the supporting insert validate operations
309   --
310   pqp_det_bus.insert_validate(p_rec
311   ,p_effective_date);
312   --
313   -- Call the supporting pre-insert operation
314   --
315   pre_insert(p_rec);
316   --
317   -- Insert the row
318   --
319   insert_dml(p_rec);
320   --
321   -- Call the supporting post-insert operation
322   --
323   post_insert(
324 p_effective_date,p_rec);
325 end ins;
326 --
327 -- ----------------------------------------------------------------------------
328 -- |---------------------------------< ins >----------------------------------|
329 -- ----------------------------------------------------------------------------
330 Procedure ins
331   (
332   p_effective_date in date,
333   p_analyzed_data_details_id     out nocopy number,
334   p_analyzed_data_id             in number,
335   p_income_code                  in varchar2         default null,
336   p_withholding_rate             in number           default null,
337   p_income_code_sub_type         in varchar2         default null,
338   p_exemption_code               in varchar2         default null,
339   p_maximum_benefit_amount       in number           default null,
340   p_retro_lose_ben_amt_flag      in varchar2         default null,
341   p_date_benefit_ends            in date             default null,
342   p_retro_lose_ben_date_flag     in varchar2         default null,
343   p_nra_exempt_from_ss           in varchar2         default null,
344   p_nra_exempt_from_medicare     in varchar2         default null,
345   p_student_exempt_from_ss       in varchar2         default null,
346   p_student_exempt_from_medi     in varchar2         default null,
347   p_addl_withholding_flag        in varchar2         default null,
348   p_constant_addl_tax            in number           default null,
349   p_addl_withholding_amt         in number           default null,
350   p_addl_wthldng_amt_period_type in varchar2         default null,
351   p_personal_exemption           in number           default null,
352   p_addl_exemption_allowed       in number           default null,
353   p_treaty_ben_allowed_flag      in varchar2         default null,
354   p_treaty_benefits_start_date   in date             default null,
355   p_object_version_number        out nocopy number,
356   p_retro_loss_notification_sent in varchar2         default null,
357   p_current_analysis             in varchar2         default null,
358   p_forecast_income_code         in varchar2         default null
359   ) is
360 --
361   l_rec	  pqp_det_shd.g_rec_type;
362   l_proc  varchar2(72) := g_package||'ins';
363 --
364 Begin
365   hr_utility.set_location('Entering:'||l_proc, 5);
366   --
367   -- Call conversion function to turn arguments into the
368   -- p_rec structure.
369   --
370   l_rec :=
371   pqp_det_shd.convert_args
372   (
373   null,
374   p_analyzed_data_id,
375   p_income_code,
376   p_withholding_rate,
377   p_income_code_sub_type,
378   p_exemption_code,
379   p_maximum_benefit_amount,
380   p_retro_lose_ben_amt_flag,
381   p_date_benefit_ends,
382   p_retro_lose_ben_date_flag,
383   p_nra_exempt_from_ss,
384   p_nra_exempt_from_medicare,
385   p_student_exempt_from_ss,
386   p_student_exempt_from_medi,
387   p_addl_withholding_flag,
388   p_constant_addl_tax,
389   p_addl_withholding_amt,
390   p_addl_wthldng_amt_period_type,
391   p_personal_exemption,
392   p_addl_exemption_allowed,
393   p_treaty_ben_allowed_flag,
394   p_treaty_benefits_start_date,
395   null,
396   p_retro_loss_notification_sent,
397   p_current_analysis,
398   p_forecast_income_code
399   );
400   --
401   -- Having converted the arguments into the det_rec
402   -- plsql record structure we call the corresponding record business process.
403   --
404   ins(
405     p_effective_date,l_rec);
406   --
407   -- As the primary key argument(s)
408   -- are specified as an OUT's we must set these values.
409   --
410   p_analyzed_data_details_id := l_rec.analyzed_data_details_id;
411   p_object_version_number := l_rec.object_version_number;
412   --
413   hr_utility.set_location(' Leaving:'||l_proc, 10);
414 End ins;
415 --
416 end pqp_det_ins;