DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_RATING_LEVELS_API

Source


1 Package Body hr_rating_levels_api as
2 /* $Header: pertlapi.pkb 120.0 2005/05/31 19:55:21 appldev noship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(33) := '  hr_rating_levels_api.';
7 --
8 -- ---------------------------------------------------------------------------
9 -- |-----------------------< <create_rating_level> >--------------------------|
10 -- ---------------------------------------------------------------------------
11 -- Validate the language parameter. l_language_code should be passed
12 -- instead of p_language_code from now on, to allow an IN OUT parameter to
13 -- be passed through.
14 --
15 --
16 -- ngundura changes done as per pa requirements { business_group_id made optional parameter}
17 procedure create_rating_level
18  (p_language_code                in varchar2 default hr_api.userenv_lang,
19   p_validate                     in     boolean  	default false,
20   p_effective_date               in     date,
21   p_name                         in 	varchar2,
22   p_business_group_id            in 	number          default null,
23   p_step_value                   in     number,
24   p_behavioural_indicator        in 	varchar2         default null,
25   p_rating_scale_id              in       number		 default null,
26   p_competence_id	               in     number		 default null,
27   p_attribute_category           in 	varchar2         default null,
28   p_attribute1                   in 	varchar2         default null,
29   p_attribute2                   in 	varchar2         default null,
30   p_attribute3                   in 	varchar2         default null,
31   p_attribute4                   in 	varchar2         default null,
32   p_attribute5                   in 	varchar2         default null,
33   p_attribute6                   in 	varchar2         default null,
34   p_attribute7                   in 	varchar2         default null,
35   p_attribute8                   in 	varchar2         default null,
36   p_attribute9                   in 	varchar2         default null,
37   p_attribute10                  in 	varchar2         default null,
38   p_attribute11                  in 	varchar2         default null,
39   p_attribute12                  in 	varchar2         default null,
40   p_attribute13                  in 	varchar2         default null,
41   p_attribute14                  in 	varchar2         default null,
42   p_attribute15                  in 	varchar2         default null,
43   p_attribute16                  in 	varchar2         default null,
44   p_attribute17                  in 	varchar2         default null,
45   p_attribute18                  in 	varchar2         default null,
46   p_attribute19                  in 	varchar2         default null,
47   p_attribute20                  in 	varchar2         default null,
48   p_rating_level_id              out nocopy    number,
49   p_object_version_number        out nocopy 	number,
50   p_obj_ver_number_cpn_or_rsc    out nocopy    number
51   ) is
52   --
53   -- Declare cursors and local variables
54   --
55   -- Cursor to get min amd max levels from the
56   -- competence entity
57   --
58   Cursor get_cpn_levels is
59   select min_level,
60          max_level,
61          object_version_number
62   from	 per_competences
63   where	 competence_id = p_competence_id;
64   --
65   -- Cursor to get min amd max levels from the
66   -- rating scale entity
67   --
68   Cursor get_rsc_levels is
69   select min_scale_step,
70          max_scale_step,
71          object_version_number
72   from	 per_rating_scales
73   where	 rating_scale_id = p_rating_scale_id;
74   --
75   l_proc                	varchar2(72) := g_package||'create_rating_level';
76   l_rating_level_id		per_rating_levels.rating_level_id%TYPE;
77   l_object_version_number	per_rating_levels.object_version_number%TYPE;
78   l_obj_ver_number_cpn_or_rsc   number;
79   --
80   l_min_level		 per_competences.min_level%TYPE;
81   l_max_level		 per_competences.max_level%TYPE;
82   l_min_scale_step	 per_rating_scales.min_scale_step%TYPE;
83   l_max_scale_step	 per_rating_scales.max_scale_step%TYPE;
84   l_language_code        per_rating_levels_tl.language%TYPE;
85   --
86 begin
87   hr_utility.set_location('Entering:'|| l_proc, 5);
88   --
89   -- Issue a savepoint.
90   --
91   savepoint create_rating_level;
92   hr_utility.set_location(l_proc, 6);
93 
94   l_language_code := p_language_code;
95   hr_api.validate_language_code(p_language_code => l_language_code);
96   --
97   -- ngundura global rating levels should not be allowed if
98   -- Cross business group profile is set to N
99   if fnd_profile.value('HR_CROSS_BUSINESS_GROUP') = 'N' and p_business_group_id is null then
100      fnd_message.set_name('PER', 'HR_52693_NO_GLOB_RAT_LEVL');
101      fnd_message.raise_error;
102   end if;
103   -- Call Before Process User Hook
104   --
105   begin
106 	hr_rating_levels_bk1.create_rating_level_b	(
107 	 p_language_code                     =>     l_language_code,
108          p_effective_date                    =>     p_effective_date,
109          p_name                              =>     p_name,
110          p_business_group_id                 =>     p_business_group_id,
111          p_step_value                        =>     p_step_value,
112          p_behavioural_indicator             =>     p_behavioural_indicator,
113          p_rating_scale_id                   =>     p_rating_scale_id,
114          p_competence_id                     =>     p_competence_id,
115          p_attribute_category                =>     p_attribute_category,
116          p_attribute1                        =>     p_attribute1,
117          p_attribute2                        =>     p_attribute2,
118          p_attribute3                        =>     p_attribute3,
119          p_attribute4                        =>     p_attribute4,
120          p_attribute5                        =>     p_attribute5,
121          p_attribute6                        =>     p_attribute6,
122          p_attribute7                        =>     p_attribute7,
123          p_attribute8                        =>     p_attribute8,
124          p_attribute9                        =>     p_attribute9,
125          p_attribute10                       =>     p_attribute10,
126          p_attribute11                       =>     p_attribute11,
127          p_attribute12                       =>     p_attribute12,
128          p_attribute13                       =>     p_attribute13,
129          p_attribute14                       =>     p_attribute14,
130          p_attribute15                       =>     p_attribute15,
131          p_attribute16                       =>     p_attribute16,
132          p_attribute17                       =>     p_attribute17,
133          p_attribute18                       =>     p_attribute18,
134          p_attribute19                       =>     p_attribute19,
135          p_attribute20                       =>     p_attribute20
136 	);
137       exception
138 	   when hr_api.cannot_find_prog_unit then
139 		  hr_api.cannot_find_prog_unit_error
140 				(p_module_name	=> 'create_rating_level',
141 				 p_hook_type	=> 'BP'
142 				);
143   end;
144   --
145   -- End of Before Process User Hook call
146   --
147   -- Validation in addition to Table Handlers
148   --
149   hr_utility.set_location(l_proc, 7);
150   --
151   -- Process Logic
152   -- 1) Get min, max and object version number of competence/rating scale
153   -- 2) place lock on competence/rating scale
154   -- 3) insert row in rating levels
155   -- 4) update competence/rating scale
156   --
157      -- Only one of them has to be set and not both.
158      -- Both cannot be null.
159      --
160      if (   ( p_rating_scale_id is not null and p_competence_id is not null )
161          or ( p_rating_scale_id is null and p_competence_id is null )
162         ) then
163         hr_utility.set_message(801,'HR_51482_RTL_RSC_OR_CPN');
164         hr_utility.raise_error;
165      end if;
166      --
167      if p_competence_id is not null then
168        -- if a rating level for a competence is being created then
169        -- get the min and max levels from competence table. Also get the
170        -- object version number
171        open get_cpn_levels;
172        fetch get_cpn_levels into l_min_level, l_max_level, l_obj_ver_number_cpn_or_rsc;
173        close get_cpn_levels;
174         --
175         -- lock the competence row
176         --
177            per_cpn_shd.lck(p_competence_id  		=> p_competence_id
178 		      	  ,p_object_version_number  	=> l_obj_ver_number_cpn_or_rsc);
179         --
180         -- call rating level api to insert the level for the competence
181         -- in the rating level table
182         --
183         per_rtl_ins.ins
184  	(p_validate                         =>     FALSE,
185   	p_effective_date                    =>     p_effective_date,
186   	p_name                         	=>     p_name,
187   	p_business_group_id            	=>     p_business_group_id,
188   	p_step_value                        =>     p_step_value,
189   	p_behavioural_indicator             =>     p_behavioural_indicator,
190   	p_rating_scale_id	                  =>     null,
191   	p_competence_id                     =>     p_competence_id,
192   	p_attribute_category           	=>     p_attribute_category,
193   	p_attribute1                   	=>     p_attribute1,
194   	p_attribute2                   	=>     p_attribute2,
195   	p_attribute3                   	=>     p_attribute3,
196   	p_attribute4                   	=>     p_attribute4,
197   	p_attribute5                   	=>     p_attribute5,
198   	p_attribute6                   	=>     p_attribute6,
199   	p_attribute7                   	=>     p_attribute7,
200   	p_attribute8                   	=>     p_attribute8,
201   	p_attribute9                   	=>     p_attribute9,
202   	p_attribute10                  	=>     p_attribute10,
203   	p_attribute11                  	=>     p_attribute11,
204   	p_attribute12                  	=>     p_attribute12,
205   	p_attribute13                  	=>     p_attribute13,
206   	p_attribute14                  	=>     p_attribute14,
207   	p_attribute15                  	=>     p_attribute15,
208   	p_attribute16                  	=>     p_attribute16,
209   	p_attribute17                  	=>     p_attribute17,
210   	p_attribute18                  	=>     p_attribute18,
211   	p_attribute19                  	=>     p_attribute19,
212   	p_attribute20                  	=>     p_attribute20,
213   	p_rating_level_id               =>     l_rating_level_id,
214   	p_object_version_number        	=>     l_object_version_number
215   	);
216 
217   	-- call the translation table handler
218 
219   	 per_rtx_ins.ins_tl
220  	(p_rating_level_id              =>   l_rating_level_id,
221   	 p_language_code                =>   l_language_code,
222   	 p_name                        	=>   p_name,
223   	 p_behavioural_indicator        =>   p_behavioural_indicator);
224 
225 
226   	--
227         -- check if the step value passed in is less than the one held in the
228         -- competence table
229         --
230 	if (p_step_value < nvl(l_min_level,0)) then
231          --
232   	 -- call the competence row handler api to update the min level
233   	 -- column in the competence table
234   	 --
235 	 per_cpn_upd.upd
236          (p_validate                   	=>	FALSE
237   	 ,p_effective_date             	=>      p_effective_date
238   	 ,p_competence_id              	=>	p_competence_id
239   	 ,p_object_version_number    	=>	l_obj_ver_number_cpn_or_rsc
240   	 ,p_min_level		 	=>	p_step_value
241   	 );
242          --
243          -- check if the step value passed in is greater than the one held in the
244          -- competence table
245          --
246        elsif (p_step_value > nvl(l_max_level,0)) then
247          --
248 	 -- call the competence row handler api to update the max level
249   	 -- column in the competence table
250   	 --
251 	 per_cpn_upd.upd
252          (p_validate                  =>	FALSE
253   	 ,p_effective_date              =>  p_effective_date
254   	 ,p_competence_id               =>	p_competence_id
255   	 ,p_object_version_number       =>	l_obj_ver_number_cpn_or_rsc
256   	 ,p_max_level                   =>	p_step_value
257   	 );
258 	 --
259        end if;
260        --
261        -- The user must be inserting rating level for rating scale.
262        --
263      else
264        -- if a rating level for a rating scale is being created then
265        -- get the min and max levels from competence table. Also get the
266        -- object version number
267        --
268        open get_rsc_levels;
269        fetch get_rsc_levels into l_min_scale_step, l_max_scale_step, l_obj_ver_number_cpn_or_rsc;
270        close get_rsc_levels;
271        --
272        -- lock the row in the rating scale table
273        --
274        per_rsc_shd.lck(p_rating_scale_id 	=> p_rating_scale_id
275 		      ,p_object_version_number  => l_obj_ver_number_cpn_or_rsc);
276        --
277        -- call rating level api to insert the level for the rating scale
278        -- in the rating level table
279        --
280         per_rtl_ins.ins
281  	(p_validate                         =>     FALSE,
282   	p_effective_date                    =>     p_effective_date,
283   	p_name                              =>     p_name,
284   	p_business_group_id                 =>     p_business_group_id,
285   	p_step_value                        =>     p_step_value,
286   	p_behavioural_indicator             =>     p_behavioural_indicator,
287   	p_rating_scale_id                   =>     p_rating_scale_id,
288   	p_competence_id                     =>     null,
289   	p_attribute_category           	=>     p_attribute_category,
290   	p_attribute1                   	=>     p_attribute1,
291   	p_attribute2                   	=>     p_attribute2,
292   	p_attribute3                       	=>     p_attribute3,
293   	p_attribute4                   	=>     p_attribute4,
294   	p_attribute5                   	=>     p_attribute5,
295   	p_attribute6                   	=>     p_attribute6,
296   	p_attribute7                   	=>     p_attribute7,
297   	p_attribute8                   	=>     p_attribute8,
298   	p_attribute9                   	=>     p_attribute9,
299   	p_attribute10                  	=>     p_attribute10,
300   	p_attribute11                  	=>     p_attribute11,
301   	p_attribute12                  	=>     p_attribute12,
302   	p_attribute13                  	=>     p_attribute13,
303   	p_attribute14                  	=>     p_attribute14,
304   	p_attribute15                  	=>     p_attribute15,
305   	p_attribute16                  	=>     p_attribute16,
306   	p_attribute17                  	=>     p_attribute17,
307   	p_attribute18                  	=>     p_attribute18,
308   	p_attribute19                  	=>     p_attribute19,
309   	p_attribute20                  	=>     p_attribute20,
310   	p_rating_level_id              	=>     l_rating_level_id,
311   	p_object_version_number        	=>     l_object_version_number
312   	);
313   	--
314   	-- call the translation table handler
315 
316   	 per_rtx_ins.ins_tl
317  	(p_rating_level_id              =>   l_rating_level_id,
318   	 p_language_code                =>   l_language_code,
319   	 p_name                        	=>   p_name,
320   	 p_behavioural_indicator        =>   p_behavioural_indicator);
321 
322         -- check if the step value passed in is less than the one held in the
323         -- rating scale table
324   	--
325         if (p_step_value < nvl(l_min_scale_step,0)) then
326          --
327          -- call the rating scale row handler api to update the min step level
328   	 -- column in the rating scale table
329    	 --
330  	 per_rsc_upd.upd
331          (p_validate                    =>	FALSE
332   	 ,p_effective_date              =>      p_effective_date
333   	 ,p_rating_scale_id             =>	p_rating_scale_id
334   	 ,p_object_version_number       =>	l_obj_ver_number_cpn_or_rsc
335   	 ,p_min_scale_step	 	=>	p_step_value
336   	 );
337 	 --
338          -- check if the step value passed in is greater than the one held in the
339          -- rating scale table
340          --
341         elsif (p_step_value > nvl(l_max_scale_step,0)) then
342          --
343          -- call the rating scale row handler api to update the max step level
344   	 -- column in the rating scale table
345    	 --
346          per_rsc_upd.upd
347          (p_validate                    =>	FALSE
348   	 ,p_effective_date             	=>      p_effective_date
349   	 ,p_rating_scale_id             =>	p_rating_scale_id
350   	 ,p_object_version_number      	=>	l_obj_ver_number_cpn_or_rsc
351   	 ,p_max_scale_step	 	=>	p_step_value
352   	 );
353         end if;
354      end if;
355      --
356   hr_utility.set_location(l_proc, 8);
357   --
358   -- Call After Process User Hook
359   --
360   begin
361 	hr_rating_levels_bk1.create_rating_level_a	(
362 	 p_language_code                     =>     l_language_code,
363          p_effective_date                    =>     p_effective_date,
364          p_name                              =>     p_name,
365          p_business_group_id                 =>     p_business_group_id,
366          p_step_value                        =>     p_step_value,
367          p_behavioural_indicator             =>     p_behavioural_indicator,
368          p_rating_scale_id                   =>     p_rating_scale_id,
369          p_competence_id                     =>     p_competence_id,
370          p_attribute_category                =>     p_attribute_category,
371          p_attribute1                        =>     p_attribute1,
372          p_attribute2                        =>     p_attribute2,
373          p_attribute3                        =>     p_attribute3,
374          p_attribute4                        =>     p_attribute4,
375          p_attribute5                        =>     p_attribute5,
376          p_attribute6                        =>     p_attribute6,
377          p_attribute7                        =>     p_attribute7,
378          p_attribute8                        =>     p_attribute8,
379          p_attribute9                        =>     p_attribute9,
380          p_attribute10                       =>     p_attribute10,
381          p_attribute11                       =>     p_attribute11,
382          p_attribute12                       =>     p_attribute12,
383          p_attribute13                       =>     p_attribute13,
384          p_attribute14                       =>     p_attribute14,
385          p_attribute15                       =>     p_attribute15,
386          p_attribute16                       =>     p_attribute16,
387          p_attribute17                       =>     p_attribute17,
388          p_attribute18                       =>     p_attribute18,
389          p_attribute19                       =>     p_attribute19,
390          p_attribute20                       =>     p_attribute20,
391          p_rating_level_id                   =>     l_rating_level_id,
392          p_object_version_number             =>     l_object_version_number,
393          p_obj_ver_number_cpn_or_rsc         =>     l_obj_ver_number_cpn_or_rsc
394 	);
395       exception
396 	   when hr_api.cannot_find_prog_unit then
397 		  hr_api.cannot_find_prog_unit_error
398 				(p_module_name	=> 'create_rating_level',
399 				 p_hook_type	=> 'AP'
400 				);
401   end;
402   --
403   -- End of After process user hook
404   --
405   -- When in validation only mode raise the Validate_Enabled exception
406   --
407   if p_validate then
408     raise hr_api.validate_enabled;
409   end if;
410   --
411   -- Set all output arguments
412   --
413   p_rating_level_id		:= l_rating_level_id;
414   p_object_version_number	:= l_object_version_number;
415   p_obj_ver_number_cpn_or_rsc	:= l_obj_ver_number_cpn_or_rsc;
416   --
417   hr_utility.set_location(' Leaving:'||l_proc, 11);
418 exception
419   when hr_api.validate_enabled then
420     --
421     -- As the Validate_Enabled exception has been raised
422     -- we must rollback to the savepoint
423     --
424     ROLLBACK TO create_rating_level;
425     --
426     -- Only set output warning arguments
427     -- (Any key or derived arguments must be set to null
428     -- when validation only mode is being used.)
429     --
430     p_rating_level_id          	:= null;
431     p_object_version_number  	:= null;
432     p_obj_ver_number_cpn_or_rsc	:= null;
433     --
434     --
435   when others then
436     --
437     -- A validation or unexpected error has occurred
438     --
439     -- Added as part of fix to bug 632482
440     --
441     p_rating_level_id           := null;
442     p_object_version_number     := null;
443     p_obj_ver_number_cpn_or_rsc := null;
444     ROLLBACK TO create_rating_level;
445     raise;
446     --
447     -- End of fix.
448     --
449     hr_utility.set_location(' Leaving:'||l_proc, 12);
450 end create_rating_level;
451 --
452 --
453 -- ---------------------------------------------------------------------------
454 -- |-----------------------< <update_rating_level> >--------------------------|
455 -- ---------------------------------------------------------------------------
456 --
457 -- Validate the language parameter. l_language_code should be passed
458 -- instead of p_language_code from now on, to allow an IN OUT parameter to
459 -- be passed through.
460 --
461 procedure update_rating_level
462  (p_language_code                in varchar2 default hr_api.userenv_lang,
463   p_validate                     in boolean         default false,
464   p_effective_date               in date,
465   p_rating_level_id              in number,
466   p_object_version_number        in out nocopy number,
467   p_name                         in varchar2         default hr_api.g_varchar2,
468   p_behavioural_indicator        in varchar2         default hr_api.g_varchar2,
469   p_attribute_category           in varchar2         default hr_api.g_varchar2,
470   p_attribute1                   in varchar2         default hr_api.g_varchar2,
471   p_attribute2                   in varchar2         default hr_api.g_varchar2,
472   p_attribute3                   in varchar2         default hr_api.g_varchar2,
473   p_attribute4                   in varchar2         default hr_api.g_varchar2,
474   p_attribute5                   in varchar2         default hr_api.g_varchar2,
475   p_attribute6                   in varchar2         default hr_api.g_varchar2,
476   p_attribute7                   in varchar2         default hr_api.g_varchar2,
477   p_attribute8                   in varchar2         default hr_api.g_varchar2,
478   p_attribute9                   in varchar2         default hr_api.g_varchar2,
479   p_attribute10                  in varchar2         default hr_api.g_varchar2,
480   p_attribute11                  in varchar2         default hr_api.g_varchar2,
481   p_attribute12                  in varchar2         default hr_api.g_varchar2,
482   p_attribute13                  in varchar2         default hr_api.g_varchar2,
483   p_attribute14                  in varchar2         default hr_api.g_varchar2,
484   p_attribute15                  in varchar2         default hr_api.g_varchar2,
485   p_attribute16                  in varchar2         default hr_api.g_varchar2,
486   p_attribute17                  in varchar2         default hr_api.g_varchar2,
487   p_attribute18                  in varchar2         default hr_api.g_varchar2,
488   p_attribute19                  in varchar2         default hr_api.g_varchar2,
489   p_attribute20                  in varchar2         default hr_api.g_varchar2
490   ) is
491   --
492   -- Declare cursors and local variables
493   --
494   l_proc                	varchar2(72) := g_package||'update_rating_level';
495   l_object_version_number	per_rating_levels.object_version_number%TYPE;
496   l_language_code               per_rating_levels_tl.language%TYPE;
497 begin
498   hr_utility.set_location('Entering:'|| l_proc, 5);
499   --
500   -- Issue a savepoint.
501   --
502   savepoint update_rating_level;
503   l_language_code := p_language_code;
504   hr_utility.set_location(l_proc, 6);
505   --
506   -- Call Before Process User Hook
507   --
508   begin
509 	hr_rating_levels_bk2.update_rating_level_b	(
510 	   p_language_code               =>     l_language_code,
511            p_effective_date               =>     p_effective_date,
512            p_rating_level_id              =>     p_rating_level_id,
513            p_object_version_number        =>     p_object_version_number,
514            p_name                         =>     p_name,
515            p_behavioural_indicator        =>     p_behavioural_indicator,
516            p_attribute_category           =>     p_attribute_category,
517            p_attribute1                   =>     p_attribute1,
518            p_attribute2                   =>     p_attribute2,
519            p_attribute3                   =>     p_attribute3,
520            p_attribute4                   =>     p_attribute4,
521            p_attribute5                   =>     p_attribute5,
522            p_attribute6                   =>     p_attribute6,
523            p_attribute7                   =>     p_attribute7,
524            p_attribute8                   =>     p_attribute8,
525            p_attribute9                   =>     p_attribute9,
526            p_attribute10                  =>     p_attribute10,
527            p_attribute11                  =>     p_attribute11,
528            p_attribute12                  =>     p_attribute12,
529            p_attribute13                  =>     p_attribute13,
530            p_attribute14                  =>     p_attribute14,
531            p_attribute15                  =>     p_attribute15,
532            p_attribute16                  =>     p_attribute16,
533            p_attribute17                  =>     p_attribute17,
534            p_attribute18                  =>     p_attribute18,
535            p_attribute19                  =>     p_attribute19,
536            p_attribute20                  =>     p_attribute20
537 	);
538       exception
539 	   when hr_api.cannot_find_prog_unit then
540 		  hr_api.cannot_find_prog_unit_error
541 				(p_module_name	=> 'update_rating_level',
542 				 p_hook_type	=> 'BP'
543 				);
544   end;
545   --
546   -- End of Before Process User Hook call
547   --
548   -- Validation in addition to Table Handlers
549   --
550   hr_utility.set_location(l_proc, 7);
551   --
552   -- Process Logic
553   --
554   l_object_version_number := p_object_version_number;
555   --
556  per_rtl_upd.upd
557  (p_validate                     =>	FALSE,
558   p_effective_date               =>     p_effective_date,
559   p_rating_level_id              =>     p_rating_level_id,
560   p_object_version_number        =>     l_object_version_number,
561   p_name                         =>     p_name,
562   p_behavioural_indicator        =>     p_behavioural_indicator,
563   p_attribute_category           =>     p_attribute_category,
564   p_attribute1                   =>     p_attribute1,
565   p_attribute2                   =>     p_attribute2,
566   p_attribute3                   =>     p_attribute3,
567   p_attribute4                   =>     p_attribute4,
568   p_attribute5                   =>     p_attribute5,
569   p_attribute6                   =>     p_attribute6,
570   p_attribute7                   =>     p_attribute7,
571   p_attribute8                   =>     p_attribute8,
572   p_attribute9                   =>     p_attribute9,
573   p_attribute10                  =>     p_attribute10,
574   p_attribute11                  =>     p_attribute11,
575   p_attribute12                  =>     p_attribute12,
576   p_attribute13                  =>     p_attribute13,
577   p_attribute14                  =>     p_attribute14,
578   p_attribute15                  =>     p_attribute15,
579   p_attribute16                  =>     p_attribute16,
580   p_attribute17                  =>     p_attribute17,
581   p_attribute18                  =>     p_attribute18,
582   p_attribute19                  =>     p_attribute19,
583   p_attribute20                  =>     p_attribute20
584   );
585   --
586   --call the translation table
587   --
588   per_rtx_upd.upd_tl
589   (p_language_code               =>     l_language_code
590   ,p_rating_level_id             =>     p_rating_level_id
591   ,p_name                        =>     p_name
592   ,p_behavioural_indicator       =>     p_behavioural_indicator
593   );
594   hr_utility.set_location(l_proc, 8);
595   --
596   -- Call After Process User Hook
597   --
598   begin
599 	hr_rating_levels_bk2.update_rating_level_a	(
600 	   p_language_code                =>     l_language_code,
601            p_effective_date               =>     p_effective_date,
602            p_rating_level_id              =>     p_rating_level_id,
603            p_object_version_number        =>     l_object_version_number,
604            p_name                         =>     p_name,
605            p_behavioural_indicator        =>     p_behavioural_indicator,
606            p_attribute_category           =>     p_attribute_category,
607            p_attribute1                   =>     p_attribute1,
608            p_attribute2                   =>     p_attribute2,
609            p_attribute3                   =>     p_attribute3,
610            p_attribute4                   =>     p_attribute4,
611            p_attribute5                   =>     p_attribute5,
612            p_attribute6                   =>     p_attribute6,
613            p_attribute7                   =>     p_attribute7,
614            p_attribute8                   =>     p_attribute8,
615            p_attribute9                   =>     p_attribute9,
616            p_attribute10                  =>     p_attribute10,
617            p_attribute11                  =>     p_attribute11,
618            p_attribute12                  =>     p_attribute12,
619            p_attribute13                  =>     p_attribute13,
620            p_attribute14                  =>     p_attribute14,
621            p_attribute15                  =>     p_attribute15,
622            p_attribute16                  =>     p_attribute16,
623            p_attribute17                  =>     p_attribute17,
624            p_attribute18                  =>     p_attribute18,
625            p_attribute19                  =>     p_attribute19,
626            p_attribute20                  =>     p_attribute20
627 	);
628       exception
629 	   when hr_api.cannot_find_prog_unit then
630 		  hr_api.cannot_find_prog_unit_error
631 				(p_module_name	=> 'update_rating_level',
632 				 p_hook_type	=> 'AP'
633 				);
634   end;
635   --
636   -- End After Process User Hook
637   --
638   -- When in validation only mode raise the Validate_Enabled exception
639   --
640   if p_validate then
641     raise hr_api.validate_enabled;
642   end if;
643   --
644   -- Set all output arguments. l_object_version_number now has the new
645   -- object version number as the update was successful
646   --
647   p_object_version_number  := l_object_version_number;
648   --
649   hr_utility.set_location(' Leaving:'||l_proc, 11);
650 exception
651   when hr_api.validate_enabled then
652     --
653     -- As the Validate_Enabled exception has been raised
654     -- we must rollback to the savepoint
655     --
656     ROLLBACK TO update_rating_level;
657     --
658     -- Only set output warning arguments and in out arguments back
659     -- to their IN value
660     -- (Any key or derived arguments must be set to null
661     -- when validation only mode is being used.)
662     --
663     p_object_version_number  := l_object_version_number;
664     --
665     --
666   when others then
667     --
668     -- A validation or unexpected error has occurred
669     --
670     -- Added as part of fix to bug 632482
671     --
672     p_object_version_number  := l_object_version_number;
673     ROLLBACK TO update_rating_level;
674     raise;
675     --
676     -- End of fix.
677     --
678     hr_utility.set_location(' Leaving:'||l_proc, 12);
679 --
680 end update_rating_level;
681 --
682 --
683 -- ---------------------------------------------------------------------------
684 -- |-----------------------< <delete_rating_level> >--------------------------|
685 -- ---------------------------------------------------------------------------
686 --
687 procedure delete_rating_level
688 (p_validate                           in  boolean default false,
689  p_rating_level_id                    in  number,
690  p_object_version_number              in  number,
691  p_obj_ver_number_cpn_or_rsc	      out nocopy number
692 ) is
693   --
694   l_competence_id		per_competences.competence_id%TYPE;
695   l_rating_scale_id		per_rating_scales.rating_scale_id%TYPE;
696   --
697   -- Declare cursors and local variables
698   --
699   --
700   -- Get values from competence table
701   --
702   Cursor get_competence_values is
703   select cpn.competence_id,cpn.object_version_number
704 	,cpn.min_level, cpn.max_level
705   from   per_competences cpn
706 	,per_rating_levels rtl
707   where  rtl.competence_id   = cpn.competence_id
708   and    rtl.rating_level_id = p_rating_level_id;
709   --
710   -- Get values from rating scale table
711   --
712   Cursor get_rating_scale_values is
713   select rsc.rating_scale_id,rsc.object_version_number
714 	,rsc.min_scale_step, rsc.max_scale_step
715   from   per_rating_scales rsc
716 	,per_rating_levels rtl
717   where  rtl.rating_scale_id  = rsc.rating_scale_id
718   and    rtl.rating_level_id = p_rating_level_id;
719   --
720   -- Cursor to get min and max rating levels for
721   -- competence from the rating level table.
722   --
723  Cursor get_cpn_levels is
724  select min(step_value),  max(step_value)
725  from 	per_rating_levels
726  where	competence_id    = l_competence_id;
727  --
728  --
729  -- Cursor to get min and max levels for
730  -- rating scale from the rating level table.
731  --
732  Cursor get_rsc_levels is
733  select min(step_value), max(step_value)
734  from 	per_rating_levels
735  where	rating_scale_id  = l_rating_scale_id;
736   --
737   --
738   l_proc                	varchar2(72) := g_package||'delete_rating_level';
739   l_obj_ver_number_cpn_or_rsc	number;
740   --
741   l_min_step			per_rating_levels.step_value%TYPE;
742   l_max_step			per_rating_levels.step_value%TYPE;
743   l_min_level			per_competences.min_level%TYPE;
744   l_max_level			per_competences.max_level%TYPE;
745   l_min_scale_step		per_rating_scales.min_scale_step%TYPE;
746   l_max_scale_step		per_rating_scales.max_scale_step%TYPE;
747   l_effective_date		date := to_date('01/01/1900','DD/MM/YYYY');
748   -- the l_effective_date parameter is set as it is a mandatory parameter on the
749   -- competence and the rating scale api's. The actual date value itself has no
750   -- particular use at all and is not used for any sort of validation in the
751   -- api.
752 begin
753   hr_utility.set_location('Entering:'|| l_proc, 5);
754   --
755   -- Issue a savepoint.
756   --
757   savepoint delete_rating_level;
758   hr_utility.set_location(l_proc, 6);
759   --
760   -- Call Before Process User Hook
761   --
762   begin
763 	hr_rating_levels_bk3.delete_rating_level_b
764 		(
765 		p_rating_level_id        =>  p_rating_level_id,
766 		p_object_version_number  =>  p_object_version_number
767 		);
768       exception
769 	   when hr_api.cannot_find_prog_unit then
770 		  hr_api.cannot_find_prog_unit_error
771 				(p_module_name	=> 'delete_rating_level',
772 				 p_hook_type	=> 'BP'
773 				);
774   end;
775   --
776   -- End of Before Process User hook
777   --
778   -- Validation in addition to Table Handlers
779   --
780   hr_utility.set_location(l_proc, 7);
781   --
782   -- Process Logic
783   -- 1) Get min and max step value from rating levels.
784   --    if inserting a rating level of competence then:
785   --      - get min_level, max_level,competence id and object version number
786   --        of competence from per_competences
787   --    if inserting a rating level of rating scale
788   --      - get min_level, max_level,rating scale id and object version number
789   --        of rating scale from per_rating_scales
790   -- 2) place lock on competence or rating scale
791   -- 3) delete row in rating levels
792   -- 4) update competence or rating scale
793   --
794     --
795     -- At this point we dont know to which parent the rating level belongs
796     -- It could be a child of competence or rating scale.
797     --
798     -- opening cursor to check againts competence first.
799     --
800     open  get_competence_values;
801     fetch get_competence_values into l_competence_id, l_obj_ver_number_cpn_or_rsc
802 				    ,l_min_level,  l_max_level;
803     close get_competence_values;
804     --
805     -- if the rating level was for a competence deal with competence
806     --
807     if l_competence_id is not null then
808       --
809       -- As We have found the right parent, lock the competence row
810       --
811          per_cpn_shd.lck(p_competence_id  		=> l_competence_id
812     	                ,p_object_version_number  	=> l_obj_ver_number_cpn_or_rsc);
813 
814       -- delete the translation table first
815       --
816       per_rtx_del.del_tl
817      (p_rating_level_id          => p_rating_level_id
818       );
819       --
820       -- delete the rating level from the rating level table
821       --
822          per_rtl_del.del
823          (p_validate			=> FALSE
824          ,p_rating_level_id  		=> p_rating_level_id
825          ,p_object_version_number 	=> p_object_version_number
826          );
827       --
828       --
829       -- if the rating level was for a competence then get the min and max
830       -- levels from the rating level table.
831       --
832       open  get_cpn_levels;
833       fetch get_cpn_levels into l_min_step, l_max_step;
834       close get_cpn_levels;
835 
836       --
837       -- call competence api to update the level for the competence
838       --
839       --
840       if (l_min_step < nvl(l_min_level,0)) then
841          --
842   	 -- call the competence row handler api to update the min level
843   	 -- column in the competence table
844   	 --
845 	 per_cpn_upd.upd
846          (p_validate                   	=>	FALSE,
847   	 p_effective_date              	=>      l_effective_date,
848   	 p_competence_id               	=>	l_competence_id,
849   	 p_object_version_number    	=>	l_obj_ver_number_cpn_or_rsc,
850   	 p_min_level		 	=>	l_min_level
851   	 );
852          --
853          -- check if the step value passed in is greater than the one held in the
854          -- competence table
855          --
856       elsif (l_max_step > nvl(l_max_level,0)) then
857          --
858 	 -- call the competence row handler api to update the max level
859   	 -- column in the competence table
860   	 --
861 	 per_cpn_upd.upd
862          (p_validate                   	=>	FALSE,
863   	 p_effective_date              	=>      l_effective_date,
864   	 p_competence_id               	=>	l_competence_id,
865   	 p_object_version_number    	=>	l_obj_ver_number_cpn_or_rsc,
866   	 p_max_level		 	=>	l_max_level
867   	 );
868 	 --
869          --
870          -- if there is only one step left then we want to make sure that
871          -- whatever the value in the min_level column in per_competences
872          -- table as long as the last value is not greater than 0, we need to
873          -- update the table with the new min value.
874 	 -- ** As a general rule the min_level column in per_competences
875 	 -- should not be greater than 0.
876 	 --
877        elsif (    (l_min_step = l_max_step)
878 	      and (l_min_step > l_min_level)
879 	      and (l_min_step <= 0 )
880              ) then
881          --
882 	 per_cpn_upd.upd
883          (p_validate                   	=>	FALSE
884   	 ,p_effective_date              =>      l_effective_date
885   	 ,p_competence_id               =>	l_competence_id
886   	 ,p_object_version_number    	=>	l_obj_ver_number_cpn_or_rsc
887   	 ,p_min_level			=>	l_min_level
888   	 );
889 	 --
890          -- Same as above but, this time for max_level column.
891          -- We want to make sure that the last value is not less than 0.
892 	 -- ** As a general rule, the max_level column in per_competences
893 	 -- should not be less than 0.
894 	 --
895        elsif (    (l_min_step = l_max_step)
896 	      and (l_max_step < l_max_level)
897 	      and (l_max_step >= 0 )
898              ) then
899          --
900 	 per_cpn_upd.upd
901          (p_validate                   	=>	FALSE
902   	 ,p_effective_date              =>      l_effective_date
903   	 ,p_competence_id               =>	l_competence_id
904   	 ,p_object_version_number    	=>	l_obj_ver_number_cpn_or_rsc
905   	 ,p_max_level			=>	l_max_level
906   	 );
907          --
908       end if;
909          --
910     else
911       -- The rating level must belong to the rating scale.
912       --
913 	 open  get_rating_scale_values;
914 	 fetch get_rating_scale_values into l_rating_scale_id, l_obj_ver_number_cpn_or_rsc
915 					   ,l_min_scale_step, l_max_scale_step;
916 	 close get_rating_scale_values;
917       --
918       --
919       -- lock the rating scale row
920       --
921           per_rsc_shd.lck(p_rating_scale_id  		=> l_rating_scale_id
922                          ,p_object_version_number  	=> l_obj_ver_number_cpn_or_rsc);
923 
924       -- delete the translation table first
925       --
926       per_rtx_del.del_tl
927      (p_rating_level_id          => p_rating_level_id
928       );
929       --
930       --
931       -- delete the rating level from the rating level table
932       --
933          per_rtl_del.del
934          (p_validate			=> FALSE
935          ,p_rating_level_id  		=> p_rating_level_id
936          ,p_object_version_number 	=> p_object_version_number
937          );
938       --
939       --
940       -- get the min and max levels for the rating scale from the
941       -- rating scale table
942       --
943          open  get_rsc_levels;
944          fetch get_rsc_levels into l_min_step, l_max_step;
945 	 close get_rsc_levels;
946       --
947       -- call rating scale api to update the level for the rating scale
948       --
949       --
950       if (l_min_step < nvl(l_min_scale_step,0)) then
951          --
952   	 -- call the rating scale row handler api to update the min scale step
953   	 -- column in the competence table
954   	 --
955 	 per_rsc_upd.upd
956          (p_validate                   	=>	FALSE
957   	 ,p_effective_date              =>      l_effective_date
958   	 ,p_rating_scale_id             =>	l_rating_scale_id
959   	 ,p_object_version_number    	=>	l_obj_ver_number_cpn_or_rsc
960   	 ,p_min_scale_step		=>	l_min_scale_step
961   	 );
962          --
963          -- check if the step value passed in is greater than the one held in the
964          -- rating scale table
965          --
966       elsif (l_max_step > nvl(l_max_scale_step,0)) then
967          --
968 	 -- call the rating scale row handler api to update the max scale step
969   	 -- column in the rating scale table
970   	 --
971 	 per_rsc_upd.upd
972          (p_validate                   	=>	FALSE
973   	 ,p_effective_date              =>      l_effective_date
974   	 ,p_rating_scale_id             =>	l_rating_scale_id
975   	 ,p_object_version_number    	=>	l_obj_ver_number_cpn_or_rsc
976   	 ,p_max_scale_step		=>	l_max_scale_step
977   	 );
978 	 --
979          -- if there is only one step left then we want to make sure that
980          -- whatever the value in the min_scale_step column in per_rating_scales
981          -- table as long as the last value is not greater than 0, we need to
982          -- update the table with the new min value.
983 	 -- ** As a general rule the min_scale_step column in per_rating_scales
984 	 -- should not be greater than 0.
985 	 --
986          --
987        elsif (    (l_min_step = l_max_step)
988 	      and (l_min_step > l_min_scale_step)
989 	      and (l_min_step <= 0 )
990              ) then
991          --
992 	 per_rsc_upd.upd
993          (p_validate                   	=>	FALSE
994   	 ,p_effective_date              =>      l_effective_date
995   	 ,p_rating_scale_id             =>	l_rating_scale_id
996   	 ,p_object_version_number    	=>	l_obj_ver_number_cpn_or_rsc
997   	 ,p_min_scale_step		=>	l_min_step
998   	 );
999 	 --
1000          -- Same as above but, this time for max_scale_step column.
1001          -- We want to make sure that the last value is not less than 0.
1002 	 -- ** As a general rule, the max_scale_step column in per_rating_scales
1003 	 -- should not be less than 0.
1004 	 --
1005        elsif (    (l_min_step = l_max_step)
1006 	      and (l_max_step < l_max_scale_step)
1007 	      and (l_max_step >= 0 )
1008              ) then
1009          --
1010 	 per_rsc_upd.upd
1011          (p_validate                   	=>	FALSE
1012   	 ,p_effective_date              =>      l_effective_date
1013   	 ,p_rating_scale_id             =>	l_rating_scale_id
1014   	 ,p_object_version_number    	=>	l_obj_ver_number_cpn_or_rsc
1015   	 ,p_max_scale_step		=>	l_max_step
1016   	 );
1017          --
1018        end if;
1019          --
1020     end if;
1021   --
1022   --
1023   hr_utility.set_location(l_proc, 8);
1024   --
1025   --
1026   -- Call After Process User Hook
1027   --
1028   begin
1029 	hr_rating_levels_bk3.delete_rating_level_a	(
1030 		p_rating_level_id        =>   p_rating_level_id,
1031 		p_object_version_number  =>   p_object_version_number
1032 		);
1033       exception
1034 	   when hr_api.cannot_find_prog_unit then
1035 		  hr_api.cannot_find_prog_unit_error
1036 				(p_module_name	=> 'delete_rating_level',
1037 				 p_hook_type	=> 'AP'
1038 				);
1039   end;
1040   --
1041   -- End of After Process User hook
1042   --
1043   -- When in validation only mode raise the Validate_Enabled exception
1044   --
1045   if p_validate then
1046     raise hr_api.validate_enabled;
1047   end if;
1048   --
1049   -- Set all output parameters
1050   --
1051   p_obj_ver_number_cpn_or_rsc	:= l_obj_ver_number_cpn_or_rsc;
1052   --
1053   hr_utility.set_location(' Leaving:'||l_proc, 11);
1054 exception
1055   when hr_api.validate_enabled then
1056     --
1057     -- As the Validate_Enabled exception has been raised
1058     -- we must rollback to the savepoint
1059     --
1060     ROLLBACK TO delete_rating_level;
1061     --
1062     -- Only set output warning arguments
1063     -- (Any key or derived arguments must be set to null
1064     -- when validation only mode is being used.)
1065     --
1066     p_obj_ver_number_cpn_or_rsc	:= null;
1067     --
1068     --
1069   when others then
1070     --
1071     -- A validation or unexpected error has occurred
1072     --
1073     -- Added as part of fix to bug 632482
1074     --
1075     p_obj_ver_number_cpn_or_rsc := null;
1076     ROLLBACK TO delete_rating_level;
1077     raise;
1078     --
1079     -- End of fix.
1080     --
1081     hr_utility.set_location(' Leaving:'||l_proc, 12);
1082 end delete_rating_level;
1083 --
1084 --
1085 -- ---------------------------------------------------------------------------
1086 -- |----------------< <create_or_update_rating_level> >-----------------------|
1087 -- ---------------------------------------------------------------------------
1088 --
1089 procedure create_or_update_rating_level
1090  (
1091   p_language_code                in varchar2        default hr_api.userenv_lang
1092  ,p_validate                     in boolean         default false
1093  ,p_effective_date               in date            default trunc(sysdate)
1094  ,p_name                         in varchar2        default null
1095  ,p_step_value                   in number          default 1
1096  ,p_rating_scale_name            in varchar2        default null
1097  ,p_behavioural_indicator        in varchar2        default null
1098  ,p_competence_name              in varchar2        default null
1099  ,p_translated_language          in varchar2        default null
1100  ,p_source_rating_level_name     in varchar2        default null
1101   ) is
1102 
1103  --
1104  -- Declare cursor and local variables
1105  --
1106  l_proc              varchar2(72) := g_package||'create_or_update_rating_level';
1107  l_rating_level_id       per_rating_levels.rating_level_id%TYPE;
1108  l_source_rating_level_id per_rating_levels.rating_level_id%TYPE;
1109  l_rating_scale_id       per_rating_levels.rating_scale_id%TYPE;
1110  l_step_value            per_rating_levels.step_value%TYPE;
1111  l_competence_id         per_rating_levels.competence_id%TYPE;
1112  l_ovn                   per_rating_levels.object_version_number%TYPE;
1113  l_source_ovn            per_rating_levels.object_version_number%TYPE;
1114  l_obj_ver_number_cpn_or_rsc   number;
1115  l_effective_date        date;
1116  l_language_code         varchar2(10);
1117  l_translated_language   varchar2(20);
1118 
1119  cursor csr_rtl(p_rating_level_name in varchar2
1120                ,p_rating_scale_id in number) is
1121   select rating_level_id , object_version_number , step_value
1122   from per_rating_levels
1123   where business_group_id is null
1124   and name = p_rating_level_name
1125   and step_value = p_step_value
1126   and rating_scale_id = p_rating_scale_id;
1127 
1128  cursor csr_rsc is
1129   select rating_scale_id
1130   from per_rating_scales
1131   where business_group_id is null
1132   and name = p_rating_scale_name;
1133 
1134  cursor csr_comp is
1135   select competence_id
1136   from per_competences
1137   where business_group_id is null
1138   and name = p_competence_name;
1139 
1140 begin
1141 
1142   hr_utility.set_location('Entering... ' || l_proc,10);
1143   --
1144   -- Issue a savepoint.
1145   --
1146   savepoint create_or_update_rating_level;
1147 
1148   hr_rating_levels_api.g_ignore_df := 'Y';
1149 
1150   if (p_language_code is NULL) then
1151     l_language_code :=  hr_api.userenv_lang;
1152   else
1153     l_language_code := p_language_code;
1154     -- BUG3668368
1155     hr_api.validate_language_code(p_language_code => l_language_code);
1156   end if;
1157 
1158   if (p_effective_date is NULL) then
1159     l_effective_date := trunc(sysdate);
1160   else
1161     l_effective_date := trunc(p_effective_date);
1162   end if;
1163   hr_utility.trace('l_effective_date : ' || l_effective_date);
1164 
1165   if (p_rating_scale_name is not NULL) then
1166     hr_utility.set_location(l_proc,40);
1167     open csr_rsc;
1168     fetch csr_rsc into l_rating_scale_id;
1169     if csr_rsc%NOTFOUND then
1170        close csr_rsc;
1171        fnd_message.set_name('PER','HR_51928_APT_RSC_NOT_EXIST');
1172        fnd_message.raise_error;
1173     end if;
1174     close csr_rsc;
1175     hr_utility.trace('l_rating_scale_id : ' || l_rating_scale_id);
1176   end if;
1177 
1178   IF (p_translated_language IS NULL AND p_source_rating_level_name IS NULL)
1179   THEN
1180     hr_utility.set_location(l_proc,20);
1181 
1182     open csr_rtl(p_name,l_rating_scale_id);
1183     fetch csr_rtl into l_rating_level_id,l_ovn,l_step_value;
1184     if csr_rtl%NOTFOUND then
1185        close csr_rtl;
1186        l_rating_level_id := NULL;
1187        l_ovn := NULL;
1188     else
1189        close csr_rtl;
1190        hr_utility.set_location(l_proc,30);
1191     end if;
1192 
1193     hr_utility.trace('l_rating_level_id : ' || l_rating_level_id);
1194     hr_utility.trace('l_ovn             : ' || l_ovn);
1195     hr_utility.trace('l_step_value      : ' || l_step_value);
1196 
1197     hr_utility.set_location(l_proc,50);
1198 
1199     if (p_competence_name is not NULL) then
1200       hr_utility.trace('p_competence_name : ' || p_competence_name);
1201       open csr_comp;
1202       fetch csr_comp into l_competence_id;
1203       if csr_comp%NOTFOUND then
1204         close csr_comp;
1205         fnd_message.set_name('PER','HR_52251_CEL_COMP_ID_INVL');
1206         fnd_message.raise_error;
1207       end if;
1208       close csr_comp;
1209       hr_utility.trace('l_competence_id : ' || l_competence_id);
1210     end if;
1211 
1212 
1213     if (l_rating_level_id is null and l_ovn is null) then
1214       hr_utility.set_location(l_proc,60);
1215       if (p_step_value is NULL) then
1216         l_step_value := 1;
1217       else
1218         l_step_value := p_step_value;
1219       end if;
1220      --
1221      create_rating_level
1222        (p_language_code                => l_language_code
1223        ,p_validate                     => p_validate
1224        ,p_effective_date               => l_effective_date
1225        ,p_name                         => p_name
1226        ,p_step_value                   => l_step_value
1227        ,p_behavioural_indicator        => p_behavioural_indicator
1228        ,p_rating_scale_id              => l_rating_scale_id
1229        ,p_competence_id                => l_competence_id
1230        ,p_rating_level_id              => l_rating_level_id
1231        ,p_object_version_number        => l_ovn
1232        ,p_obj_ver_number_cpn_or_rsc    => l_obj_ver_number_cpn_or_rsc
1233      );
1234    else
1235      hr_utility.set_location(l_proc,70);
1236 
1237      if (p_step_value is not NULL and p_step_value <> l_step_value) then
1238        fnd_message.set_name('PER','HR_449168_NO_UPDATE_STEP_VALUE');
1239        fnd_message.raise_error;
1240      else
1241        update_rating_level
1242          (p_language_code                => l_language_code
1243          ,p_validate                     => p_validate
1244          ,p_effective_date               => l_effective_date
1245          ,p_name                         => p_name
1246          ,p_behavioural_indicator        => p_behavioural_indicator
1247          ,p_rating_level_id              => l_rating_level_id
1248          ,p_object_version_number        => l_ovn
1249        );
1250      end if;
1251    end if;
1252    --
1253  ELSE
1254   --
1255   -- p_translated_language is not NULL
1256   --
1257   hr_utility.set_location(l_proc,80);
1258 
1259   open csr_rtl(p_source_rating_level_name,l_rating_scale_id);
1260   fetch csr_rtl into l_source_rating_level_id,l_source_ovn,l_step_value;
1261   if csr_rtl%NOTFOUND then
1262      close csr_rtl;
1263      hr_utility.set_message(800,'HR_449191_SOURCE_RTL_INVALID');
1264      hr_utility.raise_error;
1265   else
1266      close csr_rtl;
1267      hr_utility.set_location(l_proc,90);
1268   end if;
1269   hr_utility.trace('l_source_rating_level_id : ' || l_source_rating_level_id);
1270   hr_utility.trace('l_source_ovn             : ' || l_ovn);
1271 
1272   l_translated_language := p_translated_language;
1273   hr_api.validate_language_code(p_language_code => l_translated_language);
1274 
1275   --
1276   --  MLS Processing
1277   --
1278   per_rtx_upd.upd_tl
1279   (p_language_code               =>     l_translated_language
1280   ,p_rating_level_id             =>     l_source_rating_level_id
1281   ,p_name			 =>     p_name
1282   ,p_behavioural_indicator       =>     p_behavioural_indicator
1283   );
1284   hr_utility.set_location(l_proc, 100);
1285   --
1286   -- Call After Process User Hook
1287   --
1288   begin
1289     hr_rating_levels_bk2.update_rating_level_a	(
1290    	p_language_code                =>     l_translated_language,
1291         p_effective_date               =>     l_effective_date,
1292         p_rating_level_id              =>     l_source_rating_level_id,
1293         p_object_version_number        =>     l_source_ovn,
1294         p_name                         =>     p_source_rating_level_name,
1295         p_behavioural_indicator        =>     p_behavioural_indicator,
1296         p_attribute_category           =>     NULL,
1297         p_attribute1                   =>     NULL,
1298         p_attribute2                   =>     NULL,
1299         p_attribute3                   =>     NULL,
1300         p_attribute4                   =>     NULL,
1301         p_attribute5                   =>     NULL,
1302         p_attribute6                   =>     NULL,
1303         p_attribute7                   =>     NULL,
1304         p_attribute8                   =>     NULL,
1305         p_attribute9                   =>     NULL,
1306         p_attribute10                  =>     NULL,
1307         p_attribute11                  =>     NULL,
1308         p_attribute12                  =>     NULL,
1309         p_attribute13                  =>     NULL,
1310         p_attribute14                  =>     NULL,
1311         p_attribute15                  =>     NULL,
1312         p_attribute16                  =>     NULL,
1313         p_attribute17                  =>     NULL,
1314         p_attribute18                  =>     NULL,
1315         p_attribute19                  =>     NULL,
1316         p_attribute20                  =>     NULL
1317 	);
1318       exception
1319 	   when hr_api.cannot_find_prog_unit then
1320                   hr_rating_levels_api.g_ignore_df	:= 'N';
1321 		  hr_api.cannot_find_prog_unit_error
1322 				(p_module_name	=> 'update_rating_level',
1323 				 p_hook_type	=> 'AP'
1324 				);
1325   end;
1326   --
1327   -- End After Process User Hook
1328   --
1329  END IF;
1330  hr_rating_levels_api.g_ignore_df	:= 'N';
1331  hr_utility.set_location('Leaving... ' || l_proc,110);
1332 exception
1333   when hr_api.validate_enabled then
1334     --
1335     -- As the Validate_Enabled exception has been raised
1336     -- we must rollback to the savepoint
1337     --
1338     ROLLBACK TO create_or_update_rating_level;
1339     --
1340     hr_rating_levels_api.g_ignore_df	:= 'N';
1341     --
1342     hr_utility.set_location('Leaving... ' || l_proc,120);
1343     --
1344   when others then
1345     --
1346     -- A validation or unexpected error has occurred
1347     --
1348     ROLLBACK TO create_or_update_rating_level;
1349     --
1350     hr_rating_levels_api.g_ignore_df	:= 'N';
1351     raise;
1352     --
1353 --
1354 end create_or_update_rating_level;
1355 --
1356 end hr_rating_levels_api;