DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PEM_BUS

Source


4 -- ----------------------------------------------------------------------------
1 Package Body per_pem_bus as
2 /* $Header: pepemrhi.pkb 120.3.12020000.2 2012/09/07 10:43:01 srannama ship $ */
3 --
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_pem_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_previous_employer_id        number         default null;
15 --
16 -- -----------------------------------------------------------------------
17 -- |---------------------------< get_period_values >---------------------|
18 -- -----------------------------------------------------------------------
19 procedure get_period_values
20           (p_start_date     in  per_previous_employers.start_date%type
21           ,p_end_date       in  per_previous_employers.end_date%type
22           ,p_period_years   out nocopy per_previous_employers.period_years%type
23           ,p_period_months  out nocopy per_previous_employers.period_months%type
24           ,p_period_days    out nocopy per_previous_employers.period_days%type
25           ) is
26   l_proc            varchar2(72) := g_package||'get_period_values';
27   l_period_years    number; -- Don't change the datatype
28   l_start_date      per_previous_employers.start_date%type;
29   l_end_date        per_previous_employers.end_date%type;
30 begin
31   hr_utility.set_location('Entering:'||l_proc, 5);
32   --
33   -- Truncate all date datatypes
34   l_start_date  := trunc(p_start_date);
35   l_end_date    := trunc(p_end_date+1);
36   --
37   if l_start_date is not null and l_end_date is not null then
38     hr_utility.set_location(l_proc, 10);
39     l_period_years   := trunc(trunc(months_between(l_end_date,l_start_date))/12);
40     if l_period_years between 0 and 99 then
41       hr_utility.set_location(l_proc, 15);
42       p_period_years := trunc(trunc(months_between(l_end_date
43                                                   ,l_start_date))/12);
44       hr_utility.set_location(l_proc, 20);
45       p_period_months:= mod(trunc(months_between(l_end_date
46                                                 ,l_start_date)),12);
47       hr_utility.set_location(l_proc, 25);
48       --
49       -- 3635308: Added the if - else condition.
50       --
51       -- 3635308 start here
52       if (add_months(l_start_date,trunc(months_between(l_end_date,l_start_date)))
53          <= l_end_date) then
54          p_period_days  := trunc(l_end_date
55                                  - add_months(l_start_date
56                                               ,trunc(months_between(l_end_date
57                                                                    ,l_start_date))));
58        hr_utility.set_location(l_proc, 26);
59       else
60        p_period_days  := trunc(l_end_date
61                                 - add_months(l_start_date
62                                              ,trunc(months_between(l_end_date
63                                                                   ,l_start_date)-1)));
64        p_period_months := p_period_months - 1;
65         if p_period_months < 0 and p_period_years > 0 then
66             p_period_months:=11;
67             p_period_years:=p_period_years - 1;
68         end if;
69 
70        hr_utility.set_location(l_proc, 28);
71       end if;
72       --
73       -- 3635308  end here
74       --
78        hr_utility.set_location(l_proc, 35);
75       hr_utility.set_location(l_proc, 30);
76     else
77         /*Error message changed for the bug 5686794*/
79        fnd_message.set_name('PER','HR_289530_PEM_STRT_END_DATES');
80        fnd_message.set_token('START_DATE',TO_CHAR(p_start_date,'DD-MON-YYYY'),true);
81        fnd_message.set_token('END_DATE',TO_CHAR(p_end_date,'DD-MON-YYYY'),true);
82        fnd_message.raise_error;
83 
84       /*hr_utility.set_location(l_proc, 35);
85       fnd_message.set_name('PER','HR_289552_NOVALD_DATES_DIFF');
86       fnd_message.raise_error;*/-- Error msg changed Commented for bug 5686794
87 
88     end if;
89   end if;
90   --
91   hr_utility.set_location('Leaving:'||l_proc, 40);
92 end get_period_values;
93 --
94 --  ---------------------------------------------------------------------------
95 --  |----------------------< set_security_group_id >--------------------------|
96 --  ---------------------------------------------------------------------------
97 --
98 Procedure set_security_group_id
99   (p_previous_employer_id                 in number
100   ,p_associated_column1                   in varchar2 default null
101   ) is
102   --
103   -- Declare cursor
104   --
105   cursor csr_sec_grp is
106     select pbg.security_group_id
107       from per_business_groups pbg
108          , per_previous_employers pem
109      where pem.previous_employer_id = p_previous_employer_id
110        and pbg.business_group_id = pem.business_group_id;
111   --
112   -- Declare local variables
113   --
114   l_security_group_id number;
115   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
116   --
117 begin
118   --
119   hr_utility.set_location('Entering:'|| l_proc, 10);
120   --
121   -- Ensure that all the mandatory parameter are not null
122   --
123   hr_api.mandatory_arg_error
124     (p_api_name           => l_proc
125     ,p_argument           => 'previous_employer_id'
126     ,p_argument_value     => p_previous_employer_id
127     );
128   --
129   open csr_sec_grp;
130   fetch csr_sec_grp into l_security_group_id;
131   --
132   if csr_sec_grp%notfound then
133      --
134      close csr_sec_grp;
135      --
136      -- The primary key is invalid therefore we must error
137      --
138      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
139      hr_multi_message.add
140        (p_associated_column1 => nvl(p_associated_column1,'PREVIOUS_EMPLOYER_ID')
141        );
142   else
143     close csr_sec_grp;
144   --
145   -- Set the security_group_id in CLIENT_INFO
146   --
147   hr_api.set_security_group_id
148     (p_security_group_id => l_security_group_id
149     );
150   end if;
151   --
152   hr_utility.set_location(' Leaving:'|| l_proc, 20);
153   --
154 end set_security_group_id;
155 --
156 --  ---------------------------------------------------------------------------
157 --  |---------------------< return_legislation_code >-------------------------|
158 --  ---------------------------------------------------------------------------
159 --
160 Function return_legislation_code
161   (p_previous_employer_id                 in     number
162   )
163   Return Varchar2 Is
164   --
165   -- Declare cursor
166   --
167   cursor csr_leg_code is
168     select pbg.legislation_code
169       from per_business_groups pbg
170          , per_previous_employers pem
171      where pem.previous_employer_id = p_previous_employer_id
172        and pbg.business_group_id (+) = pem.business_group_id;
173   --
174   -- Declare local variables
175   --
176   l_legislation_code  varchar2(150);
177   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
178   --
179 Begin
180   --
181   hr_utility.set_location('Entering:'|| l_proc, 10);
182   --
183   -- Ensure that all the mandatory parameter are not null
184   --
185   hr_api.mandatory_arg_error
186     (p_api_name           => l_proc
187     ,p_argument           => 'previous_employer_id'
188     ,p_argument_value     => p_previous_employer_id
189     );
190   --
191   if ( nvl(per_pem_bus.g_previous_employer_id, hr_api.g_number)
192        = p_previous_employer_id) then
193     --
194     -- The legislation code has already been found with a previous
195     -- call to this function. Just return the value in the global
196     -- variable.
197     --
198     l_legislation_code := per_pem_bus.g_legislation_code;
199     hr_utility.set_location(l_proc, 20);
200   else
201     --
202     -- The ID is different to the last call to this function
203     -- or this is the first call to this function.
204     --
205     open csr_leg_code;
206     fetch csr_leg_code into l_legislation_code;
207     --
208     if csr_leg_code%notfound then
209       --
210       -- The primary key is invalid therefore we must error
211       --
212       close csr_leg_code;
213       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
214       fnd_message.raise_error;
215     end if;
216     hr_utility.set_location(l_proc,30);
217     --
218     -- Set the global variables so the values are
219     -- available for the next call to this function.
220     --
221     close csr_leg_code;
222     per_pem_bus.g_previous_employer_id        := p_previous_employer_id;
223     per_pem_bus.g_legislation_code  := l_legislation_code;
224   end if;
225   hr_utility.set_location(' Leaving:'|| l_proc, 40);
226   return l_legislation_code;
230 -- |-----------------------------< chk_ddf >----------------------------------|
227 end return_legislation_code;
228 --
229 -- ----------------------------------------------------------------------------
231 -- ----------------------------------------------------------------------------
232 --
233 -- Description:
234 --   Validates all the Developer Descriptive Flexfield values.
235 --
236 -- Prerequisites:
237 --   All other columns have been validated.  Must be called as the
238 --   last step from insert_validate and update_validate.
239 --
240 -- In Arguments:
241 --   p_rec
242 --
243 -- Post Success:
244 --   If the Developer Descriptive Flexfield structure column and data values
245 --   are all valid this procedure will end normally and processing will
246 --   continue.
247 --
248 -- Post Failure:
249 --   If the Developer Descriptive Flexfield structure column value or any of
250 --   the data values are invalid then an application error is raised as
251 --   a PL/SQL exception.
252 --
253 -- Access Status:
254 --   Internal Row Handler Use Only.
255 --
256 -- ----------------------------------------------------------------------------
257 procedure chk_ddf
258   (p_rec in per_pem_shd.g_rec_type
259   ) is
260 --
261   l_proc   varchar2(72) := g_package || 'chk_ddf';
262 --
263 begin
264   hr_utility.set_location('Entering:'||l_proc,10);
265   --
266   if ((p_rec.previous_employer_id is not null)  and (
267     nvl(per_pem_shd.g_old_rec.pem_information_category, hr_api.g_varchar2) <>
268     nvl(p_rec.pem_information_category, hr_api.g_varchar2)  or
269     nvl(per_pem_shd.g_old_rec.pem_information1, hr_api.g_varchar2) <>
270     nvl(p_rec.pem_information1, hr_api.g_varchar2)  or
271     nvl(per_pem_shd.g_old_rec.pem_information2, hr_api.g_varchar2) <>
272     nvl(p_rec.pem_information2, hr_api.g_varchar2)  or
273     nvl(per_pem_shd.g_old_rec.pem_information3, hr_api.g_varchar2) <>
274     nvl(p_rec.pem_information3, hr_api.g_varchar2)  or
275     nvl(per_pem_shd.g_old_rec.pem_information4, hr_api.g_varchar2) <>
276     nvl(p_rec.pem_information4, hr_api.g_varchar2)  or
277     nvl(per_pem_shd.g_old_rec.pem_information5, hr_api.g_varchar2) <>
278     nvl(p_rec.pem_information5, hr_api.g_varchar2)  or
279     nvl(per_pem_shd.g_old_rec.pem_information6, hr_api.g_varchar2) <>
280     nvl(p_rec.pem_information6, hr_api.g_varchar2)  or
281     nvl(per_pem_shd.g_old_rec.pem_information7, hr_api.g_varchar2) <>
282     nvl(p_rec.pem_information7, hr_api.g_varchar2)  or
283     nvl(per_pem_shd.g_old_rec.pem_information8, hr_api.g_varchar2) <>
284     nvl(p_rec.pem_information8, hr_api.g_varchar2)  or
285     nvl(per_pem_shd.g_old_rec.pem_information9, hr_api.g_varchar2) <>
286     nvl(p_rec.pem_information9, hr_api.g_varchar2)  or
287     nvl(per_pem_shd.g_old_rec.pem_information10, hr_api.g_varchar2) <>
288     nvl(p_rec.pem_information10, hr_api.g_varchar2)  or
289     nvl(per_pem_shd.g_old_rec.pem_information11, hr_api.g_varchar2) <>
290     nvl(p_rec.pem_information11, hr_api.g_varchar2)  or
291     nvl(per_pem_shd.g_old_rec.pem_information12, hr_api.g_varchar2) <>
292     nvl(p_rec.pem_information12, hr_api.g_varchar2)  or
293     nvl(per_pem_shd.g_old_rec.pem_information13, hr_api.g_varchar2) <>
294     nvl(p_rec.pem_information13, hr_api.g_varchar2)  or
295     nvl(per_pem_shd.g_old_rec.pem_information14, hr_api.g_varchar2) <>
296     nvl(p_rec.pem_information14, hr_api.g_varchar2)  or
297     nvl(per_pem_shd.g_old_rec.pem_information15, hr_api.g_varchar2) <>
298     nvl(p_rec.pem_information15, hr_api.g_varchar2)  or
299     nvl(per_pem_shd.g_old_rec.pem_information16, hr_api.g_varchar2) <>
300     nvl(p_rec.pem_information16, hr_api.g_varchar2)  or
301     nvl(per_pem_shd.g_old_rec.pem_information17, hr_api.g_varchar2) <>
302     nvl(p_rec.pem_information17, hr_api.g_varchar2)  or
303     nvl(per_pem_shd.g_old_rec.pem_information18, hr_api.g_varchar2) <>
304     nvl(p_rec.pem_information18, hr_api.g_varchar2)  or
305     nvl(per_pem_shd.g_old_rec.pem_information19, hr_api.g_varchar2) <>
306     nvl(p_rec.pem_information19, hr_api.g_varchar2)  or
307     nvl(per_pem_shd.g_old_rec.pem_information20, hr_api.g_varchar2) <>
308     nvl(p_rec.pem_information20, hr_api.g_varchar2)  or
309     nvl(per_pem_shd.g_old_rec.pem_information21, hr_api.g_varchar2) <>
310     nvl(p_rec.pem_information21, hr_api.g_varchar2)  or
311     nvl(per_pem_shd.g_old_rec.pem_information22, hr_api.g_varchar2) <>
312     nvl(p_rec.pem_information22, hr_api.g_varchar2)  or
313     nvl(per_pem_shd.g_old_rec.pem_information23, hr_api.g_varchar2) <>
314     nvl(p_rec.pem_information23, hr_api.g_varchar2)  or
315     nvl(per_pem_shd.g_old_rec.pem_information24, hr_api.g_varchar2) <>
316     nvl(p_rec.pem_information24, hr_api.g_varchar2)  or
317     nvl(per_pem_shd.g_old_rec.pem_information25, hr_api.g_varchar2) <>
318     nvl(p_rec.pem_information25, hr_api.g_varchar2)  or
319     nvl(per_pem_shd.g_old_rec.pem_information26, hr_api.g_varchar2) <>
320     nvl(p_rec.pem_information26, hr_api.g_varchar2)  or
321     nvl(per_pem_shd.g_old_rec.pem_information27, hr_api.g_varchar2) <>
322     nvl(p_rec.pem_information27, hr_api.g_varchar2)  or
323     nvl(per_pem_shd.g_old_rec.pem_information28, hr_api.g_varchar2) <>
324     nvl(p_rec.pem_information28, hr_api.g_varchar2)  or
325     nvl(per_pem_shd.g_old_rec.pem_information29, hr_api.g_varchar2) <>
326     nvl(p_rec.pem_information29, hr_api.g_varchar2)  or
327     nvl(per_pem_shd.g_old_rec.pem_information30, hr_api.g_varchar2) <>
328     nvl(p_rec.pem_information30, hr_api.g_varchar2) ))
329     or (p_rec.previous_employer_id is null)  then
330     --
331     -- Only execute the validation if absolutely necessary:
332     -- a) During update, the structure column value or any
333     --    of the attribute values have actually changed.
334     -- b) During insert.
335     --
336     hr_dflex_utility.ins_or_upd_descflex_attribs
337       (p_appl_short_name                 => 'PER'
338       ,p_descflex_name                   => 'Previous Employer Developer DF'
339       ,p_attribute_category              => p_rec.pem_information_category
340       ,p_attribute1_name                 => 'PEM_INFORMATION1'
341       ,p_attribute1_value                => p_rec.pem_information1
342       ,p_attribute2_name                 => 'PEM_INFORMATION2'
343       ,p_attribute2_value                => p_rec.pem_information2
344       ,p_attribute3_name                 => 'PEM_INFORMATION3'
345       ,p_attribute3_value                => p_rec.pem_information3
346       ,p_attribute4_name                 => 'PEM_INFORMATION4'
347       ,p_attribute4_value                => p_rec.pem_information4
348       ,p_attribute5_name                 => 'PEM_INFORMATION5'
349       ,p_attribute5_value                => p_rec.pem_information5
350       ,p_attribute6_name                 => 'PEM_INFORMATION6'
351       ,p_attribute6_value                => p_rec.pem_information6
352       ,p_attribute7_name                 => 'PEM_INFORMATION7'
353       ,p_attribute7_value                => p_rec.pem_information7
354       ,p_attribute8_name                 => 'PEM_INFORMATION8'
355       ,p_attribute8_value                => p_rec.pem_information8
356       ,p_attribute9_name                 => 'PEM_INFORMATION9'
357       ,p_attribute9_value                => p_rec.pem_information9
358       ,p_attribute10_name                => 'PEM_INFORMATION10'
359       ,p_attribute10_value               => p_rec.pem_information10
360       ,p_attribute11_name                => 'PEM_INFORMATION11'
361       ,p_attribute11_value               => p_rec.pem_information11
362       ,p_attribute12_name                => 'PEM_INFORMATION12'
363       ,p_attribute12_value               => p_rec.pem_information12
364       ,p_attribute13_name                => 'PEM_INFORMATION13'
365       ,p_attribute13_value               => p_rec.pem_information13
366       ,p_attribute14_name                => 'PEM_INFORMATION14'
367       ,p_attribute14_value               => p_rec.pem_information14
368       ,p_attribute15_name                => 'PEM_INFORMATION15'
369       ,p_attribute15_value               => p_rec.pem_information15
370       ,p_attribute16_name                => 'PEM_INFORMATION16'
371       ,p_attribute16_value               => p_rec.pem_information16
372       ,p_attribute17_name                => 'PEM_INFORMATION17'
373       ,p_attribute17_value               => p_rec.pem_information17
374       ,p_attribute18_name                => 'PEM_INFORMATION18'
375       ,p_attribute18_value               => p_rec.pem_information18
376       ,p_attribute19_name                => 'PEM_INFORMATION19'
377       ,p_attribute19_value               => p_rec.pem_information19
378       ,p_attribute20_name                => 'PEM_INFORMATION20'
379       ,p_attribute20_value               => p_rec.pem_information20
380       ,p_attribute21_name                => 'PEM_INFORMATION21'
381       ,p_attribute21_value               => p_rec.pem_information21
382       ,p_attribute22_name                => 'PEM_INFORMATION22'
383       ,p_attribute22_value               => p_rec.pem_information22
384       ,p_attribute23_name                => 'PEM_INFORMATION23'
385       ,p_attribute23_value               => p_rec.pem_information23
386       ,p_attribute24_name                => 'PEM_INFORMATION24'
387       ,p_attribute24_value               => p_rec.pem_information24
388       ,p_attribute25_name                => 'PEM_INFORMATION25'
389       ,p_attribute25_value               => p_rec.pem_information25
390       ,p_attribute26_name                => 'PEM_INFORMATION26'
391       ,p_attribute26_value               => p_rec.pem_information26
392       ,p_attribute27_name                => 'PEM_INFORMATION27'
393       ,p_attribute27_value               => p_rec.pem_information27
394       ,p_attribute28_name                => 'PEM_INFORMATION28'
395       ,p_attribute28_value               => p_rec.pem_information28
396       ,p_attribute29_name                => 'PEM_INFORMATION29'
397       ,p_attribute29_value               => p_rec.pem_information29
398       ,p_attribute30_name                => 'PEM_INFORMATION30'
399       ,p_attribute30_value               => p_rec.pem_information30
400       );
401   end if;
402   --
403   hr_utility.set_location(' Leaving:'||l_proc,20);
404 end chk_ddf;
405 --
406 -- ----------------------------------------------------------------------------
407 -- |------------------------------< chk_df >----------------------------------|
408 -- ----------------------------------------------------------------------------
409 --
410 -- Description:
411 --   Validates all the Descriptive Flexfield values.
412 --
413 -- Prerequisites:
414 --   All other columns have been validated.  Must be called as the
415 --   last step from insert_validate and update_validate.
416 --
417 -- In Arguments:
418 --   p_rec
419 --
420 -- Post Success:
421 --   If the Descriptive Flexfield structure column and data values are
422 --   all valid this procedure will end normally and processing will
423 --   continue.
424 --
425 -- Post Failure:
426 --   If the Descriptive Flexfield structure column value or any of
427 --   the data values are invalid then an application error is raised as
428 --   a PL/SQL exception.
429 --
430 -- Access Status:
431 --   Internal Row Handler Use Only.
432 --
433 -- ----------------------------------------------------------------------------
434 procedure chk_df
435   (p_rec in per_pem_shd.g_rec_type
436   ) is
437 --
438   l_proc   varchar2(72) := g_package || 'chk_df';
439 --
440 begin
441   hr_utility.set_location('Entering:'||l_proc,10);
442   --
443   if ((p_rec.previous_employer_id is not null)  and (
444     nvl(per_pem_shd.g_old_rec.pem_attribute_category, hr_api.g_varchar2) <>
445     nvl(p_rec.pem_attribute_category, hr_api.g_varchar2)  or
446     nvl(per_pem_shd.g_old_rec.pem_attribute1, hr_api.g_varchar2) <>
447     nvl(p_rec.pem_attribute1, hr_api.g_varchar2)  or
448     nvl(per_pem_shd.g_old_rec.pem_attribute2, hr_api.g_varchar2) <>
449     nvl(p_rec.pem_attribute2, hr_api.g_varchar2)  or
450     nvl(per_pem_shd.g_old_rec.pem_attribute3, hr_api.g_varchar2) <>
451     nvl(p_rec.pem_attribute3, hr_api.g_varchar2)  or
452     nvl(per_pem_shd.g_old_rec.pem_attribute4, hr_api.g_varchar2) <>
453     nvl(p_rec.pem_attribute4, hr_api.g_varchar2)  or
454     nvl(per_pem_shd.g_old_rec.pem_attribute5, hr_api.g_varchar2) <>
455     nvl(p_rec.pem_attribute5, hr_api.g_varchar2)  or
456     nvl(per_pem_shd.g_old_rec.pem_attribute6, hr_api.g_varchar2) <>
457     nvl(p_rec.pem_attribute6, hr_api.g_varchar2)  or
458     nvl(per_pem_shd.g_old_rec.pem_attribute7, hr_api.g_varchar2) <>
459     nvl(p_rec.pem_attribute7, hr_api.g_varchar2)  or
460     nvl(per_pem_shd.g_old_rec.pem_attribute8, hr_api.g_varchar2) <>
461     nvl(p_rec.pem_attribute8, hr_api.g_varchar2)  or
462     nvl(per_pem_shd.g_old_rec.pem_attribute9, hr_api.g_varchar2) <>
463     nvl(p_rec.pem_attribute9, hr_api.g_varchar2)  or
464     nvl(per_pem_shd.g_old_rec.pem_attribute10, hr_api.g_varchar2) <>
465     nvl(p_rec.pem_attribute10, hr_api.g_varchar2)  or
466     nvl(per_pem_shd.g_old_rec.pem_attribute11, hr_api.g_varchar2) <>
467     nvl(p_rec.pem_attribute11, hr_api.g_varchar2)  or
468     nvl(per_pem_shd.g_old_rec.pem_attribute12, hr_api.g_varchar2) <>
469     nvl(p_rec.pem_attribute12, hr_api.g_varchar2)  or
470     nvl(per_pem_shd.g_old_rec.pem_attribute13, hr_api.g_varchar2) <>
471     nvl(p_rec.pem_attribute13, hr_api.g_varchar2)  or
472     nvl(per_pem_shd.g_old_rec.pem_attribute14, hr_api.g_varchar2) <>
473     nvl(p_rec.pem_attribute14, hr_api.g_varchar2)  or
474     nvl(per_pem_shd.g_old_rec.pem_attribute15, hr_api.g_varchar2) <>
475     nvl(p_rec.pem_attribute15, hr_api.g_varchar2)  or
476     nvl(per_pem_shd.g_old_rec.pem_attribute16, hr_api.g_varchar2) <>
477     nvl(p_rec.pem_attribute16, hr_api.g_varchar2)  or
478     nvl(per_pem_shd.g_old_rec.pem_attribute17, hr_api.g_varchar2) <>
479     nvl(p_rec.pem_attribute17, hr_api.g_varchar2)  or
480     nvl(per_pem_shd.g_old_rec.pem_attribute18, hr_api.g_varchar2) <>
481     nvl(p_rec.pem_attribute18, hr_api.g_varchar2)  or
482     nvl(per_pem_shd.g_old_rec.pem_attribute19, hr_api.g_varchar2) <>
483     nvl(p_rec.pem_attribute19, hr_api.g_varchar2)  or
484     nvl(per_pem_shd.g_old_rec.pem_attribute20, hr_api.g_varchar2) <>
485     nvl(p_rec.pem_attribute20, hr_api.g_varchar2)  or
486     nvl(per_pem_shd.g_old_rec.pem_attribute21, hr_api.g_varchar2) <>
487     nvl(p_rec.pem_attribute21, hr_api.g_varchar2)  or
488     nvl(per_pem_shd.g_old_rec.pem_attribute22, hr_api.g_varchar2) <>
489     nvl(p_rec.pem_attribute22, hr_api.g_varchar2)  or
490     nvl(per_pem_shd.g_old_rec.pem_attribute23, hr_api.g_varchar2) <>
491     nvl(p_rec.pem_attribute23, hr_api.g_varchar2)  or
492     nvl(per_pem_shd.g_old_rec.pem_attribute24, hr_api.g_varchar2) <>
493     nvl(p_rec.pem_attribute24, hr_api.g_varchar2)  or
494     nvl(per_pem_shd.g_old_rec.pem_attribute25, hr_api.g_varchar2) <>
495     nvl(p_rec.pem_attribute25, hr_api.g_varchar2)  or
496     nvl(per_pem_shd.g_old_rec.pem_attribute26, hr_api.g_varchar2) <>
497     nvl(p_rec.pem_attribute26, hr_api.g_varchar2)  or
498     nvl(per_pem_shd.g_old_rec.pem_attribute27, hr_api.g_varchar2) <>
499     nvl(p_rec.pem_attribute27, hr_api.g_varchar2)  or
500     nvl(per_pem_shd.g_old_rec.pem_attribute28, hr_api.g_varchar2) <>
501     nvl(p_rec.pem_attribute28, hr_api.g_varchar2)  or
502     nvl(per_pem_shd.g_old_rec.pem_attribute29, hr_api.g_varchar2) <>
503     nvl(p_rec.pem_attribute29, hr_api.g_varchar2)  or
504     nvl(per_pem_shd.g_old_rec.pem_attribute30, hr_api.g_varchar2) <>
505     nvl(p_rec.pem_attribute30, hr_api.g_varchar2) ))
506     or (p_rec.previous_employer_id is null)  then
507     --
508     -- Only execute the validation if absolutely necessary:
509     -- a) During update, the structure column value or any
510     --    of the attribute values have actually changed.
511     -- b) During insert.
512     --
513     hr_dflex_utility.ins_or_upd_descflex_attribs
514       (p_appl_short_name                 => 'PER'
515       ,p_descflex_name                   => 'PER_PREVIOUS_EMPLOYERS'
516       ,p_attribute_category              => p_rec.pem_attribute_category
517       ,p_attribute1_name                 => 'PEM_ATTRIBUTE1'
518       ,p_attribute1_value                => p_rec.pem_attribute1
519       ,p_attribute2_name                 => 'PEM_ATTRIBUTE2'
520       ,p_attribute2_value                => p_rec.pem_attribute2
521       ,p_attribute3_name                 => 'PEM_ATTRIBUTE3'
522       ,p_attribute3_value                => p_rec.pem_attribute3
523       ,p_attribute4_name                 => 'PEM_ATTRIBUTE4'
524       ,p_attribute4_value                => p_rec.pem_attribute4
525       ,p_attribute5_name                 => 'PEM_ATTRIBUTE5'
526       ,p_attribute5_value                => p_rec.pem_attribute5
527       ,p_attribute6_name                 => 'PEM_ATTRIBUTE6'
528       ,p_attribute6_value                => p_rec.pem_attribute6
529       ,p_attribute7_name                 => 'PEM_ATTRIBUTE7'
530       ,p_attribute7_value                => p_rec.pem_attribute7
531       ,p_attribute8_name                 => 'PEM_ATTRIBUTE8'
532       ,p_attribute8_value                => p_rec.pem_attribute8
533       ,p_attribute9_name                 => 'PEM_ATTRIBUTE9'
534       ,p_attribute9_value                => p_rec.pem_attribute9
535       ,p_attribute10_name                => 'PEM_ATTRIBUTE10'
536       ,p_attribute10_value               => p_rec.pem_attribute10
537       ,p_attribute11_name                => 'PEM_ATTRIBUTE11'
538       ,p_attribute11_value               => p_rec.pem_attribute11
539       ,p_attribute12_name                => 'PEM_ATTRIBUTE12'
540       ,p_attribute12_value               => p_rec.pem_attribute12
541       ,p_attribute13_name                => 'PEM_ATTRIBUTE13'
542       ,p_attribute13_value               => p_rec.pem_attribute13
543       ,p_attribute14_name                => 'PEM_ATTRIBUTE14'
544       ,p_attribute14_value               => p_rec.pem_attribute14
545       ,p_attribute15_name                => 'PEM_ATTRIBUTE15'
546       ,p_attribute15_value               => p_rec.pem_attribute15
547       ,p_attribute16_name                => 'PEM_ATTRIBUTE16'
548       ,p_attribute16_value               => p_rec.pem_attribute16
549       ,p_attribute17_name                => 'PEM_ATTRIBUTE17'
550       ,p_attribute17_value               => p_rec.pem_attribute17
551       ,p_attribute18_name                => 'PEM_ATTRIBUTE18'
552       ,p_attribute18_value               => p_rec.pem_attribute18
553       ,p_attribute19_name                => 'PEM_ATTRIBUTE19'
554       ,p_attribute19_value               => p_rec.pem_attribute19
555       ,p_attribute20_name                => 'PEM_ATTRIBUTE20'
556       ,p_attribute20_value               => p_rec.pem_attribute20
557       ,p_attribute21_name                => 'PEM_ATTRIBUTE21'
558       ,p_attribute21_value               => p_rec.pem_attribute21
559       ,p_attribute22_name                => 'PEM_ATTRIBUTE22'
560       ,p_attribute22_value               => p_rec.pem_attribute22
561       ,p_attribute23_name                => 'PEM_ATTRIBUTE23'
562       ,p_attribute23_value               => p_rec.pem_attribute23
563       ,p_attribute24_name                => 'PEM_ATTRIBUTE24'
564       ,p_attribute24_value               => p_rec.pem_attribute24
565       ,p_attribute25_name                => 'PEM_ATTRIBUTE25'
566       ,p_attribute25_value               => p_rec.pem_attribute25
567       ,p_attribute26_name                => 'PEM_ATTRIBUTE26'
568       ,p_attribute26_value               => p_rec.pem_attribute26
569       ,p_attribute27_name                => 'PEM_ATTRIBUTE27'
570       ,p_attribute27_value               => p_rec.pem_attribute27
571       ,p_attribute28_name                => 'PEM_ATTRIBUTE28'
572       ,p_attribute28_value               => p_rec.pem_attribute28
573       ,p_attribute29_name                => 'PEM_ATTRIBUTE29'
574       ,p_attribute29_value               => p_rec.pem_attribute29
575       ,p_attribute30_name                => 'PEM_ATTRIBUTE30'
576       ,p_attribute30_value               => p_rec.pem_attribute30
577       );
578   end if;
579   --
580   hr_utility.set_location(' Leaving:'||l_proc,20);
581 end chk_df;
582 --
583 -- ----------------------------------------------------------------------------
584 -- |-----------------------< chk_non_updateable_args >------------------------|
585 -- ----------------------------------------------------------------------------
586 -- {Start Of Comments}
587 --
588 -- Description:
592 -- Pre Conditions:
589 --   This procedure is used to ensure that non updateable attributes have
590 --   not been updated. If an attribute has been updated an error is generated.
591 --
593 --   g_old_rec has been populated with details of the values currently in
594 --   the database.
595 --
596 -- In Arguments:
597 --   p_rec has been populated with the updated values the user would like the
598 --   record set to.
599 --
600 -- Post Success:
601 --   Processing continues if all the non updateable attributes have not
602 --   changed.
603 --
604 -- Post Failure:
605 --   An application error is raised if any of the non updatable attributes
606 --   have been altered.
607 --
608 -- {End Of Comments}
609 -- ----------------------------------------------------------------------------
610 Procedure chk_non_updateable_args
611   (p_effective_date               in date
612   ,p_rec                          in per_pem_shd.g_rec_type
613   ) IS
614   --
615   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
616   --
617 Begin
618   hr_utility.set_location('Entering : '||l_proc,5);
619   --
620   -- Only proceed with the validation if a row exists for the current
621   -- record in the HR Schema.
622   --
623   IF NOT per_pem_shd.api_updating
624       (p_previous_employer_id                 => p_rec.previous_employer_id
625       ,p_object_version_number                => p_rec.object_version_number
626       ) THEN
627      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
628      fnd_message.set_token('PROCEDURE ', l_proc);
629      fnd_message.set_token('STEP ', '5');
630      fnd_message.raise_error;
631   END IF;
632   --
633   -- Add checks to ensure non-updateable args have
634   -- not been updated.
635   hr_utility.set_location(l_proc,10);
636   if per_pem_shd.g_old_rec.previous_employer_id <> p_rec.previous_employer_id
637      then
638      hr_api.argument_changed_error
639        (p_api_name   => l_proc
640        ,p_argument   => 'previous_employer_id'
641        ,p_base_table => per_pem_shd.g_tab_nam
642        );
643   end if;
644   --
645   hr_utility.set_location(l_proc,15);
646   if per_pem_shd.g_old_rec.person_id <> p_rec.person_id
647      then
648      hr_api.argument_changed_error
649        (p_api_name    =>  l_proc
650        ,p_argument    =>  'person_id'
651        ,p_base_table  =>  per_pem_shd.g_tab_nam
652        );
653   end if;
654   --
655   hr_utility.set_location(l_proc,20);
656   if nvl(per_pem_shd.g_old_rec.party_id,p_rec.party_id) <>
657                  nvl(p_rec.party_id,per_pem_shd.g_old_rec.party_id)
658      then
659      hr_api.argument_changed_error
660        (p_api_name    =>  l_proc
661        ,p_argument    =>  'party_id'
662        ,p_base_table  =>  per_pem_shd.g_tab_nam
663        );
664   end if;
665   hr_utility.set_location(l_proc,25);
666   --
667   -- start commented code  for business_group_id is
668   -- updateable if previously null.
669   --
670 /*
671   if per_pem_shd.g_old_rec.business_group_id <> p_rec.business_group_id
672      then
673      hr_api.argument_changed_error
674        (p_api_name    =>  l_proc
675        ,p_argument    =>  'business_group_id'
676        ,p_base_table  =>  per_pem_shd.g_tab_nam
677        );
678   end if;
679   --
680 */
681   --
682   -- end commented code
683   --
684   hr_utility.set_location('Leaving : '||l_proc,30);
685 End chk_non_updateable_args;
686 --
687 -- ----------------------------------------------------------------------------
688 -- |----------------------------< chk_person_id >-----------------------------|
689 -- ----------------------------------------------------------------------------
690 -- {Start Of Comments}
691 --
692 -- Description:
693 --   This procedure ensures that person_id value is valid.
694 --
695 -- Pre Conditions:
696 --   g_old_rec has been populated with details of the values currently in
697 --   the database.
698 --
699 -- In Arguments:
700 --  p_person_id
701 --  p_previous_employer_id
702 --  p_object_version_number
703 --  p_effective_date
704 --
705 -- Post Success:
706 --   Processing continues if person_id is valid employee
707 --
708 -- Post Failure:
709 --   An application error is raised person_id is not valid
710 --   or person is not an employee or if the person is not valid
711 --   for the current period.
712 --
713 -- {End Of Comments}
714 -- ----------------------------------------------------------------------------
715 procedure chk_person_id(p_person_id
716                         in  per_previous_employers.person_id%type
717                        ,p_previous_employer_id
718                         in  per_previous_employers.previous_employer_id%type
719                        ,p_object_version_number
720                         in  per_previous_employers.object_version_number%type
721                        ,p_effective_date
722                         in date)
723       is
724   -- Define the cursor for the person_id
725   cursor csr_person_id is
726     select  person_id
727     from    per_all_people_f
728     where   person_id = p_person_id;
729   --
730   cursor csr_effective_person_id is
731     select  person_id
732     from    per_all_people_f
733     where   person_id = p_person_id
734     and     p_effective_date
735             between effective_start_date and effective_end_date;
736   --
737   --
738   l_person_id     per_all_people_f.person_id%type;
739   --
740   l_proc          varchar2(72) := g_package||'chk_person_id';
741   l_api_updating  boolean;
742   --
743 begin
744   hr_utility.set_location('Entering:'||l_proc, 5);
745   if p_person_id is not null then
746     hr_utility.set_location(l_proc, 10);
747     l_api_updating    := per_pem_shd.api_updating(p_previous_employer_id
748                                                   =>  p_previous_employer_id
749                                                   ,p_object_version_number
750                                                   =>  p_object_version_number
751                                                   );
752     if  ((l_api_updating
753           and nvl(per_pem_shd.g_old_rec.person_id, hr_api.g_number)
754               <> nvl(p_person_id,hr_api.g_number))
755         or
756         (not l_api_updating))
757     then
758       -- Check for invalid person_id
759       hr_utility.set_location(l_proc, 15);
760       open  csr_person_id;
761       fetch csr_person_id into l_person_id;
762       if csr_person_id%notfound then
763         hr_utility.set_location(l_proc, 20);
764         close csr_person_id;
765         fnd_message.set_name('PER','HR_289535_PEM_VALID_PERSON_ID');
766         fnd_message.raise_error;
767       end if;
768       if csr_person_id%isopen then
769         close csr_person_id;
770       end if;
771       -- Check for person_id with effective dates
772       hr_utility.set_location(l_proc, 25);
773       open  csr_effective_person_id;
774       fetch csr_effective_person_id into l_person_id;
775       if csr_effective_person_id%notfound then
776          hr_utility.set_location(l_proc, 30);
777          close csr_effective_person_id;
778          fnd_message.set_name('PER','HR_289547_PEM_DATE_PERSON_ID');
779          fnd_message.raise_error;
780       end if;
781       if csr_effective_person_id%isopen then
782         close csr_effective_person_id;
783       end if;
784     --
785     end if;
786   end if;
787   hr_utility.set_location('Leaving:'||l_proc, 40);
788 exception
789   when app_exception.application_exception then
790     if hr_multi_message.exception_add
791       (p_associated_column1  => 'PER_PREVIOUS_EMPLOYERS.PERSON_ID'
792       ) then
793       hr_utility.set_location('Leaving:'||l_proc, 50);
794       raise;
795     end if;
796     hr_utility.set_location('Leaving:'||l_proc,60);
797 end chk_person_id;
798 --
799 -- ----------------------------------------------------------------------------
800 -- |-----------------------------< chk_party_id >-----------------------------|
801 -- ----------------------------------------------------------------------------
802 -- {Start Of Comments}
803 --
804 -- Description:
805 --   This procedure ensures that party_id value is valid.
806 --
807 -- Pre Conditions:
808 --   g_old_rec has been populated with details of the values currently in
809 --   the database.
810 --
811 -- In Arguments:
812 --  p_party_id
813 --  p_previous_employer_id
814 --  p_object_version_number
815 --
816 -- Post Success:
817 --   Processing continues if party_id is valid.
818 --
819 -- Post Failure:
820 --   An application error is raised party_id is not valid
821 --
822 -- {End Of Comments}
823 -- ----------------------------------------------------------------------------
824 procedure chk_party_id(p_party_id
825                       in  per_previous_employers.party_id%type
826                       ,p_previous_employer_id
827                       in  per_previous_employers.previous_employer_id%type
831   cursor csr_party_id is
828                       ,p_object_version_number
829                       in  per_previous_employers.object_version_number%type) is
830   --Define the cursor for party_id
832     select  party_id
833     from    hz_parties
834     where   party_id = p_party_id;
835   l_party_id  hz_parties.party_id%type;
836   --
837   l_proc          varchar2(72) := g_package||'chk_party_id';
838   l_api_updating  boolean;
839 begin
840   hr_utility.set_location('Entering:'||l_proc, 5);
841   --
842   if p_party_id is not null then
843     hr_utility.set_location(l_proc, 10);
844     l_api_updating    := per_pem_shd.api_updating(p_previous_employer_id
845                                                   =>  p_previous_employer_id
846                                                   ,p_object_version_number
847                                                   =>  p_object_version_number
848                                                   );
849     if  ((l_api_updating
850           and nvl(per_pem_shd.g_old_rec.party_id, hr_api.g_number)
851               <> nvl(p_party_id,hr_api.g_number))
852         or
853         (not l_api_updating))
854     then
855       hr_utility.set_location(l_proc, 15);
856       open  csr_party_id;
857       fetch csr_party_id into l_party_id;
858       if  csr_party_id%notfound then
859         hr_utility.set_location(l_proc, 20);
860         close csr_party_id;
861         fnd_message.set_name('PER','HR_289536_PEM_VALID_PARTY_ID');
862         fnd_message.raise_error;
863       end if;
864       if  csr_party_id%isopen then
865         close csr_party_id;
866       end if;
867     end if;
868   end if;
869   --
870   hr_utility.set_location('Leaving:'||l_proc, 25);
871 exception
872   when app_exception.application_exception then
873     if hr_multi_message.exception_add
874       (p_associated_column1  => 'PER_PREVIOUS_EMPLOYERS.PARTY_ID'
875       ) then
876       hr_utility.set_location('Leaving:'||l_proc,30);
877       raise;
878     end if;
879     hr_utility.set_location('Leaving:'||l_proc,40);
880 end chk_party_id;
881 --
882 -- ----------------------------------------------------------------------------
886 --
883 -- |-------------------------< chk_employer_country >-------------------------|
884 -- ----------------------------------------------------------------------------
885 -- {Start Of Comments}
887 -- Description:
888 --   This procedure ensures that employer_country has valid lookup
889 --
890 -- Pre Conditions:
891 --   g_old_rec has been populated with details of the values currently in
892 --   the database.
893 --
894 -- In Arguments:
895 --  p_previous_employer_id
896 --  p_object_version_number
897 --  p_employer_country
898 --
899 -- Post Success:
900 --   Processing continues if employer_country has valid value
901 --   in fnd_territories
902 --
903 -- Post Failure:
904 --   An application error is raised if employer country is not valid
905 --
906 -- {End Of Comments}
907 -- ----------------------------------------------------------------------------
908 procedure chk_employer_country
909           (p_previous_employer_id
910           in per_previous_employers.previous_employer_id%type
911           ,p_object_version_number
912           in per_previous_employers.object_version_number%type
913           ,p_employer_country
914           in per_previous_employers.employer_country%type) is
915   cursor csr_employer_country is
916     select  territory_code
917     from    fnd_territories_vl
918     where   territory_code = p_employer_country;
919   l_employer_country  per_previous_employers.employer_country%type;
920   --
921   l_proc            varchar2(72) := g_package||'chk_employer_country';
922   l_api_updating    boolean;
923 begin
924   hr_utility.set_location('Entering:'||l_proc, 5);
925   --
926   if p_employer_country is not null then
927     hr_utility.set_location(l_proc, 10);
928     l_api_updating    := per_pem_shd.api_updating(p_previous_employer_id
929                                                   =>  p_previous_employer_id
930                                                   ,p_object_version_number
931                                                   =>  p_object_version_number
932                                                   );
933     if  ((l_api_updating
934           and nvl(per_pem_shd.g_old_rec.employer_country, hr_api.g_varchar2)
935               <> nvl(p_employer_country,hr_api.g_varchar2))
936         or
937         (not l_api_updating))
938     then
939       hr_utility.set_location(l_proc, 15);
940       open  csr_employer_country;
941       fetch csr_employer_country into l_employer_country;
942       if  csr_employer_country%notfound then
943         hr_utility.set_location(l_proc, 20);
944         close csr_employer_country;
945         fnd_message.set_name('PER','HR_289531_PEM_VALD_EMPR_CNTRY');
946         fnd_message.raise_error;
947       end if;
948       if  csr_employer_country%isopen then
949         close csr_employer_country;
950       end if;
951     end if;
952   end if;
953   --
954   hr_utility.set_location('Leaving:'||l_proc, 25);
955 exception
956   when app_exception.application_exception then
957     if hr_multi_message.exception_add
958       (p_associated_column1  => 'PER_PREVIOUS_EMPLOYERS.EMPLOYER_COUNTRY'
959       ) then
960       hr_utility.set_location('Leaving:'||l_proc, 30);
961       raise;
962     end if;
963     hr_utility.set_location('Leaving:'||l_proc,40);
964 end chk_employer_country;
965 --
966 -- ----------------------------------------------------------------------------
967 -- |--------------------------< chk_employer_type >---------------------------|
968 -- ----------------------------------------------------------------------------
969 -- {Start Of Comments}
970 --
971 -- Description:
972 --   This procedure ensures that employer_type has valid lookup
973 --
974 -- Pre Conditions:
975 --   g_old_rec has been populated with details of the values currently in
976 --   the database.
977 --
978 -- In Arguments:
979 --  p_previous_employer_id
980 --  p_object_version_number
981 --  p_employer_type
982 --  p_effective_date
983 --
984 -- Post Success:
985 --   Processing continues if employer_type has valid lookup
986 --
987 -- Post Failure:
988 --   An application error is raised if employer_type has no valid lookup
989 --
990 -- {End Of Comments}
991 -- ----------------------------------------------------------------------------
992 procedure chk_employer_type
993           (p_previous_employer_id
994           in  per_previous_employers.previous_employer_id%type
995           ,p_object_version_number
996           in  per_previous_employers.object_version_number%type
997           ,p_employer_type
998           in  per_previous_employers.employer_type%type
999           ,p_effective_date in  date) is
1000   l_proc              varchar2(72) := g_package||'chk_employer_type';
1001   l_no_lookup         boolean;
1002   l_effective_date    date := p_effective_date;
1003   l_lookup_type       fnd_lookups.lookup_type%type := 'PREV_EMP_TYPE';
1004   l_lookup_code       per_previous_employers.employer_type%type
1005                       := p_employer_type;
1006   l_api_updating      boolean;
1007 begin
1008   hr_utility.set_location('Entering:'||l_proc, 5);
1009   --
1010   if p_employer_type is not null then
1011     hr_utility.set_location(l_proc, 10);
1012     l_api_updating    := per_pem_shd.api_updating(p_previous_employer_id
1013                                                  =>  p_previous_employer_id
1014                                                  ,p_object_version_number
1015                                                  =>  p_object_version_number
1016                                                  );
1017     if ((l_api_updating and
1021        (not l_api_updating)) then
1018                nvl(p_employer_type,hr_api.g_varchar2)
1019                <> nvl(per_pem_shd.g_old_rec.employer_type, hr_api.g_varchar2))
1020        or
1022       hr_utility.set_location(l_proc, 15);
1023       l_no_lookup := hr_api.not_exists_in_leg_lookups
1024                       (p_effective_date =>  l_effective_date
1025                       ,p_lookup_type    =>  l_lookup_type
1026                       ,p_lookup_code    =>  l_lookup_code
1027                       );
1028       if l_no_lookup = true then
1029         hr_utility.set_location(l_proc, 20);
1030         fnd_message.set_name('PER','HR_289532_PEM_VALID_EMPR_TYPE');
1031         fnd_message.raise_error;
1032       end if;
1033     end if;
1034   end if;
1035   --
1036   hr_utility.set_location('Leaving:'||l_proc, 25);
1037 exception
1038   when app_exception.application_exception then
1039     if hr_multi_message.exception_add
1040       (p_associated_column1  => 'PER_PREVIOUS_EMPLOYERS.EMPLOYER_TYPE'
1041       ) then
1042       hr_utility.set_location('Leaving:'||l_proc, 30);
1043       raise;
1044     end if;
1045     hr_utility.set_location('Leaving:'||l_proc,40);
1046 end chk_employer_type;
1047 --
1048 -- ----------------------------------------------------------------------------
1049 -- |-------------------------< chk_employer_subtype >-------------------------|
1050 -- ----------------------------------------------------------------------------
1051 -- {Start Of Comments}
1052 --
1053 -- Description:
1054 --   This procedure ensures that employer_subtype has valid lookup
1055 --
1056 -- Pre Conditions:
1057 --   g_old_rec has been populated with details of the values currently in
1058 --   the database.
1059 --
1060 -- In Arguments:
1061 --  p_previous_employer_id
1062 --  p_object_version_number
1063 --  p_employer_type
1064 --  p_employer_subtype
1065 --  p_effective_date
1066 --
1067 -- Post Success:
1068 --   Processing continues if employer_subtype has valid lookup
1069 --
1070 -- Post Failure:
1071 --   An application error is raised if employer_subtype has no valid lookup
1072 --
1073 -- {End Of Comments}
1074 -- ----------------------------------------------------------------------------
1075 procedure chk_employer_subtype
1076           (p_previous_employer_id
1077           in  per_previous_employers.previous_employer_id%type
1078           ,p_object_version_number
1079           in  per_previous_employers.object_version_number%type
1080           ,p_employer_type
1081           in per_previous_employers.employer_type%type
1082           ,p_employer_subtype
1083           in  per_previous_employers.employer_subtype%type
1084           ,p_effective_date in  date) is
1085   --
1086   cursor csr_employer_subtype is
1087          select lookup_code
1088          from   hr_leg_lookups
1089          where  lookup_type = 'PREV_EMP_SUBTYPE'
1090          and    lookup_code like p_employer_type||'_%'
1091          and    lookup_code = p_employer_subtype;
1092   --
1093   l_proc            varchar2(72) := g_package||'chk_employer_subtype';
1094   l_no_lookup       boolean;
1095   l_effective_date  date := p_effective_date;
1096   l_lookup_type     fnd_lookups.lookup_type%type := 'PREV_EMP_SUBTYPE';
1097   l_lookup_code     fnd_lookups.lookup_code%type := p_employer_subtype;
1098   l_employer_subtype  hr_leg_lookups.lookup_code%type;
1099   --
1100   l_api_updating    boolean;
1101 begin
1102   hr_utility.set_location('Entering:'||l_proc, 5);
1103   --
1104   --Only proceed with employer_subtype validation when multiple message list
1105   --does not already contain an error associated with employer type column.
1106   --
1107   if hr_multi_message.no_exclusive_error
1108     (p_check_column1    => 'PER_PREVIOUS_EMPLOYERS.EMPLOYER_TYPE'
1109     ) then
1110     if p_employer_subtype is not null then
1111       hr_utility.set_location(l_proc, 10);
1112       l_api_updating := per_pem_shd.api_updating(p_previous_employer_id
1113                                               =>  p_previous_employer_id
1114                                               ,p_object_version_number
1115                                               =>  p_object_version_number
1116                                               );
1117       if ((l_api_updating and
1118                  nvl(p_employer_subtype,hr_api.g_varchar2)
1119                  <> nvl(per_pem_shd.g_old_rec.employer_subtype
1120                         , hr_api.g_varchar2))
1121        or
1122        (not l_api_updating)) then
1123         hr_utility.set_location(l_proc, 15);
1124         -- Check for standard lookup
1125         l_no_lookup :=  hr_api.not_exists_in_leg_lookups
1126                               (p_effective_date =>  l_effective_date
1127                               ,p_lookup_type    =>  l_lookup_type
1128                               ,p_lookup_code    =>  l_lookup_code
1129                               );
1130         if l_no_lookup = true then
1131           hr_utility.set_location(l_proc, 20);
1132           fnd_message.set_name('PER','HR_289533_PEM_VALID_EMPR_SBTP');
1133           fnd_message.raise_error;
1134         end if;
1135         -- Check for the dependency on employer type
1136         hr_utility.set_location(l_proc, 25);
1137         open csr_employer_subtype;
1138         fetch csr_employer_subtype into l_employer_subtype;
1139         if csr_employer_subtype%notfound then
1140           hr_utility.set_location(l_proc, 30);
1141           close csr_employer_subtype;
1142           fnd_message.set_name('PER','HR_289533_PEM_VALID_EMPR_SBTP');
1146           close csr_employer_subtype;
1143           fnd_message.raise_error;
1144         end if;
1145         if csr_employer_subtype%isopen then
1147         end if;
1148       end if;
1149     end if;
1150   end if;
1151   --
1152   hr_utility.set_location('Leaving:'||l_proc, 35);
1153 exception
1154   when app_exception.application_exception then
1155     if hr_multi_message.exception_add
1156       (p_associated_column1  => 'PER_PREVIOUS_EMPLOYERS.EMPLOYER_TYPE'
1157       ,p_associated_column2  => 'PER_PREVIOUS_EMPLOYERS.EMPLOYER_SUBTYPE'
1158       ) then
1159       hr_utility.set_location('Leaving:'||l_proc, 40);
1160       raise;
1161     end if;
1162     hr_utility.set_location('Leaving:'||l_proc,50);
1163 end chk_employer_subtype;
1164 --
1165 -- -----------------------------------------------------------------------
1166 -- |---------------------------< chk_start_end_dates >-------------------|
1167 -- -----------------------------------------------------------------------
1168 -- {Start Of Comments}
1169 --
1173 -- Pre Conditions:
1170 -- Description:
1171 --   This procedure ensures that end_date is greater than start_date
1172 --
1174 --   g_old_rec has been populated with details of the values currently in
1175 --   the database.
1176 --
1177 -- In Arguments:
1178 --  p_previous_employer_id
1179 --  p_object_version_number
1180 --  p_start_date
1181 --  p_end_date
1182 --
1183 -- Post Success:
1184 --   Processing continues if end_date is greater than start_date
1185 --
1186 -- Post Failure:
1187 --   An application error is raised if start_date is greater than end_date
1188 --
1189 -- {End Of Comments}
1190 -- ----------------------------------------------------------------------------
1191 -- Bug 14316052
1192 procedure chk_start_end_dates
1193           (p_previous_employer_id
1194           in  per_previous_employers.previous_employer_id%type
1195           ,p_object_version_number
1196           in  per_previous_employers.object_version_number%type
1197           ,p_start_date
1198           in  per_previous_employers.start_date%type
1199           ,p_end_date
1200           in  per_previous_employers.end_date%TYPE
1201 	  ,p_effective_date
1202 	  IN  per_previous_employers.start_date%type
1203           ,p_business_group_id
1204           IN per_previous_employers.business_group_id%TYPE
1205           ,p_employer_type
1206           IN per_previous_employers.employer_type%TYPE) is
1207 
1208 l_proc            varchar2(72) := g_package||'chk_start_end_dates';
1209 l_api_updating    boolean;
1210 
1211 l_leg_code per_business_groups.legislation_code%TYPE;
1212 CURSOR leg_code IS
1213   SELECT legislation_code
1214   FROM per_business_groups
1215   WHERE business_group_id = p_business_group_id;
1216 
1217 begin
1218   hr_utility.set_location('Entering:'||l_proc, 5);
1219   --
1220     -- This If condition added for bug 7112425
1221 
1222   OPEN leg_code;
1223   FETCH leg_code INTO l_leg_code;
1224   CLOSE leg_code;
1225 
1226     IF NOT (l_leg_code = 'PL' AND p_employer_type = 'PARALLEL') THEN
1227       IF p_start_date is not null  AND p_start_date > p_effective_date THEN
1228           fnd_message.set_name('PER','HR_INVAL_ST_DT_PEM');
1229           fnd_message.raise_error;
1230       END IF ;
1231     END IF;
1232  -- Bug 14316052
1233   hr_utility.set_location('Entering:'||l_proc, 6);
1234 
1235   if p_start_date is not null and p_end_date is not null then
1236     hr_utility.set_location(l_proc, 10);
1237     l_api_updating := per_pem_shd.api_updating(p_previous_employer_id
1238                                               =>  p_previous_employer_id
1239                                               ,p_object_version_number
1240                                               =>  p_object_version_number
1241                                               );
1242     if ((l_api_updating and
1243         ( nvl(p_start_date,hr_api.g_sot)
1244           <> nvl(per_pem_shd.g_old_rec.start_date, hr_api.g_sot)
1245              or
1246              nvl(p_end_date,hr_api.g_eot)
1247              <> nvl(per_pem_shd.g_old_rec.end_date, hr_api.g_eot)
1248         ))
1249         or
1250         (not l_api_updating)) then
1251           hr_utility.set_location(l_proc, 15);
1252           if p_start_date > p_end_date then
1253             hr_utility.set_location(l_proc, 20);
1254             fnd_message.set_name('PER','HR_289530_PEM_STRT_END_DATES');
1255             fnd_message.set_token('START_DATE',TO_CHAR(p_start_date,'DD-MON-YYYY'),true);
1256             fnd_message.set_token('END_DATE',TO_CHAR(p_end_date,'DD-MON-YYYY'),true);
1257             fnd_message.raise_error;
1258           end if;
1259     end if;
1260   end if;
1261   --
1262   hr_utility.set_location('Leaving:'||l_proc, 25);
1266       (p_associated_column1  => 'PER_PREVIOUS_EMPLOYERS.START_DATE'
1263 /*exception
1264   when app_exception.application_exception then
1265     if hr_multi_message.exception_add
1267       ,p_associated_column2  => 'PER_PREVIOUS_EMPLOYERS.END_DATE'
1268       ) then
1269       hr_utility.set_location('Leaving:'||l_proc, 30);
1270       raise;
1271     end if;
1272     hr_utility.set_location('Leaving:'||l_proc,40);*/--commented for the bug 5686794
1273 end chk_start_end_dates;
1274 --
1275 -- -----------------------------------------------------------------------
1276 -- |---------------------------< chk_period_years >----------------------|
1277 -- -----------------------------------------------------------------------
1278 -- {Start Of Comments}
1279 --
1280 -- Description:
1281 --   This procedure ensures that period_years is between 0 and 99
1282 --
1283 -- Pre Conditions:
1284 --   g_old_rec has been populated with details of the values currently in
1285 --   the database.
1286 --
1287 -- In Arguments:
1288 --  p_period_years
1289 --  p_previous_employer_id
1290 --  p_object_version_number
1291 --
1292 -- Post Success:
1293 --   Processing continues if period_years is between 0 and 99
1294 --
1295 -- Post Failure:
1296 --   An application error is raised if period_years value is not in range
1297 --   of 0 and 99.
1298 --
1299 -- {End Of Comments}
1300 -- ----------------------------------------------------------------------------
1301 procedure chk_period_years
1302           (p_period_years
1303            in  per_previous_employers.period_years%type
1304           ,p_previous_employer_id
1305            in  per_previous_employers.previous_employer_id%type
1306           ,p_object_version_number
1307            in  per_previous_employers.object_version_number%type) is
1308   l_proc          varchar2(72) := g_package||'chk_period_years';
1309   l_api_updating  boolean;
1310 begin
1311   hr_utility.set_location('Entering:'||l_proc, 5);
1312   --
1313   if p_period_years is not null then
1314     l_api_updating := per_pem_shd.api_updating(p_previous_employer_id
1315                                               =>  p_previous_employer_id
1316                                               ,p_object_version_number
1317                                               =>  p_object_version_number);
1318     hr_utility.set_location(l_proc, 10);
1319     if ((l_api_updating and
1320         (   nvl(p_period_years,hr_api.g_number)
1321             <> nvl(per_pem_shd.g_old_rec.period_years, hr_api.g_number)
1322         )
1323        ) or
1324        (not l_api_updating)) then
1325       hr_utility.set_location(l_proc, 15);
1326       if p_period_years not between 0 and 99 then
1327         hr_utility.set_location(l_proc, 20);
1328         fnd_message.set_name('PER','HR_289534_PEM_VALID_PRD_RANGE');
1329         fnd_message.set_token('RANGE_START','0',true);
1333     end if;
1330         fnd_message.set_token('RANGE_END','99',true);
1331         fnd_message.raise_error;
1332       end if;
1334   end if;
1335   --
1336   hr_utility.set_location('Leaving:'||l_proc, 25);
1337 exception
1338   when app_exception.application_exception then
1339     if hr_multi_message.exception_add
1340       (p_associated_column1  => 'PER_PREVIOUS_EMPLOYERS.PERIOD_YEARS'
1341       ) then
1342       hr_utility.set_location('Leaving:'||l_proc, 30);
1343       raise;
1344     end if;
1345     hr_utility.set_location('Leaving:'||l_proc,40);
1346 end chk_period_years;
1347 --
1348 -- -----------------------------------------------------------------------
1349 -- |---------------------------< chk_period_months >---------------------|
1350 -- -----------------------------------------------------------------------
1351 -- {Start Of Comments}
1352 --
1353 -- Description:
1354 --   This procedure ensures that period_months is between 0 and 11
1355 --
1356 -- Pre Conditions:
1357 --   g_old_rec has been populated with details of the values currently in
1358 --   the database.
1359 --
1360 -- In Arguments:
1361 --  p_period_months
1362 --  p_previous_employer_id
1363 --  p_object_version_number
1364 --
1365 -- Post Success:
1366 --   Processing continues if period_years is between 0 and 11
1367 --
1368 -- Post Failure:
1369 --   An application error is raised if period_months value is not in range
1370 --   of 0 and 11.
1371 --
1372 -- {End Of Comments}
1373 -- ----------------------------------------------------------------------------
1374 procedure chk_period_months
1375           (p_period_months
1376            in  per_previous_employers.period_months%type
1377           ,p_previous_employer_id
1378            in  per_previous_employers.previous_employer_id%type
1379           ,p_object_version_number
1383 begin
1380            in  per_previous_employers.object_version_number%type) is
1381   l_proc          varchar2(72) := g_package||'chk_period_months';
1382   l_api_updating  boolean;
1384   hr_utility.set_location('Entering:'||l_proc, 5);
1385   --
1386   if p_period_months is not null then
1387     l_api_updating := per_pem_shd.api_updating(p_previous_employer_id
1388                                               =>  p_previous_employer_id
1389                                               ,p_object_version_number
1390                                               =>  p_object_version_number);
1391     hr_utility.set_location(l_proc, 10);
1392     if ((l_api_updating and
1393         (   nvl(p_period_months,hr_api.g_number)
1394             <> nvl(per_pem_shd.g_old_rec.period_months,hr_api.g_number)
1395         )
1396        ) or
1397        (not l_api_updating)) then
1398       hr_utility.set_location(l_proc, 15);
1399       if p_period_months not between 0 and 11 then
1400         hr_utility.set_location(l_proc, 20);
1401         fnd_message.set_name('PER','HR_289534_PEM_VALID_PRD_RANGE');
1402         fnd_message.set_token('RANGE_START','0',true);
1403         fnd_message.set_token('RANGE_END','11',true);
1404         fnd_message.raise_error;
1405       end if;
1406     end if;
1407   end if;
1408   --
1409   hr_utility.set_location('Leaving:'||l_proc, 25);
1410 exception
1411   when app_exception.application_exception then
1412     if hr_multi_message.exception_add
1413       (p_associated_column1  => 'PER_PREVIOUS_EMPLOYERS.PERIOD_MONTHS'
1414       ) then
1415       hr_utility.set_location('Leaving:'||l_proc, 30);
1416       raise;
1417     end if;
1418     hr_utility.set_location('Leaving:'||l_proc,40);
1419 end chk_period_months;
1420 --
1421 -- -----------------------------------------------------------------------
1422 -- |---------------------------< chk_period_days >-----------------------|
1423 -- -----------------------------------------------------------------------
1424 -- {Start Of Comments}
1425 --
1426 -- Description:
1427 --   This procedure ensures that period_days is between 0 and 365
1428 --
1429 -- Pre Conditions:
1430 --   g_old_rec has been populated with details of the values currently in
1431 --   the database.
1432 --
1433 -- In Arguments:
1434 --  p_period_days
1435 --  p_previous_employer_id
1436 --  p_object_version_number
1437 --
1438 -- Post Success:
1439 --   Processing continues if period_days is between 0 and 365
1440 --
1441 -- Post Failure:
1442 --   An application error is raised if period_days value is not in range
1443 --   of 0 and 365.
1444 --
1445 -- {End Of Comments}
1446 -- ----------------------------------------------------------------------------
1447 procedure chk_period_days
1448           (p_period_days
1449            in  per_previous_employers.period_days%type
1450           ,p_previous_employer_id
1451            in  per_previous_employers.previous_employer_id%type
1452           ,p_object_version_number
1453            in  per_previous_employers.object_version_number%type) is
1454   l_proc          varchar2(72) := g_package||'chk_period_days';
1455   l_api_updating  boolean;
1456 begin
1457   hr_utility.set_location('Entering:'||l_proc, 5);
1458   --
1459   if p_period_days is not null then
1460     l_api_updating := per_pem_shd.api_updating(p_previous_employer_id
1461                                               =>  p_previous_employer_id
1462                                               ,p_object_version_number
1463                                               =>  p_object_version_number);
1464     hr_utility.set_location(l_proc, 10);
1465     if ((l_api_updating and
1466         (   nvl(p_period_days,hr_api.g_number)
1467             <> nvl(per_pem_shd.g_old_rec.period_days,hr_api.g_number)
1468         )
1469        ) or
1470        (not l_api_updating)) then
1471       hr_utility.set_location(l_proc, 15);
1472       if p_period_days not between 0 and 365 then
1473         hr_utility.set_location(l_proc, 20);
1474         fnd_message.set_name('PER','HR_289534_PEM_VALID_PRD_RANGE');
1475         fnd_message.set_token('RANGE_START','0',true);
1476         fnd_message.set_token('RANGE_END','365',true);
1477         fnd_message.raise_error;
1478       end if;
1479     end if;
1480   end if;
1481   --
1482   hr_utility.set_location('Leaving:'||l_proc, 25);
1483 exception
1484   when app_exception.application_exception then
1485     if hr_multi_message.exception_add
1486       (p_associated_column1  => 'PER_PREVIOUS_EMPLOYERS.PERIOD_DAYS'
1487       ) then
1488       hr_utility.set_location('Leaving:'||l_proc, 30);
1489       raise;
1490     end if;
1491     hr_utility.set_location('Leaving:'||l_proc,40);
1492 end chk_period_days;
1493 --
1497 -- {Start Of Comments}
1494 -- ----------------------------------------------------------------------------
1495 -- |---------------------------< chk_all_assignments >------------------------|
1496 -- ----------------------------------------------------------------------------
1498 --
1499 -- Description:
1500 --   This procedure ensures that all_assignments is valid value and
1501 --   this previous employer is not associated with any assignments.
1502 --   Valid values for all_assignments are 'Y' and 'N'
1503 --
1504 -- Pre Conditions:
1505 --   g_old_rec has been populated with details of the values currently in
1506 --   the database.
1507 --
1508 -- In Arguments:
1509 --  p_previous_employer_id
1510 --  p_object_version_number
1511 --  p_all_assignments
1512 --
1513 -- Post Success:
1514 --   Processing continues if all_assignments value is valid and
1515 --   this previous employer is not mapped to any assignment
1516 --
1517 --
1518 -- Post Failure:
1519 --   An application error is raised if all_assignments value is not valid
1520 --   if there are any assignments mapped to this previous employer
1521 --
1522 -- {End Of Comments}
1523 -- ----------------------------------------------------------------------------
1524 procedure chk_all_assignments
1525           (p_previous_employer_id
1526           in  per_previous_employers.previous_employer_id%type
1527           ,p_object_version_number
1528           in  per_previous_employers.object_version_number%type
1529           ,p_all_assignments
1530           in  per_previous_employers.all_assignments%type) is
1531   cursor csr_pem_assignments is
1532        select previous_job_usage_id
1533        from   per_previous_job_usages
1534        where  previous_employer_id = p_previous_employer_id;
1535   l_previous_job_usage_id   per_previous_job_usages.previous_job_usage_id%type;
1536   --
1537   l_proc                varchar2(72) := g_package||'chk_all_assignments';
1538   l_api_updating        boolean;
1539 begin
1540   hr_utility.set_location('Entering:'||l_proc, 5);
1541   --
1542   if p_all_assignments is not null then
1543     hr_utility.set_location(l_proc, 10);
1544     l_api_updating := per_pem_shd.api_updating(p_previous_employer_id
1545                                               =>  p_previous_employer_id
1546                                               ,p_object_version_number
1547                                               =>  p_object_version_number
1548                                               );
1549 
1550     if ((l_api_updating and
1551          nvl(p_all_assignments,hr_api.g_varchar2)
1552           <> nvl(per_pem_shd.g_old_rec.all_assignments, hr_api.g_varchar2))
1553           or
1554           (not l_api_updating)) then
1555         hr_utility.set_location(l_proc, 15);
1556         if p_all_assignments = 'Y' or p_all_assignments = 'N' then
1557           hr_utility.set_location(l_proc, 20);
1558           if p_all_assignments = 'Y' then
1559             hr_utility.set_location(l_proc, 25);
1560             open    csr_pem_assignments;
1561             fetch   csr_pem_assignments into l_previous_job_usage_id;
1562             if csr_pem_assignments%found then
1563               hr_utility.set_location(l_proc, 30);
1564               close   csr_pem_assignments;
1565               fnd_message.set_name('PER','HR_289546_PEM_ALL_ASG_MOD_NA');
1566               hr_multi_message.add
1567           (p_associated_column1  => 'PER_PREVIOUS_EMPLOYERS.PREVIOUS_EMPLOYER_ID'
1568                );
1569             end if;
1570             if  csr_pem_assignments%isopen then
1571               close csr_pem_assignments;
1572             end if;
1573           end if;
1574         else
1575           hr_utility.set_location(l_proc, 35);
1576           fnd_message.set_name('PER','HR_289545_PEM_VALID_ASGMT_FLAG');
1577           hr_multi_message.add
1578        (p_associated_column1  => 'PER_PREVIOUS_EMPLOYERS.ALL_ASSIGNMENTS'
1579             );
1580         end if;
1581     end if;
1582   end if;
1583   --
1584   hr_utility.set_location('Leaving:'||l_proc, 40);
1585 end chk_all_assignments;
1586 --
1587 -- ----------------------------------------------------------------------------
1588 -- |-------------------------< chk_business_group_id >------------------------|
1589 -- ----------------------------------------------------------------------------
1590 -- {Start Of Comments}
1591 --
1592 -- Description:
1593 --   This procedure ensures that business_group_id value is valid.
1594 --
1595 -- Pre Conditions:
1596 --   g_old_rec has been populated with details of the values currently in
1597 --   the database.
1598 --
1599 -- In Arguments:
1600 --  p_business_group_id
1601 --  p_previous_employer_id
1602 --  p_object_version_number
1603 --  p_effective_date
1604 --
1605 -- Post Success:
1606 --   Processing continues if business_group_id is valid and if updating,
1607 --   old_rec.business_group_id is null
1608 --
1609 -- Post Failure:
1610 --   An application error is raised
1611 --   if updating and old_rec.business_group_id is not null, or
1612 --   business_group_id is not valid.
1613 --
1614 -- {End Of Comments}
1615 -- ----------------------------------------------------------------------------
1616 procedure chk_business_group_id
1617             (p_business_group_id
1618                in  per_previous_employers.business_group_id%type
1619             ,p_previous_employer_id
1620                in  per_previous_employers.previous_employer_id%type
1621             ,p_object_version_number
1625   l_proc          varchar2(72) := g_package||'chk_business_group_id';
1622                in  per_previous_employers.object_version_number%type
1623             ,p_effective_date        in date) is
1624   --
1626   l_api_updating  boolean;
1627   --
1628 begin
1629   hr_utility.set_location('Entering:'||l_proc, 5);
1630   if p_business_group_id is not null then
1631     hr_utility.set_location(l_proc, 10);
1632     --
1633     --validate business_group_id
1634     --
1635     hr_api.validate_bus_grp_id(p_business_group_id);
1636   --
1637   end if;
1638   --
1639   --
1640   --update only if null
1641   --
1642   l_api_updating    := per_pem_shd.api_updating
1643                               (p_previous_employer_id  =>  p_previous_employer_id
1644                               ,p_object_version_number =>  p_object_version_number );
1645   if  (l_api_updating
1646         and per_pem_shd.g_old_rec.business_group_id is not null
1647         and per_pem_shd.g_old_rec.business_group_id <> p_business_group_id ) then
1648       --
1649       hr_utility.set_message(800, 'HR_289947_INV_UPD_BG_ID');
1650       hr_utility.raise_error;
1651       --
1652   end if;
1653   --
1654   hr_utility.set_location('Leaving:'||l_proc, 40);
1655 exception
1656   when app_exception.application_exception then
1657     if hr_multi_message.exception_add
1658       (p_associated_column1  => 'PER_PREVIOUS_EMPLOYERS.BUSINESS_GROUP_ID'
1659       ) then
1660       hr_utility.set_location('Leaving:'||l_proc, 50);
1661       raise;
1662     end if;
1663     hr_utility.set_location('Leaving:'||l_proc,60);
1664 end chk_business_group_id;
1665 --
1666 -- ----------------------------------------------------------------------------
1667 -- |---------------------------< insert_validate >----------------------------|
1668 -- ----------------------------------------------------------------------------
1669 Procedure insert_validate
1670   (p_effective_date               in date
1671   ,p_rec                          in per_pem_shd.g_rec_type
1672   ) is
1673 --
1674   l_proc  varchar2(72) := g_package||'insert_validate';
1675 --
1676 Begin
1677   hr_utility.set_location('Entering:'||l_proc, 5);
1678   --
1679   --Validate Important Attributes
1680   --
1681   hr_utility.set_location(l_proc, 10);
1682   hr_api.mandatory_arg_error
1683   (p_api_name           => l_proc
1684   ,p_argument           => 'EFFECTIVE_DATE'
1685   ,p_argument_value     => p_effective_date
1686   );
1687   -- Call all supporting business operations
1688   hr_utility.set_location(l_proc, 15);
1689   --
1690   if p_rec.party_id is null and p_rec.business_group_id is not null then
1691     hr_api.validate_bus_grp_id
1692     (p_business_group_id  => p_rec.business_group_id
1693     ,p_associated_column1 =>per_pem_shd.g_tab_nam || '.BUSINESS_GROUP_ID'
1694     );  -- Validate Bus Grp
1695   end if;
1696   --After validating the set of important attributes,
1697   --if multiple message detection is enabled and atleast
1698   --one error has been found then abort further validation.
1699   --
1700   hr_multi_message.end_validation_set;
1701   --
1702   --validate dependent attributes
1703   --
1704   hr_utility.set_location(l_proc, 18);
1705   chk_business_group_id(p_business_group_id     =>  p_rec.business_group_id
1706                        ,p_previous_employer_id  =>  p_rec.previous_employer_id
1707                        ,p_object_version_number =>  p_rec.object_version_number
1708                        ,p_effective_date        =>  p_effective_date);
1709   --
1710   hr_utility.set_location(l_proc, 20);
1711   chk_person_id(p_person_id             =>  p_rec.person_id
1712                ,p_effective_date        =>  p_effective_date
1713                ,p_previous_employer_id  =>  p_rec.previous_employer_id
1714                ,p_object_version_number =>  p_rec.object_version_number);
1715   --
1716   hr_utility.set_location(l_proc, 25);
1717   chk_party_id(p_party_id               =>  p_rec.party_id
1718               ,p_previous_employer_id   =>  p_rec.previous_employer_id
1719               ,p_object_version_number  =>  p_rec.object_version_number);
1720   --
1721   hr_utility.set_location(l_proc, 30);
1722   chk_employer_country(p_previous_employer_id   =>  p_rec.previous_employer_id
1723                       ,p_object_version_number  =>  p_rec.object_version_number
1724                       ,p_employer_country       =>  p_rec.employer_country);
1725   --
1726   hr_utility.set_location(l_proc, 35);
1727   chk_employer_type(p_previous_employer_id    =>  p_rec.previous_employer_id
1728                    ,p_object_version_number   =>  p_rec.object_version_number
1729                    ,p_employer_type           =>  p_rec.employer_type
1730                    ,p_effective_date          =>  p_effective_date);
1731   --
1732   hr_utility.set_location(l_proc, 40);
1733   chk_employer_subtype(p_previous_employer_id   =>  p_rec.previous_employer_id
1734                       ,p_object_version_number  =>  p_rec.object_version_number
1735                       ,p_employer_type          =>  p_rec.employer_type
1736                       ,p_employer_subtype       =>  p_rec.employer_subtype
1737                       ,p_effective_date         =>  p_effective_date);
1738   --
1739   hr_utility.set_location(l_proc, 50);
1740   chk_start_end_dates(p_previous_employer_id    =>  p_rec.previous_employer_id
1741                      ,p_object_version_number   =>  p_rec.object_version_number
1742                      ,p_start_date              =>  p_rec.start_date
1743                      ,p_end_date                =>  p_rec.end_date
1744 		     ,p_effective_date          =>  p_effective_date  -- bug 7112425
1745 		     ,p_business_group_id       =>  p_rec.business_group_id -- bug 14316052
1746                      ,p_employer_type           =>  p_rec.employer_type);
1750                    =>  p_rec.period_years
1747   --
1748   hr_utility.set_location(l_proc, 55);
1749   chk_period_years(p_period_years
1751                   ,p_previous_employer_id
1752                    =>  p_rec.previous_employer_id
1753                   ,p_object_version_number
1754                    =>  p_rec.object_version_number);
1755   --
1756   hr_utility.set_location(l_proc, 60);
1757   chk_period_months(p_period_months
1758                     =>  p_rec.period_months
1759                    ,p_previous_employer_id
1760                     =>  p_rec.previous_employer_id
1761                    ,p_object_version_number
1762                     =>  p_rec.object_version_number);
1763   --
1764   hr_utility.set_location(l_proc, 65);
1765   chk_period_days(p_period_days
1766                   =>  p_rec.period_days
1767                  ,p_previous_employer_id
1768                   =>  p_rec.previous_employer_id
1769                  ,p_object_version_number
1770                   =>  p_rec.object_version_number);
1771   --
1772   hr_utility.set_location(l_proc, 70);
1773   chk_all_assignments(p_previous_employer_id    =>  p_rec.previous_employer_id
1774                      ,p_object_version_number   =>  p_rec.object_version_number
1775                      ,p_all_assignments         =>  p_rec.all_assignments);
1776   --
1777   hr_utility.set_location(l_proc, 75);
1778   per_pem_bus.chk_ddf(p_rec);
1779   --
1780   hr_utility.set_location(l_proc, 80);
1781   per_pem_bus.chk_df(p_rec);
1782   --
1783   hr_utility.set_location(' Leaving:'||l_proc, 85);
1784 End insert_validate;
1785 --
1786 -- ----------------------------------------------------------------------------
1787 -- |---------------------------< update_validate >----------------------------|
1788 -- ----------------------------------------------------------------------------
1789 Procedure update_validate
1790   (p_effective_date               in date
1791   ,p_rec                          in per_pem_shd.g_rec_type
1792   ) is
1793 --
1794   l_proc  varchar2(72) := g_package||'update_validate';
1795 --
1796 Begin
1800   --
1797   hr_utility.set_location('Entering:'||l_proc, 5);
1798   --
1799   -- Call all supporting business operations
1801   hr_utility.set_location(l_proc, 10);
1802   hr_api.mandatory_arg_error
1803   (p_api_name           => l_proc
1804   ,p_argument           => 'EFFECTIVE_DATE'
1805   ,p_argument_value     => p_effective_date
1806   );
1807   --
1808   chk_non_updateable_args
1809     (p_effective_date              => p_effective_date
1810     ,p_rec                         => p_rec
1811     );
1812   --
1813   hr_utility.set_location(l_proc, 15);
1814   if p_rec.party_id is null and p_rec.business_group_id is not null then
1815     hr_api.validate_bus_grp_id
1816     (p_business_group_id  => p_rec.business_group_id
1817     ,p_associated_column1 =>per_pem_shd.g_tab_nam || '.BUSINESS_GROUP_ID'
1818     );  -- Validate Bus Grp
1819   end if;
1820   --
1821   --After validating the set of important attributes,
1822   --if multiple message detection is enabled and atleast
1823   --one error has been found then abort further validation.
1824   --
1825   hr_multi_message.end_validation_set;
1826   --
1827   --validate dependent attributes
1828   --
1829   hr_utility.set_location(l_proc, 18);
1830   chk_business_group_id(p_business_group_id     =>  p_rec.business_group_id
1831                        ,p_previous_employer_id  =>  p_rec.previous_employer_id
1832                        ,p_object_version_number =>  p_rec.object_version_number
1833                        ,p_effective_date        =>  p_effective_date);
1834   --
1835   hr_utility.set_location(l_proc, 20);
1836   chk_employer_country(p_previous_employer_id   =>  p_rec.previous_employer_id
1837                       ,p_object_version_number  =>  p_rec.object_version_number
1838                       ,p_employer_country       =>  p_rec.employer_country);
1839   --
1840   hr_utility.set_location(l_proc, 25);
1841   chk_employer_type(p_previous_employer_id    =>  p_rec.previous_employer_id
1842                    ,p_object_version_number   =>  p_rec.object_version_number
1843                    ,p_employer_type           =>  p_rec.employer_type
1844                    ,p_effective_date          =>  p_effective_date);
1845   --
1846   hr_utility.set_location(l_proc, 30);
1847   chk_employer_subtype(p_previous_employer_id   =>  p_rec.previous_employer_id
1848                       ,p_object_version_number  =>  p_rec.object_version_number
1849                       ,p_employer_type          =>  p_rec.employer_type
1850                       ,p_employer_subtype       =>  p_rec.employer_subtype
1851                       ,p_effective_date         =>  p_effective_date);
1852   --
1853   hr_utility.set_location(l_proc, 40);
1857                      ,p_end_date                =>  p_rec.end_date
1854   chk_start_end_dates(p_previous_employer_id    =>  p_rec.previous_employer_id
1855                      ,p_object_version_number   =>  p_rec.object_version_number
1856                      ,p_start_date              =>  p_rec.start_date
1858 		     ,p_effective_date          =>  p_effective_date -- bug 7112425
1859 		     ,p_business_group_id       =>  p_rec.business_group_id -- Bug 14316052
1860                      ,p_employer_type           =>  p_rec.employer_type);
1861   --
1862   hr_utility.set_location(l_proc, 45);
1863   chk_period_years(p_period_years
1864                    =>  p_rec.period_years
1865                   ,p_previous_employer_id
1866                    =>  p_rec.previous_employer_id
1867                   ,p_object_version_number
1868                    =>  p_rec.object_version_number);
1869   --
1870   hr_utility.set_location(l_proc, 50);
1871   chk_period_months(p_period_months
1872                     =>  p_rec.period_months
1873                    ,p_previous_employer_id
1874                     =>  p_rec.previous_employer_id
1875                    ,p_object_version_number
1876                     =>  p_rec.object_version_number);
1877   --
1878   hr_utility.set_location(l_proc, 55);
1879   chk_period_days(p_period_days
1880                   =>  p_rec.period_days
1881                  ,p_previous_employer_id
1882                   =>  p_rec.previous_employer_id
1883                  ,p_object_version_number
1884                   =>  p_rec.object_version_number);
1885   --
1886   hr_utility.set_location(l_proc, 60);
1887   chk_all_assignments(p_previous_employer_id    =>  p_rec.previous_employer_id
1888                      ,p_object_version_number   =>  p_rec.object_version_number
1889                      ,p_all_assignments         =>  p_rec.all_assignments);
1890   --
1891   hr_utility.set_location(l_proc, 65);
1892   per_pem_bus.chk_ddf(p_rec);
1893   --
1894   hr_utility.set_location(l_proc, 70);
1895   per_pem_bus.chk_df(p_rec);
1896   --
1897   hr_utility.set_location(' Leaving:'||l_proc, 75);
1898 End update_validate;
1899 --
1900 -- ----------------------------------------------------------------------------
1901 -- |---------------------------< delete_validate >----------------------------|
1902 -- ----------------------------------------------------------------------------
1903 Procedure delete_validate
1904   (p_rec                          in per_pem_shd.g_rec_type
1905   ) is
1906 --
1907   l_proc  varchar2(72) := g_package||'delete_validate';
1908 --
1909 Begin
1910   hr_utility.set_location('Entering:'||l_proc, 5);
1911   --
1912   -- Call all supporting business operations
1913   --
1914   hr_utility.set_location(' Leaving:'||l_proc, 10);
1915 End delete_validate;
1916 --
1917 end per_pem_bus;