DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PMS_BUS

Source


1 Package Body per_pms_bus as
2 /* $Header: pepmsrhi.pkb 120.2.12010000.2 2008/09/02 10:51:07 arumukhe ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_pms_bus.';  -- Global package name
9 g_debug    boolean      := hr_utility.debug_enabled;
10 --
11 -- The following two global variables are only to be
12 -- used by the return_legislation_code function.
13 --
14 g_legislation_code            varchar2(150)  default null;
15 g_scorecard_id                number         default null;
16 --
17 --  ---------------------------------------------------------------------------
18 --  |----------------------< set_security_group_id >--------------------------|
19 --  ---------------------------------------------------------------------------
20 --
21 Procedure set_security_group_id
22   (p_scorecard_id                         in number
23   ,p_associated_column1                   in varchar2 default null
24   ) is
25   --
26   -- Declare cursor
27   --
28   cursor csr_sec_grp is
29     select pbg.security_group_id,
30            pbg.legislation_code
31       from per_business_groups_perf pbg
32          , per_all_assignments_f paf
33          , per_personal_scorecards pms
34      where pms.scorecard_id = p_scorecard_id
35      and pms.assignment_id = paf.assignment_id
36      and paf.business_group_id = pbg.business_group_id;
37 
38   --
39   -- Declare local variables
40   --
41   l_security_group_id number;
42   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
43   l_legislation_code  varchar2(150);
44   --
45 begin
46   --
47   hr_utility.set_location('Entering:'|| l_proc, 10);
48   --
49   -- Ensure that all the mandatory parameter are not null
50   --
51   hr_api.mandatory_arg_error
52     (p_api_name           => l_proc
53     ,p_argument           => 'scorecard_id'
54     ,p_argument_value     => p_scorecard_id
55     );
56   --
57   open csr_sec_grp;
58   fetch csr_sec_grp into l_security_group_id
59                        , l_legislation_code;
60   --
61   if csr_sec_grp%notfound then
62      --
63      close csr_sec_grp;
64      --
65      -- The primary key is invalid therefore we must error
66      --
67      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
68      hr_multi_message.add
69        (p_associated_column1
70         => nvl(p_associated_column1,'SCORECARD_ID')
71        );
72      --
73   else
74     close csr_sec_grp;
75     --
76     -- Set the security_group_id in CLIENT_INFO
77     --
78     hr_api.set_security_group_id
79       (p_security_group_id => l_security_group_id
80       );
81     --
82     -- Set the sessions legislation context in HR_SESSION_DATA
83     --
84     hr_api.set_legislation_context(l_legislation_code);
85   end if;
86   --
87   hr_utility.set_location(' Leaving:'|| l_proc, 20);
88   --
89 end set_security_group_id;
90 --
91 --  ---------------------------------------------------------------------------
92 --  |---------------------< return_legislation_code >-------------------------|
93 --  ---------------------------------------------------------------------------
94 --
95 Function return_legislation_code
96   (p_scorecard_id                         in     number
97   )
98   Return Varchar2 Is
99   --
100   -- Declare cursor
101   --
102   cursor csr_leg_code is
103     select pbg.legislation_code
104       from per_business_groups_perf pbg
105          , per_all_assignments_f paf
106          , per_personal_scorecards pms
107      where pms.scorecard_id = p_scorecard_id
108      and pms.assignment_id = paf.assignment_id
109      and paf.business_group_id = pbg.business_group_id;
110 
111   --
112   -- Declare local variables
113   --
114   l_legislation_code  varchar2(150);
115   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
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           => 'scorecard_id'
126     ,p_argument_value     => p_scorecard_id
127     );
128   --
129   if ( nvl(per_pms_bus.g_scorecard_id, hr_api.g_number)
130        = p_scorecard_id) then
131     --
132     -- The legislation code has already been found with a previous
133     -- call to this function. Just return the value in the global
134     -- variable.
135     --
136     l_legislation_code := per_pms_bus.g_legislation_code;
137     hr_utility.set_location(l_proc, 20);
138   else
139     --
140     -- The ID is different to the last call to this function
141     -- or this is the first call to this function.
142     --
143     open csr_leg_code;
144     fetch csr_leg_code into l_legislation_code;
145     --
146     if csr_leg_code%notfound then
147       --
148       -- The primary key is invalid therefore we must error
149       --
150       close csr_leg_code;
151       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
152       fnd_message.raise_error;
153     end if;
154     hr_utility.set_location(l_proc,30);
155     --
156     -- Set the global variables so the values are
157     -- available for the next call to this function.
158     --
159     close csr_leg_code;
160     per_pms_bus.g_scorecard_id                := p_scorecard_id;
161     per_pms_bus.g_legislation_code  := l_legislation_code;
162   end if;
163   hr_utility.set_location(' Leaving:'|| l_proc, 40);
164   return l_legislation_code;
165 end return_legislation_code;
166 --
167 -- ----------------------------------------------------------------------------
168 -- |------------------------------< chk_df >----------------------------------|
169 -- ----------------------------------------------------------------------------
170 --
171 -- Description:
172 --   Validates all the Descriptive Flexfield values.
173 --
174 -- Prerequisites:
175 --   All other columns have been validated.  Must be called as the
176 --   last step from insert_validate and update_validate.
177 --
178 -- In Arguments:
179 --   p_rec
180 --
181 -- Post Success:
182 --   If the Descriptive Flexfield structure column and data values are
183 --   all valid this procedure will end normally and processing will
184 --   continue.
185 --
186 -- Post Failure:
187 --   If the Descriptive Flexfield structure column value or any of
188 --   the data values are invalid then an application error is raised as
189 --   a PL/SQL exception.
190 --
191 -- Access Status:
192 --   Internal Row Handler Use Only.
193 --
194 -- ----------------------------------------------------------------------------
195 procedure chk_df
196   (p_rec in per_pms_shd.g_rec_type
197   ) is
198 --
199   l_proc   varchar2(72) := g_package || 'chk_df';
200 --
201 begin
202   hr_utility.set_location('Entering:'||l_proc,10);
203   --
204   if ((p_rec.scorecard_id is not null)  and (
205     nvl(per_pms_shd.g_old_rec.attribute_category, hr_api.g_varchar2) <>
206     nvl(p_rec.attribute_category, hr_api.g_varchar2)  or
207     nvl(per_pms_shd.g_old_rec.attribute1, hr_api.g_varchar2) <>
208     nvl(p_rec.attribute1, hr_api.g_varchar2)  or
209     nvl(per_pms_shd.g_old_rec.attribute2, hr_api.g_varchar2) <>
210     nvl(p_rec.attribute2, hr_api.g_varchar2)  or
211     nvl(per_pms_shd.g_old_rec.attribute3, hr_api.g_varchar2) <>
212     nvl(p_rec.attribute3, hr_api.g_varchar2)  or
213     nvl(per_pms_shd.g_old_rec.attribute4, hr_api.g_varchar2) <>
214     nvl(p_rec.attribute4, hr_api.g_varchar2)  or
215     nvl(per_pms_shd.g_old_rec.attribute5, hr_api.g_varchar2) <>
216     nvl(p_rec.attribute5, hr_api.g_varchar2)  or
217     nvl(per_pms_shd.g_old_rec.attribute6, hr_api.g_varchar2) <>
218     nvl(p_rec.attribute6, hr_api.g_varchar2)  or
219     nvl(per_pms_shd.g_old_rec.attribute7, hr_api.g_varchar2) <>
220     nvl(p_rec.attribute7, hr_api.g_varchar2)  or
221     nvl(per_pms_shd.g_old_rec.attribute8, hr_api.g_varchar2) <>
222     nvl(p_rec.attribute8, hr_api.g_varchar2)  or
223     nvl(per_pms_shd.g_old_rec.attribute9, hr_api.g_varchar2) <>
224     nvl(p_rec.attribute9, hr_api.g_varchar2)  or
225     nvl(per_pms_shd.g_old_rec.attribute10, hr_api.g_varchar2) <>
226     nvl(p_rec.attribute10, hr_api.g_varchar2)  or
227     nvl(per_pms_shd.g_old_rec.attribute11, hr_api.g_varchar2) <>
228     nvl(p_rec.attribute11, hr_api.g_varchar2)  or
229     nvl(per_pms_shd.g_old_rec.attribute12, hr_api.g_varchar2) <>
230     nvl(p_rec.attribute12, hr_api.g_varchar2)  or
231     nvl(per_pms_shd.g_old_rec.attribute13, hr_api.g_varchar2) <>
232     nvl(p_rec.attribute13, hr_api.g_varchar2)  or
233     nvl(per_pms_shd.g_old_rec.attribute14, hr_api.g_varchar2) <>
234     nvl(p_rec.attribute14, hr_api.g_varchar2)  or
235     nvl(per_pms_shd.g_old_rec.attribute15, hr_api.g_varchar2) <>
236     nvl(p_rec.attribute15, hr_api.g_varchar2)  or
237     nvl(per_pms_shd.g_old_rec.attribute16, hr_api.g_varchar2) <>
238     nvl(p_rec.attribute16, hr_api.g_varchar2)  or
239     nvl(per_pms_shd.g_old_rec.attribute17, hr_api.g_varchar2) <>
240     nvl(p_rec.attribute17, hr_api.g_varchar2)  or
241     nvl(per_pms_shd.g_old_rec.attribute18, hr_api.g_varchar2) <>
242     nvl(p_rec.attribute18, hr_api.g_varchar2)  or
243     nvl(per_pms_shd.g_old_rec.attribute19, hr_api.g_varchar2) <>
244     nvl(p_rec.attribute19, hr_api.g_varchar2)  or
245     nvl(per_pms_shd.g_old_rec.attribute20, hr_api.g_varchar2) <>
246     nvl(p_rec.attribute20, hr_api.g_varchar2)  or
247     nvl(per_pms_shd.g_old_rec.attribute21, hr_api.g_varchar2) <>
248     nvl(p_rec.attribute21, hr_api.g_varchar2)  or
249     nvl(per_pms_shd.g_old_rec.attribute22, hr_api.g_varchar2) <>
250     nvl(p_rec.attribute22, hr_api.g_varchar2)  or
251     nvl(per_pms_shd.g_old_rec.attribute23, hr_api.g_varchar2) <>
252     nvl(p_rec.attribute23, hr_api.g_varchar2)  or
253     nvl(per_pms_shd.g_old_rec.attribute24, hr_api.g_varchar2) <>
254     nvl(p_rec.attribute24, hr_api.g_varchar2)  or
255     nvl(per_pms_shd.g_old_rec.attribute25, hr_api.g_varchar2) <>
256     nvl(p_rec.attribute25, hr_api.g_varchar2)  or
257     nvl(per_pms_shd.g_old_rec.attribute26, hr_api.g_varchar2) <>
258     nvl(p_rec.attribute26, hr_api.g_varchar2)  or
259     nvl(per_pms_shd.g_old_rec.attribute27, hr_api.g_varchar2) <>
260     nvl(p_rec.attribute27, hr_api.g_varchar2)  or
261     nvl(per_pms_shd.g_old_rec.attribute28, hr_api.g_varchar2) <>
262     nvl(p_rec.attribute28, hr_api.g_varchar2)  or
263     nvl(per_pms_shd.g_old_rec.attribute29, hr_api.g_varchar2) <>
264     nvl(p_rec.attribute29, hr_api.g_varchar2)  or
265     nvl(per_pms_shd.g_old_rec.attribute30, hr_api.g_varchar2) <>
266     nvl(p_rec.attribute30, hr_api.g_varchar2) ))
267     or (p_rec.scorecard_id is null)  then
268     --
269     -- Only execute the validation if absolutely necessary:
270     -- a) During update, the structure column value or any
271     --    of the attribute values have actually changed.
272     -- b) During insert.
273     --
274     hr_dflex_utility.ins_or_upd_descflex_attribs
275       (p_appl_short_name                 => 'PER'
276       ,p_descflex_name                   => 'PER_PERSONAL_SCORECARDS'
277       ,p_attribute_category              => p_rec.attribute_category
278       ,p_attribute1_name                 => 'ATTRIBUTE1'
279       ,p_attribute1_value                => p_rec.attribute1
280       ,p_attribute2_name                 => 'ATTRIBUTE2'
281       ,p_attribute2_value                => p_rec.attribute2
282       ,p_attribute3_name                 => 'ATTRIBUTE3'
283       ,p_attribute3_value                => p_rec.attribute3
284       ,p_attribute4_name                 => 'ATTRIBUTE4'
285       ,p_attribute4_value                => p_rec.attribute4
286       ,p_attribute5_name                 => 'ATTRIBUTE5'
287       ,p_attribute5_value                => p_rec.attribute5
288       ,p_attribute6_name                 => 'ATTRIBUTE6'
289       ,p_attribute6_value                => p_rec.attribute6
290       ,p_attribute7_name                 => 'ATTRIBUTE7'
291       ,p_attribute7_value                => p_rec.attribute7
292       ,p_attribute8_name                 => 'ATTRIBUTE8'
293       ,p_attribute8_value                => p_rec.attribute8
294       ,p_attribute9_name                 => 'ATTRIBUTE9'
295       ,p_attribute9_value                => p_rec.attribute9
296       ,p_attribute10_name                => 'ATTRIBUTE10'
297       ,p_attribute10_value               => p_rec.attribute10
298       ,p_attribute11_name                => 'ATTRIBUTE11'
299       ,p_attribute11_value               => p_rec.attribute11
300       ,p_attribute12_name                => 'ATTRIBUTE12'
301       ,p_attribute12_value               => p_rec.attribute12
302       ,p_attribute13_name                => 'ATTRIBUTE13'
303       ,p_attribute13_value               => p_rec.attribute13
304       ,p_attribute14_name                => 'ATTRIBUTE14'
305       ,p_attribute14_value               => p_rec.attribute14
306       ,p_attribute15_name                => 'ATTRIBUTE15'
307       ,p_attribute15_value               => p_rec.attribute15
308       ,p_attribute16_name                => 'ATTRIBUTE16'
309       ,p_attribute16_value               => p_rec.attribute16
310       ,p_attribute17_name                => 'ATTRIBUTE17'
311       ,p_attribute17_value               => p_rec.attribute17
312       ,p_attribute18_name                => 'ATTRIBUTE18'
313       ,p_attribute18_value               => p_rec.attribute18
314       ,p_attribute19_name                => 'ATTRIBUTE19'
315       ,p_attribute19_value               => p_rec.attribute19
316       ,p_attribute20_name                => 'ATTRIBUTE20'
317       ,p_attribute20_value               => p_rec.attribute20
318       ,p_attribute21_name                => 'ATTRIBUTE21'
319       ,p_attribute21_value               => p_rec.attribute21
320       ,p_attribute22_name                => 'ATTRIBUTE22'
321       ,p_attribute22_value               => p_rec.attribute22
322       ,p_attribute23_name                => 'ATTRIBUTE23'
323       ,p_attribute23_value               => p_rec.attribute23
324       ,p_attribute24_name                => 'ATTRIBUTE24'
325       ,p_attribute24_value               => p_rec.attribute24
326       ,p_attribute25_name                => 'ATTRIBUTE25'
327       ,p_attribute25_value               => p_rec.attribute25
328       ,p_attribute26_name                => 'ATTRIBUTE26'
329       ,p_attribute26_value               => p_rec.attribute26
330       ,p_attribute27_name                => 'ATTRIBUTE27'
331       ,p_attribute27_value               => p_rec.attribute27
332       ,p_attribute28_name                => 'ATTRIBUTE28'
333       ,p_attribute28_value               => p_rec.attribute28
334       ,p_attribute29_name                => 'ATTRIBUTE29'
335       ,p_attribute29_value               => p_rec.attribute29
336       ,p_attribute30_name                => 'ATTRIBUTE30'
337       ,p_attribute30_value               => p_rec.attribute30
338       );
339   end if;
340   --
341   hr_utility.set_location(' Leaving:'||l_proc,20);
342 end chk_df;
343 --
344 -- ----------------------------------------------------------------------------
345 -- |-----------------------< chk_non_updateable_args >------------------------|
346 -- ----------------------------------------------------------------------------
347 -- {Start Of Comments}
348 --
349 -- Description:
350 --   This procedure is used to ensure that non updateable attributes have
351 --   not been updated. If an attribute has been updated an error is generated.
352 --
353 -- Pre Conditions:
354 --   g_old_rec has been populated with details of the values currently in
355 --   the database.
356 --
357 -- In Arguments:
358 --   p_rec has been populated with the updated values the user would like the
359 --   record set to.
360 --
361 -- Post Success:
362 --   Processing continues if all the non updateable attributes have not
363 --   changed.
364 --
365 -- Post Failure:
366 --   An application error is raised if any of the non updatable attributes
367 --   have been altered.
368 --
369 -- {End Of Comments}
370 -- ----------------------------------------------------------------------------
371 Procedure chk_non_updateable_args
372   (p_effective_date               in date
373   ,p_rec in per_pms_shd.g_rec_type
374   ) IS
375 --
376   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
377   l_error    EXCEPTION;
378   l_argument varchar2(30);
379 --
380 Begin
381   --
382   -- Only proceed with the validation if a row exists for the current
383   -- record in the HR Schema.
384   --
385   IF NOT per_pms_shd.api_updating
386       (p_scorecard_id                      => p_rec.scorecard_id
387       ,p_object_version_number             => p_rec.object_version_number
388       ) THEN
389      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
390      fnd_message.set_token('PROCEDURE ', l_proc);
391      fnd_message.set_token('STEP ', '5');
392      fnd_message.raise_error;
393   END IF;
394   --
395   hr_utility.set_location(l_proc, 10);
396   if nvl(p_rec.person_id,hr_api.g_number) <>
397      per_pms_shd.g_old_rec.person_id then
398      l_argument := 'person_id';
399      raise l_error;
400   end if;
401   --
402   hr_utility.set_location(l_proc, 15);
403   if nvl(p_rec.assignment_id,hr_api.g_number) <>
404      per_pms_shd.g_old_rec.assignment_id then
405      l_argument := 'assignment_id';
406      raise l_error;
407   end if;
408   --
409   hr_utility.set_location(l_proc, 20);
410   if nvl(p_rec.creator_type,hr_api.g_varchar2) <>
411      per_pms_shd.g_old_rec.creator_type then
412      l_argument := 'creator_type';
413      raise l_error;
414   end if;
415   --
416   hr_utility.set_location(l_proc, 30);
417   --
418   EXCEPTION
419     WHEN l_error THEN
420        hr_api.argument_changed_error
421          (p_api_name   => l_proc
422          ,p_argument   => l_argument
423          ,p_base_table => per_pms_shd.g_tab_nam);
424     WHEN OTHERS THEN
425        RAISE;
426 End chk_non_updateable_args;
427 --
428 -- ----------------------------------------------------------------------------
429 -- |-----------------------< chk_assignment_id >------------------------------|
430 -- ----------------------------------------------------------------------------
431 -- {Start Of Comments}
432 --
433 -- Description:
434 --   This procedure is used to ensure that the specified assignment exists
435 --   and that it is not a Benefits ('B') assignment.
436 --
437 -- Pre Conditions:
438 --   The assignment must already exist.
439 --
440 -- In Arguments:
441 --
442 --
443 -- Post Success:
444 --   Processing continues if the assignment is valid.
445 --
446 -- Post Failure:
447 --   An application error is raised if the assignment does not exist
448 --   or is a Benefits assignment.
449 --
450 -- {End Of Comments}
451 -- ----------------------------------------------------------------------------
452 Procedure chk_assignment_id
453   (p_scorecard_id          IN         number
454   ,p_object_version_number IN         number
455   ,p_assignment_id         IN         number
456   ,p_person_id             OUT NOCOPY number
457   ) IS
458 
459   --
460   l_proc          varchar2(72) := g_package || 'chk_assignment_id';
461   l_api_updating  boolean;
462   l_assignment_id number;
463   --
464 
465   CURSOR csr_chk_assignment_id IS
466   SELECT asg.assignment_id, asg.person_id
467   FROM   per_all_assignments_f asg
468   WHERE  asg.assignment_id = p_assignment_id
469   AND    asg.assignment_type <> 'B';
470 --
471 BEGIN
472 
473   IF g_debug THEN hr_utility.set_location('Entering:'|| l_proc, 10); END IF;
474 
475   --
476   hr_api.mandatory_arg_error
477           (p_api_name       => l_proc
478           ,p_argument       => 'p_assignment_id'
479           ,p_argument_value => p_assignment_id
480           );
481 
482   --
483   -- Only proceed with validation if :
484   -- a) The current g_old_rec is current and
485   -- b) The date values have changed
486   --
487   l_api_updating := per_pms_shd.api_updating
488          (p_scorecard_id           => p_scorecard_id
489          ,p_object_version_number  => p_object_version_number);
490   --
491   IF (l_api_updating
492   AND nvl(per_pms_shd.g_old_rec.assignment_id, hr_api.g_number)
493     = nvl(p_assignment_id, hr_api.g_number))
494   THEN
495      RETURN;
496   END IF;
497 
498   --
499   -- Check that the assignment is valid.
500   -- No attempt is made to validate the dates of the assignment
501   -- against the scorecard: it is possible to have a scorecard
502   -- that starts before, or ends after, the assignment.
503   -- Such validation would be possible but later changes to
504   -- the assignment could invalidate the rule and it becomes
505   -- unncessarily complex for little benefit.
506   -- Life Events can be used to capture changes to the
507   -- dates of an assignment and early end the scorecard.
508   --
509   OPEN  csr_chk_assignment_id;
510   FETCH csr_chk_assignment_id INTO l_assignment_id
511                                   ,p_person_id;
512   CLOSE csr_chk_assignment_id;
513 
514   IF l_assignment_id IS null THEN
515     fnd_message.set_name('PER', 'HR_50263_PMS_INVALID_ASG');
516     fnd_message.raise_error;
517   END IF;
518 
519   IF g_debug THEN hr_utility.set_location('Leaving:'|| l_proc, 970); END IF;
520 
521 EXCEPTION
522 
523   WHEN app_exception.application_exception THEN
524     IF hr_multi_message.exception_add
525       (p_associated_column1 => 'PER_PERSONAL_SCORECARDS.ASSIGNMENT_ID')
526     THEN
527       hr_utility.set_location(' Leaving:'|| l_proc, 980);
528       RAISE;
529     END IF;
530     hr_utility.set_location(' Leaving:'|| l_proc, 990);
531 
532 END chk_assignment_id;
533 --
534 -- ----------------------------------------------------------------------------
535 -- |-----------------------< chk_plan_id >------------------------------------|
536 -- ----------------------------------------------------------------------------
537 -- {Start Of Comments}
538 --
539 -- Description:
540 --   This procedure is used to validate that the specified performance
541 --   management plan exists.
542 --
543 -- Pre Conditions:
544 --   The plan must already exist.
545 --
546 -- In Arguments:
547 --
548 --
549 -- Post Success:
550 --   Processing continues if the plan is valid.
551 --
552 -- Post Failure:
553 --   An application error is raised if the plan does not exist.
554 --
555 -- {End Of Comments}
556 -- ----------------------------------------------------------------------------
557 Procedure chk_plan_id
558   (p_scorecard_id          IN number
559   ,p_object_version_number IN number
560   ,p_plan_id               IN number
561   ) IS
562 
563   --
564   l_proc          varchar2(72) := g_package || 'chk_plan_id';
565   l_api_updating  boolean;
566   l_plan_id       number;
567   --
568 
569   CURSOR csr_chk_plan_id IS
570   SELECT pmp.plan_id
571   FROM   per_perf_mgmt_plans pmp
572   WHERE  pmp.plan_id = p_plan_id;
573 --
574 BEGIN
575 
576   IF g_debug THEN hr_utility.set_location('Entering:'|| l_proc, 10); END IF;
577 
578   --
579   -- Only proceed with validation if :
580   -- a) The current g_old_rec is current and
581   -- b) The date values have changed
582   --
583   l_api_updating := per_pms_shd.api_updating
584          (p_scorecard_id           => p_scorecard_id
585          ,p_object_version_number  => p_object_version_number);
586   --
587   IF (l_api_updating
588   AND nvl(per_pms_shd.g_old_rec.plan_id, hr_api.g_number)
589     = nvl(p_plan_id, hr_api.g_number))
590   THEN
591      RETURN;
592   END IF;
593 
594   IF p_plan_id IS NOT null THEN
595     --
596     -- Check that plan exists.
597     --
598     IF g_debug THEN hr_utility.set_location(l_proc, 20); END IF;
599     OPEN  csr_chk_plan_id;
600     FETCH csr_chk_plan_id INTO l_plan_id;
601     CLOSE csr_chk_plan_id;
602 
603     IF l_plan_id IS null THEN
604       fnd_message.set_name('PER', 'HR_50264_PMS_INVALID_PLAN');
605       fnd_message.raise_error;
606     END IF;
607 
608   END IF;
609 
610   IF g_debug THEN hr_utility.set_location('Leaving:'|| l_proc, 970); END IF;
611 
612 EXCEPTION
613 
614   WHEN app_exception.application_exception THEN
615     IF hr_multi_message.exception_add
616       (p_associated_column1 => 'PER_PERSONAL_SCORECARDS.PLAN_ID')
617     THEN
618       hr_utility.set_location(' Leaving:'|| l_proc, 980);
619       RAISE;
620     END IF;
621     hr_utility.set_location(' Leaving:'|| l_proc, 990);
622 
623 END chk_plan_id;
624 --
625 -- ----------------------------------------------------------------------------
626 -- |-----------------------< chk_duplicate >----------------------------------|
627 -- ----------------------------------------------------------------------------
628 -- {Start Of Comments}
629 --
630 -- Description:
631 --   This procedure is used to validate that a personal scorecard does not
632 --   already exist for the given assignment and given plan.
633 --
634 -- Pre Conditions:
635 --   The plan and assignment must exist and have been validated.
636 --
637 -- In Arguments:
638 --
639 --
640 -- Post Success:
641 --   Processing continues if the scorecard is not a duplicate.
642 --
643 -- Post Failure:
644 --   An application error is raised if the scorecard is a duplicate.
645 --
646 -- {End Of Comments}
647 -- ----------------------------------------------------------------------------
648 Procedure chk_duplicate
649   (p_scorecard_id          IN number
650   ,p_object_version_number IN number
651   ,p_plan_id               IN number
652   ,p_assignment_id         IN number
653   ) IS
654 
655   --
656   l_proc           varchar2(72) := g_package || 'chk_duplicate';
657   l_api_updating   boolean;
658   l_dup            varchar2(5) := 'FALSE';
659   --
660 
661   CURSOR csr_chk_duplicate IS
662   SELECT 'TRUE'
663   FROM   per_personal_scorecards pms
664   WHERE  pms.plan_id = p_plan_id
665   AND    pms.assignment_id = p_assignment_id
666   AND    pms.scorecard_id <> nvl(p_scorecard_id, hr_api.g_number)
667   AND    pms.STATUS_CODE <> 'TRANSFER_OUT';
668 --
669 BEGIN
670 
671   IF g_debug THEN hr_utility.set_location('Entering:'|| l_proc, 10); END IF;
672 
673   --
674   hr_api.mandatory_arg_error
675           (p_api_name       => l_proc
676           ,p_argument       => 'p_assignment_id'
677           ,p_argument_value => p_assignment_id
678           );
679 
680   --
681   -- Only proceed with validation if :
682   -- a) The current g_old_rec is current and
683   -- b) The date values have changed
684   --
685   l_api_updating := per_pms_shd.api_updating
686          (p_scorecard_id           => p_scorecard_id
687          ,p_object_version_number  => p_object_version_number);
688   --
689   IF (l_api_updating
690   AND nvl(per_pms_shd.g_old_rec.plan_id, hr_api.g_number)
691     = nvl(p_plan_id, hr_api.g_number)
692   AND nvl(per_pms_shd.g_old_rec.assignment_id, hr_api.g_number)
693     = nvl(p_assignment_id, hr_api.g_number))
694   THEN
695      RETURN;
696   END IF;
697 
698   IF p_plan_id IS NOT null THEN
699     --
700     -- Check that the plan is not a duplicate.
701     --
702     IF g_debug THEN hr_utility.set_location(l_proc, 20); END IF;
703     OPEN  csr_chk_duplicate;
704     FETCH csr_chk_duplicate INTO l_dup;
705     CLOSE csr_chk_duplicate;
706 
707     IF l_dup = 'TRUE' THEN
708       fnd_message.set_name('PER', 'HR_50265_PMS_DUP_SCORECARD');
709       fnd_message.raise_error;
710     END IF;
711 
712   END IF;
713 
714   IF g_debug THEN hr_utility.set_location('Leaving:'|| l_proc, 970); END IF;
715 
716 EXCEPTION
717 
718   WHEN app_exception.application_exception THEN
719     IF hr_multi_message.exception_add
720       (p_associated_column1 => 'PER_PERSONAL_SCORECARDS.PLAN_ID'
721       ,p_associated_column2 => 'PER_PERSONAL_SCORECARDS.ASSIGNMENT_ID')
722     THEN
723       hr_utility.set_location(' Leaving:'|| l_proc, 980);
724       RAISE;
725     END IF;
726     hr_utility.set_location(' Leaving:'|| l_proc, 990);
727 
728 END chk_duplicate;
729 --
730 -- ----------------------------------------------------------------------------
731 -- |-----------------------< chk_dates >--------------------------------------|
732 -- ----------------------------------------------------------------------------
733 -- {Start Of Comments}
734 --
735 -- Description:
736 --   This procedure checks the start and end date of the scorecard. It
737 --   first checks that the start date is earlier than the end date,
738 --   then it checks that the scorecard dates are within the dates of the
739 --   performance management plan and finally it checks that the dates
740 --   against the scorecard's objectives to not exceed the new dates.
741 --
742 -- Pre Conditions:
743 --   Where used, the plan must exist and have been validated.
744 --
745 -- In Arguments:
746 --
747 --
748 -- Post Success:
749 --   Processing continues if the dates are valid.
750 --
751 -- Post Failure:
752 --   An application error is raised if the dates are invalid.
753 --
754 -- {End Of Comments}
755 -- ----------------------------------------------------------------------------
756 Procedure chk_dates
757   (p_scorecard_id          IN number
758   ,p_object_version_number IN number
759   ,p_plan_id               IN number
760   ,p_start_date            IN date
761   ,p_end_date              IN date
762   ) IS
763 
764   --
765   l_proc           varchar2(72) := g_package || 'chk_dates';
766   l_api_updating   boolean;
767   l_pmp_start_date date;
768   l_pmp_end_date   date;
769   l_row_found      varchar2(1)  := 'N';
770   --
771 
772   CURSOR csr_dates_within_plan IS
773   SELECT pmp.start_date, pmp.end_date
774   FROM   per_perf_mgmt_plans pmp
775   WHERE  pmp.plan_id = p_plan_id;
776 
777   CURSOR csr_objs_outside_scorecard IS
778   SELECT 'Y'
779   FROM   per_objectives obj
780   WHERE  obj.scorecard_id IS NOT NULL
781   AND    obj.scorecard_id = p_scorecard_id
782   AND   (obj.start_date < p_start_date OR
783          obj.target_date > p_end_date)
784   AND    rownum = 1;
785 
786 --
787 BEGIN
788 
789   IF g_debug THEN hr_utility.set_location('Entering:'|| l_proc, 10); END IF;
790   --
791   hr_api.mandatory_arg_error
792           (p_api_name       => l_proc
793           ,p_argument       => 'p_start_date'
794           ,p_argument_value => p_start_date
795           );
796   --
797   hr_api.mandatory_arg_error
798           (p_api_name       => l_proc
799           ,p_argument       => 'p_end_date'
800           ,p_argument_value => p_end_date
801           );
802 
803   --
804   -- Only proceed with validation if :
805   -- a) The current g_old_rec is current and
806   -- b) The date values have changed
807   --
808   l_api_updating := per_pms_shd.api_updating
809          (p_scorecard_id           => p_scorecard_id
810          ,p_object_version_number  => p_object_version_number);
811   --
812   IF (l_api_updating
813   AND nvl(per_pms_shd.g_old_rec.plan_id, hr_api.g_number)
814     = nvl(p_plan_id, hr_api.g_number)
815   AND nvl(per_pms_shd.g_old_rec.start_date, hr_api.g_date)
816     = nvl(p_start_date, hr_api.g_date)
817   AND nvl(per_pms_shd.g_old_rec.end_date, hr_api.g_date)
818     = nvl(p_end_date, hr_api.g_date))
819   THEN
820      RETURN;
821   END IF;
822 
823   IF g_debug THEN hr_utility.set_location(l_proc, 20); END IF;
824 
825   --
826   -- Check that the scorecard's start date is not later than the end date.
827   --
828   IF p_start_date > p_end_date THEN
829     fnd_message.set_name('PER', 'HR_50266_PMS_START_END');
830     fnd_message.raise_error;
831   END IF;
832 
833   IF g_debug THEN hr_utility.set_location(l_proc, 30); END IF;
834 
835   IF p_plan_id IS NOT null THEN
836     --
837     -- Check that the scorecard's dates are within the plan dates.
838     --
839     IF g_debug THEN hr_utility.set_location(l_proc, 40); END IF;
840     OPEN  csr_dates_within_plan;
841     FETCH csr_dates_within_plan INTO l_pmp_start_date
842                                     ,l_pmp_end_date;
843     CLOSE csr_dates_within_plan;
844 
845     IF p_start_date < l_pmp_start_date
846      OR p_end_date > l_pmp_end_date
847     THEN
848       fnd_message.set_name('PER', 'HR_50267_PMS_DATES_OUT_PLAN');
849       fnd_message.raise_error;
850     END IF;
851 
852   END IF;
853 
854   IF g_debug THEN hr_utility.set_location(l_proc, 50); END IF;
855 
856   IF p_scorecard_id IS NOT null THEN
857     --
858     -- Check that there are no objectives outside the range of this scorecard.
859     --
860     IF g_debug THEN hr_utility.set_location(l_proc, 60); END IF;
861     OPEN  csr_objs_outside_scorecard;
862     FETCH csr_objs_outside_scorecard INTO l_row_found;
863     CLOSE csr_objs_outside_scorecard;
864 
865     IF l_row_found = 'Y'
866     THEN
867       fnd_message.set_name('PER', 'HR_50296_PMS_OBJ_DATES');
868       fnd_message.raise_error;
869     END IF;
870 
871   END IF;
872 
873   IF g_debug THEN hr_utility.set_location('Leaving:'|| l_proc, 970); END IF;
874 
875 EXCEPTION
876 
877   WHEN app_exception.application_exception THEN
878     IF hr_multi_message.exception_add
879       (p_associated_column1 => 'PER_PERSONAL_SCORECARDS.START_DATE'
880       ,p_associated_column2 => 'PER_PERSONAL_SCORECARDS.END_DATE')
881     THEN
882       hr_utility.set_location(' Leaving:'|| l_proc, 980);
883       RAISE;
884     END IF;
885     hr_utility.set_location(' Leaving:'|| l_proc, 990);
886 
887 END chk_dates;
888 --
889 -- ----------------------------------------------------------------------------
890 -- |-----------------------< chk_scorecard_name >-----------------------------|
891 -- ----------------------------------------------------------------------------
892 -- {Start Of Comments}
893 --
894 -- Description:
895 --   This procedure checks that the specified assignment does not already
896 --   have a scorecard with a duplicate name.
897 --
898 -- Pre Conditions:
899 --   None.
900 --
901 -- In Arguments:
902 --
903 --
904 -- Post Success:
905 --   Processing continues if the scorecard name is unique for the given
906 --   assignment and the p_duplicate_name_warning is set accordingly
907 --   (true if the name already exists; false if it does not).
908 --
909 -- Post Failure:
910 --   An error is raised if an unhandled exception occurs.
911 --
912 -- {End Of Comments}
913 -- ----------------------------------------------------------------------------
914 Procedure chk_scorecard_name
915   (p_scorecard_id           IN  number
916   ,p_object_version_number  IN  number
917   ,p_assignment_id          IN  number
918   ,p_scorecard_name         IN  varchar2
919   ,p_duplicate_name_warning OUT NOCOPY boolean
920   ) IS
921 
922   --
923   l_proc           varchar2(72) := g_package || 'chk_scorecard_name';
924   l_api_updating   boolean;
925   l_dup            varchar2(5) := 'FALSE';
926   --
927 
928   CURSOR csr_chk_scorecard_name IS
929   SELECT 'TRUE'
930   FROM   per_personal_scorecards pms
931   WHERE  pms.assignment_id = p_assignment_id
932   AND    pms.scorecard_id <> nvl(p_scorecard_id, hr_api.g_number)
933   AND    upper(trim(pms.scorecard_name)) = upper(trim(p_scorecard_name));
934 --
935 BEGIN
936 
937   IF g_debug THEN hr_utility.set_location('Entering:'|| l_proc, 10); END IF;
938 
939   --
940   hr_api.mandatory_arg_error
941           (p_api_name       => l_proc
942           ,p_argument       => 'p_assignment_id'
943           ,p_argument_value => p_assignment_id
944           );
945   --
946   hr_api.mandatory_arg_error
947           (p_api_name       => l_proc
948           ,p_argument       => 'p_scorecard_name'
949           ,p_argument_value => p_scorecard_name
950           );
951 
952   --
953   -- Only proceed with validation if :
954   -- a) The current g_old_rec is current and
955   -- b) The date values have changed
956   --
957   l_api_updating := per_pms_shd.api_updating
958          (p_scorecard_id           => p_scorecard_id
959          ,p_object_version_number  => p_object_version_number);
960   --
961   IF (l_api_updating
962   AND nvl(per_pms_shd.g_old_rec.assignment_id, hr_api.g_number)
963     = nvl(p_assignment_id, hr_api.g_number)
964   AND nvl(per_pms_shd.g_old_rec.scorecard_name, hr_api.g_varchar2)
965     = nvl(p_scorecard_name, hr_api.g_varchar2))
966   THEN
967      RETURN;
968   END IF;
969 
970   IF g_debug THEN hr_utility.set_location(l_proc, 20); END IF;
971 
972   --
973   -- Warn if a scorecard with the same name already exists
974   -- (case and space insensitive).
975   --
976   OPEN  csr_chk_scorecard_name;
977   FETCH csr_chk_scorecard_name INTO l_dup;
978   CLOSE csr_chk_scorecard_name;
979 
980   p_duplicate_name_warning := (l_dup = 'TRUE');
981 
982   IF g_debug THEN hr_utility.trace('p_duplicate_name_warning: '||l_dup); END IF;
983   IF g_debug THEN hr_utility.set_location('Leaving:'|| l_proc, 970); END IF;
984 
985 END chk_scorecard_name;
986 --
987 -- ----------------------------------------------------------------------------
988 -- |-----------------------< chk_creator_type >-------------------------------|
989 -- ----------------------------------------------------------------------------
990 -- {Start Of Comments}
991 --
992 -- Description:
993 --   This procedure checks the creator type is 'MANUAL' or 'AUTO'.
994 --
995 -- Pre Conditions:
996 --   None.
997 --
998 -- In Arguments:
999 --
1000 --
1001 -- Post Success:
1002 --   Processing continues if p_creator_type is valid.
1003 --
1004 -- Post Failure:
1005 --   An application error is raised if the creator_type is not valid.
1006 --
1007 -- {End Of Comments}
1008 -- ----------------------------------------------------------------------------
1009 Procedure chk_creator_type
1010   (p_creator_type            IN varchar2
1011   ) IS
1012 
1013   --
1014   l_proc           varchar2(72) := g_package || 'chk_creator_type';
1015   --
1016 
1017 --
1018 BEGIN
1019 
1020   IF g_debug THEN hr_utility.set_location('Entering:'|| l_proc, 10); END IF;
1021 
1022   hr_api.mandatory_arg_error
1023           (p_api_name       => l_proc
1024           ,p_argument       => 'p_creator_type'
1025           ,p_argument_value => p_creator_type
1026           );
1027 
1028   --
1029   -- Check that p_creator_type is valid.
1030   --
1031   IF NOT (p_creator_type = 'MANUAL' OR p_creator_type = 'AUTO')
1032   THEN
1033     fnd_message.set_name('PER', 'HR_50269_PMS_CREATOR_TYPE');
1034     fnd_message.raise_error;
1035   END IF;
1036 
1037   IF g_debug THEN hr_utility.set_location('Leaving:'|| l_proc, 970); END IF;
1038 
1039 EXCEPTION
1040 
1041   WHEN app_exception.application_exception THEN
1042     IF hr_multi_message.exception_add
1043       (p_associated_column1 => 'PER_PERSONAL_SCORECARDS.CREATOR_TYPE')
1044     THEN
1045       hr_utility.set_location(' Leaving:'|| l_proc, 980);
1046       RAISE;
1047     END IF;
1048     hr_utility.set_location(' Leaving:'|| l_proc, 990);
1049 
1050 END chk_creator_type;
1051 --
1052 -- ----------------------------------------------------------------------------
1053 -- |-----------------------< chk_status_code >--------------------------------|
1054 -- ----------------------------------------------------------------------------
1055 -- {Start Of Comments}
1056 --
1057 -- Description:
1058 --   This procedure checks the status code is a valid lookup.
1059 --
1060 -- Pre Conditions:
1061 --   The lookup needs to exist and enabled.
1062 --
1063 -- In Arguments:
1064 --
1065 --
1066 -- Post Success:
1067 --   Processing continues if the status code is valid.
1068 --
1069 -- Post Failure:
1070 --   An application error is raised if the status code is not valid.
1071 --
1072 -- {End Of Comments}
1073 -- ----------------------------------------------------------------------------
1074 Procedure chk_status_code
1075   (p_effective_date         IN  date
1076   ,p_scorecard_id           IN  number
1077   ,p_object_version_number  IN  number
1078   ,p_status_code            IN  varchar2
1079   ) IS
1080 
1081   --
1082   l_proc           varchar2(72) := g_package || 'chk_status_code';
1083   l_api_updating   boolean;
1084   --
1085 
1086 --
1087 BEGIN
1088 
1089   IF g_debug THEN hr_utility.set_location('Entering:'|| l_proc, 10); END IF;
1090 
1091   hr_api.mandatory_arg_error
1092           (p_api_name       => l_proc
1093           ,p_argument       => 'p_status_code'
1094           ,p_argument_value => p_status_code
1095           );
1096 
1097   --
1098   -- Only proceed with validation if :
1099   -- a) The current g_old_rec is current and
1100   -- b) The date values have changed
1101   --
1102   l_api_updating := per_pms_shd.api_updating
1103          (p_scorecard_id           => p_scorecard_id
1104          ,p_object_version_number  => p_object_version_number);
1105   --
1106   IF (l_api_updating
1107   AND nvl(per_pms_shd.g_old_rec.status_code, hr_api.g_varchar2)
1108     = nvl(p_status_code, hr_api.g_varchar2))
1109   THEN
1110      RETURN;
1111   END IF;
1112 
1113   --
1114   -- Check that the status code is a valid lookup.
1115   --
1116   IF hr_api.not_exists_in_hr_lookups
1117     (p_effective_date  => p_effective_date
1118     ,p_lookup_type     => 'HR_WPM_SCORECARD_STATUS'
1119     ,p_lookup_code     => p_status_code)
1120   THEN
1121     fnd_message.set_name('PER', 'HR_50271_PMS_STATUS_CODE');
1122     fnd_message.raise_error;
1123   END IF;
1124 
1125   IF g_debug THEN hr_utility.set_location('Leaving:'|| l_proc, 970); END IF;
1126 
1127 EXCEPTION
1128 
1129   WHEN app_exception.application_exception THEN
1130     IF hr_multi_message.exception_add
1131       (p_associated_column1 =>'PER_PERSONAL_SCORECARDS.STATUS_CODE')
1132     THEN
1133       hr_utility.set_location(' Leaving:'|| l_proc, 980);
1134       RAISE;
1135     END IF;
1136     hr_utility.set_location(' Leaving:'|| l_proc, 990);
1137 
1138 END chk_status_code;
1139 --
1140 -- ----------------------------------------------------------------------------
1141 -- |---------------------< chk_auto_creator_type >----------------------------|
1142 -- ----------------------------------------------------------------------------
1143 -- {Start Of Comments}
1144 --
1145 -- Description:
1146 --   This procedure checks if the creator type is 'AUTO'.
1147 --
1148 -- Pre Conditions:
1149 --   None.
1150 --
1151 -- In Arguments:
1152 --
1153 --
1154 -- Post Success:
1155 --   The p_created_by_plan_warning is set accordingly.
1156 --
1157 -- Post Failure:
1158 --   None.
1159 --
1160 -- {End Of Comments}
1161 -- ----------------------------------------------------------------------------
1162 Procedure chk_auto_creator_type
1163   (p_creator_type            IN varchar2
1164   ,p_created_by_plan_warning OUT NOCOPY boolean
1165   ) IS
1166 
1167   --
1168   l_proc           varchar2(72) := g_package || 'chk_auto_creator_type';
1169   --
1170 
1171 --
1172 BEGIN
1173 
1174   IF g_debug THEN hr_utility.set_location('Entering:'|| l_proc, 10); END IF;
1175 
1176   p_created_by_plan_warning := (p_creator_type = 'AUTO');
1177 
1178   IF g_debug THEN hr_utility.set_location('Leaving:'|| l_proc, 970); END IF;
1179 
1180 END chk_auto_creator_type;
1181 --
1182 -- ----------------------------------------------------------------------------
1183 -- |---------------------< chk_no_objectives >--------------------------------|
1184 -- ----------------------------------------------------------------------------
1185 -- {Start Of Comments}
1186 --
1187 -- Description:
1188 --   This procedure validates that the scorecard does not have any objectives
1189 --   before it is deleted.
1190 --
1191 -- Pre Conditions:
1192 --   None.
1193 --
1194 -- In Arguments:
1195 --
1196 --
1197 -- Post Success:
1198 --   Processing continues if the scorecard does not have any objectives.
1199 --
1200 -- Post Failure:
1201 --   An application error is raised if the scorecard has objectives.
1202 --
1203 -- {End Of Comments}
1204 -- ----------------------------------------------------------------------------
1205 Procedure chk_no_objectives
1206   (p_scorecard_id            IN number
1207   ) IS
1208 
1209   --
1210   l_proc           varchar2(72) := g_package || 'chk_no_objectives';
1211   l_exists         varchar2(1)  := 'N';
1212   --
1213   CURSOR csr_has_objectives IS
1214   SELECT 'Y'
1215   FROM   per_objectives obj
1216   WHERE  obj.scorecard_id IS NOT NULL
1217   AND    obj.scorecard_id = p_scorecard_id
1218   AND    rownum = 1;
1219 
1220 --
1221 BEGIN
1222 
1223   IF g_debug THEN hr_utility.set_location('Entering:'|| l_proc, 10); END IF;
1224 
1225   --
1226   -- Check whether this scorecard has any objectives.
1227   --
1228   OPEN  csr_has_objectives;
1229   FETCH csr_has_objectives INTO l_exists;
1230   CLOSE csr_has_objectives;
1231 
1232   IF l_exists = 'Y' THEN
1233     IF g_debug THEN hr_utility.set_location(l_proc, 20); END IF;
1234     fnd_message.set_name('PER', 'HR_50229_PMS_DEL_NO_OBJ');
1235     fnd_message.raise_error;
1236   END IF;
1237 
1238   IF g_debug THEN hr_utility.set_location('Leaving:'|| l_proc, 970); END IF;
1239 
1240 END chk_no_objectives;
1241 --
1242 -- ----------------------------------------------------------------------------
1243 -- |---------------------------< insert_validate >----------------------------|
1244 -- ----------------------------------------------------------------------------
1245 Procedure insert_validate
1246   (p_effective_date               in date
1247   ,p_rec                          in per_pms_shd.g_rec_type
1248   ,p_person_id                    out nocopy number
1249   ,p_duplicate_name_warning       out nocopy boolean
1250   ) is
1251 --
1252   l_proc  varchar2(72) := g_package||'insert_validate';
1253 --
1254 Begin
1255 
1256   hr_utility.set_location('Entering:'||l_proc, 5);
1257 
1258   --
1259   -- Call all supporting business operations.
1260   --
1261   --
1262   -- Validate the assignment first, so that the call to
1263   -- per_asg_bus1 does not provide a misleading error message.
1264   --
1265   chk_assignment_id
1266     (p_scorecard_id           => p_rec.scorecard_id
1267     ,p_object_version_number  => p_rec.object_version_number
1268     ,p_assignment_id          => p_rec.assignment_id
1269     ,p_person_id              => p_person_id);
1270 
1271   --
1272   -- As this table does not have a mandatory business_group_id
1273   -- column, ensure client_info is populated by calling a suitable
1274   -- set_security_group_id procedure.
1275   --
1276   per_asg_bus1.set_security_group_id
1277     (p_assignment_id => p_rec.assignment_id);
1278 
1279   chk_plan_id
1280     (p_scorecard_id           => p_rec.scorecard_id
1281     ,p_object_version_number  => p_rec.object_version_number
1282     ,p_plan_id                => p_rec.plan_id);
1283 
1284   --
1285   -- End important validation
1286   --
1287   hr_multi_message.end_validation_set;
1288 
1289   --
1290   -- Validate Independent Attributes
1291   --
1292   chk_duplicate
1293     (p_scorecard_id            => p_rec.scorecard_id
1294     ,p_object_version_number   => p_rec.object_version_number
1295     ,p_plan_id                 => p_rec.plan_id
1296     ,p_assignment_id           => p_rec.assignment_id);
1297 
1298   chk_dates
1299     (p_scorecard_id            => p_rec.scorecard_id
1300     ,p_object_version_number   => p_rec.object_version_number
1301     ,p_plan_id                 => p_rec.plan_id
1302     ,p_start_date              => p_rec.start_date
1303     ,p_end_date                => p_rec.end_date);
1304 
1305   chk_scorecard_name
1306     (p_scorecard_id            => p_rec.scorecard_id
1307     ,p_object_version_number   => p_rec.object_version_number
1308     ,p_assignment_id           => p_rec.assignment_id
1309     ,p_scorecard_name          => p_rec.scorecard_name
1310     ,p_duplicate_name_warning  => p_duplicate_name_warning);
1311 
1312   chk_creator_type
1313     (p_creator_type            => p_rec.creator_type);
1314 
1315   chk_status_code
1316     (p_effective_date          => p_effective_date
1317     ,p_scorecard_id            => p_rec.scorecard_id
1318     ,p_object_version_number   => p_rec.object_version_number
1319     ,p_status_code             => p_rec.status_code);
1320 
1321   per_pms_bus.chk_df(p_rec);
1322   --
1323   hr_utility.set_location(' Leaving:'||l_proc, 10);
1324 End insert_validate;
1325 --
1326 -- ----------------------------------------------------------------------------
1327 -- |---------------------------< update_validate >----------------------------|
1328 -- ----------------------------------------------------------------------------
1329 Procedure update_validate
1330   (p_effective_date               in date
1331   ,p_rec                          in per_pms_shd.g_rec_type
1332   ,p_duplicate_name_warning      out nocopy boolean
1333   ) is
1334 --
1335   l_proc  varchar2(72) := g_package||'update_validate';
1336 --
1337 Begin
1338   hr_utility.set_location('Entering:'||l_proc, 5);
1339   --
1340   -- Call all supporting business operations
1341   --
1342   --
1343   -- Validate Important Attributes
1344   --
1345   chk_non_updateable_args
1346     (p_effective_date        => p_effective_date
1347     ,p_rec                   => p_rec);
1348 
1349   --
1350   -- As this table does not have a mandatory business_group_id
1351   -- column, ensure client_info is populated by calling a suitable
1352   -- set_security_group_id procedure.
1353   --
1354   per_asg_bus1.set_security_group_id
1355     (p_assignment_id => p_rec.assignment_id);
1356 
1357   chk_plan_id
1358     (p_scorecard_id           => p_rec.scorecard_id
1359     ,p_object_version_number  => p_rec.object_version_number
1360     ,p_plan_id                => p_rec.plan_id);
1361 
1362   --
1363   -- End important validation
1364   --
1365   hr_multi_message.end_validation_set;
1366 
1367   --
1368   -- Validate Independent Attributes
1369   --
1370   chk_duplicate
1371     (p_scorecard_id           => p_rec.scorecard_id
1372     ,p_object_version_number  => p_rec.object_version_number
1373     ,p_plan_id                => p_rec.plan_id
1374     ,p_assignment_id          => p_rec.assignment_id);
1375 
1376   chk_dates
1377     (p_scorecard_id           => p_rec.scorecard_id
1378     ,p_object_version_number  => p_rec.object_version_number
1379     ,p_plan_id                => p_rec.plan_id
1380     ,p_start_date             => p_rec.start_date
1381     ,p_end_date               => p_rec.end_date);
1382 
1383   chk_scorecard_name
1384     (p_scorecard_id           => p_rec.scorecard_id
1385     ,p_object_version_number  => p_rec.object_version_number
1386     ,p_assignment_id          => p_rec.assignment_id
1387     ,p_scorecard_name         => p_rec.scorecard_name
1388     ,p_duplicate_name_warning => p_duplicate_name_warning);
1389 
1390   chk_status_code
1391     (p_effective_date          => p_effective_date
1392     ,p_scorecard_id            => p_rec.scorecard_id
1393     ,p_object_version_number   => p_rec.object_version_number
1394     ,p_status_code             => p_rec.status_code);
1395 
1396   per_pms_bus.chk_df(p_rec);
1397   --
1398   hr_utility.set_location(' Leaving:'||l_proc, 10);
1399 End update_validate;
1400 --
1401 -- ----------------------------------------------------------------------------
1402 -- |---------------------------< delete_validate >----------------------------|
1403 -- ----------------------------------------------------------------------------
1404 Procedure delete_validate
1405   (p_rec                          in per_pms_shd.g_rec_type
1406   ,p_created_by_plan_warning     out nocopy boolean
1407   ) is
1408 --
1409   l_proc  varchar2(72) := g_package||'delete_validate';
1410 --
1411 Begin
1412 
1413   hr_utility.set_location('Entering:'||l_proc, 5);
1414 
1415   --
1416   -- Call all supporting business operations
1417   --
1418   chk_auto_creator_type
1419     (p_creator_type            => p_rec.creator_type
1420     ,p_created_by_plan_warning => p_created_by_plan_warning);
1421 
1422   hr_utility.set_location('Entering:'||l_proc, 10);
1423 
1424   --
1425   -- Check if the scorecard has any objectives before deleting.
1426   --
1427   chk_no_objectives
1428     (p_scorecard_id            => p_rec.scorecard_id);
1429 
1430   hr_utility.set_location(' Leaving:'||l_proc, 980);
1431 
1432 End delete_validate;
1433 --
1434 end per_pms_bus;