DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PPMV4_UTILS_SS

Source


1 package body pay_ppmv4_utils_ss as
2 /* $Header: pyppmv4u.pkb 120.0.12010000.2 2008/08/14 11:06:36 aniagarw ship $ */
3 ---------------------------------------------------------------------------
4 ---------------------------------- CONSTANTS ------------------------------
5 ---------------------------------------------------------------------------
6 g_package constant varchar(2000) default 'pay_ppmv4_utils_ss.';
7 ---------------------------------------------------------------------------
8 ----------------------- FUNCTIONS AND PROCEDURES --------------------------
9 ---------------------------------------------------------------------------
10 -------------------------------< seterror >--------------------------------
11 procedure seterrorstage
12 (p_proc in varchar2, p_stage in varchar2, p_location in number) is
13 begin
14   hr_utility.set_location(p_proc || ':' || p_stage, p_location);
15 end seterrorstage;
16 -----------------------------< add_tx_row >-------------------------
17 --
18 -- {Start Of Comments}
19 --
20 -- Description:
21 --   Adds a row of a given type to the PLSQL representation of the
22 --   transaction table.
23 --
24 -- Prerequisites:
25 --   None.
26 --
27 -- Post Success:
28 --   A new table entry is created.
29 --
30 -- Post Failure:
31 --   Not applicable.
32 --
33 -- Access Status:
34 --   Internal Development Use Only.
35 --
36 -- {End Of Comments}
37 --
38 procedure add_tx_row
39 (p_parameter_name  in            varchar2
40 ,p_parameter_value in            long
41 ,p_data_type       in            varchar2 default 'VARCHAR2'
42 ,p_proc            in            varchar2
43 ,p_table           in out nocopy hr_transaction_ss.transaction_table
44 ) is
45 i      binary_integer;
46 begin
47   seterrorstage(p_proc, p_parameter_name, 5);
48   i := p_table.count + 1;
49   p_table(i).param_name := p_parameter_name;
50   p_table(i).param_value := p_parameter_value;
51   p_table(i).param_data_type := p_data_type;
52 exception
53   when others then
54     raise;
55 end add_tx_row;
56 ------------------------------< ppm2hrtt >---------------------------------
57 procedure ppm2hrtt
58 (p_item_type             in varchar2
59 ,p_item_key              in varchar2
60 ,p_activity_id           in number
61 ,p_login_person_id       in number
62 ,p_review_proc_call      in varchar2
63 ,p_transaction_step_id   in number -- From PAY_PSS_TRANSACTION_STEPS.
64 ,p_force_new_transaction in boolean
65 ) is
66 l_tx_table         hr_transaction_ss.transaction_table;
67 l_transaction_id   number;
68 l_api_display_name varchar2(2000);
69 l_api_name         varchar2(2000);
70 l_result           varchar2(2000);
71 l_wf_txstep_id     number;
72 l_ovn              number;
73 l_proc             varchar2(2000) := g_package || 'ppm2wftt';
74 begin
75   seterrorstage(l_proc, 'ENTER', 0);
76   --
77   -- Build the transaction row.
78   --
79   add_tx_row
80   (p_parameter_name  => C_TX_STEP_ID_ARG
81   ,p_parameter_value => to_char(p_transaction_step_id)
82   ,p_data_type       => 'NUMBER'
83   ,p_proc            => l_proc
84   ,p_table           => l_tx_table
85   );
86   add_tx_row
87   (p_parameter_name  => C_REVIEW_PROC_CALL_ARG
88   ,p_parameter_value => p_review_proc_call
89   ,p_proc            => l_proc
90   ,p_table           => l_tx_table
91   );
92   add_tx_row
93   (p_parameter_name  => C_REVIEW_ACTID_ARG
94   ,p_parameter_value => to_char(p_activity_id)
95   ,p_proc            => l_proc
96   ,p_table           => l_tx_table
97   );
98   add_tx_row
99   (p_parameter_name  => C_PROCESSED_FLAG_ARG
100   ,p_parameter_value => 'N'
101   ,p_proc            => l_proc
102   ,p_table           => l_tx_table
103   );
104   --
105   -- Write to HR transaction table.
106   --
107   l_api_name := C_PSS_API;
108   l_api_display_name := 'PAYROLL PAYMENTS SELF-SERVICE V4';
109   if p_force_new_transaction then
110     seterrorstage(l_proc, 'START_TRANSACTION_ID', 10);
111     hr_transaction_ss.start_transaction
112     (itemtype          => p_item_type
113     ,itemkey           => p_item_key
114     ,actid             => p_activity_id
115     ,funmode           => 'RUN'
116     ,p_login_person_id => p_login_person_id
117     ,result            => l_result
118     );
119     seterrorstage(l_proc, 'GET_TRANSACTION_ID:2', 20);
120     l_transaction_id := hr_transaction_ss.get_transaction_id
121     (p_item_type => p_item_type
122     ,p_item_key  => p_item_key
123     );
124   else
125     seterrorstage(l_proc, 'GET_TRANSACTION_ID:1', 30);
126     l_transaction_id := hr_transaction_ss.get_transaction_id
127     (p_item_type => p_item_type
128     ,p_item_key  => p_item_key
129     );
130   end if;
131   seterrorstage(l_proc, 'CREATE_TRANSACTION_STEP', 35);
132   hr_transaction_api.create_transaction_step
133   (p_validate              => false
134   ,p_creator_person_id     => p_login_person_id
135   ,p_transaction_id        => l_transaction_id
136   ,p_api_name              => l_api_name
137   ,p_api_display_name      => l_api_display_name
138   ,p_item_type             => p_item_type
139   ,p_item_key              => p_item_key
140   ,p_activity_id           => p_activity_id
141   ,p_transaction_step_id   => l_wf_txstep_id
142   ,p_object_version_number => l_ovn
143   );
144   seterrorstage(l_proc, 'SAVE_TRANSACTION_STEP', 40);
145   hr_transaction_ss.save_transaction_step
146   (p_item_type           => p_item_type
147   ,p_item_key            => p_item_key
148   ,p_actid               => p_activity_id
149   ,p_login_person_id     => p_login_person_id
150   ,p_transaction_step_id => l_wf_txstep_id
151   ,p_api_name            => l_api_name
152   ,p_api_display_name    => l_api_display_name
153   ,p_transaction_data    => l_tx_table
154   );
155   return;
156 exception
157   when others then
158     seterrorstage(l_proc, 'EXIT:FAIL', 50);
159     raise;
160 end ppm2hrtt;
161 --------------------------------< ppm2tt >---------------------------------
162 procedure ppm2tt
163 (p_ppm in out nocopy t_ppmv4
164 ) is
165 l_proc varchar2(2000) := g_package || 'ppm2tt';
166 begin
167   seterrorstage(l_proc, 'ENTER', 0);
168   if p_ppm.transaction_step_id is null then
169     pay_pss_tx_steps_pkg.insert_row
170     (p_transaction_id             => p_ppm.transaction_id
171     ,p_transaction_step_id        => p_ppm.transaction_step_id
172     ,p_source_table               => p_ppm.source_table
173     ,p_state                      => p_ppm.state
174     ,p_personal_payment_method_id => p_ppm.personal_payment_method_id
175     ,p_update_ovn                 => p_ppm.update_ovn
176     ,p_delete_ovn                 => p_ppm.delete_ovn
177     ,p_update_datetrack_mode      => p_ppm.update_datetrack_mode
178     ,p_delete_datetrack_mode      => p_ppm.delete_datetrack_mode
179     ,p_delete_disabled            => p_ppm.delete_disabled
180     ,p_effective_date             => p_ppm.effective_date
181     ,p_org_payment_method_id      => p_ppm.org_payment_method_id
182     ,p_assignment_id              => p_ppm.assignment_id
183     ,p_payment_type               => p_ppm.payment_type
184     ,p_currency_code              => p_ppm.currency_code
185     ,p_territory_code             => p_ppm.territory_code
186     ,p_run_type_id		  => p_ppm.run_type_id
187     ,p_real_priority              => p_ppm.real_priority
188     ,p_logical_priority           => p_ppm.logical_priority
189     ,p_amount_type                => p_ppm.amount_type
190     ,p_amount                     => p_ppm.amount
191     ,p_external_account_id        => p_ppm.external_account_id
192     ,p_attribute_category         => p_ppm.attribute_category
193     ,p_attribute1                 => p_ppm.attribute1
194     ,p_attribute2                 => p_ppm.attribute2
195     ,p_attribute3                 => p_ppm.attribute3
196     ,p_attribute4                 => p_ppm.attribute4
197     ,p_attribute5                 => p_ppm.attribute5
198     ,p_attribute6                 => p_ppm.attribute6
199     ,p_attribute7                 => p_ppm.attribute7
200     ,p_attribute8                 => p_ppm.attribute8
201     ,p_attribute9                 => p_ppm.attribute9
202     ,p_attribute10                => p_ppm.attribute10
203     ,p_attribute11                => p_ppm.attribute11
204     ,p_attribute12                => p_ppm.attribute12
205     ,p_attribute13                => p_ppm.attribute13
206     ,p_attribute14                => p_ppm.attribute14
207     ,p_attribute15                => p_ppm.attribute15
208     ,p_attribute16                => p_ppm.attribute16
209     ,p_attribute17                => p_ppm.attribute17
210     ,p_attribute18                => p_ppm.attribute18
211     ,p_attribute19                => p_ppm.attribute19
212     ,p_attribute20                => p_ppm.attribute20
213     ,p_o_real_priority            => p_ppm.o_real_priority
214     ,p_o_logical_priority         => p_ppm.o_logical_priority
215     ,p_o_amount_type              => p_ppm.o_amount_type
216     ,p_o_amount                   => p_ppm.o_amount
217     ,p_o_external_account_id      => p_ppm.o_external_account_id
218     ,p_o_attribute_category       => p_ppm.o_attribute_category
219     ,p_o_attribute1               => p_ppm.o_attribute1
220     ,p_o_attribute2               => p_ppm.o_attribute2
221     ,p_o_attribute3               => p_ppm.o_attribute3
222     ,p_o_attribute4               => p_ppm.o_attribute4
223     ,p_o_attribute5               => p_ppm.o_attribute5
224     ,p_o_attribute6               => p_ppm.o_attribute6
225     ,p_o_attribute7               => p_ppm.o_attribute7
226     ,p_o_attribute8               => p_ppm.o_attribute8
227     ,p_o_attribute9               => p_ppm.o_attribute9
228     ,p_o_attribute10              => p_ppm.o_attribute10
229     ,p_o_attribute11              => p_ppm.o_attribute11
230     ,p_o_attribute12              => p_ppm.o_attribute12
231     ,p_o_attribute13              => p_ppm.o_attribute13
232     ,p_o_attribute14              => p_ppm.o_attribute14
233     ,p_o_attribute15              => p_ppm.o_attribute15
234     ,p_o_attribute16              => p_ppm.o_attribute16
235     ,p_o_attribute17              => p_ppm.o_attribute17
236     ,p_o_attribute18              => p_ppm.o_attribute18
237     ,p_o_attribute19              => p_ppm.o_attribute19
238     ,p_o_attribute20              => p_ppm.o_attribute20
239     );
240   else
241     pay_pss_tx_steps_pkg.update_row
242     (p_transaction_step_id        => p_ppm.transaction_step_id
243     ,p_source_table               => p_ppm.source_table
244     ,p_state                      => p_ppm.state
245     ,p_personal_payment_method_id => p_ppm.personal_payment_method_id
246     ,p_update_ovn                 => p_ppm.update_ovn
247     ,p_delete_ovn                 => p_ppm.delete_ovn
248     ,p_update_datetrack_mode      => p_ppm.update_datetrack_mode
249     ,p_delete_datetrack_mode      => p_ppm.delete_datetrack_mode
250     ,p_delete_disabled            => p_ppm.delete_disabled
251     ,p_effective_date             => p_ppm.effective_date
252     ,p_org_payment_method_id      => p_ppm.org_payment_method_id
253     ,p_assignment_id              => p_ppm.assignment_id
254     ,p_payment_type               => p_ppm.payment_type
255     ,p_currency_code              => p_ppm.currency_code
256     ,p_territory_code             => p_ppm.territory_code
257     ,p_run_type_id		  => p_ppm.run_type_id
258     ,p_real_priority              => p_ppm.real_priority
259     ,p_logical_priority           => p_ppm.logical_priority
260     ,p_amount_type                => p_ppm.amount_type
261     ,p_amount                     => p_ppm.amount
262     ,p_external_account_id        => p_ppm.external_account_id
263     ,p_attribute_category         => p_ppm.attribute_category
264     ,p_attribute1                 => p_ppm.attribute1
265     ,p_attribute2                 => p_ppm.attribute2
266     ,p_attribute3                 => p_ppm.attribute3
267     ,p_attribute4                 => p_ppm.attribute4
268     ,p_attribute5                 => p_ppm.attribute5
269     ,p_attribute6                 => p_ppm.attribute6
270     ,p_attribute7                 => p_ppm.attribute7
271     ,p_attribute8                 => p_ppm.attribute8
272     ,p_attribute9                 => p_ppm.attribute9
273     ,p_attribute10                => p_ppm.attribute10
274     ,p_attribute11                => p_ppm.attribute11
275     ,p_attribute12                => p_ppm.attribute12
276     ,p_attribute13                => p_ppm.attribute13
277     ,p_attribute14                => p_ppm.attribute14
278     ,p_attribute15                => p_ppm.attribute15
279     ,p_attribute16                => p_ppm.attribute16
280     ,p_attribute17                => p_ppm.attribute17
281     ,p_attribute18                => p_ppm.attribute18
282     ,p_attribute19                => p_ppm.attribute19
283     ,p_attribute20                => p_ppm.attribute20
284     ,p_o_real_priority            => p_ppm.o_real_priority
285     ,p_o_logical_priority         => p_ppm.o_logical_priority
286     ,p_o_amount_type              => p_ppm.o_amount_type
287     ,p_o_amount                   => p_ppm.o_amount
288     ,p_o_external_account_id      => p_ppm.o_external_account_id
289     ,p_o_attribute_category       => p_ppm.o_attribute_category
290     ,p_o_attribute1               => p_ppm.o_attribute1
291     ,p_o_attribute2               => p_ppm.o_attribute2
292     ,p_o_attribute3               => p_ppm.o_attribute3
293     ,p_o_attribute4               => p_ppm.o_attribute4
294     ,p_o_attribute5               => p_ppm.o_attribute5
295     ,p_o_attribute6               => p_ppm.o_attribute6
296     ,p_o_attribute7               => p_ppm.o_attribute7
297     ,p_o_attribute8               => p_ppm.o_attribute8
298     ,p_o_attribute9               => p_ppm.o_attribute9
299     ,p_o_attribute10              => p_ppm.o_attribute10
300     ,p_o_attribute11              => p_ppm.o_attribute11
301     ,p_o_attribute12              => p_ppm.o_attribute12
302     ,p_o_attribute13              => p_ppm.o_attribute13
303     ,p_o_attribute14              => p_ppm.o_attribute14
304     ,p_o_attribute15              => p_ppm.o_attribute15
305     ,p_o_attribute16              => p_ppm.o_attribute16
306     ,p_o_attribute17              => p_ppm.o_attribute17
307     ,p_o_attribute18              => p_ppm.o_attribute18
308     ,p_o_attribute19              => p_ppm.o_attribute19
309     ,p_o_attribute20              => p_ppm.o_attribute20
310     );
311   end if;
312   seterrorstage(l_proc, 'EXIT:SUCCESS', 10);
313   return;
314 exception
315   when others then
316     seterrorstage(l_proc, 'EXIT:FAIL', 20);
317     raise;
318 end ppm2tt;
319 --------------------------------< tt2ppm >---------------------------------
320 procedure tt2ppm
321 (p_transaction_step_id in     number
322 ,p_ppm                    out nocopy t_ppmv4
323 ) is
324 cursor csr_ppm
325 (p_transaction_step_id in number
326 ) is
327 select p.transaction_id
328 ,      p.transaction_step_id
329 ,      p.source_table
330 ,      p.state
331 ,      p.personal_payment_method_id
332 ,      p.update_ovn
333 ,      p.delete_ovn
334 ,      p.update_datetrack_mode
335 ,      p.delete_datetrack_mode
336 ,      p.delete_disabled
337 ,      p.effective_date
338 ,      p.org_payment_method_id
339 ,      p.assignment_id
340 ,      p.payment_type
341 ,      p.currency_code
342 ,      p.territory_code
343 ,      p.real_priority
344 ,      p.logical_priority
345 ,      p.amount_type
346 ,      p.amount
347 ,      p.external_account_id
348 ,      p.attribute_category
349 ,      p.attribute1
350 ,      p.attribute2
351 ,      p.attribute3
352 ,      p.attribute4
353 ,      p.attribute5
354 ,      p.attribute6
355 ,      p.attribute7
356 ,      p.attribute8
357 ,      p.attribute9
358 ,      p.attribute10
359 ,      p.attribute11
360 ,      p.attribute12
361 ,      p.attribute13
362 ,      p.attribute14
363 ,      p.attribute15
364 ,      p.attribute16
365 ,      p.attribute17
366 ,      p.attribute18
367 ,      p.attribute19
368 ,      p.attribute20
369 ,      p.o_real_priority
370 ,      p.o_logical_priority
371 ,      p.o_amount_type
372 ,      p.o_amount
373 ,      p.o_external_account_id
374 ,      p.o_attribute_category
375 ,      p.o_attribute1
376 ,      p.o_attribute2
377 ,      p.o_attribute3
378 ,      p.o_attribute4
379 ,      p.o_attribute5
380 ,      p.o_attribute6
381 ,      p.o_attribute7
382 ,      p.o_attribute8
383 ,      p.o_attribute9
384 ,      p.o_attribute10
385 ,      p.o_attribute11
386 ,      p.o_attribute12
387 ,      p.o_attribute13
388 ,      p.o_attribute14
389 ,      p.o_attribute15
390 ,      p.o_attribute16
391 ,      p.o_attribute17
392 ,      p.o_attribute18
393 ,      p.o_attribute19
394 ,      p.o_attribute20
395 ,      p.run_type_id
396 from   pay_pss_transaction_steps p
397 where  p.transaction_step_id = p_transaction_step_id
398 ;
399 l_proc varchar2(2000) := g_package || 'tt2ppm';
400 begin
401   seterrorstage(l_proc, 'ENTER', 0);
402   --
403   open csr_ppm
404   (p_transaction_step_id => p_transaction_step_id
405   );
406   fetch csr_ppm
407   into p_ppm.transaction_id
408   ,    p_ppm.transaction_step_id
409   ,    p_ppm.source_table
410   ,    p_ppm.state
411   ,    p_ppm.personal_payment_method_id
412   ,    p_ppm.update_ovn
413   ,    p_ppm.delete_ovn
414   ,    p_ppm.update_datetrack_mode
415   ,    p_ppm.delete_datetrack_mode
416   ,    p_ppm.delete_disabled
417   ,    p_ppm.effective_date
418   ,    p_ppm.org_payment_method_id
419   ,    p_ppm.assignment_id
420   ,    p_ppm.payment_type
421   ,    p_ppm.currency_code
422   ,    p_ppm.territory_code
423   ,    p_ppm.real_priority
424   ,    p_ppm.logical_priority
425   ,    p_ppm.amount_type
426   ,    p_ppm.amount
427   ,    p_ppm.external_account_id
428   ,    p_ppm.attribute_category
429   ,    p_ppm.attribute1
430   ,    p_ppm.attribute2
431   ,    p_ppm.attribute3
432   ,    p_ppm.attribute4
433   ,    p_ppm.attribute5
434   ,    p_ppm.attribute6
435   ,    p_ppm.attribute7
436   ,    p_ppm.attribute8
437   ,    p_ppm.attribute9
438   ,    p_ppm.attribute10
439   ,    p_ppm.attribute11
440   ,    p_ppm.attribute12
441   ,    p_ppm.attribute13
442   ,    p_ppm.attribute14
443   ,    p_ppm.attribute15
444   ,    p_ppm.attribute16
445   ,    p_ppm.attribute17
446   ,    p_ppm.attribute18
447   ,    p_ppm.attribute19
448   ,    p_ppm.attribute20
449   ,    p_ppm.o_real_priority
450   ,    p_ppm.o_logical_priority
451   ,    p_ppm.o_amount_type
452   ,    p_ppm.o_amount
453   ,    p_ppm.o_external_account_id
454   ,    p_ppm.o_attribute_category
455   ,    p_ppm.o_attribute1
456   ,    p_ppm.o_attribute2
457   ,    p_ppm.o_attribute3
458   ,    p_ppm.o_attribute4
459   ,    p_ppm.o_attribute5
460   ,    p_ppm.o_attribute6
461   ,    p_ppm.o_attribute7
462   ,    p_ppm.o_attribute8
463   ,    p_ppm.o_attribute9
464   ,    p_ppm.o_attribute10
465   ,    p_ppm.o_attribute11
466   ,    p_ppm.o_attribute12
467   ,    p_ppm.o_attribute13
468   ,    p_ppm.o_attribute14
469   ,    p_ppm.o_attribute15
470   ,    p_ppm.o_attribute16
471   ,    p_ppm.o_attribute17
472   ,    p_ppm.o_attribute18
473   ,    p_ppm.o_attribute19
474   ,    p_ppm.o_attribute20
475   ,    p_ppm.run_type_id
476   ;
477   close csr_ppm;
478   seterrorstage(l_proc, 'EXIT:SUCCESS', 20);
479   return;
480 exception
481   when others then
482     seterrorstage(l_proc, 'EXIT:FAIL', 30);
483     if csr_ppm%isopen then
484       close csr_ppm;
485     end if;
486     raise;
487 end;
488 -----------------------------< changed >-------------------------
489 --
490 -- {Start Of Comments}
491 --
492 -- Description:
493 --   Compares data used to check whether or not a PPM has changed.
494 --
495 -- Prerequisites:
496 --   None.
497 --
498 -- Post Success:
499 --   P_CHANGES is set to true if there are any differences.
500 --   P_BANK is set to true if the Bank Details differ.
501 --
502 -- Post Failure:
503 --   Not applicable.
504 --
505 -- Access Status:
506 --   Internal Development Use Only.
507 --
508 -- {End Of Comments}
509 --
510 procedure changed
511 (p_logical_priority      in     number
512 ,p_amount_type           in     varchar2
513 ,p_amount                in     number
514 ,p_external_account_id   in     number
515 ,p_attribute_category    in     varchar2
516 ,p_attribute1            in     varchar2
517 ,p_attribute2            in     varchar2
518 ,p_attribute3            in     varchar2
519 ,p_attribute4            in     varchar2
520 ,p_attribute5            in     varchar2
521 ,p_attribute6            in     varchar2
522 ,p_attribute7            in     varchar2
523 ,p_attribute8            in     varchar2
524 ,p_attribute9            in     varchar2
525 ,p_attribute10           in     varchar2
526 ,p_attribute11           in     varchar2
527 ,p_attribute12           in     varchar2
528 ,p_attribute13           in     varchar2
529 ,p_attribute14           in     varchar2
530 ,p_attribute15           in     varchar2
531 ,p_attribute16           in     varchar2
532 ,p_attribute17           in     varchar2
533 ,p_attribute18           in     varchar2
534 ,p_attribute19           in     varchar2
535 ,p_attribute20           in     varchar2
536 ,p_o_logical_priority    in     number
537 ,p_o_amount_type         in     varchar2
538 ,p_o_amount              in     number
539 ,p_o_external_account_id in     number
540 ,p_o_attribute_category  in     varchar2
541 ,p_o_attribute1          in     varchar2
542 ,p_o_attribute2          in     varchar2
543 ,p_o_attribute3          in     varchar2
544 ,p_o_attribute4          in     varchar2
545 ,p_o_attribute5          in     varchar2
546 ,p_o_attribute6          in     varchar2
547 ,p_o_attribute7          in     varchar2
548 ,p_o_attribute8          in     varchar2
549 ,p_o_attribute9          in     varchar2
550 ,p_o_attribute10         in     varchar2
551 ,p_o_attribute11         in     varchar2
552 ,p_o_attribute12         in     varchar2
553 ,p_o_attribute13         in     varchar2
554 ,p_o_attribute14         in     varchar2
555 ,p_o_attribute15         in     varchar2
556 ,p_o_attribute16         in     varchar2
557 ,p_o_attribute17         in     varchar2
558 ,p_o_attribute18         in     varchar2
559 ,p_o_attribute19         in     varchar2
560 ,p_o_attribute20         in     varchar2
561 ,p_changes                  out nocopy boolean
562 ,p_bank                     out nocopy boolean
563 ) is
564 --
565 l_changes boolean := false;
566 l_bank    boolean := false;
567 --
568 -- Local procedures to detect a changed column.
569 --
570 procedure ch
571 (p_value1 in     number
572 ,p_value2 in     number
573 ,p_change in out nocopy boolean
574 ) is
575 begin
576   --
577   -- The HR_API defaults are used to indicate no change.
578   --
579   if nvl(p_value1, hr_api.g_number) <> nvl(p_value2, hr_api.g_number) then
580     p_change := true;
581   end if;
582 end ch;
583 --
584 procedure ch
585 (p_value1 in     varchar2
586 ,p_value2 in     varchar2
587 ,p_change in out nocopy boolean
588 ) is
589 begin
590   --
591   -- The HR_API defaults are used to indicate no change.
592   --
593   if nvl(p_value1, hr_api.g_varchar2) <> nvl(p_value2, hr_api.g_varchar2) then
594     p_change := true;
595   end if;
596 end ch;
597 --
598 begin
599   ch(p_logical_priority, p_o_logical_priority, l_changes);
600   ch(p_amount, p_o_amount, l_changes);
601   ch(p_amount_type, p_o_amount_type, l_changes);
602   ch(p_external_account_id, p_o_external_account_id, l_bank);
603   ch(p_attribute_category, p_o_attribute_category, l_changes);
604   ch(p_attribute1, p_o_attribute1, l_changes);
605   ch(p_attribute2, p_o_attribute2, l_changes);
606   ch(p_attribute3, p_o_attribute3, l_changes);
607   ch(p_attribute4, p_o_attribute4, l_changes);
608   ch(p_attribute5, p_o_attribute5, l_changes);
609   ch(p_attribute6, p_o_attribute6, l_changes);
610   ch(p_attribute7, p_o_attribute7, l_changes);
611   ch(p_attribute8, p_o_attribute8, l_changes);
612   ch(p_attribute9, p_o_attribute9, l_changes);
613   ch(p_attribute10, p_o_attribute10, l_changes);
614   ch(p_attribute11, p_o_attribute11, l_changes);
615   ch(p_attribute12, p_o_attribute12, l_changes);
616   ch(p_attribute13, p_o_attribute13, l_changes);
617   ch(p_attribute14, p_o_attribute14, l_changes);
618   ch(p_attribute15, p_o_attribute15, l_changes);
619   ch(p_attribute16, p_o_attribute16, l_changes);
620   ch(p_attribute17, p_o_attribute17, l_changes);
621   ch(p_attribute18, p_o_attribute18, l_changes);
622   ch(p_attribute19, p_o_attribute19, l_changes);
623   ch(p_attribute20, p_o_attribute20, l_changes);
624   --
625   -- Set the return values.
626   --
627   if l_bank then
628     l_changes := true;
629   end if;
630   p_bank    := l_bank;
631   p_changes := l_changes;
632 end changed;
633 -----------------------------< changedppm >------------------------
634 procedure changedppm
635 (p_ppm           in     t_ppmv4
636 ,p_changes          out nocopy boolean
637 ,p_bank             out nocopy boolean
638 ) is
639 begin
640   --
641   -- Call private routine.
642   --
643   changed
644   (p_logical_priority      => p_ppm.logical_priority
645   ,p_amount_type           => p_ppm.amount_type
646   ,p_amount                => p_ppm.amount
647   ,p_external_account_id   => p_ppm.external_account_id
648   ,p_attribute_category    => p_ppm.attribute_category
649   ,p_attribute1            => p_ppm.attribute1
650   ,p_attribute2            => p_ppm.attribute2
651   ,p_attribute3            => p_ppm.attribute3
652   ,p_attribute4            => p_ppm.attribute4
653   ,p_attribute5            => p_ppm.attribute5
654   ,p_attribute6            => p_ppm.attribute6
655   ,p_attribute7            => p_ppm.attribute7
656   ,p_attribute8            => p_ppm.attribute8
657   ,p_attribute9            => p_ppm.attribute9
658   ,p_attribute10           => p_ppm.attribute10
659   ,p_attribute11           => p_ppm.attribute11
660   ,p_attribute12           => p_ppm.attribute12
661   ,p_attribute13           => p_ppm.attribute13
662   ,p_attribute14           => p_ppm.attribute14
663   ,p_attribute15           => p_ppm.attribute15
664   ,p_attribute16           => p_ppm.attribute16
665   ,p_attribute17           => p_ppm.attribute17
666   ,p_attribute18           => p_ppm.attribute18
667   ,p_attribute19           => p_ppm.attribute19
668   ,p_attribute20           => p_ppm.attribute20
669   ,p_o_logical_priority    => p_ppm.o_logical_priority
670   ,p_o_amount_type         => p_ppm.o_amount_type
671   ,p_o_amount              => p_ppm.o_amount
672   ,p_o_external_account_id => p_ppm.o_external_account_id
673   ,p_o_attribute_category  => p_ppm.o_attribute_category
674   ,p_o_attribute1          => p_ppm.o_attribute1
675   ,p_o_attribute2          => p_ppm.o_attribute2
676   ,p_o_attribute3          => p_ppm.o_attribute3
677   ,p_o_attribute4          => p_ppm.o_attribute4
678   ,p_o_attribute5          => p_ppm.o_attribute5
679   ,p_o_attribute6          => p_ppm.o_attribute6
680   ,p_o_attribute7          => p_ppm.o_attribute7
681   ,p_o_attribute8          => p_ppm.o_attribute8
682   ,p_o_attribute9          => p_ppm.o_attribute9
683   ,p_o_attribute10         => p_ppm.o_attribute10
684   ,p_o_attribute11         => p_ppm.o_attribute11
685   ,p_o_attribute12         => p_ppm.o_attribute12
686   ,p_o_attribute13         => p_ppm.o_attribute13
687   ,p_o_attribute14         => p_ppm.o_attribute14
688   ,p_o_attribute15         => p_ppm.o_attribute15
689   ,p_o_attribute16         => p_ppm.o_attribute16
690   ,p_o_attribute17         => p_ppm.o_attribute17
691   ,p_o_attribute18         => p_ppm.o_attribute18
692   ,p_o_attribute19         => p_ppm.o_attribute19
693   ,p_o_attribute20         => p_ppm.o_attribute20
694   ,p_changes               => p_changes
695   ,p_bank                  => p_bank
696   );
697 end changedppm;
698 -----------------------------< changedppm >------------------------
699 procedure changedppm
700 (p_new_ppm   in     t_ppmv4
701 ,p_saved_ppm in     t_ppmv4
702 ,p_original     out nocopy boolean
703 ,p_current      out nocopy boolean
704 ) is
705 l_bank boolean;
706 l_changes boolean;
707 begin
708   --
709   -- Call private routine.
710   --
711   changed
712   (p_logical_priority      => hr_api.g_number
713   ,p_amount_type           => p_new_ppm.amount_type
714   ,p_amount                => p_new_ppm.amount
715   ,p_external_account_id   => p_new_ppm.external_account_id
716   ,p_attribute_category    => p_new_ppm.attribute_category
717   ,p_attribute1            => p_new_ppm.attribute1
718   ,p_attribute2            => p_new_ppm.attribute2
719   ,p_attribute3            => p_new_ppm.attribute3
720   ,p_attribute4            => p_new_ppm.attribute4
721   ,p_attribute5            => p_new_ppm.attribute5
722   ,p_attribute6            => p_new_ppm.attribute6
723   ,p_attribute7            => p_new_ppm.attribute7
724   ,p_attribute8            => p_new_ppm.attribute8
725   ,p_attribute9            => p_new_ppm.attribute9
726   ,p_attribute10           => p_new_ppm.attribute10
727   ,p_attribute11           => p_new_ppm.attribute11
728   ,p_attribute12           => p_new_ppm.attribute12
729   ,p_attribute13           => p_new_ppm.attribute13
730   ,p_attribute14           => p_new_ppm.attribute14
731   ,p_attribute15           => p_new_ppm.attribute15
732   ,p_attribute16           => p_new_ppm.attribute16
733   ,p_attribute17           => p_new_ppm.attribute17
734   ,p_attribute18           => p_new_ppm.attribute18
735   ,p_attribute19           => p_new_ppm.attribute19
736   ,p_attribute20           => p_new_ppm.attribute20
737   ,p_o_logical_priority    => hr_api.g_number
738   ,p_o_amount_type         => p_saved_ppm.o_amount_type
739   ,p_o_amount              => p_saved_ppm.o_amount
740   ,p_o_external_account_id => p_saved_ppm.o_external_account_id
741   ,p_o_attribute_category  => p_saved_ppm.o_attribute_category
742   ,p_o_attribute1          => p_saved_ppm.o_attribute1
743   ,p_o_attribute2          => p_saved_ppm.o_attribute2
744   ,p_o_attribute3          => p_saved_ppm.o_attribute3
745   ,p_o_attribute4          => p_saved_ppm.o_attribute4
746   ,p_o_attribute5          => p_saved_ppm.o_attribute5
747   ,p_o_attribute6          => p_saved_ppm.o_attribute6
748   ,p_o_attribute7          => p_saved_ppm.o_attribute7
749   ,p_o_attribute8          => p_saved_ppm.o_attribute8
750   ,p_o_attribute9          => p_saved_ppm.o_attribute9
751   ,p_o_attribute10         => p_saved_ppm.o_attribute10
752   ,p_o_attribute11         => p_saved_ppm.o_attribute11
753   ,p_o_attribute12         => p_saved_ppm.o_attribute12
754   ,p_o_attribute13         => p_saved_ppm.o_attribute13
755   ,p_o_attribute14         => p_saved_ppm.o_attribute14
756   ,p_o_attribute15         => p_saved_ppm.o_attribute15
757   ,p_o_attribute16         => p_saved_ppm.o_attribute16
758   ,p_o_attribute17         => p_saved_ppm.o_attribute17
759   ,p_o_attribute18         => p_saved_ppm.o_attribute18
760   ,p_o_attribute19         => p_saved_ppm.o_attribute19
761   ,p_o_attribute20         => p_saved_ppm.o_attribute20
762   ,p_changes               => l_changes
763   ,p_bank                  => l_bank
764   );
765   p_original := l_changes;
766   --
767   changed
768   (p_logical_priority      => hr_api.g_number
769   ,p_amount_type           => p_new_ppm.amount_type
770   ,p_amount                => p_new_ppm.amount
771   ,p_external_account_id   => p_new_ppm.external_account_id
772   ,p_attribute_category    => p_new_ppm.attribute_category
773   ,p_attribute1            => p_new_ppm.attribute1
774   ,p_attribute2            => p_new_ppm.attribute2
775   ,p_attribute3            => p_new_ppm.attribute3
776   ,p_attribute4            => p_new_ppm.attribute4
777   ,p_attribute5            => p_new_ppm.attribute5
778   ,p_attribute6            => p_new_ppm.attribute6
779   ,p_attribute7            => p_new_ppm.attribute7
780   ,p_attribute8            => p_new_ppm.attribute8
781   ,p_attribute9            => p_new_ppm.attribute9
782   ,p_attribute10           => p_new_ppm.attribute10
783   ,p_attribute11           => p_new_ppm.attribute11
784   ,p_attribute12           => p_new_ppm.attribute12
785   ,p_attribute13           => p_new_ppm.attribute13
786   ,p_attribute14           => p_new_ppm.attribute14
787   ,p_attribute15           => p_new_ppm.attribute15
788   ,p_attribute16           => p_new_ppm.attribute16
789   ,p_attribute17           => p_new_ppm.attribute17
790   ,p_attribute18           => p_new_ppm.attribute18
791   ,p_attribute19           => p_new_ppm.attribute19
792   ,p_attribute20           => p_new_ppm.attribute20
793   ,p_o_logical_priority    => hr_api.g_number
794   ,p_o_amount_type         => p_saved_ppm.amount_type
795   ,p_o_amount              => p_saved_ppm.amount
796   ,p_o_external_account_id => p_saved_ppm.external_account_id
797   ,p_o_attribute_category  => p_saved_ppm.attribute_category
798   ,p_o_attribute1          => p_saved_ppm.attribute1
799   ,p_o_attribute2          => p_saved_ppm.attribute2
800   ,p_o_attribute3          => p_saved_ppm.attribute3
801   ,p_o_attribute4          => p_saved_ppm.attribute4
802   ,p_o_attribute5          => p_saved_ppm.attribute5
803   ,p_o_attribute6          => p_saved_ppm.attribute6
804   ,p_o_attribute7          => p_saved_ppm.attribute7
805   ,p_o_attribute8          => p_saved_ppm.attribute8
806   ,p_o_attribute9          => p_saved_ppm.attribute9
807   ,p_o_attribute10         => p_saved_ppm.attribute10
808   ,p_o_attribute11         => p_saved_ppm.attribute11
809   ,p_o_attribute12         => p_saved_ppm.attribute12
810   ,p_o_attribute13         => p_saved_ppm.attribute13
811   ,p_o_attribute14         => p_saved_ppm.attribute14
812   ,p_o_attribute15         => p_saved_ppm.attribute15
813   ,p_o_attribute16         => p_saved_ppm.attribute16
814   ,p_o_attribute17         => p_saved_ppm.attribute17
815   ,p_o_attribute18         => p_saved_ppm.attribute18
816   ,p_o_attribute19         => p_saved_ppm.attribute19
817   ,p_o_attribute20         => p_saved_ppm.attribute20
818   ,p_changes               => l_changes
819   ,p_bank                  => l_bank
820   );
821   p_current := l_changes;
822 end changedppm;
823 -----------------------------< nextentry >--------------------------
824 function nextentry
825 (p_list      in     varchar2
826 ,p_separator in     varchar2
827 ,p_start     in out nocopy number
828 ) return varchar2 is
829 l_list  long;
830 l_entry long;
831 l_end   number;
832 begin
833   l_list := substr(p_list, p_start);
834   l_end :=  instr(l_list, p_separator);
835   --
836   -- Separator not found - last entry in the list.
837   --
838   if nvl(l_end, 0) = 0 then
839     l_entry := l_list;
840     p_start := 0;
841   else
842   --
843   -- Found separator, get the entry and reset the start of
844   -- the list. Don't worry if the new start is beyond the
845   -- end of the list.
846   --
847     l_entry := substr(l_list, 1, l_end-1);
848     p_start := p_start + l_end;
849   end if;
850   return l_entry;
851 end nextentry;
852 ------------------------< read_wf_config_option >------------------------
853 function read_wf_config_option
854 (p_item_type   in varchar2
855 ,p_item_key    in varchar2
856 ,p_activity_id in number   default null
857 ,p_option      in varchar2
858 ,p_number      in boolean  default false
859 ) return varchar2 is
860 l_value   long;
861 l_exists  boolean;
862 l_subtype wf_activity_attributes.subtype%type;
863 l_type    wf_activity_attributes.type%type;
864 l_format  wf_activity_attributes.format%type;
865 l_date    wf_activity_attr_values.date_value%type;
866 l_number  wf_activity_attr_values.number_value%type;
867 begin
868   if p_activity_id is not null then
869     --
870     -- Look for activity attribute first.
871     --
872     hr_mee_workflow_service.get_act_attr_expanded_info
873     (p_item_type    => p_item_type
874     ,p_item_key     => p_item_key
875     ,p_actid        => p_activity_id
876     ,p_name         => p_option
877     ,p_exists       => l_exists
878     ,p_subtype      => l_subtype
879     ,p_type         => l_type
880     ,p_format       => l_format
881     ,p_date_value   => l_date
882     ,p_number_value => l_number
883     ,p_text_value   => l_value
884     );
885     if l_exists then
886       if l_type = 'NUMBER' then
887         l_value := to_char(l_number);
888       elsif l_type = 'DATE' then
889         l_value := to_char(l_date, hr_transaction_ss.g_date_format);
890       end if;
891       return l_value;
892     end if;
893   end if;
894   --
895   -- Just look for item attribute.
896   --
897   if hr_workflow_utility.item_attribute_exists
898      (p_item_type => p_item_type
899      ,p_item_key  => p_item_key
900      ,p_name      => p_option
901      )
902   then
903     if p_number then
904       l_number := wf_engine.getitemattrnumber
905       (itemtype => p_item_type
906       ,itemkey  => p_item_key
907       ,aname    => p_option
908       );
909       l_value := to_char(l_number);
910     else
911       l_value := wf_engine.getitemattrtext
912       (itemtype => p_item_type
913       ,itemkey  => p_item_key
914       ,aname    => p_option
915       );
916     end if;
917     return l_value;
918   end if;
919   --
920   -- Display a fatal error.
921   --
922   hr_utility.set_message
923   (applid         => 800
924   ,l_message_name => 'PAY_52631_PPMSS_OPTION_ERROR'
925   );
926   hr_utility.set_message_token
927   (l_token_name  => 'OPTION'
928   ,l_token_value => p_option
929   );
930   hr_utility.raise_error;
931 exception
932   when others then
933     raise;
934 end read_wf_config_option;
935 ----------------------< getpriorities >-----------------------
936 procedure getpriorities
937 (p_assignment_id  in     number
938 ,p_effective_date in     date
939 ,p_run_type_id    in     number default null
940 ,p_priority_tbl      out nocopy t_boolean_tbl
941 ,p_first_available   out nocopy number
942 ) is
943 cursor csr_priorities
944 (p_assignment_id  in number
945 ,p_effective_date in date
946 ,p_run_type_id    in number
947 ) is
948 select ppm.priority priority
949 from   pay_personal_payment_methods_f ppm
950 ,      pay_org_payment_methods_f opm
951 where  ppm.assignment_id = p_assignment_id
952 and    nvl(ppm.run_type_id, hr_api.g_number) = nvl(p_run_type_id, hr_api.g_number)
953 and    p_effective_date between
954        ppm.effective_start_date and ppm.effective_end_date
955 and    opm.org_payment_method_id = ppm.org_payment_method_id
956 and    opm.defined_balance_id is not null
957 and    p_effective_date between
958        opm.effective_start_date and opm.effective_end_date
959 order by priority
960 ;
961 --
962 l_priority_tbl    t_boolean_tbl;
963 l_first_available number;
964 l_proc            varchar2(2000) := g_package||'getpriorities';
965 begin
966   seterrorstage(l_proc, 'ENTER', 0);
967   --
968   -- Initialise the priority table.
969   --
970   for i in C_MIN_PRIORITY .. C_MAX_PRIORITY loop
971     l_priority_tbl(i) := true;
972   end loop;
973   --
974   -- Get the existing priorities.
975   --
976   seterrorstage(l_proc, 'FETCH_PRIORITIES', 10);
977   l_first_available := C_MIN_PRIORITY;
978   for crec in csr_priorities
979   (p_assignment_id  => p_assignment_id
980   ,p_effective_date => p_effective_date
981   ,p_run_type_id    => p_run_type_id
982   ) loop
983     --
984     -- Avoid adding entries for values < C_MIN_PRIORITY.
985     --
986     if crec.priority >= C_MIN_PRIORITY then
987       l_priority_tbl(crec.priority) := false;
988     end if;
989     if crec.priority = l_first_available then
990       l_first_available := l_first_available + 1;
991     end if;
992   end loop;
993   p_first_available := l_first_available;
994   p_priority_tbl := l_priority_tbl;
995   seterrorstage(l_proc, 'EXIT:SUCCESS', 20);
996   return;
997 exception
998   when others then
999     seterrorstage(l_proc, 'EXIT:FAIL', 30);
1000     raise;
1001 end getpriorities;
1002 -----------------------------< validateppm >------------------------
1003 procedure validateppm
1004 (p_state                      in     varchar2
1005 ,p_personal_payment_method_id in     number   default null
1006 ,p_object_version_number      in     number   default null
1007 ,p_update_datetrack_mode      in     varchar2 default null
1008 ,p_effective_date             in     date     default null
1009 ,p_org_payment_method_id      in     number   default null
1010 ,p_assignment_id              in     number   default null
1011 ,p_run_type_id                in     number   default null
1012 ,p_payment_type               in     varchar2 default null
1013 ,p_territory_code             in     varchar2 default null
1014 ,p_amount_type                in     varchar2 default null
1015 ,p_amount                     in     number   default null
1016 ,p_external_account_id        in     number   default null
1017 ,p_attribute_category         in     varchar2 default null
1018 ,p_attribute1                 in     varchar2 default null
1019 ,p_attribute2                 in     varchar2 default null
1020 ,p_attribute3                 in     varchar2 default null
1021 ,p_attribute4                 in     varchar2 default null
1022 ,p_attribute5                 in     varchar2 default null
1023 ,p_attribute6                 in     varchar2 default null
1024 ,p_attribute7                 in     varchar2 default null
1025 ,p_attribute8                 in     varchar2 default null
1026 ,p_attribute9                 in     varchar2 default null
1027 ,p_attribute10                in     varchar2 default null
1028 ,p_attribute11                in     varchar2 default null
1029 ,p_attribute12                in     varchar2 default null
1030 ,p_attribute13                in     varchar2 default null
1031 ,p_attribute14                in     varchar2 default null
1032 ,p_attribute15                in     varchar2 default null
1033 ,p_attribute16                in     varchar2 default null
1034 ,p_attribute17                in     varchar2 default null
1035 ,p_attribute18                in     varchar2 default null
1036 ,p_attribute19                in     varchar2 default null
1037 ,p_attribute20                in     varchar2 default null
1038 ,p_segment1                   in     varchar2 default null
1039 ,p_segment2                   in     varchar2 default null
1040 ,p_segment3                   in     varchar2 default null
1041 ,p_segment4                   in     varchar2 default null
1042 ,p_segment5                   in     varchar2 default null
1043 ,p_segment6                   in     varchar2 default null
1044 ,p_segment7                   in     varchar2 default null
1045 ,p_segment8                   in     varchar2 default null
1046 ,p_segment9                   in     varchar2 default null
1047 ,p_segment10                  in     varchar2 default null
1048 ,p_segment11                  in     varchar2 default null
1049 ,p_segment12                  in     varchar2 default null
1050 ,p_segment13                  in     varchar2 default null
1051 ,p_segment14                  in     varchar2 default null
1052 ,p_segment15                  in     varchar2 default null
1053 ,p_segment16                  in     varchar2 default null
1054 ,p_segment17                  in     varchar2 default null
1055 ,p_segment18                  in     varchar2 default null
1056 ,p_segment19                  in     varchar2 default null
1057 ,p_segment20                  in     varchar2 default null
1058 ,p_segment21                  in     varchar2 default null
1059 ,p_segment22                  in     varchar2 default null
1060 ,p_segment23                  in     varchar2 default null
1061 ,p_segment24                  in     varchar2 default null
1062 ,p_segment25                  in     varchar2 default null
1063 ,p_segment26                  in     varchar2 default null
1064 ,p_segment27                  in     varchar2 default null
1065 ,p_segment28                  in     varchar2 default null
1066 ,p_segment29                  in     varchar2 default null
1067 ,p_segment30                  in     varchar2 default null
1068 ,p_return_status                 out nocopy varchar2
1069 ,p_msg_count                     out nocopy number
1070 ,p_msg_data                      out nocopy varchar2
1071 ) is
1072 --
1073 --  Cursor to get business_group_id from assignment_id and
1074 --  effective_date. This is required for the INSERT operation.
1075 --
1076 cursor csr_asg_busgrp
1077 (p_assignment_id  in number
1078 ,p_effective_date in date
1079 ) is
1080 select asg.business_group_id
1081 from   per_all_assignments_f asg
1082 where  asg.assignment_id = p_assignment_id
1083 and    p_effective_date between
1084        asg.effective_start_date and asg.effective_end_date
1085 ;
1086 --
1087 -- Cursor to get business_group_id from the personal_payment_method_id
1088 -- and effective_date. This is required for the UPDATE operation.
1089 --
1090 cursor csr_ppm_busgrp
1091 (p_personal_payment_method_id in number
1092 ,p_effective_date             in date
1093 ) is
1094 select ppm.business_group_id
1095 from   pay_personal_payment_methods_f ppm
1096 where  ppm.personal_payment_method_id = p_personal_payment_method_id
1097 and    p_effective_date between
1098        ppm.effective_start_date and ppm.effective_end_date
1099 ;
1100 --
1101 l_business_group_id     number;
1102 l_rec                   pay_ppm_shd.g_rec_type;
1103 l_datetrack_mode        varchar2(2000);
1104 l_validation_start_date date;
1105 l_validation_end_date   date;
1106 l_message_name          varchar2(2000);
1107 l_column                varchar2(2000);
1108 l_prompt                varchar2(2000);
1109 --
1110 -- Percentage/Amount values.
1111 --
1112 l_amount                number;
1113 l_percentage            number;
1114 --
1115 -- The following are required for bank details segment validation.
1116 --
1117 l_external_account_id   number;
1118 l_external_account_ovn  number;
1119 l_exa_user_error        boolean := false;
1120 l_user_error            boolean := false;
1121 --
1122 -- API default values.
1123 --
1124 l_default_number        number;
1125 l_default_varchar2      varchar2(2000);
1126 --
1127 -- Transit code checking.
1128 --
1129 l_check_digit           number;
1130 l_transit_code_sum      number;
1131 --
1132 l_proc                  varchar2(2000) := g_package || 'validateppm';
1133 begin
1134   --
1135   savepoint start_validate;
1136   --
1137   -- Set up default values by operation and type.
1138   --
1139   seterrorstage(l_proc, 'ENTER', 0);
1140   if p_state = pay_pss_tx_steps_pkg.C_STATE_NEW then
1141     seterrorstage(l_proc, 'C_STATE_NEW', 10);
1142     l_default_number := null;
1143     l_default_varchar2 := null;
1144     l_datetrack_mode := hr_api.g_insert;
1145   elsif p_state = pay_pss_tx_steps_pkg.C_STATE_UPDATED then
1146     seterrorstage(l_proc, 'C_STATE_UPDATED', 20);
1147     l_default_number := hr_api.g_number;
1148     l_default_varchar2 := hr_api.g_varchar2;
1149     l_datetrack_mode := p_update_datetrack_mode;
1150   else
1151     --
1152     -- Should not reach here.
1153     --
1154     seterrorstage(l_proc, 'STATE:'||p_state, 30);
1155     fnd_message.set_name('PAY', 'PAY_51518_PSS_ASSERT_ERROR');
1156     fnd_message.set_token('WHERE', l_proc);
1157     fnd_message.set_token('ADDITIONAL_INFO', '<p_state = ' || p_state || '>');
1158     fnd_msg_pub.add;
1159     p_return_status := fnd_api.G_RET_STS_UNEXP_ERROR;
1160     fnd_msg_pub.count_and_get
1161     (p_count => p_msg_count
1162     ,p_data  => p_msg_data
1163     );
1164     return;
1165   end if;
1166   --
1167   -- Set up Percent/Amount validation.
1168   --
1169   if p_amount_type = pay_pss_tx_steps_pkg.C_PERCENTAGE or
1170      p_amount_type = pay_pss_tx_steps_pkg.C_PERCENTAGE_ONLY then
1171     seterrorstage(l_proc, 'C_PERCENTAGE', 40);
1172     l_amount := null;
1173     l_percentage := p_amount;
1174   elsif p_amount_type = pay_pss_tx_steps_pkg.C_MONETARY or
1175         p_amount_type = pay_pss_tx_steps_pkg.C_MONETARY_ONLY then
1176     seterrorstage(l_proc, 'C_MONETARY', 50);
1177     l_amount := p_amount;
1178     l_percentage := null;
1179   elsif p_amount_type = pay_pss_tx_steps_pkg.C_REMAINING_PAY then
1180     --
1181     -- Handled as 100%.
1182     --
1183     seterrorstage(l_proc, 'C_REMAINING_PAY', 60);
1184     l_amount := null;
1185     l_percentage := 100;
1186   else
1187     --
1188     -- Should not reach here.
1189     --
1190     seterrorstage(l_proc, 'AMOUNT_TYPE:'||p_amount_type, 70);
1191     fnd_message.set_name('PAY', 'PAY_51518_PSS_ASSERT_ERROR');
1192     fnd_message.set_token('WHERE', l_proc);
1193     fnd_message.set_token
1194     ('ADDITIONAL_INFO', '<p_amount_type = ' || p_amount_type || '>');
1195     fnd_msg_pub.add;
1196     p_return_status := fnd_api.G_RET_STS_UNEXP_ERROR;
1197     fnd_msg_pub.count_and_get
1198     (p_count => p_msg_count
1199     ,p_data  => p_msg_data
1200     );
1201     return;
1202   end if;
1203   --
1204   -- Set up the business_group_id for the INSERT and UPDATE operations.
1205   --
1206   if p_state = pay_pss_tx_steps_pkg.C_STATE_NEW then
1207     --
1208     -- Check for (fatal) business_group_id error. If this error
1209     -- occurs then the module is broken.
1210     --
1211     seterrorstage(l_proc, 'ASG_BUSGRPID', 80);
1212     begin
1213       open csr_asg_busgrp
1214       (p_assignment_id  => p_assignment_id
1215       ,p_effective_date => p_effective_date
1216       );
1217       fetch csr_asg_busgrp
1218       into  l_business_group_id;
1219       close csr_asg_busgrp;
1220       hr_api.validate_bus_grp_id
1221       (p_business_group_id => l_business_group_id
1222       );
1223     exception
1224       when others then
1225         if csr_asg_busgrp%isopen then
1226           close csr_asg_busgrp;
1227         end if;
1228         raise;
1229     end;
1230   elsif p_state  = pay_pss_tx_steps_pkg.C_STATE_UPDATED then
1231     --
1232     -- Check for (fatal) business_group_id error. If this error
1233     -- occurs then the module is broken.
1234     --
1235     seterrorstage(l_proc, 'PPM_BUSGRPID', 90);
1236     begin
1237       open csr_ppm_busgrp
1238       (p_personal_payment_method_id => p_personal_payment_method_id
1239       ,p_effective_date             => p_effective_date
1240       );
1241       fetch csr_ppm_busgrp
1242       into  l_business_group_id;
1243       close csr_ppm_busgrp;
1244       hr_api.validate_bus_grp_id
1245       (p_business_group_id => l_business_group_id
1246       );
1247     exception
1248       when others then
1249         if csr_ppm_busgrp%isopen then
1250           close csr_ppm_busgrp;
1251         end if;
1252         raise;
1253     end;
1254   end if;
1255   --
1256   -- Set up the internal PPM record structure.
1257   --
1258   seterrorstage(l_proc, 'CONVERT_ARGS', 100);
1259   l_rec := pay_ppm_shd.convert_args
1260   (p_personal_payment_method_id =>
1261    nvl(p_personal_payment_method_id, l_default_number)
1262   ,p_effective_start_date       => null
1263   ,p_effective_end_date         => null
1264   ,p_business_group_id          => l_business_group_id
1265   ,p_external_account_id        => l_external_account_id
1266   ,p_assignment_id              => nvl(p_assignment_id, l_default_number)
1267   ,p_run_type_id                => p_run_type_id
1268   ,p_org_payment_method_id      =>
1269    nvl(p_org_payment_method_id, l_default_number)
1270   ,p_amount                     => l_amount
1271   ,p_comment_id                 => l_default_number
1272   ,p_comments                   => l_default_varchar2
1273   ,p_percentage                 => l_percentage
1274   ,p_priority                   => hr_api.g_number
1275   ,p_attribute_category         => p_attribute_category
1276   ,p_attribute1                 => p_attribute1
1277   ,p_attribute2                 => p_attribute2
1278   ,p_attribute3                 => p_attribute3
1279   ,p_attribute4                 => p_attribute4
1280   ,p_attribute5                 => p_attribute5
1281   ,p_attribute6                 => p_attribute6
1282   ,p_attribute7                 => p_attribute7
1283   ,p_attribute8                 => p_attribute8
1284   ,p_attribute9                 => p_attribute9
1285   ,p_attribute10                => p_attribute10
1286   ,p_attribute11                => p_attribute11
1287   ,p_attribute12                => p_attribute12
1288   ,p_attribute13                => p_attribute13
1289   ,p_attribute14                => p_attribute14
1290   ,p_attribute15                => p_attribute15
1291   ,p_attribute16                => p_attribute16
1292   ,p_attribute17                => p_attribute17
1293   ,p_attribute18                => p_attribute18
1294   ,p_attribute19                => p_attribute19
1295   ,p_attribute20                => p_attribute20
1296   ,p_object_version_number      =>
1297    nvl(p_object_version_number, l_default_number)
1298   ,p_payee_type                 => l_default_varchar2
1299   ,p_payee_id                   => l_default_number
1300   ,p_ppm_information_category   => null
1301   ,p_ppm_information1           => null
1302   ,p_ppm_information2           => null
1303   ,p_ppm_information3           => null
1304   ,p_ppm_information4           => null
1305   ,p_ppm_information5           => null
1306   ,p_ppm_information6           => null
1307   ,p_ppm_information7           => null
1308   ,p_ppm_information8           => null
1309   ,p_ppm_information9           => null
1310   ,p_ppm_information10          => null
1311   ,p_ppm_information11          => null
1312   ,p_ppm_information12          => null
1313   ,p_ppm_information13          => null
1314   ,p_ppm_information14          => null
1315   ,p_ppm_information15          => null
1316   ,p_ppm_information16          => null
1317   ,p_ppm_information17          => null
1318   ,p_ppm_information18          => null
1319   ,p_ppm_information19          => null
1320   ,p_ppm_information20          => null
1321   ,p_ppm_information21          => null
1322   ,p_ppm_information22          => null
1323   ,p_ppm_information23          => null
1324   ,p_ppm_information24          => null
1325   ,p_ppm_information25          => null
1326   ,p_ppm_information26          => null
1327   ,p_ppm_information27          => null
1328   ,p_ppm_information28          => null
1329   ,p_ppm_information29          => null
1330   ,p_ppm_information30          => null
1331   );
1332   --
1333   -- Do initial checks specific to each operation.
1334   --
1335   if p_state = pay_pss_tx_steps_pkg.C_STATE_NEW then
1336     --
1337     -- Do the record locking. If this code fails then it is fatal
1338     -- error within the module.
1339     --
1340     seterrorstage(l_proc, 'INS:INITIAL', 110);
1341     begin
1342       pay_ppm_ins.ins_lck
1343       (p_effective_date        => p_effective_date
1344       ,p_datetrack_mode        => l_datetrack_mode
1345       ,p_rec                   => l_rec
1346       ,p_validation_start_date => l_validation_start_date
1347       ,p_validation_end_date   => l_validation_end_date
1348       );
1349       --
1350       l_validation_end_date := pay_ppm_bus.return_effective_end_date
1351       (p_datetrack_mode             =>  l_datetrack_mode
1352       ,p_effective_date             =>  p_effective_date
1353       ,p_org_payment_method_id      =>  l_rec.org_payment_method_id
1354       ,p_business_group_id          =>  l_rec.business_group_id
1355       ,p_personal_payment_method_id =>  l_rec.personal_payment_method_id
1356       ,p_assignment_id              =>  l_rec.assignment_id
1357       ,p_run_type_id                =>  l_rec.run_type_id
1358       ,p_priority                   =>  l_rec.priority
1359       ,p_validation_start_date      =>  l_validation_start_date
1360       ,p_validation_end_date        =>  l_validation_end_date
1361       );
1362     exception
1363       when others then
1364         raise;
1365     end;
1366     --
1367     -- Check for (fatal) org_payment_method_id error. The module is
1368     -- broken if a correct value for org_payment_method_id is not
1369     -- supplied because the org_payment_method_id select list is
1370     -- generated.
1371     --
1372     begin
1373       pay_ppm_bus.chk_org_payment_method_id
1374       (p_business_group_id     => l_business_group_id
1375       ,p_org_payment_method_id => l_rec.org_payment_method_id
1376       ,p_effective_date        => p_effective_date
1377       );
1378     exception
1379       when others then
1380         raise;
1381     end;
1382   elsif p_state = pay_pss_tx_steps_pkg.C_STATE_UPDATED then
1383     --
1384     -- Do the record locking. If this code fails then it is fatal
1385     -- error within the module.
1386     --
1387     seterrorstage(l_proc, 'UPD:INITIAL', 120);
1388     begin
1389       pay_ppm_shd.lck
1390       (p_effective_date             => p_effective_date
1391       ,p_datetrack_mode             => l_datetrack_mode
1392       ,p_personal_payment_method_id => l_rec.personal_payment_method_id
1393       ,p_object_version_number      => l_rec.object_version_number
1394       ,p_validation_start_date      => l_validation_start_date
1395       ,p_validation_end_date        => l_validation_end_date
1396       );
1397     exception
1398       when others then
1399         raise;
1400     end;
1401     --
1402     -- Convert the default values to the actual values.
1403     --
1404     pay_ppm_upd.convert_defs(p_rec => l_rec);
1405     --
1406     -- Check for (fatal) error in the arguments that may not be updated.
1407     -- Such an error indicates a bug in the module.
1408     --
1409     seterrorstage(l_proc, 'CHK_NON_UPDATEABLE', 130);
1410     begin
1411       pay_ppm_bus.check_non_updateable_args
1412       (p_rec            => l_rec
1413       ,p_effective_date => p_effective_date
1414       );
1415     exception
1416       when others then
1417         raise;
1418     end;
1419   end if;
1420   --
1421   -- Now call the segment validation code.
1422   --
1423   seterrorstage(l_proc, 'VALIDATE_BANK_SEGMENTS', 150);
1424   begin
1425     --
1426     if p_payment_type = pay_pss_tx_steps_pkg.C_DEPOSIT then
1427       --
1428       -- The OA key flex code inserts into the combination table: therefore,
1429       -- p_external_account_id refers to an existing row in
1430       -- PAY_EXTERNAL_ACCOUNTS.
1431       --
1432       l_external_account_id := p_external_account_id;
1433       pay_exa_upd.upd_or_sel
1434       (p_segment1              => p_segment1
1435       ,p_segment2              => p_segment2
1436       ,p_segment3              => p_segment3
1437       ,p_segment4              => p_segment4
1438       ,p_segment5              => p_segment5
1439       ,p_segment6              => p_segment6
1440       ,p_segment7              => p_segment7
1441       ,p_segment8              => p_segment8
1442       ,p_segment9              => p_segment9
1443       ,p_segment10             => p_segment10
1444       ,p_segment11             => p_segment11
1445       ,p_segment12             => p_segment12
1446       ,p_segment13             => p_segment13
1447       ,p_segment14             => p_segment14
1448       ,p_segment15             => p_segment15
1449       ,p_segment16             => p_segment16
1450       ,p_segment17             => p_segment17
1451       ,p_segment18             => p_segment18
1452       ,p_segment19             => p_segment19
1453       ,p_segment20             => p_segment20
1454       ,p_segment21             => p_segment21
1455       ,p_segment22             => p_segment22
1456       ,p_segment23             => p_segment23
1457       ,p_segment24             => p_segment24
1458       ,p_segment25             => p_segment25
1459       ,p_segment26             => p_segment26
1460       ,p_segment27             => p_segment27
1461       ,p_segment28             => p_segment28
1462       ,p_segment29             => p_segment29
1463       ,p_segment30             => p_segment30
1464       ,p_concat_segments       => null
1465       ,p_business_group_id     => l_business_group_id
1466       ,p_territory_code        => p_territory_code
1467       ,p_external_account_id   => l_external_account_id
1468       ,p_object_version_number => l_external_account_ovn
1469       ,p_prenote_date          => null
1470       ,p_validate              => false
1471       );
1472     end if;
1473   exception
1474     when others then
1475       l_exa_user_error := true;
1476       l_user_error := true;
1477       l_external_account_id := null;
1478       hr_message.provide_error;
1479       l_message_name := hr_message.last_message_name;
1480       --
1481       -- Can set field-level errors for US and GB segments.
1482       --
1483       if (p_territory_code = 'US' and
1484            ( l_message_name = 'HR_51458_EXA_US_ACCT_NAME_LONG' or
1485              l_message_name = 'HR_51459_EXA_US_ACCT_TYPE_LONG' or
1486              l_message_name = 'HR_51460_EXA_US_ACC_TYP_UNKNOW' or
1487              l_message_name = 'HR_51461_EXA_US_ACCT_NO_LONG'   or
1488              l_message_name = 'HR_51462_EXA_US_TRAN_CODE_LONG' or
1489              l_message_name = 'HR_51463_EXA_US_BANK_NAME_LONG' or
1490              l_message_name = 'HR_51464_EXA_US_BANK_BRAN_LONG'
1491            )
1492          ) or
1493          (p_territory_code = 'GB' and
1494            ( l_message_name = 'HR_51416_EXA_BANK_NAME_LONG'     or
1495              l_message_name = 'HR_51417_EXA_BANK_NAME_UNKNOWN'  or
1496              l_message_name = 'HR_51418_EXA_BANK_BRANCH_LONG'   or
1497              l_message_name = 'HR_51419_EXA_SORT_CODE_LENGTH'   or
1498              l_message_name = 'HR_51420_EXA_SORT_CODE_POSITVE'  or
1499              l_message_name = 'HR_51421_EXA_ACCOUNT_NO_LONG'    or
1500              l_message_name = 'HR_51422_EXA_ACCT_NO_POSITIVE'   or
1501              l_message_name = 'HR_51423_EXA_ACCOUNT_NAME_LONG'  or
1502              l_message_name = 'HR_51424_EXA_ACCOUNT_NAME_CASE'  or
1503              l_message_name = 'HR_51425_EXA_ACCOUNT_TYPE_LONG'  or
1504              l_message_name = 'HR_51426_EXA_ACCT_TYPE_RANGE'    or
1505              l_message_name = 'HR_51427_EXA_BS_ACCT_NO_LONG'    or
1506              l_message_name = 'HR_51428_EXA_BS_ACCT_NO_CASE'    or
1507              l_message_name = 'HR_51429_EXA_BANK_LOC_LONG'      or
1508              l_message_name = 'HR_51430_EXA_BANK_LOC_UNKNOWN'
1509            )
1510          )
1511       then
1512         fnd_msg_pub.add;
1513       end if;
1514       --
1515       -- Handle generic flexfield errors.
1516       --
1517       if l_message_name = 'HR_FLEX_VALUE_MISSING' then
1518         fnd_message.set_name('PER', 'HR_WEB_REQUIRED_FIELD');
1519         fnd_msg_pub.add;
1520       elsif l_message_name = 'HR_FLEX_VALUE_INVALID' then
1521         fnd_message.set_name('PER', 'PAY_52634_PPM_BAD_FLEX_VALUE');
1522         l_prompt := hr_message.get_token_value(p_token_name => 'PROMPT');
1523         fnd_message.set_token('PROMPT', l_prompt);
1524         fnd_msg_pub.add;
1525       else
1526         --
1527         -- General flexfield message that cannot be assigned to a
1528         -- particular field.
1529         --
1530         fnd_msg_pub.add;
1531       end if;
1532   end;
1533   --
1534   -- Check Transit Code for US Bank flex.
1535   --
1536   if p_territory_code = 'US' then
1537     l_transit_code_sum := 0;
1538     --
1539     -- Standard Transit Code checking algorithm.
1540     --
1541     l_check_digit := substr(p_segment4, 9, 1);
1542     for i in 1 .. 8 loop
1543       if i = 1 or i = 4 or i = 7 then
1544         l_transit_code_sum :=
1545         l_transit_code_sum + 3 * substr(p_segment4, i, 1);
1546       elsif i = 2 or i = 5 or i = 8 then
1547         l_transit_code_sum :=
1548         l_transit_code_sum + 7 * substr(p_segment4, i, 1);
1549       else
1550         l_transit_code_sum :=
1551         l_transit_code_sum + substr(p_segment4, i, 1);
1552       end if;
1553     end loop;
1554     l_transit_code_sum := 10 - mod(l_transit_code_sum, 10);
1555     if l_transit_code_sum = 10 then
1556       l_transit_code_sum := 0;
1557     end if;
1558     if l_transit_code_sum <> l_check_digit then
1559       l_exa_user_error := true;
1560       l_user_error := true;
1561       fnd_message.set_name('PAY', 'PAY_50043_INVALID_TRANSIT_CODE');
1562       fnd_msg_pub.add;
1563     end if;
1564   end if;
1565   --
1566   -- Only do the external_account_id check if there are no
1567   -- errors.
1568   --
1569   if not l_exa_user_error then
1570     seterrorstage(l_proc, 'CHK_EXA_ID', 160);
1571     begin
1572       pay_ppm_bus.chk_external_account_id
1573       (p_personal_payment_method_id => p_personal_payment_method_id
1574       ,p_org_payment_method_id      => l_rec.org_payment_method_id
1575       ,p_external_account_id        => l_external_account_id
1576       ,p_effective_date             => p_effective_date
1577       ,p_object_version_number      => p_object_version_number
1578       );
1579     exception
1580       when others then
1581         l_user_error := true;
1582         hr_message.provide_error;
1583         l_message_name := hr_message.last_message_name;
1584         if l_message_name = 'HR_6678_PPM_MT_BANK' then
1585           --
1586           -- The user did not supply bank details when required.
1587           --
1588           fnd_msg_pub.add;
1589         else
1590           --
1591           -- The remaining errors are fatal errors because they
1592           -- concern data that the module should set up correctly.
1593           --
1594           raise;
1595         end if;
1596     end;
1597   end if;
1598   --
1599   -- defined_balance_id check - this is yet another fatal error
1600   -- check.
1601   --
1602   begin
1603     seterrorstage(l_proc, 'CHK_DEF_BAL_ID', 170);
1604     pay_ppm_bus.chk_defined_balance_id
1605     (p_business_group_id           =>  l_rec.business_group_id
1606     ,p_assignment_id               =>  l_rec.assignment_id
1607     ,p_personal_payment_method_id  =>  l_rec.personal_payment_method_id
1608     ,p_org_payment_method_id       =>  l_rec.org_payment_method_id
1609     ,p_effective_date              =>  p_effective_date
1610     ,p_object_version_number       =>  l_rec.object_version_number
1611     ,p_payee_type                  =>  l_rec.payee_type
1612     ,p_payee_id                    =>  l_rec.payee_id
1613     );
1614   exception
1615     when others then
1616       raise;
1617   end;
1618   --
1619   -- Amount and percentage checks.
1620   --
1621   begin
1622     seterrorstage(l_proc, 'CHK_AMOUNT', 180);
1623     pay_ppm_bus.chk_amount_percent
1624     (p_amount                     => l_rec.amount
1625     ,p_percentage                 => l_rec.percentage
1626     ,p_personal_payment_method_id => l_rec.personal_payment_method_id
1627     ,p_org_payment_method_id      => l_rec.org_payment_method_id
1628     ,p_effective_date             => p_effective_date
1629     ,p_object_version_number      => l_rec.object_version_number
1630     );
1631   exception
1632     when others then
1633       l_user_error := true;
1634       hr_message.provide_error;
1635       l_message_name := hr_message.last_message_name;
1636       if l_message_name = 'HR_6221_PAYM_INVALID_PPM' or
1637          l_message_name = 'HR_6680_PPM_AMT_PERC' then
1638         --
1639         -- Choose more specific messages based on whether or not
1640         -- the configuration is for percent only or amount only.
1641         --
1642         if p_amount_type = pay_pss_tx_steps_pkg.C_PERCENTAGE or
1643            p_amount_type = pay_pss_tx_steps_pkg.C_MONETARY then
1644           fnd_msg_pub.add;
1645         else
1646           fnd_message.set_name('PER', 'HR_WEB_REQUIRED_FIELD');
1647           fnd_msg_pub.add;
1648         end if;
1649       elsif l_message_name = 'HR_7355_PPM_AMOUNT_NEGATIVE' or
1650             l_message_name = 'HR_7040_PERCENT_RANGE'       or
1651             l_message_name = 'HR_7912_CHECK_FMT_MONEY'     or
1652             l_message_name = 'HR_7913_CHK_FMT_INTEGER'
1653       then
1654         fnd_msg_pub.add;
1655       else
1656         --
1657         -- Some other (fatal) error.
1658         --
1659         raise;
1660       end if;
1661     end;
1662   --
1663   -- Check the descriptive flex field - another user-level error.
1664   --
1665   begin
1666     seterrorstage(l_proc, 'CHK_DF', 190);
1667     pay_ppm_bus.chk_df(p_rec => l_rec);
1668   exception
1669     when others then
1670       l_user_error := true;
1671       hr_message.provide_error;
1672       l_message_name := hr_message.last_message_name;
1673       if l_message_name = 'HR_FLEX_VALUE_MISSING' then
1674         fnd_message.set_name('PER', 'HR_WEB_REQUIRED_FIELD');
1675         fnd_msg_pub.add;
1676       elsif l_message_name = 'HR_FLEX_VALUE_INVALID' then
1677         l_prompt := hr_message.get_token_value(p_token_name => 'PROMPT');
1678         fnd_message.set_name('PER', 'PAY_52634_PPM_BAD_FLEX_VALUE');
1679         fnd_message.set_token('PROMPT', l_prompt);
1680         fnd_msg_pub.add;
1681       else
1682         if l_message_name is null then
1683           if fnd_flex_descval.encoded_error_message is not null then
1684             fnd_message.set_encoded(fnd_flex_descval.encoded_error_message);
1685           end if;
1686         end if;
1687         --
1688         -- General flexfield message that cannot be assigned to a
1689         -- particular field.
1690         --
1691         fnd_msg_pub.add;
1692       end if;
1693   end;
1694   --
1695   rollback to start_validate;
1696   --
1697   -- Set up messages to Oracle Applications API standards as these
1698   -- are handled "for free" using checkErrors.
1699   --
1700   if l_user_error then
1701     seterrorstage(l_proc, 'GOT_USER_ERRORS', 200);
1702     p_return_status := fnd_api.G_RET_STS_ERROR;
1703   else
1704     seterrorstage(l_proc, 'NO_USER_ERRORS', 205);
1705     p_return_status := fnd_api.G_RET_STS_SUCCESS;
1706   end if;
1707   fnd_msg_pub.count_and_get
1708   (p_count => p_msg_count
1709   ,p_data  => p_msg_data
1710   );
1711   seterrorstage(l_proc, 'EXIT:SUCCESS', 210);
1712   return;
1713 exception
1714   when others then
1715     rollback to start_validate;
1716     seterrorstage(l_proc, 'EXIT:FAIL', 220);
1717     --
1718     -- Set up messages to Oracle Applications API standards as these
1719     -- are handled "for free" using checkErrors.
1720     --
1721     p_return_status := fnd_api.G_RET_STS_UNEXP_ERROR;
1722     fnd_msg_pub.initialize;
1723     fnd_message.set_name('PAY', 'PAY_51518_PSS_ASSERT_ERROR');
1724     fnd_message.set_token('WHERE', l_proc);
1725     fnd_message.set_token('ADDITIONAL_INFO', sqlerrm);
1726     fnd_msg_pub.add;
1727     fnd_msg_pub.count_and_get
1728     (p_count => p_msg_count
1729     ,p_data  => p_msg_data
1730     );
1731     return;
1732 end validateppm;
1733 -----------------------------< process_api >------------------------
1734 procedure process_api
1735 (p_state                      in     varchar2 default null
1736 ,p_personal_payment_method_id in     number   default null
1737 ,p_object_version_number      in     number   default null
1738 ,p_delete_ovn                 in     number   default null
1739 ,p_update_datetrack_mode      in     varchar2 default null
1740 ,p_delete_datetrack_mode      in     varchar2 default null
1741 ,p_effective_date             in     date     default null
1742 ,p_org_payment_method_id      in     number   default null
1743 ,p_assignment_id              in     number   default null
1744 ,p_run_type_id                in     number   default null
1745 ,p_territory_code             in     varchar2 default null
1746 ,p_real_priority              in     number   default null
1747 ,p_amount_type                in     varchar2 default null
1748 ,p_amount                     in     number   default null
1749 ,p_attribute_category         in     varchar2 default null
1750 ,p_attribute1                 in     varchar2 default null
1751 ,p_attribute2                 in     varchar2 default null
1752 ,p_attribute3                 in     varchar2 default null
1753 ,p_attribute4                 in     varchar2 default null
1754 ,p_attribute5                 in     varchar2 default null
1755 ,p_attribute6                 in     varchar2 default null
1756 ,p_attribute7                 in     varchar2 default null
1757 ,p_attribute8                 in     varchar2 default null
1758 ,p_attribute9                 in     varchar2 default null
1759 ,p_attribute10                in     varchar2 default null
1760 ,p_attribute11                in     varchar2 default null
1761 ,p_attribute12                in     varchar2 default null
1762 ,p_attribute13                in     varchar2 default null
1763 ,p_attribute14                in     varchar2 default null
1764 ,p_attribute15                in     varchar2 default null
1765 ,p_attribute16                in     varchar2 default null
1766 ,p_attribute17                in     varchar2 default null
1767 ,p_attribute18                in     varchar2 default null
1768 ,p_attribute19                in     varchar2 default null
1769 ,p_attribute20                in     varchar2 default null
1770 ,p_segment1                   in     varchar2 default null
1771 ,p_segment2                   in     varchar2 default null
1772 ,p_segment3                   in     varchar2 default null
1773 ,p_segment4                   in     varchar2 default null
1774 ,p_segment5                   in     varchar2 default null
1775 ,p_segment6                   in     varchar2 default null
1776 ,p_segment7                   in     varchar2 default null
1777 ,p_segment8                   in     varchar2 default null
1778 ,p_segment9                   in     varchar2 default null
1779 ,p_segment10                  in     varchar2 default null
1780 ,p_segment11                  in     varchar2 default null
1781 ,p_segment12                  in     varchar2 default null
1782 ,p_segment13                  in     varchar2 default null
1783 ,p_segment14                  in     varchar2 default null
1784 ,p_segment15                  in     varchar2 default null
1785 ,p_segment16                  in     varchar2 default null
1786 ,p_segment17                  in     varchar2 default null
1787 ,p_segment18                  in     varchar2 default null
1788 ,p_segment19                  in     varchar2 default null
1789 ,p_segment20                  in     varchar2 default null
1790 ,p_segment21                  in     varchar2 default null
1791 ,p_segment22                  in     varchar2 default null
1792 ,p_segment23                  in     varchar2 default null
1793 ,p_segment24                  in     varchar2 default null
1794 ,p_segment25                  in     varchar2 default null
1795 ,p_segment26                  in     varchar2 default null
1796 ,p_segment27                  in     varchar2 default null
1797 ,p_segment28                  in     varchar2 default null
1798 ,p_segment29                  in     varchar2 default null
1799 ,p_segment30                  in     varchar2 default null
1800 ,p_o_real_priority            in     number   default null
1801 ,p_validate                   in     boolean  default false
1802 ) is
1803 l_effective_date             date;
1804 --
1805 -- Various OUT-parameters.
1806 --
1807 l_effective_start_date       date;
1808 l_effective_end_date         date;
1809 l_object_version_number      number;
1810 l_personal_payment_method_id number;
1811 l_external_account_id        number;
1812 l_comment_id                 number;
1813 --
1814 -- Percentage/Amount.
1815 --
1816 l_percentage                 number;
1817 l_amount                     number;
1818 begin
1819   l_object_version_number := p_object_version_number;
1820   l_personal_payment_method_id := p_personal_payment_method_id;
1821   --
1822   -- Set Percentage/Amount.
1823   --
1824   if p_amount_type = pay_pss_tx_steps_pkg.C_PERCENTAGE or
1825      p_amount_type = pay_pss_tx_steps_pkg.C_PERCENTAGE_ONLY then
1826     l_percentage := p_amount;
1827     l_amount := null;
1828   elsif p_amount_type = pay_pss_tx_steps_pkg.C_MONETARY or
1829         p_amount_type = pay_pss_tx_steps_pkg.C_MONETARY_ONLY then
1830     l_percentage := null;
1831     l_amount := p_amount;
1832 
1833     --
1834     -- If its the C_REMAINING_PAY (i.e. lowest priority) pay method,
1835     -- then setting the values to hr_api.g_number so that original values are retained
1836     -- when date track apis enters a new record.
1837   else
1838     l_percentage := hr_api.g_number;
1839     l_amount := hr_api.g_number;
1840   end if;
1841   --
1842   -- Check the PPM state to determine which API call to make.
1843   --
1844   if p_state = pay_pss_tx_steps_pkg.C_STATE_NEW then
1845     hr_personal_pay_method_api.create_personal_pay_method
1846     (p_validate                   => p_validate
1847     ,p_effective_date             => p_effective_date
1848     ,p_assignment_id              => p_assignment_id
1849     ,p_run_type_id                => p_run_type_id
1850     ,p_org_payment_method_id      => p_org_payment_method_id
1851     ,p_personal_payment_method_id => l_personal_payment_method_id
1852     ,p_object_version_number      => l_object_version_number
1853     ,p_amount                     => l_amount
1854     ,p_percentage                 => l_percentage
1855     ,p_priority                   => p_real_priority
1856     ,p_attribute_category         => p_attribute_category
1857     ,p_attribute1                 => p_attribute1
1858     ,p_attribute2                 => p_attribute2
1859     ,p_attribute3                 => p_attribute3
1860     ,p_attribute4                 => p_attribute4
1861     ,p_attribute5                 => p_attribute5
1862     ,p_attribute6                 => p_attribute6
1863     ,p_attribute7                 => p_attribute7
1864     ,p_attribute8                 => p_attribute8
1865     ,p_attribute9                 => p_attribute9
1866     ,p_attribute10                => p_attribute10
1867     ,p_attribute11                => p_attribute11
1868     ,p_attribute12                => p_attribute12
1869     ,p_attribute13                => p_attribute13
1870     ,p_attribute14                => p_attribute14
1871     ,p_attribute15                => p_attribute15
1872     ,p_attribute16                => p_attribute16
1873     ,p_attribute17                => p_attribute17
1874     ,p_attribute18                => p_attribute18
1875     ,p_attribute19                => p_attribute19
1876     ,p_attribute20                => p_attribute20
1877     ,p_territory_code             => p_territory_code
1878     ,p_segment1                   => p_segment1
1879     ,p_segment2                   => p_segment2
1880     ,p_segment3                   => p_segment3
1881     ,p_segment4                   => p_segment4
1882     ,p_segment5                   => p_segment5
1883     ,p_segment6                   => p_segment6
1884     ,p_segment7                   => p_segment7
1885     ,p_segment8                   => p_segment8
1886     ,p_segment9                   => p_segment9
1887     ,p_segment10                  => p_segment10
1888     ,p_segment11                  => p_segment11
1889     ,p_segment12                  => p_segment12
1890     ,p_segment13                  => p_segment13
1891     ,p_segment14                  => p_segment14
1892     ,p_segment15                  => p_segment15
1893     ,p_segment16                  => p_segment16
1894     ,p_segment17                  => p_segment17
1895     ,p_segment18                  => p_segment18
1896     ,p_segment19                  => p_segment19
1897     ,p_segment20                  => p_segment20
1898     ,p_segment21                  => p_segment21
1899     ,p_segment22                  => p_segment22
1900     ,p_segment23                  => p_segment23
1901     ,p_segment24                  => p_segment24
1902     ,p_segment25                  => p_segment25
1903     ,p_segment26                  => p_segment26
1904     ,p_segment27                  => p_segment27
1905     ,p_segment28                  => p_segment28
1906     ,p_segment29                  => p_segment29
1907     ,p_segment30                  => p_segment30
1908     ,p_external_account_id        => l_external_account_id
1909     ,p_effective_start_date       => l_effective_start_date
1910     ,p_effective_end_date         => l_effective_end_date
1911     ,p_comment_id                 => l_comment_id
1912     );
1913   elsif p_state = pay_pss_tx_steps_pkg.C_STATE_UPDATED then
1914     hr_personal_pay_method_api.update_personal_pay_method
1915     (p_validate                   => p_validate
1916     ,p_effective_date             => p_effective_date
1917     ,p_datetrack_update_mode      => p_update_datetrack_mode
1918     ,p_personal_payment_method_id => p_personal_payment_method_id
1919     ,p_object_version_number      => l_object_version_number
1920     ,p_amount                     => l_amount
1921     ,p_percentage                 => l_percentage
1922     ,p_priority                   => p_real_priority
1923     ,p_attribute_category         => p_attribute_category
1924     ,p_attribute1                 => p_attribute1
1925     ,p_attribute2                 => p_attribute2
1926     ,p_attribute3                 => p_attribute3
1927     ,p_attribute4                 => p_attribute4
1928     ,p_attribute5                 => p_attribute5
1929     ,p_attribute6                 => p_attribute6
1930     ,p_attribute7                 => p_attribute7
1931     ,p_attribute8                 => p_attribute8
1932     ,p_attribute9                 => p_attribute9
1933     ,p_attribute10                => p_attribute10
1934     ,p_attribute11                => p_attribute11
1935     ,p_attribute12                => p_attribute12
1936     ,p_attribute13                => p_attribute13
1937     ,p_attribute14                => p_attribute14
1938     ,p_attribute15                => p_attribute15
1939     ,p_attribute16                => p_attribute16
1940     ,p_attribute17                => p_attribute17
1941     ,p_attribute18                => p_attribute18
1942     ,p_attribute19                => p_attribute19
1943     ,p_attribute20                => p_attribute20
1944     ,p_territory_code             => p_territory_code
1945     ,p_segment1                   => p_segment1
1946     ,p_segment2                   => p_segment2
1947     ,p_segment3                   => p_segment3
1948     ,p_segment4                   => p_segment4
1949     ,p_segment5                   => p_segment5
1950     ,p_segment6                   => p_segment6
1951     ,p_segment7                   => p_segment7
1952     ,p_segment8                   => p_segment8
1953     ,p_segment9                   => p_segment9
1954     ,p_segment10                  => p_segment10
1955     ,p_segment11                  => p_segment11
1956     ,p_segment12                  => p_segment12
1957     ,p_segment13                  => p_segment13
1958     ,p_segment14                  => p_segment14
1959     ,p_segment15                  => p_segment15
1960     ,p_segment16                  => p_segment16
1961     ,p_segment17                  => p_segment17
1962     ,p_segment18                  => p_segment18
1963     ,p_segment19                  => p_segment19
1964     ,p_segment20                  => p_segment20
1965     ,p_segment21                  => p_segment21
1966     ,p_segment22                  => p_segment22
1967     ,p_segment23                  => p_segment23
1968     ,p_segment24                  => p_segment24
1969     ,p_segment25                  => p_segment25
1970     ,p_segment26                  => p_segment26
1971     ,p_segment27                  => p_segment27
1972     ,p_segment28                  => p_segment28
1973     ,p_segment29                  => p_segment29
1974     ,p_segment30                  => p_segment30
1975     ,p_external_account_id        => l_external_account_id
1976     ,p_effective_start_date       => l_effective_start_date
1977     ,p_effective_end_date         => l_effective_end_date
1978     ,p_comment_id                 => l_comment_id
1979     );
1980   elsif p_state = pay_pss_tx_steps_pkg.C_STATE_DELETED then
1981     l_object_version_number := p_delete_ovn;
1982     if p_delete_datetrack_mode = hr_api.g_zap then
1983       l_effective_date := p_effective_date;
1984     else
1985       l_effective_date := p_effective_date - 1;
1986     end if;
1987     hr_personal_pay_method_api.delete_personal_pay_method
1988     (p_validate                   => p_validate
1989     ,p_effective_date             => l_effective_date
1990     ,p_datetrack_delete_mode      => p_delete_datetrack_mode
1991     ,p_personal_payment_method_id => p_personal_payment_method_id
1992     ,p_object_version_number      => l_object_version_number
1993     ,p_effective_start_date       => l_effective_start_date
1994     ,p_effective_end_date         => l_effective_end_date
1995     );
1996   elsif p_state = pay_pss_tx_steps_pkg.C_STATE_EXISTING and
1997         p_real_priority <> p_o_real_priority then
1998     hr_personal_pay_method_api.update_personal_pay_method
1999     (p_validate                   => p_validate
2000     ,p_personal_payment_method_id => p_personal_payment_method_id
2001     ,p_object_version_number      => l_object_version_number
2002     ,p_effective_date             => p_effective_date
2003     ,p_datetrack_update_mode      => p_update_datetrack_mode
2004     ,p_priority                   => p_real_priority
2005     ,p_external_account_id        => l_external_account_id
2006     ,p_effective_start_date       => l_effective_start_date
2007     ,p_effective_end_date         => l_effective_end_date
2008     ,p_comment_id                 => l_comment_id
2009     );
2010   end if;
2011 exception
2012   when others then
2013     raise;
2014 end process_api;
2015 -------------------------< get_bank_segments >----------------------
2016 procedure get_bank_segments
2017 (p_external_account_id in     number
2018 ,p_segment1               out nocopy varchar2
2019 ,p_segment2               out nocopy varchar2
2020 ,p_segment3               out nocopy varchar2
2021 ,p_segment4               out nocopy varchar2
2022 ,p_segment5               out nocopy varchar2
2023 ,p_segment6               out nocopy varchar2
2024 ,p_segment7               out nocopy varchar2
2025 ,p_segment8               out nocopy varchar2
2026 ,p_segment9               out nocopy varchar2
2027 ,p_segment10              out nocopy varchar2
2028 ,p_segment11              out nocopy varchar2
2029 ,p_segment12              out nocopy varchar2
2030 ,p_segment13              out nocopy varchar2
2031 ,p_segment14              out nocopy varchar2
2032 ,p_segment15              out nocopy varchar2
2033 ,p_segment16              out nocopy varchar2
2034 ,p_segment17              out nocopy varchar2
2035 ,p_segment18              out nocopy varchar2
2036 ,p_segment19              out nocopy varchar2
2037 ,p_segment20              out nocopy varchar2
2038 ,p_segment21              out nocopy varchar2
2039 ,p_segment22              out nocopy varchar2
2040 ,p_segment23              out nocopy varchar2
2041 ,p_segment24              out nocopy varchar2
2042 ,p_segment25              out nocopy varchar2
2043 ,p_segment26              out nocopy varchar2
2044 ,p_segment27              out nocopy varchar2
2045 ,p_segment28              out nocopy varchar2
2046 ,p_segment29              out nocopy varchar2
2047 ,p_segment30              out nocopy varchar2
2048 ) is
2049 l_proc varchar2(2000) := g_package || 'get_bank_segments';
2050 begin
2051   --
2052   -- Use SELECT ... INTO ... rather than a cursor as this select
2053   -- statement must return segments. The OA framework code inserts
2054   -- into the combination table.
2055   --
2056   seterrorstage(l_proc, 'ENTER', 10);
2057   select  segment1
2058   ,       segment2
2059   ,       segment3
2060   ,       segment4
2061   ,       segment5
2062   ,       segment6
2063   ,       segment7
2064   ,       segment8
2065   ,       segment9
2066   ,       segment10
2067   ,       segment11
2068   ,       segment12
2069   ,       segment13
2070   ,       segment14
2071   ,       segment15
2072   ,       segment16
2073   ,       segment17
2074   ,       segment18
2075   ,       segment19
2076   ,       segment20
2077   ,       segment21
2078   ,       segment22
2079   ,       segment23
2080   ,       segment24
2081   ,       segment25
2082   ,       segment26
2083   ,       segment27
2084   ,       segment28
2085   ,       segment29
2086   ,       segment30
2087   into    p_segment1
2088   ,       p_segment2
2089   ,       p_segment3
2090   ,       p_segment4
2091   ,       p_segment5
2092   ,       p_segment6
2093   ,       p_segment7
2094   ,       p_segment8
2095   ,       p_segment9
2096   ,       p_segment10
2097   ,       p_segment11
2098   ,       p_segment12
2099   ,       p_segment13
2100   ,       p_segment14
2101   ,       p_segment15
2102   ,       p_segment16
2103   ,       p_segment17
2104   ,       p_segment18
2105   ,       p_segment19
2106   ,       p_segment20
2107   ,       p_segment21
2108   ,       p_segment22
2109   ,       p_segment23
2110   ,       p_segment24
2111   ,       p_segment25
2112   ,       p_segment26
2113   ,       p_segment27
2114   ,       p_segment28
2115   ,       p_segment29
2116   ,       p_segment30
2117   from    pay_external_accounts
2118   where   external_account_id = p_external_account_id;
2119 exception
2120   when others then
2121     seterrorstage(l_proc, 'EXIT:FAIL', 20);
2122     raise;
2123 end get_bank_segments;
2124 --
2125 end pay_ppmv4_utils_ss;