DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_BLT_INS

Source


1 Package Body pay_blt_ins as
2 /* $Header: pybltrhi.pkb 120.4 2012/03/01 05:23:29 vvijayku ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_blt_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_balance_type_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_balance_type_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_blt_ins.g_balance_type_id_i := p_balance_type_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_blt_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   pay_blt_shd.g_api_dml := true;  -- Set the api dml status
134   --
135   -- Insert the row into: pay_balance_types
136   --
137   insert into pay_balance_types
138       (balance_type_id
139       ,business_group_id
140       ,legislation_code
141       ,currency_code
142       ,assignment_remuneration_flag
143       ,balance_name
144       ,balance_uom
145       ,comments
146       ,legislation_subgroup
147       ,reporting_name
148       ,attribute_category
149       ,attribute1
150       ,attribute2
151       ,attribute3
152       ,attribute4
153       ,attribute5
154       ,attribute6
155       ,attribute7
156       ,attribute8
157       ,attribute9
158       ,attribute10
159       ,attribute11
160       ,attribute12
161       ,attribute13
162       ,attribute14
163       ,attribute15
164       ,attribute16
165       ,attribute17
166       ,attribute18
167       ,attribute19
168       ,attribute20
169       ,jurisdiction_level
170       ,tax_type
171       ,object_version_number
172       ,balance_category_id
173       ,base_balance_type_id
174       ,input_value_id
175       )
176   Values
177     (p_rec.balance_type_id
178     ,p_rec.business_group_id
179     ,p_rec.legislation_code
180     ,p_rec.currency_code
181     ,p_rec.assignment_remuneration_flag
182     ,p_rec.balance_name
183     ,p_rec.balance_uom
184     ,p_rec.comments
185     ,p_rec.legislation_subgroup
186     ,p_rec.reporting_name
187     ,p_rec.attribute_category
188     ,p_rec.attribute1
189     ,p_rec.attribute2
190     ,p_rec.attribute3
191     ,p_rec.attribute4
192     ,p_rec.attribute5
193     ,p_rec.attribute6
194     ,p_rec.attribute7
195     ,p_rec.attribute8
196     ,p_rec.attribute9
197     ,p_rec.attribute10
198     ,p_rec.attribute11
199     ,p_rec.attribute12
200     ,p_rec.attribute13
201     ,p_rec.attribute14
202     ,p_rec.attribute15
203     ,p_rec.attribute16
204     ,p_rec.attribute17
205     ,p_rec.attribute18
206     ,p_rec.attribute19
207     ,p_rec.attribute20
208     ,p_rec.jurisdiction_level
209     ,p_rec.tax_type
210     ,p_rec.object_version_number
211     ,p_rec.balance_category_id
212     ,p_rec.base_balance_type_id
213     ,p_rec.input_value_id
214     );
215   --
216   pay_blt_shd.g_api_dml := false;   -- Unset the api dml status
217   --
218   hr_utility.set_location(' Leaving:'||l_proc, 10);
219 Exception
220   When hr_api.check_integrity_violated Then
221     -- A check constraint has been violated
222     pay_blt_shd.g_api_dml := false;   -- Unset the api dml status
223     pay_blt_shd.constraint_error
224       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
225   When hr_api.parent_integrity_violated Then
226     -- Parent integrity has been violated
227     pay_blt_shd.g_api_dml := false;   -- Unset the api dml status
228     pay_blt_shd.constraint_error
229       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
230   When hr_api.unique_integrity_violated Then
231     -- Unique integrity has been violated
232     pay_blt_shd.g_api_dml := false;   -- Unset the api dml status
233     pay_blt_shd.constraint_error
234       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
235   When Others Then
236     pay_blt_shd.g_api_dml := false;   -- Unset the api dml status
237     Raise;
238 End insert_dml;
239 --
240 -- ----------------------------------------------------------------------------
241 -- |------------------------------< pre_insert >------------------------------|
242 -- ----------------------------------------------------------------------------
243 -- {Start Of Comments}
244 --
245 -- Description:
246 --   This private procedure contains any processing which is required before
247 --   the insert dml. Presently, if the entity has a corresponding primary
248 --   key which is maintained by an associating sequence, the primary key for
249 --   the entity will be populated with the next sequence value in
250 --   preparation for the insert dml.
251 --
252 -- Prerequisites:
253 --   This is an internal procedure which is called from the ins procedure.
254 --
255 -- In Parameters:
256 --   A Pl/Sql record structure.
257 --
258 -- Post Success:
259 --   Processing continues.
260 --
261 -- Post Failure:
262 --   If an error has occurred, an error message and exception will be raised
263 --   but not handled.
264 --
265 -- Developer Implementation Notes:
266 --   Any pre-processing required before the insert dml is issued should be
267 --   coded within this procedure. As stated above, a good example is the
268 --   generation of a primary key number via a corresponding sequence.
269 --   It is important to note that any 3rd party maintenance should be reviewed
270 --   before placing in this procedure.
271 --
272 -- Access Status:
273 --   Internal Row Handler Use Only.
274 --
275 -- {End Of Comments}
276 -- ----------------------------------------------------------------------------
277 Procedure pre_insert
278   (p_rec  in out nocopy pay_blt_shd.g_rec_type
279   ) is
280 --
281   Cursor C_Sel1 is select pay_balance_types_s.nextval from sys.dual;
282 --
283   Cursor C_Sel2 is
284     Select null
285       from pay_balance_types
286      where balance_type_id =
287              pay_blt_ins.g_balance_type_id_i;
288 --
289   l_proc   varchar2(72) := g_package||'pre_insert';
290   l_exists varchar2(1);
291 --
292 Begin
293   hr_utility.set_location('Entering:'||l_proc, 5);
294   --
295   If (pay_blt_ins.g_balance_type_id_i is not null) Then
296     --
297     -- Verify registered primary key values not already in use
298     --
299     Open C_Sel2;
300     Fetch C_Sel2 into l_exists;
301     If C_Sel2%found Then
302        Close C_Sel2;
303        --
304        -- The primary key values are already in use.
305        --
306        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
307        fnd_message.set_token('TABLE_NAME','pay_balance_types');
308        fnd_message.raise_error;
309     End If;
310     Close C_Sel2;
311     --
312     -- Use registered key values and clear globals
313     --
314     p_rec.balance_type_id :=
315       pay_blt_ins.g_balance_type_id_i;
316     pay_blt_ins.g_balance_type_id_i := null;
317   Else
318     --
319     -- No registerd key values, so select the next sequence number
320     --
321     --
322     -- Select the next sequence number
323     --
324     Open C_Sel1;
325     Fetch C_Sel1 Into p_rec.balance_type_id;
326     Close C_Sel1;
327   End If;
328   --
329   hr_utility.set_location(' Leaving:'||l_proc, 10);
330 End pre_insert;
331 --
332 -- ----------------------------------------------------------------------------
333 -- |-----------------------------< post_insert >------------------------------|
334 -- ----------------------------------------------------------------------------
335 -- {Start Of Comments}
336 --
337 -- Description:
338 --   This private procedure contains any processing which is required after
339 --   the insert dml.
340 --
341 -- Prerequisites:
342 --   This is an internal procedure which is called from the ins procedure.
343 --
344 -- In Parameters:
345 --   A Pl/Sql record structre.
346 --
347 -- Post Success:
348 --   Processing continues.
349 --
350 -- Post Failure:
351 --   If an error has occurred, an error message and exception will be raised
352 --   but not handled.
353 --
354 -- Developer Implementation Notes:
355 --   Any post-processing required after the insert dml is issued should be
356 --   coded within this procedure. It is important to note that any 3rd party
357 --   maintenance should be reviewed before placing in this procedure.
358 --
359 -- Access Status:
360 --   Internal Row Handler Use Only.
361 --
362 -- {End Of Comments}
363 -- ----------------------------------------------------------------------------
364 Procedure post_insert
365   (p_effective_date               in date
366   ,p_rec                          in pay_blt_shd.g_rec_type
367   ) is
368 --
369   l_proc  varchar2(72) := g_package||'post_insert';
370 --
371 Begin
372   hr_utility.set_location('Entering:'||l_proc, 5);
373   begin
374     --
375     -- insert ownerships if applicable
376     create_app_ownerships
377       ('BALANCE_TYPE_ID', p_rec.balance_type_id
378       );
379     --
380     --
381     pay_blt_rki.after_insert
382       (p_effective_date              => p_effective_date
383       ,p_balance_type_id
384       => p_rec.balance_type_id
385       ,p_business_group_id
386       => p_rec.business_group_id
387       ,p_legislation_code
388       => p_rec.legislation_code
389       ,p_currency_code
390       => p_rec.currency_code
391       ,p_assignment_remuneration_flag
392       => p_rec.assignment_remuneration_flag
393       ,p_balance_name
394       => p_rec.balance_name
395       ,p_balance_uom
396       => p_rec.balance_uom
397       ,p_comments
398       => p_rec.comments
399       ,p_legislation_subgroup
400       => p_rec.legislation_subgroup
401       ,p_reporting_name
402       => p_rec.reporting_name
403       ,p_attribute_category
404       => p_rec.attribute_category
405       ,p_attribute1
406       => p_rec.attribute1
407       ,p_attribute2
408       => p_rec.attribute2
409       ,p_attribute3
410       => p_rec.attribute3
411       ,p_attribute4
412       => p_rec.attribute4
413       ,p_attribute5
414       => p_rec.attribute5
415       ,p_attribute6
416       => p_rec.attribute6
417       ,p_attribute7
418       => p_rec.attribute7
419       ,p_attribute8
420       => p_rec.attribute8
421       ,p_attribute9
422       => p_rec.attribute9
423       ,p_attribute10
424       => p_rec.attribute10
425       ,p_attribute11
426       => p_rec.attribute11
427       ,p_attribute12
428       => p_rec.attribute12
429       ,p_attribute13
430       => p_rec.attribute13
431       ,p_attribute14
432       => p_rec.attribute14
433       ,p_attribute15
434       => p_rec.attribute15
435       ,p_attribute16
436       => p_rec.attribute16
437       ,p_attribute17
438       => p_rec.attribute17
439       ,p_attribute18
440       => p_rec.attribute18
441       ,p_attribute19
442       => p_rec.attribute19
443       ,p_attribute20
444       => p_rec.attribute20
445       ,p_jurisdiction_level
446       => p_rec.jurisdiction_level
447       ,p_tax_type
448       => p_rec.tax_type
449       ,p_object_version_number
450       => p_rec.object_version_number
451       ,p_balance_category_id
452       => p_rec.balance_category_id
453       ,p_base_balance_type_id
454       => p_rec.base_balance_type_id
455       ,p_input_value_id
456       => p_rec.input_value_id
457       );
458     --
459   exception
460     --
461     when hr_api.cannot_find_prog_unit then
462       --
463       hr_api.cannot_find_prog_unit_error
464         (p_module_name => 'PAY_BALANCE_TYPES'
465         ,p_hook_type   => 'AI');
466       --
467   end;
468   --
469   hr_utility.set_location(' Leaving:'||l_proc, 10);
470 End post_insert;
471 --
472 -- ----------------------------------------------------------------------------
473 -- |---------------------------------< ins >----------------------------------|
474 -- ----------------------------------------------------------------------------
475 Procedure ins
476   (p_effective_date               in date
477   ,p_rec                          in out nocopy pay_blt_shd.g_rec_type
478   ) is
479 --
480   l_proc  varchar2(72) := g_package||'ins';
481 --
482 Begin
483   hr_utility.set_location('Entering:'||l_proc, 5);
484   --
485   -- Call the supporting insert validate operations
486   --
487   pay_blt_bus.insert_validate
488      (p_effective_date
489      ,p_rec
490      );
491 
492   --
493   --
494   -- Call to raise any errors on multi-message list
495   hr_multi_message.end_validation_set;
496   --
497   -- Call the supporting pre-insert operation
498   --
499   pay_blt_ins.pre_insert(p_rec);
500   --
501   -- Insert the row
502   --
503   pay_blt_ins.insert_dml(p_rec);
504   --
505   -- Call the supporting post-insert operation
506   --
507   pay_blt_ins.post_insert
508      (p_effective_date
509      ,p_rec
510      );
511   --
512   -- insert associated feed of primary balance
513   --
514   if p_rec.input_value_id is not null then
515     pay_blt_bus.insert_primary_balance_feed
516      ( p_effective_date       => p_effective_date
517       ,p_business_group_id    => p_rec.business_group_id
518       ,p_balance_type_id      => p_rec.balance_type_id
519       ,p_input_value_id       => p_rec.input_value_id
520      );
521   end if;
522 
523   -- Call to raise any errors on multi-message list
524   hr_multi_message.end_validation_set;
525   --
526   hr_utility.set_location('Leaving:'||l_proc, 20);
527 end ins;
528 --
529 -- ----------------------------------------------------------------------------
530 -- |---------------------------------< ins >----------------------------------|
531 -- ----------------------------------------------------------------------------
532 Procedure ins
533   (p_effective_date               in     date
534   ,p_assignment_remuneration_flag   in     varchar2
535   ,p_balance_uom                    in     varchar2
536   ,p_business_group_id              in     number   default null
537   ,p_legislation_code               in     varchar2 default null
538   ,p_currency_code                  in     varchar2 default null
539   ,p_balance_name                   in     varchar2 default null
540   ,p_comments                       in     varchar2 default null
541   ,p_legislation_subgroup           in     varchar2 default null
542   ,p_reporting_name                 in     varchar2 default null
543   ,p_attribute_category             in     varchar2 default null
544   ,p_attribute1                     in     varchar2 default null
545   ,p_attribute2                     in     varchar2 default null
546   ,p_attribute3                     in     varchar2 default null
547   ,p_attribute4                     in     varchar2 default null
548   ,p_attribute5                     in     varchar2 default null
549   ,p_attribute6                     in     varchar2 default null
550   ,p_attribute7                     in     varchar2 default null
551   ,p_attribute8                     in     varchar2 default null
552   ,p_attribute9                     in     varchar2 default null
553   ,p_attribute10                    in     varchar2 default null
554   ,p_attribute11                    in     varchar2 default null
555   ,p_attribute12                    in     varchar2 default null
556   ,p_attribute13                    in     varchar2 default null
557   ,p_attribute14                    in     varchar2 default null
558   ,p_attribute15                    in     varchar2 default null
559   ,p_attribute16                    in     varchar2 default null
560   ,p_attribute17                    in     varchar2 default null
561   ,p_attribute18                    in     varchar2 default null
562   ,p_attribute19                    in     varchar2 default null
563   ,p_attribute20                    in     varchar2 default null
564   ,p_jurisdiction_level             in     number   default null
565   ,p_tax_type                       in     varchar2 default null
566   ,p_balance_category_id            in     number   default null
567   ,p_base_balance_type_id           in     number   default null
568   ,p_input_value_id                 in     number   default null
569   ,p_balance_type_id                   out nocopy number
570   ,p_object_version_number             out nocopy number
571   ) is
572 --
573   l_rec				pay_blt_shd.g_rec_type;
574   l_proc			varchar2(72) := g_package||'ins';
575   l_balance_name_warning        number;
576 --
577 Begin
578   hr_utility.set_location('Entering:'||l_proc, 5);
579   --
580   -- Call conversion function to turn arguments into the
581   -- p_rec structure.
582   --
583   l_rec :=
584   pay_blt_shd.convert_args
585     (null
586     ,p_business_group_id
587     ,p_legislation_code
588     ,p_currency_code
589     ,p_assignment_remuneration_flag
590     ,p_balance_name
591     ,p_balance_uom
592     ,p_comments
593     ,p_legislation_subgroup
594     ,p_reporting_name
595     ,p_attribute_category
596     ,p_attribute1
597     ,p_attribute2
598     ,p_attribute3
599     ,p_attribute4
600     ,p_attribute5
601     ,p_attribute6
602     ,p_attribute7
603     ,p_attribute8
604     ,p_attribute9
605     ,p_attribute10
606     ,p_attribute11
607     ,p_attribute12
608     ,p_attribute13
609     ,p_attribute14
610     ,p_attribute15
611     ,p_attribute16
612     ,p_attribute17
613     ,p_attribute18
614     ,p_attribute19
615     ,p_attribute20
616     ,p_jurisdiction_level
617     ,p_tax_type
618     ,null
619     ,p_balance_category_id
620     ,p_base_balance_type_id
621     ,p_input_value_id
622     );
623   --
624   -- Having converted the arguments into the pay_blt_rec
625   -- plsql record structure we call the corresponding record business process.
626   --
627   pay_blt_ins.ins
628      (p_effective_date
629      ,l_rec
630      );
631   --
632   -- As the primary key argument(s)
633   -- are specified as an OUT's we must set these values.
634   --
635   p_balance_type_id := l_rec.balance_type_id;
636   p_object_version_number := l_rec.object_version_number;
637   --
638   hr_utility.set_location(' Leaving:'||l_proc, 10);
639 End ins;
640 --
641 end pay_blt_ins;