DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PAY_INS

Source


1 Package Body pay_pay_ins as
2 /* $Header: pypayrhi.pkb 120.0.12000000.3 2007/03/08 09:23:27 mshingan noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_pay_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_payroll_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_payroll_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_pay_ins.g_payroll_id_i := p_payroll_id;
27   --
28   hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 -- ----------------------------------------------------------------------------
32 -- |------------------------< get_comment_id >-------------------------------|
33 -- ----------------------------------------------------------------------------
34 -- {Start Of Comments}
35 --
36 -- Description:
37 --	This function is used to get new comment-id for inserting the comments.
38 --
39 -- Prerequisites:
40 --	This is an internal private function which must be called from the
41 --	pre_insert and pre_update procedure and must have
42 --	all mandatory arguments set.This procedure must be called when the
43 --	comments are not null.
44 --
45 -- In Parameters:
46 --	None.
47 --
48 -- Post Success:
49 --   Returns the new comment id.
50 
51 -- Post Failure:
52 --	None.
53 --
54 --Developer Implementation Notes:
55 --   This is an internal call.
56 --
57 -- Access Status:
58 --   Internal Row Handler Use Only.
59 
60 function get_comment_id return number is
61    l_comment_id number;
62 begin
63    select hr_comments_s.nextval
64    into   l_comment_id
65    from   sys.dual;
66    return(l_comment_id);
67 end get_comment_id;
68 
69 --
70 -- ----------------------------------------------------------------------------
71 -- |----------------------------< dt_insert_dml >-----------------------------|
72 -- ----------------------------------------------------------------------------
73 -- {Start Of Comments}
74 --
75 -- Description:
76 --   This procedure controls the actual dml insert logic for datetrack. The
77 --   functions of this procedure are as follows:
78 --   1) Get the object_version_number.
79 --   2) To set the effective start and end dates to the corresponding
80 --      validation start and end dates. Also, the object version number
81 --      record attribute is set.
82 --   3) To set and unset the g_api_dml status as required (as we are about to
83 --      perform dml).
84 --   4) To insert the row into the schema with the derived effective start
85 --      and end dates and the object version number.
86 --   5) To trap any constraint violations that may have occurred.
87 --   6) To raise any other errors.
88 --
89 -- Prerequisites:
90 --   This is an internal private procedure which must be called from the
91 --   insert_dml and pre_update (logic permitting) procedure and must have
92 --   all mandatory arguments set.
93 --
94 -- In Parameters:
95 --   A Pl/Sql record structure.
96 --
97 -- Post Success:
98 --   The specified row will be inserted into the schema.
99 --
100 -- Post Failure:
101 --   On the insert dml failure it is important to note that we always reset the
102 --   g_api_dml status to false.
103 --   If a check or unique integrity constraint violation is raised the
104 --   constraint_error procedure will be called.
105 --   If any other error is reported, the error will be raised after the
106 --   g_api_dml status is reset.
107 --
108 -- Developer Implementation Notes:
109 --   This is an internal datetrack maintenance procedure which should
110 --   not be modified in anyway.
111 --
112 -- Access Status:
113 --   Internal Row Handler Use Only.
114 --
115 -- {End Of Comments}
116 -- ----------------------------------------------------------------------------
117 Procedure dt_insert_dml
118   (p_rec                     in out nocopy pay_pay_shd.g_rec_type
119   ,p_effective_date          in date
120   ,p_datetrack_mode          in varchar2
121   ,p_validation_start_date   in date
122   ,p_validation_end_date     in date
123   ) is
124 -- Cursor to select 'old' created AOL who column values
125 --
126   Cursor C_Sel1 Is
127     select t.created_by,
128            t.creation_date
129     from   pay_all_payrolls_f t
130     where  t.payroll_id       = p_rec.payroll_id
131     and    t.effective_start_date =
132              pay_pay_shd.g_old_rec.effective_start_date
133     and    t.effective_end_date   = (p_validation_start_date - 1);
134 --
135   l_proc                varchar2(72) := g_package||'dt_insert_dml';
136   l_created_by          pay_all_payrolls_f.created_by%TYPE;
137   l_creation_date       pay_all_payrolls_f.creation_date%TYPE ;
138   l_last_update_date    pay_all_payrolls_f.last_update_date%TYPE := sysdate;
139   l_last_updated_by     pay_all_payrolls_f.last_updated_by%TYPE := fnd_global.user_id;
140   l_last_update_login   pay_all_payrolls_f.last_update_login%TYPE := fnd_global.login_id;
141 
142   l_effective_start_date    date;
143   l_effective_end_date      date;
144   c_eot constant date := to_date('4712/12/31','YYYY/MM/DD');
145   l_org_pay_method_usage_id  number(16);
146   l_status_of_dml boolean;
147 --
148 Begin
149   hr_utility.set_location('Entering:'||l_proc, 5);
150   --
151   -- Set the effective start and end dates to the corresponding
152   -- validation start and end dates
153   --
154   p_rec.effective_start_date := p_validation_start_date;
155   p_rec.effective_end_date   := p_validation_end_date;
156 
157   l_created_by := l_last_updated_by;
158   l_creation_date := l_last_update_date;
159   --
160   -- If the datetrack_mode is not INSERT then we must populate the WHO
161   -- columns with the 'old' creation values and 'new' updated values.
162   --
163   If (p_datetrack_mode <> hr_api.g_insert) then
164     --
165     hr_utility.set_location(l_proc, 10);
166     --
167     -- Get the object version number for the insert
168     --
169     p_rec.object_version_number :=
170     dt_api.get_object_version_number
171       (p_base_table_name => 'pay_all_payrolls_f'
172       ,p_base_key_column => 'payroll_id'
173       ,p_base_key_value  => p_rec.payroll_id
174       );
175     --
176     -- Select the 'old' created values
177     --
178     Open C_Sel1;
179     Fetch C_Sel1 Into l_created_by, l_creation_date;
180     If C_Sel1%notfound Then
181       --
182       -- The previous 'old' created row has not been found. We need
183       -- to error as an internal datetrack problem exists.
184       --
185       Close C_Sel1;
186       fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
187       fnd_message.set_token('PROCEDURE', l_proc);
188       fnd_message.set_token('STEP','10');
189       fnd_message.raise_error;
190       --
191     End If;
192     Close C_Sel1;
193     --
194     -- Set the AOL updated WHO values
195     --
196     l_last_update_date   := sysdate;
197     l_last_updated_by    := fnd_global.user_id;
198     l_last_update_login  := fnd_global.login_id;
199   Else
200     --
201     p_rec.object_version_number := 1;  -- Initialise the object version
202     --
203   End If;
204   --
205   pay_pay_shd.g_api_dml := true;  -- Set the api dml status
206   --
207   -- Insert the row into: pay_all_payrolls_f
208   --
209   insert into pay_all_payrolls_f
210       (payroll_id
211       ,effective_start_date
212       ,effective_end_date
213       ,default_payment_method_id
214       ,business_group_id
215       ,consolidation_set_id
216       ,cost_allocation_keyflex_id
217       ,suspense_account_keyflex_id
218       ,gl_set_of_books_id
219       ,soft_coding_keyflex_id
220       ,period_type
221       ,organization_id
222       ,cut_off_date_offset
223       ,direct_deposit_date_offset
224       ,first_period_end_date
225       ,negative_pay_allowed_flag
226       ,number_of_years
227       ,pay_advice_date_offset
228       ,pay_date_offset
229       ,payroll_name
230       ,workload_shifting_level
231       ,comment_id
232       ,midpoint_offset
233       ,attribute_category
234       ,attribute1
235       ,attribute2
236       ,attribute3
237       ,attribute4
238       ,attribute5
239       ,attribute6
240       ,attribute7
241       ,attribute8
242       ,attribute9
243       ,attribute10
244       ,attribute11
245       ,attribute12
246       ,attribute13
247       ,attribute14
248       ,attribute15
249       ,attribute16
250       ,attribute17
251       ,attribute18
252       ,attribute19
253       ,attribute20
254       ,arrears_flag
255       ,payroll_type
256       ,prl_information_category
257       ,prl_information1
258       ,prl_information2
259       ,prl_information3
260       ,prl_information4
261       ,prl_information5
262       ,prl_information6
263       ,prl_information7
264       ,prl_information8
265       ,prl_information9
266       ,prl_information10
267       ,prl_information11
268       ,prl_information12
269       ,prl_information13
270       ,prl_information14
271       ,prl_information15
272       ,prl_information16
273       ,prl_information17
274       ,prl_information18
275       ,prl_information19
276       ,prl_information20
277       ,prl_information21
278       ,prl_information22
279       ,prl_information23
280       ,prl_information24
281       ,prl_information25
282       ,prl_information26
283       ,prl_information27
284       ,prl_information28
285       ,prl_information29
286       ,prl_information30
287       ,multi_assignments_flag
288       ,period_reset_years
289       ,object_version_number
290       ,payslip_view_date_offset
291       ,created_by
292       ,creation_date
293       ,last_update_date
294       ,last_updated_by
295       ,last_update_login
296       )
297   Values
298     (p_rec.payroll_id
299     ,p_rec.effective_start_date
300     ,p_rec.effective_end_date
301     ,p_rec.default_payment_method_id
302     ,p_rec.business_group_id
303     ,p_rec.consolidation_set_id
304     ,p_rec.cost_allocation_keyflex_id
305     ,p_rec.suspense_account_keyflex_id
306     ,p_rec.gl_set_of_books_id
307     ,p_rec.soft_coding_keyflex_id
308     ,p_rec.period_type
309     ,p_rec.organization_id
310     ,p_rec.cut_off_date_offset
311     ,p_rec.direct_deposit_date_offset
312     ,p_rec.first_period_end_date
313     ,p_rec.negative_pay_allowed_flag
314     ,p_rec.number_of_years
315     ,p_rec.pay_advice_date_offset
316     ,p_rec.pay_date_offset
317     ,p_rec.payroll_name
318     ,p_rec.workload_shifting_level
319     ,p_rec.comment_id
320     ,p_rec.midpoint_offset
321     ,p_rec.attribute_category
322     ,p_rec.attribute1
323     ,p_rec.attribute2
324     ,p_rec.attribute3
325     ,p_rec.attribute4
326     ,p_rec.attribute5
327     ,p_rec.attribute6
328     ,p_rec.attribute7
329     ,p_rec.attribute8
330     ,p_rec.attribute9
331     ,p_rec.attribute10
332     ,p_rec.attribute11
333     ,p_rec.attribute12
334     ,p_rec.attribute13
335     ,p_rec.attribute14
336     ,p_rec.attribute15
337     ,p_rec.attribute16
338     ,p_rec.attribute17
339     ,p_rec.attribute18
340     ,p_rec.attribute19
341     ,p_rec.attribute20
342     ,p_rec.arrears_flag
343     ,p_rec.payroll_type
344     ,p_rec.prl_information_category
345     ,p_rec.prl_information1
346     ,p_rec.prl_information2
347     ,p_rec.prl_information3
348     ,p_rec.prl_information4
349     ,p_rec.prl_information5
350     ,p_rec.prl_information6
351     ,p_rec.prl_information7
352     ,p_rec.prl_information8
353     ,p_rec.prl_information9
354     ,p_rec.prl_information10
355     ,p_rec.prl_information11
356     ,p_rec.prl_information12
357     ,p_rec.prl_information13
358     ,p_rec.prl_information14
359     ,p_rec.prl_information15
360     ,p_rec.prl_information16
361     ,p_rec.prl_information17
362     ,p_rec.prl_information18
363     ,p_rec.prl_information19
364     ,p_rec.prl_information20
365     ,p_rec.prl_information21
366     ,p_rec.prl_information22
367     ,p_rec.prl_information23
368     ,p_rec.prl_information24
369     ,p_rec.prl_information25
370     ,p_rec.prl_information26
371     ,p_rec.prl_information27
372     ,p_rec.prl_information28
373     ,p_rec.prl_information29
374     ,p_rec.prl_information30
375     ,p_rec.multi_assignments_flag
376     ,p_rec.period_reset_years
377     ,p_rec.object_version_number
378     ,p_rec.payslip_view_date_offset
379     ,l_created_by
380     ,l_creation_date
381     ,l_last_update_date
382     ,l_last_updated_by
383     ,l_last_update_login
384     );
385   --
386   --Storing the result of the above DML operation.
387   l_status_of_dml:=SQL%NOTFOUND;
388 
389   pay_pay_shd.g_api_dml := false;   -- Unset the api dml status
390 
391   --Checking the status of the above dml operation.
392   if (l_status_of_dml) then
393       --
394       hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
395       hr_utility.set_message_token('PROCEDURE',
396                                  'pay_payrolls_f_pkg.insert_row');
397       hr_utility.set_message_token('STEP','1');
398       hr_utility.raise_error;
399       --
400     End if;
401     --
402   hr_utility.set_location(' Leaving:'||l_proc, 25);
403 --
404 Exception
405   When hr_api.check_integrity_violated Then
406     -- A check constraint has been violated
407     pay_pay_shd.g_api_dml := false;   -- Unset the api dml status
408     pay_pay_shd.constraint_error
409       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
410   When hr_api.unique_integrity_violated Then
411     -- Unique integrity has been violated
412     pay_pay_shd.g_api_dml := false;   -- Unset the api dml status
413     pay_pay_shd.constraint_error
414       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
415   When Others Then
416     pay_pay_shd.g_api_dml := false;   -- Unset the api dml status
417     Raise;
418 End dt_insert_dml;
419 --
420 -- ----------------------------------------------------------------------------
421 -- |------------------------------< insert_dml >------------------------------|
422 -- ----------------------------------------------------------------------------
423 Procedure insert_dml
424   (p_rec                   in out nocopy pay_pay_shd.g_rec_type
425   ,p_effective_date        in date
426   ,p_datetrack_mode        in varchar2
427   ,p_validation_start_date in date
428   ,p_validation_end_date   in date
429   ) is
430 --
431   l_proc        varchar2(72) := g_package||'insert_dml';
432 --
433 Begin
434   hr_utility.set_location('Entering:'||l_proc, 5);
435   --
436   pay_pay_ins.dt_insert_dml
437     (p_rec                   => p_rec
438     ,p_effective_date        => p_effective_date
439     ,p_datetrack_mode        => p_datetrack_mode
440     ,p_validation_start_date => p_validation_start_date
441     ,p_validation_end_date   => p_validation_end_date
442     );
443   --
444   hr_utility.set_location(' Leaving:'||l_proc, 10);
445 End insert_dml;
446 --
447 -- ----------------------------------------------------------------------------
448 -- |------------------------------< pre_insert >------------------------------|
449 -- ----------------------------------------------------------------------------
450 -- {Start Of Comments}
451 --
452 -- Description:
453 --   This private procedure contains any processing which is required before
454 --   the insert dml. Presently, if the entity has a corresponding primary
455 --   key which is maintained by an associating sequence, the primary key for
456 --   the entity will be populated with the next sequence value in
457 --   preparation for the insert dml.
458 --   Also, if comments are defined for this entity, the comments insert
459 --   logic will also be called, generating a comment_id if required.
460 --
461 -- Prerequisites:
462 --   This is an internal procedure which is called from the ins procedure.
463 --
464 -- In Parameters:
465 --   A Pl/Sql record structure.
466 --
467 -- Post Success:
468 --   Processing continues.
469 --
470 -- Post Failure:
471 --   If an error has occurred, an error message and exception will be raised
472 --   but not handled.
473 --
474 -- Developer Implementation Notes:
475 --   Any pre-processing required before the insert dml is issued should be
476 --   coded within this procedure. As stated above, a good example is the
477 --   generation of a primary key number via a corresponding sequence.
478 --   It is important to note that any 3rd party maintenance should be reviewed
479 --   before placing in this procedure.
480 --
481 -- Access Status:
482 --   Internal Row Handler Use Only.
483 --
484 -- {End Of Comments}
485 -- ----------------------------------------------------------------------------
486 Procedure pre_insert
487   (p_rec                   in out nocopy pay_pay_shd.g_rec_type
488   ,p_effective_date        in date
489   ,p_datetrack_mode        in varchar2
490   ,p_validation_start_date in date
491   ,p_validation_end_date   in date
492   ) is
493 --
494   Cursor C_Sel1 is select pay_payrolls_s.nextval from sys.dual;
495 --
496  Cursor C_Sel2 is
497     Select null
498       from pay_all_payrolls_f
499      where payroll_id =
500              pay_pay_ins.g_payroll_id_i;
501 --
502   l_proc        varchar2(72) := g_package||'pre_insert';
503   l_exists      varchar2(1);
504 --
505 Begin
506   hr_utility.set_location('Entering:'||l_proc, 5);
507   --
508     If (pay_pay_ins.g_payroll_id_i is not null) Then
509     --
510     -- Verify registered primary key values not already in use
511     --
512     Open C_Sel2;
513     Fetch C_Sel2 into l_exists;
514     If C_Sel2%found Then
515        --
516        Close C_Sel2;
517        --
518        -- The primary key values are already in use.
519        --
520        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
521        fnd_message.set_token('TABLE_NAME','pay_all_payrolls_f');
522        fnd_message.raise_error;
523        --
524     End If;
525     Close C_Sel2;
526     --
527     -- Use registered key values and clear globals
528     --
529     p_rec.payroll_id := pay_pay_ins.g_payroll_id_i;
530     pay_pay_ins.g_payroll_id_i := null;
531   Else
532     --
533     -- No registerd key values, so select the next sequence number
534     --
535     -- Select the next sequence number
536     --
537     Open C_Sel1;
538     Fetch C_Sel1 Into p_rec.payroll_id;
539     Close C_Sel1;
540     --
541   End If;
542   --
543 
544   -- Insert the comment text if comments exist.
545   --
546   If (p_rec.comments is not null) then
547     --
548     p_rec.comment_id :=get_comment_id();
549     hr_comm_api.ins
550       (p_comment_id        => p_rec.comment_id
551       ,p_source_table_name => 'PAY_ALL_PAYROLLS_F'
552       ,p_comment_text      => p_rec.comments
553       );
554     --
555   End If;
556 
557   -- Default the Midpoint Offset
558 
559    If (p_rec.period_type = 'Semi-Month') then
560       --
561       p_rec.midpoint_offset := -15;
562       --
563    Else
564       --
565       p_rec.midpoint_offset := 0;
566       --
567    End If;
568 
569   hr_utility.set_location(' Leaving:'||l_proc, 10);
570 --
571 End pre_insert;
572 --
573 -- ----------------------------------------------------------------------------
574 -- |----------------------------< post_insert >-------------------------------|
575 -- ----------------------------------------------------------------------------
576 -- {Start Of Comments}
577 --
578 -- Description:
579 --   This private procedure contains any processing which is required after
580 --   the insert dml.
581 --
582 -- Prerequisites:
583 --   This is an internal procedure which is called from the ins procedure.
584 --
585 -- In Parameters:
586 --   A Pl/Sql record structure.
587 --
588 -- Post Success:
589 --   Processing continues.
590 --
591 -- Post Failure:
592 --   If an error has occurred, an error message and exception will be raised
593 --   but not handled.
594 --
595 -- Developer Implementation Notes:
596 --   Any post-processing required after the insert dml is issued should be
597 --   coded within this procedure. It is important to note that any 3rd party
598 --   maintenance should be reviewed before placing in this procedure.
599 --
600 -- Access Status:
601 --   Internal Row Handler Use Only.
602 --
603 -- {End Of Comments}
604 -- ----------------------------------------------------------------------------
605 Procedure post_insert
606   (p_rec                   in pay_pay_shd.g_rec_type
607   ,p_effective_date        in date
608   ,p_datetrack_mode        in varchar2
609   ,p_validation_start_date in date
610   ,p_validation_end_date   in date
611   ) is
612 --
613   l_proc        varchar2(72) := g_package||'post_insert';
614 --
615 Begin
616   hr_utility.set_location('Entering:'||l_proc, 5);
617   begin
618     --
619     pay_pay_rki.after_insert
620       (p_effective_date
621       => p_effective_date
622       ,p_validation_start_date
623       => p_validation_start_date
624       ,p_validation_end_date
625       => p_validation_end_date
626       ,p_payroll_id
627       => p_rec.payroll_id
628       ,p_effective_start_date
629       => p_rec.effective_start_date
630       ,p_effective_end_date
631       => p_rec.effective_end_date
632       ,p_default_payment_method_id
633       => p_rec.default_payment_method_id
634       ,p_business_group_id
635       => p_rec.business_group_id
636       ,p_consolidation_set_id
637       => p_rec.consolidation_set_id
638       ,p_cost_allocation_keyflex_id
639       => p_rec.cost_allocation_keyflex_id
640       ,p_suspense_account_keyflex_id
641       => p_rec.suspense_account_keyflex_id
642       ,p_gl_set_of_books_id
643       => p_rec.gl_set_of_books_id
644       ,p_soft_coding_keyflex_id
645       => p_rec.soft_coding_keyflex_id
646       ,p_period_type
647       => p_rec.period_type
648       ,p_organization_id
649       => p_rec.organization_id
650       ,p_cut_off_date_offset
651       => p_rec.cut_off_date_offset
652       ,p_direct_deposit_date_offset
653       => p_rec.direct_deposit_date_offset
654       ,p_first_period_end_date
655       => p_rec.first_period_end_date
656       ,p_negative_pay_allowed_flag
657       => p_rec.negative_pay_allowed_flag
658       ,p_number_of_years
659       => p_rec.number_of_years
660       ,p_pay_advice_date_offset
661       => p_rec.pay_advice_date_offset
662       ,p_pay_date_offset
663       => p_rec.pay_date_offset
664       ,p_payroll_name
665       => p_rec.payroll_name
666       ,p_workload_shifting_level
667       => p_rec.workload_shifting_level
668       ,p_comment_id
669       => p_rec.comment_id
670       ,p_comments
671       => p_rec.comments
672       ,p_midpoint_offset
673       => p_rec.midpoint_offset
674       ,p_attribute_category
675       => p_rec.attribute_category
676       ,p_attribute1
677       => p_rec.attribute1
678       ,p_attribute2
679       => p_rec.attribute2
680       ,p_attribute3
681       => p_rec.attribute3
682       ,p_attribute4
683       => p_rec.attribute4
684       ,p_attribute5
685       => p_rec.attribute5
686       ,p_attribute6
687       => p_rec.attribute6
688       ,p_attribute7
689       => p_rec.attribute7
690       ,p_attribute8
691       => p_rec.attribute8
692       ,p_attribute9
693       => p_rec.attribute9
694       ,p_attribute10
695       => p_rec.attribute10
696       ,p_attribute11
697       => p_rec.attribute11
698       ,p_attribute12
699       => p_rec.attribute12
700       ,p_attribute13
701       => p_rec.attribute13
702       ,p_attribute14
703       => p_rec.attribute14
704       ,p_attribute15
705       => p_rec.attribute15
706       ,p_attribute16
707       => p_rec.attribute16
708       ,p_attribute17
709       => p_rec.attribute17
710       ,p_attribute18
711       => p_rec.attribute18
712       ,p_attribute19
713       => p_rec.attribute19
714       ,p_attribute20
715       => p_rec.attribute20
716       ,p_arrears_flag
717       => p_rec.arrears_flag
718       ,p_payroll_type
719       => p_rec.payroll_type
720       ,p_prl_information_category
721       => p_rec.prl_information_category
722       ,p_prl_information1
723       => p_rec.prl_information1
724       ,p_prl_information2
725       => p_rec.prl_information2
726       ,p_prl_information3
727       => p_rec.prl_information3
728       ,p_prl_information4
729       => p_rec.prl_information4
730       ,p_prl_information5
731       => p_rec.prl_information5
732       ,p_prl_information6
733       => p_rec.prl_information6
734       ,p_prl_information7
735       => p_rec.prl_information7
736       ,p_prl_information8
737       => p_rec.prl_information8
738       ,p_prl_information9
739       => p_rec.prl_information9
740       ,p_prl_information10
741       => p_rec.prl_information10
742       ,p_prl_information11
743       => p_rec.prl_information11
744       ,p_prl_information12
745       => p_rec.prl_information12
746       ,p_prl_information13
747       => p_rec.prl_information13
748       ,p_prl_information14
749       => p_rec.prl_information14
750       ,p_prl_information15
751       => p_rec.prl_information15
752       ,p_prl_information16
753       => p_rec.prl_information16
754       ,p_prl_information17
755       => p_rec.prl_information17
756       ,p_prl_information18
757       => p_rec.prl_information18
758       ,p_prl_information19
759       => p_rec.prl_information19
760       ,p_prl_information20
761       => p_rec.prl_information20
762       ,p_prl_information21
763       => p_rec.prl_information21
764       ,p_prl_information22
765       => p_rec.prl_information22
766       ,p_prl_information23
767       => p_rec.prl_information23
768       ,p_prl_information24
769       => p_rec.prl_information24
770       ,p_prl_information25
771       => p_rec.prl_information25
772       ,p_prl_information26
773       => p_rec.prl_information26
774       ,p_prl_information27
775       => p_rec.prl_information27
776       ,p_prl_information28
777       => p_rec.prl_information28
778       ,p_prl_information29
779       => p_rec.prl_information29
780       ,p_prl_information30
781       => p_rec.prl_information30
782       ,p_multi_assignments_flag
783       => p_rec.multi_assignments_flag
784       ,p_period_reset_years
785       => p_rec.period_reset_years
786       ,p_object_version_number
787       => p_rec.object_version_number
788       ,p_payslip_view_date_offset
789       => p_rec.payslip_view_date_offset
790       );
791     --
792   exception
793     --
794     when hr_api.cannot_find_prog_unit then
795       --
796       hr_api.cannot_find_prog_unit_error
797         (p_module_name => 'PAY_ALL_PAYROLLS_F'
798         ,p_hook_type   => 'AI');
799       --
800   end;
801   --
802   hr_utility.set_location(' Leaving:'||l_proc, 10);
803 End post_insert;
804 --
805 -- ----------------------------------------------------------------------------
806 -- |-------------------------------< ins_lck >--------------------------------|
807 -- ----------------------------------------------------------------------------
808 -- {Start Of Comments}
809 --
810 -- Description:
811 --   The ins_lck process has one main function to perform. When inserting
812 --   a datetracked row, we must validate the DT mode.
813 --
814 -- Prerequisites:
815 --   This procedure can only be called for the datetrack mode of INSERT.
816 --
817 -- In Parameters:
818 --
819 -- Post Success:
820 --   On successful completion of the ins_lck process the parental
821 --   datetracked rows will be locked providing the p_enforce_foreign_locking
822 --   argument value is TRUE.
823 --   If the p_enforce_foreign_locking argument value is FALSE then the
824 --   parential rows are not locked.
825 --
826 -- Post Failure:
827 --   The Lck process can fail for:
828 --   1) When attempting to lock the row the row could already be locked by
829 --      another user. This will raise the HR_Api.Object_Locked exception.
830 --   2) When attempting to the lock the parent which doesn't exist.
831 --      For the entity to be locked the parent must exist!
832 --
833 -- Developer Implementation Notes:
834 --   None.
835 --
836 -- Access Status:
837 --   Internal Row Handler Use Only.
838 --
839 -- {End Of Comments}
840 -- ----------------------------------------------------------------------------
841 Procedure ins_lck
842   (p_effective_date        in date
843   ,p_datetrack_mode        in varchar2
844   ,p_rec                   in pay_pay_shd.g_rec_type
845   ,p_validation_start_date out nocopy date
846   ,p_validation_end_date   out nocopy date
847   ) is
848 --
849   l_proc                  varchar2(72) := g_package||'ins_lck';
850   l_validation_start_date date;
851   l_validation_end_date   date;
852 
853   l_effective_date          date;
854   l_first_period_end_date   date;
855 
856 --
857 Begin
858   hr_utility.set_location('Entering:'||l_proc, 5);
859 
860   l_effective_date        := trunc(p_effective_date);
861   l_first_period_end_date := trunc(p_rec.first_period_end_date);
862 
863   hr_api.mandatory_arg_error
864      (p_api_name       => l_proc
865      ,p_argument       => 'effective_date'
866      ,p_argument_value => l_effective_date
867      );
868 
869    hr_utility.set_location(l_proc, 20);
870    hr_api.mandatory_arg_error
871      (p_api_name       => l_proc
872      ,p_argument       => 'payroll_name'
873      ,p_argument_value => p_rec.payroll_name
874      );
875 
876    hr_utility.set_location(l_proc, 30);
877    hr_api.mandatory_arg_error
878      (p_api_name       => l_proc
879      ,p_argument       => 'period_type'
880      ,p_argument_value => p_rec.period_type
881      );
882 
883    hr_utility.set_location(l_proc, 40);
884    hr_api.mandatory_arg_error
885      (p_api_name       => l_proc
886      ,p_argument       => 'first_period_end_date'
887      ,p_argument_value => l_first_period_end_date
888      );
889 
890    hr_api.mandatory_arg_error
891      (p_api_name       => l_proc
892      ,p_argument       => 'number_of_years'
893      ,p_argument_value => p_rec.number_of_years
894      );
895 
896    hr_api.mandatory_arg_error
897      (p_api_name       => l_proc
898      ,p_argument       => 'consolidation_set_id'
899      ,p_argument_value => p_rec.consolidation_set_id
900      );
901 
902   --
903   -- Validate the datetrack mode mode getting the validation start
904   -- and end dates for the specified datetrack operation.
905   --
906   dt_api.validate_dt_mode
907       (p_effective_date             => p_effective_date
908       ,p_datetrack_mode             => p_datetrack_mode
909       ,p_base_table_name            => 'pay_all_payrolls_f'
910       ,p_base_key_column            => 'payroll_id'
911       ,p_base_key_value             => p_rec.payroll_id
912 
913       ,p_parent_table_name1         => 'pay_org_payment_methods_f'
914       ,p_parent_key_column1         => 'org_payment_method_id'
915       ,p_parent_key_value1          => pay_pay_shd.g_old_rec.default_payment_method_id
916 
917       ,p_child_table_name1          => 'per_all_assignments_f'
918       ,p_child_key_column1          => 'assignment_id'
919       ,p_child_alt_base_key_column1 => 'payroll_id'
920 
921       ,p_child_table_name2          => 'pay_element_links_f'
922       ,p_child_key_column2          => 'element_link_id'
923       ,p_child_alt_base_key_column2 => 'payroll_id'
924 
925       ,p_child_table_name3          => 'hr_all_positions_f'
926       ,p_child_key_column3	    => 'position_id'
927       ,p_child_alt_base_key_column3 => 'pay_freq_payroll_id'
928 
929       ,p_enforce_foreign_locking    => true
930       ,p_validation_start_date      => l_validation_start_date
931       ,p_validation_end_date        => l_validation_end_date
932       );
933   --
934   -- Set the validation start and end date OUT arguments
935   --
936   p_validation_start_date := l_validation_start_date;
937   p_validation_end_date   := l_validation_end_date;
938   --
939   hr_utility.set_location(' Leaving:'||l_proc, 10);
940   --
941 End ins_lck;
942 --
943 -- ----------------------------------------------------------------------------
944 -- |---------------------------------< ins >----------------------------------|
945 -- ----------------------------------------------------------------------------
946 Procedure ins
947   (p_effective_date in     date
948   ,p_rec            in out nocopy pay_pay_shd.g_rec_type
949   ) is
950 --
951   l_proc                        varchar2(72) := g_package||'ins';
952   l_datetrack_mode              varchar2(30) := hr_api.g_insert;
953   l_validation_start_date       date;
954   l_validation_end_date         date;
955   l_business_group_id           number(15);
956 --
957 Begin
958   hr_utility.set_location('Entering:'||l_proc, 5);
959 
960   --
961   -- Call the lock operation
962   --
963   pay_pay_ins.ins_lck
964     (p_effective_date        => p_effective_date
965     ,p_datetrack_mode        => l_datetrack_mode
966     ,p_rec                   => p_rec
967     ,p_validation_start_date => l_validation_start_date
968     ,p_validation_end_date   => l_validation_end_date
969     );
970   --
971   -- Call the supporting insert validate operations
972   --
973   pay_pay_bus.insert_validate
974     (p_rec                   => p_rec
975     ,p_effective_date        => p_effective_date
976     ,p_datetrack_mode        => l_datetrack_mode
977     ,p_validation_start_date => l_validation_start_date
978     ,p_validation_end_date   => l_validation_end_date
979     );
980   --
981   -- Call to raise any errors on multi-message list
982   hr_multi_message.end_validation_set;
983   --
984   -- Call the supporting pre-insert operation
985   --
986   pay_pay_ins.pre_insert
987     (p_rec                   => p_rec
988     ,p_effective_date        => p_effective_date
989     ,p_datetrack_mode        => l_datetrack_mode
990     ,p_validation_start_date => l_validation_start_date
991     ,p_validation_end_date   => l_validation_end_date
992     );
993   --
994   -- Insert the row
995   --
996   pay_pay_ins.insert_dml
997     (p_rec                   => p_rec
998     ,p_effective_date        => p_effective_date
999     ,p_datetrack_mode        => l_datetrack_mode
1000     ,p_validation_start_date => l_validation_start_date
1001     ,p_validation_end_date   => l_validation_end_date
1002     );
1003   --
1004   -- Call the supporting post-insert operation
1005   --
1006   pay_pay_ins.post_insert
1007     (p_rec                   => p_rec
1008     ,p_effective_date        => p_effective_date
1009     ,p_datetrack_mode        => l_datetrack_mode
1010     ,p_validation_start_date => l_validation_start_date
1011     ,p_validation_end_date   => l_validation_end_date
1012     );
1013   --
1014   -- Call to raise any errors on multi-message list
1015   hr_multi_message.end_validation_set;
1016   --
1017   hr_utility.set_location('Leaving:'||l_proc,10);
1018 end ins;
1019 --
1020 -- ----------------------------------------------------------------------------
1021 -- |---------------------------------< ins >----------------------------------|
1022 -- ----------------------------------------------------------------------------
1023 Procedure ins
1024   (p_effective_date                 in     date
1025   ,p_consolidation_set_id           in     number
1026   ,p_period_type                    in     varchar2
1027   ,p_cut_off_date_offset            in     number default 0 --Added default as per the old API
1028   ,p_direct_deposit_date_offset     in     number default 0 --Added default as per the old API
1029   ,p_first_period_end_date          in     date
1030   ,p_negative_pay_allowed_flag      in     varchar2 default 'N' --Added default as per the old API
1031   ,p_number_of_years                in     number
1032   ,p_pay_advice_date_offset         in     number default 0 --Added  default as per the old API
1033   ,p_pay_date_offset                in     number default 0 --Added  default as per the old API.
1034   ,p_payroll_name                   in     varchar2
1035   ,p_workload_shifting_level        in     varchar2 default 'N' --Added default.
1036   ,p_default_payment_method_id      in     number   default null
1037   ,p_cost_allocation_keyflex_id     in     number   default null
1038   ,p_suspense_account_keyflex_id    in     number   default null
1039   ,p_gl_set_of_books_id             in     number   default null
1040   ,p_soft_coding_keyflex_id         in     number   default null
1041   ,p_organization_id                in     number   default null
1042   ,p_comments                       in     varchar2 default null
1043   ,p_midpoint_offset                in     number   default null
1044   ,p_attribute_category             in     varchar2 default null
1045   ,p_attribute1                     in     varchar2 default null
1046   ,p_attribute2                     in     varchar2 default null
1047   ,p_attribute3                     in     varchar2 default null
1048   ,p_attribute4                     in     varchar2 default null
1049   ,p_attribute5                     in     varchar2 default null
1050   ,p_attribute6                     in     varchar2 default null
1051   ,p_attribute7                     in     varchar2 default null
1052   ,p_attribute8                     in     varchar2 default null
1053   ,p_attribute9                     in     varchar2 default null
1054   ,p_attribute10                    in     varchar2 default null
1055   ,p_attribute11                    in     varchar2 default null
1056   ,p_attribute12                    in     varchar2 default null
1057   ,p_attribute13                    in     varchar2 default null
1058   ,p_attribute14                    in     varchar2 default null
1059   ,p_attribute15                    in     varchar2 default null
1060   ,p_attribute16                    in     varchar2 default null
1061   ,p_attribute17                    in     varchar2 default null
1062   ,p_attribute18                    in     varchar2 default null
1063   ,p_attribute19                    in     varchar2 default null
1064   ,p_attribute20                    in     varchar2 default null
1065   ,p_arrears_flag                   in     varchar2 default null
1066   ,p_payroll_type                   in     varchar2 default null
1067   ,p_prl_information_category       in     varchar2 default null
1068   ,p_prl_information1               in     varchar2 default null
1069   ,p_prl_information2               in     varchar2 default null
1070   ,p_prl_information3               in     varchar2 default null
1071   ,p_prl_information4               in     varchar2 default null
1072   ,p_prl_information5               in     varchar2 default null
1073   ,p_prl_information6               in     varchar2 default null
1074   ,p_prl_information7               in     varchar2 default null
1075   ,p_prl_information8               in     varchar2 default null
1076   ,p_prl_information9               in     varchar2 default null
1077   ,p_prl_information10              in     varchar2 default null
1078   ,p_prl_information11              in     varchar2 default null
1079   ,p_prl_information12              in     varchar2 default null
1080   ,p_prl_information13              in     varchar2 default null
1081   ,p_prl_information14              in     varchar2 default null
1082   ,p_prl_information15              in     varchar2 default null
1083   ,p_prl_information16              in     varchar2 default null
1084   ,p_prl_information17              in     varchar2 default null
1085   ,p_prl_information18              in     varchar2 default null
1086   ,p_prl_information19              in     varchar2 default null
1087   ,p_prl_information20              in     varchar2 default null
1088   ,p_prl_information21              in     varchar2 default null
1089   ,p_prl_information22              in     varchar2 default null
1090   ,p_prl_information23              in     varchar2 default null
1091   ,p_prl_information24              in     varchar2 default null
1092   ,p_prl_information25              in     varchar2 default null
1093   ,p_prl_information26              in     varchar2 default null
1094   ,p_prl_information27              in     varchar2 default null
1095   ,p_prl_information28              in     varchar2 default null
1096   ,p_prl_information29              in     varchar2 default null
1097   ,p_prl_information30              in     varchar2 default null
1098   ,p_multi_assignments_flag         in     varchar2 default null
1099   ,p_period_reset_years             in     varchar2 default null
1100   ,p_payslip_view_date_offset       in     number   default null
1101   ,p_payroll_id                        out nocopy number
1102   ,p_object_version_number             out nocopy number
1103   ,p_effective_start_date              out nocopy date
1104   ,p_effective_end_date                out nocopy date
1105   ,p_comment_id                        out nocopy number
1106   ) is
1107 --
1108   l_rec         pay_pay_shd.g_rec_type;
1109   l_proc        varchar2(72) := g_package||'ins';
1110   l_effective_date          date;
1111   l_first_period_end_date   date;
1112 
1113 --
1114 Begin
1115 
1116   hr_utility.set_location('Entering:'||l_proc, 5);
1117   --
1118   -- Call conversion function to turn arguments into the
1119   -- p_rec structure.
1120   --
1121   l_rec :=
1122   pay_pay_shd.convert_args
1123     (null
1124     ,null
1125     ,null
1126     ,p_default_payment_method_id
1127     ,null --p_business_group_id
1128     ,p_consolidation_set_id
1129     ,p_cost_allocation_keyflex_id
1130     ,p_suspense_account_keyflex_id
1131     ,p_gl_set_of_books_id
1132     ,p_soft_coding_keyflex_id
1133     ,p_period_type
1134     ,p_organization_id
1135     ,p_cut_off_date_offset
1136     ,p_direct_deposit_date_offset
1137     ,p_first_period_end_date
1138     ,p_negative_pay_allowed_flag
1139     ,p_number_of_years
1140     ,p_pay_advice_date_offset
1141     ,p_pay_date_offset
1142     ,p_payroll_name
1143     ,p_workload_shifting_level
1144     ,null
1145     ,p_comments
1146     ,p_midpoint_offset
1147     ,p_attribute_category
1148     ,p_attribute1
1149     ,p_attribute2
1150     ,p_attribute3
1151     ,p_attribute4
1152     ,p_attribute5
1153     ,p_attribute6
1154     ,p_attribute7
1155     ,p_attribute8
1156     ,p_attribute9
1157     ,p_attribute10
1158     ,p_attribute11
1159     ,p_attribute12
1160     ,p_attribute13
1161     ,p_attribute14
1162     ,p_attribute15
1163     ,p_attribute16
1164     ,p_attribute17
1165     ,p_attribute18
1166     ,p_attribute19
1167     ,p_attribute20
1168     ,p_arrears_flag
1169     ,p_payroll_type
1170     ,p_prl_information_category
1171     ,p_prl_information1
1172     ,p_prl_information2
1173     ,p_prl_information3
1174     ,p_prl_information4
1175     ,p_prl_information5
1176     ,p_prl_information6
1177     ,p_prl_information7
1178     ,p_prl_information8
1179     ,p_prl_information9
1180     ,p_prl_information10
1181     ,p_prl_information11
1182     ,p_prl_information12
1183     ,p_prl_information13
1184     ,p_prl_information14
1185     ,p_prl_information15
1186     ,p_prl_information16
1187     ,p_prl_information17
1188     ,p_prl_information18
1189     ,p_prl_information19
1190     ,p_prl_information20
1191     ,p_prl_information21
1192     ,p_prl_information22
1193     ,p_prl_information23
1194     ,p_prl_information24
1195     ,p_prl_information25
1196     ,p_prl_information26
1197     ,p_prl_information27
1198     ,p_prl_information28
1199     ,p_prl_information29
1200     ,p_prl_information30
1201     ,p_multi_assignments_flag
1202     ,p_period_reset_years
1203     ,NULL --p_object_version_number
1204     ,p_payslip_view_date_offset
1205     );
1206   --
1207   -- Having converted the arguments into the pay_pay_rec
1208   -- plsql record structure we call the corresponding record
1209   -- business process.
1210   --
1211   pay_pay_ins.ins
1212     (p_effective_date
1213     ,l_rec
1214     );
1215   --
1216   -- Set the OUT arguments.
1217   --
1218   p_payroll_id                       := l_rec.payroll_id;
1219   p_effective_start_date             := l_rec.effective_start_date;
1220   p_effective_end_date               := l_rec.effective_end_date;
1221   p_object_version_number            := l_rec.object_version_number;
1222   p_comment_id                       := l_rec.comment_id;
1223   --
1224   hr_utility.set_location(' Leaving:'||l_proc, 10);
1225 End ins;
1226 --
1227 end pay_pay_ins;