DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BEO_INS

Source


1 Package Body ben_beo_ins as
2 /* $Header: bebeorhi.pkb 120.0.12010000.3 2008/08/05 14:07:36 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ben_beo_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_elig_obj_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_elig_obj_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   ben_beo_ins.g_elig_obj_id_i := p_elig_obj_id;
27   --
28   hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 --
32 -- ----------------------------------------------------------------------------
33 -- |----------------------------< dt_insert_dml >-----------------------------|
34 -- ----------------------------------------------------------------------------
35 -- {Start Of Comments}
36 --
37 -- Description:
38 --   This procedure controls the actual dml insert logic for datetrack. The
39 --   functions of this procedure are as follows:
40 --   1) Get the object_version_number.
41 --   2) To set the effective start and end dates to the corresponding
42 --      validation start and end dates. Also, the object version number
43 --      record attribute is set.
44 --   3) To set and unset the g_api_dml status as required (as we are about to
45 --      perform dml).
46 --   4) To insert the row into the schema with the derived effective start
47 --      and end dates and the object version number.
48 --   5) To trap any constraint violations that may have occurred.
49 --   6) To raise any other errors.
50 --
51 -- Prerequisites:
52 --   This is an internal private procedure which must be called from the
53 --   insert_dml and pre_update (logic permitting) procedure and must have
54 --   all mandatory arguments set.
55 --
56 -- In Parameters:
57 --   A Pl/Sql record structure.
58 --
59 -- Post Success:
60 --   The specified row will be inserted into the schema.
61 --
62 -- Post Failure:
63 --   On the insert dml failure it is important to note that we always reset the
64 --   g_api_dml status to false.
65 --   If a check or unique integrity constraint violation is raised the
66 --   constraint_error procedure will be called.
67 --   If any other error is reported, the error will be raised after the
68 --   g_api_dml status is reset.
69 --
70 -- Developer Implementation Notes:
71 --   This is an internal datetrack maintenance procedure which should
72 --   not be modified in anyway.
73 --
74 -- Access Status:
75 --   Internal Row Handler Use Only.
76 --
77 -- {End Of Comments}
78 -- ----------------------------------------------------------------------------
79 Procedure dt_insert_dml
80   (p_rec                     in out nocopy ben_beo_shd.g_rec_type
81   ,p_effective_date          in date
82   ,p_datetrack_mode          in varchar2
83   ,p_validation_start_date   in date
84   ,p_validation_end_date     in date
85   ) is
86 -- Cursor to select 'old' created AOL who column values
87 --
88   Cursor C_Sel1 Is
89     select t.created_by,
90            t.creation_date
91     from   ben_elig_obj_f t
92     where  t.elig_obj_id       = p_rec.elig_obj_id
93     and    t.effective_start_date =
94              ben_beo_shd.g_old_rec.effective_start_date
95     and    t.effective_end_date   = (p_validation_start_date - 1);
96 --
97   l_proc                varchar2(72) := g_package||'dt_insert_dml';
98   l_created_by          ben_elig_obj_f.created_by%TYPE;
99   l_creation_date       ben_elig_obj_f.creation_date%TYPE;
100   l_last_update_date    ben_elig_obj_f.last_update_date%TYPE;
101   l_last_updated_by     ben_elig_obj_f.last_updated_by%TYPE;
102   l_last_update_login   ben_elig_obj_f.last_update_login%TYPE;
103 --
104 Begin
105   hr_utility.set_location('Entering:'||l_proc, 5);
106   --
107   -- Set the effective start and end dates to the corresponding
108   -- validation start and end dates
109   --
110   p_rec.effective_start_date := p_validation_start_date;
111   p_rec.effective_end_date   := p_validation_end_date;
112   --
113   -- If the datetrack_mode is not INSERT then we must populate the WHO
114   -- columns with the 'old' creation values and 'new' updated values.
115   --
116   If (p_datetrack_mode <> hr_api.g_insert) then
117     hr_utility.set_location(l_proc, 10);
118     --
119       -- Get the object version number for the insert
120   --
121   p_rec.object_version_number :=
122     dt_api.get_object_version_number
123       (p_base_table_name => 'ben_elig_obj_f'
124       ,p_base_key_column => 'elig_obj_id'
125       ,p_base_key_value  => p_rec.elig_obj_id
126       );
127   --
128     -- Select the 'old' created values
129     --
130     Open C_Sel1;
131     Fetch C_Sel1 Into l_created_by, l_creation_date;
132     If C_Sel1%notfound Then
133       --
134       -- The previous 'old' created row has not been found. We need
135       -- to error as an internal datetrack problem exists.
136       --
137       Close C_Sel1;
138       fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
139       fnd_message.set_token('PROCEDURE', l_proc);
140       fnd_message.set_token('STEP','10');
141       fnd_message.raise_error;
142     End If;
143     Close C_Sel1;
144     --
145     -- Set the AOL updated WHO values
146     --
147     l_last_update_date   := sysdate;
148     l_last_updated_by    := fnd_global.user_id;
149     l_last_update_login  := fnd_global.login_id;
150   Else
151     p_rec.object_version_number := 1;  -- Initialise the object version
152   End If;
153   --
154   --
155   --
156   -- Insert the row into: ben_elig_obj_f
157   --
158   insert into ben_elig_obj_f
159       (elig_obj_id
160       ,effective_start_date
161       ,effective_end_date
162       ,table_name
163       ,column_name
164       ,column_value
165       ,business_group_id
166       ,object_version_number
167       ,created_by
168       ,creation_date
169       ,last_update_date
170       ,last_updated_by
171       ,last_update_login
172       )
173   Values
174     (p_rec.elig_obj_id
175     ,p_rec.effective_start_date
176     ,p_rec.effective_end_date
177     ,p_rec.table_name
178     ,p_rec.column_name
179     ,p_rec.column_value
180     ,p_rec.business_group_id
181     ,p_rec.object_version_number
182     ,l_created_by
183     ,l_creation_date
184     ,l_last_update_date
185     ,l_last_updated_by
186     ,l_last_update_login
187     );
188   --
189   --
190   hr_utility.set_location(' Leaving:'||l_proc, 15);
191 --
192 Exception
193   When hr_api.check_integrity_violated Then
194     -- A check constraint has been violated
195     --
196     ben_beo_shd.constraint_error
197       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
198   When hr_api.unique_integrity_violated Then
199     -- Unique integrity has been violated
200     --
201     ben_beo_shd.constraint_error
202       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
203   When Others Then
204     --
205     Raise;
206 End dt_insert_dml;
207 --
208 -- ----------------------------------------------------------------------------
209 -- |------------------------------< insert_dml >------------------------------|
210 -- ----------------------------------------------------------------------------
211 Procedure insert_dml
212   (p_rec                   in out nocopy ben_beo_shd.g_rec_type
213   ,p_effective_date        in date
214   ,p_datetrack_mode        in varchar2
215   ,p_validation_start_date in date
216   ,p_validation_end_date   in date
217   ) is
218 --
219   l_proc        varchar2(72) := g_package||'insert_dml';
220 --
221 Begin
222   hr_utility.set_location('Entering:'||l_proc, 5);
223   --
224   ben_beo_ins.dt_insert_dml
225     (p_rec                   => p_rec
226     ,p_effective_date        => p_effective_date
227     ,p_datetrack_mode        => p_datetrack_mode
228     ,p_validation_start_date => p_validation_start_date
229     ,p_validation_end_date   => p_validation_end_date
230     );
231   --
232   hr_utility.set_location(' Leaving:'||l_proc, 10);
233 End insert_dml;
234 --
235 -- ----------------------------------------------------------------------------
236 -- |------------------------------< pre_insert >------------------------------|
237 -- ----------------------------------------------------------------------------
238 -- {Start Of Comments}
239 --
240 -- Description:
241 --   This private procedure contains any processing which is required before
242 --   the insert dml. Presently, if the entity has a corresponding primary
243 --   key which is maintained by an associating sequence, the primary key for
244 --   the entity will be populated with the next sequence value in
245 --   preparation for the insert dml.
246 --   Also, if comments are defined for this entity, the comments insert
247 --   logic will also be called, generating a comment_id if required.
248 --
249 -- Prerequisites:
250 --   This is an internal procedure which is called from the ins procedure.
251 --
252 -- In Parameters:
253 --   A Pl/Sql record structure.
254 --
255 -- Post Success:
256 --   Processing continues.
257 --
258 -- Post Failure:
259 --   If an error has occurred, an error message and exception will be raised
260 --   but not handled.
261 --
262 -- Developer Implementation Notes:
263 --   Any pre-processing required before the insert dml is issued should be
264 --   coded within this procedure. As stated above, a good example is the
265 --   generation of a primary key number via a corresponding sequence.
266 --   It is important to note that any 3rd party maintenance should be reviewed
267 --   before placing in this procedure.
268 --
269 -- Access Status:
270 --   Internal Row Handler Use Only.
271 --
272 -- {End Of Comments}
273 -- ----------------------------------------------------------------------------
274 Procedure pre_insert
275   (p_rec                   in out nocopy ben_beo_shd.g_rec_type
276   ,p_effective_date        in date
277   ,p_datetrack_mode        in varchar2
278   ,p_validation_start_date in date
279   ,p_validation_end_date   in date
280   ) is
281 --
282   Cursor C_Sel1 is select ben_elig_obj_s.nextval from sys.dual;
283 --
284  Cursor C_Sel2 is
285     Select null
286       from ben_elig_obj_f
287      where elig_obj_id =
288              ben_beo_ins.g_elig_obj_id_i;
289 --
290   l_proc        varchar2(72) := g_package||'pre_insert';
291   l_exists      varchar2(1);
292 --
293 Begin
294   hr_utility.set_location('Entering:'||l_proc, 5);
295   --
296     If (ben_beo_ins.g_elig_obj_id_i is not null) Then
297     --
298     -- Verify registered primary key values not already in use
299     --
300     Open C_Sel2;
301     Fetch C_Sel2 into l_exists;
302     If C_Sel2%found Then
303        Close C_Sel2;
304        --
305        -- The primary key values are already in use.
306        --
307        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
308        fnd_message.set_token('TABLE_NAME','ben_elig_obj_f');
309        fnd_message.raise_error;
310     End If;
311     Close C_Sel2;
312     --
313     -- Use registered key values and clear globals
314     --
315     p_rec.elig_obj_id :=
316       ben_beo_ins.g_elig_obj_id_i;
317     ben_beo_ins.g_elig_obj_id_i := null;
318   Else
319     --
320     -- No registerd key values, so select the next sequence number
321     --
322     --
323     -- Select the next sequence number
324     --
325     Open C_Sel1;
326     Fetch C_Sel1 Into p_rec.elig_obj_id;
327     Close C_Sel1;
328   End If;
329   --
330   --
331   hr_utility.set_location(' Leaving:'||l_proc, 10);
332 End pre_insert;
333 --
334 -- ----------------------------------------------------------------------------
335 -- |----------------------------< post_insert >-------------------------------|
336 -- ----------------------------------------------------------------------------
337 -- {Start Of Comments}
338 --
339 -- Description:
340 --   This private procedure contains any processing which is required after
341 --   the insert dml.
342 --
343 -- Prerequisites:
344 --   This is an internal procedure which is called from the ins procedure.
345 --
346 -- In Parameters:
347 --   A Pl/Sql record structure.
348 --
349 -- Post Success:
350 --   Processing continues.
351 --
352 -- Post Failure:
353 --   If an error has occurred, an error message and exception will be raised
354 --   but not handled.
355 --
356 -- Developer Implementation Notes:
357 --   Any post-processing required after the insert dml is issued should be
358 --   coded within this procedure. It is important to note that any 3rd party
359 --   maintenance should be reviewed before placing in this procedure.
360 --
361 -- Access Status:
362 --   Internal Row Handler Use Only.
363 --
364 -- {End Of Comments}
365 -- ----------------------------------------------------------------------------
366 Procedure post_insert
367   (p_rec                   in ben_beo_shd.g_rec_type
368   ,p_effective_date        in date
369   ,p_datetrack_mode        in varchar2
370   ,p_validation_start_date in date
371   ,p_validation_end_date   in date
372   ) is
373 --
374   l_proc        varchar2(72) := g_package||'post_insert';
375 --
376 Begin
377   hr_utility.set_location('Entering:'||l_proc, 5);
378   begin
379     --
380     ben_beo_rki.after_insert
381       (p_effective_date
382       => p_effective_date
383       ,p_validation_start_date
384       => p_validation_start_date
385       ,p_validation_end_date
386       => p_validation_end_date
387       ,p_elig_obj_id
388       => p_rec.elig_obj_id
389       ,p_effective_start_date
390       => p_rec.effective_start_date
391       ,p_effective_end_date
392       => p_rec.effective_end_date
393       ,p_table_name
394       => p_rec.table_name
395       ,p_column_name
396       => p_rec.column_name
397       ,p_column_value
398       => p_rec.column_value
399       ,p_business_group_id
400       => p_rec.business_group_id
401       ,p_object_version_number
402       => p_rec.object_version_number
403       );
404     --
405   exception
406     --
407     when hr_api.cannot_find_prog_unit then
408       --
409       hr_api.cannot_find_prog_unit_error
410         (p_module_name => 'ben_elig_obj_f'
411         ,p_hook_type   => 'AI');
412       --
413   end;
414   --
415   hr_utility.set_location(' Leaving:'||l_proc, 10);
416 End post_insert;
417 --
418 -- ----------------------------------------------------------------------------
419 -- |-------------------------------< ins_lck >--------------------------------|
420 -- ----------------------------------------------------------------------------
421 -- {Start Of Comments}
422 --
423 -- Description:
424 --   The ins_lck process has one main function to perform. When inserting
425 --   a datetracked row, we must validate the DT mode.
426 --
427 -- Prerequisites:
428 --   This procedure can only be called for the datetrack mode of INSERT.
429 --
430 -- In Parameters:
431 --
432 -- Post Success:
433 --   On successful completion of the ins_lck process the parental
434 --   datetracked rows will be locked providing the p_enforce_foreign_locking
435 --   argument value is TRUE.
436 --   If the p_enforce_foreign_locking argument value is FALSE then the
437 --   parential rows are not locked.
438 --
439 -- Post Failure:
440 --   The Lck process can fail for:
441 --   1) When attempting to lock the row the row could already be locked by
442 --      another user. This will raise the HR_Api.Object_Locked exception.
443 --   2) When attempting to the lock the parent which doesn't exist.
444 --      For the entity to be locked the parent must exist!
445 --
446 -- Developer Implementation Notes:
447 --   None.
448 --
449 -- Access Status:
450 --   Internal Row Handler Use Only.
451 --
452 -- {End Of Comments}
453 -- ----------------------------------------------------------------------------
454 Procedure ins_lck
455   (p_effective_date        in date
456   ,p_datetrack_mode        in varchar2
457   ,p_rec                   in ben_beo_shd.g_rec_type
458   ,p_validation_start_date out nocopy date
459   ,p_validation_end_date   out nocopy date
460   ) is
461 --
462   l_proc                  varchar2(72) := g_package||'ins_lck';
463   l_validation_start_date date;
464   l_validation_end_date   date;
465 --
466 Begin
467   hr_utility.set_location('Entering:'||l_proc, 5);
468   --
469   -- Validate the datetrack mode mode getting the validation start
470   -- and end dates for the specified datetrack operation.
471   --
472   dt_api.validate_dt_mode
473     (p_effective_date          => p_effective_date
474     ,p_datetrack_mode          => p_datetrack_mode
475     ,p_base_table_name         => 'ben_elig_obj_f'
476     ,p_base_key_column         => 'elig_obj_id'
477     ,p_base_key_value          => p_rec.elig_obj_id
478 /*    ,p_parent_table_name1      => p_rec.table_name
479     ,p_parent_key_column1      => p_rec.column_name
480     ,p_parent_key_value1       => p_rec.column_value */
481     ,p_enforce_foreign_locking => false --true
482     ,p_validation_start_date   => l_validation_start_date
483     ,p_validation_end_date     => l_validation_end_date
484     );
485   --
486   -- Set the validation start and end date OUT arguments
487   --
488   p_validation_start_date := l_validation_start_date;
489   p_validation_end_date   := l_validation_end_date;
490   --
491   hr_utility.set_location(' Leaving:'||l_proc, 10);
492   --
493 End ins_lck;
494 --
495 -- ----------------------------------------------------------------------------
496 -- |---------------------------------< ins >----------------------------------|
497 -- ----------------------------------------------------------------------------
498 Procedure ins
499   (p_effective_date in     date
500   ,p_rec            in out nocopy ben_beo_shd.g_rec_type
501   ) is
502 --
503   l_proc                        varchar2(72) := g_package||'ins';
504   l_datetrack_mode              varchar2(30) := hr_api.g_insert;
505   l_validation_start_date       date;
506   l_validation_end_date         date;
507 --
508 Begin
509   hr_utility.set_location('Entering:'||l_proc, 5);
510   --
511   -- Call the lock operation
512   --
513   ben_beo_ins.ins_lck
514     (p_effective_date        => p_effective_date
515     ,p_datetrack_mode        => l_datetrack_mode
516     ,p_rec                   => p_rec
517     ,p_validation_start_date => l_validation_start_date
518     ,p_validation_end_date   => l_validation_end_date
519     );
520   --
521   -- Call the supporting insert validate operations
522   --
523   ben_beo_bus.insert_validate
524     (p_rec                   => p_rec
525     ,p_effective_date        => p_effective_date
526     ,p_datetrack_mode        => l_datetrack_mode
527     ,p_validation_start_date => l_validation_start_date
528     ,p_validation_end_date   => l_validation_end_date
529     );
530   --
531   -- Call to raise any errors on multi-message list
532   hr_multi_message.end_validation_set;
533   --
534   -- Call the supporting pre-insert operation
535   --
536   ben_beo_ins.pre_insert
537     (p_rec                   => p_rec
538     ,p_effective_date        => p_effective_date
539     ,p_datetrack_mode        => l_datetrack_mode
540     ,p_validation_start_date => l_validation_start_date
541     ,p_validation_end_date   => l_validation_end_date
542     );
543   --
544   -- Insert the row
545   --
546   ben_beo_ins.insert_dml
547     (p_rec                   => p_rec
548     ,p_effective_date        => p_effective_date
549     ,p_datetrack_mode        => l_datetrack_mode
550     ,p_validation_start_date => l_validation_start_date
551     ,p_validation_end_date   => l_validation_end_date
552     );
553   --
554   -- Call the supporting post-insert operation
555   --
556   ben_beo_ins.post_insert
557     (p_rec                   => p_rec
558     ,p_effective_date        => p_effective_date
559     ,p_datetrack_mode        => l_datetrack_mode
560     ,p_validation_start_date => l_validation_start_date
561     ,p_validation_end_date   => l_validation_end_date
562     );
563   --
564   -- Call to raise any errors on multi-message list
565   hr_multi_message.end_validation_set;
566   --
567   hr_utility.set_location('Leaving:'||l_proc,10);
568 end ins;
569 --
570 -- ----------------------------------------------------------------------------
571 -- |---------------------------------< ins >----------------------------------|
572 -- ----------------------------------------------------------------------------
573 Procedure ins
574   (p_effective_date                 in     date
575   ,p_table_name                     in     varchar2
576   ,p_column_name                    in     varchar2
577   ,p_column_value                   in     varchar2
578   ,p_business_group_id              in     number
579   ,p_elig_obj_id                       out nocopy number
580   ,p_object_version_number             out nocopy number
581   ,p_effective_start_date              out nocopy date
582   ,p_effective_end_date                out nocopy date
583   ) is
584 --
585   l_rec         ben_beo_shd.g_rec_type;
586   l_proc        varchar2(72) := g_package||'ins';
587 --
588 Begin
589   hr_utility.set_location('Entering:'||l_proc, 5);
590   --
591   -- Call conversion function to turn arguments into the
592   -- p_rec structure.
593   --
594   l_rec :=
595   ben_beo_shd.convert_args
596     (null
597     ,null
598     ,null
599     ,p_table_name
600     ,p_column_name
601     ,p_column_value
602     ,p_business_group_id
603     ,null
604     );
605   --
606   -- Having converted the arguments into the ben_beo_rec
607   -- plsql record structure we call the corresponding record
608   -- business process.
609   --
610   ben_beo_ins.ins
611     (p_effective_date
612     ,l_rec
613     );
614   --
615   -- Set the OUT arguments.
616   --
617   p_elig_obj_id                      := l_rec.elig_obj_id;
618   p_effective_start_date             := l_rec.effective_start_date;
619   p_effective_end_date               := l_rec.effective_end_date;
620   p_object_version_number            := l_rec.object_version_number;
621   --
622   --
623   hr_utility.set_location(' Leaving:'||l_proc, 10);
624 End ins;
625 --
626 end ben_beo_ins;