DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQP_ATD_UPD

Source


1 Package Body pqp_atd_upd 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_upd.';  -- Global package name
9 
10 ----------------------------------------------------------------------------
11 --|------------------------------< update_dml >------------------------------|
12 ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the actual dml update logic. The processing of
17 --   this procedure is:
18 --   1) Increment the object_version_number by 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 update the specified row in the schema using the primary key in
23 --      the predicates.
24 --   4) To trap any constraint violations that may have occurred.
25 --   5) To raise any other errors.
26 --
27 -- Prerequisites:
28 --   This is an internal private procedure which must be called from the upd
29 --   procedure.
30 --
31 -- In Parameters:
32 --   A Pl/Sql record structre.
33 --
34 -- Post Success:
35 --   The specified row will be updated in the schema.
36 --
37 -- Post Failure:
38 --   On the update 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 --   The update 'set' attribute list should be modified if any of your
47 --   attributes are not updateable.
48 --
49 -- Access Status:
50 --   Internal Row Handler Use Only.
51 --
52 -- {End Of Comments}
53 ----------------------------------------------------------------------------
54 Procedure update_dml(p_rec in out nocopy pqp_atd_shd.g_rec_type) is
55 
56   l_proc  varchar2(72) := g_package||'update_dml';
57 
58 Begin
59   hr_utility.set_location('Entering:'||l_proc, 5);
60   --
61   -- Increment the object version
62   --
63   p_rec.object_version_number := p_rec.object_version_number + 1;
64   --
65   pqp_atd_shd.g_api_dml := true;  -- Set the api dml status
66   --
67   -- Update the pqp_alien_transaction_data Row
68   --
69   update pqp_alien_transaction_data
70   set
71   alien_transaction_id              = p_rec.alien_transaction_id,
72   person_id                         = p_rec.person_id,
73   data_source_type                  = p_rec.data_source_type,
74   tax_year                          = p_rec.tax_year,
75   income_code                       = p_rec.income_code,
76   withholding_rate                  = p_rec.withholding_rate,
77   income_code_sub_type              = p_rec.income_code_sub_type,
78   exemption_code                    = p_rec.exemption_code,
79   maximum_benefit_amount            = p_rec.maximum_benefit_amount,
80   retro_lose_ben_amt_flag           = p_rec.retro_lose_ben_amt_flag,
81   date_benefit_ends                 = p_rec.date_benefit_ends,
82   retro_lose_ben_date_flag          = p_rec.retro_lose_ben_date_flag,
83   current_residency_status          = p_rec.current_residency_status,
84   nra_to_ra_date                    = p_rec.nra_to_ra_date,
85   target_departure_date             = p_rec.target_departure_date,
86   tax_residence_country_code        = p_rec.tax_residence_country_code,
87   treaty_info_update_date           = p_rec.treaty_info_update_date,
88   nra_exempt_from_fica              = p_rec.nra_exempt_from_fica,
89   student_exempt_from_fica          = p_rec.student_exempt_from_fica,
90   addl_withholding_flag             = p_rec.addl_withholding_flag,
91   addl_withholding_amt              = p_rec.addl_withholding_amt,
92   addl_wthldng_amt_period_type      = p_rec.addl_wthldng_amt_period_type,
93   personal_exemption                = p_rec.personal_exemption,
94   addl_exemption_allowed            = p_rec.addl_exemption_allowed,
95   number_of_days_in_usa             = p_rec.number_of_days_in_usa,
96   wthldg_allow_eligible_flag        = p_rec.wthldg_allow_eligible_flag,
97   treaty_ben_allowed_flag           = p_rec.treaty_ben_allowed_flag,
98   treaty_benefits_start_date        = p_rec.treaty_benefits_start_date,
99   ra_effective_date                 = p_rec.ra_effective_date,
100   state_code                        = p_rec.state_code,
101   state_honors_treaty_flag          = p_rec.state_honors_treaty_flag,
102   ytd_payments                      = p_rec.ytd_payments,
103   ytd_w2_payments                   = p_rec.ytd_w2_payments,
104   ytd_w2_withholding                = p_rec.ytd_w2_withholding,
105   ytd_withholding_allowance         = p_rec.ytd_withholding_allowance,
106   ytd_treaty_payments               = p_rec.ytd_treaty_payments,
107   ytd_treaty_withheld_amt           = p_rec.ytd_treaty_withheld_amt,
108   record_source                     = p_rec.record_source,
109   visa_type                         = p_rec.visa_type,
110   j_sub_type                        = p_rec.j_sub_type,
111   primary_activity                  = p_rec.primary_activity,
112   non_us_country_code               = p_rec.non_us_country_code,
113   citizenship_country_code          = p_rec.citizenship_country_code,
114   constant_addl_tax                 = p_rec.constant_addl_tax,
115   date_8233_signed                  = p_rec.date_8233_signed,
116   date_w4_signed                    = p_rec.date_w4_signed,
117   error_indicator                   = p_rec.error_indicator,
118   prev_er_treaty_benefit_amt        = p_rec.prev_er_treaty_benefit_amt,
119   error_text                        = p_rec.error_text,
120   object_version_number             = p_rec.object_version_number,
121   current_analysis                  = p_rec.current_analysis,
122   forecast_income_code              = p_rec.forecast_income_code
123   where alien_transaction_id = p_rec.alien_transaction_id;
124   --
125   pqp_atd_shd.g_api_dml := false;   -- Unset the api dml status
126   --
127   hr_utility.set_location(' Leaving:'||l_proc, 10);
128 
129 Exception
130   When hr_api.check_integrity_violated Then
131     -- A check constraint has been violated
132     pqp_atd_shd.g_api_dml := false;   -- Unset the api dml status
133     pqp_atd_shd.constraint_error
134       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
135   When hr_api.parent_integrity_violated Then
136     -- Parent integrity has been violated
137     pqp_atd_shd.g_api_dml := false;   -- Unset the api dml status
138     pqp_atd_shd.constraint_error
139       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
140   When hr_api.unique_integrity_violated Then
141     -- Unique integrity has been violated
142     pqp_atd_shd.g_api_dml := false;   -- Unset the api dml status
143     pqp_atd_shd.constraint_error
144       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
145   When Others Then
146     pqp_atd_shd.g_api_dml := false;   -- Unset the api dml status
147     Raise;
148 End update_dml;
149 
150 ----------------------------------------------------------------------------
151 -- |------------------------------< pre_update >------------------------------|
152 ----------------------------------------------------------------------------
153 -- {Start Of Comments}
154 --
155 -- Description:
156 --   This private procedure contains any processing which is required before
157 --   the update dml.
158 --
159 -- Prerequisites:
160 --   This is an internal procedure which is called from the upd procedure.
161 --
162 -- In Parameters:
163 --   A Pl/Sql record structre.
164 --
165 -- Post Success:
166 --   Processing continues.
167 --
168 -- Post Failure:
169 --   If an error has occurred, an error message and exception will be raised
170 --   but not handled.
171 --
172 -- Developer Implementation Notes:
173 --   Any pre-processing required before the update dml is issued should be
174 --   coded within this procedure. It is important to note that any 3rd party
175 --   maintenance should be reviewed before placing in this procedure.
176 --
177 -- Access Status:
178 --   Internal Row Handler Use Only.
179 --
180 -- {End Of Comments}
181 ----------------------------------------------------------------------------
182 Procedure pre_update(p_rec in pqp_atd_shd.g_rec_type) is
183 
184   l_proc  varchar2(72) := g_package||'pre_update';
185 
186 Begin
187   hr_utility.set_location('Entering:'||l_proc, 5);
188   --
189   hr_utility.set_location(' Leaving:'||l_proc, 10);
190 End pre_update;
191 
192 ----------------------------------------------------------------------------
193 -- |-----------------------------< post_update >------------------------------|
194 ----------------------------------------------------------------------------
195 -- {Start Of Comments}
196 --
197 -- Description:
198 --   This private procedure contains any processing which is required after the
199 --   update dml.
200 --
201 -- Prerequisites:
202 --   This is an internal procedure which is called from the upd procedure.
203 --
204 -- In Parameters:
205 --   A Pl/Sql record structre.
206 --
207 -- Post Success:
208 --   Processing continues.
209 --
210 -- Post Failure:
211 --   If an error has occurred, an error message and exception will be raised
212 --   but not handled.
213 --
214 -- Developer Implementation Notes:
215 --   Any post-processing required after the update dml is issued should be
216 --   coded within this procedure. It is important to note that any 3rd party
217 --   maintenance should be reviewed before placing in this procedure.
218 --
219 -- Access Status:
220 --   Internal Row Handler Use Only.
221 --
222 -- {End Of Comments}
223 ----------------------------------------------------------------------------
224 Procedure post_update(
225 p_effective_date in date,p_rec in pqp_atd_shd.g_rec_type) is
226 
227   l_proc  varchar2(72) := g_package||'post_update';
228 
229 Begin
230   hr_utility.set_location('Entering:'||l_proc, 5);
231 
232   --
233   -- Start of API User Hook for post_update.
234   --
235   begin
236     --
237     pqp_atd_rku.after_update
238       (
239   p_alien_transaction_id          =>p_rec.alien_transaction_id
240  ,p_person_id                     =>p_rec.person_id
241  ,p_data_source_type              =>p_rec.data_source_type
242  ,p_tax_year                      =>p_rec.tax_year
243  ,p_income_code                   =>p_rec.income_code
244  ,p_withholding_rate              =>p_rec.withholding_rate
245  ,p_income_code_sub_type          =>p_rec.income_code_sub_type
246  ,p_exemption_code                =>p_rec.exemption_code
247  ,p_maximum_benefit_amount        =>p_rec.maximum_benefit_amount
248  ,p_retro_lose_ben_amt_flag       =>p_rec.retro_lose_ben_amt_flag
249  ,p_date_benefit_ends             =>p_rec.date_benefit_ends
250  ,p_retro_lose_ben_date_flag      =>p_rec.retro_lose_ben_date_flag
251  ,p_current_residency_status      =>p_rec.current_residency_status
252  ,p_nra_to_ra_date                =>p_rec.nra_to_ra_date
253  ,p_target_departure_date         =>p_rec.target_departure_date
254  ,p_tax_residence_country_code    =>p_rec.tax_residence_country_code
255  ,p_treaty_info_update_date       =>p_rec.treaty_info_update_date
256  ,p_nra_exempt_from_fica          =>p_rec.nra_exempt_from_fica
257  ,p_student_exempt_from_fica      =>p_rec.student_exempt_from_fica
258  ,p_addl_withholding_flag         =>p_rec.addl_withholding_flag
259  ,p_addl_withholding_amt          =>p_rec.addl_withholding_amt
260  ,p_addl_wthldng_amt_period_type  =>p_rec.addl_wthldng_amt_period_type
261  ,p_personal_exemption            =>p_rec.personal_exemption
262  ,p_addl_exemption_allowed        =>p_rec.addl_exemption_allowed
263  ,p_number_of_days_in_usa         =>p_rec.number_of_days_in_usa
264  ,p_wthldg_allow_eligible_flag    =>p_rec.wthldg_allow_eligible_flag
265  ,p_treaty_ben_allowed_flag       =>p_rec.treaty_ben_allowed_flag
266  ,p_treaty_benefits_start_date    =>p_rec.treaty_benefits_start_date
267  ,p_ra_effective_date             =>p_rec.ra_effective_date
268  ,p_state_code                    =>p_rec.state_code
269  ,p_state_honors_treaty_flag      =>p_rec.state_honors_treaty_flag
270  ,p_ytd_payments                  =>p_rec.ytd_payments
271  ,p_ytd_w2_payments               =>p_rec.ytd_w2_payments
272  ,p_ytd_w2_withholding            =>p_rec.ytd_w2_withholding
273  ,p_ytd_withholding_allowance     =>p_rec.ytd_withholding_allowance
274  ,p_ytd_treaty_payments           =>p_rec.ytd_treaty_payments
275  ,p_ytd_treaty_withheld_amt       =>p_rec.ytd_treaty_withheld_amt
276  ,p_record_source                 =>p_rec.record_source
277  ,p_visa_type                     =>p_rec.visa_type
278  ,p_j_sub_type                    =>p_rec.j_sub_type
279  ,p_primary_activity              =>p_rec.primary_activity
280  ,p_non_us_country_code           =>p_rec.non_us_country_code
281  ,p_citizenship_country_code      =>p_rec.citizenship_country_code
282  ,p_constant_addl_tax             =>p_rec.constant_addl_tax
283  ,p_date_8233_signed              =>p_rec.date_8233_signed
284  ,p_date_w4_signed                =>p_rec.date_w4_signed
285  ,p_error_indicator               =>p_rec.error_indicator
286  ,p_prev_er_treaty_benefit_amt    =>p_rec.prev_er_treaty_benefit_amt
287  ,p_error_text                    =>p_rec.error_text
288  ,p_object_version_number         =>p_rec.object_version_number
289  ,p_effective_date                =>p_effective_date
290  ,p_current_analysis              =>p_rec.current_analysis
291  ,p_forecast_income_code          =>p_rec.forecast_income_code
292  ,p_person_id_o                   =>pqp_atd_shd.g_old_rec.person_id
293  ,p_data_source_type_o            =>pqp_atd_shd.g_old_rec.data_source_type
294  ,p_tax_year_o                    =>pqp_atd_shd.g_old_rec.tax_year
295  ,p_income_code_o                 =>pqp_atd_shd.g_old_rec.income_code
296  ,p_withholding_rate_o            =>pqp_atd_shd.g_old_rec.withholding_rate
297  ,p_income_code_sub_type_o        =>pqp_atd_shd.g_old_rec.income_code_sub_type
298  ,p_exemption_code_o              =>pqp_atd_shd.g_old_rec.exemption_code
299  ,p_maximum_benefit_amount_o      =>pqp_atd_shd.g_old_rec.maximum_benefit_amount
300  ,p_retro_lose_ben_amt_flag_o     =>pqp_atd_shd.g_old_rec.retro_lose_ben_amt_flag
301  ,p_date_benefit_ends_o           =>pqp_atd_shd.g_old_rec.date_benefit_ends
302  ,p_retro_lose_ben_date_flag_o    =>pqp_atd_shd.g_old_rec.retro_lose_ben_date_flag
303  ,p_current_residency_status_o    =>pqp_atd_shd.g_old_rec.current_residency_status
304  ,p_nra_to_ra_date_o              =>pqp_atd_shd.g_old_rec.nra_to_ra_date
305  ,p_target_departure_date_o       =>pqp_atd_shd.g_old_rec.target_departure_date
306  ,p_tax_residence_country_code_o  =>pqp_atd_shd.g_old_rec.tax_residence_country_code
307  ,p_treaty_info_update_date_o     =>pqp_atd_shd.g_old_rec.treaty_info_update_date
308  ,p_nra_exempt_from_fica_o        =>pqp_atd_shd.g_old_rec.nra_exempt_from_fica
309  ,p_student_exempt_from_fica_o    =>pqp_atd_shd.g_old_rec.student_exempt_from_fica
310  ,p_addl_withholding_flag_o       =>pqp_atd_shd.g_old_rec.addl_withholding_flag
311  ,p_addl_withholding_amt_o        =>pqp_atd_shd.g_old_rec.addl_withholding_amt
312  ,p_addl_wthldng_amt_period_ty_o=>pqp_atd_shd.g_old_rec.addl_wthldng_amt_period_type
313  ,p_personal_exemption_o          =>pqp_atd_shd.g_old_rec.personal_exemption
314  ,p_addl_exemption_allowed_o      =>pqp_atd_shd.g_old_rec.addl_exemption_allowed
315  ,p_number_of_days_in_usa_o       =>pqp_atd_shd.g_old_rec.number_of_days_in_usa
316  ,p_wthldg_allow_eligible_flag_o  =>pqp_atd_shd.g_old_rec.wthldg_allow_eligible_flag
317  ,p_treaty_ben_allowed_flag_o     =>pqp_atd_shd.g_old_rec.treaty_ben_allowed_flag
318  ,p_treaty_benefits_start_date_o  =>pqp_atd_shd.g_old_rec.treaty_benefits_start_date
319  ,p_ra_effective_date_o           =>pqp_atd_shd.g_old_rec.ra_effective_date
320  ,p_state_code_o                  =>pqp_atd_shd.g_old_rec.state_code
321  ,p_state_honors_treaty_flag_o    =>pqp_atd_shd.g_old_rec.state_honors_treaty_flag
322  ,p_ytd_payments_o                =>pqp_atd_shd.g_old_rec.ytd_payments
323  ,p_ytd_w2_payments_o             =>pqp_atd_shd.g_old_rec.ytd_w2_payments
324  ,p_ytd_w2_withholding_o          =>pqp_atd_shd.g_old_rec.ytd_w2_withholding
325  ,p_ytd_withholding_allowance_o   =>pqp_atd_shd.g_old_rec.ytd_withholding_allowance
326  ,p_ytd_treaty_payments_o         =>pqp_atd_shd.g_old_rec.ytd_treaty_payments
327  ,p_ytd_treaty_withheld_amt_o     =>pqp_atd_shd.g_old_rec.ytd_treaty_withheld_amt
328  ,p_record_source_o               =>pqp_atd_shd.g_old_rec.record_source
329  ,p_visa_type_o                   =>pqp_atd_shd.g_old_rec.visa_type
330  ,p_j_sub_type_o                  =>pqp_atd_shd.g_old_rec.j_sub_type
331  ,p_primary_activity_o            =>pqp_atd_shd.g_old_rec.primary_activity
332  ,p_non_us_country_code_o         =>pqp_atd_shd.g_old_rec.non_us_country_code
333  ,p_citizenship_country_code_o    =>pqp_atd_shd.g_old_rec.citizenship_country_code
334  ,p_constant_addl_tax_o           =>pqp_atd_shd.g_old_rec.constant_addl_tax
335  ,p_date_8233_signed_o            =>pqp_atd_shd.g_old_rec.date_8233_signed
336  ,p_date_w4_signed_o              =>pqp_atd_shd.g_old_rec.date_w4_signed
337  ,p_error_indicator_o             =>pqp_atd_shd.g_old_rec.error_indicator
338  ,p_prev_er_treaty_benefit_amt_o  =>pqp_atd_shd.g_old_rec.prev_er_treaty_benefit_amt
339  ,p_error_text_o                  =>pqp_atd_shd.g_old_rec.error_text
340  ,p_object_version_number_o       =>pqp_atd_shd.g_old_rec.object_version_number
341  ,p_current_analysis_o            =>pqp_atd_shd.g_old_rec.current_analysis
342  ,p_forecast_income_code_o        =>pqp_atd_shd.g_old_rec.forecast_income_code
343       );
344     --
345   exception
346     --
347     when hr_api.cannot_find_prog_unit then
348       --
349       hr_api.cannot_find_prog_unit_error
350         (p_module_name => 'PQP_ALIEN_TRANS_DATA'
351         ,p_hook_type   => 'AU');
352       --
353   end;
354   --
355   -- End of API User Hook for post_update.
356   --
357   --
358   hr_utility.set_location(' Leaving:'||l_proc, 10);
359 End post_update;
360 
361 ----------------------------------------------------------------------------
362 -- |-----------------------------< convert_defs >-----------------------------|
363 ----------------------------------------------------------------------------
364 -- {Start Of Comments}
365 --
366 -- Description:
367 --   The Convert_Defs procedure has one very important function:
368 --   It must return the record structure for the row with all system defaulted
369 --   values converted into its corresponding parameter value for update. When
370 --   we attempt to update a row through the Upd process , certain
371 --   parameters can be defaulted which enables flexibility in the calling of
372 --   the upd process (e.g. only attributes which need to be updated need to be
373 --   specified). For the upd process to determine which attributes
374 --   have NOT been specified we need to check if the parameter has a reserved
375 --   system default value. Therefore, for all parameters which have a
376 --   corresponding reserved system default mechanism specified we need to
377 --   check if a system default is being used. If a system default is being
378 --   used then we convert the defaulted value into its corresponding attribute
379 --   value held in the g_old_rec data structure.
380 --
381 -- Prerequisites:
382 --   This private function can only be called from the upd process.
383 --
384 -- In Parameters:
385 --   A Pl/Sql record structre.
386 --
387 -- Post Success:
388 --   The record structure will be returned with all system defaulted parameter
389 --   values converted into its current row attribute value.
390 --
391 -- Post Failure:
392 --   No direct error handling is required within this function. Any possible
393 --   errors within this procedure will be a PL/SQL value error due to conversion
394 --   of datatypes or data lengths.
395 --
396 -- Developer Implementation Notes:
397 --   None.
398 --
399 -- Access Status:
400 --   Internal Row Handler Use Only.
401 --
402 -- {End Of Comments}
403 ----------------------------------------------------------------------------
404 Procedure convert_defs(p_rec in out nocopy pqp_atd_shd.g_rec_type) is
405 
406   l_proc  varchar2(72) := g_package||'convert_defs';
407 
408 Begin
409   --
410   hr_utility.set_location('Entering:'||l_proc, 5);
411   --
412   -- We must now examine each argument value in the
413   -- p_rec plsql record structure
414   -- to see if a system default is being used. If a system default
415   -- is being used then we must set to the 'current' argument value.
416   --
417   If (p_rec.person_id = hr_api.g_number) then
418     p_rec.person_id :=
419     pqp_atd_shd.g_old_rec.person_id;
420   End If;
421   If (p_rec.data_source_type = hr_api.g_varchar2) then
422     p_rec.data_source_type :=
423     pqp_atd_shd.g_old_rec.data_source_type;
424   End If;
425   If (p_rec.tax_year = hr_api.g_number) then
426     p_rec.tax_year :=
427     pqp_atd_shd.g_old_rec.tax_year;
428   End If;
429   If (p_rec.income_code = hr_api.g_varchar2) then
430     p_rec.income_code :=
431     pqp_atd_shd.g_old_rec.income_code;
432   End If;
433   If (p_rec.withholding_rate = hr_api.g_number) then
434     p_rec.withholding_rate :=
435     pqp_atd_shd.g_old_rec.withholding_rate;
436   End If;
437   If (p_rec.income_code_sub_type = hr_api.g_varchar2) then
438     p_rec.income_code_sub_type :=
439     pqp_atd_shd.g_old_rec.income_code_sub_type;
440   End If;
441   If (p_rec.exemption_code = hr_api.g_varchar2) then
442     p_rec.exemption_code :=
443     pqp_atd_shd.g_old_rec.exemption_code;
444   End If;
445   If (p_rec.maximum_benefit_amount = hr_api.g_number) then
446     p_rec.maximum_benefit_amount :=
447     pqp_atd_shd.g_old_rec.maximum_benefit_amount;
448   End If;
449   If (p_rec.retro_lose_ben_amt_flag = hr_api.g_varchar2) then
450     p_rec.retro_lose_ben_amt_flag :=
451     pqp_atd_shd.g_old_rec.retro_lose_ben_amt_flag;
452   End If;
453   If (p_rec.date_benefit_ends = hr_api.g_date) then
454     p_rec.date_benefit_ends :=
455     pqp_atd_shd.g_old_rec.date_benefit_ends;
456   End If;
457   If (p_rec.retro_lose_ben_date_flag = hr_api.g_varchar2) then
458     p_rec.retro_lose_ben_date_flag :=
459     pqp_atd_shd.g_old_rec.retro_lose_ben_date_flag;
460   End If;
461   If (p_rec.current_residency_status = hr_api.g_varchar2) then
462     p_rec.current_residency_status :=
463     pqp_atd_shd.g_old_rec.current_residency_status;
464   End If;
465   If (p_rec.nra_to_ra_date = hr_api.g_date) then
466     p_rec.nra_to_ra_date :=
467     pqp_atd_shd.g_old_rec.nra_to_ra_date;
468   End If;
469   If (p_rec.target_departure_date = hr_api.g_date) then
470     p_rec.target_departure_date :=
471     pqp_atd_shd.g_old_rec.target_departure_date;
472   End If;
473   If (p_rec.tax_residence_country_code = hr_api.g_varchar2) then
474     p_rec.tax_residence_country_code :=
475     pqp_atd_shd.g_old_rec.tax_residence_country_code;
476   End If;
477   If (p_rec.treaty_info_update_date = hr_api.g_date) then
478     p_rec.treaty_info_update_date :=
479     pqp_atd_shd.g_old_rec.treaty_info_update_date;
480   End If;
481   If (p_rec.nra_exempt_from_fica = hr_api.g_varchar2) then
482     p_rec.nra_exempt_from_fica :=
483     pqp_atd_shd.g_old_rec.nra_exempt_from_fica;
484   End If;
485   If (p_rec.student_exempt_from_fica = hr_api.g_varchar2) then
486     p_rec.student_exempt_from_fica :=
487     pqp_atd_shd.g_old_rec.student_exempt_from_fica;
488   End If;
489   If (p_rec.addl_withholding_flag = hr_api.g_varchar2) then
490     p_rec.addl_withholding_flag :=
491     pqp_atd_shd.g_old_rec.addl_withholding_flag;
492   End If;
493   If (p_rec.addl_withholding_amt = hr_api.g_number) then
494     p_rec.addl_withholding_amt :=
495     pqp_atd_shd.g_old_rec.addl_withholding_amt;
496   End If;
497   If (p_rec.addl_wthldng_amt_period_type = hr_api.g_varchar2) then
498     p_rec.addl_wthldng_amt_period_type :=
499     pqp_atd_shd.g_old_rec.addl_wthldng_amt_period_type;
500   End If;
501   If (p_rec.personal_exemption = hr_api.g_number) then
502     p_rec.personal_exemption :=
503     pqp_atd_shd.g_old_rec.personal_exemption;
504   End If;
505   If (p_rec.addl_exemption_allowed = hr_api.g_number) then
506     p_rec.addl_exemption_allowed :=
507     pqp_atd_shd.g_old_rec.addl_exemption_allowed;
508   End If;
509   If (p_rec.number_of_days_in_usa = hr_api.g_number) then
510     p_rec.number_of_days_in_usa :=
511     pqp_atd_shd.g_old_rec.number_of_days_in_usa;
512   End If;
513   If (p_rec.wthldg_allow_eligible_flag = hr_api.g_varchar2) then
514     p_rec.wthldg_allow_eligible_flag :=
515     pqp_atd_shd.g_old_rec.wthldg_allow_eligible_flag;
516   End If;
517   If (p_rec.treaty_ben_allowed_flag = hr_api.g_varchar2) then
518     p_rec.treaty_ben_allowed_flag :=
519     pqp_atd_shd.g_old_rec.treaty_ben_allowed_flag;
520   End If;
521   If (p_rec.treaty_benefits_start_date = hr_api.g_date) then
522     p_rec.treaty_benefits_start_date :=
523     pqp_atd_shd.g_old_rec.treaty_benefits_start_date;
524   End If;
525   If (p_rec.ra_effective_date = hr_api.g_date) then
526     p_rec.ra_effective_date :=
527     pqp_atd_shd.g_old_rec.ra_effective_date;
528   End If;
529   If (p_rec.state_code = hr_api.g_varchar2) then
530     p_rec.state_code :=
531     pqp_atd_shd.g_old_rec.state_code;
532   End If;
533   If (p_rec.state_honors_treaty_flag = hr_api.g_varchar2) then
534     p_rec.state_honors_treaty_flag :=
535     pqp_atd_shd.g_old_rec.state_honors_treaty_flag;
536   End If;
537   If (p_rec.ytd_payments = hr_api.g_number) then
538     p_rec.ytd_payments :=
539     pqp_atd_shd.g_old_rec.ytd_payments;
540   End If;
541   If (p_rec.ytd_w2_payments = hr_api.g_number) then
542     p_rec.ytd_w2_payments :=
543     pqp_atd_shd.g_old_rec.ytd_w2_payments;
544   End If;
545   If (p_rec.ytd_w2_withholding = hr_api.g_number) then
546     p_rec.ytd_w2_withholding :=
547     pqp_atd_shd.g_old_rec.ytd_w2_withholding;
548   End If;
549   If (p_rec.ytd_withholding_allowance = hr_api.g_number) then
550     p_rec.ytd_withholding_allowance :=
551     pqp_atd_shd.g_old_rec.ytd_withholding_allowance;
552   End If;
553   If (p_rec.ytd_treaty_payments = hr_api.g_number) then
554     p_rec.ytd_treaty_payments :=
555     pqp_atd_shd.g_old_rec.ytd_treaty_payments;
556   End If;
557   If (p_rec.ytd_treaty_withheld_amt = hr_api.g_number) then
558     p_rec.ytd_treaty_withheld_amt :=
559     pqp_atd_shd.g_old_rec.ytd_treaty_withheld_amt;
560   End If;
561   If (p_rec.record_source = hr_api.g_varchar2) then
562     p_rec.record_source :=
563     pqp_atd_shd.g_old_rec.record_source;
564   End If;
565   If (p_rec.visa_type = hr_api.g_varchar2) then
566     p_rec.visa_type :=
567     pqp_atd_shd.g_old_rec.visa_type;
568   End If;
569   If (p_rec.j_sub_type = hr_api.g_varchar2) then
570     p_rec.j_sub_type :=
571     pqp_atd_shd.g_old_rec.j_sub_type;
572   End If;
573   If (p_rec.primary_activity = hr_api.g_varchar2) then
574     p_rec.primary_activity :=
575     pqp_atd_shd.g_old_rec.primary_activity;
576   End If;
577   If (p_rec.non_us_country_code = hr_api.g_varchar2) then
578     p_rec.non_us_country_code :=
579     pqp_atd_shd.g_old_rec.non_us_country_code;
580   End If;
581   If (p_rec.citizenship_country_code = hr_api.g_varchar2) then
582     p_rec.citizenship_country_code :=
583     pqp_atd_shd.g_old_rec.citizenship_country_code;
584   End If;
585   If (p_rec.constant_addl_tax = hr_api.g_number) then
586     p_rec.constant_addl_tax :=
587     pqp_atd_shd.g_old_rec.constant_addl_tax;
588   End If;
589   If (p_rec.date_8233_signed = hr_api.g_date) then
590     p_rec.date_8233_signed :=
591     pqp_atd_shd.g_old_rec.date_8233_signed;
592   End If;
593   If (p_rec.date_w4_signed = hr_api.g_date) then
594     p_rec.date_w4_signed :=
595     pqp_atd_shd.g_old_rec.date_w4_signed;
596   End If;
597   If (p_rec.error_indicator = hr_api.g_varchar2) then
598     p_rec.error_indicator :=
599     pqp_atd_shd.g_old_rec.error_indicator;
600   End If;
601   If (p_rec.prev_er_treaty_benefit_amt = hr_api.g_number) then
602     p_rec.prev_er_treaty_benefit_amt :=
603     pqp_atd_shd.g_old_rec.prev_er_treaty_benefit_amt;
604   End If;
605   If (p_rec.error_text = hr_api.g_varchar2) then
606     p_rec.error_text :=
607     pqp_atd_shd.g_old_rec.error_text;
608   End If;
609   If (p_rec.current_analysis= hr_api.g_varchar2) then
610     p_rec.current_analysis :=
611     pqp_atd_shd.g_old_rec.current_analysis;
612   End If;
613   If (p_rec.forecast_income_code = hr_api.g_varchar2) then
614     p_rec.forecast_income_code :=
615     pqp_atd_shd.g_old_rec.forecast_income_code;
616   End If;
617 
618   --
619   hr_utility.set_location(' Leaving:'||l_proc, 10);
620 
621 End convert_defs;
622 
623 ----------------------------------------------------------------------------
624 -- |---------------------------------< upd >----------------------------------|
625 ----------------------------------------------------------------------------
626 Procedure upd
627   (
628   p_effective_date in date,
629   p_rec        in out nocopy pqp_atd_shd.g_rec_type
630   ) is
631 
632   l_proc  varchar2(72) := g_package||'upd';
633 
634 Begin
635   hr_utility.set_location('Entering:'||l_proc, 5);
636   --
637   -- We must lock the row which we need to update.
638   --
639   pqp_atd_shd.lck
640         (
641         p_rec.alien_transaction_id,
642         p_rec.object_version_number
643         );
644   --
645   -- 1. During an update system defaults are used to determine if
646   --    arguments have been defaulted or not. We must therefore
647   --    derive the full record structure values to be updated.
648   --
649   -- 2. Call the supporting update validate operations.
650   --
651   convert_defs(p_rec);
652   pqp_atd_bus.update_validate(p_rec
653   ,p_effective_date);
654   --
655   -- Call the supporting pre-update operation
656   --
657   pre_update(p_rec);
658   --
659   -- Update the row.
660   --
661   update_dml(p_rec);
662   --
663   -- Call the supporting post-update operation
664   --
665   post_update(
666 p_effective_date,p_rec);
667 End upd;
668 
669 ----------------------------------------------------------------------------
670 -- |---------------------------------< upd >----------------------------------|
671 ----------------------------------------------------------------------------
672 Procedure upd
673   (
674   p_effective_date in date,
675   p_alien_transaction_id         in number,
676   p_person_id                    in number           default hr_api.g_number ,
677   p_data_source_type             in varchar2         default hr_api.g_varchar2,
678   p_tax_year                     in number           default hr_api.g_number,
679   p_income_code                  in varchar2         default hr_api.g_varchar2,
680   p_withholding_rate             in number           default hr_api.g_number,
681   p_income_code_sub_type         in varchar2         default hr_api.g_varchar2,
682   p_exemption_code               in varchar2         default hr_api.g_varchar2,
683   p_maximum_benefit_amount       in number           default hr_api.g_number,
684   p_retro_lose_ben_amt_flag      in varchar2         default hr_api.g_varchar2,
685   p_date_benefit_ends            in date             default hr_api.g_date,
686   p_retro_lose_ben_date_flag     in varchar2         default hr_api.g_varchar2,
687   p_current_residency_status     in varchar2         default hr_api.g_varchar2,
688   p_nra_to_ra_date               in date             default hr_api.g_date,
689   p_target_departure_date        in date             default hr_api.g_date,
690   p_tax_residence_country_code   in varchar2         default hr_api.g_varchar2,
691   p_treaty_info_update_date      in date             default hr_api.g_date,
692   p_nra_exempt_from_fica         in varchar2         default hr_api.g_varchar2,
693   p_student_exempt_from_fica     in varchar2         default hr_api.g_varchar2,
694   p_addl_withholding_flag        in varchar2         default hr_api.g_varchar2,
695   p_addl_withholding_amt         in number           default hr_api.g_number,
696   p_addl_wthldng_amt_period_type in varchar2         default hr_api.g_varchar2,
697   p_personal_exemption           in number           default hr_api.g_number,
698   p_addl_exemption_allowed       in number           default hr_api.g_number,
699   p_number_of_days_in_usa        in number           default hr_api.g_number,
700   p_wthldg_allow_eligible_flag   in varchar2         default hr_api.g_varchar2,
701   p_treaty_ben_allowed_flag      in varchar2         default hr_api.g_varchar2,
702   p_treaty_benefits_start_date   in date             default hr_api.g_date,
703   p_ra_effective_date            in date             default hr_api.g_date,
704   p_state_code                   in varchar2         default hr_api.g_varchar2,
705   p_state_honors_treaty_flag     in varchar2         default hr_api.g_varchar2,
706   p_ytd_payments                 in number           default hr_api.g_number,
707   p_ytd_w2_payments              in number           default hr_api.g_number,
708   p_ytd_w2_withholding           in number           default hr_api.g_number,
709   p_ytd_withholding_allowance    in number           default hr_api.g_number,
710   p_ytd_treaty_payments          in number           default hr_api.g_number,
711   p_ytd_treaty_withheld_amt      in number           default hr_api.g_number,
712   p_record_source                in varchar2         default hr_api.g_varchar2,
713   p_visa_type                    in varchar2         default hr_api.g_varchar2,
714   p_j_sub_type                   in varchar2         default hr_api.g_varchar2,
715   p_primary_activity             in varchar2         default hr_api.g_varchar2,
716   p_non_us_country_code          in varchar2         default hr_api.g_varchar2,
717   p_citizenship_country_code     in varchar2         default hr_api.g_varchar2,
718   p_constant_addl_tax            in number           default hr_api.g_number,
719   p_date_8233_signed             in date             default hr_api.g_date,
720   p_date_w4_signed               in date             default hr_api.g_date,
721   p_error_indicator              in varchar2         default hr_api.g_varchar2,
722   p_prev_er_treaty_benefit_amt   in number           default hr_api.g_number,
723   p_error_text                   in varchar2         default hr_api.g_varchar2,
724   p_object_version_number        in out nocopy number,
725   p_current_analysis             in varchar2         default hr_api.g_varchar2,
726   p_forecast_income_code         in varchar2         default hr_api.g_varchar2
727   ) is
728 
729   l_rec          pqp_atd_shd.g_rec_type;
730   l_proc  varchar2(72) := g_package||'upd';
731 
732 Begin
733   hr_utility.set_location('Entering:'||l_proc, 5);
734   --
735   -- Call conversion function to turn arguments into the
736   -- l_rec structure.
737   --
738   l_rec :=
739   pqp_atd_shd.convert_args
740   (
741   p_alien_transaction_id,
742   p_person_id,
743   p_data_source_type,
744   p_tax_year,
745   p_income_code,
746   p_withholding_rate,
747   p_income_code_sub_type,
748   p_exemption_code,
749   p_maximum_benefit_amount,
750   p_retro_lose_ben_amt_flag,
751   p_date_benefit_ends,
752   p_retro_lose_ben_date_flag,
753   p_current_residency_status,
754   p_nra_to_ra_date,
755   p_target_departure_date,
756   p_tax_residence_country_code,
757   p_treaty_info_update_date,
758   p_nra_exempt_from_fica,
759   p_student_exempt_from_fica,
760   p_addl_withholding_flag,
761   p_addl_withholding_amt,
762   p_addl_wthldng_amt_period_type,
763   p_personal_exemption,
764   p_addl_exemption_allowed,
765   p_number_of_days_in_usa,
766   p_wthldg_allow_eligible_flag,
767   p_treaty_ben_allowed_flag,
768   p_treaty_benefits_start_date,
769   p_ra_effective_date,
770   p_state_code,
771   p_state_honors_treaty_flag,
772   p_ytd_payments,
773   p_ytd_w2_payments,
774   p_ytd_w2_withholding,
775   p_ytd_withholding_allowance,
776   p_ytd_treaty_payments,
777   p_ytd_treaty_withheld_amt,
778   p_record_source,
779   p_visa_type,
780   p_j_sub_type,
781   p_primary_activity,
782   p_non_us_country_code,
783   p_citizenship_country_code,
784   p_constant_addl_tax,
785   p_date_8233_signed,
786   p_date_w4_signed,
787   p_error_indicator,
788   p_prev_er_treaty_benefit_amt,
789   p_error_text,
790   p_object_version_number,
791   p_current_analysis,
792   p_forecast_income_code
793   );
794   --
795   -- Having converted the arguments into the
796   -- plsql record structure we call the corresponding record
797   -- business process.
798   --
799   upd(
800     p_effective_date,l_rec);
801   p_object_version_number := l_rec.object_version_number;
802   --
803   hr_utility.set_location(' Leaving:'||l_proc, 10);
804 End upd;
805 
806 end pqp_atd_upd;