DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQP_AAD_INS

Source


1 Package Body pqp_aad_ins as
2 /* $Header: pqaadrhi.pkb 115.5 2003/02/17 22:13:35 tmehra ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqp_aad_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_aad_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_aad_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: pqp_analyzed_alien_data
64   --
65   insert into pqp_analyzed_alien_data
66   (	analyzed_data_id,
67 	assignment_id,
68 	data_source,
69 	tax_year,
70 	current_residency_status,
71 	nra_to_ra_date,
72 	target_departure_date,
73 	tax_residence_country_code,
74 	treaty_info_update_date,
75 	number_of_days_in_usa,
76 	withldg_allow_eligible_flag,
77 	ra_effective_date,
78 	record_source,
79 	visa_type,
80 	j_sub_type,
81 	primary_activity,
82 	non_us_country_code,
83 	citizenship_country_code,
84 	object_version_number ,
85         date_8233_signed,
86         date_w4_signed
87   )
88   Values
89   (	p_rec.analyzed_data_id,
90 	p_rec.assignment_id,
91 	p_rec.data_source,
92 	p_rec.tax_year,
93 	p_rec.current_residency_status,
94 	p_rec.nra_to_ra_date,
95 	p_rec.target_departure_date,
96 	p_rec.tax_residence_country_code,
97 	p_rec.treaty_info_update_date,
98 	p_rec.number_of_days_in_usa,
99 	p_rec.withldg_allow_eligible_flag,
100 	p_rec.ra_effective_date,
101 	p_rec.record_source,
102 	p_rec.visa_type,
103 	p_rec.j_sub_type,
104 	p_rec.primary_activity,
105 	p_rec.non_us_country_code,
106 	p_rec.citizenship_country_code,
107 	p_rec.object_version_number ,
108         p_rec.date_8233_signed,
109         p_rec.date_w4_signed
110   );
111   --
112   pqp_aad_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     pqp_aad_shd.g_api_dml := false;   -- Unset the api dml status
119     pqp_aad_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     pqp_aad_shd.g_api_dml := false;   -- Unset the api dml status
124     pqp_aad_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     pqp_aad_shd.g_api_dml := false;   -- Unset the api dml status
129     pqp_aad_shd.constraint_error
130       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
131   When Others Then
132     pqp_aad_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 pqp_aad_shd.g_rec_type) is
174 --
175   l_proc  varchar2(72) := g_package||'pre_insert';
176 --
177   Cursor C_Sel1 is select pqp_analyzed_alien_data_s.nextval from sys.dual;
178 --
179 Begin
180   hr_utility.set_location('Entering:'||l_proc, 5);
181   --
182   --
183   -- Select the next sequence number
184   --
185   Open C_Sel1;
186   Fetch C_Sel1 Into p_rec.analyzed_data_id;
187   Close C_Sel1;
188   --
189   hr_utility.set_location(' Leaving:'||l_proc, 10);
190 End pre_insert;
191 --
192 -- ----------------------------------------------------------------------------
193 -- |-----------------------------< post_insert >------------------------------|
194 -- ----------------------------------------------------------------------------
195 -- {Start Of Comments}
196 --
197 -- Description:
198 --   This private procedure contains any processing which is required after the
199 --   insert dml.
200 --
201 -- Prerequisites:
202 --   This is an internal procedure which is called from the ins 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 insert 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_insert(
225 p_effective_date in date,p_rec in pqp_aad_shd.g_rec_type) is
226 --
227   l_proc  varchar2(72) := g_package||'post_insert';
228 --
229 Begin
230   hr_utility.set_location('Entering:'||l_proc, 5);
231 --
232   --
233   -- Start of API User Hook for post_insert.
234   --
235   begin
236     --
237     pqp_aad_rki.after_insert
238       (
239   p_analyzed_data_id              =>p_rec.analyzed_data_id
240  ,p_assignment_id                 =>p_rec.assignment_id
241  ,p_data_source                   =>p_rec.data_source
242  ,p_tax_year                      =>p_rec.tax_year
243  ,p_current_residency_status      =>p_rec.current_residency_status
244  ,p_nra_to_ra_date                =>p_rec.nra_to_ra_date
245  ,p_target_departure_date         =>p_rec.target_departure_date
246  ,p_tax_residence_country_code    =>p_rec.tax_residence_country_code
247  ,p_treaty_info_update_date       =>p_rec.treaty_info_update_date
248  ,p_number_of_days_in_usa         =>p_rec.number_of_days_in_usa
249  ,p_withldg_allow_eligible_flag   =>p_rec.withldg_allow_eligible_flag
250  ,p_ra_effective_date             =>p_rec.ra_effective_date
251  ,p_record_source                 =>p_rec.record_source
252  ,p_visa_type                     =>p_rec.visa_type
253  ,p_j_sub_type                    =>p_rec.j_sub_type
254  ,p_primary_activity              =>p_rec.primary_activity
255  ,p_non_us_country_code           =>p_rec.non_us_country_code
256  ,p_citizenship_country_code      =>p_rec.citizenship_country_code
257  ,p_object_version_number         =>p_rec.object_version_number
258  ,p_effective_date                =>p_effective_date
259  ,p_date_8233_signed              =>p_rec.date_8233_signed
260  ,p_date_w4_signed                =>p_rec.date_w4_signed
261       );
262     --
263   exception
264     --
265     when hr_api.cannot_find_prog_unit then
266       --
267       hr_api.cannot_find_prog_unit_error
268         (p_module_name => 'pqp_analyzed_alien_data'
269         ,p_hook_type   => 'AI');
270       --
271   end;
272   --
273   -- End of API User Hook for post_insert.
274   --
275   --
276   hr_utility.set_location(' Leaving:'||l_proc, 10);
277 End post_insert;
278 --
279 -- ----------------------------------------------------------------------------
280 -- |---------------------------------< ins >----------------------------------|
281 -- ----------------------------------------------------------------------------
282 Procedure ins
283   (
284   p_effective_date in date,
285   p_rec        in out nocopy pqp_aad_shd.g_rec_type
286   ) is
287 --
288   l_proc  varchar2(72) := g_package||'ins';
289 --
290 Begin
291   hr_utility.set_location('Entering:'||l_proc, 5);
292   --
293   -- Call the supporting insert validate operations
294   --
295   pqp_aad_bus.insert_validate(p_rec
296   ,p_effective_date);
297   --
298   -- Call the supporting pre-insert operation
299   --
300   pre_insert(p_rec);
301   --
302   -- Insert the row
303   --
304   insert_dml(p_rec);
305   --
306   -- Call the supporting post-insert operation
307   --
308   post_insert(
309 p_effective_date,p_rec);
310 end ins;
311 --
312 -- ----------------------------------------------------------------------------
313 -- |---------------------------------< ins >----------------------------------|
314 -- ----------------------------------------------------------------------------
315 Procedure ins
316   (
317   p_effective_date in date,
318   p_analyzed_data_id             out nocopy number,
319   p_assignment_id                in number,
320   p_data_source                  in varchar2,
321   p_tax_year                     in number,
322   p_current_residency_status     in varchar2         default null,
323   p_nra_to_ra_date               in date             default null,
324   p_target_departure_date        in date             default null,
325   p_tax_residence_country_code   in varchar2         default null,
326   p_treaty_info_update_date      in date             default null,
327   p_number_of_days_in_usa        in number           default null,
328   p_withldg_allow_eligible_flag  in varchar2         default null,
329   p_ra_effective_date            in date             default null,
330   p_record_source                in varchar2         default null,
331   p_visa_type                    in varchar2         default null,
332   p_j_sub_type                   in varchar2         default null,
333   p_primary_activity             in varchar2         default null,
334   p_non_us_country_code          in varchar2         default null,
335   p_citizenship_country_code     in varchar2         default null,
336   p_object_version_number        out nocopy number                      ,
337   p_date_8233_signed             in date             default null,
338   p_date_w4_signed               in date             default null
339   ) is
340 --
341   l_rec	  pqp_aad_shd.g_rec_type;
342   l_proc  varchar2(72) := g_package||'ins';
343 --
344 Begin
345   hr_utility.set_location('Entering:'||l_proc, 5);
346   --
347   -- Call conversion function to turn arguments into the
348   -- p_rec structure.
349   --
350   l_rec :=
351   pqp_aad_shd.convert_args
352   (
353   null,
354   p_assignment_id,
355   p_data_source,
356   p_tax_year,
357   p_current_residency_status,
358   p_nra_to_ra_date,
359   p_target_departure_date,
360   p_tax_residence_country_code,
361   p_treaty_info_update_date,
362   p_number_of_days_in_usa,
363   p_withldg_allow_eligible_flag,
364   p_ra_effective_date,
365   p_record_source,
366   p_visa_type,
367   p_j_sub_type,
368   p_primary_activity,
369   p_non_us_country_code,
370   p_citizenship_country_code,
371   null ,
372   p_date_8233_signed,
373   p_date_w4_signed
374   );
375   --
376   -- Having converted the arguments into the analyzed_alien_data_rec
377   -- plsql record structure we call the corresponding record business process.
378   --
379   ins(
380     p_effective_date,l_rec);
381   --
382   -- As the primary key argument(s)
383   -- are specified as an OUT's we must set these values.
384   --
385   p_analyzed_data_id := l_rec.analyzed_data_id;
386   p_object_version_number := l_rec.object_version_number;
387   --
388   hr_utility.set_location(' Leaving:'||l_proc, 10);
389 End ins;
390 --
391 end pqp_aad_ins;