DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_OPM_BUS

Source


1 Package Body pay_opm_bus as
2 /* $Header: pyopmrhi.pkb 120.4 2005/11/07 01:38:13 pgongada noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pay_opm_bus.';  -- Global package name
9 --
10 -- The following two global variables are only to be
11 -- used by the return_legislation_code function.
12 --
13 g_legislation_code            varchar2(150)  default null;
14 g_org_payment_method_id       number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_org_payment_method_id                in number
22   ) is
23   --
24   -- Declare cursor
25   --
26   cursor csr_sec_grp is
27     select pbg.security_group_id
28       from per_business_groups pbg
29          , pay_org_payment_methods_f opm
30      where opm.org_payment_method_id = p_org_payment_method_id
31        and pbg.business_group_id = opm.business_group_id;
32   --
33   -- Declare local variables
34   --
35   l_security_group_id number;
36   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
37   --
38 begin
39   --
40   hr_utility.set_location('Entering:'|| l_proc, 10);
41   --
42   -- Ensure that all the mandatory parameter are not null
43   --
44   hr_api.mandatory_arg_error
45     (p_api_name           => l_proc
46     ,p_argument           => 'org_payment_method_id'
47     ,p_argument_value     => p_org_payment_method_id
48     );
49   --
50   open csr_sec_grp;
51   fetch csr_sec_grp into l_security_group_id;
52   --
53   if csr_sec_grp%notfound then
54      --
55      close csr_sec_grp;
56      --
57      -- The primary key is invalid therefore we must error
58      --
59      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
60      fnd_message.raise_error;
61      --
62   end if;
63   close csr_sec_grp;
64   --
65   -- Set the security_group_id in CLIENT_INFO
66   --
67   hr_api.set_security_group_id
68     (p_security_group_id => l_security_group_id
69     );
70   --
71   hr_utility.set_location(' Leaving:'|| l_proc, 20);
72   --
73 end set_security_group_id;
74 --
75 --  ---------------------------------------------------------------------------
76 --  |---------------------< return_legislation_code >-------------------------|
77 --  ---------------------------------------------------------------------------
78 --
79 Function return_legislation_code
80   (p_org_payment_method_id                in     number
81   )
82   Return Varchar2 Is
83   --
84   -- Declare cursor
85   --
86   cursor csr_leg_code is
87     select pbg.legislation_code
88       from per_business_groups pbg
89          , pay_org_payment_methods_f opm
90      where opm.org_payment_method_id = p_org_payment_method_id
91        and pbg.business_group_id = opm.business_group_id;
92   --
93   -- Declare local variables
94   --
95   l_legislation_code  varchar2(150);
96   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
97   --
98 Begin
99   --
100   hr_utility.set_location('Entering:'|| l_proc, 10);
101   --
102   -- Ensure that all the mandatory parameter are not null
103   --
104   hr_api.mandatory_arg_error
105     (p_api_name           => l_proc
106     ,p_argument           => 'org_payment_method_id'
107     ,p_argument_value     => p_org_payment_method_id
108     );
109   --
110   if ( nvl(pay_opm_bus.g_org_payment_method_id, hr_api.g_number)
111        = p_org_payment_method_id) then
112     --
113     -- The legislation code has already been found with a previous
114     -- call to this function. Just return the value in the global
115     -- variable.
116     --
117     l_legislation_code := pay_opm_bus.g_legislation_code;
118     hr_utility.set_location(l_proc, 20);
119   else
120     --
121     -- The ID is different to the last call to this function
122     -- or this is the first call to this function.
123     --
124     open csr_leg_code;
125     fetch csr_leg_code into l_legislation_code;
126     --
127     if csr_leg_code%notfound then
128       --
129       -- The primary key is invalid therefore we must error
130       --
131       close csr_leg_code;
132       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
133       fnd_message.raise_error;
134     end if;
135     hr_utility.set_location(l_proc,30);
136     --
137     -- Set the global variables so the values are
138     -- available for the next call to this function.
139     --
140     close csr_leg_code;
141     pay_opm_bus.g_org_payment_method_id:= p_org_payment_method_id;
142     pay_opm_bus.g_legislation_code  := l_legislation_code;
143   end if;
144   hr_utility.set_location(' Leaving:'|| l_proc, 40);
145   return l_legislation_code;
146 end return_legislation_code;
147 --
148 -- ----------------------------------------------------------------------------
149 -- |-----------------------------< chk_ddf >----------------------------------|
150 -- ----------------------------------------------------------------------------
151 --
152 -- Description:
153 --   Validates all the Developer Descriptive Flexfield values.
154 --
155 -- Prerequisites:
156 --   All other columns have been validated.  Must be called as the
157 --   last step from insert_validate and update_validate.
158 --
159 -- In Arguments:
160 --   p_rec
161 --
162 -- Post Success:
163 --   If the Developer Descriptive Flexfield structure column and data values
164 --   are all valid this procedure will end normally and processing will
165 --   continue.
166 --
167 -- Post Failure:
168 --   If the Developer Descriptive Flexfield structure column value or any of
169 --   the data values are invalid then an application error is raised as
170 --   a PL/SQL exception.
171 --
172 -- Access Status:
173 --   Internal Row Handler Use Only.
174 --
175 -- ----------------------------------------------------------------------------
176 procedure chk_ddf
177   (p_rec in pay_opm_shd.g_rec_type
178   ) is
179 --
180   l_proc   varchar2(72) := g_package || 'chk_ddf';
181 --
182 begin
183   hr_utility.set_location('Entering:'||l_proc,10);
184   --
185   if ((p_rec.org_payment_method_id is not null)  and (
186     nvl(pay_opm_shd.g_old_rec.pmeth_information_category, hr_api.g_varchar2) <>
187     nvl(p_rec.pmeth_information_category, hr_api.g_varchar2)  or
188     nvl(pay_opm_shd.g_old_rec.pmeth_information1, hr_api.g_varchar2) <>
189     nvl(p_rec.pmeth_information1, hr_api.g_varchar2)  or
190     nvl(pay_opm_shd.g_old_rec.pmeth_information2, hr_api.g_varchar2) <>
191     nvl(p_rec.pmeth_information2, hr_api.g_varchar2)  or
192     nvl(pay_opm_shd.g_old_rec.pmeth_information3, hr_api.g_varchar2) <>
193     nvl(p_rec.pmeth_information3, hr_api.g_varchar2)  or
194     nvl(pay_opm_shd.g_old_rec.pmeth_information4, hr_api.g_varchar2) <>
195     nvl(p_rec.pmeth_information4, hr_api.g_varchar2)  or
196     nvl(pay_opm_shd.g_old_rec.pmeth_information5, hr_api.g_varchar2) <>
197     nvl(p_rec.pmeth_information5, hr_api.g_varchar2)  or
198     nvl(pay_opm_shd.g_old_rec.pmeth_information6, hr_api.g_varchar2) <>
199     nvl(p_rec.pmeth_information6, hr_api.g_varchar2)  or
200     nvl(pay_opm_shd.g_old_rec.pmeth_information7, hr_api.g_varchar2) <>
201     nvl(p_rec.pmeth_information7, hr_api.g_varchar2)  or
202     nvl(pay_opm_shd.g_old_rec.pmeth_information8, hr_api.g_varchar2) <>
203     nvl(p_rec.pmeth_information8, hr_api.g_varchar2)  or
204     nvl(pay_opm_shd.g_old_rec.pmeth_information9, hr_api.g_varchar2) <>
205     nvl(p_rec.pmeth_information9, hr_api.g_varchar2)  or
206     nvl(pay_opm_shd.g_old_rec.pmeth_information10, hr_api.g_varchar2) <>
207     nvl(p_rec.pmeth_information10, hr_api.g_varchar2)  or
208     nvl(pay_opm_shd.g_old_rec.pmeth_information11, hr_api.g_varchar2) <>
209     nvl(p_rec.pmeth_information11, hr_api.g_varchar2)  or
210     nvl(pay_opm_shd.g_old_rec.pmeth_information12, hr_api.g_varchar2) <>
211     nvl(p_rec.pmeth_information12, hr_api.g_varchar2)  or
212     nvl(pay_opm_shd.g_old_rec.pmeth_information13, hr_api.g_varchar2) <>
213     nvl(p_rec.pmeth_information13, hr_api.g_varchar2)  or
214     nvl(pay_opm_shd.g_old_rec.pmeth_information14, hr_api.g_varchar2) <>
215     nvl(p_rec.pmeth_information14, hr_api.g_varchar2)  or
216     nvl(pay_opm_shd.g_old_rec.pmeth_information15, hr_api.g_varchar2) <>
217     nvl(p_rec.pmeth_information15, hr_api.g_varchar2)  or
218     nvl(pay_opm_shd.g_old_rec.pmeth_information16, hr_api.g_varchar2) <>
219     nvl(p_rec.pmeth_information16, hr_api.g_varchar2)  or
220     nvl(pay_opm_shd.g_old_rec.pmeth_information17, hr_api.g_varchar2) <>
221     nvl(p_rec.pmeth_information17, hr_api.g_varchar2)  or
222     nvl(pay_opm_shd.g_old_rec.pmeth_information18, hr_api.g_varchar2) <>
223     nvl(p_rec.pmeth_information18, hr_api.g_varchar2)  or
224     nvl(pay_opm_shd.g_old_rec.pmeth_information19, hr_api.g_varchar2) <>
225     nvl(p_rec.pmeth_information19, hr_api.g_varchar2)  or
226     nvl(pay_opm_shd.g_old_rec.pmeth_information20, hr_api.g_varchar2) <>
227     nvl(p_rec.pmeth_information20, hr_api.g_varchar2) ))
228     or (p_rec.org_payment_method_id is null)  then
229     --
230     -- Only execute the validation if absolutely necessary:
231     -- a) During update, the structure column value or any
232     --    of the attribute values have actually changed.
233     -- b) During insert.
234     --
235     hr_dflex_utility.ins_or_upd_descflex_attribs
236       (p_appl_short_name                 => 'PAY'
237       ,p_descflex_name                   => 'Paymeth Developer DF'
238       ,p_attribute_category              => p_rec.PMETH_INFORMATION_CATEGORY
239       ,p_attribute1_name                 => 'PMETH_INFORMATION1'
240       ,p_attribute1_value                => p_rec.pmeth_information1
241       ,p_attribute2_name                 => 'PMETH_INFORMATION2'
242       ,p_attribute2_value                => p_rec.pmeth_information2
243       ,p_attribute3_name                 => 'PMETH_INFORMATION3'
244       ,p_attribute3_value                => p_rec.pmeth_information3
245       ,p_attribute4_name                 => 'PMETH_INFORMATION4'
246       ,p_attribute4_value                => p_rec.pmeth_information4
247       ,p_attribute5_name                 => 'PMETH_INFORMATION5'
248       ,p_attribute5_value                => p_rec.pmeth_information5
249       ,p_attribute6_name                 => 'PMETH_INFORMATION6'
250       ,p_attribute6_value                => p_rec.pmeth_information6
251       ,p_attribute7_name                 => 'PMETH_INFORMATION7'
252       ,p_attribute7_value                => p_rec.pmeth_information7
253       ,p_attribute8_name                 => 'PMETH_INFORMATION8'
254       ,p_attribute8_value                => p_rec.pmeth_information8
255       ,p_attribute9_name                 => 'PMETH_INFORMATION9'
256       ,p_attribute9_value                => p_rec.pmeth_information9
257       ,p_attribute10_name                => 'PMETH_INFORMATION10'
258       ,p_attribute10_value               => p_rec.pmeth_information10
259       ,p_attribute11_name                => 'PMETH_INFORMATION11'
260       ,p_attribute11_value               => p_rec.pmeth_information11
261       ,p_attribute12_name                => 'PMETH_INFORMATION12'
262       ,p_attribute12_value               => p_rec.pmeth_information12
263       ,p_attribute13_name                => 'PMETH_INFORMATION13'
264       ,p_attribute13_value               => p_rec.pmeth_information13
265       ,p_attribute14_name                => 'PMETH_INFORMATION14'
266       ,p_attribute14_value               => p_rec.pmeth_information14
267       ,p_attribute15_name                => 'PMETH_INFORMATION15'
268       ,p_attribute15_value               => p_rec.pmeth_information15
269       ,p_attribute16_name                => 'PMETH_INFORMATION16'
270       ,p_attribute16_value               => p_rec.pmeth_information16
271       ,p_attribute17_name                => 'PMETH_INFORMATION17'
272       ,p_attribute17_value               => p_rec.pmeth_information17
273       ,p_attribute18_name                => 'PMETH_INFORMATION18'
274       ,p_attribute18_value               => p_rec.pmeth_information18
275       ,p_attribute19_name                => 'PMETH_INFORMATION19'
276       ,p_attribute19_value               => p_rec.pmeth_information19
277       ,p_attribute20_name                => 'PMETH_INFORMATION20'
278       ,p_attribute20_value               => p_rec.pmeth_information20
279       );
280   end if;
281   --
282   hr_utility.set_location(' Leaving:'||l_proc,20);
283 end chk_ddf;
284 --
285 -- ----------------------------------------------------------------------------
286 -- |------------------------------< chk_df >----------------------------------|
287 -- ----------------------------------------------------------------------------
288 --
289 -- Description:
290 --   Validates all the Descriptive Flexfield values.
291 --
292 -- Prerequisites:
293 --   All other columns have been validated.  Must be called as the
294 --   last step from insert_validate and update_validate.
295 --
296 -- In Arguments:
297 --   p_rec
298 --
299 -- Post Success:
300 --   If the Descriptive Flexfield structure column and data values are
301 --   all valid this procedure will end normally and processing will
302 --   continue.
303 --
304 -- Post Failure:
305 --   If the Descriptive Flexfield structure column value or any of
306 --   the data values are invalid then an application error is raised as
307 --   a PL/SQL exception.
308 --
309 -- Access Status:
310 --   Internal Row Handler Use Only.
311 --
312 -- ----------------------------------------------------------------------------
313 procedure chk_df
314   (p_rec in pay_opm_shd.g_rec_type
315   ) is
316 --
317   l_proc   varchar2(72) := g_package || 'chk_df';
318 --
319 begin
320   hr_utility.set_location('Entering:'||l_proc,10);
321   --
322   if ((p_rec.org_payment_method_id is not null)  and (
323     nvl(pay_opm_shd.g_old_rec.attribute_category, hr_api.g_varchar2) <>
324     nvl(p_rec.attribute_category, hr_api.g_varchar2)  or
325     nvl(pay_opm_shd.g_old_rec.attribute1, hr_api.g_varchar2) <>
326     nvl(p_rec.attribute1, hr_api.g_varchar2)  or
327     nvl(pay_opm_shd.g_old_rec.attribute2, hr_api.g_varchar2) <>
328     nvl(p_rec.attribute2, hr_api.g_varchar2)  or
329     nvl(pay_opm_shd.g_old_rec.attribute3, hr_api.g_varchar2) <>
330     nvl(p_rec.attribute3, hr_api.g_varchar2)  or
331     nvl(pay_opm_shd.g_old_rec.attribute4, hr_api.g_varchar2) <>
332     nvl(p_rec.attribute4, hr_api.g_varchar2)  or
333     nvl(pay_opm_shd.g_old_rec.attribute5, hr_api.g_varchar2) <>
334     nvl(p_rec.attribute5, hr_api.g_varchar2)  or
335     nvl(pay_opm_shd.g_old_rec.attribute6, hr_api.g_varchar2) <>
336     nvl(p_rec.attribute6, hr_api.g_varchar2)  or
337     nvl(pay_opm_shd.g_old_rec.attribute7, hr_api.g_varchar2) <>
338     nvl(p_rec.attribute7, hr_api.g_varchar2)  or
339     nvl(pay_opm_shd.g_old_rec.attribute8, hr_api.g_varchar2) <>
340     nvl(p_rec.attribute8, hr_api.g_varchar2)  or
341     nvl(pay_opm_shd.g_old_rec.attribute9, hr_api.g_varchar2) <>
342     nvl(p_rec.attribute9, hr_api.g_varchar2)  or
343     nvl(pay_opm_shd.g_old_rec.attribute10, hr_api.g_varchar2) <>
344     nvl(p_rec.attribute10, hr_api.g_varchar2)  or
345     nvl(pay_opm_shd.g_old_rec.attribute11, hr_api.g_varchar2) <>
346     nvl(p_rec.attribute11, hr_api.g_varchar2)  or
347     nvl(pay_opm_shd.g_old_rec.attribute12, hr_api.g_varchar2) <>
348     nvl(p_rec.attribute12, hr_api.g_varchar2)  or
349     nvl(pay_opm_shd.g_old_rec.attribute13, hr_api.g_varchar2) <>
350     nvl(p_rec.attribute13, hr_api.g_varchar2)  or
351     nvl(pay_opm_shd.g_old_rec.attribute14, hr_api.g_varchar2) <>
352     nvl(p_rec.attribute14, hr_api.g_varchar2)  or
353     nvl(pay_opm_shd.g_old_rec.attribute15, hr_api.g_varchar2) <>
354     nvl(p_rec.attribute15, hr_api.g_varchar2)  or
355     nvl(pay_opm_shd.g_old_rec.attribute16, hr_api.g_varchar2) <>
356     nvl(p_rec.attribute16, hr_api.g_varchar2)  or
357     nvl(pay_opm_shd.g_old_rec.attribute17, hr_api.g_varchar2) <>
358     nvl(p_rec.attribute17, hr_api.g_varchar2)  or
359     nvl(pay_opm_shd.g_old_rec.attribute18, hr_api.g_varchar2) <>
360     nvl(p_rec.attribute18, hr_api.g_varchar2)  or
361     nvl(pay_opm_shd.g_old_rec.attribute19, hr_api.g_varchar2) <>
362     nvl(p_rec.attribute19, hr_api.g_varchar2)  or
363     nvl(pay_opm_shd.g_old_rec.attribute20, hr_api.g_varchar2) <>
364     nvl(p_rec.attribute20, hr_api.g_varchar2) ))
365     or (p_rec.org_payment_method_id is null)  then
366     --
367     -- Only execute the validation if absolutely necessary:
368     -- a) During update, the structure column value or any
369     --    of the attribute values have actually changed.
370     -- b) During insert.
371     --
372     hr_dflex_utility.ins_or_upd_descflex_attribs
373       (p_appl_short_name                 => 'PAY'
374       ,p_descflex_name                   => 'PAY_ORG_PAYMENT_METHODS'
375       ,p_attribute_category              => p_rec.ATTRIBUTE_CATEGORY
376       ,p_attribute1_name                 => 'ATTRIBUTE1'
377       ,p_attribute1_value                => p_rec.attribute1
378       ,p_attribute2_name                 => 'ATTRIBUTE2'
379       ,p_attribute2_value                => p_rec.attribute2
380       ,p_attribute3_name                 => 'ATTRIBUTE3'
381       ,p_attribute3_value                => p_rec.attribute3
382       ,p_attribute4_name                 => 'ATTRIBUTE4'
383       ,p_attribute4_value                => p_rec.attribute4
384       ,p_attribute5_name                 => 'ATTRIBUTE5'
385       ,p_attribute5_value                => p_rec.attribute5
386       ,p_attribute6_name                 => 'ATTRIBUTE6'
387       ,p_attribute6_value                => p_rec.attribute6
388       ,p_attribute7_name                 => 'ATTRIBUTE7'
389       ,p_attribute7_value                => p_rec.attribute7
390       ,p_attribute8_name                 => 'ATTRIBUTE8'
391       ,p_attribute8_value                => p_rec.attribute8
392       ,p_attribute9_name                 => 'ATTRIBUTE9'
393       ,p_attribute9_value                => p_rec.attribute9
394       ,p_attribute10_name                => 'ATTRIBUTE10'
395       ,p_attribute10_value               => p_rec.attribute10
396       ,p_attribute11_name                => 'ATTRIBUTE11'
397       ,p_attribute11_value               => p_rec.attribute11
398       ,p_attribute12_name                => 'ATTRIBUTE12'
399       ,p_attribute12_value               => p_rec.attribute12
400       ,p_attribute13_name                => 'ATTRIBUTE13'
401       ,p_attribute13_value               => p_rec.attribute13
402       ,p_attribute14_name                => 'ATTRIBUTE14'
403       ,p_attribute14_value               => p_rec.attribute14
404       ,p_attribute15_name                => 'ATTRIBUTE15'
405       ,p_attribute15_value               => p_rec.attribute15
406       ,p_attribute16_name                => 'ATTRIBUTE16'
407       ,p_attribute16_value               => p_rec.attribute16
408       ,p_attribute17_name                => 'ATTRIBUTE17'
409       ,p_attribute17_value               => p_rec.attribute17
410       ,p_attribute18_name                => 'ATTRIBUTE18'
411       ,p_attribute18_value               => p_rec.attribute18
412       ,p_attribute19_name                => 'ATTRIBUTE19'
413       ,p_attribute19_value               => p_rec.attribute19
414       ,p_attribute20_name                => 'ATTRIBUTE20'
415       ,p_attribute20_value               => p_rec.attribute20
416       );
417   end if;
418   --
419   hr_utility.set_location(' Leaving:'||l_proc,20);
420 end chk_df;
421 --
422 -- ----------------------------------------------------------------------------
423 -- |-----------------------< chk_non_updateable_args >------------------------|
424 -- ----------------------------------------------------------------------------
425 -- {Start Of Comments}
426 --
427 -- Description:
428 --   This procedure is used to ensure that non updateable attributes have
429 --   not been updated. If an attribute has been updated an error is generated.
430 --
431 -- Pre Conditions:
432 --   g_old_rec has been populated with details of the values currently in
433 --   the database.
434 --
435 -- In Arguments:
436 --   p_rec has been populated with the updated values the user would like the
437 --   record set to.
438 --
439 -- Post Success:
440 --   Processing continues if all the non updateable attributes have not
441 --   changed.
442 --
443 -- Post Failure:
444 --   An application error is raised if any of the non updatable attributes
445 --   have been altered.
446 --
447 -- {End Of Comments}
448 -- ----------------------------------------------------------------------------
449 Procedure chk_non_updateable_args
450   (p_effective_date  in date
451   ,p_rec             in pay_opm_shd.g_rec_type
452   ) IS
453 --
454   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
455   l_error    EXCEPTION;
456   l_argument varchar2(30);
457 --
458 Begin
459   --
460   hr_utility.set_location(l_proc, 5);
461   --
462   -- Only proceed with the validation if a row exists for the current
463   -- record in the HR Schema.
464   --
465   IF NOT pay_opm_shd.api_updating
466       (p_org_payment_method_id            => p_rec.org_payment_method_id
467       ,p_effective_date                   => p_effective_date
468       ,p_object_version_number            => p_rec.object_version_number
469       ) THEN
470      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
471      fnd_message.set_token('PROCEDURE ', l_proc);
472      fnd_message.set_token('STEP ', '5');
473      fnd_message.raise_error;
474   END IF;
475   --
476   hr_utility.set_location(l_proc, 10);
477   --
478   if nvl(p_rec.business_group_id, hr_api.g_number) <>
479      pay_opm_shd.g_old_rec.business_group_id then
480      l_argument := 'business_group_id';
481      raise l_error;
482   end if;
483   --
484   hr_utility.set_location(l_proc, 20);
485   --
486   if nvl(p_rec.payment_type_id, hr_api.g_number) <>
487      pay_opm_shd.g_old_rec.payment_type_id then
488      l_argument := 'payment_type_id';
489      raise l_error;
490   end if;
491   --
492   hr_utility.set_location(l_proc, 30);
493   --
494   if nvl(p_rec.defined_balance_id, hr_api.g_number) <>
495      nvl(pay_opm_shd.g_old_rec.defined_balance_id, hr_api.g_number) then
496      l_argument := 'defined_balance_id';
497      raise l_error;
498   end if;
499   --
500   hr_utility.set_location(l_proc, 35);
501   --
502   if nvl(p_rec.org_payment_method_name, hr_api.g_varchar2) <>
503      nvl(pay_opm_shd.g_old_rec.org_payment_method_name, hr_api.g_varchar2) then
504      l_argument := 'org_payment_method_name';
505      raise l_error;
506   end if;
507   --
508   hr_utility.set_location(l_proc, 40);
509   --
510   EXCEPTION
511     WHEN l_error THEN
512        hr_api.argument_changed_error
513          (p_api_name => l_proc
514          ,p_argument => l_argument);
515     WHEN OTHERS THEN
516        RAISE;
517 End chk_non_updateable_args;
518 --
519 -- ----------------------------------------------------------------------------
520 -- |--------------------------< dt_update_validate >--------------------------|
521 -- ----------------------------------------------------------------------------
522 -- {Start Of Comments}
523 --
524 -- Description:
525 --   This procedure is used for referential integrity of datetracked
526 --   parent entities when a datetrack update operation is taking place
527 --   and where there is no cascading of update defined for this entity.
528 --
529 -- Prerequisites:
530 --   This procedure is called from the update_validate.
531 --
532 -- In Parameters:
533 --
534 -- Post Success:
535 --   Processing continues.
536 --
537 -- Post Failure:
538 --
539 -- Developer Implementation Notes:
540 --   This procedure should not need maintenance unless the HR Schema model
541 --   changes.
542 --
543 -- Access Status:
544 --   Internal Row Handler Use Only.
545 --
546 -- {End Of Comments}
547 -- ----------------------------------------------------------------------------
548 Procedure dt_update_validate
549   (p_datetrack_mode                in varchar2
550   ,p_validation_start_date         in date
551   ,p_validation_end_date           in date
552   ) Is
553 --
554   l_proc  varchar2(72) := g_package||'dt_update_validate';
555   l_integrity_error Exception;
556   l_table_name      all_tables.table_name%TYPE;
557 --
558 Begin
559   --
560   -- Ensure that the p_datetrack_mode argument is not null
561   --
562   hr_api.mandatory_arg_error
563     (p_api_name       => l_proc
564     ,p_argument       => 'datetrack_mode'
565     ,p_argument_value => p_datetrack_mode
566     );
567   --
568   -- Mode will be valid, as this is checked at the start of the upd.
569   --
570   -- Ensure the arguments are not null
571   --
572   hr_api.mandatory_arg_error
573     (p_api_name       => l_proc
574     ,p_argument       => 'validation_start_date'
575     ,p_argument_value => p_validation_start_date
576     );
577   --
578   hr_api.mandatory_arg_error
579     (p_api_name       => l_proc
580     ,p_argument       => 'validation_end_date'
581     ,p_argument_value => p_validation_end_date
582     );
583   --
584     --
585   --
586 Exception
587   When l_integrity_error Then
588     --
589     -- A referential integrity check was violated therefore
590     -- we must error
591     --
592     fnd_message.set_name('PAY', 'HR_7216_DT_UPD_INTEGRITY_ERR');
593     fnd_message.set_token('TABLE_NAME', l_table_name);
594     fnd_message.raise_error;
595   When Others Then
596     --
597     -- An unhandled or unexpected error has occurred which
598     -- we must report
599     --
600     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
601     fnd_message.set_token('PROCEDURE', l_proc);
602     fnd_message.set_token('STEP','15');
603     fnd_message.raise_error;
604 End dt_update_validate;
605 --
606 -- ----------------------------------------------------------------------------
607 -- |--------------------------< dt_delete_validate >--------------------------|
608 -- ----------------------------------------------------------------------------
609 -- {Start Of Comments}
610 --
611 -- Description:
612 --   This procedure is used for referential integrity of datetracked
613 --   child entities when either a datetrack DELETE or ZAP is in operation
614 --   and where there is no cascading of delete defined for this entity.
615 --   For the datetrack mode of DELETE or ZAP we must ensure that no
616 --   datetracked child rows exist between the validation start and end
617 --   dates.
618 --
619 -- Prerequisites:
620 --   This procedure is called from the delete_validate.
621 --
622 -- In Parameters:
623 --
624 -- Post Success:
625 --   Processing continues.
626 --
627 -- Post Failure:
628 --   If a row exists by determining the returning Boolean value from the
629 --   generic dt_api.rows_exist function then we must supply an error via
630 --   the use of the local exception handler l_rows_exist.
631 --
632 -- Developer Implementation Notes:
633 --   This procedure should not need maintenance unless the HR Schema model
634 --   changes.
635 --
636 -- Access Status:
637 --   Internal Row Handler Use Only.
638 --
639 -- {End Of Comments}
640 -- ----------------------------------------------------------------------------
641 Procedure dt_delete_validate
642   (p_org_payment_method_id            in number
643   ,p_datetrack_mode                   in varchar2
644   ,p_validation_start_date            in date
645   ,p_validation_end_date              in date
646   ) Is
647 --
648   l_proc	varchar2(72) 	:= g_package||'dt_delete_validate';
649   l_rows_exist	Exception;
650   l_table_name	all_tables.table_name%TYPE;
651 --
652 Begin
653   --
654   -- Ensure that the p_datetrack_mode argument is not null
655   --
656   hr_api.mandatory_arg_error
657     (p_api_name       => l_proc
658     ,p_argument       => 'datetrack_mode'
659     ,p_argument_value => p_datetrack_mode
660     );
661   --
662   -- Only perform the validation if the datetrack mode is either
663   -- DELETE or ZAP
664   --
665   If (p_datetrack_mode = hr_api.g_delete or
666       p_datetrack_mode = hr_api.g_zap) then
667     --
668     --
669     -- Ensure the arguments are not null
670     --
671     hr_api.mandatory_arg_error
672       (p_api_name       => l_proc
673       ,p_argument       => 'validation_start_date'
674       ,p_argument_value => p_validation_start_date
675       );
676     --
677     hr_api.mandatory_arg_error
678       (p_api_name       => l_proc
679       ,p_argument       => 'validation_end_date'
680       ,p_argument_value => p_validation_end_date
681       );
682     --
683     hr_api.mandatory_arg_error
684       (p_api_name       => l_proc
685       ,p_argument       => 'org_payment_method_id'
686       ,p_argument_value => p_org_payment_method_id
687       );
688     --
689     If (dt_api.rows_exist
690        (p_base_table_name => 'pay_org_pay_method_usages_f'
691        ,p_base_key_column => 'org_payment_method_id'
692        ,p_base_key_value  => p_org_payment_method_id
693        ,p_from_date       => p_validation_start_date
694        ,p_to_date         => p_validation_end_date
695        )) Then
696          l_table_name := 'org pay method usages';
697          Raise l_rows_exist;
698     End If;
699     If (dt_api.rows_exist
700        (p_base_table_name => 'pay_personal_payment_methods_f'
701        ,p_base_key_column => 'org_payment_method_id'
702        ,p_base_key_value  => p_org_payment_method_id
703        ,p_from_date       => p_validation_start_date
704        ,p_to_date         => p_validation_end_date
705        )) Then
706          l_table_name := 'personal payment methods';
707          Raise l_rows_exist;
708     End If;
709     If (dt_api.rows_exist
710        (p_base_table_name => 'pay_run_type_org_methods_f'
711        ,p_base_key_column => 'org_payment_method_id'
712        ,p_base_key_value  => p_org_payment_method_id
713        ,p_from_date       => p_validation_start_date
714        ,p_to_date         => p_validation_end_date
715        )) Then
716          l_table_name := 'run type org methods';
717          Raise l_rows_exist;
718     End If;
719     -- If (dt_api.rows_exist
720     --    (p_base_table_name => 'pay_all_payrolls_f'
721     --    ,p_base_key_column => 'default_payment_method_id'
722     --    ,p_base_key_value  => p_org_payment_method_id
723     --    ,p_from_date       => p_validation_start_date
724     --    ,p_to_date         => p_validation_end_date
725     --    )) Then
726     --      l_table_name := 'payrolls';
727     --      Raise l_rows_exist;
728     -- End If;
729     --
730   End If;
731   --
732 Exception
733   When l_rows_exist Then
734     --
735     -- A referential integrity check was violated therefore
736     -- we must error
737     --
738     fnd_message.set_name('PAY', 'HR_7215_DT_CHILD_EXISTS');
739     fnd_message.set_token('TABLE_NAME', l_table_name);
740     fnd_message.raise_error;
741   When Others Then
742     --
743     -- An unhandled or unexpected error has occurred which
744     -- we must report
745     --
746     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
747     fnd_message.set_token('PROCEDURE', l_proc);
748     fnd_message.set_token('STEP','15');
749     fnd_message.raise_error;
750   --
751 End dt_delete_validate;
752 --
753 -- ----------------------------------------------------------------------------
754 -- |----------------------< chk_external_account_id >-------------------------|
755 -- ----------------------------------------------------------------------------
756 --
757 --  Description:
758 --    Check that the external_account_id is not null and that it refers to a
759 --    row on the parent PAY_EXTERNAL_ACCOUNTS table.
760 --    Also cross validate the TERRITORY_CODE with that of Payment Type's.
761 --
762 --    If there is more than one payment methods with the given category
763 --    then it can be null.
764 --
765 --  Pre-Requisites:
766 --    None
767 --
768 --  In Parameters:
769 --    p_external_account_id
770 --    p_payment_type_id
771 --    p_business_group_id
772 --    p_effective_date
773 --    p_org_payment_method_id
774 --    p_object_version_number
775 --
776 --  Post Success:
777 --    Processing continues if the external_account_id is valid.
778 --
779 --  Post Failure:
780 --    An application error is raised and processing is terminated if
781 --    the external_account_id is invalid.
782 --
783 --  Access Status:
784 --    Internal Row Handler Use Only.
785 --
786 Procedure chk_external_account_id
787   (p_external_account_id   in pay_org_payment_methods_f.external_account_id%TYPE
788   ,p_payment_type_id       in pay_org_payment_methods_f.payment_type_id%TYPE
789   ,p_business_group_id     in pay_org_payment_methods_f.business_group_id%TYPE
790   ,p_effective_date        in date
791   ,p_org_payment_method_id in pay_org_payment_methods_f.org_payment_method_id%TYPE
792   ,p_object_version_number in pay_org_payment_methods_f.object_version_number%TYPE
793   ) is
794 --
795   l_proc         varchar2(72) := g_package||'chk_external_account_id';
796   l_api_updating boolean;
797   l_dummy        number;
798   --
799   cursor csr_ext_acc_id_exists is
800     select null
801       from pay_external_accounts exa
802      where exa.external_account_id = p_external_account_id
803        and exists
804              (select null
805                 from pay_payment_types pty
806                where pty.payment_type_id = p_payment_type_id
807                  and ((pty.territory_code is not null
808                        and pty.territory_code = exa.territory_code)
809                       or (pty.territory_code is null
810                           and exists
811                                 (select null
812                                    from per_business_groups pbg
813                                   where pbg.business_group_id = p_business_group_id
814                                     and pbg.legislation_code = exa.territory_code))));
815 --
816   cursor csr_ext_chk is
817     select count (*)
818       from pay_org_payment_methods_f pop,
819            pay_payment_types pyt
820      where pop.payment_type_id = pyt.payment_type_id
821        and pyt.category =
822            ( select pyt.category
823                from pay_payment_types pyt
824               where pyt.payment_type_id = p_payment_type_id)
825        and (p_org_payment_method_id is null
826            or pop.org_payment_method_id <> p_org_payment_method_id )
827        and pop.external_account_id is not null
828        and p_effective_date between pop.effective_start_date and pop.effective_end_date
829        and pop.business_group_id = p_business_group_id;
830 --
831 Begin
832   hr_utility.set_location('Entering:'||l_proc, 5);
833   --
834   --    Check mandatory external_account_id exists
835   --
836   --
837   hr_api.mandatory_arg_error
838     (p_api_name                     => l_proc
839     ,p_argument                     => 'payment_type_id'
840     ,p_argument_value               => p_payment_type_id
841     );
842   --
843   hr_api.mandatory_arg_error
844     (p_api_name                     => l_proc
845     ,p_argument                     => 'business_group_id'
846     ,p_argument_value               => p_business_group_id
847     );
848   --
849   hr_api.mandatory_arg_error
850     (p_api_name                   => l_proc
851     ,p_argument                   => 'effective_date'
852     ,p_argument_value             => p_effective_date
853     );
854   --
855   open csr_ext_chk;
856   fetch csr_ext_chk into l_dummy;
857   close csr_ext_chk;
858   --
859   if p_external_account_id is null and l_dummy > 2 then
860      return;
861   end if;
862   --
863   hr_api.mandatory_arg_error
864     (p_api_name                     => l_proc
865     ,p_argument                     => 'external_account_id'
866     ,p_argument_value               => p_external_account_id
867     );
868   --
869   l_api_updating := pay_opm_shd.api_updating
870     (p_effective_date          => p_effective_date,
871      p_org_payment_method_id   => p_org_payment_method_id,
872      p_object_version_number   => p_object_version_number
873     );
874   --
875   hr_utility.set_location(l_proc,10);
876   --
877   -- Only proceed with SQL validation if absolutely necessary
878   --
879   if ((l_api_updating and
880        nvl(pay_opm_shd.g_old_rec.external_account_id,hr_api.g_number) <>
881        nvl(p_external_account_id,hr_api.g_number))
882        or (NOT l_api_updating)) then
883      --
884      hr_utility.set_location(l_proc,20);
885      --
886      --  Check external_account_id exists within PAY_EXTERNAL_ACCOUNTS.
887      --  Also it check the territory_code of the PAY_EXTERNAL_ACCOUNTS.
888      --
889      open csr_ext_acc_id_exists;
890      fetch csr_ext_acc_id_exists into l_dummy;
891      if csr_ext_acc_id_exists%notfound then
892         close csr_ext_acc_id_exists;
893         pay_opm_shd.constraint_error('PAY_ORG_PAYMENT_METHODS_F_FK2');
894      end if;
895      close csr_ext_acc_id_exists;
896      --
897      hr_utility.set_location(l_proc,30);
898      --
899   end if;
900   --
901   --
902   hr_utility.set_location(' Leaving:'||l_proc, 100);
903 End chk_external_account_id;
904 --
905 -- ----------------------------------------------------------------------------
906 -- |-------------------------< chk_currency_code >----------------------------|
907 -- ----------------------------------------------------------------------------
908 --
909 --  Description:
910 --    Check that the currency_code is not null and that it refers to a
911 --    row on the FND_CURRENCIES_VL table.
912 --    Check whether it is same as of Payment type's (only if it is not null).
913 --
914 --  Pre-Requisites:
915 --    None
916 --
917 --  In Parameters:
918 --    p_currency_code
919 --    p_payment_type_id
920 --    p_effective_date
921 --    p_org_payment_method_id
922 --    p_object_version_number
923 --
924 --  Post Success:
925 --    Processing continues if the currency_code is valid.
926 --
927 --  Post Failure:
928 --    An application error is raised and processing is terminated if
929 --    the currency_code is invalid.
930 --
931 --  Access Status:
932 --    Internal Row Handler Use Only.
933 --
934 Procedure chk_currency_code
935   (p_currency_code         in pay_org_payment_methods_f.currency_code%TYPE
936   ,p_payment_type_id       in pay_org_payment_methods_f.payment_type_id%TYPE
937   ,p_effective_date        in date
938   ,p_org_payment_method_id in pay_org_payment_methods_f.org_payment_method_id%TYPE
939   ,p_object_version_number in pay_org_payment_methods_f.object_version_number%TYPE
940   ) is
941 --
942   l_proc         varchar2(72) := g_package||'chk_currency_code';
943   l_api_updating boolean;
944   l_dummy        number;
945   --
946   cursor csr_currency_code_exists is
947     select null
948       from fnd_currencies_vl cur
949      where cur.enabled_flag = 'Y'
950        and cur.currency_flag = 'Y'
951        and p_effective_date between nvl(start_date_active,p_effective_date)
952            and nvl(end_date_active,p_effective_date)
953        and exists
954              (select null
955                 from pay_payment_types pty
956                where pty.payment_type_id = p_payment_type_id
957                  and (pty.currency_code is null
958                       or (pty.currency_code is not null
959                           and pty.currency_code = p_currency_code)));
960 --
961 --
962 Begin
963   hr_utility.set_location('Entering:'||l_proc, 5);
964   --
965   --    Check mandatory currency_code exists
966   --
967   hr_api.mandatory_arg_error
968     (p_api_name                     => l_proc
969     ,p_argument                     => 'currency_code'
970     ,p_argument_value               => p_currency_code
971     );
972   --
973   hr_api.mandatory_arg_error
974     (p_api_name                     => l_proc
975     ,p_argument                     => 'payment_type_id'
976     ,p_argument_value               => p_payment_type_id
977     );
978   --
979   hr_api.mandatory_arg_error
980     (p_api_name                   => l_proc
981     ,p_argument                   => 'effective_date'
982     ,p_argument_value             => p_effective_date
983     );
984   --
985   l_api_updating := pay_opm_shd.api_updating
986     (p_effective_date          => p_effective_date,
987      p_org_payment_method_id   => p_org_payment_method_id,
988      p_object_version_number   => p_object_version_number
989     );
990   --
991   hr_utility.set_location(l_proc,10);
992   --
993   -- Only proceed with SQL validation if absolutely necessary
994   --
995   if ((l_api_updating and
996        nvl(pay_opm_shd.g_old_rec.currency_code,hr_api.g_varchar2) <>
997        nvl(p_currency_code,hr_api.g_varchar2))
998        or (NOT l_api_updating)) then
999      --
1000      hr_utility.set_location(l_proc,20);
1001      --
1002      --  Check currency_code exists within FND_CURRENCIES_VL.
1003      --  Also checks whether Paymen Type's
1004      --
1005      open csr_currency_code_exists;
1006      fetch csr_currency_code_exists into l_dummy;
1007      if csr_currency_code_exists%notfound then
1008         close csr_currency_code_exists;
1009         -- RAISE ERROR MESSAGE
1010         fnd_message.set_name('PAY', 'HR_7462_PLK_INVLD_VALUE');
1011         fnd_message.set_token('COLUMN_NAME', 'CURRENCY_CODE');
1012         fnd_message.raise_error;
1013      end if;
1014      close csr_currency_code_exists;
1015      --
1016      hr_utility.set_location(l_proc,30);
1017      --
1018   end if;
1019   --
1020   --
1021   hr_utility.set_location(' Leaving:'||l_proc, 100);
1022 End chk_currency_code;
1023 --
1024 -- ----------------------------------------------------------------------------
1025 -- |------------------------< chk_payment_type_id >---------------------------|
1026 -- ----------------------------------------------------------------------------
1027 --
1028 --  Description:
1029 --    Check that the payment_type_id is not null and that it refers to a
1030 --    row on the parent PAY_PAYMENT_TYPES table.
1031 --    Also cross validate whether this is a valid Payment Type for the
1032 --    business group.
1033 --
1034 --  Pre-Requisites:
1035 --    None
1036 --
1037 --  In Parameters:
1038 --    p_payment_type_id
1039 --    p_business_group_id
1040 --    p_org_payment_method_id
1041 --
1042 --  Post Success:
1043 --    Processing continues if the payment_type_id is valid.
1044 --
1045 --  Post Failure:
1046 --    An application error is raised and processing is terminated if
1047 --    the payment_type_id is invalid.
1048 --
1049 --  Access Status:
1050 --    Internal Row Handler Use Only.
1051 --
1052 Procedure chk_payment_type_id
1053   (p_payment_type_id       in pay_org_payment_methods_f.payment_type_id%TYPE
1054   ,p_business_group_id     in pay_org_payment_methods_f.business_group_id%TYPE
1055   ,p_org_payment_method_id in pay_org_payment_methods_f.org_payment_method_id%TYPE
1056   ) is
1057 --
1058   l_proc         varchar2(72) := g_package||'chk_payment_type_id';
1059   l_dummy        number;
1060   --
1061   cursor csr_pay_type_id_exists is
1062     select null
1063       from pay_payment_types pyt
1064      where pyt.payment_type_id = p_payment_type_id
1065        and ((pyt.territory_code is null)
1066             or exists
1067             (select null
1068                from pay_legislation_rules lgr
1069               where lgr.legislation_code = pyt.territory_code
1070                 and lgr.rule_type = 'E'))
1071        and not exists
1072             (select 'x'
1073                from pay_payment_types pyt2,
1074                     per_business_groups pbg
1075               where pyt2.category = pyt.category
1076                 and pbg.business_group_id = p_business_group_id
1077                 and pyt2.territory_code = pbg.legislation_code
1078                 and pyt.territory_code is null
1079                 and pyt2.payment_type_id <> pyt.payment_type_id);
1080 --
1081 --
1082 Begin
1083   hr_utility.set_location('Entering:'||l_proc, 5);
1084   --
1085   --    Check mandatory payment_type_id exists
1086   --
1087   hr_api.mandatory_arg_error
1088     (p_api_name                     => l_proc
1089     ,p_argument                     => 'payment_type_id'
1090     ,p_argument_value               => p_payment_type_id
1091     );
1092   --
1093   hr_api.mandatory_arg_error
1094     (p_api_name                     => l_proc
1095     ,p_argument                     => 'business_group_id'
1096     ,p_argument_value               => p_business_group_id
1097     );
1098   --
1099   --
1100   hr_utility.set_location(l_proc,10);
1101   --
1102   -- Only proceed with SQL validation if absolutely necessary
1103   --
1104   if (p_org_payment_method_id is null) then
1105      --
1106      hr_utility.set_location(l_proc,20);
1107      --
1108      --  Check payment_type_id is a valid entry within PAY_PAYMENT_TYPES.
1109      --
1110      open csr_pay_type_id_exists;
1111      fetch csr_pay_type_id_exists into l_dummy;
1112      if csr_pay_type_id_exists%notfound then
1113         close csr_pay_type_id_exists;
1114         -- RAISE ERROR MESSAGE
1115         fnd_message.set_name('PAY', 'HR_7462_PLK_INVLD_VALUE');
1116         fnd_message.set_token('COLUMN_NAME', 'PAYMENT_TYPE_ID');
1117         fnd_message.raise_error;
1118      end if;
1119      close csr_pay_type_id_exists;
1120      --
1121      hr_utility.set_location(l_proc,30);
1122      --
1123   end if;
1124   --
1125   --
1126   hr_utility.set_location(' Leaving:'||l_proc, 100);
1127 End chk_payment_type_id;
1128 --
1129 -- ----------------------------------------------------------------------------
1130 -- |----------------------< chk_defined_balance_id >--------------------------|
1131 -- ----------------------------------------------------------------------------
1132 --
1133 --  Description:
1134 --    Check that the defined_balance_id is not null and that it refers to a
1135 --    row on the parent PAY_DEFINED_BALANCES table.
1136 --
1137 --  Pre-Requisites:
1138 --    None
1139 --
1140 --  In Parameters:
1141 --    p_defined_balance_id
1142 --    p_business_group_id
1143 --    p_org_payment_method_id
1144 --
1145 --  Post Success:
1146 --    Processing continues if the defined_balance_id is valid.
1147 --
1148 --  Post Failure:
1149 --    An application error is raised and processing is terminated if
1150 --    the defined_balance_id is invalid.
1151 --
1152 --  Access Status:
1153 --    Internal Row Handler Use Only.
1154 --
1155 Procedure chk_defined_balance_id
1156   (p_defined_balance_id    in pay_org_payment_methods_f.defined_balance_id%TYPE
1157   ,p_business_group_id     in pay_org_payment_methods_f.business_group_id%TYPE
1158   ,p_org_payment_method_id in pay_org_payment_methods_f.org_payment_method_id%TYPE
1159   ) is
1160 --
1161   l_proc         varchar2(72) := g_package||'chk_defined_balance_id';
1162   l_dummy        number;
1163   --
1164   cursor csr_def_bal_id_exists is
1165               select  db.defined_balance_id
1166                 from  pay_defined_balances db,
1167                       pay_balance_dimensions bd,
1168          	      pay_balance_types bt
1169                where  nvl(db.business_group_id,p_business_group_id) = p_business_group_id
1170                  and  ((db.legislation_code is null)
1171                        or exists
1172                           (select null
1173                              from per_business_groups pbg
1174                             where pbg.business_group_id = p_business_group_id
1175                               and pbg.legislation_code = db.legislation_code))
1176                  and  db.balance_dimension_id = bd.balance_dimension_id
1177                  and  db.balance_type_id      = bt.balance_type_id
1178                  and  bd.payments_flag = 'Y'
1179                  and  bt.assignment_remuneration_flag = 'Y'
1180                order  by db.business_group_id,db.legislation_code;
1181 --
1182 --
1183 Begin
1184   hr_utility.set_location('Entering:'||l_proc, 5);
1185   --
1186   --    Check mandatory defined_balance_id exists
1187   --
1188   -- hr_api.mandatory_arg_error
1189   --   (p_api_name                     => l_proc
1190   --   ,p_argument                     => 'defined_balance_id'
1191   --   ,p_argument_value               => p_defined_balance_id
1192   --   );
1193   --
1194   hr_api.mandatory_arg_error
1195     (p_api_name                     => l_proc
1196     ,p_argument                     => 'business_group_id'
1197     ,p_argument_value               => p_business_group_id
1198     );
1199   --
1200   --
1201   hr_utility.set_location(l_proc,10);
1202   --
1203   -- Only proceed with SQL validation if absolutely necessary
1204   --
1205   if (p_org_payment_method_id is null and p_defined_balance_id is not null) then
1206      --
1207      hr_utility.set_location(l_proc,20);
1208      --
1209      --  Check payment_type_id is a valid entry within PAY_DEFINED_BALANCES.
1210      --
1211      open csr_def_bal_id_exists;
1212      fetch csr_def_bal_id_exists into l_dummy;
1213      if ((csr_def_bal_id_exists%notfound) or (l_dummy<>p_defined_balance_id)) then
1214         close csr_def_bal_id_exists;
1215         -- RAISE ERROR MESSAGE
1216         fnd_message.set_name('PAY', 'HR_7462_PLK_INVLD_VALUE');
1217         fnd_message.set_token('COLUMN_NAME', 'DEFINED_BALANCE_ID');
1218         fnd_message.raise_error;
1219      end if;
1220      close csr_def_bal_id_exists;
1221      --
1222      hr_utility.set_location(l_proc,30);
1223      --
1224   end if;
1225   --
1226   --
1227   hr_utility.set_location(' Leaving:'||l_proc, 100);
1228 End chk_defined_balance_id;
1229 --
1230 -- ----------------------------------------------------------------------------
1231 -- |--------------------< chk_org_payment_method_name >-----------------------|
1232 -- ----------------------------------------------------------------------------
1233 --
1234 --  Description:
1235 --    Check that the org_payment_method_name is not null.
1236 --
1237 --  Pre-Requisites:
1238 --    None
1239 --
1240 --  In Parameters:
1241 --    p_org_payment_method_name
1242 --    p_business_group_id
1243 --    p_org_payment_method_id
1244 --
1245 --  Post Success:
1246 --    Processing continues if the org_payment_method_name is valid.
1247 --
1248 --  Post Failure:
1249 --    An application error is raised and processing is terminated if
1250 --    the org_payment_method_name is invalid.
1251 --
1252 --  Access Status:
1253 --    Internal Row Handler Use Only.
1254 --
1255 Procedure chk_org_payment_method_name
1256   (p_org_payment_method_name in pay_org_payment_methods_f.org_payment_method_name%TYPE
1257   ,p_business_group_id       in pay_org_payment_methods_f.business_group_id%TYPE
1258   ,p_org_payment_method_id   in pay_org_payment_methods_f.org_payment_method_id%TYPE
1259   ) is
1260 --
1261   l_proc         varchar2(72) := g_package||'chk_org_payment_method_name';
1262   l_api_updating boolean;
1263   l_dummy        number;
1264   --
1265   cursor csr_org_pay_meth_name_exists is
1266      select  null
1267        from  pay_org_payment_methods_f opm
1268       where  upper(opm.org_payment_method_name) = upper(p_org_payment_method_name)
1269         and  (p_org_payment_method_id is null
1270              or p_org_payment_method_id <> opm.org_payment_method_id)
1271         and  opm.business_group_id = p_business_group_id;
1272   --
1273 --
1274 Begin
1275   hr_utility.set_location('Entering:'||l_proc, 5);
1276   --
1277   --    Check mandatory org_payment_method_name exists
1278   --
1279   hr_api.mandatory_arg_error
1280     (p_api_name                     => l_proc
1281     ,p_argument                     => 'org_payment_method_name'
1282     ,p_argument_value               => p_org_payment_method_name
1283     );
1284   --
1285   hr_api.mandatory_arg_error
1286     (p_api_name                   => l_proc
1287     ,p_argument                   => 'business_group_id'
1288     ,p_argument_value             => p_business_group_id
1289     );
1290   --
1291   hr_utility.set_location(l_proc,10);
1292   --
1293   -- Only proceed with SQL validation if absolutely necessary
1294   --
1295   if (p_org_payment_method_id is null) then
1296      --
1297      hr_utility.set_location(l_proc,20);
1298      --
1299      --
1300      open csr_org_pay_meth_name_exists;
1301      fetch csr_org_pay_meth_name_exists into l_dummy;
1302      if csr_org_pay_meth_name_exists%found then
1303         close csr_org_pay_meth_name_exists;
1304         -- RAISE ERROR MESSAGE
1305         fnd_message.set_name('PAY', 'HR_7462_PLK_INVLD_VALUE');
1306         fnd_message.set_token('COLUMN_NAME', 'ORG_PAYMENT_METHOD_NAME');
1307         fnd_message.raise_error;
1308      end if;
1309      close csr_org_pay_meth_name_exists;
1310      --
1311      hr_utility.set_location(l_proc,30);
1312      --
1313   end if;
1314   --
1315   --
1316   hr_utility.set_location(' Leaving:'||l_proc, 100);
1317 End chk_org_payment_method_name;
1318 --
1319 -- ----------------------------------------------------------------------------
1320 -- |--------------------------< chk_pre_payment >-----------------------------|
1321 -- ----------------------------------------------------------------------------
1322 --
1323 --  Description:
1324 --    Checks whether there is any pre_payments exists from the validation date
1325 --    onwards.
1326 --
1327 --  Pre-Requisites:
1328 --    None
1329 --
1330 --  In Parameters:
1331 --    p_validation_start_date
1332 --    p_org_payment_method_id
1333 --
1334 --  Post Success:
1335 --    Processing continues if the p_validation_start_date is valid.
1336 --
1337 --  Post Failure:
1338 --    An application error is raised and processing is terminated if
1339 --    the p_validation_start_date is invalid.
1340 --
1341 --  Access Status:
1342 --    Internal Row Handler Use Only.
1343 --
1344 Procedure chk_pre_payment
1345   (p_validation_start_date   in date
1346   ,p_org_payment_method_id   in pay_org_payment_methods_f.org_payment_method_id%TYPE
1347   ) is
1348 --
1349   l_proc         varchar2(72) := g_package||'chk_pre_payment';
1350   l_api_updating boolean;
1351   l_dummy        number;
1352   --
1353   cursor csr_pre_payment_exists is
1354      select  null
1355        from  pay_pre_payments ppm
1356           ,  pay_assignment_actions paa
1357           ,  pay_payroll_actions ppa
1358       where  ppm.org_payment_method_id = p_org_payment_method_id
1359         and  ppm.assignment_action_id = paa.assignment_action_id
1360         and  paa.payroll_action_id = ppa.payroll_action_id
1361         and ppa.action_type in ('P', 'U')
1362         and  ppa.effective_date >= p_validation_start_date;
1363   --
1364 --
1365 Begin
1366   hr_utility.set_location('Entering:'||l_proc, 5);
1367   --
1368   --
1369   hr_api.mandatory_arg_error
1370     (p_api_name                   => l_proc
1371     ,p_argument                   => 'validation_start_date'
1372     ,p_argument_value             => p_validation_start_date
1373     );
1374   --
1375   hr_utility.set_location(l_proc,10);
1376   --
1377   --
1378      --
1379      --
1380      open csr_pre_payment_exists;
1381      fetch csr_pre_payment_exists into l_dummy;
1382      if csr_pre_payment_exists%found then
1383         close csr_pre_payment_exists;
1384         -- RAISE ERROR MESSAGE
1385         fnd_message.set_name('PAY', 'HR_6226_PAYM_PPS_EXIST');
1386         fnd_message.raise_error;
1387      end if;
1388      close csr_pre_payment_exists;
1389      --
1390      --
1391   --
1392   --
1393   hr_utility.set_location(' Leaving:'||l_proc, 100);
1394 End chk_pre_payment;
1395 -- ----------------------------------------------------------------------------
1396 -- |---------------------< chk_costing_enabled >------------------------------|
1397 -- ----------------------------------------------------------------------------
1398 --
1399 -- Description
1400 --   check the costing is enabled for the given legislation.
1401 -------------------------------------------------------------------------------
1402 procedure chk_costing_enabled
1403 (
1404 p_business_group_id		in	number
1405 ,p_transfer_to_gl_flag		in	varchar2
1406 ,p_cost_payment			in	varchar2
1407 ,p_cost_cleared_payment         in	varchar2
1408 ,p_cost_cleared_void_payment    in	varchar2
1409 ,p_exclude_manual_payment       in	varchar2
1410 ) is
1411 --
1412 l_proc             varchar2(72) := g_package||'chk_costing_enabled';
1413 l_legislation_code varchar2(3);
1414 l_flag             varchar2(1);
1415 l_flag_name	   varchar2(30);
1416 --
1417 cursor csr_chk_leg_field_info is
1418    select lfi.rule_mode
1419      from pay_legislative_field_info lfi
1420     where lfi.validation_type = 'TAB_PAGE_PROPERTY'
1421       and lfi.validation_name = 'DISPLAY'
1422       and lfi.rule_type = 'DISPLAY'
1423       and lfi.field_name = 'COSTING_TAB'
1424       and lfi.target_location = 'PAYWSDPM'
1425       and lfi.legislation_code = l_legislation_code;
1426 begin
1427 	hr_utility.set_location(l_proc,10);
1428 	--
1429 	l_legislation_code := hr_api.return_legislation_code(p_business_group_id);
1430 	--
1431 	open csr_chk_leg_field_info;
1432 	fetch csr_chk_leg_field_info into l_flag;
1433 	if (csr_chk_leg_field_info % NOTFOUND or
1434 	    l_flag = 'N' or l_flag is null ) then
1435 	--
1436 	    if(NVL(p_transfer_to_gl_flag, 'N') = 'Y' or
1437                NVL(p_cost_payment, 'N') = 'Y' or
1438                NVL(p_cost_cleared_payment, 'N') = 'Y' or
1439                NVL(p_cost_cleared_void_payment, 'N') = 'Y' or
1440                NVL(p_exclude_manual_payment, 'N') = 'Y') then
1441 	    --
1442 
1443 			if NVL(p_transfer_to_gl_flag, 'N') = 'Y' then
1444 				l_flag_name := 'P_TRANSFER_TO_GL_FLAG';
1445 			elsif NVL(p_cost_payment, 'N') = 'Y' then
1446 				l_flag_name := 'P_COST_PAYMENT';
1447 			elsif NVL(p_cost_cleared_payment, 'N') = 'Y' then
1448 				l_flag_name := 'P_COST_CLEARED_PAYMENT';
1449 			elsif NVL(p_cost_cleared_void_payment, 'N') = 'Y' then
1450 				l_flag_name := 'P_COST_CLEARED_VOID_PAYMENT';
1451 			elsif NVL(p_exclude_manual_payment, 'N') = 'Y' then
1452 				l_flag_name := 'P_EXCLUDE_MANUAL_PAYMENT';
1453 			end if;
1454 
1455 			fnd_message.set_name('PAY', 'PAY_34525_CST_FLAG_NT_ALLWD');
1456 			fnd_message.set_token('CST_FLAG',l_flag_name);
1457 			fnd_message.raise_error;
1458 	    --
1459 	    end if;
1460 	 --
1461 	 end if;
1462 end chk_costing_enabled;
1463 -- ----------------------------------------------------------------------------
1464 -- |------------------------< chk_cost_payment >------------------------------|
1465 -- ----------------------------------------------------------------------------
1466 --
1467 -- Description
1468 --   cost_payment if specified must be either 'Y' or 'N'.
1469 -------------------------------------------------------------------------------
1470 procedure chk_cost_payment
1471 (
1472   p_effective_date            in date
1473  ,p_cost_payment              in varchar2
1474 ) is
1475 begin
1476   if (p_cost_payment is not null) then
1477   --
1478 	if hr_api.not_exists_in_hr_lookups
1479 	(p_effective_date
1480 	,'YES_NO'
1481 	,p_cost_payment) then
1482 	--
1483 		fnd_message.set_name('PAY','HR_52966_INVALID_LOOKUP');
1484 		fnd_message.set_token('COLUMN','COST_PAYMENT');
1485 		fnd_message.set_token('LOOKUP_TYPE','YES_NO');
1486 		fnd_message.raise_error;
1487 	--
1488 	end If;
1489         --
1490   --
1491   end if;
1492 end chk_cost_payment;
1493 --
1494 -- ----------------------------------------------------------------------------
1495 -- |---------------------< chk_cost_cleared_payment >--------------------------|
1496 -- ----------------------------------------------------------------------------
1497 --
1498 -- Description
1499 --   cost_payment_cleared if specified must be either 'Y' or 'N'.
1500 --   It ensures that when cost_cleared_payment is 'Y' then the cost_payment
1501 --   should be 'Y'.
1502 -------------------------------------------------------------------------------
1503 --
1504 procedure chk_cost_cleared_payment
1505 (
1506   p_effective_date            in date
1507  ,p_cost_cleared_payment      in varchar2
1508  ,p_cost_payment              in varchar2
1509 ) is
1510 begin
1511   if(p_cost_cleared_payment is not null) then
1512   --
1513 	if hr_api.not_exists_in_hr_lookups
1514 	(p_effective_date
1515 	,'YES_NO'
1516 	,p_cost_cleared_payment) then
1517 	--
1518 		fnd_message.set_name('PAY','HR_52966_INVALID_LOOKUP');
1519 		fnd_message.set_token('COLUMN','COST_CLEARED_PAYMENT');
1520 		fnd_message.set_token('LOOKUP_TYPE','YES_NO');
1521 		fnd_message.raise_error;
1522 	--
1523         end If;
1524 	--
1525 	if (p_cost_cleared_payment = 'Y') and (p_cost_payment <> 'Y') then
1526 	--
1527 		fnd_message.set_name('PAY', 'PAY_33415_CST_CLRCST_SYNC');
1528 		fnd_message.set_token('PARAMETER1','COST_PAYMENT');
1529 		fnd_message.set_token('PARAMETER2','COST_CLEARED_PAYMENT');
1530 		fnd_message.raise_error;
1531 	--
1532 	end If;
1533    --
1534    end if;
1535 end chk_cost_cleared_payment;
1536 --
1537 --
1538 -- ----------------------------------------------------------------------------
1539 -- |------------------< chk_cost_cleared_void_payment >-----------------------|
1540 -- ----------------------------------------------------------------------------
1541 --
1542 -- Description
1543 --   cost_cleared_void_payment if specified must be either 'Y' or 'N'.
1544 --   It ensures that when cost_cleared_void_payment is 'Y' then
1545 --   cost_cleared_payment should set to 'Y'
1546 -------------------------------------------------------------------------------
1547 procedure chk_cost_cleared_void_payment
1548 (
1549   p_effective_date            in date
1550  ,p_cost_cleared_void_payment in varchar2
1551  ,p_cost_cleared_payment      in varchar2
1552 ) is
1553 begin
1554   if (p_cost_cleared_void_payment is not null) then
1555   --
1556 	if hr_api.not_exists_in_hr_lookups
1557 	(p_effective_date
1558 	,'YES_NO'
1559 	,p_cost_cleared_void_payment) then
1560 	--
1561 		fnd_message.set_name('PAY','HR_52966_INVALID_LOOKUP');
1562 		fnd_message.set_token('COLUMN','COST_CLEARED_VOID_PAYMENT');
1563 		fnd_message.set_token('LOOKUP_TYPE','YES_NO');
1564 		fnd_message.raise_error;
1565 	--
1566 	end If;
1567 	--
1568 	If ((p_cost_cleared_void_payment = 'Y') and (p_cost_cleared_payment <> 'Y')) then
1569 	--
1570 		fnd_message.set_name('PAY', 'PAY_33415_CST_CSTCLR_SYNC');
1571 		fnd_message.set_token('PARAMETER1','COST_CLEARED_PAYMENT');
1572 		fnd_message.set_token('PARAMETER2','COST_CLEARED_VOID_PAYMENT');
1573 		fnd_message.raise_error;
1574 	--
1575 	end If;
1576   --
1577   end if;
1578 end chk_cost_cleared_void_payment;
1579 --
1580 --
1581 -- ----------------------------------------------------------------------------
1582 -- |---------------------< chk_exclude_manual_payment >------------------------|
1583 -- ----------------------------------------------------------------------------
1584 --
1585 -- Description
1586 --   Exclude_manual_payment if specified must be either 'Y' or 'N'.
1587 --   It ensures that when exclude_manual_payment is 'Y' then
1588 --   cost_payment should set to 'Y'
1589 -------------------------------------------------------------------------------
1590 procedure chk_exclude_manual_payment
1591 (
1592   p_effective_date		in date
1593  ,p_exclude_manual_payment	in varchar2
1594  ,p_cost_payment		in varchar2
1595 ) is
1596 begin
1597   if (p_exclude_manual_payment  is not null) then
1598   --
1599 	if hr_api.not_exists_in_hr_lookups
1600 	(p_effective_date
1601 	,'YES_NO'
1602 	,p_exclude_manual_payment) then
1603 	--
1604 		fnd_message.set_name('PAY','HR_52966_INVALID_LOOKUP');
1605 		fnd_message.set_token('COLUMN','EXCLUDE_MANUAL_PAYMENT');
1606 		fnd_message.set_token('LOOKUP_TYPE','YES_NO');
1607 		fnd_message.raise_error;
1608 	--
1609         end if;
1610 	--
1611 	If ((p_exclude_manual_payment = 'Y') and (p_cost_payment <> 'Y')) then
1612 	--
1613 		fnd_message.set_name('PAY', 'PAY_33415_CST_CSTCLR_SYNC');
1614 		fnd_message.set_token('PARAMETER1','COST_PAYMENT');
1615 		fnd_message.set_token('PARAMETER2','EXCLUDE_MANUAL_PAYMENT');
1616 		fnd_message.raise_error;
1617 	--
1618 	end If;
1619   --
1620   end If;
1621 end chk_exclude_manual_payment;
1622 --
1623 --
1624 -- ----------------------------------------------------------------------------
1625 -- |-------------------< chk_transfer_to_gl_flag >----------------------------|
1626 -- ----------------------------------------------------------------------------
1627 --
1628 -- Description
1629 --   transfer_to_gl_flag if specified must be either 'Y' or 'N'.
1630 --   It ensures that when transfer_to_gl_flag is 'Y' then
1631 --   cost_payment should set to 'Y'.
1632 -------------------------------------------------------------------------------
1633 procedure chk_transfer_to_gl_flag
1634 (
1635   p_effective_date            in date
1636  ,p_transfer_to_gl_flag       in varchar2
1637  ,p_cost_payment	      in varchar2
1638 ) is
1639 begin
1640   if(p_transfer_to_gl_flag is not null) then
1641   --
1642 	if hr_api.not_exists_in_hr_lookups
1643 	(p_effective_date
1644 	,'YES_NO'
1645 	,p_transfer_to_gl_flag) then
1646 	--
1647 		fnd_message.set_name('PAY','HR_52966_INVALID_LOOKUP');
1648 		fnd_message.set_token('COLUMN','TRANSFER_TO_GL_FLAG');
1649 		fnd_message.set_token('LOOKUP_TYPE','YES_NO');
1650 		fnd_message.raise_error;
1651 	--
1652 	end If;
1653 	--
1654 	If ((p_transfer_to_gl_flag = 'Y') and (p_cost_payment <> 'Y')) then
1655 	--
1656 		fnd_message.set_name('PAY', 'PAY_33415_CST_CSTCLR_SYNC');
1657 		fnd_message.set_token('PARAMETER1','COST_PAYMENT');
1658 		fnd_message.set_token('PARAMETER2','TRANSFER_TO_GL_FLAG');
1659 		fnd_message.raise_error;
1660 	--
1661 	end If;
1662   --
1663   end if;
1664 --
1665 end chk_transfer_to_gl_flag;
1666 --
1667 --
1668 -- ---------------------------------------------------------------------------
1669 -- |-------------------------------< chk_delete >----------------------------|
1670 -- ---------------------------------------------------------------------------
1671 --
1672 --  Desciption :
1673 --
1674 --    Check if there is no child row exists in
1675 --    PAY_ORG_PAYMENT_METHODS_TL,
1676 --    PAY_ORG_METHOD_USAGES_F,
1677 --    PAY_PRE_PAYMENTS,
1678 --    PAY_RUN_TYPE_ORG_METHODS,
1679 --    PAY_PAYROLL_ACTIONS,
1680 --    PAY_ALL_PAYROLLS_F,
1681 --    and
1682 --    PAY_PERSONAL_PAYMENT_METHODS_F
1683 --
1684 --  Pre-conditions :
1685 --
1686 --
1687 --  In Arguments :
1688 --    p_org_payment_method_id
1689 --    p_effective_date
1690 --    p_business_group_id
1691 --    p_datetrack_mode
1692 --    p_validation_start_date
1693 --    p_validation_end_date
1694 --
1695 --  Post Success :
1696 --    Processing continues
1697 --
1698 --  Post Failure :
1699 --    An application error will be raised and processing is
1700 --    terminated
1701 --
1702 --  Access Status :
1703 --    Internal Table Handler Use only.
1704 --
1705 -- {End of Comments}
1706 --
1707 -- ---------------------------------------------------------------------------
1708 procedure chk_delete
1709   (p_org_payment_method_id     in pay_org_payment_methods_f.org_payment_method_id%TYPE
1710   ,p_business_group_id         in pay_org_payment_methods_f.business_group_id%TYPE
1711   ,p_datetrack_mode            in varchar2
1712   ,p_effective_date            in date
1713   ,p_validation_start_date     in date
1714   ,p_validation_end_date       in date
1715    ) is
1716 --
1717   l_proc  varchar2(72) := g_package||'chk_delete';
1718   l_exists   varchar2(1);
1719 --
1720   cursor csr_pre_payment_exists is
1721     select null
1722     from   pay_pre_payments ppt,
1723            pay_assignment_actions paa,
1724            pay_payroll_actions ppa
1725     where  ppt.org_payment_method_id = p_org_payment_method_id
1726     and    ppt.assignment_action_id = paa.assignment_action_id
1727     and    paa.payroll_action_id = ppa.payroll_action_id
1728     and    (p_datetrack_mode = hr_api.g_zap
1729            or (p_datetrack_mode = hr_api.g_delete
1730                and p_effective_date < ppa.effective_date));
1731 --
1732   cursor csr_org_pay_methods_tl_exists is
1733     select null
1734     from   pay_org_payment_methods_f_tl opt
1735     where  opt.org_payment_method_id = p_org_payment_method_id
1736     and    p_datetrack_mode = hr_api.g_zap;
1737 --
1738   cursor csr_payroll_actions_exists is
1739     select null
1740     from   pay_payroll_actions ppa
1741     where  ppa.org_payment_method_id = p_org_payment_method_id
1742     and    (p_datetrack_mode = hr_api.g_zap
1743            or (p_datetrack_mode = hr_api.g_delete
1744                and p_effective_date < ppa.effective_date));
1745 --
1746   cursor csr_payrolls_exists is
1747     select null
1748     from   pay_all_payrolls_f ppa
1749     where  ppa.default_payment_method_id = p_org_payment_method_id
1750     and    ppa.business_group_id = p_business_group_id;
1751 --
1752 begin
1753   hr_utility.set_location('Entering:'||l_proc, 1);
1754   --
1755   -- Ensure that the p_datetrack_mode argument is not null
1756   --
1757   hr_api.mandatory_arg_error
1758     (p_api_name       => l_proc
1759     ,p_argument       => 'datetrack_mode'
1760     ,p_argument_value => p_datetrack_mode
1761     );
1762   --
1763   -- Only perform the validation if the datetrack mode is either
1764   -- DELETE or ZAP
1765   --
1766   If (p_datetrack_mode = hr_api.g_delete or
1767       p_datetrack_mode = hr_api.g_zap) then
1768     --
1769     -- Ensure the arguments are not null
1770     --
1771     hr_api.mandatory_arg_error
1772       (p_api_name       => l_proc
1773       ,p_argument       => 'effective_date'
1774       ,p_argument_value => p_effective_date
1775       );
1776     --
1777     hr_api.mandatory_arg_error
1778       (p_api_name       => l_proc
1779       ,p_argument       => 'business_group_id'
1780       ,p_argument_value => p_business_group_id
1781       );
1782     --
1783     --
1784     open csr_pre_payment_exists;
1785     --
1786     fetch csr_pre_payment_exists into l_exists;
1787     --
1788     If csr_pre_payment_exists%found Then
1789       --
1790       close csr_pre_payment_exists;
1791       --
1792       fnd_message.set_name('PAY', 'HR_7215_DT_CHILD_EXISTS');
1793       fnd_message.set_token('TABLE_NAME', 'PAY_PRE_PAYMENTS');
1794       fnd_message.raise_error;
1795       --
1796     End If;
1797     --
1798     close csr_pre_payment_exists;
1799     --
1800     hr_utility.set_location(l_proc, 10);
1801     --
1802     --
1803     open csr_org_pay_methods_tl_exists;
1804     --
1805     fetch csr_org_pay_methods_tl_exists into l_exists;
1806     --
1807     If csr_org_pay_methods_tl_exists%found Then
1808       --
1809       close csr_org_pay_methods_tl_exists;
1810       --
1811       fnd_message.set_name('PAY', 'HR_7215_DT_CHILD_EXISTS');
1812       fnd_message.set_token('TABLE_NAME', 'PAY_ORG_PAYMENT_METHODS_F_TL');
1813       fnd_message.raise_error;
1814       --
1815     End If;
1816     --
1817     close csr_org_pay_methods_tl_exists;
1818     --
1819     hr_utility.set_location(l_proc, 20);
1820     --
1821     --
1822     open csr_payroll_actions_exists;
1823     --
1824     fetch csr_payroll_actions_exists into l_exists;
1825     --
1826     If csr_payroll_actions_exists%found Then
1827       --
1828       close csr_payroll_actions_exists;
1829       --
1830       fnd_message.set_name('PAY', 'HR_7215_DT_CHILD_EXISTS');
1831       fnd_message.set_token('TABLE_NAME', 'PAY_PAYROLL_ACTIONS');
1832       fnd_message.raise_error;
1833       --
1834     End If;
1835     --
1836     close csr_payroll_actions_exists;
1837     --
1838     hr_utility.set_location(l_proc, 30);
1839     --
1840     --
1841   End If;
1842   --
1843   open csr_payrolls_exists;
1844   --
1845   fetch csr_payrolls_exists into l_exists;
1846   --
1847   If csr_payrolls_exists%found Then
1848     --
1849     close csr_payrolls_exists;
1850     --
1851     if (p_datetrack_mode = hr_api.g_zap) then
1852        fnd_message.set_name('PAY', 'HR_7215_DT_CHILD_EXISTS');
1853        fnd_message.set_token('TABLE_NAME', 'PAY_ALL_PAYROLLS_F');
1854        fnd_message.raise_error;
1855     else
1856        fnd_message.set_name('PAY','HR_6739_PAYM_NO_METH');
1857        fnd_message.raise_error;
1858     end if;
1859     --
1860   End If;
1861   --
1862   close csr_payrolls_exists;
1863   --
1864   hr_utility.set_location(l_proc, 35);
1865   --
1866   --Bug No. 4644827
1867   If ( pay_maintain_bank_acct.chk_account_exists(
1868             p_org_payment_method_id    =>p_org_payment_method_id,
1869             p_validation_start_date    =>p_validation_start_date,
1870             p_validation_end_date      =>p_validation_end_date
1871            ))Then
1872     --
1873     fnd_message.set_name('PAY', 'PAY_52999_METHOD_USED_FOR_CE');
1874     fnd_message.raise_error;
1875     --
1876   End If;
1877   --
1878   hr_utility.set_location(' Leaving:'||l_proc, 40);
1879   --
1880 end chk_delete;
1881 --
1882 -- ----------------------------------------------------------------------------
1883 -- |---------------------------< insert_validate >----------------------------|
1884 -- ----------------------------------------------------------------------------
1885 Procedure insert_validate
1886   (p_rec                   in pay_opm_shd.g_rec_type
1887   ,p_effective_date        in date
1888   ,p_datetrack_mode        in varchar2
1889   ,p_validation_start_date in date
1890   ,p_validation_end_date   in date
1891   ) is
1892 --
1893   l_proc	varchar2(72) := g_package||'insert_validate';
1894 --
1895 Begin
1896   hr_utility.set_location('Entering:'||l_proc, 5);
1897   --
1898   -- Call all supporting business operations
1899   --
1900   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
1901   --
1902   hr_utility.set_location(l_proc,10);
1903   --
1904   pay_opm_bus.chk_external_account_id(p_external_account_id => p_rec.external_account_id
1905                                      ,p_payment_type_id => p_rec.payment_type_id
1906                                      ,p_business_group_id => p_rec.business_group_id
1907                                      ,p_effective_date => p_effective_date
1908                                      ,p_org_payment_method_id => p_rec.org_payment_method_id
1909                                      ,p_object_version_number => p_rec.object_version_number);
1910   --
1911   hr_utility.set_location(l_proc,15);
1912   --
1913   pay_opm_bus.chk_currency_code(p_currency_code => p_rec.currency_code
1914                                ,p_payment_type_id => p_rec.payment_type_id
1915                                ,p_effective_date => p_effective_date
1916                                ,p_org_payment_method_id => p_rec.org_payment_method_id
1917                                ,p_object_version_number => p_rec.object_version_number);
1918   --
1919   hr_utility.set_location(l_proc,20);
1920   --
1921   pay_opm_bus.chk_payment_type_id(p_payment_type_id => p_rec.payment_type_id
1922                                  ,p_business_group_id => p_rec.business_group_id
1923                                  ,p_org_payment_method_id => p_rec.org_payment_method_id);
1924   --
1925   hr_utility.set_location(l_proc,25);
1926   --
1927   pay_opm_bus.chk_defined_balance_id(p_defined_balance_id => p_rec.defined_balance_id
1928                                     ,p_business_group_id => p_rec.business_group_id
1929                                     ,p_org_payment_method_id => p_rec.org_payment_method_id);
1930   --
1931   hr_utility.set_location(l_proc,30);
1932   --
1933   pay_opm_bus.chk_org_payment_method_name(p_org_payment_method_name => p_rec.org_payment_method_name
1934                                           ,p_business_group_id => p_rec.business_group_id
1935                                           ,p_org_payment_method_id => p_rec.org_payment_method_id);
1936   --
1937   hr_utility.set_location(l_proc,35);
1938   --
1939   pay_opm_bus.chk_costing_enabled(p_business_group_id		=> p_rec.business_group_id
1940 				 ,p_transfer_to_gl_flag		=> p_rec.transfer_to_gl_flag
1941 				 ,p_cost_payment		=> p_rec.cost_payment
1942 				 ,p_cost_cleared_payment        => p_rec.cost_cleared_payment
1943 				 ,p_cost_cleared_void_payment   => p_rec.cost_cleared_void_payment
1944 				 ,p_exclude_manual_payment      => p_rec.exclude_manual_payment);
1945   --
1946   hr_utility.set_location(l_proc,40);
1947   --
1948   pay_opm_bus.chk_cost_payment(p_effective_date => p_effective_date
1949 			      ,p_cost_payment => NVL(p_rec.cost_payment, 'N'));
1950   --
1951   hr_utility.set_location(l_proc,45);
1952   --
1953   pay_opm_bus.chk_cost_cleared_payment(p_effective_date => p_effective_date
1954 				      ,p_cost_cleared_payment => NVL(p_rec.cost_cleared_payment, 'N')
1955 				      ,p_cost_payment => NVL(p_rec.cost_payment,'N'));
1956   --
1957   hr_utility.set_location(l_proc,50);
1958   --
1959   pay_opm_bus.chk_cost_cleared_void_payment(p_effective_date => p_effective_date
1960 			      ,p_cost_cleared_void_payment => NVL(p_rec.cost_cleared_void_payment, 'N')
1961 			      ,p_cost_cleared_payment      => NVL(p_rec.cost_cleared_payment,'N'));
1962   --
1963   hr_utility.set_location(l_proc,55);
1964   --
1965   pay_opm_bus.chk_exclude_manual_payment(p_effective_date => p_effective_date
1966 			      ,p_exclude_manual_payment => NVL(p_rec.exclude_manual_payment, 'N')
1967 			      ,p_cost_payment => NVL(p_rec.cost_payment, 'N'));
1968   --
1969   hr_utility.set_location(l_proc,60);
1970   --
1971   pay_opm_bus.chk_transfer_to_gl_flag(p_effective_date => p_effective_date
1972 				,p_transfer_to_gl_flag => NVL(p_rec.transfer_to_gl_flag,'N')
1973 				,p_cost_payment => NVL(p_rec.cost_payment, 'N'));
1974   --
1975   pay_opm_bus.chk_ddf(p_rec);
1976   --
1977   hr_utility.set_location(l_proc,70);
1978   --
1979   pay_opm_bus.chk_df(p_rec);
1980   --
1981   hr_utility.set_location(l_proc,75);
1982   --
1983   hr_utility.set_location(' Leaving:'||l_proc, 100);
1984 End insert_validate;
1985 --
1986 -- ----------------------------------------------------------------------------
1987 -- |---------------------------< update_validate >----------------------------|
1988 -- ----------------------------------------------------------------------------
1989 Procedure update_validate
1990   (p_rec                     in pay_opm_shd.g_rec_type
1991   ,p_effective_date          in date
1992   ,p_datetrack_mode          in varchar2
1993   ,p_validation_start_date   in date
1994   ,p_validation_end_date     in date
1995   ) is
1996 --
1997   l_proc	varchar2(72) := g_package||'update_validate';
1998 --
1999 Begin
2000   hr_utility.set_location('Entering:'||l_proc, 5);
2001   --
2002   -- Call all supporting business operations
2003   --
2004   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
2005   --
2006   -- Call the datetrack update integrity operation
2007   --
2008   dt_update_validate
2009     (p_datetrack_mode                 => p_datetrack_mode
2010     ,p_validation_start_date          => p_validation_start_date
2011     ,p_validation_end_date            => p_validation_end_date
2012     );
2013   --
2014   chk_non_updateable_args
2015     (p_effective_date  => p_effective_date
2016     ,p_rec             => p_rec
2017     );
2018   --
2019   --
2020   hr_utility.set_location(l_proc,10);
2021   --
2022   pay_opm_bus.chk_external_account_id(p_external_account_id => p_rec.external_account_id
2023                                      ,p_payment_type_id => p_rec.payment_type_id
2024                                      ,p_business_group_id => p_rec.business_group_id
2025                                      ,p_effective_date => p_effective_date
2026                                      ,p_org_payment_method_id => p_rec.org_payment_method_id
2027                                      ,p_object_version_number => p_rec.object_version_number);
2028   --
2029   hr_utility.set_location(l_proc,15);
2030   --
2031   pay_opm_bus.chk_currency_code(p_currency_code => p_rec.currency_code
2032                                ,p_payment_type_id => p_rec.payment_type_id
2033                                ,p_effective_date => p_effective_date
2034                                ,p_org_payment_method_id => p_rec.org_payment_method_id
2035                                ,p_object_version_number => p_rec.object_version_number);
2036   --
2037   hr_utility.set_location(l_proc,20);
2038   --
2039   pay_opm_bus.chk_pre_payment(p_validation_start_date => p_validation_start_date
2040                              ,p_org_payment_method_id => p_rec.org_payment_method_id);
2041   --
2042   --
2043   hr_utility.set_location(l_proc,25);
2044   --
2045   pay_opm_bus.chk_costing_enabled(p_business_group_id		=> p_rec.business_group_id
2046 				 ,p_transfer_to_gl_flag		=> p_rec.transfer_to_gl_flag
2047 				 ,p_cost_payment		=> p_rec.cost_payment
2048 				 ,p_cost_cleared_payment        => p_rec.cost_cleared_payment
2049 				 ,p_cost_cleared_void_payment   => p_rec.cost_cleared_void_payment
2050 				 ,p_exclude_manual_payment      => p_rec.exclude_manual_payment);
2051   --
2052   hr_utility.set_location(l_proc,30);
2053   --
2054   pay_opm_bus.chk_cost_payment(p_effective_date => p_effective_date
2055 			      ,p_cost_payment => NVL(p_rec.cost_payment, 'N'));
2056   --
2057   hr_utility.set_location(l_proc,45);
2058   --
2059   pay_opm_bus.chk_cost_cleared_payment(p_effective_date => p_effective_date
2060 				      ,p_cost_cleared_payment => NVL(p_rec.cost_cleared_payment, 'N')
2061 				      ,p_cost_payment => NVL(p_rec.cost_payment, 'N'));
2062   --
2063   hr_utility.set_location(l_proc,50);
2064   --
2065   pay_opm_bus.chk_cost_cleared_void_payment(p_effective_date => p_effective_date
2066 			      ,p_cost_cleared_void_payment => NVL(p_rec.cost_cleared_void_payment, 'N')
2067 			      ,p_cost_cleared_payment      => NVL(p_rec.cost_cleared_payment, 'N'));
2068   --
2069   hr_utility.set_location(l_proc,55);
2070   --
2071   pay_opm_bus.chk_exclude_manual_payment(p_effective_date => p_effective_date
2072 			      ,p_exclude_manual_payment => NVL(p_rec.exclude_manual_payment, 'N')
2073 			      ,p_cost_payment => NVL(p_rec.cost_payment, 'N'));
2074   --
2075   hr_utility.set_location(l_proc,60);
2076   --
2077   pay_opm_bus.chk_transfer_to_gl_flag(p_effective_date => p_effective_date
2078 				,p_transfer_to_gl_flag => NVL(p_rec.transfer_to_gl_flag, 'N')
2079 				,p_cost_payment => NVL(p_rec.cost_payment,'N'));
2080   --
2081   hr_utility.set_location(l_proc,65);
2082   --
2083   pay_opm_bus.chk_ddf(p_rec);
2084   --
2085   hr_utility.set_location(l_proc,70);
2086   --
2087   pay_opm_bus.chk_df(p_rec);
2088   --
2089   hr_utility.set_location(' Leaving:'||l_proc, 100);
2090 End update_validate;
2091 --
2092 -- ----------------------------------------------------------------------------
2093 -- |---------------------------< delete_validate >----------------------------|
2094 -- ----------------------------------------------------------------------------
2095 Procedure delete_validate
2096   (p_rec                    in pay_opm_shd.g_rec_type
2097   ,p_effective_date         in date
2098   ,p_datetrack_mode         in varchar2
2099   ,p_validation_start_date  in date
2100   ,p_validation_end_date    in date
2101   ) is
2102 --
2103   l_proc	varchar2(72) := g_package||'delete_validate';
2104 --
2105 Begin
2106   hr_utility.set_location('Entering:'||l_proc, 5);
2107   --
2108   -- Call all supporting business operations
2109   --
2110   dt_delete_validate
2111     (p_datetrack_mode                   => p_datetrack_mode
2112     ,p_validation_start_date            => p_validation_start_date
2113     ,p_validation_end_date              => p_validation_end_date
2114     ,p_org_payment_method_id            => p_rec.org_payment_method_id
2115     );
2116   --
2117   pay_opm_bus.chk_delete(p_datetrack_mode => p_datetrack_mode
2118                         ,p_effective_date => p_effective_date
2119                         ,p_org_payment_method_id => p_rec.org_payment_method_id
2120                         ,p_business_group_id => p_rec.business_group_id
2121                         ,p_validation_start_date => p_validation_start_date
2122                         ,p_validation_end_date => p_validation_end_date);
2123   --
2124   pay_opm_bus.chk_pre_payment(p_validation_start_date => p_validation_start_date
2125                              ,p_org_payment_method_id => p_rec.org_payment_method_id);
2126   --
2127   hr_utility.set_location(l_proc,30);
2128   --
2129   hr_utility.set_location(' Leaving:'||l_proc, 10);
2130 End delete_validate;
2131 --
2132 end pay_opm_bus;