DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_ABV_INS

Source


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