DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQP_ATD_INS

Source


1 Package Body pqp_atd_ins as
2 /* $Header: pqatdrhi.pkb 115.10 2003/02/17 22:13:56 tmehra ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)        := '  pqp_atd_ins.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< insert_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
18 --   1) Initialise the object_version_number to 1 if the object_version_number
15 -- Description:
16 --   This procedure controls the actual dml insert logic. The processing of
17 --   this procedure are as follows:
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_atd_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_atd_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: pqp_alien_transaction_data
64   --
65   insert into pqp_alien_transaction_data
66   (     alien_transaction_id,
67         person_id,
68         data_source_type,
69         tax_year,
70         income_code,
71         withholding_rate,
72         income_code_sub_type,
73         exemption_code,
74         maximum_benefit_amount,
75         retro_lose_ben_amt_flag,
76         date_benefit_ends,
77         retro_lose_ben_date_flag,
78         current_residency_status,
79         nra_to_ra_date,
80         target_departure_date,
81         tax_residence_country_code,
82         treaty_info_update_date,
83         nra_exempt_from_fica,
84         student_exempt_from_fica,
85         addl_withholding_flag,
86         addl_withholding_amt,
87         addl_wthldng_amt_period_type,
88         personal_exemption,
89         addl_exemption_allowed,
90         number_of_days_in_usa,
91         wthldg_allow_eligible_flag,
92         treaty_ben_allowed_flag,
93         treaty_benefits_start_date,
94         ra_effective_date,
95         state_code,
96         state_honors_treaty_flag,
97         ytd_payments,
98         ytd_w2_payments,
99         ytd_w2_withholding,
100         ytd_withholding_allowance,
101         ytd_treaty_payments,
102         ytd_treaty_withheld_amt,
103         record_source,
104         visa_type,
105         j_sub_type,
106         primary_activity,
107         non_us_country_code,
108         citizenship_country_code,
109         constant_addl_tax,
110         date_8233_signed,
111         date_w4_signed,
112         error_indicator,
113         prev_er_treaty_benefit_amt,
114         error_text,
115         object_version_number,
116         current_analysis,
117         forecast_income_code
118   )
119   Values
120   (        p_rec.alien_transaction_id,
121         p_rec.person_id,
122         p_rec.data_source_type,
123         p_rec.tax_year,
124         p_rec.income_code,
125         p_rec.withholding_rate,
126         p_rec.income_code_sub_type,
127         p_rec.exemption_code,
128         p_rec.maximum_benefit_amount,
129         p_rec.retro_lose_ben_amt_flag,
130         p_rec.date_benefit_ends,
131         p_rec.retro_lose_ben_date_flag,
132         p_rec.current_residency_status,
133         p_rec.nra_to_ra_date,
134         p_rec.target_departure_date,
135         p_rec.tax_residence_country_code,
136         p_rec.treaty_info_update_date,
137         p_rec.nra_exempt_from_fica,
138         p_rec.student_exempt_from_fica,
139         p_rec.addl_withholding_flag,
140         p_rec.addl_withholding_amt,
141         p_rec.addl_wthldng_amt_period_type,
142         p_rec.personal_exemption,
143         p_rec.addl_exemption_allowed,
144         p_rec.number_of_days_in_usa,
145         p_rec.wthldg_allow_eligible_flag,
146         p_rec.treaty_ben_allowed_flag,
147         p_rec.treaty_benefits_start_date,
148         p_rec.ra_effective_date,
149         p_rec.state_code,
150         p_rec.state_honors_treaty_flag,
151         p_rec.ytd_payments,
152         p_rec.ytd_w2_payments,
153         p_rec.ytd_w2_withholding,
154         p_rec.ytd_withholding_allowance,
155         p_rec.ytd_treaty_payments,
156         p_rec.ytd_treaty_withheld_amt,
157         p_rec.record_source,
158         p_rec.visa_type,
159         p_rec.j_sub_type,
160         p_rec.primary_activity,
164         p_rec.date_8233_signed,
161         p_rec.non_us_country_code,
162         p_rec.citizenship_country_code,
163         p_rec.constant_addl_tax,
165         p_rec.date_w4_signed,
166         p_rec.error_indicator,
167         p_rec.prev_er_treaty_benefit_amt,
168         p_rec.error_text,
169         p_rec.object_version_number,
170         p_rec.current_analysis,
171         p_rec.forecast_income_code
172   );
173   --
174   pqp_atd_shd.g_api_dml := false;   -- Unset the api dml status
175   --
176   hr_utility.set_location(' Leaving:'||l_proc, 10);
177 Exception
178   When hr_api.check_integrity_violated Then
179     -- A check constraint has been violated
180     pqp_atd_shd.g_api_dml := false;   -- Unset the api dml status
181     pqp_atd_shd.constraint_error
182       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
183   When hr_api.parent_integrity_violated Then
184     -- Parent integrity has been violated
185     pqp_atd_shd.g_api_dml := false;   -- Unset the api dml status
186     pqp_atd_shd.constraint_error
187       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
188   When hr_api.unique_integrity_violated Then
189     -- Unique integrity has been violated
190     pqp_atd_shd.g_api_dml := false;   -- Unset the api dml status
191     pqp_atd_shd.constraint_error
192       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
193   When Others Then
194     pqp_atd_shd.g_api_dml := false;   -- Unset the api dml status
195     Raise;
196 End insert_dml;
197 --
198 -- ----------------------------------------------------------------------------
199 -- |------------------------------< pre_insert >------------------------------|
200 -- ----------------------------------------------------------------------------
201 -- {Start Of Comments}
202 --
203 -- Description:
204 --   This private procedure contains any processing which is required before
205 --   the insert dml. Presently, if the entity has a corresponding primary
206 --   key which is maintained by an associating sequence, the primary key for
207 --   the entity will be populated with the next sequence value in
208 --   preparation for the insert dml.
209 --
210 -- Prerequisites:
211 --   This is an internal procedure which is called from the ins procedure.
212 --
213 -- In Parameters:
214 --   A Pl/Sql record structre.
215 --
216 -- Post Success:
217 --   Processing continues.
218 --
219 -- Post Failure:
220 --   If an error has occurred, an error message and exception will be raised
221 --   but not handled.
222 --
223 -- Developer Implementation Notes:
224 --   Any pre-processing required before the insert dml is issued should be
225 --   coded within this procedure. As stated above, a good example is the
226 --   generation of a primary key number via a corresponding sequence.
227 --   It is important to note that any 3rd party maintenance should be reviewed
228 --   before placing in this procedure.
229 --
230 -- Access Status:
231 --   Internal Row Handler Use Only.
232 --
233 -- {End Of Comments}
234 -- ----------------------------------------------------------------------------
235 Procedure pre_insert(p_rec  in out nocopy pqp_atd_shd.g_rec_type) is
236 --
237   l_proc  varchar2(72) := g_package||'pre_insert';
238 --
239   Cursor C_Sel1 is select pqp_alien_transaction_data_s.nextval from sys.dual;
240 --
241 Begin
242   hr_utility.set_location('Entering:'||l_proc, 5);
243   --
244   --
245   -- Select the next sequence number
246   --
247   Open C_Sel1;
248   Fetch C_Sel1 Into p_rec.alien_transaction_id;
249   Close C_Sel1;
250   --
251   hr_utility.set_location(' Leaving:'||l_proc, 10);
252 End pre_insert;
253 --
254 -- ----------------------------------------------------------------------------
255 -- |-----------------------------< post_insert >------------------------------|
256 -- ----------------------------------------------------------------------------
257 -- {Start Of Comments}
258 --
259 -- Description:
260 --   This private procedure contains any processing which is required after the
261 --   insert dml.
262 --
263 -- Prerequisites:
264 --   This is an internal procedure which is called from the ins procedure.
265 --
266 -- In Parameters:
267 --   A Pl/Sql record structre.
268 --
269 -- Post Success:
270 --   Processing continues.
271 --
272 -- Post Failure:
273 --   If an error has occurred, an error message and exception will be raised
274 --   but not handled.
275 --
276 -- Developer Implementation Notes:
277 --   Any post-processing required after the insert dml is issued should be
278 --   coded within this procedure. It is important to note that any 3rd party
279 --   maintenance should be reviewed before placing in this procedure.
280 --
281 -- Access Status:
282 --   Internal Row Handler Use Only.
283 --
284 -- {End Of Comments}
285 -- ----------------------------------------------------------------------------
286 Procedure post_insert(
287 p_effective_date in date,p_rec in pqp_atd_shd.g_rec_type) is
288 --
289   l_proc  varchar2(72) := g_package||'post_insert';
290 --
291 Begin
292   hr_utility.set_location('Entering:'||l_proc, 5);
293 --
294   --
295   -- Start of API User Hook for post_insert.
296   --
297   begin
298     --
299     pqp_atd_rki.after_insert
300       (
301   p_alien_transaction_id          =>p_rec.alien_transaction_id
302  ,p_person_id                     =>p_rec.person_id
303  ,p_data_source_type              =>p_rec.data_source_type
307  ,p_income_code_sub_type          =>p_rec.income_code_sub_type
304  ,p_tax_year                      =>p_rec.tax_year
305  ,p_income_code                   =>p_rec.income_code
306  ,p_withholding_rate              =>p_rec.withholding_rate
308  ,p_exemption_code                =>p_rec.exemption_code
309  ,p_maximum_benefit_amount        =>p_rec.maximum_benefit_amount
310  ,p_retro_lose_ben_amt_flag       =>p_rec.retro_lose_ben_amt_flag
311  ,p_date_benefit_ends             =>p_rec.date_benefit_ends
312  ,p_retro_lose_ben_date_flag      =>p_rec.retro_lose_ben_date_flag
313  ,p_current_residency_status      =>p_rec.current_residency_status
314  ,p_nra_to_ra_date                =>p_rec.nra_to_ra_date
315  ,p_target_departure_date         =>p_rec.target_departure_date
316  ,p_tax_residence_country_code    =>p_rec.tax_residence_country_code
317  ,p_treaty_info_update_date       =>p_rec.treaty_info_update_date
318  ,p_nra_exempt_from_fica          =>p_rec.nra_exempt_from_fica
319  ,p_student_exempt_from_fica      =>p_rec.student_exempt_from_fica
320  ,p_addl_withholding_flag         =>p_rec.addl_withholding_flag
321  ,p_addl_withholding_amt          =>p_rec.addl_withholding_amt
322  ,p_addl_wthldng_amt_period_type  =>p_rec.addl_wthldng_amt_period_type
323  ,p_personal_exemption            =>p_rec.personal_exemption
324  ,p_addl_exemption_allowed        =>p_rec.addl_exemption_allowed
325  ,p_number_of_days_in_usa         =>p_rec.number_of_days_in_usa
326  ,p_wthldg_allow_eligible_flag    =>p_rec.wthldg_allow_eligible_flag
327  ,p_treaty_ben_allowed_flag       =>p_rec.treaty_ben_allowed_flag
328  ,p_treaty_benefits_start_date    =>p_rec.treaty_benefits_start_date
329  ,p_ra_effective_date             =>p_rec.ra_effective_date
330  ,p_state_code                    =>p_rec.state_code
331  ,p_state_honors_treaty_flag      =>p_rec.state_honors_treaty_flag
332  ,p_ytd_payments                  =>p_rec.ytd_payments
333  ,p_ytd_w2_payments               =>p_rec.ytd_w2_payments
334  ,p_ytd_w2_withholding            =>p_rec.ytd_w2_withholding
335  ,p_ytd_withholding_allowance     =>p_rec.ytd_withholding_allowance
336  ,p_ytd_treaty_payments           =>p_rec.ytd_treaty_payments
337  ,p_ytd_treaty_withheld_amt       =>p_rec.ytd_treaty_withheld_amt
338  ,p_record_source                 =>p_rec.record_source
339  ,p_visa_type                     =>p_rec.visa_type
340  ,p_j_sub_type                    =>p_rec.j_sub_type
341  ,p_primary_activity              =>p_rec.primary_activity
342  ,p_non_us_country_code           =>p_rec.non_us_country_code
343  ,p_citizenship_country_code      =>p_rec.citizenship_country_code
344  ,p_constant_addl_tax             =>p_rec.constant_addl_tax
345  ,p_date_8233_signed              =>p_rec.date_8233_signed
346  ,p_date_w4_signed                =>p_rec.date_w4_signed
347  ,p_error_indicator               =>p_rec.error_indicator
348  ,p_prev_er_treaty_benefit_amt    =>p_rec.prev_er_treaty_benefit_amt
349  ,p_error_text                    =>p_rec.error_text
350  ,p_object_version_number         =>p_rec.object_version_number
351  ,p_effective_date                =>p_effective_date
352  ,p_current_analysis              =>p_rec.current_analysis
353  ,p_forecast_income_code          =>p_rec.forecast_income_code
354       );
355     --
356   exception
357     --
358     when hr_api.cannot_find_prog_unit then
359       --
360       hr_api.cannot_find_prog_unit_error
361         (p_module_name => 'PQP_ALIEN_TRANS_DATA'
362         ,p_hook_type   => 'AI');
363       --
364   end;
365   --
366   -- End of API User Hook for post_insert.
367   --
368   --
369   hr_utility.set_location(' Leaving:'||l_proc, 10);
370 End post_insert;
371 --
372 -- ----------------------------------------------------------------------------
373 -- |---------------------------------< ins >----------------------------------|
374 -- ----------------------------------------------------------------------------
375 Procedure ins
376   (
377   p_effective_date in date,
378   p_rec        in out nocopy pqp_atd_shd.g_rec_type
379   ) is
380 --
381   l_proc  varchar2(72) := g_package||'ins';
382 --
383 Begin
384   hr_utility.set_location('Entering:'||l_proc, 5);
385   --
386   -- Call the supporting insert validate operations
387   --
388   pqp_atd_bus.insert_validate(p_rec            ,
389                                        p_effective_date );
390 
391   /* Added the code below to append the error text/ error indicator */
392   IF (pqp_atd_bus.g_error_message IS NOT NULL) THEN
393       p_rec.error_text      := p_rec.error_text ||
394                                    pqp_atd_bus.g_error_message;
395       p_rec.error_indicator := 'ERROR';
396   END IF;
397 
398 
399   /* Added the code till here */
400   --
401   -- Call the supporting pre-insert operation
402   --
403   pre_insert(p_rec);
404   --
405   -- Insert the row
406   --
407   insert_dml(p_rec);
408   --
409   -- Call the supporting post-insert operation
410   --
411   post_insert(
412 p_effective_date,p_rec);
413 end ins;
414 --
415 -- ----------------------------------------------------------------------------
416 -- |---------------------------------< ins >----------------------------------|
417 -- ----------------------------------------------------------------------------
418 Procedure ins
419   (
420   p_effective_date in date,
421   p_alien_transaction_id         out nocopy number,
422   p_person_id                    in number,
423   p_data_source_type             in varchar2,
424   p_tax_year                     in number           default null,
425   p_income_code                  in varchar2,
426   p_withholding_rate             in number           default null,
427   p_income_code_sub_type         in varchar2         default null,
428   p_exemption_code               in varchar2         default null,
429   p_maximum_benefit_amount       in number           default null,
430   p_retro_lose_ben_amt_flag      in varchar2         default null,
431   p_date_benefit_ends            in date             default null,
432   p_retro_lose_ben_date_flag     in varchar2         default null,
433   p_current_residency_status     in varchar2         default null,
434   p_nra_to_ra_date               in date             default null,
435   p_target_departure_date        in date             default null,
436   p_tax_residence_country_code   in varchar2         default null,
437   p_treaty_info_update_date      in date             default null,
438   p_nra_exempt_from_fica         in varchar2         default null,
439   p_student_exempt_from_fica     in varchar2         default null,
440   p_addl_withholding_flag        in varchar2         default null,
441   p_addl_withholding_amt         in number           default null,
442   p_addl_wthldng_amt_period_type in varchar2         default null,
443   p_personal_exemption           in number           default null,
444   p_addl_exemption_allowed       in number           default null,
445   p_number_of_days_in_usa        in number           default null,
446   p_wthldg_allow_eligible_flag   in varchar2         default null,
447   p_treaty_ben_allowed_flag      in varchar2         default null,
448   p_treaty_benefits_start_date   in date             default null,
449   p_ra_effective_date            in date             default null,
450   p_state_code                   in varchar2         default null,
451   p_state_honors_treaty_flag     in varchar2         default null,
452   p_ytd_payments                 in number           default null,
453   p_ytd_w2_payments              in number           default null,
454   p_ytd_w2_withholding           in number           default null,
455   p_ytd_withholding_allowance    in number           default null,
456   p_ytd_treaty_payments          in number           default null,
457   p_ytd_treaty_withheld_amt      in number           default null,
458   p_record_source                in varchar2         default null,
459   p_visa_type                    in varchar2         default null,
460   p_j_sub_type                   in varchar2         default null,
461   p_primary_activity             in varchar2         default null,
462   p_non_us_country_code          in varchar2         default null,
463   p_citizenship_country_code     in varchar2         default null,
464   p_constant_addl_tax            in number           default null,
465   p_date_8233_signed             in date             default null,
466   p_date_w4_signed               in date             default null,
467   p_error_indicator              in varchar2         default null,
468   p_prev_er_treaty_benefit_amt   in number           default null,
469   p_error_text                   in varchar2         default null,
470   p_object_version_number        out nocopy number,
471   p_current_analysis             in varchar2         default null,
472   p_forecast_income_code         in varchar2         default null
473   ) is
474 --
475   l_rec          pqp_atd_shd.g_rec_type;
476   l_proc  varchar2(72) := g_package||'ins';
477 --
478 Begin
479   hr_utility.set_location('Entering:'||l_proc, 5);
480   --
481   -- Call conversion function to turn arguments into the
482   -- p_rec structure.
483   --
484   l_rec :=
485   pqp_atd_shd.convert_args
486   (
487   null,
488   p_person_id,
489   p_data_source_type,
490   p_tax_year,
491   p_income_code,
492   p_withholding_rate,
493   p_income_code_sub_type,
494   p_exemption_code,
495   p_maximum_benefit_amount,
496   p_retro_lose_ben_amt_flag,
497   p_date_benefit_ends,
498   p_retro_lose_ben_date_flag,
499   p_current_residency_status,
500   p_nra_to_ra_date,
501   p_target_departure_date,
502   p_tax_residence_country_code,
503   p_treaty_info_update_date,
504   p_nra_exempt_from_fica,
505   p_student_exempt_from_fica,
506   p_addl_withholding_flag,
507   p_addl_withholding_amt,
508   p_addl_wthldng_amt_period_type,
509   p_personal_exemption,
510   p_addl_exemption_allowed,
511   p_number_of_days_in_usa,
512   p_wthldg_allow_eligible_flag,
513   p_treaty_ben_allowed_flag,
514   p_treaty_benefits_start_date,
515   p_ra_effective_date,
516   p_state_code,
517   p_state_honors_treaty_flag,
518   p_ytd_payments,
519   p_ytd_w2_payments,
520   p_ytd_w2_withholding,
521   p_ytd_withholding_allowance,
522   p_ytd_treaty_payments,
523   p_ytd_treaty_withheld_amt,
524   p_record_source,
525   p_visa_type,
526   p_j_sub_type,
527   p_primary_activity,
528   p_non_us_country_code,
529   p_citizenship_country_code,
530   p_constant_addl_tax,
531   p_date_8233_signed,
532   p_date_w4_signed,
533   p_error_indicator,
534   p_prev_er_treaty_benefit_amt,
535   p_error_text,
536   null,
537   p_current_analysis,
538   p_forecast_income_code
539   );
540   --
541   -- Having converted the arguments into the pqp_atd_rec
542   -- plsql record structure we call the corresponding record business process.
543   --
544   ins(
545     p_effective_date,l_rec);
546   --
547   -- As the primary key argument(s)
548   -- are specified as an OUT's we must set these values.
549   --
550   p_alien_transaction_id := l_rec.alien_transaction_id;
551   p_object_version_number := l_rec.object_version_number;
552   --
553   hr_utility.set_location(' Leaving:'||l_proc, 10);
554 End ins;
555 --
556 end pqp_atd_ins;