DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PEL_INS

Source


1 Package Body pay_pel_ins as
2 /* $Header: pypelrhi.pkb 120.8 2008/02/06 11:17:40 salogana noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_pel_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_element_link_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_element_link_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_pel_ins.g_element_link_id_i := p_element_link_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 pay_pel_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   pay_element_links_f t
92     where  t.element_link_id       = p_rec.element_link_id
93     and    t.effective_start_date =
94              pay_pel_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          pay_element_links_f.created_by%TYPE;
99   l_creation_date       pay_element_links_f.creation_date%TYPE;
100   l_last_update_date    pay_element_links_f.last_update_date%TYPE;
101   l_last_updated_by     pay_element_links_f.last_updated_by%TYPE;
102   l_last_update_login   pay_element_links_f.last_update_login%TYPE;
103 --
104 Begin
105   hr_utility.set_location('Entering:'||l_proc, 5);
106   --
107   -- Get the object version number for the insert
108   --
109   p_rec.object_version_number :=
110     dt_api.get_object_version_number
111       (p_base_table_name => 'pay_element_links_f'
112       ,p_base_key_column => 'element_link_id'
113       ,p_base_key_value  => p_rec.element_link_id
114       );
115   --
116   -- Set the effective start and end dates to the corresponding
117   -- validation start and end dates
118   --
119   p_rec.effective_start_date := p_validation_start_date;
120   p_rec.effective_end_date   := p_validation_end_date;
121   --
122   -- If the datetrack_mode is not INSERT then we must populate the WHO
123   -- columns with the 'old' creation values and 'new' updated values.
124   --
125   If (p_datetrack_mode <> hr_api.g_insert) then
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   End If;
151   --
152   pay_pel_shd.g_api_dml := true;  -- Set the api dml status
153   --
154   -- Insert the row into: pay_element_links_f
155   --
156   insert into pay_element_links_f
157       (element_link_id
158       ,effective_start_date
159       ,effective_end_date
160       ,payroll_id
161       ,job_id
162       ,position_id
163       ,people_group_id
164       ,cost_allocation_keyflex_id
165       ,organization_id
166       ,element_type_id
167       ,location_id
168       ,grade_id
169       ,balancing_keyflex_id
170       ,business_group_id
171       ,element_set_id
172       ,pay_basis_id
173       ,costable_type
174       ,link_to_all_payrolls_flag
175       ,multiply_value_flag
176       ,standard_link_flag
177       ,transfer_to_gl_flag
178       ,comment_id
179       ,employment_category
180       ,qualifying_age
181       ,qualifying_length_of_service
182       ,qualifying_units
183       ,attribute_category
184       ,attribute1
185       ,attribute2
186       ,attribute3
187       ,attribute4
188       ,attribute5
189       ,attribute6
190       ,attribute7
191       ,attribute8
192       ,attribute9
193       ,attribute10
194       ,attribute11
195       ,attribute12
196       ,attribute13
197       ,attribute14
198       ,attribute15
199       ,attribute16
200       ,attribute17
201       ,attribute18
202       ,attribute19
203       ,attribute20
204       ,object_version_number
205       ,created_by
206       ,creation_date
207       ,last_update_date
208       ,last_updated_by
209       ,last_update_login
210       )
211   Values
212     (p_rec.element_link_id
213     ,p_rec.effective_start_date
214     ,p_rec.effective_end_date
215     ,p_rec.payroll_id
216     ,p_rec.job_id
217     ,p_rec.position_id
218     ,p_rec.people_group_id
219     ,p_rec.cost_allocation_keyflex_id
220     ,p_rec.organization_id
221     ,p_rec.element_type_id
222     ,p_rec.location_id
223     ,p_rec.grade_id
224     ,p_rec.balancing_keyflex_id
225     ,p_rec.business_group_id
226     ,p_rec.element_set_id
227     ,p_rec.pay_basis_id
228     ,p_rec.costable_type
229     ,p_rec.link_to_all_payrolls_flag
230     ,p_rec.multiply_value_flag
231     ,p_rec.standard_link_flag
232     ,p_rec.transfer_to_gl_flag
233     ,p_rec.comment_id
234     ,p_rec.employment_category
235     ,p_rec.qualifying_age
236     ,p_rec.qualifying_length_of_service
237     ,p_rec.qualifying_units
238     ,p_rec.attribute_category
239     ,p_rec.attribute1
240     ,p_rec.attribute2
241     ,p_rec.attribute3
242     ,p_rec.attribute4
243     ,p_rec.attribute5
244     ,p_rec.attribute6
245     ,p_rec.attribute7
246     ,p_rec.attribute8
247     ,p_rec.attribute9
248     ,p_rec.attribute10
249     ,p_rec.attribute11
250     ,p_rec.attribute12
251     ,p_rec.attribute13
252     ,p_rec.attribute14
253     ,p_rec.attribute15
254     ,p_rec.attribute16
255     ,p_rec.attribute17
256     ,p_rec.attribute18
257     ,p_rec.attribute19
258     ,p_rec.attribute20
259     ,p_rec.object_version_number
260     ,l_created_by
261     ,l_creation_date
262     ,l_last_update_date
263     ,l_last_updated_by
264     ,l_last_update_login
265     );
266   --
267   pay_pel_shd.g_api_dml := false;   -- Unset the api dml status
268   hr_utility.set_location(' Leaving:'||l_proc, 15);
269 --
270 Exception
271   When hr_api.check_integrity_violated Then
272     -- A check constraint has been violated
273     pay_pel_shd.g_api_dml := false;   -- Unset the api dml status
274     pay_pel_shd.constraint_error
275       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
276   When hr_api.unique_integrity_violated Then
277     -- Unique integrity has been violated
278     pay_pel_shd.g_api_dml := false;   -- Unset the api dml status
279     pay_pel_shd.constraint_error
280       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
281   When Others Then
282     pay_pel_shd.g_api_dml := false;   -- Unset the api dml status
283     Raise;
284 End dt_insert_dml;
285 --
286 -- ----------------------------------------------------------------------------
287 -- |------------------------------< insert_dml >------------------------------|
288 -- ----------------------------------------------------------------------------
289 Procedure insert_dml
290   (p_rec                   in out nocopy pay_pel_shd.g_rec_type
291   ,p_effective_date        in date
292   ,p_datetrack_mode        in varchar2
293   ,p_validation_start_date in date
294   ,p_validation_end_date   in date
295   ) is
296 --
297   l_proc        varchar2(72) := g_package||'insert_dml';
298 --
299 Begin
300   hr_utility.set_location('Entering:'||l_proc, 5);
301   --
302   pay_pel_ins.dt_insert_dml
303     (p_rec                   => p_rec
304     ,p_effective_date        => p_effective_date
305     ,p_datetrack_mode        => p_datetrack_mode
306     ,p_validation_start_date => p_validation_start_date
307     ,p_validation_end_date   => p_validation_end_date
308     );
309   --
310   hr_utility.set_location(' Leaving:'||l_proc, 10);
311 End insert_dml;
312 --
313 -- ----------------------------------------------------------------------------
314 -- |------------------------------< pre_insert >------------------------------|
315 -- ----------------------------------------------------------------------------
316 -- {Start Of Comments}
317 --
318 -- Description:
319 --   This private procedure contains any processing which is required before
320 --   the insert dml. Presently, if the entity has a corresponding primary
321 --   key which is maintained by an associating sequence, the primary key for
322 --   the entity will be populated with the next sequence value in
323 --   preparation for the insert dml.
324 --   Also, if comments are defined for this entity, the comments insert
325 --   logic will also be called, generating a comment_id if required.
326 --
327 -- Prerequisites:
328 --   This is an internal procedure which is called from the ins procedure.
329 --
330 -- In Parameters:
331 --   A Pl/Sql record structure.
332 --
333 -- Post Success:
334 --   Processing continues.
335 --
336 -- Post Failure:
337 --   If an error has occurred, an error message and exception will be raised
338 --   but not handled.
339 --
340 -- Developer Implementation Notes:
341 --   Any pre-processing required before the insert dml is issued should be
342 --   coded within this procedure. As stated above, a good example is the
343 --   generation of a primary key number via a corresponding sequence.
344 --   It is important to note that any 3rd party maintenance should be reviewed
345 --   before placing in this procedure.
346 --
347 -- Access Status:
348 --   Internal Row Handler Use Only.
349 --
350 -- {End Of Comments}
351 -- ----------------------------------------------------------------------------
352 Procedure pre_insert
353   (p_rec                   in out nocopy pay_pel_shd.g_rec_type
354   ,p_effective_date        in date
355   ,p_datetrack_mode        in varchar2
356   ,p_validation_start_date in date
357   ,p_validation_end_date   in date
358   ) is
359 --
360   Cursor C_Sel1 is select pay_element_links_s.nextval from sys.dual;
361 --
362  Cursor C_Sel2 is
363     Select null
364       from pay_element_links_f
365      where element_link_id =
366              pay_pel_ins.g_element_link_id_i;
367 --
368   l_proc        varchar2(72) := g_package||'pre_insert';
369   l_exists      varchar2(1);
370 --
371 Begin
372   hr_utility.set_location('Entering:'||l_proc, 5);
373   --
374     If (pay_pel_ins.g_element_link_id_i is not null) Then
375     --
376     -- Verify registered primary key values not already in use
377     --
378     Open C_Sel2;
379     Fetch C_Sel2 into l_exists;
380     If C_Sel2%found Then
381        Close C_Sel2;
382        --
383        -- The primary key values are already in use.
384        --
385        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
386        fnd_message.set_token('TABLE_NAME','pay_element_links_f');
387        fnd_message.raise_error;
388     End If;
389     Close C_Sel2;
390     --
391     -- Use registered key values and clear globals
392     --
393     p_rec.element_link_id :=
394       pay_pel_ins.g_element_link_id_i;
395     pay_pel_ins.g_element_link_id_i := null;
396   Else
397     --
398     -- No registerd key values, so select the next sequence number
399     --
400     --
401     -- Select the next sequence number
402     --
403     Open C_Sel1;
404     Fetch C_Sel1 Into p_rec.element_link_id;
405     Close C_Sel1;
406   End If;
407   --
408   --
409   -- Insert the comment text if comments exist
410   --
411   If (p_rec.comments is not null) then
412     hr_comm_api.ins
413       (p_comment_id        => p_rec.comment_id
414       ,p_source_table_name => 'PAY_ELEMENT_LINKS_F'
415       ,p_comment_text      => p_rec.comments
416       );
417   End If;
418   hr_utility.set_location(' Leaving:'||l_proc, 10);
419 End pre_insert;
420 --
421 -- ----------------------------------------------------------------------------
422 -- |----------------------------< post_insert >-------------------------------|
423 -- ----------------------------------------------------------------------------
424 -- {Start Of Comments}
425 --
426 -- Description:
427 --   This private procedure contains any processing which is required after
428 --   the insert dml.
429 --
430 -- Prerequisites:
431 --   This is an internal procedure which is called from the ins procedure.
432 --
433 -- In Parameters:
434 --   A Pl/Sql record structure.
435 --
436 -- Post Success:
437 --   Processing continues.
438 --
439 -- Post Failure:
440 --   If an error has occurred, an error message and exception will be raised
441 --   but not handled.
442 --
443 -- Developer Implementation Notes:
444 --   Any post-processing required after the insert dml is issued should be
445 --   coded within this procedure. It is important to note that any 3rd party
446 --   maintenance should be reviewed before placing in this procedure.
447 --
448 -- Access Status:
449 --   Internal Row Handler Use Only.
450 --
451 -- {End Of Comments}
452 -- ----------------------------------------------------------------------------
453 Procedure post_insert
454   (p_rec                   in pay_pel_shd.g_rec_type
455   ,p_effective_date        in date
456   ,p_datetrack_mode        in varchar2
457   ,p_validation_start_date in date
458   ,p_validation_end_date   in date
459   ) is
460 --
461   l_proc        varchar2(72) := g_package||'post_insert';
462 --
463 Begin
464   hr_utility.set_location('Entering:'||l_proc, 5);
465   begin
466     --
467     pay_pel_rki.after_insert
468       (p_effective_date
469       => p_effective_date
470       ,p_validation_start_date
471       => p_validation_start_date
472       ,p_validation_end_date
473       => p_validation_end_date
474       ,p_element_link_id
475       => p_rec.element_link_id
476       ,p_effective_start_date
477       => p_rec.effective_start_date
478       ,p_effective_end_date
479       => p_rec.effective_end_date
480       ,p_payroll_id
481       => p_rec.payroll_id
482       ,p_job_id
483       => p_rec.job_id
484       ,p_position_id
485       => p_rec.position_id
486       ,p_people_group_id
487       => p_rec.people_group_id
488       ,p_cost_allocation_keyflex_id
489       => p_rec.cost_allocation_keyflex_id
490       ,p_organization_id
491       => p_rec.organization_id
492       ,p_element_type_id
493       => p_rec.element_type_id
494       ,p_location_id
495       => p_rec.location_id
496       ,p_grade_id
497       => p_rec.grade_id
498       ,p_balancing_keyflex_id
499       => p_rec.balancing_keyflex_id
500       ,p_business_group_id
501       => p_rec.business_group_id
502       ,p_element_set_id
503       => p_rec.element_set_id
504       ,p_pay_basis_id
505       => p_rec.pay_basis_id
506       ,p_costable_type
507       => p_rec.costable_type
508       ,p_link_to_all_payrolls_flag
509       => p_rec.link_to_all_payrolls_flag
510       ,p_multiply_value_flag
511       => p_rec.multiply_value_flag
512       ,p_standard_link_flag
513       => p_rec.standard_link_flag
514       ,p_transfer_to_gl_flag
515       => p_rec.transfer_to_gl_flag
516       ,p_comment_id
517       => p_rec.comment_id
518       ,p_comments
519       => p_rec.comments
520       ,p_employment_category
521       => p_rec.employment_category
522       ,p_qualifying_age
523       => p_rec.qualifying_age
524       ,p_qualifying_length_of_service
525       => p_rec.qualifying_length_of_service
526       ,p_qualifying_units
527       => p_rec.qualifying_units
528       ,p_attribute_category
529       => p_rec.attribute_category
530       ,p_attribute1
531       => p_rec.attribute1
532       ,p_attribute2
533       => p_rec.attribute2
534       ,p_attribute3
535       => p_rec.attribute3
536       ,p_attribute4
537       => p_rec.attribute4
538       ,p_attribute5
539       => p_rec.attribute5
540       ,p_attribute6
541       => p_rec.attribute6
542       ,p_attribute7
543       => p_rec.attribute7
544       ,p_attribute8
545       => p_rec.attribute8
546       ,p_attribute9
547       => p_rec.attribute9
548       ,p_attribute10
549       => p_rec.attribute10
550       ,p_attribute11
551       => p_rec.attribute11
552       ,p_attribute12
553       => p_rec.attribute12
554       ,p_attribute13
555       => p_rec.attribute13
556       ,p_attribute14
557       => p_rec.attribute14
558       ,p_attribute15
559       => p_rec.attribute15
560       ,p_attribute16
561       => p_rec.attribute16
562       ,p_attribute17
563       => p_rec.attribute17
564       ,p_attribute18
565       => p_rec.attribute18
566       ,p_attribute19
567       => p_rec.attribute19
568       ,p_attribute20
569       => p_rec.attribute20
570       ,p_object_version_number
571       => p_rec.object_version_number
572       );
573     --
574   exception
575     --
576     when hr_api.cannot_find_prog_unit then
577       --
578       hr_api.cannot_find_prog_unit_error
579         (p_module_name => 'PAY_ELEMENT_LINKS_F'
580         ,p_hook_type   => 'AI');
581       --
582   end;
583   --
584   hr_utility.set_location(' Leaving:'||l_proc, 10);
585 End post_insert;
586 --
587 -- ----------------------------------------------------------------------------
588 -- |-------------------------------< ins_lck >--------------------------------|
589 -- ----------------------------------------------------------------------------
590 -- {Start Of Comments}
591 --
592 -- Description:
593 --   The ins_lck process has one main function to perform. When inserting
594 --   a datetracked row, we must validate the DT mode.
595 --
596 -- Prerequisites:
597 --   This procedure can only be called for the datetrack mode of INSERT.
598 --
599 -- In Parameters:
600 --
601 -- Post Success:
602 --   On successful completion of the ins_lck process the parental
603 --   datetracked rows will be locked providing the p_enforce_foreign_locking
604 --   argument value is TRUE.
605 --   If the p_enforce_foreign_locking argument value is FALSE then the
606 --   parential rows are not locked.
607 --
608 -- Post Failure:
609 --   The Lck process can fail for:
610 --   1) When attempting to lock the row the row could already be locked by
611 --      another user. This will raise the HR_Api.Object_Locked exception.
612 --   2) When attempting to the lock the parent which doesn't exist.
613 --      For the entity to be locked the parent must exist!
614 --
615 -- Developer Implementation Notes:
616 --   None.
617 --
618 -- Access Status:
619 --   Internal Row Handler Use Only.
620 --
621 -- {End Of Comments}
622 -- ----------------------------------------------------------------------------
623 Procedure ins_lck
624   (p_effective_date        in date
625   ,p_datetrack_mode        in varchar2
626   ,p_rec                   in pay_pel_shd.g_rec_type
627   ,p_validation_start_date out nocopy date
628   ,p_validation_end_date   out nocopy date
629   ) is
630 --
631   l_proc                  varchar2(72) := g_package||'ins_lck';
632   l_validation_start_date date;
633   l_validation_end_date   date;
634 --
635 Begin
636   hr_utility.set_location('Entering:'||l_proc, 5);
637   --
638   -- Validate the datetrack mode mode getting the validation start
639   -- and end dates for the specified datetrack operation.
640   --
641   dt_api.validate_dt_mode
642     (p_effective_date          => p_effective_date
643     ,p_datetrack_mode          => p_datetrack_mode
644     ,p_base_table_name         => 'pay_element_links_f'
645     ,p_base_key_column         => 'element_link_id'
646     ,p_base_key_value          => p_rec.element_link_id
647     ,p_parent_table_name1      => 'pay_all_payrolls_f'
648     ,p_parent_key_column1      => 'payroll_id'
649     ,p_parent_key_value1       => p_rec.payroll_id
650     ,p_parent_table_name2      => 'pay_element_types_f'
651     ,p_parent_key_column2      => 'element_type_id'
652     ,p_parent_key_value2       => p_rec.element_type_id
653     ,p_enforce_foreign_locking => true
654     ,p_validation_start_date   => l_validation_start_date
655     ,p_validation_end_date     => l_validation_end_date
656     );
657   --
658   -- Set the validation start and end date OUT arguments
659   --
660   p_validation_start_date := l_validation_start_date;
661   p_validation_end_date   := l_validation_end_date;
662   --
663   hr_utility.set_location(' Leaving:'||l_proc, 10);
664   --
665 End ins_lck;
666 --
667 -- ----------------------------------------------------------------------------
668 -- |---------------------------------< ins >----------------------------------|
669 -- ----------------------------------------------------------------------------
670 Procedure ins
671   (p_effective_date in     date
672   ,p_rec            in out nocopy pay_pel_shd.g_rec_type
673   ) is
674 --
675   l_proc                        varchar2(72) := g_package||'ins';
676   l_datetrack_mode              varchar2(30) := hr_api.g_insert;
677   l_validation_start_date       date;
678   l_validation_end_date         date;
679 --
680 Begin
681   hr_utility.set_location('Entering:'||l_proc, 5);
682   --
683   -- Call the lock operation
684   --
685   pay_pel_ins.ins_lck
686     (p_effective_date        => p_effective_date
687     ,p_datetrack_mode        => l_datetrack_mode
688     ,p_rec                   => p_rec
689     ,p_validation_start_date => l_validation_start_date
690     ,p_validation_end_date   => l_validation_end_date
691     );
692 
693 
694   -- The end date is set by the following procedure.
695   -- Called here in order to overide the date setting by the lck procedure
696 
697   -- Bug 4138645. Changed the value passed to the p_effective_start_date
698   -- parameter in the call to chk_end_date from p_rec.effective_start_date
699   -- to l_validation_start_date. This is because p_rec.effective_start_date
700   -- will be set to null at this point.
701 
702   pay_pel_bus.chk_end_date
703   (p_rec.element_type_id ,
704    null ,
705    l_validation_start_date,
706    l_validation_end_date ,
707    p_rec.organization_id ,
708    p_rec.people_group_id ,
709    p_rec.job_id ,
710    p_rec.position_id ,
711    p_rec.grade_id ,
712    p_rec.location_id ,
713    p_rec.link_to_all_payrolls_flag ,
714    p_rec.payroll_id ,
715    p_rec.employment_category ,
716    p_rec.pay_basis_id ,
717    p_rec.business_group_id
718   );
719   --
720   -- Call the supporting insert validate operations
721   --
722   pay_pel_bus.insert_validate
723     (p_rec                   => p_rec
724     ,p_effective_date        => p_effective_date
725     ,p_datetrack_mode        => l_datetrack_mode
726     ,p_validation_start_date => l_validation_start_date
727     ,p_validation_end_date   => l_validation_end_date
728     );
729 
730   --
731   -- Bug 6010954. We cannot populate the location during the process as this
732   -- does not allow the user to set null to location, hence commented out
733   -- the following. The organization unit validation has been moved to
734   -- insert_validate.
735   --
736   -- validation for organization outside insert validate to default
737   -- location id in p_rec
738   -- if p_rec.organization_id is not null then
739   --    pay_pel_bus.chk_org_unit
740   --    (p_business_group_id  =>	p_rec.business_group_id
741   --    ,p_organization_id 	  =>    p_rec.organization_id
742   --    ,p_effective_date     =>    p_effective_date
743   --    ,p_location_id        =>    p_rec.location_id
744   --    );
745   --  end if;
746 
747   --
748   -- Call to raise any errors on multi-message list
749   hr_multi_message.end_validation_set;
750   --
751   -- Call the supporting pre-insert operation
752   --
753   pay_pel_ins.pre_insert
754     (p_rec                   => p_rec
755     ,p_effective_date        => p_effective_date
756     ,p_datetrack_mode        => l_datetrack_mode
757     ,p_validation_start_date => l_validation_start_date
758     ,p_validation_end_date   => l_validation_end_date
759     );
760   --
761   -- Insert the row
762   --
763   if p_rec.costable_type = 'D' then
764     p_rec.transfer_to_gl_flag := 'Y';
765   elsif p_rec.costable_type in ('N','F') then
766     p_rec.transfer_to_gl_flag := nvl(p_rec.transfer_to_gl_flag,'Y');
767   end if;
768 
769   pay_pel_ins.insert_dml
770     (p_rec                   => p_rec
771     ,p_effective_date        => p_effective_date
772     ,p_datetrack_mode        => l_datetrack_mode
773     ,p_validation_start_date => l_validation_start_date
774     ,p_validation_end_date   => l_validation_end_date
775     );
776   --
777   -- Call the supporting post-insert operation
778   --
779   pay_pel_ins.post_insert
780     (p_rec                   => p_rec
781     ,p_effective_date        => p_effective_date
782     ,p_datetrack_mode        => l_datetrack_mode
783     ,p_validation_start_date => l_validation_start_date
784     ,p_validation_end_date   => l_validation_end_date
785     );
786   --
787   -- Call to raise any errors on multi-message list
788   hr_multi_message.end_validation_set;
789   --
790   hr_utility.set_location('Leaving:'||l_proc,10);
791 end ins;
792 --
793 -- ----------------------------------------------------------------------------
794 -- |---------------------------------< ins >----------------------------------|
795 -- ----------------------------------------------------------------------------
796 Procedure ins
797   (p_effective_date                in     date
798   ,p_element_type_id               in     number
799   ,p_business_group_id             in     number
800   ,p_costable_type                 in     varchar2
801   ,p_link_to_all_payrolls_flag     in     varchar2
802   ,p_multiply_value_flag           in     varchar2
803   ,p_standard_link_flag            in     varchar2
804   ,p_transfer_to_gl_flag           in     varchar2
805   ,p_payroll_id                    in     number   default null
806   ,p_job_id                        in     number   default null
807   ,p_position_id                   in     number   default null
808   ,p_people_group_id               in     number   default null
809   ,p_cost_allocation_keyflex_id    in     number   default null
810   ,p_organization_id               in     number   default null
811   ,p_location_id                   in     number   default null
812   ,p_grade_id                      in     number   default null
813   ,p_balancing_keyflex_id          in     number   default null
814   ,p_element_set_id                in     number   default null
815   ,p_pay_basis_id                  in     number   default null
816   ,p_comments                      in     varchar2 default null
817   ,p_employment_category           in     varchar2 default null
818   ,p_qualifying_age                in     number   default null
819   ,p_qualifying_length_of_service  in     number   default null
820   ,p_qualifying_units              in     varchar2 default null
821   ,p_attribute_category            in     varchar2 default null
822   ,p_attribute1                    in     varchar2 default null
823   ,p_attribute2                    in     varchar2 default null
824   ,p_attribute3                    in     varchar2 default null
825   ,p_attribute4                    in     varchar2 default null
826   ,p_attribute5                    in     varchar2 default null
827   ,p_attribute6                    in     varchar2 default null
828   ,p_attribute7                    in     varchar2 default null
829   ,p_attribute8                    in     varchar2 default null
830   ,p_attribute9                    in     varchar2 default null
831   ,p_attribute10                   in     varchar2 default null
832   ,p_attribute11                   in     varchar2 default null
833   ,p_attribute12                   in     varchar2 default null
834   ,p_attribute13                   in     varchar2 default null
835   ,p_attribute14                   in     varchar2 default null
836   ,p_attribute15                   in     varchar2 default null
837   ,p_attribute16                   in     varchar2 default null
838   ,p_attribute17                   in     varchar2 default null
839   ,p_attribute18                   in     varchar2 default null
840   ,p_attribute19                   in     varchar2 default null
841   ,p_attribute20                   in     varchar2 default null
842   ,p_element_link_id                  out nocopy number
843   ,p_object_version_number            out nocopy number
844   ,p_effective_start_date             out nocopy date
845   ,p_effective_end_date               out nocopy date
846   ,p_comment_id			      out nocopy number
847   ) is
848 --
849   l_rec         pay_pel_shd.g_rec_type;
850   l_proc        varchar2(72) := g_package||'ins';
851 --
852 Begin
853   hr_utility.set_location('Entering:'||l_proc, 5);
854   --
855   -- Call conversion function to turn arguments into the
856   -- p_rec structure.
857   --
858   l_rec :=
859   pay_pel_shd.convert_args
860     (null
861     ,null
862     ,null
863     ,p_payroll_id
864     ,p_job_id
865     ,p_position_id
866     ,p_people_group_id
867     ,p_cost_allocation_keyflex_id
868     ,p_organization_id
869     ,p_element_type_id
870     ,p_location_id
871     ,p_grade_id
872     ,p_balancing_keyflex_id
873     ,p_business_group_id
874     ,p_element_set_id
875     ,p_pay_basis_id
876     ,p_costable_type
877     ,p_link_to_all_payrolls_flag
878     ,p_multiply_value_flag
879     ,p_standard_link_flag
880     ,p_transfer_to_gl_flag
881     ,null
882     ,p_comment_id
883     ,p_employment_category
884     ,p_qualifying_age
885     ,p_qualifying_length_of_service
886     ,p_qualifying_units
887     ,p_attribute_category
888     ,p_attribute1
889     ,p_attribute2
890     ,p_attribute3
891     ,p_attribute4
892     ,p_attribute5
893     ,p_attribute6
894     ,p_attribute7
895     ,p_attribute8
896     ,p_attribute9
897     ,p_attribute10
898     ,p_attribute11
899     ,p_attribute12
900     ,p_attribute13
901     ,p_attribute14
902     ,p_attribute15
903     ,p_attribute16
904     ,p_attribute17
905     ,p_attribute18
906     ,p_attribute19
907     ,p_attribute20
908     ,null
909     );
910   --
911   -- Having converted the arguments into the pay_pel_rec
912   -- plsql record structure we call the corresponding record
913   -- business process.
914   --
915   pay_pel_ins.ins
916     (p_effective_date
917     ,l_rec
918     );
919   --
920   -- Set the OUT arguments.
921   --
922   p_element_link_id                  := l_rec.element_link_id;
923   p_effective_start_date             := l_rec.effective_start_date;
924   p_effective_end_date               := l_rec.effective_end_date;
925   p_object_version_number            := l_rec.object_version_number;
926   p_comment_id                       := l_rec.comment_id;
927   --
928   hr_utility.set_location(' Leaving:'||l_proc, 10);
929 End ins;
930 --
931 end pay_pel_ins;