DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_RCU_INS

Source


1 Package Body pay_rcu_ins as
2 /* $Header: pyrcurhi.pkb 120.1.12020000.2 2012/09/23 07:50:52 jkvallab ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_rcu_ins.';  -- Global package name
9 --
10 -- The following global variables are only to be used by
11 -- the set_base_key_value and pre_insert procedures.
12 --
13 g_retro_component_usage_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_retro_component_usage_id  in  number) is
20 --
21   l_proc       varchar2(72) := g_package||'set_base_key_value';
22 --
23 Begin
24   hr_utility.set_location('Entering:'||l_proc, 10);
25   --
26   pay_rcu_ins.g_retro_component_usage_id_i := p_retro_component_usage_id;
27   --
28   hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 --
32 -- ----------------------------------------------------------------------------
33 -- |-----------------------< create_app_ownerships >--------------------------|
34 -- ----------------------------------------------------------------------------
35 --
36 -- Description:
37 --   This procedure inserts a row into the HR_APPLICATION_OWNERSHIPS table
38 --   when the row handler is called in the appropriate mode.
39 --
40 -- ----------------------------------------------------------------------------
41 PROCEDURE create_app_ownerships(p_pk_column  IN varchar2
42                                ,p_pk_value   IN varchar2) IS
43 --
44 CURSOR csr_definition IS
45   SELECT product_short_name
46     FROM hr_owner_definitions
47    WHERE session_id = hr_startup_data_api_support.g_session_id;
48 --
49 BEGIN
50   --
51   IF (hr_startup_data_api_support.return_startup_mode IN
52                                ('STARTUP','GENERIC')) THEN
53      --
54      FOR c1 IN csr_definition LOOP
55        --
56        INSERT INTO hr_application_ownerships
57          (key_name
58          ,key_value
59          ,product_name
60          )
61        VALUES
62          (p_pk_column
63          ,fnd_number.number_to_canonical(p_pk_value)
64          ,c1.product_short_name
65          );
66      END LOOP;
67   END IF;
68 END create_app_ownerships;
69 --
70 -- ----------------------------------------------------------------------------
71 -- |-----------------------< create_app_ownerships >--------------------------|
72 -- ----------------------------------------------------------------------------
73 PROCEDURE create_app_ownerships(p_pk_column IN varchar2
74                                ,p_pk_value  IN number) IS
75 --
76 BEGIN
77   create_app_ownerships(p_pk_column, to_char(p_pk_value));
78 END create_app_ownerships;
79 --
80 -- ----------------------------------------------------------------------------
81 -- |------------------------------< insert_dml >------------------------------|
82 -- ----------------------------------------------------------------------------
83 -- {Start Of Comments}
84 --
85 -- Description:
86 --   This procedure controls the actual dml insert logic. The processing of
87 --   this procedure are as follows:
88 --   1) Initialise the object_version_number to 1 if the object_version_number
89 --      is defined as an attribute for this entity.
90 --   2) To set and unset the g_api_dml status as required (as we are about to
91 --      perform dml).
92 --   3) To insert the row into the schema.
93 --   4) To trap any constraint violations that may have occurred.
94 --   5) To raise any other errors.
95 --
96 -- Prerequisites:
97 --   This is an internal private procedure which must be called from the ins
98 --   procedure and must have all mandatory attributes set (except the
99 --   object_version_number which is initialised within this procedure).
100 --
101 -- In Parameters:
102 --   A Pl/Sql record structre.
103 --
104 -- Post Success:
105 --   The specified row will be inserted into the schema.
106 --
107 -- Post Failure:
108 --   On the insert dml failure it is important to note that we always reset the
109 --   g_api_dml status to false.
110 --   If a check, unique or parent integrity constraint violation is raised the
111 --   constraint_error procedure will be called.
112 --   If any other error is reported, the error will be raised after the
113 --   g_api_dml status is reset.
114 --
115 -- Developer Implementation Notes:
116 --   None.
117 --
118 -- Access Status:
119 --   Internal Row Handler Use Only.
120 --
121 -- {End Of Comments}
122 -- ----------------------------------------------------------------------------
123 Procedure insert_dml
124   (p_rec in out nocopy pay_rcu_shd.g_rec_type
125   ) is
126 --
127   l_proc  varchar2(72) := g_package||'insert_dml';
128 --
129 Begin
130   hr_utility.set_location('Entering:'||l_proc, 5);
131   p_rec.object_version_number := 1;  -- Initialise the object version
132   --
133   --
134   --
135   -- Insert the row into: pay_retro_component_usages
136   --
137   insert into pay_retro_component_usages
138       (retro_component_usage_id
139       ,business_group_id
140       ,legislation_code
141       ,retro_component_id
142       ,creator_id
143       ,creator_type
144       ,default_component
145       ,reprocess_type
146       ,object_version_number
147       ,replace_run_flag
148       ,use_override_dates
149       )
150   Values
151     (p_rec.retro_component_usage_id
152     ,p_rec.business_group_id
153     ,p_rec.legislation_code
154     ,p_rec.retro_component_id
155     ,p_rec.creator_id
156     ,p_rec.creator_type
157     ,p_rec.default_component
158     ,p_rec.reprocess_type
159     ,p_rec.object_version_number
160     ,p_rec.replace_run_flag
161     ,p_rec.use_override_dates
162     );
163   --
164   --
165   --
166   hr_utility.set_location(' Leaving:'||l_proc, 10);
167 Exception
168   When hr_api.check_integrity_violated Then
169     -- A check constraint has been violated
170     --
171     pay_rcu_shd.constraint_error
172       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
173   When hr_api.parent_integrity_violated Then
174     -- Parent integrity has been violated
175     --
176     pay_rcu_shd.constraint_error
177       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
178   When hr_api.unique_integrity_violated Then
179     -- Unique integrity has been violated
180     --
181     pay_rcu_shd.constraint_error
182       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
183   When Others Then
184     --
185     Raise;
186 End insert_dml;
187 --
188 -- ----------------------------------------------------------------------------
189 -- |------------------------------< pre_insert >------------------------------|
190 -- ----------------------------------------------------------------------------
191 -- {Start Of Comments}
192 --
193 -- Description:
194 --   This private procedure contains any processing which is required before
195 --   the insert dml. Presently, if the entity has a corresponding primary
196 --   key which is maintained by an associating sequence, the primary key for
197 --   the entity will be populated with the next sequence value in
198 --   preparation for the insert dml.
199 --
200 -- Prerequisites:
201 --   This is an internal procedure which is called from the ins procedure.
202 --
203 -- In Parameters:
204 --   A Pl/Sql record structure.
205 --
206 -- Post Success:
207 --   Processing continues.
208 --
209 -- Post Failure:
210 --   If an error has occurred, an error message and exception will be raised
211 --   but not handled.
212 --
213 -- Developer Implementation Notes:
214 --   Any pre-processing required before the insert dml is issued should be
215 --   coded within this procedure. As stated above, a good example is the
216 --   generation of a primary key number via a corresponding sequence.
217 --   It is important to note that any 3rd party maintenance should be reviewed
218 --   before placing in this procedure.
219 --
220 -- Access Status:
221 --   Internal Row Handler Use Only.
222 --
223 -- {End Of Comments}
224 -- ----------------------------------------------------------------------------
225 Procedure pre_insert
226   (p_rec  in out nocopy pay_rcu_shd.g_rec_type
227   ) is
228 --
229   Cursor C_Sel1 is select pay_retro_component_usages_s.nextval from sys.dual;
230 --
231   Cursor C_Sel2 is
232     Select null
233       from pay_retro_component_usages
234      where retro_component_usage_id =
235              pay_rcu_ins.g_retro_component_usage_id_i;
236 --
237   l_proc   varchar2(72) := g_package||'pre_insert';
238   l_exists varchar2(1);
239 --
240 Begin
241   hr_utility.set_location('Entering:'||l_proc, 5);
242   --
243   If (pay_rcu_ins.g_retro_component_usage_id_i is not null) Then
244     --
245     -- Verify registered primary key values not already in use
246     --
247     Open C_Sel2;
248     Fetch C_Sel2 into l_exists;
249     If C_Sel2%found Then
250        Close C_Sel2;
251        --
252        -- The primary key values are already in use.
253        --
254        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
255        fnd_message.set_token('TABLE_NAME','pay_retro_component_usages');
256        fnd_message.raise_error;
257     End If;
258     Close C_Sel2;
259     --
260     -- Use registered key values and clear globals
261     --
262     p_rec.retro_component_usage_id :=
263       pay_rcu_ins.g_retro_component_usage_id_i;
264     pay_rcu_ins.g_retro_component_usage_id_i := null;
265   Else
266     --
267     -- No registerd key values, so select the next sequence number
268     --
269     --
270     -- Select the next sequence number
271     --
272     Open C_Sel1;
273     Fetch C_Sel1 Into p_rec.retro_component_usage_id;
274     Close C_Sel1;
275   End If;
276   --
277   hr_utility.set_location(' Leaving:'||l_proc, 10);
278 End pre_insert;
279 --
280 -- ----------------------------------------------------------------------------
281 -- |-----------------------------< post_insert >------------------------------|
282 -- ----------------------------------------------------------------------------
283 -- {Start Of Comments}
284 --
285 -- Description:
286 --   This private procedure contains any processing which is required after
287 --   the insert dml.
288 --
289 -- Prerequisites:
290 --   This is an internal procedure which is called from the ins procedure.
291 --
292 -- In Parameters:
293 --   A Pl/Sql record structre.
294 --
295 -- Post Success:
296 --   Processing continues.
297 --
298 -- Post Failure:
299 --   If an error has occurred, an error message and exception will be raised
300 --   but not handled.
301 --
302 -- Developer Implementation Notes:
303 --   Any post-processing required after the insert dml is issued should be
304 --   coded within this procedure. It is important to note that any 3rd party
305 --   maintenance should be reviewed before placing in this procedure.
306 --
307 -- Access Status:
308 --   Internal Row Handler Use Only.
309 --
310 -- {End Of Comments}
311 -- ----------------------------------------------------------------------------
312 Procedure post_insert
313   (p_effective_date               in date
314   ,p_rec                          in pay_rcu_shd.g_rec_type
315   ) is
316 --
317   l_proc  varchar2(72) := g_package||'post_insert';
318 --
319 Begin
320   hr_utility.set_location('Entering:'||l_proc, 5);
321   begin
322     --
323     -- insert ownerships if applicable
324     create_app_ownerships
325       ('RETRO_COMPONENT_USAGE_ID', p_rec.retro_component_usage_id
326       );
327     --
328     --
329     pay_rcu_rki.after_insert
330       (p_effective_date              => p_effective_date
331       ,p_retro_component_usage_id
332       => p_rec.retro_component_usage_id
333       ,p_business_group_id
334       => p_rec.business_group_id
335       ,p_legislation_code
336       => p_rec.legislation_code
337       ,p_retro_component_id
338       => p_rec.retro_component_id
339       ,p_creator_id
340       => p_rec.creator_id
341       ,p_creator_type
342       => p_rec.creator_type
343       ,p_default_component
344       => p_rec.default_component
345       ,p_reprocess_type
346       => p_rec.reprocess_type
347       ,p_object_version_number
348       => p_rec.object_version_number
349       ,p_replace_run_flag
350       => p_rec.replace_run_flag
351       ,p_use_override_dates
352       => p_rec.use_override_dates
353       );
354     --
355   exception
356     --
357     when hr_api.cannot_find_prog_unit then
358       --
359       hr_api.cannot_find_prog_unit_error
360         (p_module_name => 'PAY_RETRO_COMPONENT_USAGES'
361         ,p_hook_type   => 'AI');
362       --
363   end;
364   --
365   hr_utility.set_location(' Leaving:'||l_proc, 10);
366 End post_insert;
367 --
368 -- ----------------------------------------------------------------------------
369 -- |---------------------------------< ins >----------------------------------|
370 -- ----------------------------------------------------------------------------
371 Procedure ins
372   (p_effective_date               in date
373   ,p_rec                          in out nocopy pay_rcu_shd.g_rec_type
374   ) is
375 --
376   l_proc  varchar2(72) := g_package||'ins';
377 --
378 Begin
379   hr_utility.set_location('Entering:'||l_proc, 5);
380   --
381   -- Call the supporting insert validate operations
382   --
383   pay_rcu_bus.insert_validate
384      (p_effective_date
385      ,p_rec
386      );
387   --
388   -- Call to raise any errors on multi-message list
389   hr_multi_message.end_validation_set;
390   --
391   -- Call the supporting pre-insert operation
392   --
393   pay_rcu_ins.pre_insert(p_rec);
394   --
395   -- Insert the row
396   --
397   pay_rcu_ins.insert_dml(p_rec);
398   --
399   -- Call the supporting post-insert operation
400   --
401   pay_rcu_ins.post_insert
402      (p_effective_date
403      ,p_rec
404      );
405   --
406   -- Call to raise any errors on multi-message list
407   hr_multi_message.end_validation_set;
408   --
409   hr_utility.set_location('Leaving:'||l_proc, 20);
410 end ins;
411 --
412 -- ----------------------------------------------------------------------------
413 -- |---------------------------------< ins >----------------------------------|
414 -- ----------------------------------------------------------------------------
415 Procedure ins
416   (p_effective_date               in     date
417   ,p_retro_component_id             in     number
418   ,p_creator_id                     in     number
419   ,p_creator_type                   in     varchar2
420   ,p_default_component              in     varchar2
421   ,p_reprocess_type                 in     varchar2
422   ,p_business_group_id              in     number   default null
423   ,p_legislation_code               in     varchar2 default null
424   ,p_retro_component_usage_id          out nocopy number
425   ,p_object_version_number             out nocopy number
426   ,p_replace_run_flag               in     varchar2 default null
427   ,p_use_override_dates             in     varchar2 default null
428   ) is
429 --
430   l_rec   pay_rcu_shd.g_rec_type;
431   l_proc  varchar2(72) := g_package||'ins';
432 --
433 Begin
434   hr_utility.set_location('Entering:'||l_proc, 5);
435   --
436   -- Call conversion function to turn arguments into the
437   -- p_rec structure.
438   --
439   l_rec :=
440   pay_rcu_shd.convert_args
441     (null
442     ,p_business_group_id
443     ,p_legislation_code
444     ,p_retro_component_id
445     ,p_creator_id
446     ,p_creator_type
447     ,p_default_component
448     ,p_reprocess_type
449     ,null
450     ,p_replace_run_flag
451     ,p_use_override_dates
452     );
453   --
454   -- Having converted the arguments into the pay_rcu_rec
455   -- plsql record structure we call the corresponding record business process.
456   --
457   pay_rcu_ins.ins
458      (p_effective_date
459      ,l_rec
460      );
461   --
462   -- As the primary key argument(s)
463   -- are specified as an OUT's we must set these values.
464   --
465   p_retro_component_usage_id := l_rec.retro_component_usage_id;
466   p_object_version_number := l_rec.object_version_number;
467   --
468   hr_utility.set_location(' Leaving:'||l_proc, 10);
469 End ins;
470 --
471 end pay_rcu_ins;