DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_PERSONAL_PAY_METHOD_API

Source


1 Package Body hr_personal_pay_method_api as
2 /* $Header: pyppmapi.pkb 120.5.12010000.3 2008/08/06 08:13:31 ubhat ship $ */
3 --
4 -- Package Variables
5 --
6 g_debug boolean := hr_utility.debug_enabled;
7 g_package  varchar2(33) := 'hr_personal_pay_method_api.';
8 --
9 -- ----------------------------------------------------------------------------
10 -- |-------------------------< check_insert_legislation >-------------------------|
11 -- ----------------------------------------------------------------------------
12 --
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This private procedure ensures that the legislation rule for the
17 --   for the personal payment method being inserted is the
18 --   of the required business process.
19 --
20 -- Prerequisites:
21 --   None.
22 --
23 -- In Parameters:
24 --   Name                           Reqd Type     Description
25 --   p_personal_payment_method_id   Yes  number   Id of personal payment
26 --                                                method being deleted.
27 --   p_effective_date               Yes  date     The session date.
28 --   p_leg_code                     Yes  varchar2 Legislation of business
29 --                                                group
30 --
31 -- Post Success:
32 --   The procedure returns control back to the calling process.
33 --
34 -- Post Failure:
35 --   The process raises an error and stops execution.
36 --
37 -- Access Status:
38 --   Private.
39 --
40 -- {End Of Comments}
41 --
42 procedure check_insert_legislation
43   (p_assignment_id          in            number
44   ,p_effective_date         in out nocopy date
45   ,p_leg_code               in            varchar2
46   ) is
47   --
48   -- Declare cursors and local variables
49   --
50   l_proc                varchar2(72);
51   l_valid               varchar2(150);
52   l_effective_date      date;
53   --
54   cursor legsel is
55     select pbg.legislation_code
56     from   per_business_groups pbg,
57            per_assignments_f   asg
58     where  pbg.business_group_id = asg.business_group_id
59     and    asg.assignment_id     = p_assignment_id
60     and    p_effective_date between asg.effective_start_date
61                             and     asg.effective_end_date;
62   --
63 begin
64   if g_debug then
65      l_proc := g_package||'chk_insert_legislation';
66      hr_utility.set_location('Entering:'|| l_proc, 5);
67   end if;
68   --
69   -- Check that p_assignment_id and p_effective_date are not null as they
70   -- are used by the cursor to validate the business group.
71   --
72   hr_api.mandatory_arg_error
73     (p_api_name       => l_proc,
74      p_argument       => 'assignment_id',
75      p_argument_value => p_assignment_id);
76   --
77   hr_api.mandatory_arg_error
78     (p_api_name       => l_proc,
79      p_argument       => 'effective_date',
80      p_argument_value => p_effective_date);
81   --
82   if g_debug then
83      hr_utility.set_location(l_proc, 6);
84   end if;
85   --
86   -- Ensure that the legislation rule for the employee assignment
87   -- business group is that of p_leg_code.
88   --
89   open legsel;
90   fetch legsel
91   into l_valid;
92   --
93   if legsel%notfound then
94     close legsel;
95     hr_utility.set_message(801, 'HR_7348_ASSIGNMENT_INVALID');
96     hr_utility.raise_error;
97   end if;
98   if legsel%found and l_valid <> p_leg_code then
99     close legsel;
100     hr_utility.set_message(801, 'HR_7898_PPM_BUS_GRP_INVALID');
101     hr_utility.raise_error;
102   end if;
103   --
104   close legsel;
105   if g_debug then
106      hr_utility.set_location(l_proc, 7);
107   end if;
108   --
109   -- Assign out parameter after truncating the date by using a local
110   -- variable.
111   --
112   l_effective_date := trunc(p_effective_date);
113   p_effective_date := l_effective_date;
114   --
115   if g_debug then
116      hr_utility.set_location('Leaving:'|| l_proc, 8);
117   end if;
118   --
119 end check_insert_legislation;
120 --
121 -- ----------------------------------------------------------------------------
122 -- |-------------------------< check_update_legislation >-------------------------|
123 -- ----------------------------------------------------------------------------
124 --
125 -- {Start Of Comments}
126 --
127 -- Description:
128 --   This private procedure ensures that the legislation rule for the
129 --   for the personal payment method being updated or deleted is the
130 --   of the required business process.
131 --
132 -- Prerequisites:
133 --   None.
134 --
135 -- In Parameters:
136 --   Name                           Reqd Type     Description
137 --   p_personal_payment_method_id   Yes  number   Id of personal payment
138 --                                                method being deleted.
139 --   p_effective_date               Yes  date     The session date.
140 --   p_leg_code                     Yes  varchar2 Legislation of business
141 --                                                group
142 --
143 -- Post Success:
144 --   The procedure returns control back to the calling process.
145 --
146 -- Post Failure:
147 --   The process raises an error and stops execution.
148 --
149 -- Access Status:
150 --   Private.
151 --
152 -- {End Of Comments}
153 --
154 procedure check_update_legislation
155   (p_personal_payment_method_id    in
156      pay_personal_payment_methods_f.personal_payment_method_id%type
157   ,p_effective_date                in     date
158   ,p_leg_code                      in varchar2
159   ) is
160   --
161   -- Declare cursors and local variables
162   --
163   l_proc                varchar2(72);
164   l_valid               varchar2(150);
165   --
166   cursor legsel is
167     select pbg.legislation_code
168     from   per_business_groups pbg,
169            pay_personal_payment_methods_f ppm
170     where  pbg.business_group_id = ppm.business_group_id
171     and    ppm.personal_payment_method_id = p_personal_payment_method_id
172     and    p_effective_date between ppm.effective_start_date
173                             and     ppm.effective_end_date;
174 --
175 begin
176   --
177   -- Ensure that the legislation rule for the employee assignment business
178   -- group is that of p_leg_code.
179   --
180   if g_debug then
181      l_proc := g_package||'check_update_legislation';
182      hr_utility.set_location('Entering:'|| l_proc, 10);
183   end if;
184   open legsel;
185   fetch legsel
186   into l_valid;
187   --
188   if legsel%notfound then
189     close legsel;
190     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
191     hr_utility.raise_error;
192   end if;
193   if legsel%found and l_valid <> p_leg_code then
194     hr_utility.set_message(801, 'HR_7898_PPM_BUS_GRP_INVALID');
195     hr_utility.raise_error;
196   end if;
197   --
198   close legsel;
199   if g_debug then
200      hr_utility.set_location('Leaving:'|| l_proc, 20);
201   end if;
202   --
203 end check_update_legislation;
204 --
205 -- ----------------------------------------------------------------------------
206 -- |---------------------------< stamp_prenote_date >-------------------------|
207 -- ----------------------------------------------------------------------------
208 --
209 -- {Start Of Comments}
210 --
211 -- Description:
212 --   This private procedure stamps the prenote date on the external account
213 --   row for US legislation. Contains minimal validation - it's called at the
214 --   end of create_personal_pay_method and update_personal_pay_method after
215 --   the EXA and PPM row handlers will have done the validation already.
216 --
217 -- Prerequisites:
218 --   Must only be called for US territory code, and if the payment method
219 --   is for a magtape payment.
220 --
221 -- In Parameters:
222 --   Name                           Reqd Type     Description
223 --   p_personal_payment_method_id   Yes  number   Id of personal payment
224 --                                                method being created/updated.
225 --   p_effective_date               Yes  date     The session date.
226 --   p_external_account_id          Yes  number   Id of external account row.
227 --   p_external_account_ovn         Yes  number   Object version number of
228 --                                                external account row.
229 --
230 -- Post Success:
231 --   The procedure returns control back to the calling process.
232 --
233 -- Post Failure:
234 --   The process raises an error and stops execution.
235 --
236 -- Access Status:
237 --   Private.
238 --
239 -- {End Of Comments}
240 --
241 procedure stamp_prenote_date
242 (p_personal_payment_method_id in            number
243 ,p_effective_date             in            date
244 ,p_external_account_id        in            number
245 ,p_external_account_ovn       in out nocopy number
246 ) is
247 l_proc              varchar2(2000);
248 l_prenote_date      date;
249 l_new_prenote_date  date;
250 l_3rd_party_payment varchar2(2000);
251 l_prenote_allowed   varchar2(2000);
252 l_validation_days   number;
253 --
254 -- Cursor to get payment-related information (PPM->OPM direction).
255 --
256 cursor csr_payment_details
257 (p_personal_payment_method_id in number
258 ,p_effective_date             in date
259 ) is
260 select nvl(to_char(opm.defined_balance_id), 'Y') third_party
261 ,      nvl(ppt.validation_days, 0)               validation_days
262 from   pay_personal_payment_methods_f ppm
263 ,      pay_org_payment_methods_f      opm
264 ,      pay_payment_types              ppt
265 where  ppm.personal_payment_method_id = p_personal_payment_method_id
266 and    p_effective_date between
267        ppm.effective_start_date and ppm.effective_end_date
268 and    opm.org_payment_method_id = ppm.org_payment_method_id
269 and    p_effective_date between
270        opm.effective_start_date and opm.effective_end_date
271 and    ppt.payment_type_id = opm.payment_type_id
272 ;
273 --
274 -- Cursor to get payroll information (PPM->ASG->PAYROLL direction).
275 --
276 cursor csr_payroll_details
277 (p_personal_payment_method_id in number
278 ,p_effective_date             in date
279 ) is
280 select nvl(pap.prl_information3, 'Y') prenote_allowed
281 from   pay_personal_payment_methods_f ppm
282 ,      per_all_assignments_f paa
283 ,      pay_all_payrolls_f    pap
284 where  ppm.personal_payment_method_id = p_personal_payment_method_id
285 and    p_effective_date between
286        ppm.effective_start_date and ppm.effective_end_date
287 and    paa.assignment_id = ppm.assignment_id
288 and    p_effective_date between
289        paa.effective_start_date and paa.effective_end_date
290 and    pap.payroll_id = paa.payroll_id
291 and    p_effective_date between
292        pap.effective_start_date and pap.effective_end_date
293 ;
294 --
295 -- Cursor to get the current prenote date.
296 --
297 cursor csr_curr_prenote_date
298 (p_external_account_id in number
299 ) is
300 select exa.prenote_date
301 from   pay_external_accounts exa
302 where  exa.external_account_id = p_external_account_id
303 ;
304 begin
305   if g_debug then
306      l_proc := g_package || 'stamp_prenote_date';
307      hr_utility.set_location('Entering:'|| l_proc, 10);
308   end if;
309   --
310   -- Prenotification is allowed by default.
311   --
312   l_prenote_allowed := 'Y';
313   --
314   -- Get the payment-related information.
315   --
316   open csr_payment_details
317   (p_personal_payment_method_id => p_personal_payment_method_id
318   ,p_effective_date             => p_effective_date
319   );
320   fetch csr_payment_details
321   into  l_3rd_party_payment
322   ,     l_validation_days;
323   if csr_payment_details%notfound then
324     if g_debug then
325        hr_utility.set_location('Leaving (csr_payment_details):'|| l_proc, 20);
326     end if;
327     close csr_payment_details;
328     --
329     -- There must've been an invalid primary key for the query to
330     -- return no rows.
331     --
332     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
333     hr_utility.raise_error;
334   end if;
335   close csr_payment_details;
336   --
337   -- Standard prenote date.
338   --
339   l_new_prenote_date := p_effective_date - l_validation_days;
340   --
341   -- Handle prenotification depending on payment type.
342   --
343   if l_3rd_party_payment = 'Y' then
344     --
345     -- bug1870072 requirement.
346     --
347     l_new_prenote_date := l_new_prenote_date - 1;
348     l_prenote_allowed := 'N';
349   else
350     open csr_payroll_details
351     (p_personal_payment_method_id => p_personal_payment_method_id
352     ,p_effective_date             => p_effective_date
353     );
354     fetch csr_payroll_details
355     into  l_prenote_allowed;
356     if csr_payroll_details%notfound then
357       if g_debug then
358          hr_utility.set_location('Leaving (csr_payroll_details):'|| l_proc, 30);
359       end if;
360       close csr_payroll_details;
361       --
362       -- There must've been an invalid primary key for the query to
363       -- return no rows.
364       --
365       hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
366       hr_utility.raise_error;
367     end if;
368     close csr_payroll_details;
369   end if;
370   --
371   -- Stamp the prenote date using the row handler if prenotification is not
372   -- allowed.
373   --
374   if upper(l_prenote_allowed) <> 'Y' then
375     --
376     -- This is an API call (implicit behaviour) so we should only stamp the
377     -- prenote date if it is NULL. Without this restriction, each API call
378     -- would be stamping the prenote date with a new value.
379     --
380     open csr_curr_prenote_date
381     (p_external_account_id => p_external_account_id);
382     fetch csr_curr_prenote_date
383     into  l_prenote_date;
384     if csr_curr_prenote_date%notfound then
385       if g_debug then
386          hr_utility.set_location
387          ('Leaving (csr_curr_prenote_date):'|| l_proc, 35);
388       end if;
389       close csr_curr_prenote_date;
390       --
391       -- There must've been an invalid primary key for the query to
392       -- return no rows.
393       --
394       hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
395       hr_utility.raise_error;
396     end if;
397     close csr_curr_prenote_date;
398     --
399     if l_prenote_date is null then
400       if g_debug then
401          hr_utility.set_location('Stamp the prenote date:'|| l_proc, 40);
402       end if;
403       pay_exa_upd.upd
404       (p_external_account_id   => p_external_account_id
405       ,p_object_version_number => p_external_account_ovn
406       ,p_territory_code        => 'US'
407       ,p_prenote_date          => l_new_prenote_date
408       ,p_validate              => false
409       );
410     end if;
411   end if;
412   if g_debug then
413      hr_utility.set_location('Leaving:'|| l_proc, 50);
414   end if;
415 end stamp_prenote_date;
416 --
417 -- ----------------------------------------------------------------------------
418 -- |---------------------------< upd_prenote_date >---------------------------|
419 -- ----------------------------------------------------------------------------
420 --
421 -- {Start Of Comments}
422 --
423 -- Description:
424 --   This procedure is used to update the prenote date in pay_external_accounts
425 --   with the value provided by the user. However the prenote date is updated
426 --   only if prenoting is allowed for the payroll(ie. prl_information3 = 'Y').
427 --
428 -- Prerequisites:
429 --   Must be called only from 'US' specific insert and update APIs.
430 --
431 -- In Parameters:
432 --   Name                           Reqd Type     Description
433 --   p_personal_payment_method_id   Yes  number   Id of personal payment
434 --                                                method being created/updated.
435 --   p_effective_date               Yes  date     The session date.
436 --   p_external_account_id          Yes  number   Id of external account row.
437 --   p_prenote_date                 Yes  date     Prenote Date that needs to
438 --                                                updated on the external
439 --                                                account row.
440 --
441 -- Post Success:
442 --   The procedure returns control back to the calling process.
443 --
444 -- Post Failure:
445 --   The process raises an error and stops execution.
446 --
447 -- Access Status:
448 --   Private.
449 --
450 -- {End Of Comments}
451 --
452 procedure upd_prenote_date
453   (p_personal_payment_method_id in number
454   ,p_external_account_id        in number
455   ,p_effective_date             in date
456   ,p_prenote_date               in date
457   ) is
458   --
459   l_proc                varchar2(72) := 'upd_prenote_date';
460   l_exa_ovn             pay_external_accounts.object_version_number%type;
461   l_prenote_allowed     pay_all_payrolls_f.prl_information3%type;
462   --
463   cursor csr_payroll_details(p_personal_payment_method_id in number
464                             ,p_effective_date             in date
465                             ) is
466     select nvl(pap.prl_information3, 'Y') prenote_allowed
467     from   pay_personal_payment_methods_f ppm
468     ,      per_all_assignments_f paa
469     ,      pay_all_payrolls_f    pap
470     where  ppm.personal_payment_method_id = p_personal_payment_method_id
471     and    p_effective_date between
472            ppm.effective_start_date and ppm.effective_end_date
473     and    paa.assignment_id = ppm.assignment_id
474     and    p_effective_date between
475            paa.effective_start_date and paa.effective_end_date
476     and    pap.payroll_id = paa.payroll_id
477     and    p_effective_date between
478            pap.effective_start_date and pap.effective_end_date;
479   --
480   cursor csr_exa_ovn(p_external_account_id in number) is
481     select pea.object_version_number
482     from   pay_external_accounts pea
483     where  pea.external_account_id = p_external_account_id;
484   --
485 begin
486   --
487   if g_debug then
488     hr_utility.set_location('Entering: '|| l_proc, 5);
489   end if;
490   --
491   open csr_payroll_details
492     (p_personal_payment_method_id => p_personal_payment_method_id
493     ,p_effective_date             => trunc(p_effective_date)
494     );
495   fetch csr_payroll_details into l_prenote_allowed;
496   if csr_payroll_details%notfound then
497     if g_debug then
498       hr_utility.set_location('Leaving (csr_payroll_details):'|| l_proc, 8);
499     end if;
500     close csr_payroll_details;
501     --
502     -- There must've been an invalid primary key for the query to
503     -- return no rows.
504     --
505     fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
506     fnd_message.raise_error;
507   end if;
508   close csr_payroll_details;
509   --
510   if l_prenote_allowed = 'Y' then
511     --
512     open csr_exa_ovn(p_external_account_id);
513     fetch csr_exa_ovn into l_exa_ovn;
514     if csr_exa_ovn%notfound then
515       if g_debug then
516         hr_utility.set_location('Leaving (csr_exa_ovn):'|| l_proc, 9);
517       end if;
518       close csr_exa_ovn;
519       --
520       -- There must've been an invalid primary key for the query to
521       -- return no rows.
522       --
523       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
524       fnd_message.raise_error;
525     end if;
526     close csr_exa_ovn;
527     --
528     pay_exa_upd.upd
529       (p_external_account_id   => p_external_account_id
530       ,p_object_version_number => l_exa_ovn
531       ,p_territory_code        => 'US'
532       ,p_prenote_date          => trunc(p_prenote_date)
533       ,p_validate              => false
534       );
535     --
536   end if;
537   --
538   if g_debug then
539     hr_utility.set_location('Leaving: '|| l_proc, 10);
540   end if;
541   --
542 end upd_prenote_date;
543 -- ----------------------------------------------------------------------------
544 -- |----------------------< create_personal_pay_method >----------------------|
545 -- ----------------------------------------------------------------------------
546 --
547 procedure create_personal_pay_method
548   (p_validate                      in     boolean  default false
549   ,p_effective_date                in     date
550   ,p_assignment_id                 in     number
551   ,p_run_type_id                   in     number  default null
552   ,p_org_payment_method_id         in     number
553   ,p_amount                        in     number   default null
554   ,p_percentage                    in     number   default null
555   ,p_priority                      in     number   default null
556   ,p_comments                      in     varchar2 default null
557   ,p_attribute_category            in     varchar2 default null
558   ,p_attribute1                    in     varchar2 default null
559   ,p_attribute2                    in     varchar2 default null
560   ,p_attribute3                    in     varchar2 default null
561   ,p_attribute4                    in     varchar2 default null
562   ,p_attribute5                    in     varchar2 default null
563   ,p_attribute6                    in     varchar2 default null
564   ,p_attribute7                    in     varchar2 default null
565   ,p_attribute8                    in     varchar2 default null
566   ,p_attribute9                    in     varchar2 default null
567   ,p_attribute10                   in     varchar2 default null
568   ,p_attribute11                   in     varchar2 default null
569   ,p_attribute12                   in     varchar2 default null
570   ,p_attribute13                   in     varchar2 default null
571   ,p_attribute14                   in     varchar2 default null
572   ,p_attribute15                   in     varchar2 default null
573   ,p_attribute16                   in     varchar2 default null
574   ,p_attribute17                   in     varchar2 default null
575   ,p_attribute18                   in     varchar2 default null
576   ,p_attribute19                   in     varchar2 default null
577   ,p_attribute20                   in     varchar2 default null
578   ,p_territory_code                in     varchar2 default null
579   ,p_segment1                      in     varchar2 default null
580   ,p_segment2                      in     varchar2 default null
581   ,p_segment3                      in     varchar2 default null
582   ,p_segment4                      in     varchar2 default null
583   ,p_segment5                      in     varchar2 default null
584   ,p_segment6                      in     varchar2 default null
585   ,p_segment7                      in     varchar2 default null
586   ,p_segment8                      in     varchar2 default null
587   ,p_segment9                      in     varchar2 default null
588   ,p_segment10                     in     varchar2 default null
589   ,p_segment11                     in     varchar2 default null
590   ,p_segment12                     in     varchar2 default null
591   ,p_segment13                     in     varchar2 default null
592   ,p_segment14                     in     varchar2 default null
593   ,p_segment15                     in     varchar2 default null
594   ,p_segment16                     in     varchar2 default null
595   ,p_segment17                     in     varchar2 default null
596   ,p_segment18                     in     varchar2 default null
597   ,p_segment19                     in     varchar2 default null
598   ,p_segment20                     in     varchar2 default null
599   ,p_segment21                     in     varchar2 default null
600   ,p_segment22                     in     varchar2 default null
601   ,p_segment23                     in     varchar2 default null
602   ,p_segment24                     in     varchar2 default null
603   ,p_segment25                     in     varchar2 default null
604   ,p_segment26                     in     varchar2 default null
605   ,p_segment27                     in     varchar2 default null
606   ,p_segment28                     in     varchar2 default null
607   ,p_segment29                     in     varchar2 default null
608   ,p_segment30                     in     varchar2 default null
609 /** sbilling **/
610   ,p_concat_segments               in     varchar2 default null
611   ,p_payee_type                    in     varchar2 default null
612   ,p_payee_id                      in     number   default null
613   ,p_ppm_information_category      in     varchar2 default null  --Bug 6439573
614   ,p_ppm_information1              in     varchar2 default null
615   ,p_ppm_information2              in     varchar2 default null
616   ,p_ppm_information3              in     varchar2 default null
617   ,p_ppm_information4              in     varchar2 default null
618   ,p_ppm_information5              in     varchar2 default null
619   ,p_ppm_information6              in     varchar2 default null
620   ,p_ppm_information7              in     varchar2 default null
621   ,p_ppm_information8              in     varchar2 default null
622   ,p_ppm_information9              in     varchar2 default null
623   ,p_ppm_information10             in     varchar2 default null
624   ,p_ppm_information11             in     varchar2 default null
625   ,p_ppm_information12             in     varchar2 default null
626   ,p_ppm_information13             in     varchar2 default null
627   ,p_ppm_information14             in     varchar2 default null
628   ,p_ppm_information15             in     varchar2 default null
629   ,p_ppm_information16             in     varchar2 default null
630   ,p_ppm_information17             in     varchar2 default null
631   ,p_ppm_information18             in     varchar2 default null
632   ,p_ppm_information19             in     varchar2 default null
633   ,p_ppm_information20             in     varchar2 default null
634   ,p_ppm_information21             in     varchar2 default null
635   ,p_ppm_information22             in     varchar2 default null
636   ,p_ppm_information23             in     varchar2 default null
637   ,p_ppm_information24             in     varchar2 default null
638   ,p_ppm_information25             in     varchar2 default null
639   ,p_ppm_information26             in     varchar2 default null
640   ,p_ppm_information27             in     varchar2 default null
641   ,p_ppm_information28             in     varchar2 default null
642   ,p_ppm_information29             in     varchar2 default null
643   ,p_ppm_information30             in     varchar2 default null
644   ,p_personal_payment_method_id    out    nocopy number
645   ,p_external_account_id           out    nocopy number
646   ,p_object_version_number         out    nocopy number
647   ,p_effective_start_date          out    nocopy date
648   ,p_effective_end_date            out    nocopy date
649   ,p_comment_id                    out    nocopy number
650   ) is
651   --
652   -- Declare cursors and local variables
653   --
654   l_proc                varchar2(72);
655   l_business_group_id   per_assignments_f.business_group_id%TYPE;
656   l_external_account_id pay_personal_payment_methods_f.external_account_id%TYPE;
657   l_validate            boolean := FALSE;
658   l_exa_ovn             number;
659   l_exists              varchar2(1);
660   l_category            varchar2(2);
661   l_effective_date      date;
662   l_ppm_information_category pay_personal_payment_methods_f.ppm_information_category%TYPE;
663   --
664   -- Declare OUT variables.
665   --
666   l_personal_payment_method_id    pay_personal_payment_methods_f.personal_payment_method_id%TYPE;
667   l_object_version_number         pay_personal_payment_methods_f.object_version_number%TYPE;
668   l_effective_start_date          pay_personal_payment_methods_f.effective_start_date%TYPE;
669   l_effective_end_date            pay_personal_payment_methods_f.effective_end_date%TYPE;
670   l_comment_id                    pay_personal_payment_methods_f.comment_id%TYPE;
671   --
672   cursor bgsel is
673     select pa.business_group_id
674     from   per_assignments_f pa
675     where  pa.assignment_id = p_assignment_id
676     and    p_effective_date between pa.effective_start_date
677                             and     pa.effective_end_date;
678   --
679   -- Bug 4644507. Removed the usage of per_business_groups from the cursor.
680   cursor csr_is_valid is
681     select  null
682     from    pay_org_payment_methods_f opm,
683             pay_payment_types ppt
684     where   opm.org_payment_method_id = p_org_payment_method_id
685     and     p_effective_date
686     between opm.effective_start_date
687     and     opm.effective_end_date
688     and     ppt.payment_type_id   = opm.payment_type_id ;
689   --
690   cursor csr_chk_pay_type is
691     select pyt.category
692     from pay_org_payment_methods_f opm
693     ,    pay_payment_types pyt
694     where p_org_payment_method_id = opm.org_payment_method_id
695       and opm.payment_type_id = pyt.payment_type_id
696       and p_effective_date between opm.effective_start_date
697                                and opm.effective_end_date;
698   --
699   cursor csr_ppm_info_category ( p_org_payment_method_id number,
700                                  p_effective_date        date) is
701      select decode(ppt.territory_code,null,null,ppt.territory_code||'_')||UPPER(ppt.payment_type_name) ppm_information_category
702        from pay_payment_types ppt,
703             pay_org_payment_methods_f opm
704       where opm.org_payment_method_id = p_org_payment_method_id
705         and p_effective_date between opm.effective_start_date and opm.effective_end_date
706         and opm.payment_type_id = ppt.payment_type_id;
707   --
708 begin
709   g_debug := hr_utility.debug_enabled;
710   if g_debug then
711      l_proc := g_package||'create_personal_pay_method';
712      hr_utility.set_location('Entering:'|| l_proc, 10);
713   end if;
714   --
715   -- Issue a savepoint.
716   --
717   savepoint create_personal_pay_method;
718   --
719   -- Initialize local variables
720   --
721   l_external_account_id   := null;
722   --
723   -- Check that p_assignment_id and p_effective_date are not null as they
724   -- are used by the cursor to derive the business group.
725   --
726   hr_api.mandatory_arg_error
727     (p_api_name       => l_proc,
728      p_argument       => 'assignment_id',
729      p_argument_value => p_assignment_id
730     );
731   --
732   hr_api.mandatory_arg_error
733     (p_api_name       => l_proc
734     ,p_argument       => 'org_payment_method_id'
735     ,p_argument_value => p_org_payment_method_id
736     );
737   --
738   hr_api.mandatory_arg_error
739     (p_api_name       => l_proc,
740      p_argument       => 'effective_date',
741      p_argument_value => p_effective_date);
742   if g_debug then
743      hr_utility.set_location(l_proc, 20);
744   end if;
745   --
746   l_effective_date := trunc(p_effective_date);
747   --
748   begin
749     --
750     -- Start of API User Hook for the before hook of create_personal_pay_method
751     --
752     hr_personal_pay_method_bk1.create_personal_pay_method_b
753       (p_effective_date                => l_effective_date
754       ,p_assignment_id                 => p_assignment_id
755       ,p_org_payment_method_id         => p_org_payment_method_id
756       ,p_amount                        => p_amount
757       ,p_percentage                    => p_percentage
758       ,p_priority                      => p_priority
759       ,p_comments                      => p_comments
760       ,p_attribute_category            => p_attribute_category
761       ,p_attribute1                    => p_attribute1
762       ,p_attribute2                    => p_attribute2
763       ,p_attribute3                    => p_attribute3
764       ,p_attribute4                    => p_attribute4
765       ,p_attribute5                    => p_attribute5
766       ,p_attribute6                    => p_attribute6
767       ,p_attribute7                    => p_attribute7
768       ,p_attribute8                    => p_attribute8
769       ,p_attribute9                    => p_attribute9
770       ,p_attribute10                   => p_attribute10
771       ,p_attribute11                   => p_attribute11
772       ,p_attribute12                   => p_attribute12
773       ,p_attribute13                   => p_attribute13
774       ,p_attribute14                   => p_attribute14
775       ,p_attribute15                   => p_attribute15
776       ,p_attribute16                   => p_attribute16
777       ,p_attribute17                   => p_attribute17
778       ,p_attribute18                   => p_attribute18
779       ,p_attribute19                   => p_attribute19
780       ,p_attribute20                   => p_attribute20
781       ,p_territory_code                => p_territory_code
782       ,p_segment1                      => p_segment1
783       ,p_segment2                      => p_segment2
784       ,p_segment3                      => p_segment3
785 --    ,p_segment4                      => lpad(p_segment4,9,'0')
786       ,p_segment4                      => p_segment4
787       ,p_segment5                      => p_segment5
788       ,p_segment6                      => p_segment6
789       ,p_segment7                      => p_segment7
790       ,p_segment8                      => p_segment8
791       ,p_segment9                      => p_segment9
792       ,p_segment10                     => p_segment10
793       ,p_segment11                     => p_segment11
794       ,p_segment12                     => p_segment12
795       ,p_segment13                     => p_segment13
796       ,p_segment14                     => p_segment14
797       ,p_segment15                     => p_segment15
798       ,p_segment16                     => p_segment16
799       ,p_segment17                     => p_segment17
800       ,p_segment18                     => p_segment18
801       ,p_segment19                     => p_segment19
802       ,p_segment20                     => p_segment20
803       ,p_segment21                     => p_segment21
804       ,p_segment22                     => p_segment22
805       ,p_segment23                     => p_segment23
806       ,p_segment24                     => p_segment24
807       ,p_segment25                     => p_segment25
808       ,p_segment26                     => p_segment26
809       ,p_segment27                     => p_segment27
810       ,p_segment28                     => p_segment28
811       ,p_segment29                     => p_segment29
812       ,p_segment30                     => p_segment30
813       ,p_payee_type                    => p_payee_type
814       ,p_payee_id                      => p_payee_id
815       ,p_ppm_information1              => p_ppm_information1
816       ,p_ppm_information2              => p_ppm_information2
817       ,p_ppm_information3              => p_ppm_information3
818       ,p_ppm_information4              => p_ppm_information4
819       ,p_ppm_information5              => p_ppm_information5
820       ,p_ppm_information6              => p_ppm_information6
821       ,p_ppm_information7              => p_ppm_information7
822       ,p_ppm_information8              => p_ppm_information8
823       ,p_ppm_information9              => p_ppm_information9
824       ,p_ppm_information10             => p_ppm_information10
825       ,p_ppm_information11             => p_ppm_information11
826       ,p_ppm_information12             => p_ppm_information12
827       ,p_ppm_information13             => p_ppm_information13
828       ,p_ppm_information14             => p_ppm_information14
829       ,p_ppm_information15             => p_ppm_information15
830       ,p_ppm_information16             => p_ppm_information16
831       ,p_ppm_information17             => p_ppm_information17
832       ,p_ppm_information18             => p_ppm_information18
833       ,p_ppm_information19             => p_ppm_information19
834       ,p_ppm_information20             => p_ppm_information20
835       ,p_ppm_information21             => p_ppm_information21
836       ,p_ppm_information22             => p_ppm_information22
837       ,p_ppm_information23             => p_ppm_information23
838       ,p_ppm_information24             => p_ppm_information24
839       ,p_ppm_information25             => p_ppm_information25
840       ,p_ppm_information26             => p_ppm_information26
841       ,p_ppm_information27             => p_ppm_information27
842       ,p_ppm_information28             => p_ppm_information28
843       ,p_ppm_information29             => p_ppm_information29
844       ,p_ppm_information30             => p_ppm_information30
845       );
846   exception
847     when hr_api.cannot_find_prog_unit then
848       hr_api.cannot_find_prog_unit_error
849         (p_module_name => 'CREATE_PERSONAL_PAY_METHOD'
850         ,p_hook_type   => 'BP'
851         );
852     --
853     -- End of API User Hook for the before hook of create_personal_pay_method
854     --
855   end;
856   --
857   -- Derive the business group id, using the assignment id.
858   --
859   open bgsel;
860   fetch bgsel
861   into l_business_group_id;
862   if g_debug then
863      hr_utility.set_location(l_proc, 30);
864   end if;
865   --
866   if bgsel%notfound then
867     close bgsel;
868     hr_utility.set_message(801, 'HR_7348_ASSIGNMENT_INVALID');
869     Hr_utility.raise_error;
870   end if;
871   close bgsel;
872   if g_debug then
873      hr_utility.set_location(l_proc, 40);
874   end if;
875   --
876   -- Validate the organization payment method
877   --
878   open csr_is_valid;
879   fetch csr_is_valid into l_exists;
880   if csr_is_valid%notfound then
881     close csr_is_valid;
882 
883     hr_utility.set_message(801, 'HR_7347_PPM_INVALID_PAY_TYPE');
884     hr_utility.raise_error;
885   end if;
886   close csr_is_valid;
887   if g_debug then
888      hr_utility.set_location(l_proc, 40);
889   end if;
890   --
891   -- Bug 3940935. Derive PPM_INFORMATION_CATEGORY.
892   --
893   if ((p_ppm_information1 is not null or
894       p_ppm_information2 is not null or
895       p_ppm_information3 is not null or
896       p_ppm_information4 is not null or
897       p_ppm_information5 is not null or
898       p_ppm_information6 is not null or
899       p_ppm_information7 is not null or
900       p_ppm_information8 is not null or
901       p_ppm_information9 is not null or
902       p_ppm_information10 is not null or
903       p_ppm_information11 is not null or
904       p_ppm_information12 is not null or
905       p_ppm_information13 is not null or
906       p_ppm_information14 is not null or
907       p_ppm_information15 is not null or
908       p_ppm_information16 is not null or
909       p_ppm_information17 is not null or
910       p_ppm_information18 is not null or
911       p_ppm_information19 is not null or
912       p_ppm_information20 is not null or
913       p_ppm_information21 is not null or
914       p_ppm_information22 is not null or
915       p_ppm_information23 is not null or
916       p_ppm_information24 is not null or
917       p_ppm_information25 is not null or
918       p_ppm_information26 is not null or
919       p_ppm_information27 is not null or
920       p_ppm_information28 is not null or
921       p_ppm_information29 is not null or
922       p_ppm_information30 is not null   ) and
923       p_ppm_information_category is null) then  --6439573
924 
925       open csr_ppm_info_category ( p_org_payment_method_id => p_org_payment_method_id
926                                   ,p_effective_date => p_effective_date );
927 
928       fetch csr_ppm_info_category into l_ppm_information_category;
929       if (csr_ppm_info_category%notfound) then
930          close csr_ppm_info_category;
931          fnd_message.set_name('PAY', 'HR_7462_PLK_INVLD_VALUE');
932          fnd_message.set_token('COLUMN_NAME', 'PPM_INFORMATION_CATEGORY');
933          fnd_message.raise_error;
934       end if;
935       close csr_ppm_info_category;
936   /* Bug 6439573 ppm_info_category is not null, then assigned to the local one */
937   elsif p_ppm_information_category is not null then
938       l_ppm_information_category := p_ppm_information_category;
939   end if;
940   --
941   -- Check that if payment type of the organization payment method
942   -- is not 'MT' then all external account details should be null.
943   --
944   open csr_chk_pay_type;
945   fetch csr_chk_pay_type into l_category;
946   close csr_chk_pay_type;
947   --
948   if (l_category <> 'MT' or l_category is null)
949     and (p_segment1  is not null or
950          p_segment2  is not null or
951          p_segment3  is not null or
952          p_segment4  is not null or
953          p_segment5  is not null or
954          p_segment6  is not null or
955          p_segment7  is not null or
956          p_segment8  is not null or
957          p_segment9  is not null or
958          p_segment10 is not null or
959          p_segment11 is not null or
960          p_segment12 is not null or
961          p_segment13 is not null or
962          p_segment14 is not null or
963          p_segment15 is not null or
964          p_segment16 is not null or
965          p_segment17 is not null or
966          p_segment18 is not null or
967          p_segment19 is not null or
968          p_segment20 is not null or
969          p_segment21 is not null or
970          p_segment22 is not null or
971          p_segment23 is not null or
972          p_segment24 is not null or
973          p_segment25 is not null or
974          p_segment26 is not null or
975          p_segment27 is not null or
976          p_segment28 is not null or
977          p_segment29 is not null or
978          p_segment30 is not null ) then
979   --
980   --  Raise Error
981       hr_utility.set_message(801, 'HR_51377_PPM_NON_MAG_TAPE_SEGM');
982       hr_utility.raise_error;
983   --
984   elsif l_category = 'MT' then
985     --
986   if g_debug then
987      hr_utility.set_location(l_proc, 50);
988   end if;
989     --
990     -- call table handler pay_exa_ins to control the processing of the external
991     -- account combination keyflex, discarding the returning parameter
992     -- p_object_version_number
993     --
994     pay_exa_ins.ins_or_sel
995     (p_segment1              => p_segment1
996     ,p_segment2              => p_segment2
997     ,p_segment3              => p_segment3
998 --  ,p_segment4              => lpad(p_segment4,9,'0')
999     ,p_segment4              => p_segment4
1000     ,p_segment5              => p_segment5
1001     ,p_segment6              => p_segment6
1002     ,p_segment7              => p_segment7
1003     ,p_segment8              => p_segment8
1004     ,p_segment9              => p_segment9
1005     ,p_segment10             => p_segment10
1006     ,p_segment11             => p_segment11
1007     ,p_segment12             => p_segment12
1008     ,p_segment13             => p_segment13
1009     ,p_segment14             => p_segment14
1010     ,p_segment15             => p_segment15
1011     ,p_segment16             => p_segment16
1012     ,p_segment17             => p_segment17
1013     ,p_segment18             => p_segment18
1014     ,p_segment19             => p_segment19
1015     ,p_segment20             => p_segment20
1016     ,p_segment21             => p_segment21
1017     ,p_segment22             => p_segment22
1018     ,p_segment23             => p_segment23
1019     ,p_segment24             => p_segment24
1020     ,p_segment25             => p_segment25
1021     ,p_segment26             => p_segment26
1022     ,p_segment27             => p_segment27
1023     ,p_segment28             => p_segment28
1024     ,p_segment29             => p_segment29
1025     ,p_segment30             => p_segment30
1026 /** sbilling **/
1027     ,p_concat_segments       => p_concat_segments
1028     ,p_business_group_id     => l_business_group_id
1029     ,p_territory_code        => p_territory_code
1030     ,p_external_account_id   => l_external_account_id
1031     ,p_object_version_number => l_exa_ovn
1032     ,p_validate              => l_validate
1033     --
1034     -- Special p_prenote_date value after bug2307154 changes.
1035     --
1036     ,p_prenote_date          => hr_api.g_date
1037     );
1038   end if;
1039   --
1040   if g_debug then
1041      hr_utility.set_location(l_proc, 60);
1042   end if;
1043   --
1044   -- Call the row handler to insert the personal payment method.
1045   --
1046   pay_ppm_ins.ins
1047   (p_personal_payment_method_id   => l_personal_payment_method_id
1048   ,p_effective_start_date         => l_effective_start_date
1049   ,p_effective_end_date           => l_effective_end_date
1050   ,p_business_group_id            => l_business_group_id
1051   ,p_external_account_id          => l_external_account_id
1052   ,p_assignment_id                => p_assignment_id
1053   ,p_run_type_id                  => p_run_type_id
1054   ,p_org_payment_method_id        => p_org_payment_method_id
1055   ,p_amount                       => p_amount
1056   ,p_comment_id                   => l_comment_id
1057   ,p_comments                     => p_comments
1058   ,p_percentage                   => p_percentage
1059   ,p_priority                     => p_priority
1060   ,p_attribute_category           => p_attribute_category
1061   ,p_attribute1                   => p_attribute1
1062   ,p_attribute2                   => p_attribute2
1063   ,p_attribute3                   => p_attribute3
1064   ,p_attribute4                   => p_attribute4
1065   ,p_attribute5                   => p_attribute5
1066   ,p_attribute6                   => p_attribute6
1067   ,p_attribute7                   => p_attribute7
1068   ,p_attribute8                   => p_attribute8
1069   ,p_attribute9                   => p_attribute9
1070   ,p_attribute10                  => p_attribute10
1071   ,p_attribute11                  => p_attribute11
1072   ,p_attribute12                  => p_attribute12
1073   ,p_attribute13                  => p_attribute13
1074   ,p_attribute14                  => p_attribute14
1075   ,p_attribute15                  => p_attribute15
1076   ,p_attribute16                  => p_attribute16
1077   ,p_attribute17                  => p_attribute17
1078   ,p_attribute18                  => p_attribute18
1079   ,p_attribute19                  => p_attribute19
1080   ,p_attribute20                  => p_attribute20
1081   ,p_object_version_number        => l_object_version_number
1082   ,p_payee_type                   => p_payee_type
1083   ,p_payee_id                     => p_payee_id
1084   ,p_effective_date               => l_effective_date
1085   ,p_validate                     => l_validate
1086   ,p_ppm_information_category     => l_ppm_information_category
1087   ,p_ppm_information1             => p_ppm_information1
1088   ,p_ppm_information2             => p_ppm_information2
1089   ,p_ppm_information3             => p_ppm_information3
1090   ,p_ppm_information4             => p_ppm_information4
1091   ,p_ppm_information5             => p_ppm_information5
1092   ,p_ppm_information6             => p_ppm_information6
1093   ,p_ppm_information7             => p_ppm_information7
1094   ,p_ppm_information8             => p_ppm_information8
1095   ,p_ppm_information9             => p_ppm_information9
1096   ,p_ppm_information10            => p_ppm_information10
1097   ,p_ppm_information11            => p_ppm_information11
1098   ,p_ppm_information12            => p_ppm_information12
1099   ,p_ppm_information13            => p_ppm_information13
1100   ,p_ppm_information14            => p_ppm_information14
1101   ,p_ppm_information15            => p_ppm_information15
1102   ,p_ppm_information16            => p_ppm_information16
1103   ,p_ppm_information17            => p_ppm_information17
1104   ,p_ppm_information18            => p_ppm_information18
1105   ,p_ppm_information19            => p_ppm_information19
1106   ,p_ppm_information20            => p_ppm_information20
1107   ,p_ppm_information21            => p_ppm_information21
1108   ,p_ppm_information22            => p_ppm_information22
1109   ,p_ppm_information23            => p_ppm_information23
1110   ,p_ppm_information24            => p_ppm_information24
1111   ,p_ppm_information25            => p_ppm_information25
1112   ,p_ppm_information26            => p_ppm_information26
1113   ,p_ppm_information27            => p_ppm_information27
1114   ,p_ppm_information28            => p_ppm_information28
1115   ,p_ppm_information29            => p_ppm_information29
1116   ,p_ppm_information30            => p_ppm_information30
1117   );
1118   --
1119   -- Stamp the prenote_date on the external accounts row for 'US' magtape
1120   -- payments only.
1121   --
1122   if g_debug then
1123      hr_utility.set_location(l_proc, 65);
1124   end if;
1125   if p_territory_code = 'US' and l_category = 'MT' then
1126     stamp_prenote_date
1127     (p_personal_payment_method_id => l_personal_payment_method_id
1128     ,p_effective_date             => l_effective_date
1129     ,p_external_account_id        => l_external_account_id
1130     ,p_external_account_ovn       => l_exa_ovn
1131     );
1132   end if;
1133   --
1134   if g_debug then
1135      hr_utility.set_location(l_proc, 70);
1136   end if;
1137   --
1138   begin
1139     --
1140     -- Start of API User Hook for the after hook of create_personal_pay_method
1141     --
1142     hr_personal_pay_method_bk1.create_personal_pay_method_a
1143       (p_effective_date                => l_effective_date
1144       ,p_assignment_id                 => p_assignment_id
1145       ,p_org_payment_method_id         => p_org_payment_method_id
1146       ,p_amount                        => p_amount
1147       ,p_percentage                    => p_percentage
1148       ,p_priority                      => p_priority
1149       ,p_comments                      => p_comments
1150       ,p_attribute_category            => p_attribute_category
1151       ,p_attribute1                    => p_attribute1
1152       ,p_attribute2                    => p_attribute2
1153       ,p_attribute3                    => p_attribute3
1154       ,p_attribute4                    => p_attribute4
1155       ,p_attribute5                    => p_attribute5
1156       ,p_attribute6                    => p_attribute6
1157       ,p_attribute7                    => p_attribute7
1158       ,p_attribute8                    => p_attribute8
1159       ,p_attribute9                    => p_attribute9
1160       ,p_attribute10                   => p_attribute10
1161       ,p_attribute11                   => p_attribute11
1162       ,p_attribute12                   => p_attribute12
1163       ,p_attribute13                   => p_attribute13
1164       ,p_attribute14                   => p_attribute14
1165       ,p_attribute15                   => p_attribute15
1166       ,p_attribute16                   => p_attribute16
1167       ,p_attribute17                   => p_attribute17
1168       ,p_attribute18                   => p_attribute18
1169       ,p_attribute19                   => p_attribute19
1170       ,p_attribute20                   => p_attribute20
1171       ,p_territory_code                => p_territory_code
1172       ,p_segment1                      => p_segment1
1173       ,p_segment2                      => p_segment2
1174       ,p_segment3                      => p_segment3
1175 --    ,p_segment4                      => lpad(p_segment4,9,'0')
1176       ,p_segment4                      => p_segment4
1177       ,p_segment5                      => p_segment5
1178       ,p_segment6                      => p_segment6
1179       ,p_segment7                      => p_segment7
1180       ,p_segment8                      => p_segment8
1181       ,p_segment9                      => p_segment9
1182       ,p_segment10                     => p_segment10
1183       ,p_segment11                     => p_segment11
1184       ,p_segment12                     => p_segment12
1185       ,p_segment13                     => p_segment13
1186       ,p_segment14                     => p_segment14
1187       ,p_segment15                     => p_segment15
1188       ,p_segment16                     => p_segment16
1189       ,p_segment17                     => p_segment17
1190       ,p_segment18                     => p_segment18
1191       ,p_segment19                     => p_segment19
1192       ,p_segment20                     => p_segment20
1193       ,p_segment21                     => p_segment21
1194       ,p_segment22                     => p_segment22
1195       ,p_segment23                     => p_segment23
1196       ,p_segment24                     => p_segment24
1197       ,p_segment25                     => p_segment25
1198       ,p_segment26                     => p_segment26
1199       ,p_segment27                     => p_segment27
1200       ,p_segment28                     => p_segment28
1201       ,p_segment29                     => p_segment29
1202       ,p_segment30                     => p_segment30
1203       ,p_payee_type                    => p_payee_type
1204       ,p_payee_id                      => p_payee_id
1205       ,p_personal_payment_method_id    => l_personal_payment_method_id
1206       ,p_external_account_id           => l_external_account_id
1207       ,p_object_version_number         => l_object_version_number
1208       ,p_effective_start_date          => l_effective_start_date
1209       ,p_effective_end_date            => l_effective_end_date
1210       ,p_comment_id                    => l_comment_id
1211       ,p_ppm_information1              => p_ppm_information1
1212       ,p_ppm_information2              => p_ppm_information2
1213       ,p_ppm_information3              => p_ppm_information3
1214       ,p_ppm_information4              => p_ppm_information4
1215       ,p_ppm_information5              => p_ppm_information5
1216       ,p_ppm_information6              => p_ppm_information6
1217       ,p_ppm_information7              => p_ppm_information7
1218       ,p_ppm_information8              => p_ppm_information8
1219       ,p_ppm_information9              => p_ppm_information9
1220       ,p_ppm_information10             => p_ppm_information10
1221       ,p_ppm_information11             => p_ppm_information11
1222       ,p_ppm_information12             => p_ppm_information12
1223       ,p_ppm_information13             => p_ppm_information13
1224       ,p_ppm_information14             => p_ppm_information14
1225       ,p_ppm_information15             => p_ppm_information15
1226       ,p_ppm_information16             => p_ppm_information16
1227       ,p_ppm_information17             => p_ppm_information17
1228       ,p_ppm_information18             => p_ppm_information18
1229       ,p_ppm_information19             => p_ppm_information19
1230       ,p_ppm_information20             => p_ppm_information20
1231       ,p_ppm_information21             => p_ppm_information21
1232       ,p_ppm_information22             => p_ppm_information22
1233       ,p_ppm_information23             => p_ppm_information23
1234       ,p_ppm_information24             => p_ppm_information24
1235       ,p_ppm_information25             => p_ppm_information25
1236       ,p_ppm_information26             => p_ppm_information26
1237       ,p_ppm_information27             => p_ppm_information27
1238       ,p_ppm_information28             => p_ppm_information28
1239       ,p_ppm_information29             => p_ppm_information29
1240       ,p_ppm_information30             => p_ppm_information30
1241       );
1242   exception
1243     when hr_api.cannot_find_prog_unit then
1244       hr_api.cannot_find_prog_unit_error
1245         (p_module_name => 'CREATE_PERSONAL_PAY_METHOD'
1246         ,p_hook_type   => 'AP'
1247         );
1248     --
1249     -- End of API User Hook for the after hook of create_personal_pay_method
1250     --
1251   end;
1252   --
1253   -- When in validation only mode raise the Validate_Enabled exception
1254   --
1255   if p_validate then
1256     raise hr_api.validate_enabled;
1257   end if;
1258   --
1259   -- Set remaining output arguments
1260   --
1261   p_personal_payment_method_id    := l_personal_payment_method_id;
1262   p_external_account_id           := l_external_account_id;
1263   p_object_version_number         := l_object_version_number;
1264   p_effective_start_date          := l_effective_start_date;
1265   p_effective_end_date            := l_effective_end_date;
1266   p_comment_id                    := l_comment_id;
1267   --
1268   if g_debug then
1269      hr_utility.set_location(' Leaving:'||l_proc, 80);
1270   end if;
1271 exception
1272   when hr_api.validate_enabled then
1273     --
1274     -- As the Validate_Enabled exception has been raised
1275     -- we must rollback to the savepoint
1276     --
1277     ROLLBACK TO create_personal_pay_method;
1278     --
1279     -- Only set output warning arguments
1280     -- (Any key or derived arguments must be set to null
1281     -- when validation only mode is being used.)
1282     --
1283     p_personal_payment_method_id := null;
1284     p_external_account_id := null;
1285     p_object_version_number  := null;
1286     p_effective_start_date := null;
1287     p_effective_end_date := null;
1288     p_comment_id := null;
1289     --
1290   when others then
1291     --
1292     -- A validation or unexpected error has occurred
1293     --
1294     -- Added as part of fix to bug 632479
1295     --
1296     ROLLBACK TO create_personal_pay_method;
1297     p_personal_payment_method_id := null;
1298     p_external_account_id := null;
1299     p_object_version_number  := null;
1300     p_effective_start_date := null;
1301     p_effective_end_date := null;
1302     p_comment_id := null;
1303     raise;
1304     --
1305     -- End of fix.
1306     --
1307   if g_debug then
1308      hr_utility.set_location(' Leaving:'||l_proc, 90);
1309   end if;
1310     --
1311 end create_personal_pay_method;
1312 --
1313 -- ----------------------------------------------------------------------------
1314 -- |--------------------< create_gb_personal_pay_method >---------------------|
1315 -- ----------------------------------------------------------------------------
1316 --
1317 procedure create_gb_personal_pay_method
1318   (p_validate                      in     boolean  default false
1319   ,p_effective_date                in     date
1320   ,p_assignment_id                 in     number
1321   ,p_run_type_id                   in     number  default null
1322   ,p_org_payment_method_id         in     number
1323   ,p_account_name                  in     varchar2
1324   ,p_account_number                in     varchar2
1325   ,p_sort_code                     in     varchar2
1326   ,p_bank_name                     in     varchar2
1327   ,p_account_type                  in     varchar2 default null
1328   ,p_bank_branch                   in     varchar2 default null
1329   ,p_bank_branch_location          in     varchar2 default null
1330   ,p_bldg_society_account_number   in     varchar2 default null
1331   ,p_amount                        in     number   default null
1332   ,p_percentage                    in     number   default null
1333   ,p_priority                      in     number   default null
1334   ,p_comments                      in     varchar2 default null
1335   ,p_attribute_category            in     varchar2 default null
1336   ,p_attribute1                    in     varchar2 default null
1337   ,p_attribute2                    in     varchar2 default null
1338   ,p_attribute3                    in     varchar2 default null
1339   ,p_attribute4                    in     varchar2 default null
1340   ,p_attribute5                    in     varchar2 default null
1341   ,p_attribute6                    in     varchar2 default null
1342   ,p_attribute7                    in     varchar2 default null
1343   ,p_attribute8                    in     varchar2 default null
1344   ,p_attribute9                    in     varchar2 default null
1345   ,p_attribute10                   in     varchar2 default null
1346   ,p_attribute11                   in     varchar2 default null
1347   ,p_attribute12                   in     varchar2 default null
1348   ,p_attribute13                   in     varchar2 default null
1349   ,p_attribute14                   in     varchar2 default null
1350   ,p_attribute15                   in     varchar2 default null
1351   ,p_attribute16                   in     varchar2 default null
1352   ,p_attribute17                   in     varchar2 default null
1353   ,p_attribute18                   in     varchar2 default null
1354   ,p_attribute19                   in     varchar2 default null
1355   ,p_attribute20                   in     varchar2 default null
1356   ,p_payee_type                    in     varchar2 default null
1357   ,p_payee_id                      in     number   default null
1358   ,p_territory_code                in     varchar2 default null      -- Bug 6469439
1359   ,p_personal_payment_method_id    out    nocopy number
1360   ,p_external_account_id           out    nocopy number
1361   ,p_object_version_number         out    nocopy number
1362   ,p_effective_start_date          out    nocopy date
1363   ,p_effective_end_date            out    nocopy date
1364   ,p_comment_id                    out    nocopy number
1365   ,p_segment9                      in     varchar2 default null -- Bug 7185344
1366   ,p_segment10                     in     varchar2 default null
1367   ,p_segment11                     in     varchar2 default null
1368   ,p_segment12                     in     varchar2 default null
1369   ,p_segment13                     in     varchar2 default null
1370   ,p_segment14                     in     varchar2 default null
1371   ,p_segment15                     in     varchar2 default null
1372   ,p_segment16                     in     varchar2 default null
1373   ,p_segment17                     in     varchar2 default null
1374   ,p_segment18                     in     varchar2 default null
1375   ,p_segment19                     in     varchar2 default null
1376   ,p_segment20                     in     varchar2 default null
1377   ,p_segment21                     in     varchar2 default null
1378   ,p_segment22                     in     varchar2 default null
1379   ,p_segment23                     in     varchar2 default null
1380   ,p_segment24                     in     varchar2 default null
1381   ,p_segment25                     in     varchar2 default null
1382   ,p_segment26                     in     varchar2 default null
1383   ,p_segment27                     in     varchar2 default null
1384   ,p_segment28                     in     varchar2 default null
1385   ,p_segment29                     in     varchar2 default null
1386   ,p_segment30                     in     varchar2 default null -- Bug 7185344
1387   ) is
1388   --
1389   -- Declare cursors and local variables
1390   --
1391   l_proc                varchar2(72);
1392   l_valid               varchar2(150);
1393   l_effective_date      date;
1394   l_territory_code      varchar2(30);
1395   --
1396 begin
1397   g_debug := hr_utility.debug_enabled;
1398   --
1399   if g_debug then
1400      l_proc := g_package||'create_gb_personal_pay_method';
1401      hr_utility.set_location('Entering:'|| l_proc, 5);
1402   end if;
1403   --
1404   l_effective_date := p_effective_date;
1405   --
1406   hr_personal_pay_method_api.check_insert_legislation
1407   (p_assignment_id   => p_assignment_id
1408   ,p_effective_date  => l_effective_date
1409   ,p_leg_code        => 'GB');
1410   --
1411   if g_debug then
1412      hr_utility.set_location(l_proc, 7);
1413   end if;
1414   --
1415   if p_territory_code is null then
1416      l_territory_code := 'GB';
1417   else
1418      l_territory_code := p_territory_code;
1419   end if;
1420   --
1421   -- Call the business process to create the personal payment method
1422   --
1423   hr_personal_pay_method_api.create_personal_pay_method
1424   (p_validate                      => p_validate
1425   ,p_effective_date                => l_effective_date
1426   ,p_assignment_id                 => p_assignment_id
1427   ,p_run_type_id                   => p_run_type_id
1428   ,p_org_payment_method_id         => p_org_payment_method_id
1429   ,p_amount                        => p_amount
1430   ,p_percentage                    => p_percentage
1431   ,p_priority                      => p_priority
1432   ,p_comments                      => p_comments
1433   ,p_attribute_category            => p_attribute_category
1434   ,p_attribute1                    => p_attribute1
1435   ,p_attribute2                    => p_attribute2
1436   ,p_attribute3                    => p_attribute3
1437   ,p_attribute4                    => p_attribute4
1438   ,p_attribute5                    => p_attribute5
1439   ,p_attribute6                    => p_attribute6
1440   ,p_attribute7                    => p_attribute7
1441   ,p_attribute8                    => p_attribute8
1442   ,p_attribute9                    => p_attribute9
1443   ,p_attribute10                   => p_attribute10
1444   ,p_attribute11                   => p_attribute11
1445   ,p_attribute12                   => p_attribute12
1446   ,p_attribute13                   => p_attribute13
1447   ,p_attribute14                   => p_attribute14
1448   ,p_attribute15                   => p_attribute15
1449   ,p_attribute16                   => p_attribute16
1450   ,p_attribute17                   => p_attribute17
1451   ,p_attribute18                   => p_attribute18
1452   ,p_attribute19                   => p_attribute19
1453   ,p_attribute20                   => p_attribute20
1454   ,p_territory_code                => l_territory_code   --6469439
1455   ,p_segment1                      => p_bank_name
1456   ,p_segment2                      => p_bank_branch
1457   ,p_segment3                      => p_sort_code
1458   ,p_segment4                      => p_account_number
1459   ,p_segment5                      => p_account_name
1460   ,p_segment6                      => p_account_type
1461   ,p_segment7                      => p_bldg_society_account_number
1462   ,p_segment8                      => p_bank_branch_location
1463   ,p_payee_type                    => p_payee_type
1464   ,p_payee_id                      => p_payee_id
1465   ,p_personal_payment_method_id    => p_personal_payment_method_id
1466   ,p_external_account_id           => p_external_account_id
1467   ,p_object_version_number         => p_object_version_number
1468   ,p_effective_start_date          => p_effective_start_date
1469   ,p_effective_end_date            => p_effective_end_date
1470   ,p_comment_id                    => p_comment_id
1471   ,p_segment9                      => p_segment9    -- Bug 7185344
1472   ,p_segment10                     => p_segment10
1473   ,p_segment11                     => p_segment11
1474   ,p_segment12                     => p_segment12
1475   ,p_segment13                     => p_segment13
1476   ,p_segment14                     => p_segment14
1477   ,p_segment15                     => p_segment15
1478   ,p_segment16                     => p_segment16
1479   ,p_segment17                     => p_segment17
1480   ,p_segment18                     => p_segment18
1481   ,p_segment19                     => p_segment19
1482   ,p_segment20                     => p_segment20
1483   ,p_segment21                     => p_segment21
1484   ,p_segment22                     => p_segment22
1485   ,p_segment23                     => p_segment23
1486   ,p_segment24                     => p_segment24
1487   ,p_segment25                     => p_segment25
1488   ,p_segment26                     => p_segment26
1489   ,p_segment27                     => p_segment27
1490   ,p_segment28                     => p_segment28
1491   ,p_segment29                     => p_segment29
1492   ,p_segment30                     => p_segment30   -- Bug 7185344
1493   );
1494   --
1495   if g_debug then
1496      hr_utility.set_location(' Leaving:'||l_proc, 8);
1497   end if;
1498 end create_gb_personal_pay_method;
1499 --
1500 -- ----------------------------------------------------------------------------
1501 -- |--------------------< create_us_personal_pay_method >---------------------|
1502 -- ----------------------------------------------------------------------------
1503 --
1504 procedure create_us_personal_pay_method
1505   (p_validate                      in     boolean  default false
1506   ,p_effective_date                in     date
1507   ,p_assignment_id                 in     number
1508   ,p_run_type_id                   in     number  default null
1509   ,p_org_payment_method_id         in     number
1510   ,p_account_name                  in     varchar2
1511   ,p_account_number                in     varchar2
1512   ,p_transit_code                  in     varchar2
1513   ,p_bank_name                     in     varchar2
1514   ,p_account_type                  in     varchar2 default null
1515   ,p_bank_branch                   in     varchar2 default null
1516   ,p_amount                        in     number   default null
1517   ,p_percentage                    in     number   default null
1518   ,p_priority                      in     number   default null
1519   ,p_comments                      in     varchar2 default null
1520   ,p_attribute_category            in     varchar2 default null
1521   ,p_attribute1                    in     varchar2 default null
1522   ,p_attribute2                    in     varchar2 default null
1523   ,p_attribute3                    in     varchar2 default null
1524   ,p_attribute4                    in     varchar2 default null
1525   ,p_attribute5                    in     varchar2 default null
1526   ,p_attribute6                    in     varchar2 default null
1527   ,p_attribute7                    in     varchar2 default null
1528   ,p_attribute8                    in     varchar2 default null
1529   ,p_attribute9                    in     varchar2 default null
1530   ,p_attribute10                   in     varchar2 default null
1531   ,p_attribute11                   in     varchar2 default null
1532   ,p_attribute12                   in     varchar2 default null
1533   ,p_attribute13                   in     varchar2 default null
1534   ,p_attribute14                   in     varchar2 default null
1535   ,p_attribute15                   in     varchar2 default null
1536   ,p_attribute16                   in     varchar2 default null
1537   ,p_attribute17                   in     varchar2 default null
1538   ,p_attribute18                   in     varchar2 default null
1539   ,p_attribute19                   in     varchar2 default null
1540   ,p_attribute20                   in     varchar2 default null
1541   ,p_payee_type                    in     varchar2 default null
1542   ,p_payee_id                      in     number   default null
1543   ,p_prenote_date                  in     date     default null
1544   ,p_territory_code                in     varchar2 default null      -- Bug 6469439
1545   ,p_personal_payment_method_id    out    nocopy number
1546   ,p_external_account_id           out    nocopy number
1547   ,p_object_version_number         out    nocopy number
1548   ,p_effective_start_date          out    nocopy date
1549   ,p_effective_end_date            out    nocopy date
1550   ,p_comment_id                    out    nocopy number
1551   ) is
1552   --
1553   -- Declare cursors and local variables
1554   --
1555   l_proc                varchar2(72);
1556   l_valid               varchar2(150);
1557   l_effective_date      date;
1558   l_territory_code      varchar2(30);
1559   --
1560 begin
1561   g_debug := hr_utility.debug_enabled;
1562   if g_debug then
1563      l_proc := g_package||'create_us_personal_pay_method';
1564      hr_utility.set_location('Entering:'|| l_proc, 5);
1565   end if;
1566   --
1567   l_effective_date := p_effective_date;
1568   --
1569   --
1570   hr_personal_pay_method_api.check_insert_legislation
1571   (p_assignment_id   => p_assignment_id
1572   ,p_effective_date  => l_effective_date
1573   ,p_leg_code        => 'US');
1574   --
1575   if g_debug then
1576      hr_utility.set_location(l_proc, 7);
1577   end if;
1578   --
1579   if p_territory_code is null then
1580      l_territory_code := 'US';
1581   else
1582      l_territory_code := p_territory_code;
1583   end if;
1584   --
1585   -- Call the business process to create the personal payment method
1586   --
1587   hr_personal_pay_method_api.create_personal_pay_method
1588   (p_validate                      => p_validate
1589   ,p_effective_date                => l_effective_date
1590   ,p_assignment_id                 => p_assignment_id
1591   ,p_run_type_id                   => p_run_type_id
1592   ,p_org_payment_method_id         => p_org_payment_method_id
1593   ,p_amount                        => p_amount
1594   ,p_percentage                    => p_percentage
1595   ,p_priority                      => p_priority
1596   ,p_comments                      => p_comments
1597   ,p_attribute_category            => p_attribute_category
1598   ,p_attribute1                    => p_attribute1
1599   ,p_attribute2                    => p_attribute2
1600   ,p_attribute3                    => p_attribute3
1601   ,p_attribute4                    => p_attribute4
1602   ,p_attribute5                    => p_attribute5
1603   ,p_attribute6                    => p_attribute6
1604   ,p_attribute7                    => p_attribute7
1605   ,p_attribute8                    => p_attribute8
1606   ,p_attribute9                    => p_attribute9
1607   ,p_attribute10                   => p_attribute10
1608   ,p_attribute11                   => p_attribute11
1609   ,p_attribute12                   => p_attribute12
1610   ,p_attribute13                   => p_attribute13
1611   ,p_attribute14                   => p_attribute14
1612   ,p_attribute15                   => p_attribute15
1613   ,p_attribute16                   => p_attribute16
1614   ,p_attribute17                   => p_attribute17
1615   ,p_attribute18                   => p_attribute18
1616   ,p_attribute19                   => p_attribute19
1617   ,p_attribute20                   => p_attribute20
1618   ,p_territory_code                => l_territory_code   --6469439
1619   ,p_segment1                      => p_account_name
1620   ,p_segment2                      => p_account_type
1621   ,p_segment3                      => p_account_number
1622   ,p_segment4                      => lpad(p_transit_code,9,'0')
1623   ,p_segment5                      => p_bank_name
1624   ,p_segment6                      => p_bank_branch
1625   ,p_payee_type                    => p_payee_type
1626   ,p_payee_id                      => p_payee_id
1627   ,p_personal_payment_method_id    => p_personal_payment_method_id
1628   ,p_external_account_id           => p_external_account_id
1629   ,p_object_version_number         => p_object_version_number
1630   ,p_effective_start_date          => p_effective_start_date
1631   ,p_effective_end_date            => p_effective_end_date
1632   ,p_comment_id                    => p_comment_id
1633   );
1634   --
1635   -- Update prenote date if external account is generated.
1636   --
1637   if p_prenote_date is not null and p_external_account_id is not null then
1638     --
1639     upd_prenote_date
1640       (p_personal_payment_method_id => p_personal_payment_method_id
1641       ,p_external_account_id        => p_external_account_id
1642       ,p_effective_date             => l_effective_date
1643       ,p_prenote_date               => p_prenote_date);
1644     --
1645   end if;
1646   --
1647   if g_debug then
1648      hr_utility.set_location(' Leaving:'||l_proc, 10);
1649   end if;
1650 end create_us_personal_pay_method;
1651 --
1652 -- ----------------------------------------------------------------------------
1653 -- |--------------------< create_ca_personal_pay_method >---------------------|
1654 -- ----------------------------------------------------------------------------
1655 --
1656 procedure create_ca_personal_pay_method
1657   (p_validate                      in     boolean  default false
1658   ,p_effective_date                in     date
1659   ,p_assignment_id                 in     number
1660   ,p_run_type_id                   in     number  default null
1661   ,p_org_payment_method_id         in     number
1662   ,p_account_name                  in     varchar2
1663   ,p_account_number                in     varchar2
1664   ,p_transit_code                  in     varchar2
1665   ,p_bank_name                     in     varchar2
1666   ,p_bank_number                   in     varchar2
1667   ,p_account_type                  in     varchar2 default null
1668   ,p_bank_branch                   in     varchar2 default null
1669   ,p_amount                        in     number   default null
1670   ,p_percentage                    in     number   default null
1671   ,p_priority                      in     number   default null
1672   ,p_comments                      in     varchar2 default null
1673   ,p_attribute_category            in     varchar2 default null
1674   ,p_attribute1                    in     varchar2 default null
1675   ,p_attribute2                    in     varchar2 default null
1676   ,p_attribute3                    in     varchar2 default null
1677   ,p_attribute4                    in     varchar2 default null
1678   ,p_attribute5                    in     varchar2 default null
1679   ,p_attribute6                    in     varchar2 default null
1680   ,p_attribute7                    in     varchar2 default null
1681   ,p_attribute8                    in     varchar2 default null
1682   ,p_attribute9                    in     varchar2 default null
1683   ,p_attribute10                   in     varchar2 default null
1684   ,p_attribute11                   in     varchar2 default null
1685   ,p_attribute12                   in     varchar2 default null
1686   ,p_attribute13                   in     varchar2 default null
1687   ,p_attribute14                   in     varchar2 default null
1688   ,p_attribute15                   in     varchar2 default null
1689   ,p_attribute16                   in     varchar2 default null
1690   ,p_attribute17                   in     varchar2 default null
1691   ,p_attribute18                   in     varchar2 default null
1692   ,p_attribute19                   in     varchar2 default null
1693   ,p_attribute20                   in     varchar2 default null
1694   ,p_payee_type                    in     varchar2 default null
1695   ,p_payee_id                      in     number   default null
1696   ,p_territory_code                in     varchar2 default null      -- Bug 6469439
1697   ,p_personal_payment_method_id    out    nocopy number
1698   ,p_external_account_id           out    nocopy number
1699   ,p_object_version_number         out    nocopy number
1700   ,p_effective_start_date          out    nocopy date
1701   ,p_effective_end_date            out    nocopy date
1702   ,p_comment_id                    out    nocopy number
1703   ) is
1704   --
1705   -- Declare cursors and local variables
1706   --
1707   l_proc                varchar2(72);
1708   l_valid               varchar2(150);
1709   l_effective_date      date;
1710   l_territory_code      varchar2(30);
1711   --
1712 begin
1713   g_debug := hr_utility.debug_enabled;
1714   if g_debug then
1715      l_proc := g_package||'create_ca_personal_pay_method';
1716      hr_utility.set_location('Entering:'|| l_proc, 5);
1717   end if;
1718   --
1719   l_effective_date := p_effective_date;
1720   --
1721   --
1722   hr_personal_pay_method_api.check_insert_legislation
1723   (p_assignment_id   => p_assignment_id
1724   ,p_effective_date  => l_effective_date
1725   ,p_leg_code        => 'CA');
1726   --
1727   if g_debug then
1728      hr_utility.set_location(l_proc, 7);
1729   end if;
1730   --
1731   if p_territory_code is null then
1732      l_territory_code := 'CA';
1733   else
1734      l_territory_code := p_territory_code;
1735   end if;
1736   --
1737   -- Call the business process to create the personal payment method
1738   --
1739   hr_personal_pay_method_api.create_personal_pay_method
1740   (p_validate                      => p_validate
1741   ,p_effective_date                => l_effective_date
1742   ,p_assignment_id                 => p_assignment_id
1743   ,p_run_type_id                   => p_run_type_id
1744   ,p_org_payment_method_id         => p_org_payment_method_id
1745   ,p_amount                        => p_amount
1746   ,p_percentage                    => p_percentage
1747   ,p_priority                      => p_priority
1748   ,p_comments                      => p_comments
1749   ,p_attribute_category            => p_attribute_category
1750   ,p_attribute1                    => p_attribute1
1751   ,p_attribute2                    => p_attribute2
1752   ,p_attribute3                    => p_attribute3
1753   ,p_attribute4                    => p_attribute4
1754   ,p_attribute5                    => p_attribute5
1755   ,p_attribute6                    => p_attribute6
1756   ,p_attribute7                    => p_attribute7
1757   ,p_attribute8                    => p_attribute8
1758   ,p_attribute9                    => p_attribute9
1759   ,p_attribute10                   => p_attribute10
1760   ,p_attribute11                   => p_attribute11
1761   ,p_attribute12                   => p_attribute12
1762   ,p_attribute13                   => p_attribute13
1763   ,p_attribute14                   => p_attribute14
1764   ,p_attribute15                   => p_attribute15
1765   ,p_attribute16                   => p_attribute16
1766   ,p_attribute17                   => p_attribute17
1767   ,p_attribute18                   => p_attribute18
1768   ,p_attribute19                   => p_attribute19
1769   ,p_attribute20                   => p_attribute20
1770   ,p_territory_code                => l_territory_code   --6469439
1771   ,p_segment1                      => p_account_name
1772   ,p_segment2                      => p_account_type
1773   ,p_segment3                      => p_account_number
1774   ,p_segment4                      => lpad(p_transit_code,5,'0')
1775   ,p_segment5                      => p_bank_name
1776   ,p_segment6                      => p_bank_branch
1777   ,p_segment7                      => p_bank_number
1778   ,p_payee_type                    => p_payee_type
1779   ,p_payee_id                      => p_payee_id
1780   ,p_personal_payment_method_id    => p_personal_payment_method_id
1781   ,p_external_account_id           => p_external_account_id
1782   ,p_object_version_number         => p_object_version_number
1783   ,p_effective_start_date          => p_effective_start_date
1784   ,p_effective_end_date            => p_effective_end_date
1785   ,p_comment_id                    => p_comment_id
1786   );
1787   --
1788   if g_debug then
1789      hr_utility.set_location(' Leaving:'||l_proc, 8);
1790   end if;
1791 end create_ca_personal_pay_method;
1792 --
1793 -- ----------------------------------------------------------------------------
1794 -- |----------------------< update_personal_pay_method >----------------------|
1795 -- ----------------------------------------------------------------------------
1796 --
1797 procedure update_personal_pay_method
1798   (p_validate                      in     boolean  default false
1799   ,p_effective_date                in     date
1800   ,p_datetrack_update_mode         in     varchar2
1801   ,p_personal_payment_method_id    in     number
1802   ,p_object_version_number         in out nocopy number
1803   ,p_amount                        in     number   default hr_api.g_number
1804   ,p_comments                      in     varchar2 default hr_api.g_varchar2
1805   ,p_percentage                    in     number   default hr_api.g_number
1806   ,p_priority                      in     number   default hr_api.g_number
1807   ,p_attribute_category            in     varchar2 default hr_api.g_varchar2
1808   ,p_attribute1                    in     varchar2 default hr_api.g_varchar2
1809   ,p_attribute2                    in     varchar2 default hr_api.g_varchar2
1810   ,p_attribute3                    in     varchar2 default hr_api.g_varchar2
1811   ,p_attribute4                    in     varchar2 default hr_api.g_varchar2
1812   ,p_attribute5                    in     varchar2 default hr_api.g_varchar2
1813   ,p_attribute6                    in     varchar2 default hr_api.g_varchar2
1814   ,p_attribute7                    in     varchar2 default hr_api.g_varchar2
1815   ,p_attribute8                    in     varchar2 default hr_api.g_varchar2
1816   ,p_attribute9                    in     varchar2 default hr_api.g_varchar2
1817   ,p_attribute10                   in     varchar2 default hr_api.g_varchar2
1818   ,p_attribute11                   in     varchar2 default hr_api.g_varchar2
1819   ,p_attribute12                   in     varchar2 default hr_api.g_varchar2
1820   ,p_attribute13                   in     varchar2 default hr_api.g_varchar2
1821   ,p_attribute14                   in     varchar2 default hr_api.g_varchar2
1822   ,p_attribute15                   in     varchar2 default hr_api.g_varchar2
1823   ,p_attribute16                   in     varchar2 default hr_api.g_varchar2
1824   ,p_attribute17                   in     varchar2 default hr_api.g_varchar2
1825   ,p_attribute18                   in     varchar2 default hr_api.g_varchar2
1826   ,p_attribute19                   in     varchar2 default hr_api.g_varchar2
1827   ,p_attribute20                   in     varchar2 default hr_api.g_varchar2
1828   ,p_territory_code                in     varchar2 default hr_api.g_varchar2
1829   ,p_segment1                      in     varchar2 default hr_api.g_varchar2
1830   ,p_segment2                      in     varchar2 default hr_api.g_varchar2
1831   ,p_segment3                      in     varchar2 default hr_api.g_varchar2
1832   ,p_segment4                      in     varchar2 default hr_api.g_varchar2
1833   ,p_segment5                      in     varchar2 default hr_api.g_varchar2
1834   ,p_segment6                      in     varchar2 default hr_api.g_varchar2
1835   ,p_segment7                      in     varchar2 default hr_api.g_varchar2
1836   ,p_segment8                      in     varchar2 default hr_api.g_varchar2
1837   ,p_segment9                      in     varchar2 default hr_api.g_varchar2
1838   ,p_segment10                     in     varchar2 default hr_api.g_varchar2
1839   ,p_segment11                     in     varchar2 default hr_api.g_varchar2
1840   ,p_segment12                     in     varchar2 default hr_api.g_varchar2
1841   ,p_segment13                     in     varchar2 default hr_api.g_varchar2
1842   ,p_segment14                     in     varchar2 default hr_api.g_varchar2
1843   ,p_segment15                     in     varchar2 default hr_api.g_varchar2
1844   ,p_segment16                     in     varchar2 default hr_api.g_varchar2
1845   ,p_segment17                     in     varchar2 default hr_api.g_varchar2
1846   ,p_segment18                     in     varchar2 default hr_api.g_varchar2
1847   ,p_segment19                     in     varchar2 default hr_api.g_varchar2
1848   ,p_segment20                     in     varchar2 default hr_api.g_varchar2
1849   ,p_segment21                     in     varchar2 default hr_api.g_varchar2
1850   ,p_segment22                     in     varchar2 default hr_api.g_varchar2
1851   ,p_segment23                     in     varchar2 default hr_api.g_varchar2
1852   ,p_segment24                     in     varchar2 default hr_api.g_varchar2
1853   ,p_segment25                     in     varchar2 default hr_api.g_varchar2
1854   ,p_segment26                     in     varchar2 default hr_api.g_varchar2
1855   ,p_segment27                     in     varchar2 default hr_api.g_varchar2
1856   ,p_segment28                     in     varchar2 default hr_api.g_varchar2
1857   ,p_segment29                     in     varchar2 default hr_api.g_varchar2
1858   ,p_segment30                     in     varchar2 default hr_api.g_varchar2
1859 /** sbilling **/
1860   ,p_concat_segments               in     varchar2 default null
1861   ,p_payee_type                    in     varchar2 default hr_api.g_varchar2
1862   ,p_payee_id                      in     number   default hr_api.g_number
1863   ,p_ppm_information_category      in     varchar2 default hr_api.g_varchar2  --Bug 6439573
1864   ,p_ppm_information1              in     varchar2 default hr_api.g_varchar2
1865   ,p_ppm_information2              in     varchar2 default hr_api.g_varchar2
1866   ,p_ppm_information3              in     varchar2 default hr_api.g_varchar2
1867   ,p_ppm_information4              in     varchar2 default hr_api.g_varchar2
1868   ,p_ppm_information5              in     varchar2 default hr_api.g_varchar2
1869   ,p_ppm_information6              in     varchar2 default hr_api.g_varchar2
1870   ,p_ppm_information7              in     varchar2 default hr_api.g_varchar2
1871   ,p_ppm_information8              in     varchar2 default hr_api.g_varchar2
1872   ,p_ppm_information9              in     varchar2 default hr_api.g_varchar2
1873   ,p_ppm_information10             in     varchar2 default hr_api.g_varchar2
1874   ,p_ppm_information11             in     varchar2 default hr_api.g_varchar2
1875   ,p_ppm_information12             in     varchar2 default hr_api.g_varchar2
1876   ,p_ppm_information13             in     varchar2 default hr_api.g_varchar2
1877   ,p_ppm_information14             in     varchar2 default hr_api.g_varchar2
1878   ,p_ppm_information15             in     varchar2 default hr_api.g_varchar2
1879   ,p_ppm_information16             in     varchar2 default hr_api.g_varchar2
1880   ,p_ppm_information17             in     varchar2 default hr_api.g_varchar2
1881   ,p_ppm_information18             in     varchar2 default hr_api.g_varchar2
1882   ,p_ppm_information19             in     varchar2 default hr_api.g_varchar2
1883   ,p_ppm_information20             in     varchar2 default hr_api.g_varchar2
1884   ,p_ppm_information21             in     varchar2 default hr_api.g_varchar2
1885   ,p_ppm_information22             in     varchar2 default hr_api.g_varchar2
1886   ,p_ppm_information23             in     varchar2 default hr_api.g_varchar2
1887   ,p_ppm_information24             in     varchar2 default hr_api.g_varchar2
1888   ,p_ppm_information25             in     varchar2 default hr_api.g_varchar2
1889   ,p_ppm_information26             in     varchar2 default hr_api.g_varchar2
1890   ,p_ppm_information27             in     varchar2 default hr_api.g_varchar2
1891   ,p_ppm_information28             in     varchar2 default hr_api.g_varchar2
1892   ,p_ppm_information29             in     varchar2 default hr_api.g_varchar2
1893   ,p_ppm_information30             in     varchar2 default hr_api.g_varchar2
1894   ,p_comment_id                    out nocopy    number
1895   ,p_external_account_id           out nocopy    number
1896   ,p_effective_start_date          out nocopy    date
1897   ,p_effective_end_date            out nocopy    date
1898   ) is
1899   --
1900   -- Declare cursors and local variables
1901   --
1902   --
1903   l_proc               varchar2(72);
1904   l_business_group_id  per_assignments_f.business_group_id%TYPE;
1905   l_validate           boolean := FALSE;
1906   l_external_account_id
1907                        pay_personal_payment_methods_f.external_account_id%TYPE;
1908   l_object_version_number
1909                        pay_external_accounts.object_version_number%TYPE;
1910   l_exa_ovn            number;
1911   l_effective_date     date;
1912   l_ppm_information_category pay_personal_payment_methods_f.ppm_information_category%TYPE;
1913   --
1914   -- Declare OUT variables
1915   --
1916   l_comment_id
1917                        pay_personal_payment_methods_f.comment_id%TYPE;
1918   l_effective_start_date
1919                        pay_personal_payment_methods_f.effective_start_date%TYPE;
1920   l_effective_end_date
1921                        pay_personal_payment_methods_f.effective_end_date%TYPE;
1922   l_category varchar(2000);
1923   l_territory_code varchar2(2000);
1924   l_exa_territory_code varchar2(2000);
1925   --
1926   cursor bgsel is
1927     select ppm.business_group_id,
1928            ppm.external_account_id
1929     from   pay_personal_payment_methods_f ppm
1930     where  ppm.personal_payment_method_id = p_personal_payment_method_id
1931     and    p_effective_date between ppm.effective_start_date
1932                             and     ppm.effective_end_date;
1933   --
1934   cursor ovnsel is
1935     select pea.object_version_number
1936     ,      pea.territory_code
1937     from pay_external_accounts pea
1938     where pea.external_account_id = l_external_account_id;
1939   --
1940   cursor csr_chk_pay_type is
1941   select pyt.category
1942   from pay_personal_payment_methods_f ppm
1943   ,    pay_org_payment_methods_f opm
1944   ,    pay_payment_types pyt
1945   where ppm.personal_payment_method_id = p_personal_payment_method_id
1946   and   p_effective_date between
1947         ppm.effective_start_date and ppm.effective_end_date
1948   and   opm.org_payment_method_id = ppm.org_payment_method_id
1949   and   p_effective_date between
1950         opm.effective_start_date and opm.effective_end_date
1951   and   opm.payment_type_id = pyt.payment_type_id
1952   ;
1953   --
1954   cursor csr_ppm_info_category ( p_personal_payment_method_id number,
1955                                  p_effective_date date) is
1956      select decode(ppt.territory_code,null,null,ppt.territory_code||'_')||UPPER(ppt.payment_type_name) ppm_information_category
1957        from pay_payment_types ppt,
1958             pay_org_payment_methods_f opm,
1959             pay_personal_payment_methods_f ppm
1960       where ppm.personal_payment_method_id = p_personal_payment_method_id
1961         and p_effective_date between ppm.effective_start_date and ppm.effective_end_date
1962         and opm.org_payment_method_id = ppm.org_payment_method_id
1963         and p_effective_date between opm.effective_start_date and opm.effective_end_date
1964         and opm.payment_type_id = ppt.payment_type_id;
1965   --
1966 --
1967 -- In Out parameter
1968 --
1969   l_object_version_number1        number;
1970 --
1971 begin
1972   g_debug := hr_utility.debug_enabled;
1973   if g_debug then
1974      l_proc := g_package||'update_personal_pay_method';
1975      hr_utility.set_location('Entering:'|| l_proc, 5);
1976   end if;
1977   --
1978   -- Assign in-out parameters to local variable
1979   -- and issue the savepoint.
1980   --
1981   l_object_version_number1 := p_object_version_number;
1982   --
1983   savepoint update_personal_pay_method;
1984   --
1985   --
1986   -- Check that p_personal_payment_method_id and p_effective_date are not null
1987   -- as they are used by the cursor to derive the business group.
1988   --
1989   hr_api.mandatory_arg_error
1990     (p_api_name       => l_proc,
1991      p_argument       => 'personal_payment_method_id',
1992      p_argument_value => p_personal_payment_method_id);
1993 
1994   hr_api.mandatory_arg_error
1995     (p_api_name       => l_proc,
1996      p_argument       => 'effective_date',
1997      p_argument_value => p_effective_date);
1998   --
1999   if g_debug then
2000      hr_utility.set_location(l_proc, 6);
2001   end if;
2002   --
2003   l_effective_date := trunc(p_effective_date);
2004   --
2005   begin
2006     --
2007     -- Start of API User Hook for the before hook of update_personal_pay_method
2008     --
2009     hr_personal_pay_method_bk2.update_personal_pay_method_b
2010       (p_effective_date                => l_effective_date
2011       ,p_datetrack_update_mode         => p_datetrack_update_mode
2012       ,p_personal_payment_method_id    => p_personal_payment_method_id
2013       ,p_object_version_number         => p_object_version_number
2014       ,p_amount                        => p_amount
2015       ,p_comments                      => p_comments
2016       ,p_percentage                    => p_percentage
2017       ,p_priority                      => p_priority
2018       ,p_attribute_category            => p_attribute_category
2019       ,p_attribute1                    => p_attribute1
2020       ,p_attribute2                    => p_attribute2
2021       ,p_attribute3                    => p_attribute3
2022       ,p_attribute4                    => p_attribute4
2023       ,p_attribute5                    => p_attribute5
2024       ,p_attribute6                    => p_attribute6
2025       ,p_attribute7                    => p_attribute7
2026       ,p_attribute8                    => p_attribute8
2027       ,p_attribute9                    => p_attribute9
2028       ,p_attribute10                   => p_attribute10
2029       ,p_attribute11                   => p_attribute11
2030       ,p_attribute12                   => p_attribute12
2031       ,p_attribute13                   => p_attribute13
2032       ,p_attribute14                   => p_attribute14
2033       ,p_attribute15                   => p_attribute15
2034       ,p_attribute16                   => p_attribute16
2035       ,p_attribute17                   => p_attribute17
2036       ,p_attribute18                   => p_attribute18
2037       ,p_attribute19                   => p_attribute19
2038       ,p_attribute20                   => p_attribute20
2039       ,p_territory_code                => p_territory_code
2040       ,p_segment1                      => p_segment1
2041       ,p_segment2                      => p_segment2
2042       ,p_segment3                      => p_segment3
2043 --    ,p_segment4                      => lpad(p_segment4,9,'0')
2044       ,p_segment4                      => p_segment4
2045       ,p_segment5                      => p_segment5
2046       ,p_segment6                      => p_segment6
2047       ,p_segment7                      => p_segment7
2048       ,p_segment8                      => p_segment8
2049       ,p_segment9                      => p_segment9
2050       ,p_segment10                     => p_segment10
2051       ,p_segment11                     => p_segment11
2052       ,p_segment12                     => p_segment12
2053       ,p_segment13                     => p_segment13
2054       ,p_segment14                     => p_segment14
2055       ,p_segment15                     => p_segment15
2056       ,p_segment16                     => p_segment16
2057       ,p_segment17                     => p_segment17
2058       ,p_segment18                     => p_segment18
2059       ,p_segment19                     => p_segment19
2060       ,p_segment20                     => p_segment20
2061       ,p_segment21                     => p_segment21
2062       ,p_segment22                     => p_segment22
2063       ,p_segment23                     => p_segment23
2064       ,p_segment24                     => p_segment24
2065       ,p_segment25                     => p_segment25
2066       ,p_segment26                     => p_segment26
2067       ,p_segment27                     => p_segment27
2068       ,p_segment28                     => p_segment28
2069       ,p_segment29                     => p_segment29
2070       ,p_segment30                     => p_segment30
2071       ,p_payee_type                    => p_payee_type
2072       ,p_payee_id                      => p_payee_id
2073       ,p_ppm_information1              => p_ppm_information1
2074       ,p_ppm_information2              => p_ppm_information2
2075       ,p_ppm_information3              => p_ppm_information3
2076       ,p_ppm_information4              => p_ppm_information4
2077       ,p_ppm_information5              => p_ppm_information5
2078       ,p_ppm_information6              => p_ppm_information6
2079       ,p_ppm_information7              => p_ppm_information7
2080       ,p_ppm_information8              => p_ppm_information8
2081       ,p_ppm_information9              => p_ppm_information9
2082       ,p_ppm_information10             => p_ppm_information10
2083       ,p_ppm_information11             => p_ppm_information11
2084       ,p_ppm_information12             => p_ppm_information12
2085       ,p_ppm_information13             => p_ppm_information13
2086       ,p_ppm_information14             => p_ppm_information14
2087       ,p_ppm_information15             => p_ppm_information15
2088       ,p_ppm_information16             => p_ppm_information16
2089       ,p_ppm_information17             => p_ppm_information17
2090       ,p_ppm_information18             => p_ppm_information18
2091       ,p_ppm_information19             => p_ppm_information19
2092       ,p_ppm_information20             => p_ppm_information20
2093       ,p_ppm_information21             => p_ppm_information21
2094       ,p_ppm_information22             => p_ppm_information22
2095       ,p_ppm_information23             => p_ppm_information23
2096       ,p_ppm_information24             => p_ppm_information24
2097       ,p_ppm_information25             => p_ppm_information25
2098       ,p_ppm_information26             => p_ppm_information26
2099       ,p_ppm_information27             => p_ppm_information27
2100       ,p_ppm_information28             => p_ppm_information28
2101       ,p_ppm_information29             => p_ppm_information29
2102       ,p_ppm_information30             => p_ppm_information30
2103       );
2104   exception
2105     when hr_api.cannot_find_prog_unit then
2106       hr_api.cannot_find_prog_unit_error
2107         (p_module_name => 'UPDATE_PERSONAL_PAY_METHOD'
2108         ,p_hook_type   => 'BP'
2109         );
2110     --
2111     -- End of API User Hook for the before hook of update_personal_pay_method
2112     --
2113   end;
2114   --
2115   -- Derive the business group id, using the personal payment method id.
2116   --
2117   open bgsel;
2118   fetch bgsel
2119   into l_business_group_id,
2120        l_external_account_id;
2121   --
2122   if bgsel%notfound then
2123     close bgsel;
2124     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
2125     Hr_utility.raise_error;
2126   end if;
2127   --
2128   close bgsel;
2129   --
2130   if l_external_account_id is not null then
2131     open ovnsel;
2132     fetch ovnsel
2133     into l_object_version_number
2134     ,    l_territory_code;
2135     if ovnsel%notfound then
2136       close ovnsel;
2137       --
2138       -- The external account primary key is invalid, so raise an error.
2139       --
2140       hr_utility.set_message(801, 'HR_51457_PPM_INVALID_OVN');
2141       hr_utility.raise_error;
2142     end if;
2143     close ovnsel;
2144   end if;
2145   --
2146   if g_debug then
2147      hr_utility.set_location(l_proc, 7);
2148   end if;
2149   --
2150   -- Check that if payment type of the organization payment method
2151   -- is not 'MT' then all external account details should be null.
2152   -- If the values have been defaulted then assume that the code is
2153   -- updating a valid record.
2154   --
2155   open csr_chk_pay_type;
2156   fetch csr_chk_pay_type into l_category;
2157   close csr_chk_pay_type;
2158   --
2159   if l_category <> 'MT'and
2160      (nvl(p_segment1, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2161       nvl(p_segment2, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2162       nvl(p_segment3, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2163       nvl(p_segment4, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2164       nvl(p_segment5, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2165       nvl(p_segment6, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2166       nvl(p_segment7, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2167       nvl(p_segment8, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2168       nvl(p_segment9, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2169       nvl(p_segment10, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2170       nvl(p_segment11, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2171       nvl(p_segment12, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2172       nvl(p_segment13, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2173       nvl(p_segment14, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2174       nvl(p_segment15, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2175       nvl(p_segment16, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2176       nvl(p_segment17, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2177       nvl(p_segment18, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2178       nvl(p_segment19, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2179       nvl(p_segment20, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2180       nvl(p_segment21, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2181       nvl(p_segment22, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2182       nvl(p_segment23, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2183       nvl(p_segment24, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2184       nvl(p_segment25, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2185       nvl(p_segment26, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2186       nvl(p_segment27, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2187       nvl(p_segment28, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2188       nvl(p_segment29, hr_api.g_varchar2) <> hr_api.g_varchar2 or
2189       nvl(p_segment30, hr_api.g_varchar2) <> hr_api.g_varchar2) then
2190    --
2191    --  Raise Error
2192    --
2193    hr_utility.set_message(801, 'HR_51377_PPM_NON_MAG_TAPE_SEGM');
2194    hr_utility.raise_error;
2195   --
2196   elsif l_category = 'MT' then
2197     --
2198     -- Call table handler pay_exa_upd to control the processing of the external
2199     -- account combination keyflex.
2200     --
2201 
2202     -- Bug #3829284. When territory code is defaulted with hr_api.g_varchar2
2203     -- pass the derived territory code.
2204 
2205     l_exa_territory_code := p_territory_code;
2206 
2207     if p_territory_code = hr_api.g_varchar2 then
2208 
2209         l_exa_territory_code := l_territory_code;
2210 
2211     end if;
2212 
2213     pay_exa_upd.upd_or_sel
2214     (p_segment1              => p_segment1
2215     ,p_segment2              => p_segment2
2216     ,p_segment3              => p_segment3
2217     ,p_segment4              => p_segment4
2218     ,p_segment5              => p_segment5
2219     ,p_segment6              => p_segment6
2220     ,p_segment7              => p_segment7
2221     ,p_segment8              => p_segment8
2222     ,p_segment9              => p_segment9
2223     ,p_segment10             => p_segment10
2224     ,p_segment11             => p_segment11
2225     ,p_segment12             => p_segment12
2226     ,p_segment13             => p_segment13
2227     ,p_segment14             => p_segment14
2228     ,p_segment15             => p_segment15
2229     ,p_segment16             => p_segment16
2230     ,p_segment17             => p_segment17
2231     ,p_segment18             => p_segment18
2232     ,p_segment19             => p_segment19
2233     ,p_segment20             => p_segment20
2234     ,p_segment21             => p_segment21
2235     ,p_segment22             => p_segment22
2236     ,p_segment23             => p_segment23
2237     ,p_segment24             => p_segment24
2238     ,p_segment25             => p_segment25
2239     ,p_segment26             => p_segment26
2240     ,p_segment27             => p_segment27
2241     ,p_segment28             => p_segment28
2242     ,p_segment29             => p_segment29
2243     ,p_segment30             => p_segment30
2244   /** sbilling **/
2245     ,p_concat_segments       => p_concat_segments
2246     ,p_business_group_id     => l_business_group_id
2247     ,p_territory_code        => l_exa_territory_code
2248     ,p_external_account_id   => l_external_account_id
2249     ,p_object_version_number => l_exa_ovn
2250     ,p_validate              => l_validate
2251     --
2252     -- Special p_prenote_date value after bug2307154 changes.
2253     --
2254     ,p_prenote_date          => hr_api.g_date
2255     );
2256   end if;
2257   --
2258   -- Bug 3940935. Derive PPM_INFORMATION_CATEGORY.
2259   --
2260   l_ppm_information_category := hr_api.g_varchar2;
2261 
2262   if ((p_ppm_information1 <> hr_api.g_varchar2 or
2263       p_ppm_information2 <> hr_api.g_varchar2 or
2264       p_ppm_information3 <> hr_api.g_varchar2 or
2265       p_ppm_information4 <> hr_api.g_varchar2 or
2266       p_ppm_information5 <> hr_api.g_varchar2 or
2267       p_ppm_information6 <> hr_api.g_varchar2 or
2268       p_ppm_information7 <> hr_api.g_varchar2 or
2269       p_ppm_information8 <> hr_api.g_varchar2 or
2270       p_ppm_information9 <> hr_api.g_varchar2 or
2271       p_ppm_information10 <> hr_api.g_varchar2 or
2272       p_ppm_information11 <> hr_api.g_varchar2 or
2273       p_ppm_information12 <> hr_api.g_varchar2 or
2274       p_ppm_information13 <> hr_api.g_varchar2 or
2275       p_ppm_information14 <> hr_api.g_varchar2 or
2276       p_ppm_information15 <> hr_api.g_varchar2 or
2277       p_ppm_information16 <> hr_api.g_varchar2 or
2278       p_ppm_information17 <> hr_api.g_varchar2 or
2279       p_ppm_information18 <> hr_api.g_varchar2 or
2280       p_ppm_information19 <> hr_api.g_varchar2 or
2281       p_ppm_information20 <> hr_api.g_varchar2 or
2282       p_ppm_information21 <> hr_api.g_varchar2 or
2283       p_ppm_information22 <> hr_api.g_varchar2 or
2284       p_ppm_information23 <> hr_api.g_varchar2 or
2285       p_ppm_information24 <> hr_api.g_varchar2 or
2286       p_ppm_information25 <> hr_api.g_varchar2 or
2287       p_ppm_information26 <> hr_api.g_varchar2 or
2288       p_ppm_information27 <> hr_api.g_varchar2 or
2289       p_ppm_information28 <> hr_api.g_varchar2 or
2290       p_ppm_information29 <> hr_api.g_varchar2 or
2291       p_ppm_information30 <> hr_api.g_varchar2   ) and
2292       p_ppm_information_category = hr_api.g_varchar2   )then  --6439573
2293 
2294       open csr_ppm_info_category ( p_personal_payment_method_id => p_personal_payment_method_id
2295                                   ,p_effective_date => p_effective_date );
2296 
2297       fetch csr_ppm_info_category into l_ppm_information_category;
2298       if (csr_ppm_info_category%notfound) then
2299          close csr_ppm_info_category;
2300          fnd_message.set_name('PAY', 'HR_7462_PLK_INVLD_VALUE');
2301          fnd_message.set_token('COLUMN_NAME', 'PPM_INFORMATION_CATEGORY');
2302          fnd_message.raise_error;
2303       end if;
2304       close csr_ppm_info_category;
2305   /* Bug 6439573 ppm_info_category is not null, then assigned to the local one */
2306   elsif p_ppm_information_category <> hr_api.g_varchar2 then
2307       l_ppm_information_category := p_ppm_information_category;
2308   end if;
2309   --
2310   if g_debug then
2311      hr_utility.set_location(l_proc, 8);
2312   end if;
2313   --
2314   -- Call the row handler to update the personal payment method.
2315   --
2316   pay_ppm_upd.upd
2317   (p_personal_payment_method_id   => p_personal_payment_method_id
2318   ,p_effective_start_date         => l_effective_start_date
2319   ,p_effective_end_date           => l_effective_end_date
2320   ,p_external_account_id          => l_external_account_id
2321   ,p_amount                       => p_amount
2322   ,p_comment_id                   => l_comment_id
2323   ,p_comments                     => p_comments
2324   ,p_percentage                   => p_percentage
2325   ,p_priority                     => p_priority
2326   ,p_attribute_category           => p_attribute_category
2327   ,p_attribute1                   => p_attribute1
2328   ,p_attribute2                   => p_attribute2
2329   ,p_attribute3                   => p_attribute3
2330   ,p_attribute4                   => p_attribute4
2331   ,p_attribute5                   => p_attribute5
2332   ,p_attribute6                   => p_attribute6
2333   ,p_attribute7                   => p_attribute7
2334   ,p_attribute8                   => p_attribute8
2335   ,p_attribute9                   => p_attribute9
2336   ,p_attribute10                  => p_attribute10
2337   ,p_attribute11                  => p_attribute11
2338   ,p_attribute12                  => p_attribute12
2339   ,p_attribute13                  => p_attribute13
2340   ,p_attribute14                  => p_attribute14
2341   ,p_attribute15                  => p_attribute15
2342   ,p_attribute16                  => p_attribute16
2343   ,p_attribute17                  => p_attribute17
2344   ,p_attribute18                  => p_attribute18
2345   ,p_attribute19                  => p_attribute19
2346   ,p_attribute20                  => p_attribute20
2347   ,p_object_version_number        => p_object_version_number
2348   ,p_payee_type                   => p_payee_type
2349   ,p_payee_id                     => p_payee_id
2350   ,p_effective_date               => l_effective_date
2351   ,p_datetrack_mode               => p_datetrack_update_mode
2352   ,p_validate                     => l_validate
2353   ,p_ppm_information_category     => l_ppm_information_category
2354   ,p_ppm_information1             => p_ppm_information1
2355   ,p_ppm_information2             => p_ppm_information2
2356   ,p_ppm_information3             => p_ppm_information3
2357   ,p_ppm_information4             => p_ppm_information4
2358   ,p_ppm_information5             => p_ppm_information5
2359   ,p_ppm_information6             => p_ppm_information6
2360   ,p_ppm_information7             => p_ppm_information7
2361   ,p_ppm_information8             => p_ppm_information8
2362   ,p_ppm_information9             => p_ppm_information9
2363   ,p_ppm_information10            => p_ppm_information10
2364   ,p_ppm_information11            => p_ppm_information11
2365   ,p_ppm_information12            => p_ppm_information12
2366   ,p_ppm_information13            => p_ppm_information13
2367   ,p_ppm_information14            => p_ppm_information14
2368   ,p_ppm_information15            => p_ppm_information15
2369   ,p_ppm_information16            => p_ppm_information16
2370   ,p_ppm_information17            => p_ppm_information17
2371   ,p_ppm_information18            => p_ppm_information18
2372   ,p_ppm_information19            => p_ppm_information19
2373   ,p_ppm_information20            => p_ppm_information20
2374   ,p_ppm_information21            => p_ppm_information21
2375   ,p_ppm_information22            => p_ppm_information22
2376   ,p_ppm_information23            => p_ppm_information23
2377   ,p_ppm_information24            => p_ppm_information24
2378   ,p_ppm_information25            => p_ppm_information25
2379   ,p_ppm_information26            => p_ppm_information26
2380   ,p_ppm_information27            => p_ppm_information27
2381   ,p_ppm_information28            => p_ppm_information28
2382   ,p_ppm_information29            => p_ppm_information29
2383   ,p_ppm_information30            => p_ppm_information30
2384   );
2385   --
2386   -- Stamp the prenote_date on the external accounts row for 'US' magtape
2387   -- payments only.
2388   --
2389   if g_debug then
2390      hr_utility.set_location(l_proc, 9);
2391   end if;
2392   if l_territory_code = 'US' and l_category = 'MT' then
2393     stamp_prenote_date
2394     (p_personal_payment_method_id => p_personal_payment_method_id
2395     ,p_effective_date             => l_effective_date
2396     ,p_external_account_id        => l_external_account_id
2397     ,p_external_account_ovn       => l_exa_ovn
2398     );
2399   end if;
2400   --
2401   if g_debug then
2402      hr_utility.set_location(l_proc, 10);
2403   end if;
2404   --
2405   begin
2406     --
2407     -- Start of API User Hook for the after hook of update_personal_pay_method
2408     --
2409     hr_personal_pay_method_bk2.update_personal_pay_method_a
2410       (p_effective_date                => l_effective_date
2411       ,p_datetrack_update_mode         => p_datetrack_update_mode
2412       ,p_personal_payment_method_id    => p_personal_payment_method_id
2413       ,p_object_version_number         => p_object_version_number
2414       ,p_amount                        => p_amount
2415       ,p_comments                      => p_comments
2416       ,p_percentage                    => p_percentage
2417       ,p_priority                      => p_priority
2418       ,p_attribute_category            => p_attribute_category
2419       ,p_attribute1                    => p_attribute1
2420       ,p_attribute2                    => p_attribute2
2421       ,p_attribute3                    => p_attribute3
2422       ,p_attribute4                    => p_attribute4
2423       ,p_attribute5                    => p_attribute5
2424       ,p_attribute6                    => p_attribute6
2425       ,p_attribute7                    => p_attribute7
2426       ,p_attribute8                    => p_attribute8
2427       ,p_attribute9                    => p_attribute9
2428       ,p_attribute10                   => p_attribute10
2429       ,p_attribute11                   => p_attribute11
2430       ,p_attribute12                   => p_attribute12
2431       ,p_attribute13                   => p_attribute13
2432       ,p_attribute14                   => p_attribute14
2433       ,p_attribute15                   => p_attribute15
2434       ,p_attribute16                   => p_attribute16
2435       ,p_attribute17                   => p_attribute17
2436       ,p_attribute18                   => p_attribute18
2437       ,p_attribute19                   => p_attribute19
2438       ,p_attribute20                   => p_attribute20
2439       ,p_territory_code                => p_territory_code
2440       ,p_segment1                      => p_segment1
2441       ,p_segment2                      => p_segment2
2442       ,p_segment3                      => p_segment3
2443 --    ,p_segment4                      => lpad(p_segment4,9,'0')
2444       ,p_segment4                      => p_segment4
2445       ,p_segment5                      => p_segment5
2446       ,p_segment6                      => p_segment6
2447       ,p_segment7                      => p_segment7
2448       ,p_segment8                      => p_segment8
2449       ,p_segment9                      => p_segment9
2450       ,p_segment10                     => p_segment10
2451       ,p_segment11                     => p_segment11
2452       ,p_segment12                     => p_segment12
2453       ,p_segment13                     => p_segment13
2454       ,p_segment14                     => p_segment14
2455       ,p_segment15                     => p_segment15
2456       ,p_segment16                     => p_segment16
2457       ,p_segment17                     => p_segment17
2458       ,p_segment18                     => p_segment18
2459       ,p_segment19                     => p_segment19
2460       ,p_segment20                     => p_segment20
2461       ,p_segment21                     => p_segment21
2462       ,p_segment22                     => p_segment22
2463       ,p_segment23                     => p_segment23
2464       ,p_segment24                     => p_segment24
2465       ,p_segment25                     => p_segment25
2466       ,p_segment26                     => p_segment26
2467       ,p_segment27                     => p_segment27
2468       ,p_segment28                     => p_segment28
2469       ,p_segment29                     => p_segment29
2470       ,p_segment30                     => p_segment30
2471       ,p_payee_type                    => p_payee_type
2472       ,p_payee_id                      => p_payee_id
2473       ,p_comment_id                    => l_comment_id
2474       ,p_external_account_id           => l_external_account_id
2475       ,p_effective_start_date          => l_effective_start_date
2476       ,p_effective_end_date            => l_effective_end_date
2477       ,p_ppm_information1              => p_ppm_information1
2478       ,p_ppm_information2              => p_ppm_information2
2479       ,p_ppm_information3              => p_ppm_information3
2480       ,p_ppm_information4              => p_ppm_information4
2481       ,p_ppm_information5              => p_ppm_information5
2482       ,p_ppm_information6              => p_ppm_information6
2483       ,p_ppm_information7              => p_ppm_information7
2484       ,p_ppm_information8              => p_ppm_information8
2485       ,p_ppm_information9              => p_ppm_information9
2486       ,p_ppm_information10             => p_ppm_information10
2487       ,p_ppm_information11             => p_ppm_information11
2488       ,p_ppm_information12             => p_ppm_information12
2489       ,p_ppm_information13             => p_ppm_information13
2490       ,p_ppm_information14             => p_ppm_information14
2491       ,p_ppm_information15             => p_ppm_information15
2492       ,p_ppm_information16             => p_ppm_information16
2493       ,p_ppm_information17             => p_ppm_information17
2494       ,p_ppm_information18             => p_ppm_information18
2495       ,p_ppm_information19             => p_ppm_information19
2496       ,p_ppm_information20             => p_ppm_information20
2497       ,p_ppm_information21             => p_ppm_information21
2498       ,p_ppm_information22             => p_ppm_information22
2499       ,p_ppm_information23             => p_ppm_information23
2500       ,p_ppm_information24             => p_ppm_information24
2501       ,p_ppm_information25             => p_ppm_information25
2502       ,p_ppm_information26             => p_ppm_information26
2503       ,p_ppm_information27             => p_ppm_information27
2504       ,p_ppm_information28             => p_ppm_information28
2505       ,p_ppm_information29             => p_ppm_information29
2506       ,p_ppm_information30             => p_ppm_information30
2507       );
2508   exception
2509     when hr_api.cannot_find_prog_unit then
2510       hr_api.cannot_find_prog_unit_error
2511         (p_module_name => 'UPDATE_PERSONAL_PAY_METHOD'
2512         ,p_hook_type   => 'AP'
2513         );
2514     --
2515     -- End of API User Hook for the after hook of update_personal_pay_method
2516     --
2517   end;
2518   --
2519   -- When in validation only mode raise the Validate_Enabled exception
2520   --
2521   if p_validate then
2522     raise hr_api.validate_enabled;
2523   end if;
2524   --
2525   -- Set remaining output arguments
2526   --
2527   p_comment_id                  := l_comment_id;
2528   p_external_account_id         := l_external_account_id;
2529   p_effective_start_date        := l_effective_start_date;
2530   p_effective_end_date          := l_effective_end_date;
2531   --
2532   if g_debug then
2533      hr_utility.set_location(' Leaving:'||l_proc, 10);
2534   end if;
2535   --
2536 exception
2537   when hr_api.validate_enabled then
2538     --
2539     -- As the Validate_Enabled exception has been raised
2540     -- we must rollback to the savepoint
2541     --
2542     ROLLBACK TO update_personal_pay_method;
2543     --
2544     -- Only set output warning arguments
2545     -- (Any key or derived arguments must be set to null
2546     -- when validation only mode is being used.)
2547     --
2548     p_object_version_number  := l_object_version_number1;
2549     p_comment_id := null;
2550     p_external_account_id := null;
2551     p_effective_start_date := null;
2552     p_effective_end_date := null;
2553     --
2554   when others then
2555     --
2556     -- A validation or unexpected error has occurred
2557     --
2558     -- Added as part of fix to bug 632479
2559     --
2560     ROLLBACK TO update_personal_pay_method;
2561     p_object_version_number  := l_object_version_number1;
2562     p_comment_id := null;
2563     p_external_account_id := null;
2564     p_effective_start_date := null;
2565     p_effective_end_date := null;
2566     raise;
2567     --
2568     -- End of fix.
2569     --
2570   if g_debug then
2571      hr_utility.set_location(' Leaving:'||l_proc, 11);
2572   end if;
2573 end update_personal_pay_method;
2574 --
2575 -- ----------------------------------------------------------------------------
2576 -- |--------------------< update_gb_personal_pay_method >---------------------|
2577 -- ----------------------------------------------------------------------------
2578 --
2579 procedure update_gb_personal_pay_method
2580   (p_validate                      in     boolean  default false
2581   ,p_effective_date                in     date
2582   ,p_datetrack_update_mode         in     varchar2
2583   ,p_personal_payment_method_id    in     number
2584   ,p_object_version_number         in out nocopy number
2585   ,p_account_name                  in     varchar2 default hr_api.g_varchar2
2586   ,p_account_number                in     varchar2 default hr_api.g_varchar2
2587   ,p_sort_code                     in     varchar2 default hr_api.g_varchar2
2588   ,p_bank_name                     in     varchar2 default hr_api.g_varchar2
2589   ,p_account_type                  in     varchar2 default hr_api.g_varchar2
2590   ,p_bank_branch                   in     varchar2 default hr_api.g_varchar2
2591   ,p_bank_branch_location          in     varchar2 default hr_api.g_varchar2
2592   ,p_bldg_society_account_number   in     varchar2 default hr_api.g_varchar2
2593   ,p_amount                        in     number   default hr_api.g_number
2594   ,p_comments                      in     varchar2 default hr_api.g_varchar2
2595   ,p_percentage                    in     number   default hr_api.g_number
2596   ,p_priority                      in     number   default hr_api.g_number
2597   ,p_attribute_category            in     varchar2 default hr_api.g_varchar2
2598   ,p_attribute1                    in     varchar2 default hr_api.g_varchar2
2599   ,p_attribute2                    in     varchar2 default hr_api.g_varchar2
2600   ,p_attribute3                    in     varchar2 default hr_api.g_varchar2
2601   ,p_attribute4                    in     varchar2 default hr_api.g_varchar2
2602   ,p_attribute5                    in     varchar2 default hr_api.g_varchar2
2603   ,p_attribute6                    in     varchar2 default hr_api.g_varchar2
2604   ,p_attribute7                    in     varchar2 default hr_api.g_varchar2
2605   ,p_attribute8                    in     varchar2 default hr_api.g_varchar2
2606   ,p_attribute9                    in     varchar2 default hr_api.g_varchar2
2607   ,p_attribute10                   in     varchar2 default hr_api.g_varchar2
2608   ,p_attribute11                   in     varchar2 default hr_api.g_varchar2
2609   ,p_attribute12                   in     varchar2 default hr_api.g_varchar2
2610   ,p_attribute13                   in     varchar2 default hr_api.g_varchar2
2611   ,p_attribute14                   in     varchar2 default hr_api.g_varchar2
2612   ,p_attribute15                   in     varchar2 default hr_api.g_varchar2
2613   ,p_attribute16                   in     varchar2 default hr_api.g_varchar2
2614   ,p_attribute17                   in     varchar2 default hr_api.g_varchar2
2615   ,p_attribute18                   in     varchar2 default hr_api.g_varchar2
2616   ,p_attribute19                   in     varchar2 default hr_api.g_varchar2
2617   ,p_attribute20                   in     varchar2 default hr_api.g_varchar2
2618   ,p_payee_type                    in     varchar2 default hr_api.g_varchar2
2619   ,p_payee_id                      in     number   default hr_api.g_number
2620   ,p_territory_code                in     varchar2 default hr_api.g_varchar2
2621   ,p_comment_id                    out    nocopy number
2622   ,p_external_account_id           out    nocopy number
2623   ,p_effective_start_date          out    nocopy date
2624   ,p_effective_end_date            out    nocopy date
2625   ,p_segment9                      in     varchar2 default null -- Bug 7185344
2626   ,p_segment10                     in     varchar2 default null
2627   ,p_segment11                     in     varchar2 default null
2628   ,p_segment12                     in     varchar2 default null
2629   ,p_segment13                     in     varchar2 default null
2630   ,p_segment14                     in     varchar2 default null
2631   ,p_segment15                     in     varchar2 default null
2632   ,p_segment16                     in     varchar2 default null
2633   ,p_segment17                     in     varchar2 default null
2634   ,p_segment18                     in     varchar2 default null
2635   ,p_segment19                     in     varchar2 default null
2636   ,p_segment20                     in     varchar2 default null
2637   ,p_segment21                     in     varchar2 default null
2638   ,p_segment22                     in     varchar2 default null
2639   ,p_segment23                     in     varchar2 default null
2640   ,p_segment24                     in     varchar2 default null
2641   ,p_segment25                     in     varchar2 default null
2642   ,p_segment26                     in     varchar2 default null
2643   ,p_segment27                     in     varchar2 default null
2644   ,p_segment28                     in     varchar2 default null
2645   ,p_segment29                     in     varchar2 default null
2646   ,p_segment30                     in     varchar2 default null -- Bug 7185344
2647   ) is
2648   --
2649   -- Declare cursors and local variables
2650   --
2651   l_proc                varchar2(72);
2652   --
2653 begin
2654   g_debug := hr_utility.debug_enabled;
2655   if g_debug then
2656      l_proc := g_package||'update_gb_personal_pay_method';
2657      hr_utility.set_location('Entering:'|| l_proc, 5);
2658   end if;
2659   --
2660   -- Ensure that the legislation rule for the employee assignment business
2661   -- group is 'GB'.
2662   --
2663   hr_personal_pay_method_api.check_update_legislation
2664   (p_personal_payment_method_id => p_personal_payment_method_id
2665   ,p_effective_date             => p_effective_date
2666   ,p_leg_code                   => 'GB');
2667   --
2668   if g_debug then
2669      hr_utility.set_location(l_proc, 6);
2670   end if;
2671   --
2672   -- Call the business process to update the personal payment method
2673   --
2674 hr_personal_pay_method_api.update_personal_pay_method
2675   (p_validate                      => p_validate
2676   ,p_effective_date                => trunc(p_effective_date)
2677   ,p_datetrack_update_mode         => p_datetrack_update_mode
2678   ,p_personal_payment_method_id    => p_personal_payment_method_id
2679   ,p_object_version_number         => p_object_version_number
2680   ,p_amount                        => p_amount
2681   ,p_comments                      => p_comments
2682   ,p_percentage                    => p_percentage
2683   ,p_priority                      => p_priority
2684   ,p_attribute_category            => p_attribute_category
2685   ,p_attribute1                    => p_attribute1
2686   ,p_attribute2                    => p_attribute2
2687   ,p_attribute3                    => p_attribute3
2688   ,p_attribute4                    => p_attribute4
2689   ,p_attribute5                    => p_attribute5
2690   ,p_attribute6                    => p_attribute6
2691   ,p_attribute7                    => p_attribute7
2692   ,p_attribute8                    => p_attribute8
2693   ,p_attribute9                    => p_attribute9
2694   ,p_attribute10                   => p_attribute10
2695   ,p_attribute11                   => p_attribute11
2696   ,p_attribute12                   => p_attribute12
2697   ,p_attribute13                   => p_attribute13
2698   ,p_attribute14                   => p_attribute14
2699   ,p_attribute15                   => p_attribute15
2700   ,p_attribute16                   => p_attribute16
2701   ,p_attribute17                   => p_attribute17
2702   ,p_attribute18                   => p_attribute18
2703   ,p_attribute19                   => p_attribute19
2704   ,p_attribute20                   => p_attribute20
2705   ,p_territory_code                => p_territory_code     --Bug 6469439
2706   ,p_segment1                      => p_bank_name
2707   ,p_segment2                      => p_bank_branch
2708   ,p_segment3                      => p_sort_code
2709   ,p_segment4                      => p_account_number
2710   ,p_segment5                      => p_account_name
2711   ,p_segment6                      => p_account_type
2712   ,p_segment7                      => p_bldg_society_account_number
2713   ,p_segment8                      => p_bank_branch_location
2714   ,p_payee_type                    => p_payee_type
2715   ,p_payee_id                      => p_payee_id
2716   ,p_comment_id                    => p_comment_id
2717   ,p_external_account_id           => p_external_account_id
2718   ,p_effective_start_date          => p_effective_start_date
2719   ,p_effective_end_date            => p_effective_end_date
2720   ,p_segment9                      => p_segment9    -- Bug 7185344
2721   ,p_segment10                     => p_segment10
2722   ,p_segment11                     => p_segment11
2723   ,p_segment12                     => p_segment12
2724   ,p_segment13                     => p_segment13
2725   ,p_segment14                     => p_segment14
2726   ,p_segment15                     => p_segment15
2727   ,p_segment16                     => p_segment16
2728   ,p_segment17                     => p_segment17
2729   ,p_segment18                     => p_segment18
2730   ,p_segment19                     => p_segment19
2731   ,p_segment20                     => p_segment20
2732   ,p_segment21                     => p_segment21
2733   ,p_segment22                     => p_segment22
2734   ,p_segment23                     => p_segment23
2735   ,p_segment24                     => p_segment24
2736   ,p_segment25                     => p_segment25
2737   ,p_segment26                     => p_segment26
2738   ,p_segment27                     => p_segment27
2739   ,p_segment28                     => p_segment28
2740   ,p_segment29                     => p_segment29
2741   ,p_segment30                     => p_segment30   -- Bug 7185344
2742   );
2743   --
2744   if g_debug then
2745      hr_utility.set_location(' Leaving:'||l_proc, 7);
2746   end if;
2747 end update_gb_personal_pay_method;
2748 --
2749 -- ----------------------------------------------------------------------------
2750 -- |--------------------< update_us_personal_pay_method >---------------------|
2751 -- ----------------------------------------------------------------------------
2752 --
2753 procedure update_us_personal_pay_method
2754   (p_validate                      in     boolean  default false
2755   ,p_effective_date                in     date
2756   ,p_datetrack_update_mode         in     varchar2
2757   ,p_personal_payment_method_id    in     number
2758   ,p_object_version_number         in out nocopy number
2759   ,p_account_name                  in     varchar2 default hr_api.g_varchar2
2760   ,p_account_number                in     varchar2 default hr_api.g_varchar2
2761   ,p_transit_code                  in     varchar2 default hr_api.g_varchar2
2762   ,p_bank_name                     in     varchar2 default hr_api.g_varchar2
2763   ,p_account_type                  in     varchar2 default hr_api.g_varchar2
2764   ,p_bank_branch                   in     varchar2 default hr_api.g_varchar2
2765   ,p_amount                        in     number   default hr_api.g_number
2766   ,p_comments                      in     varchar2 default hr_api.g_varchar2
2767   ,p_percentage                    in     number   default hr_api.g_number
2768   ,p_priority                      in     number   default hr_api.g_number
2769   ,p_attribute_category            in     varchar2 default hr_api.g_varchar2
2770   ,p_attribute1                    in     varchar2 default hr_api.g_varchar2
2771   ,p_attribute2                    in     varchar2 default hr_api.g_varchar2
2772   ,p_attribute3                    in     varchar2 default hr_api.g_varchar2
2773   ,p_attribute4                    in     varchar2 default hr_api.g_varchar2
2774   ,p_attribute5                    in     varchar2 default hr_api.g_varchar2
2775   ,p_attribute6                    in     varchar2 default hr_api.g_varchar2
2776   ,p_attribute7                    in     varchar2 default hr_api.g_varchar2
2777   ,p_attribute8                    in     varchar2 default hr_api.g_varchar2
2778   ,p_attribute9                    in     varchar2 default hr_api.g_varchar2
2779   ,p_attribute10                   in     varchar2 default hr_api.g_varchar2
2780   ,p_attribute11                   in     varchar2 default hr_api.g_varchar2
2781   ,p_attribute12                   in     varchar2 default hr_api.g_varchar2
2782   ,p_attribute13                   in     varchar2 default hr_api.g_varchar2
2783   ,p_attribute14                   in     varchar2 default hr_api.g_varchar2
2784   ,p_attribute15                   in     varchar2 default hr_api.g_varchar2
2785   ,p_attribute16                   in     varchar2 default hr_api.g_varchar2
2786   ,p_attribute17                   in     varchar2 default hr_api.g_varchar2
2787   ,p_attribute18                   in     varchar2 default hr_api.g_varchar2
2788   ,p_attribute19                   in     varchar2 default hr_api.g_varchar2
2789   ,p_attribute20                   in     varchar2 default hr_api.g_varchar2
2790   ,p_payee_type                    in     varchar2 default hr_api.g_varchar2
2791   ,p_payee_id                      in     number   default hr_api.g_number
2792   ,p_prenote_date                  in     date     default hr_api.g_date
2793   ,p_territory_code                in     varchar2 default hr_api.g_varchar2
2794   ,p_comment_id                    out    nocopy number
2795   ,p_external_account_id           out    nocopy number
2796   ,p_effective_start_date          out    nocopy date
2797   ,p_effective_end_date            out    nocopy date
2798   ) is
2799   --
2800   -- Declare cursors and local variables
2801   --
2802   l_proc                varchar2(72);
2803   --
2804 begin
2805   g_debug := hr_utility.debug_enabled;
2806   if g_debug then
2807      l_proc := g_package||'update_gb_personal_pay_method';
2808      hr_utility.set_location('Entering:'|| l_proc, 5);
2809   end if;
2810   --
2811   -- Ensure that the legislation rule for the employee assignment business
2812   -- group is 'US'.
2813   --
2814   hr_personal_pay_method_api.check_update_legislation
2815   (p_personal_payment_method_id => p_personal_payment_method_id
2816   ,p_effective_date             => p_effective_date
2817   ,p_leg_code                   => 'US');
2818   --
2819   if g_debug then
2820      hr_utility.set_location(l_proc, 6);
2821   end if;
2822   --
2823   -- Call the business process to update the personal payment method
2824   --
2825 hr_personal_pay_method_api.update_personal_pay_method
2826   (p_validate                      => p_validate
2827   ,p_effective_date                => trunc(p_effective_date)
2828   ,p_datetrack_update_mode         => p_datetrack_update_mode
2829   ,p_personal_payment_method_id    => p_personal_payment_method_id
2830   ,p_object_version_number         => p_object_version_number
2831   ,p_amount                        => p_amount
2832   ,p_comments                      => p_comments
2833   ,p_percentage                    => p_percentage
2834   ,p_priority                      => p_priority
2835   ,p_attribute_category            => p_attribute_category
2836   ,p_attribute1                    => p_attribute1
2837   ,p_attribute2                    => p_attribute2
2838   ,p_attribute3                    => p_attribute3
2839   ,p_attribute4                    => p_attribute4
2840   ,p_attribute5                    => p_attribute5
2841   ,p_attribute6                    => p_attribute6
2842   ,p_attribute7                    => p_attribute7
2843   ,p_attribute8                    => p_attribute8
2844   ,p_attribute9                    => p_attribute9
2845   ,p_attribute10                   => p_attribute10
2846   ,p_attribute11                   => p_attribute11
2847   ,p_attribute12                   => p_attribute12
2848   ,p_attribute13                   => p_attribute13
2849   ,p_attribute14                   => p_attribute14
2850   ,p_attribute15                   => p_attribute15
2851   ,p_attribute16                   => p_attribute16
2852   ,p_attribute17                   => p_attribute17
2853   ,p_attribute18                   => p_attribute18
2854   ,p_attribute19                   => p_attribute19
2855   ,p_attribute20                   => p_attribute20
2856   ,p_territory_code                => p_territory_code     --Bug 6469439
2857   ,p_segment1                      => p_account_name
2858   ,p_segment2                      => p_account_type
2859   ,p_segment3                      => p_account_number
2860   ,p_segment4                      => lpad(p_transit_code,9,'0')
2861   ,p_segment5                      => p_bank_name
2862   ,p_segment6                      => p_bank_branch
2863   ,p_payee_type                    => p_payee_type
2864   ,p_payee_id                      => p_payee_id
2865   ,p_comment_id                    => p_comment_id
2866   ,p_external_account_id           => p_external_account_id
2867   ,p_effective_start_date          => p_effective_start_date
2868   ,p_effective_end_date            => p_effective_end_date
2869   );
2870   --
2871   -- Update prenote date if external account is generated.
2872   --
2873   if nvl(p_prenote_date, hr_api.g_date+1) <> hr_api.g_date and p_external_account_id is not null then
2874     --
2875     upd_prenote_date
2876       (p_personal_payment_method_id => p_personal_payment_method_id
2877       ,p_external_account_id        => p_external_account_id
2878       ,p_effective_date             => p_effective_date
2879       ,p_prenote_date               => p_prenote_date);
2880     --
2881   end if;
2882   --
2883   if g_debug then
2884      hr_utility.set_location(' Leaving:'||l_proc, 7);
2885   end if;
2886 end update_us_personal_pay_method;
2887 --
2888 -- ----------------------------------------------------------------------------
2889 -- |--------------------< update_ca_personal_pay_method >---------------------|
2890 -- ----------------------------------------------------------------------------
2891 --
2892 procedure update_ca_personal_pay_method
2893   (p_validate                      in     boolean  default false
2894   ,p_effective_date                in     date
2895   ,p_datetrack_update_mode         in     varchar2
2896   ,p_personal_payment_method_id    in     number
2897   ,p_object_version_number         in out nocopy number
2898   ,p_account_name                  in     varchar2 default hr_api.g_varchar2
2899   ,p_account_number                in     varchar2 default hr_api.g_varchar2
2900   ,p_transit_code                  in     varchar2 default hr_api.g_varchar2
2901   ,p_bank_number                   in     varchar2 default hr_api.g_varchar2
2902   ,p_bank_name                     in     varchar2 default hr_api.g_varchar2
2903   ,p_account_type                  in     varchar2 default hr_api.g_varchar2
2904   ,p_bank_branch                   in     varchar2 default hr_api.g_varchar2
2905   ,p_amount                        in     number   default hr_api.g_number
2906   ,p_comments                      in     varchar2 default hr_api.g_varchar2
2907   ,p_percentage                    in     number   default hr_api.g_number
2908   ,p_priority                      in     number   default hr_api.g_number
2909   ,p_attribute_category            in     varchar2 default hr_api.g_varchar2
2910   ,p_attribute1                    in     varchar2 default hr_api.g_varchar2
2911   ,p_attribute2                    in     varchar2 default hr_api.g_varchar2
2912   ,p_attribute3                    in     varchar2 default hr_api.g_varchar2
2913   ,p_attribute4                    in     varchar2 default hr_api.g_varchar2
2914   ,p_attribute5                    in     varchar2 default hr_api.g_varchar2
2915   ,p_attribute6                    in     varchar2 default hr_api.g_varchar2
2916   ,p_attribute7                    in     varchar2 default hr_api.g_varchar2
2917   ,p_attribute8                    in     varchar2 default hr_api.g_varchar2
2918   ,p_attribute9                    in     varchar2 default hr_api.g_varchar2
2919   ,p_attribute10                   in     varchar2 default hr_api.g_varchar2
2920   ,p_attribute11                   in     varchar2 default hr_api.g_varchar2
2921   ,p_attribute12                   in     varchar2 default hr_api.g_varchar2
2922   ,p_attribute13                   in     varchar2 default hr_api.g_varchar2
2923   ,p_attribute14                   in     varchar2 default hr_api.g_varchar2
2924   ,p_attribute15                   in     varchar2 default hr_api.g_varchar2
2925   ,p_attribute16                   in     varchar2 default hr_api.g_varchar2
2926   ,p_attribute17                   in     varchar2 default hr_api.g_varchar2
2927   ,p_attribute18                   in     varchar2 default hr_api.g_varchar2
2928   ,p_attribute19                   in     varchar2 default hr_api.g_varchar2
2929   ,p_attribute20                   in     varchar2 default hr_api.g_varchar2
2930   ,p_payee_type                    in     varchar2 default hr_api.g_varchar2
2931   ,p_payee_id                      in     number   default hr_api.g_number
2932   ,p_territory_code                in     varchar2 default hr_api.g_varchar2
2933   ,p_comment_id                    out    nocopy number
2934   ,p_external_account_id           out    nocopy number
2935   ,p_effective_start_date          out    nocopy date
2936   ,p_effective_end_date            out    nocopy date
2937   ) is
2938   --
2939   -- Declare cursors and local variables
2940   --
2941   l_proc                varchar2(72);
2942   --
2943 begin
2944   g_debug := hr_utility.debug_enabled;
2945   if g_debug then
2946      l_proc := g_package||'update_gb_personal_pay_method';
2947      hr_utility.set_location('Entering:'|| l_proc, 5);
2948   end if;
2949   --
2950   -- Ensure that the legislation rule for the employee assignment business
2951   -- group is 'US'.
2952   --
2953   hr_personal_pay_method_api.check_update_legislation
2954   (p_personal_payment_method_id => p_personal_payment_method_id
2955   ,p_effective_date             => p_effective_date
2956   ,p_leg_code                   => 'CA');
2957   --
2958   if g_debug then
2959      hr_utility.set_location(l_proc, 6);
2960   end if;
2961   --
2962   -- Call the business process to update the personal payment method
2963   --
2964 hr_personal_pay_method_api.update_personal_pay_method
2965   (p_validate                      => p_validate
2966   ,p_effective_date                => trunc(p_effective_date)
2967   ,p_datetrack_update_mode         => p_datetrack_update_mode
2968   ,p_personal_payment_method_id    => p_personal_payment_method_id
2969   ,p_object_version_number         => p_object_version_number
2970   ,p_amount                        => p_amount
2971   ,p_comments                      => p_comments
2972   ,p_percentage                    => p_percentage
2973   ,p_priority                      => p_priority
2974   ,p_attribute_category            => p_attribute_category
2975   ,p_attribute1                    => p_attribute1
2976   ,p_attribute2                    => p_attribute2
2977   ,p_attribute3                    => p_attribute3
2978   ,p_attribute4                    => p_attribute4
2979   ,p_attribute5                    => p_attribute5
2980   ,p_attribute6                    => p_attribute6
2981   ,p_attribute7                    => p_attribute7
2982   ,p_attribute8                    => p_attribute8
2983   ,p_attribute9                    => p_attribute9
2984   ,p_attribute10                   => p_attribute10
2985   ,p_attribute11                   => p_attribute11
2986   ,p_attribute12                   => p_attribute12
2987   ,p_attribute13                   => p_attribute13
2988   ,p_attribute14                   => p_attribute14
2989   ,p_attribute15                   => p_attribute15
2990   ,p_attribute16                   => p_attribute16
2991   ,p_attribute17                   => p_attribute17
2992   ,p_attribute18                   => p_attribute18
2993   ,p_attribute19                   => p_attribute19
2994   ,p_attribute20                   => p_attribute20
2995   ,p_territory_code                => p_territory_code     --Bug 6469439
2996   ,p_segment1                      => p_account_name
2997   ,p_segment2                      => p_account_type
2998   ,p_segment3                      => p_account_number
2999   ,p_segment4                      => lpad(p_transit_code,5,'0')
3000   ,p_segment5                      => p_bank_name
3001   ,p_segment6                      => p_bank_branch
3002   ,p_segment7                      => p_bank_number
3003   ,p_payee_type                    => p_payee_type
3004   ,p_payee_id                      => p_payee_id
3005   ,p_comment_id                    => p_comment_id
3006   ,p_external_account_id           => p_external_account_id
3007   ,p_effective_start_date          => p_effective_start_date
3008   ,p_effective_end_date            => p_effective_end_date
3009   );
3010   --
3011   if g_debug then
3012      hr_utility.set_location(' Leaving:'||l_proc, 7);
3013   end if;
3014 end update_ca_personal_pay_method;
3015 --
3016 -- ----------------------------------------------------------------------------
3017 -- |----------------------< delete_personal_pay_method >----------------------|
3018 -- ----------------------------------------------------------------------------
3019 --
3020 procedure delete_personal_pay_method
3021   (p_validate                      in     boolean  default false
3022   ,p_effective_date                in     date
3023   ,p_datetrack_delete_mode         in     varchar2
3024   ,p_personal_payment_method_id    in     number
3025   ,p_object_version_number         in out nocopy number
3026   ,p_effective_start_date          out    nocopy date
3027   ,p_effective_end_date            out    nocopy date
3028   ) is
3029   --
3030   -- Declare cursors and local variables
3031   --
3032   l_proc               varchar2(72);
3033   l_validate           boolean := FALSE;
3034   --
3035 begin
3036   g_debug := hr_utility.debug_enabled;
3037   if g_debug then
3038      l_proc := g_package||'delete_personal_pay_method';
3039      hr_utility.set_location('Entering:'|| l_proc, 5);
3040   end if;
3041   --
3042   -- Issue a savepoint.
3043   --
3044   savepoint delete_personal_pay_method;
3045   --
3046   if g_debug then
3047      hr_utility.set_location(l_proc, 6);
3048   end if;
3049   --
3050   -- Call the row handler to delete the personal payment method.
3051   --
3052   pay_ppm_del.del
3053   (p_personal_payment_method_id   => p_personal_payment_method_id
3054   ,p_effective_start_date         => p_effective_start_date
3055   ,p_effective_end_date           => p_effective_end_date
3056   ,p_object_version_number        => p_object_version_number
3057   ,p_effective_date               => trunc(p_effective_date)
3058   ,p_datetrack_mode               => p_datetrack_delete_mode
3059   ,p_validate                     => l_validate
3060   );
3061   --
3062   if g_debug then
3063      hr_utility.set_location(l_proc, 7);
3064   end if;
3065   --
3066   -- When in validation only mode raise the Validate_Enabled exception
3067   --
3068   if p_validate then
3069     raise hr_api.validate_enabled;
3070   end if;
3071   --
3072   if g_debug then
3073      hr_utility.set_location(' Leaving:'||l_proc, 8);
3074   end if;
3075 exception
3076   when hr_api.validate_enabled then
3077     --
3078     -- As the Validate_Enabled exception has been raised
3079     -- we must rollback to the savepoint
3080     --
3081     ROLLBACK TO delete_personal_pay_method;
3082     --
3083     -- Only set output warning arguments
3084     -- (Any key or derived arguments must be set to null
3085     -- when validation only mode is being used.)
3086     --
3087     p_object_version_number  := null;
3088     p_effective_start_date := null;
3089     p_effective_end_date := null;
3090     --
3091   when others then
3092     --
3093     -- A validation or unexpected error has occurred
3094     --
3095     -- Added as part of fix to bug 632479
3096     --
3097     ROLLBACK TO delete_personal_pay_method;
3098     p_object_version_number  := null;
3099     p_effective_start_date := null;
3100     p_effective_end_date := null;
3101     raise;
3102     --
3103     -- End of fix.
3104     --
3105   if g_debug then
3106      hr_utility.set_location(' Leaving:'||l_proc, 9);
3107   end if;
3108 end delete_personal_pay_method;
3109 --
3110 end hr_personal_pay_method_api;