DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_ORU_BUS

Source


1 Package Body hr_oru_bus as
2 /* $Header: hrorurhi.pkb 120.2 2006/03/08 11:46:02 deenath noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_oru_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_organization_id             number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_organization_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          , hr_all_organization_units oru
30      where oru.organization_id = p_organization_id
31        and pbg.business_group_id = oru.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           => 'organization_id'
47     ,p_argument_value     => p_organization_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_organization_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          , hr_all_organization_units oru
90      where oru.organization_id = p_organization_id
91        and pbg.business_group_id = oru.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           => 'organization_id'
107     ,p_argument_value     => p_organization_id
108     );
109   --
110   if ( nvl(hr_oru_bus.g_organization_id, hr_api.g_number)
111        = p_organization_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 := hr_oru_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     hr_oru_bus.g_organization_id   := p_organization_id;
142     hr_oru_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_df >----------------------------------|
150 -- ----------------------------------------------------------------------------
151 --
152 -- Description:
153 --   Validates all the 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 Descriptive Flexfield structure column and data values are
164 --   all valid this procedure will end normally and processing will
165 --   continue.
166 --
167 -- Post Failure:
168 --   If the 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_df
177   (p_rec in hr_oru_shd.g_rec_type
178   ) is
179 --
180   l_proc   varchar2(72) := g_package || 'chk_df';
181 --
182 begin
183   hr_utility.set_location('Entering:'||l_proc,10);
184   --
185   if ((p_rec.organization_id is not null)  and (
186     nvl(hr_oru_shd.g_old_rec.attribute_category, hr_api.g_varchar2) <>
187     nvl(p_rec.attribute_category, hr_api.g_varchar2)  or
188     nvl(hr_oru_shd.g_old_rec.attribute1, hr_api.g_varchar2) <>
189     nvl(p_rec.attribute1, hr_api.g_varchar2)  or
190     nvl(hr_oru_shd.g_old_rec.attribute2, hr_api.g_varchar2) <>
191     nvl(p_rec.attribute2, hr_api.g_varchar2)  or
192     nvl(hr_oru_shd.g_old_rec.attribute3, hr_api.g_varchar2) <>
193     nvl(p_rec.attribute3, hr_api.g_varchar2)  or
194     nvl(hr_oru_shd.g_old_rec.attribute4, hr_api.g_varchar2) <>
195     nvl(p_rec.attribute4, hr_api.g_varchar2)  or
196     nvl(hr_oru_shd.g_old_rec.attribute5, hr_api.g_varchar2) <>
197     nvl(p_rec.attribute5, hr_api.g_varchar2)  or
198     nvl(hr_oru_shd.g_old_rec.attribute6, hr_api.g_varchar2) <>
199     nvl(p_rec.attribute6, hr_api.g_varchar2)  or
200     nvl(hr_oru_shd.g_old_rec.attribute7, hr_api.g_varchar2) <>
201     nvl(p_rec.attribute7, hr_api.g_varchar2)  or
202     nvl(hr_oru_shd.g_old_rec.attribute8, hr_api.g_varchar2) <>
203     nvl(p_rec.attribute8, hr_api.g_varchar2)  or
204     nvl(hr_oru_shd.g_old_rec.attribute9, hr_api.g_varchar2) <>
205     nvl(p_rec.attribute9, hr_api.g_varchar2)  or
206     nvl(hr_oru_shd.g_old_rec.attribute10, hr_api.g_varchar2) <>
207     nvl(p_rec.attribute10, hr_api.g_varchar2)  or
208     nvl(hr_oru_shd.g_old_rec.attribute11, hr_api.g_varchar2) <>
209     nvl(p_rec.attribute11, hr_api.g_varchar2)  or
210     nvl(hr_oru_shd.g_old_rec.attribute12, hr_api.g_varchar2) <>
211     nvl(p_rec.attribute12, hr_api.g_varchar2)  or
212     nvl(hr_oru_shd.g_old_rec.attribute13, hr_api.g_varchar2) <>
213     nvl(p_rec.attribute13, hr_api.g_varchar2)  or
214     nvl(hr_oru_shd.g_old_rec.attribute14, hr_api.g_varchar2) <>
215     nvl(p_rec.attribute14, hr_api.g_varchar2)  or
216     nvl(hr_oru_shd.g_old_rec.attribute15, hr_api.g_varchar2) <>
217     nvl(p_rec.attribute15, hr_api.g_varchar2)  or
218     nvl(hr_oru_shd.g_old_rec.attribute16, hr_api.g_varchar2) <>
219     nvl(p_rec.attribute16, hr_api.g_varchar2)  or
220     nvl(hr_oru_shd.g_old_rec.attribute17, hr_api.g_varchar2) <>
221     nvl(p_rec.attribute17, hr_api.g_varchar2)  or
222     nvl(hr_oru_shd.g_old_rec.attribute18, hr_api.g_varchar2) <>
223     nvl(p_rec.attribute18, hr_api.g_varchar2)  or
224     nvl(hr_oru_shd.g_old_rec.attribute19, hr_api.g_varchar2) <>
225     nvl(p_rec.attribute19, hr_api.g_varchar2)  or
226     nvl(hr_oru_shd.g_old_rec.attribute20, hr_api.g_varchar2) <>
227     nvl(p_rec.attribute20, hr_api.g_varchar2)  or
228     -- Enhancement 4040086
229     nvl(hr_oru_shd.g_old_rec.attribute21, hr_api.g_varchar2) <>
230     nvl(p_rec.attribute21, hr_api.g_varchar2) or
231     nvl(hr_oru_shd.g_old_rec.attribute22, hr_api.g_varchar2) <>
232     nvl(p_rec.attribute22, hr_api.g_varchar2) or
233     nvl(hr_oru_shd.g_old_rec.attribute23, hr_api.g_varchar2) <>
234     nvl(p_rec.attribute23, hr_api.g_varchar2) or
235     nvl(hr_oru_shd.g_old_rec.attribute24, hr_api.g_varchar2) <>
236     nvl(p_rec.attribute24, hr_api.g_varchar2) or
237     nvl(hr_oru_shd.g_old_rec.attribute25, hr_api.g_varchar2) <>
238     nvl(p_rec.attribute25, hr_api.g_varchar2) or
239     nvl(hr_oru_shd.g_old_rec.attribute26, hr_api.g_varchar2) <>
240     nvl(p_rec.attribute26, hr_api.g_varchar2) or
241     nvl(hr_oru_shd.g_old_rec.attribute27, hr_api.g_varchar2) <>
242     nvl(p_rec.attribute27, hr_api.g_varchar2) or
243     nvl(hr_oru_shd.g_old_rec.attribute28, hr_api.g_varchar2) <>
244     nvl(p_rec.attribute28, hr_api.g_varchar2) or
245     nvl(hr_oru_shd.g_old_rec.attribute29, hr_api.g_varchar2) <>
246     nvl(p_rec.attribute29, hr_api.g_varchar2) or
247     nvl(hr_oru_shd.g_old_rec.attribute30, hr_api.g_varchar2) <>
248     nvl(p_rec.attribute30, hr_api.g_varchar2) ))
249     -- End Enhancement 4040086
250     or (p_rec.organization_id is null)  then
251     --
252     -- Only execute the validation if absolutely necessary:
253     -- a) During update, the structure column value or any
254     --    of the attribute values have actually changed.
255     -- b) During insert.
256     --
257    if nvl(fnd_profile.value('FLEXFIELDS:VALIDATE_ON_SERVER'),'N') = 'Y' then
258     hr_dflex_utility.ins_or_upd_descflex_attribs
259       (p_appl_short_name                 => 'PER'
260       ,p_descflex_name                   => 'PER_ORGANIZATION_UNITS'
261       ,p_attribute_category              => p_rec.attribute_category
262       ,p_attribute1_name                 => 'ATTRIBUTE1'
263       ,p_attribute1_value                => p_rec.attribute1
264       ,p_attribute2_name                 => 'ATTRIBUTE2'
265       ,p_attribute2_value                => p_rec.attribute2
266       ,p_attribute3_name                 => 'ATTRIBUTE3'
267       ,p_attribute3_value                => p_rec.attribute3
268       ,p_attribute4_name                 => 'ATTRIBUTE4'
269       ,p_attribute4_value                => p_rec.attribute4
270       ,p_attribute5_name                 => 'ATTRIBUTE5'
271       ,p_attribute5_value                => p_rec.attribute5
272       ,p_attribute6_name                 => 'ATTRIBUTE6'
273       ,p_attribute6_value                => p_rec.attribute6
274       ,p_attribute7_name                 => 'ATTRIBUTE7'
275       ,p_attribute7_value                => p_rec.attribute7
276       ,p_attribute8_name                 => 'ATTRIBUTE8'
277       ,p_attribute8_value                => p_rec.attribute8
278       ,p_attribute9_name                 => 'ATTRIBUTE9'
279       ,p_attribute9_value                => p_rec.attribute9
280       ,p_attribute10_name                => 'ATTRIBUTE10'
281       ,p_attribute10_value               => p_rec.attribute10
282       ,p_attribute11_name                => 'ATTRIBUTE11'
283       ,p_attribute11_value               => p_rec.attribute11
284       ,p_attribute12_name                => 'ATTRIBUTE12'
285       ,p_attribute12_value               => p_rec.attribute12
286       ,p_attribute13_name                => 'ATTRIBUTE13'
287       ,p_attribute13_value               => p_rec.attribute13
288       ,p_attribute14_name                => 'ATTRIBUTE14'
289       ,p_attribute14_value               => p_rec.attribute14
290       ,p_attribute15_name                => 'ATTRIBUTE15'
291       ,p_attribute15_value               => p_rec.attribute15
292       ,p_attribute16_name                => 'ATTRIBUTE16'
293       ,p_attribute16_value               => p_rec.attribute16
294       ,p_attribute17_name                => 'ATTRIBUTE17'
295       ,p_attribute17_value               => p_rec.attribute17
296       ,p_attribute18_name                => 'ATTRIBUTE18'
297       ,p_attribute18_value               => p_rec.attribute18
298       ,p_attribute19_name                => 'ATTRIBUTE19'
299       ,p_attribute19_value               => p_rec.attribute19
300       ,p_attribute20_name                => 'ATTRIBUTE20'
301       ,p_attribute20_value               => p_rec.attribute20
302       --Enhancement 4040086
303       ,p_attribute21_name                => 'ATTRIBUTE21'
304       ,p_attribute21_value               => p_rec.attribute21
305       ,p_attribute22_name                => 'ATTRIBUTE22'
306       ,p_attribute22_value               => p_rec.attribute22
307       ,p_attribute23_name                => 'ATTRIBUTE23'
308       ,p_attribute23_value               => p_rec.attribute23
309       ,p_attribute24_name                => 'ATTRIBUTE24'
310       ,p_attribute24_value               => p_rec.attribute24
311       ,p_attribute25_name                => 'ATTRIBUTE25'
312       ,p_attribute25_value               => p_rec.attribute25
313       ,p_attribute26_name                => 'ATTRIBUTE26'
314       ,p_attribute26_value               => p_rec.attribute26
315       ,p_attribute27_name                => 'ATTRIBUTE27'
316       ,p_attribute27_value               => p_rec.attribute27
317       ,p_attribute28_name                => 'ATTRIBUTE28'
318       ,p_attribute28_value               => p_rec.attribute28
319       ,p_attribute29_name                => 'ATTRIBUTE29'
320       ,p_attribute29_value               => p_rec.attribute29
321       ,p_attribute30_name                => 'ATTRIBUTE30'
322       ,p_attribute30_value               => p_rec.attribute30
323       --End enhancement 4040086
324       );
325    end if;
326   end if;
327   --
328   hr_utility.set_location(' Leaving:'||l_proc,20);
329 end chk_df;
330 --
331 -- ----------------------------------------------------------------------------
332 -- |-----------------------< chk_non_updateable_args >------------------------|
333 -- ----------------------------------------------------------------------------
334 -- {Start Of Comments}
335 --
336 -- Description:
337 --   This procedure is used to ensure that non updateable attributes have
338 --   not been updated. If an attribute has been updated an error is generated.
339 --
340 -- Pre Conditions:
341 --   g_old_rec has been populated with details of the values currently in
342 --   the database.
343 --
344 -- In Arguments:
345 --   p_rec has been populated with the updated values the user would like the
346 --   record set to.
347 --
348 -- Post Success:
349 --   Processing continues if all the non updateable attributes have not
350 --   changed.
351 --
352 -- Post Failure:
353 --   An application error is raised if any of the non updatable attributes
354 --   have been altered.
355 --
356 -- {End Of Comments}
357 -- ----------------------------------------------------------------------------
358 Procedure chk_non_updateable_args
359   (p_effective_date               in date
360   ,p_rec in hr_oru_shd.g_rec_type
361   ) IS
362 --
363   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
364   l_error    EXCEPTION;
365   l_argument varchar2(30);
366 --
367 Begin
368   --
369   -- Only proceed with the validation if a row exists for the current
370   -- record in the HR Schema.
371   --
372   IF NOT hr_oru_shd.api_updating
373       (p_organization_id                      => p_rec.organization_id
374       ,p_object_version_number                => p_rec.object_version_number
375       ) THEN
376      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
377      fnd_message.set_token('PROCEDURE ', l_proc);
378      fnd_message.set_token('STEP ', '5');
379      fnd_message.raise_error;
380   END IF;
381   --
382   -- EDIT_HERE: Add checks to ensure non-updateable args have
383   --            not been updated.
384   --
385 /* bug fix for 2999489
386   IF nvl(p_rec.name, hr_api.g_varchar2) <>
387      nvl(hr_oru_shd.g_old_rec.name, hr_api.g_varchar2) THEN
388      l_argument := 'NAME';
389      RAISE l_error;
390   END IF;
391   --
392   EXCEPTION
393     WHEN l_error THEN
394        hr_api.argument_changed_error
395          (p_api_name => l_proc
396          ,p_argument => l_argument);
397     WHEN OTHERS THEN
398        RAISE;
399 */
400 End chk_non_updateable_args;
401 --
402 --
403 --         THIS PROCEDURE HAS BEEN COMMENTED OUT DUE TO BUG 2074718
404 -- ----------------------------------------------------------------------------
405 -- |--------------------------< chk_date_from >-------------------------------|
406 -- ----------------------------------------------------------------------------
407 --
408 --  Description:
409 --    Validates that date_from of organization unit is greater than or equal
410 --    to date_from of the business group
411 --
412 --  Pre-conditions:
413 --    None.
414 --
415 --  In Arguments:
416 --    p_date_from
417 --    p_effective_date
418 --    p_business_group_id
419 --
420 --  Post Success:
421 --    If date_from of organization unit is greater than or equal to date_from
422 --    of the relevant business group then normal processing continues
423 --
424 --  Post Failure:
425 --    If the date_from of the organization unit is less than the date_from of
426 --    the relevant business group then an application
427 --    error will be raised and processing is terminated.
428 --
429 --  Developer/Implementation Notes:
430 --    Duplicate validation exists on form, so any changes made here
431 --    or on form must be dual-maintained
432 --
433 --  Access Status:
434 --    Internal Row Handler Use Only
435 --
436 -- {End Of Comments}
437 --
438 --PROCEDURE chk_date_from
439 --  (p_date_from              IN     hr_all_organization_units.date_from%TYPE,
440 --   p_effective_date         IN     DATE,
441 --   p_business_group_id      IN     hr_all_organization_units.business_group_id%TYPE)
442 --IS
443 --
444 --   l_proc  VARCHAR2(72) := g_package||'chk_date_from';
445 --
446 --   l_bgr_date_from DATE;
447 --
448 --   CURSOR csr_bgr_date_from IS
449 --   SELECT date_from
450 --   FROM hr_all_organization_units
451 --   WHERE organization_id = p_business_group_id
452 --     AND business_group_id = p_business_group_id;
453 --
454 --BEGIN
455 --   hr_utility.set_location('Entering:'|| l_proc, 10);
456 --
457 --   hr_api.mandatory_arg_error
458 --    (p_api_name           => l_proc
459 --    ,p_argument           => 'DATE_FROM'
460 --    ,p_argument_value     => p_date_from
461 --    );
462 --
463    --
464    -- Get date_from for the business group
465    --
466 --   OPEN csr_bgr_date_from;
467 --   FETCH csr_bgr_date_from INTO l_bgr_date_from;
468 --   IF csr_bgr_date_from%notfound THEN
469 --     CLOSE csr_bgr_date_from;
470 --     hr_utility.set_message(800, 'HR_51491_ESA_BUS_GRP_ID_FK2');
471 --     hr_utility.raise_error;
472 --   END IF;
473 --   CLOSE csr_bgr_date_from;
474    --
475    --  If found, date_from must be greater or equal to business group
476    --  date_from.
477    --
478 --   IF p_date_from < l_bgr_date_from THEN
479 --      hr_utility.set_message(800, 'HR_52757_INV_DATE_FROM');
480 --      hr_utility.raise_error;
481 --   END IF;
482    --
483 --   hr_utility.set_location('Leaving:'||l_proc, 30);
484 --
485 --END chk_date_from;
486 --
487 -- ----------------------------------------------------------------------------
488 -- |-------------------------< chk_name >-------------------------------------|
489 -- ----------------------------------------------------------------------------
490 --
491 --  Procedure description is in the header.
492 --
493 --  Access Status:
494 --    Internal Development Use Only.
495 --
496 -- {End Of Comments}
497 --
498 PROCEDURE chk_name
499   ( p_name                    IN     hr_all_organization_units.name%TYPE,
500     p_effective_date          IN     DATE default NULL,
501     p_business_group_id       IN     number,
502     p_organization_id         IN     number default null,
503 p_duplicate_org_warning OUT NOCOPY  BOOLEAN
504   )
505 IS
506    l_proc           VARCHAR2(72)  :=  g_package||'chk_name';
507    l_exists         number;
508     -- cursor returns organization id, business id, and boolean (BG) if the org is a BG
509    l_is_business_group    boolean;
510    l_duplicate_bg         boolean;
511    l_bg                   number;
512    CURSOR C1 is
513       select o.organization_id, o.business_group_id
514       from  hr_all_organization_units o
515       where (o.name = p_name OR o.organization_id = p_organization_id);
516 
517 BEGIN
518 --
519    hr_utility.set_location('Entering:'|| l_proc, 10);
520 --
521 p_duplicate_org_warning := false;
522 l_is_business_group     := false;
523 l_duplicate_bg          := false;
524 --
525   hr_api.mandatory_arg_error
526     (p_api_name           => l_proc
527     ,p_argument           => 'NAME'
528     ,p_argument_value     => p_name
529     );
530 --
531 --
532 hr_utility.set_location(l_proc, 20);
533 --
534 --
535 -- Check organization name uniqueness throughout business groups if
536 -- Cross business profile option is set to Y
537 -- This will also check for duplicate business groups
538 --
539 
540 for Crec in C1 loop
541 
542  select count(*)
543  into l_bg
544  from hr_organization_information i
545  where i.organization_id = crec.organization_id
546  and i.org_information1='HR_BG'
547  and i.org_information_context='CLASS'
548  and i.org_information2 ='Y';
549 if Crec.organization_id = nvl(p_organization_id,'-1') then
550   if L_BG = 1 then
551     l_is_business_group := true;-- if we are updating and the current row is
552                                 -- a BG, then l_is_business_group
553                                 -- is set to true
554   end if;
555 else
556   if L_BG = 1 then          -- if the row returned is a BG but not the
557                             -- current row set both flags true
558     l_duplicate_bg := TRUE;
559     p_duplicate_org_warning := TRUE;
560   elsif                          -- if it is not the current row, but XBG option is yes then set warning
561    fnd_profile.value('HR_CROSS_BUSINESS_GROUP') = 'Y' then
562     p_duplicate_org_warning :=TRUE;
563   end if;
564 
565   if (crec.business_group_id = p_business_group_id) then -- if not current row but in same business group
566     hr_utility.set_message(800, 'HR_52751_DUPL_NAME');   -- raise error
567     hr_utility.raise_error;
568   end if;
569 
570 end if;
571 end loop;
572 
573   if l_is_business_group and l_duplicate_bg then           -- using flags set above, if current row is a BG
574      hr_utility.set_message(800, 'HR_289381_DUPLICATE_BG');-- and a different bg with the same name exists
575      hr_utility.raise_error;                               -- raise the duplicate BG error
576   end if;
577 --
578 --
579 hr_utility.set_location('Leaving:'||l_proc, 30);
580 --
581 END chk_name;
582 --
583 -- ----------------------------------------------------------------------------
584 -- |-------------------------< chk_soft_coding_kf >---------------------------|
585 -- ----------------------------------------------------------------------------
586 --
587 --  Description:
588 --    Validates that soft_coding_keyflex_id of organization unit is present in
589 --    HR_SOFT_CODING_KEYFLEX table when not null.
590 --
591 --  Pre-conditions:
592 --    None.
593 --
594 --  In Arguments:
595 --    p_soft_coding_keyflex_id
596 --
597 --  Post Success:
598 --    If the soft_coding_keyflex_id attribute is present then
599 --    normal processing continues
600 --
601 --  Post Failure:
602 --    If the soft_coding_keyflex_id attribute is not present then an application
603 --    error will be raised and processing is terminated.
604 --
605 --  Developer/Implementation Notes:
606 --    Duplicate validation exists on form, so any changes made here
607 --    or on form must be dual-maintained.
608 --
609 --  Access Status:
610 --    Internal Row Table Handler Use Only.
611 --
612 -- {End Of Comments}
613 --
614 PROCEDURE chk_soft_coding_kf
615   ( p_soft_coding_keyflex_id IN hr_all_organization_units.soft_coding_keyflex_id%TYPE)
616 IS
617    l_proc           VARCHAR2(72)  :=  g_package||'chk_soft_coding_kf';
618    l_exists         VARCHAR2(1) := 'N';
619 --
620    cursor csr_soft_coding_keyflex_id IS
621      SELECT 'Y'
622         FROM hr_soft_coding_keyflex
623         WHERE soft_coding_keyflex_id = p_soft_coding_keyflex_id;
624 --
625 BEGIN
626 --
627    hr_utility.set_location('Entering:'|| l_proc, 10);
628 --
629 --
630 -- Check soft_coding_keyflex_id uniqueness
631 --
632   IF p_soft_coding_keyflex_id IS NOT null THEN
633    OPEN csr_soft_coding_keyflex_id;
634    FETCH csr_soft_coding_keyflex_id INTO l_exists;
635 --
636    hr_utility.set_location(l_proc, 20);
637 --
638    IF csr_soft_coding_keyflex_id%notfound THEN
639      CLOSE csr_soft_coding_keyflex_id;
640      hr_utility.set_message(800, 'HR_52754_INV_SCL_ID');
641      hr_utility.raise_error;
642    ELSE
643      CLOSE csr_soft_coding_keyflex_id;
644    END IF;
645   END IF;
646 --
647 --
648   hr_utility.set_location('Leaving:'||l_proc, 30);
649 --
650 END chk_soft_coding_kf;
651 --
652 -- ----------------------------------------------------------------------------
653 -- |-------------------------< chk_cost_alloc_kf >----------------------------|
654 -- ----------------------------------------------------------------------------
655 --
656 --  Description:
657 --    Validates that cost_allocation_keyflex_id of organization unit is present in
658 --    PAY_COST_ALLOCATION_KEYFLEX table when not null.
659 --
660 --  Pre-conditions:
661 --    None.
662 --
663 --  In Arguments:
664 --    p_organization_id
665 --    p_cost_allocation_keyflex_id
666 --
667 --  Post Success:
668 --    If the cost_allocation_keyflex_id attribute is present then
669 --    normal processing continues
670 --
671 --  Post Failure:
672 --    If the cost_allocation_keyflex_id attribute is not present then an application
673 --    error will be raised and processing is terminated.
674 --
675 --  Developer/Implementation Notes:
676 --    Duplicate validation exists on form, so any changes made here
677 --    or on form must be dual-maintained.
678 --
679 --  Access Status:
680 --    Internal Row Table Handler Use Only.
681 --
682 -- {End Of Comments}
683 --
684 PROCEDURE chk_cost_alloc_kf
685   (p_organization_id            IN NUMBER,
686    p_business_group_id          IN NUMBER,
687    p_cost_allocation_keyflex_id IN hr_all_organization_units.cost_allocation_keyflex_id%TYPE)
688 IS
689 --
690 l_count                         NUMBER;
691 l_proc                          VARCHAR2(72)  :=  g_package||'chk_cost_alloc_kf';
692 l_exists                        VARCHAR2(1) := 'N';
693 --
694 CURSOR csr_cost_allocation_keyflex_id IS
695        SELECT 'Y'
696          FROM pay_cost_allocation_keyflex pcak,
697               per_business_groups_perf pbg
698         WHERE pcak.cost_allocation_keyflex_id = p_cost_allocation_keyflex_id
699           AND pbg.business_group_id = p_business_group_id
700           AND pbg.cost_allocation_structure = to_char(pcak.id_flex_num);
701 --
702 BEGIN
703 --
704 hr_utility.set_location('Entering:'|| l_proc, 10);
705 --
706 -- Check cost_allocation_keyflex_id uniqueness
707 --
708 IF p_cost_allocation_keyflex_id IS NOT NULL THEN
709    --
710    -- The following validation needs to be performed only for the INSERT
711    -- operation or the value has actually changed during an UPDATE operation
712    --
713    IF p_organization_id IS NULL OR
714       p_cost_allocation_keyflex_id <>
715       NVL(hr_oru_shd.g_old_rec.cost_allocation_keyflex_id, hr_api.g_number) THEN
716       --
717       OPEN csr_cost_allocation_keyflex_id;
718       FETCH csr_cost_allocation_keyflex_id INTO l_exists;
719       --
720       hr_utility.set_location(l_proc, 20);
721       --
722       IF csr_cost_allocation_keyflex_id%notfound THEN
723          --
724          CLOSE csr_cost_allocation_keyflex_id;
725          hr_utility.set_location(l_proc, 21);
726          hr_utility.set_message(800, 'HR_52755_INV_COST_ID');
727          hr_utility.raise_error;
728          --
729       ELSE
730          --
731          CLOSE csr_cost_allocation_keyflex_id;
732          --
733       END IF;
734       --
735    END IF;
736    --
737    -- Following validation should be performed only during UPDATE
738    -- operation
739    --
740    IF p_organization_id IS NOT NULL THEN
741       --
742       SELECT COUNT(*)
743              INTO l_count
744              FROM hr_organization_information
745             WHERE organization_id = p_organization_id
746               AND org_information_context = 'CLASS'
747               AND org_information1 = 'HR_ORG'
748               AND org_information2 = 'Y';
749       --
750       IF l_count = 0 THEN
751          --
752          hr_utility.set_location(l_proc, 22);
753          hr_utility.set_message(800, 'HR_289484_INV_ORG_COST_ID');
754          hr_utility.raise_error;
755          --
756       END IF;
757       --
758    END IF;
759    --
760 END IF;
761 --
762 --
763   hr_utility.set_location('Leaving:'||l_proc, 30);
764 --
765 END chk_cost_alloc_kf;
766 --
767 -- ----------------------------------------------------------------------------
768 -- |-------------------------< chk_location_id >------------------------------|
769 -- ----------------------------------------------------------------------------
770 --
771 --  Description:
772 --    Validates that location_id of organization unit is present in
773 --    HR_LOCATIONS_ALL table and valid when not null.
774 --
775 --  Pre-conditions:
776 --    None.
777 --
778 --  In Arguments:
779 --    p_location_id
780 --
781 --  Post Success:
782 --    If the location_id attribute is present and valid then
783 --    normal processing continues
784 --
785 --  Post Failure:
786 --    If the location_id attribute is present and invalid then an application
787 --    error will be raised and processing is terminated.
788 --
789 --  Developer/Implementation Notes:
790 --    Duplicate validation exists on form, so any changes made here
791 --    or on form must be dual-maintained.
792 --
793 --  Access Status:
794 --    Internal Row Table Handler Use Only.
795 --
796 -- {End Of Comments}
797 --
798 PROCEDURE chk_location_id
799   ( p_location_id  IN hr_all_organization_units.location_id%TYPE)
800 IS
801    l_proc           VARCHAR2(72)  :=  g_package||'chk_location_id';
802    l_exists         VARCHAR2(1) := 'N';
803 --
804    cursor csr_location_id IS
805      SELECT 'Y'
806         FROM hr_locations_all
807         WHERE location_id = p_location_id;
808 --
809 BEGIN
810 --
811    hr_utility.set_location('Entering:'|| l_proc, 10);
812 --
813 --
814 -- Check location_id uniqueness
815 --
816   IF p_location_id IS NOT null THEN
817    OPEN csr_location_id;
818    FETCH csr_location_id INTO l_exists;
819 --
820    hr_utility.set_location(l_proc, 20);
821 --
822    IF csr_location_id%notfound THEN
823      CLOSE csr_location_id;
824      hr_utility.set_message(800, 'HR_52756_INV_LOC_ID');
825      hr_utility.raise_error;
826    ELSE
827      CLOSE csr_location_id;
828    END IF;
829   END IF;
830 --
831 --
832   hr_utility.set_location('Leaving:'||l_proc, 30);
833 --
834 END chk_location_id;
835 --
836 -- ----------------------------------------------------------------------------
837 -- |-------------------------< chk_type >-------------------------------------|
838 -- ----------------------------------------------------------------------------
839 --
840 --  Description:
841 --    Validates that type of organization unit is present in
842 --    HR_LOKUPS table and valid when not null.
843 --
844 --  Pre-conditions:
845 --    None.
846 --
847 --  In Arguments:
848 --    p_type
849 --    p_effective_date
850 --
851 --  Post Success:
852 --    If the type attribute is present and valid then
853 --    normal processing continues
854 --
855 --  Post Failure:
856 --    If the type attribute is present and invalid then an application
857 --    error will be raised and processing is terminated.
858 --
859 --  Developer/Implementation Notes:
860 --    Duplicate validation exists on form, so any changes made here
861 --    or on form must be dual-maintained.
862 --
863 --  Access Status:
864 --    Internal Row Table Handler Use Only.
865 --
866 -- {End Of Comments}
867 --
868 PROCEDURE chk_type
869   ( p_type  IN hr_all_organization_units.type%TYPE,
870     p_effective_date          IN     DATE)
871 IS
872    l_proc           VARCHAR2(72)  :=  g_package||'chk_type';
873    l_exists         VARCHAR2(1) := 'N';
874 --
875    cursor csr_type IS
876      SELECT 'Y'
877         FROM hr_lookups
878         WHERE lookup_type = 'ORG_TYPE'
879           AND lookup_code = p_type
880           AND enabled_flag = 'Y'
881           AND p_effective_date BETWEEN nvl(start_date_active,p_effective_date)
882           AND nvl(end_date_active,p_effective_date);
883 --
884 BEGIN
885 --
886    hr_utility.set_location('Entering:'|| l_proc, 10);
887 --
888 --
889 -- Check location_id uniqueness
890 --
891   IF p_type IS NOT null THEN
892    OPEN csr_type;
893    FETCH csr_type INTO l_exists;
894 --
895    hr_utility.set_location(l_proc, 20);
896 --
897    IF csr_type%notfound THEN
898      CLOSE csr_type;
899      hr_utility.set_message(800, 'HR_52752_INV_ORG_TYPE');
900      hr_utility.raise_error;
901    ELSE
902      CLOSE csr_type;
903    END IF;
904   END IF;
905 --
906 --
907   hr_utility.set_location('Leaving:'||l_proc, 30);
908 --
909 END chk_type;
910 --
911 --
912 -- ----------------------------------------------------------------------------
913 -- |-------------------------< chk_int_ext_flag >-----------------------------|
914 -- ----------------------------------------------------------------------------
915 --
916 --  Description:
917 --    Validates that internal_external_flag of organization unit is present in
918 --    HR_LOKUPS table and valid when not null.
919 --
920 --  Pre-conditions:
921 --    None.
922 --
923 --  In Arguments:
924 --    p_internal_external_flag
925 --    p_effective_date
926 --
927 --  Post Success:
928 --    If the internal_external_flag attribute is present and valid then
929 --    normal processing continues
930 --
931 --  Post Failure:
932 --    If the internal_external_flag attribute is present and invalid then an application
933 --    error will be raised and processing is terminated.
934 --
935 --  Developer/Implementation Notes:
936 --    Duplicate validation exists on form, so any changes made here
937 --    or on form must be dual-maintained.
938 --
939 --  Access Status:
940 --    Internal Row Table Handler Use Only.
941 --
942 -- {End Of Comments}
943 --
944 PROCEDURE chk_int_ext_flag
945   ( p_internal_external_flag  IN hr_all_organization_units.internal_external_flag%TYPE,
946     p_effective_date          IN     DATE)
947 IS
948    l_proc           VARCHAR2(72)  :=  g_package||'chk_int_ext_flag';
949    l_exists         VARCHAR2(1) := 'N';
950 --
951    cursor csr_internal_external_flag IS
952      SELECT 'Y'
953         FROM hr_lookups
954         WHERE lookup_type = 'INTL_EXTL'
955           AND lookup_code = p_internal_external_flag
956           AND enabled_flag = 'Y'
957           AND p_effective_date BETWEEN nvl(start_date_active,p_effective_date)
958           AND nvl(end_date_active,p_effective_date);
959 --
960 BEGIN
961 --
962    hr_utility.set_location('Entering:'|| l_proc, 10);
963 --
964 --
965 -- Bug 4319315
966   if (hr_oru_shd.g_old_rec.internal_external_flag is not null
967      and
968  (nvl(p_internal_external_flag,hr_oru_shd.g_old_rec.internal_external_flag)
969 	       <>hr_oru_shd.g_old_rec.internal_external_flag)) then
970      fnd_message.set_name('PER','PER_449606_INVALID_UPD_ORG');
971      fnd_message.raise_error;
972 
973  end if;
974 
975 -- End of Bug 4319315
976 -- Check location_id uniqueness
977 --
978   IF p_internal_external_flag IS NOT null THEN
979    OPEN csr_internal_external_flag;
980    FETCH csr_internal_external_flag INTO l_exists;
981 --
982    hr_utility.set_location(l_proc, 20);
983 --
984    IF csr_internal_external_flag%notfound THEN
985      CLOSE csr_internal_external_flag;
986      hr_utility.set_message(800, 'HR_52753_INV_ORG_INT_EXT_FLAG');
987      hr_utility.raise_error;
988    ELSE
989      CLOSE csr_internal_external_flag;
990    END IF;
991   END IF;
992 --
993 --
994   hr_utility.set_location('Leaving:'||l_proc, 30);
995 --
996 END chk_int_ext_flag;
997 --
998 --
999 -- ----------------------------------------------------------------------------
1000 -- |-------------------------< chk_cls_exists >-------------------------------|
1001 -- ----------------------------------------------------------------------------
1002 --
1003 --  Description:
1004 --    Validates that organization unit has at least one classification
1005 --
1006 --  Pre-conditions:
1007 --    None.
1008 --
1009 --  In Arguments:
1010 --    p_organization_id
1011 --
1012 --  Post Success:
1013 --    If classification is not present then
1014 --    normal processing continues
1015 --
1016 --  Post Failure:
1017 --    If classification is already present then an application
1018 --    error will be raised and processing is terminated.
1019 --
1020 --  Developer/Implementation Notes:
1021 --    Duplicate validation exists on form, so any changes made here
1022 --    or on form must be dual-maintained.
1023 --
1024 --  Access Status:
1025 --    Internal Row Table Handler Use Only.
1026 --
1027 -- {End Of Comments}
1028 --
1029 PROCEDURE chk_org_delete
1030   ( p_organization_id  IN hr_all_organization_units.organization_id%TYPE)
1031 IS
1032    l_proc           VARCHAR2(72)  :=  g_package||'chk_cls_exists';
1033    l_exists         VARCHAR2(1) := 'N';
1034 --
1035 BEGIN
1036 --
1037    hr_utility.set_location('Entering:'|| l_proc, 10);
1038 --
1039 --
1040 -- Check classification presence
1041 --
1042 -- Added 'AND org_infformation2 = 'Y' for WWBUG 2293725
1043 --
1044   BEGIN
1045    SELECT 'Y'
1046    INTO l_exists
1047    FROM sys.dual
1048    WHERE EXISTS
1049      (SELECT null
1050       FROM hr_organization_information
1051       WHERE organization_id = p_organization_id
1052         AND org_information_context = 'CLASS'
1053         AND org_information2 = 'Y'
1054     );
1055    EXCEPTION
1056    WHEN NO_DATA_FOUND THEN null;
1057   END;
1058 --
1059    hr_utility.set_location(l_proc, 20);
1060 --
1061    IF l_exists = 'Y' THEN
1062      hr_utility.set_message(800, 'HR_52758_ORG_HAS_CLSF');
1063      hr_utility.raise_error;
1064    END IF;
1065 --
1066 --
1067   hr_utility.set_location('Leaving:'||l_proc, 30);
1068 --
1069 END chk_org_delete;
1070 --
1071 -- ----------------------------------------------------------------------------
1072 -- |---------------------------< insert_validate >----------------------------|
1073 -- ----------------------------------------------------------------------------
1074 Procedure insert_validate
1075   (p_effective_date               in date
1076   ,p_rec                          in hr_oru_shd.g_rec_type
1077   ,p_duplicate_org_warning        out nocopy boolean
1078   ) is
1079 --
1080   l_proc  varchar2(72) := g_package||'insert_validate';
1081 --
1082 Begin
1083   hr_utility.set_location('Entering:'||l_proc, 5);
1084   --
1085   -- Call all supporting business operations
1086   --
1087   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
1088   --
1089   --
1090   hr_utility.set_location('Entering:'||l_proc, 10);
1091   --
1092   --
1093   -- Validate name
1094   -- =================
1095   --
1096   chk_name
1097     (p_name                     =>    p_rec.name,
1098      p_effective_date           =>    p_effective_date,
1099      p_business_group_id        =>    p_rec.business_group_id,
1100      p_duplicate_org_warning    =>    p_duplicate_org_warning
1101      );
1102   --
1103   hr_utility.set_location(l_proc, 20);
1104   --
1105   -- Validate date_from
1106   -- ======================
1107 --  chk_date_from
1108 --    (p_date_from                  =>    p_rec.date_from,
1109 --     p_effective_date             =>    p_effective_date,
1110 --     p_business_group_id          =>    p_rec.business_group_id
1111 --    );
1112   --
1113   --
1114   hr_utility.set_location(l_proc, 30);
1115   --
1116   -- Validate soft_coding_keyflex_id
1117   -- =======================
1118   chk_soft_coding_kf
1119     (p_soft_coding_keyflex_id     =>    p_rec.soft_coding_keyflex_id);
1120   --
1121   hr_utility.set_location(l_proc, 40);
1122   -- Validate cost_allocation_keyflex_id
1123   -- =======================
1124   chk_cost_alloc_kf
1125     (p_organization_id            =>    p_rec.organization_id,
1126      p_business_group_id          =>    p_rec.business_group_id,
1127      p_cost_allocation_keyflex_id =>    p_rec.cost_allocation_keyflex_id);
1128   --
1129   hr_utility.set_location(l_proc, 50);
1130   -- Validate location_id
1131   -- =======================
1132   chk_location_id
1133     (p_location_id                =>    p_rec.location_id);
1134   --
1135   hr_utility.set_location(l_proc, 60);
1136   --
1137   -- Validate type
1138   -- ======================
1139   chk_type
1140     (p_type                       =>    p_rec.type,
1141      p_effective_date             =>    p_effective_date);
1142   --
1143   hr_utility.set_location(l_proc, 70);
1144   --
1145   -- Validate type
1146   -- ======================
1147   chk_int_ext_flag
1148     (p_internal_external_flag     =>    p_rec.internal_external_flag,
1149      p_effective_date             =>    p_effective_date);
1150   --
1151   hr_utility.set_location(l_proc, 80);
1152   --
1153   --
1154   hr_oru_bus.chk_df(p_rec);
1155   --
1156   hr_utility.set_location(' Leaving:'||l_proc, 40);
1157 End insert_validate;
1158 --
1159 -- ----------------------------------------------------------------------------
1160 -- |---------------------------< update_validate >----------------------------|
1161 -- ----------------------------------------------------------------------------
1162 Procedure update_validate
1163   (p_effective_date               in date
1164   ,p_rec                          in hr_oru_shd.g_rec_type
1165   ,p_duplicate_org_warning        out nocopy boolean
1166   ) is
1167 --
1168   l_proc  varchar2(72) := g_package||'update_validate';
1169 --
1170 Begin
1171   hr_utility.set_location('Entering:'||l_proc, 5);
1172   --
1173   -- Call all supporting business operations
1174   --
1175   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
1176   --
1177   chk_non_updateable_args
1178     (p_effective_date              => p_effective_date
1179       ,p_rec              => p_rec
1180     );
1181   --
1182   --
1183   hr_utility.set_location(l_proc, 20);
1184   --
1185   -- Validate date_from
1186   -- ======================
1187 --  chk_date_from
1188 --    (p_date_from                  =>    p_rec.date_from,
1189 --     p_effective_date             =>    p_effective_date,
1190 --     p_business_group_id          =>    p_rec.business_group_id
1191 --    );
1192   --
1193   --
1194   hr_utility.set_location(l_proc, 30);
1195   --
1196   -- Validate soft_coding_keyflex_id
1197   -- =======================
1198   chk_soft_coding_kf
1199     (p_soft_coding_keyflex_id     =>    p_rec.soft_coding_keyflex_id);
1200   --
1201   hr_utility.set_location(l_proc, 40);
1202   -- Validate cost_allocation_keyflex_id
1203   -- =======================
1204   chk_cost_alloc_kf
1205     (p_organization_id            =>    p_rec.organization_id,
1206      p_business_group_id          =>    p_rec.business_group_id,
1207      p_cost_allocation_keyflex_id =>    p_rec.cost_allocation_keyflex_id);
1208   --
1209   hr_utility.set_location(l_proc, 50);
1210   -- Validate location_id
1211   -- =======================
1212   chk_location_id
1213     (p_location_id                =>    p_rec.location_id);
1214   --
1215   chk_name
1216         (p_name                   =>    p_rec.name
1217          ,p_effective_date        =>    p_effective_date
1218          ,p_business_group_id     =>    p_rec.business_group_id
1219          ,p_organization_id       =>    p_rec.organization_id
1220          ,p_duplicate_org_warning =>    p_duplicate_org_warning );
1221   hr_utility.set_location(l_proc, 60);
1222   --
1223   -- Validate type
1224   -- ======================
1225   chk_type
1226     (p_type                       =>    p_rec.type,
1227      p_effective_date             =>    p_effective_date);
1228   --
1229   hr_utility.set_location(l_proc, 70);
1230   --
1231   -- Validate type
1232   -- ======================
1233   chk_int_ext_flag
1234     (p_internal_external_flag     =>    p_rec.internal_external_flag,
1235      p_effective_date             =>    p_effective_date);
1236   --
1237   hr_utility.set_location(l_proc, 80);
1238   --
1239   --
1240   hr_oru_bus.chk_df(p_rec);
1241   --
1242   hr_utility.set_location(' Leaving:'||l_proc, 100);
1243 End update_validate;
1244 --
1245 -- ----------------------------------------------------------------------------
1246 -- |---------------------------< delete_validate >----------------------------|
1247 -- ----------------------------------------------------------------------------
1248 Procedure delete_validate
1249   (p_rec                          in hr_oru_shd.g_rec_type
1250   ) is
1251 --
1252   l_proc  varchar2(72) := g_package||'delete_validate';
1253   -- Start of fix for bug 2881808
1254   l_bg_id    hr_all_organization_units.business_group_id%Type;
1255   l_installed boolean;
1256   l_pa_installed varchar2(1);
1257   l_inv_installed varchar2(1);
1258   l_eng_installed varchar2(1);
1259   l_ota_installed varchar2(1);
1260   l_industry  varchar2(1);
1261   -- End of fix for bug 2881808
1262 --
1263 Begin
1264   hr_utility.set_location('Entering:'||l_proc, 5);
1265   --
1266   -- Get the Business Group id.
1267   --
1268   select business_group_id
1269   into l_bg_id
1270   from  hr_all_organization_units
1271   where organization_id = p_rec.organization_id;
1272   --
1273   hr_utility.set_location(l_proc, 10);
1274   --
1275   -- Call all supporting business operations
1276   --
1277   -- Validate classification exists
1278   -- =======================
1279   chk_org_delete
1280     (p_organization_id     =>    p_rec.organization_id);
1281   --
1282   hr_utility.set_location(l_proc, 15);
1283   --
1284   -- Start of fix for bug 2881808
1285   --
1286   -- Validate  Job and Position exists
1287   -- =================================
1288     hr_job_pos.hr_jp_predelete(p_rec.organization_id,
1289                                l_bg_id);
1290   hr_utility.set_location(l_proc, 20);
1291   --
1292   -- Validate Person, Org and Hierarchies exists
1293   -- ===========================================
1294     hr_organization.org_predel_check(p_rec.organization_id,
1295                                      l_bg_id);
1296   hr_utility.set_location(l_proc, 25);
1297   --
1298   -- Product specific validations
1299   -- ============================
1300 
1301   --          Project Accounting PA
1302             l_installed := fnd_installation.get(appl_id => 275
1303                                                ,dep_appl_id => 275
1304                                                ,status => l_pa_installed
1305                                                ,industry => l_industry);
1306             if l_pa_installed <> 'N' then
1307                  pa_org.pa_predel_validation(p_rec.organization_id);
1308                  null;
1309             end if;
1310             pa_org.pa_org_predel_validation(p_rec.organization_id);
1311             hr_utility.set_location(l_proc, 30);
1312        --
1313 --          Inventory INV
1314             l_installed := fnd_installation.get(appl_id => 401
1315                                                ,dep_appl_id => 401
1316                                                ,status => l_inv_installed
1317                                                ,industry => l_industry);
1318             if l_inv_installed <> 'N' then
1319                   inv_org.inv_predel_validation(p_rec.organization_id);
1320             end if;
1321             hr_utility.set_location(l_proc, 35);
1322        --
1323   --      Training OTA
1324             if p_rec.organization_id is not null then
1325               per_ota_predel_validation.ota_predel_org_validation(p_rec.organization_id);
1326             else null;
1327             end if;
1328        hr_utility.set_location(l_proc, 40);
1329        --
1330 --          Engineering Eng
1331             l_installed := fnd_installation.get(appl_id => 703
1332                                                ,dep_appl_id => 703
1333                                                ,status => l_eng_installed
1334                                                ,industry => l_industry);
1335             if l_eng_installed <> 'N' then
1336                null;
1337                eng_org.eng_predel_validation(p_rec.organization_id);
1338             end if;
1339   --  End of fix for bug 2881808
1340   hr_utility.set_location(' Leaving:'||l_proc, 10);
1341 End delete_validate;
1342 --
1343 end hr_oru_bus;