DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_GRADE_API

Source


1 Package Body hr_grade_api as
2 /* $Header: pegrdapi.pkb 120.3.12020000.2 2012/07/05 02:45:43 amnaraya ship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(33) := '  hr_grade_api.';
7 --
8 --
9 -- ----------------------------------------------------------------------------
10 -- |------------------------< create_grade >----------------------------------|
11 -- ----------------------------------------------------------------------------
12 procedure create_grade
13   (p_validate                      in     boolean  default false
14   ,p_business_group_id             in     number
15   ,p_date_from                     in     date
16   ,p_sequence			   in	  number
17   ,p_effective_date		   in     date     default null
18   ,p_date_to                       in     date     default null
19   ,p_request_id			   in 	  number   default null
20   ,p_program_application_id        in 	  number   default null
21   ,p_program_id                    in 	  number   default null
22   ,p_program_update_date           in 	  date     default null
23   ,p_last_update_date              in 	  date     default null
24   ,p_last_updated_by               in 	  number   default null
25   ,p_last_update_login             in 	  number   default null
26   ,p_created_by                    in 	  number   default null
27   ,p_creation_date                 in 	  date     default null
28   ,p_attribute_category            in     varchar2 default null
29   ,p_attribute1                    in     varchar2 default null
30   ,p_attribute2                    in     varchar2 default null
31   ,p_attribute3                    in     varchar2 default null
32   ,p_attribute4                    in     varchar2 default null
33   ,p_attribute5                    in     varchar2 default null
34   ,p_attribute6                    in     varchar2 default null
35   ,p_attribute7                    in     varchar2 default null
36   ,p_attribute8                    in     varchar2 default null
37   ,p_attribute9                    in     varchar2 default null
38   ,p_attribute10                   in     varchar2 default null
39   ,p_attribute11                   in     varchar2 default null
40   ,p_attribute12                   in     varchar2 default null
41   ,p_attribute13                   in     varchar2 default null
42   ,p_attribute14                   in     varchar2 default null
43   ,p_attribute15                   in     varchar2 default null
44   ,p_attribute16                   in     varchar2 default null
45   ,p_attribute17                   in     varchar2 default null
46   ,p_attribute18                   in     varchar2 default null
47   ,p_attribute19                   in     varchar2 default null
48   ,p_attribute20                   in     varchar2 default null
49   ,p_information_category          in     varchar2 default null
50   ,p_information1 	           in     varchar2 default null
51   ,p_information2 	           in     varchar2 default null
52   ,p_information3 	           in     varchar2 default null
53   ,p_information4 	           in     varchar2 default null
54   ,p_information5 	           in     varchar2 default null
55   ,p_information6 	           in     varchar2 default null
56   ,p_information7 	           in     varchar2 default null
57   ,p_information8 	           in     varchar2 default null
58   ,p_information9 	           in     varchar2 default null
59   ,p_information10 	           in     varchar2 default null
60   ,p_information11 	           in     varchar2 default null
61   ,p_information12 	           in     varchar2 default null
62   ,p_information13 	           in     varchar2 default null
63   ,p_information14 	           in     varchar2 default null
64   ,p_information15 	           in     varchar2 default null
65   ,p_information16 	           in     varchar2 default null
66   ,p_information17 	           in     varchar2 default null
67   ,p_information18 	           in     varchar2 default null
68   ,p_information19 	           in     varchar2 default null
69   ,p_information20 	           in     varchar2 default null
70   ,p_segment1                      in     varchar2 default null
71   ,p_segment2                      in     varchar2 default null
72   ,p_segment3                      in     varchar2 default null
73   ,p_segment4                      in     varchar2 default null
74   ,p_segment5                      in     varchar2 default null
75   ,p_segment6                      in     varchar2 default null
76   ,p_segment7                      in     varchar2 default null
77   ,p_segment8                      in     varchar2 default null
78   ,p_segment9                      in     varchar2 default null
79   ,p_segment10                     in     varchar2 default null
80   ,p_segment11                     in     varchar2 default null
81   ,p_segment12                     in     varchar2 default null
82   ,p_segment13                     in     varchar2 default null
83   ,p_segment14                     in     varchar2 default null
84   ,p_segment15                     in     varchar2 default null
85   ,p_segment16                     in     varchar2 default null
86   ,p_segment17                     in     varchar2 default null
87   ,p_segment18                     in     varchar2 default null
88   ,p_segment19                     in     varchar2 default null
89   ,p_segment20                     in     varchar2 default null
90   ,p_segment21                     in     varchar2 default null
91   ,p_segment22                     in     varchar2 default null
92   ,p_segment23                     in     varchar2 default null
93   ,p_segment24                     in     varchar2 default null
94   ,p_segment25                     in     varchar2 default null
95   ,p_segment26                     in     varchar2 default null
96   ,p_segment27                     in     varchar2 default null
97   ,p_segment28                     in     varchar2 default null
98   ,p_segment29                     in     varchar2 default null
99   ,p_segment30                     in     varchar2 default null
100   ,p_language_code                 in     varchar2 default hr_api.userenv_lang
101   ,p_concat_segments               in     varchar2 default null
102   ,p_short_name			   in     varchar2 default null
103   ,p_grade_id                      out nocopy    number
104   ,p_object_version_number         out nocopy    number
105   ,p_grade_definition_id           in out nocopy number
106   ,p_name                          in out nocopy varchar2
107    ) is
108 --
109 -- Declare cursors and local variables
110 --
111    l_grade_id                 per_grades.grade_id%TYPE;
112    l_grade_definition_id      per_grades.grade_definition_id%TYPE := p_grade_definition_id;
113    l_business_group_id        per_grades.business_group_id%TYPE;
114    l_name                     per_grades.name%TYPE 	:= p_name;
115    l_proc                     varchar2(72) := g_package||'create_grade';
116    l_flex_num                 fnd_id_flex_segments.id_flex_num%TYPE;
117    l_object_version_number    per_grades.object_version_number%TYPE;
118    l_sequence		          per_grades.sequence%TYPE;
119    l_date_from                per_grades.date_from%TYPE;
120    l_date_to                  per_grades.date_to%TYPE;
121    l_effective_date           date := p_effective_date;
122    l_segment1                 varchar2(60) := p_segment1;
123    l_segment2                 varchar2(60) := p_segment2;
124    l_segment3                 varchar2(60) := p_segment3;
125    l_segment4                 varchar2(60) := p_segment4;
126    l_segment5                 varchar2(60) := p_segment5;
127    l_segment6                 varchar2(60) := p_segment6;
128    l_segment7                 varchar2(60) := p_segment7;
129    l_segment8                 varchar2(60) := p_segment8;
130    l_segment9                 varchar2(60) := p_segment9;
131    l_segment10                varchar2(60) := p_segment10;
132    l_segment11                varchar2(60) := p_segment11;
133    l_segment12                varchar2(60) := p_segment12;
134    l_segment13                varchar2(60) := p_segment13;
135    l_segment14                varchar2(60) := p_segment14;
136    l_segment15                varchar2(60) := p_segment15;
137    l_segment16                varchar2(60) := p_segment16;
138    l_segment17                varchar2(60) := p_segment17;
139    l_segment18                varchar2(60) := p_segment18;
140    l_segment19                varchar2(60) := p_segment19;
141    l_segment20                varchar2(60) := p_segment20;
142    l_segment21                varchar2(60) := p_segment21;
143    l_segment22                varchar2(60) := p_segment22;
144    l_segment23                varchar2(60) := p_segment23;
145    l_segment24                varchar2(60) := p_segment24;
146    l_segment25                varchar2(60) := p_segment25;
147    l_segment26                varchar2(60) := p_segment26;
148    l_segment27                varchar2(60) := p_segment27;
149    l_segment28                varchar2(60) := p_segment28;
150    l_segment29                varchar2(60) := p_segment29;
151    l_segment30                varchar2(60) := p_segment30;
152    l_language_code            varchar2(30) := p_language_code;
153    l_short_name               per_grades.short_name%TYPE;
154    --
155    -- variable to indicate whether key flex id parameter
156    -- enters the program with a value.
157    --
158    l_null_ind                 number(1)    := 0;
159    --
160    --
161 cursor isdel is
162        select pbg.grade_structure
163        from per_business_groups_perf pbg
164        where pbg.business_group_id = p_business_group_id;
165 
166    --
167    -- get per_grade_definition segment values where
168    -- grade_definition_id is known
169    --
170    cursor c_segments is
171      select segment1,
172             segment2,
173             segment3,
174             segment4,
175             segment5,
176             segment6,
177             segment7,
178             segment8,
179             segment9,
180             segment10,
181             segment11,
182             segment12,
183             segment13,
184             segment14,
185             segment15,
186             segment16,
187             segment17,
188             segment18,
189             segment19,
190             segment20,
191             segment21,
192             segment22,
193             segment23,
194             segment24,
195             segment25,
196             segment26,
197             segment27,
198             segment28,
199             segment29,
200             segment30
201        from per_grade_definitions
202       where grade_definition_id = l_grade_definition_id;
203 --
204 begin
205 --
206   hr_utility.set_location('Entering:'|| l_proc, 10);
207   --
208   -- Issue a savepoint
209   --
210   savepoint create_grade;
211   --
212   -- Validate the language parameter. l_language_code should be passed
213   -- instead of p_language_code from now on, to allow an IN OUT parameter to
214   -- be passed through.
215   --
216   hr_api.validate_language_code(p_language_code => l_language_code);
217   --
218   -- Truncate date_from and date_to
219   --
220   l_date_from      := trunc(p_date_from);
221   l_date_to        := trunc(p_date_to);
222   --
223   -- check that flex structure is valid
224   --
225   open isdel;
226   fetch isdel into l_flex_num;
227   if isdel%notfound
228   then
229      close isdel;
230      --
231      -- the flex structure has not been found
232      --
233      hr_utility.set_message(801, 'HR_6039_ALL_CANT_GET_FFIELD');
234      hr_utility.raise_error;
235   end if;
236   close isdel;
237   --
238   -- get segment values if p_grade_definition_id entered with a value
239   --
240   if l_grade_definition_id is not null
241   --
242   then
243   --
244      hr_utility.set_location(l_proc, 15);
245      --
246      -- set indicator to show p_grade_definition_id did not enter program null
247      --
248      l_null_ind := 1;
249      --
250      open c_segments;
251         fetch c_segments into
252                       l_segment1,
253                       l_segment2,
254                       l_segment3,
255                       l_segment4,
256                       l_segment5,
257                       l_segment6,
258                       l_segment7,
259                       l_segment8,
260                       l_segment9,
261                       l_segment10,
262                       l_segment11,
263                       l_segment12,
264                       l_segment13,
265                       l_segment14,
266                       l_segment15,
267                       l_segment16,
268                       l_segment17,
269                       l_segment18,
270                       l_segment19,
271                       l_segment20,
272                       l_segment21,
273                       l_segment22,
274                       l_segment23,
275                       l_segment24,
276                       l_segment25,
277                       l_segment26,
278                       l_segment27,
279                       l_segment28,
280                       l_segment29,
281                       l_segment30;
282      close c_segments;
283   end if;
284   --
285   begin
286   --
287   -- Call Before Process User hook for create_grade
288   --
289   hr_grade_bk1.create_grade_b
290     (p_business_group_id             => l_business_group_id
291     ,p_date_from                     => l_date_from
292     ,p_sequence		             => l_sequence
293     ,p_date_to                       => l_date_to
294     ,p_request_id	             => p_request_id
295     ,p_program_application_id        => p_program_application_id
296     ,p_program_id                    => p_program_id
297     ,p_program_update_date           => p_program_update_date
298     ,p_last_update_date              => p_last_update_date
299     ,p_last_updated_by               => p_last_updated_by
300     ,p_last_update_login             => p_last_update_login
301     ,p_created_by                    => p_created_by
302     ,p_creation_date                 => p_creation_date
303     ,p_attribute_category            => p_attribute_category
304     ,p_attribute1                    => p_attribute1
305     ,p_attribute2                    => p_attribute2
306     ,p_attribute3                    => p_attribute3
307     ,p_attribute4                    => p_attribute4
308     ,p_attribute5                    => p_attribute5
309     ,p_attribute6                    => p_attribute6
310     ,p_attribute7                    => p_attribute7
311     ,p_attribute8                    => p_attribute8
312     ,p_attribute9                    => p_attribute9
313     ,p_attribute10                   => p_attribute10
314     ,p_attribute11                   => p_attribute11
315     ,p_attribute12                   => p_attribute12
316     ,p_attribute13                   => p_attribute13
317     ,p_attribute14                   => p_attribute14
318     ,p_attribute15                   => p_attribute15
319     ,p_attribute16                   => p_attribute16
320     ,p_attribute17                   => p_attribute17
321     ,p_attribute18                   => p_attribute18
322     ,p_attribute19                   => p_attribute19
323     ,p_attribute20                   => p_attribute20
324     ,p_information_category          => p_information_category
325     ,p_information1                  => p_information1
326     ,p_information2                  => p_information2
327     ,p_information3                  => p_information3
328     ,p_information4                  => p_information4
329     ,p_information5                  => p_information5
330     ,p_information6                  => p_information6
331     ,p_information7                  => p_information7
332     ,p_information8                  => p_information8
333     ,p_information9                  => p_information9
334     ,p_information10                 => p_information10
335     ,p_information11                 => p_information11
336     ,p_information12                 => p_information12
337     ,p_information13                 => p_information13
338     ,p_information14                 => p_information14
339     ,p_information15                 => p_information15
340     ,p_information16                 => p_information16
341     ,p_information17                 => p_information17
342     ,p_information18                 => p_information18
343     ,p_information19                 => p_information19
344     ,p_information20 	             => p_information20
345     ,p_segment1                      => l_segment1
346     ,p_segment2                      => l_segment2
347     ,p_segment3                      => l_segment3
348     ,p_segment4                      => l_segment4
349     ,p_segment5                      => l_segment5
350     ,p_segment6                      => l_segment6
351     ,p_segment7                      => l_segment7
352     ,p_segment8                      => l_segment8
353     ,p_segment9                      => l_segment9
354     ,p_segment10                     => l_segment10
355     ,p_segment11                     => l_segment11
356     ,p_segment12                     => l_segment12
357     ,p_segment13                     => l_segment13
358     ,p_segment14                     => l_segment14
359     ,p_segment15                     => l_segment15
360     ,p_segment16                     => l_segment16
361     ,p_segment17                     => l_segment17
362     ,p_segment18                     => l_segment18
363     ,p_segment19                     => l_segment19
364     ,p_segment20                     => l_segment20
365     ,p_segment21                     => l_segment21
366     ,p_segment22                     => l_segment22
367     ,p_segment23                     => l_segment23
368     ,p_segment24                     => l_segment24
369     ,p_segment25                     => l_segment25
370     ,p_segment26                     => l_segment26
371     ,p_segment27                     => l_segment27
372     ,p_segment28                     => l_segment28
373     ,p_segment29                     => l_segment29
374     ,p_segment30                     => l_segment30
375     ,p_language_code                 => l_language_code
376     ,p_concat_segments               => p_concat_segments
377     ,p_grade_id                      => l_grade_id
378     ,p_object_version_number         => l_object_version_number
379     ,p_grade_definition_id           => l_grade_definition_id
380     ,p_name                          => l_name
381     ,p_effective_date		     => p_effective_date
382     ,p_short_name                    => p_short_name
383     );
384   exception
385     when hr_api.cannot_find_prog_unit then
386       hr_api.cannot_find_prog_unit_error
387         (p_module_name => 'CREATE_GRADE'
388         ,p_hook_type   => 'BP'
389         );
390   --
391   -- End of before hook process (create_grade)
392   --
393   end;
394   --
395   -- Process Logic
396   --
397   if l_grade_definition_id is null
398   then
399      --
400      -- Determine the Grade defintion by calling ins_or_sel
401      --
402      hr_utility.set_location(l_proc, 20);
403      --
404      hr_kflex_utility.ins_or_sel_keyflex_comb
405        (p_appl_short_name       => 'PER'
406        ,p_flex_code             => 'GRD'
407        ,p_flex_num              => l_flex_num
408        ,p_segment1              => l_segment1
409        ,p_segment2              => l_segment2
410        ,p_segment3              => l_segment3
411        ,p_segment4              => l_segment4
412        ,p_segment5              => l_segment5
413        ,p_segment6              => l_segment6
414        ,p_segment7              => l_segment7
415        ,p_segment8              => l_segment8
416        ,p_segment9              => l_segment9
417        ,p_segment10             => l_segment10
418        ,p_segment11             => l_segment11
419        ,p_segment12             => l_segment12
420        ,p_segment13             => l_segment13
421        ,p_segment14             => l_segment14
422        ,p_segment15             => l_segment15
423        ,p_segment16             => l_segment16
424        ,p_segment17             => l_segment17
425        ,p_segment18             => l_segment18
426        ,p_segment19             => l_segment19
427        ,p_segment20             => l_segment20
428        ,p_segment21             => l_segment21
429        ,p_segment22             => l_segment22
430        ,p_segment23             => l_segment23
431        ,p_segment24             => l_segment24
432        ,p_segment25             => l_segment25
433        ,p_segment26             => l_segment26
434        ,p_segment27             => l_segment27
435        ,p_segment28             => l_segment28
436        ,p_segment29             => l_segment29
437        ,p_segment30             => l_segment30
438        ,p_concat_segments_in    => p_concat_segments
439        ,p_ccid                  => l_grade_definition_id
440        ,p_concat_segments_out   => l_name
441        );
442   end if;
443   --
444   if l_grade_definition_id is not null
445   then
446   --
447   -- Insert Grade.
448   --
449      hr_utility.set_location(l_proc, 30);
450      --
451      per_grd_ins.ins
452        (p_effective_date               => p_effective_date
453        ,p_business_group_id            => p_business_group_id
454        ,p_grade_definition_id          => l_grade_definition_id
455        ,p_date_from                    => l_date_from
456        ,p_sequence                     => p_sequence
457        ,p_date_to                      => l_date_to
458        ,p_name                         => l_name
459        ,p_request_id                   => p_request_id
460        ,p_program_application_id       => p_program_application_id
461        ,p_program_id                   => p_program_id
462        ,p_program_update_date          => p_program_update_date
463        ,p_attribute_category           => p_attribute_category
464        ,p_attribute1                   => p_attribute1
465        ,p_attribute2                   => p_attribute2
466        ,p_attribute3                   => p_attribute3
467        ,p_attribute4                   => p_attribute4
468        ,p_attribute5                   => p_attribute5
469        ,p_attribute6                   => p_attribute6
470        ,p_attribute7                   => p_attribute7
471        ,p_attribute8                   => p_attribute8
472        ,p_attribute9                   => p_attribute9
473        ,p_attribute10                  => p_attribute10
474        ,p_attribute11                  => p_attribute11
475        ,p_attribute12                  => p_attribute12
476        ,p_attribute13                  => p_attribute13
477        ,p_attribute14                  => p_attribute14
478        ,p_attribute15                  => p_attribute15
479        ,p_attribute16                  => p_attribute16
480        ,p_attribute17                  => p_attribute17
481        ,p_attribute18                  => p_attribute18
482        ,p_attribute19                  => p_attribute19
483        ,p_attribute20                  => p_attribute20
484        ,p_information_category         => p_information_category
485        ,p_information1                 => p_information1
486        ,p_information2                 => p_information2
487        ,p_information3                 => p_information3
488        ,p_information4                 => p_information4
489        ,p_information5                 => p_information5
490        ,p_information6                 => p_information6
491        ,p_information7                 => p_information7
492        ,p_information8                 => p_information8
493        ,p_information9                 => p_information9
494        ,p_information10                => p_information10
495        ,p_information11                => p_information11
496        ,p_information12                => p_information12
497        ,p_information13                => p_information13
498        ,p_information14                => p_information14
499        ,p_information15                => p_information15
500        ,p_information16                => p_information16
501        ,p_information17                => p_information17
502        ,p_information18                => p_information18
503        ,p_information19                => p_information19
504        ,p_information20                => p_information20
505        ,p_grade_id                     => l_grade_id
506        ,p_object_version_number        => l_object_version_number
507        ,p_short_name		       => p_short_name
508        );
509      --
510      hr_utility.set_location(l_proc, 40);
511   --
512   end if;
513   --
514   -- MLS Processing
515   --
516   per_gdt_ins.ins_tl
517   (p_language_code         => l_language_code
518   ,p_grade_id              => l_grade_id
519   ,p_name                  => p_name
520   );
521   --
522   --
523   -- Call After Process hook for create_grade
524   --
525   begin
526     hr_grade_bk1.create_grade_a
527     (p_business_group_id             => l_business_group_id
528     ,p_date_from                     => l_date_from
529     ,p_sequence			     => l_sequence
530     ,p_date_to                       => l_date_to
531     ,p_request_id		     => p_request_id
532     ,p_program_application_id        => p_program_application_id
533     ,p_program_id                    => p_program_id
534     ,p_program_update_date           => p_program_update_date
535     ,p_last_update_date              => p_last_update_date
536     ,p_last_updated_by               => p_last_updated_by
537     ,p_last_update_login             => p_last_update_login
538     ,p_created_by                    => p_created_by
539     ,p_creation_date                 => p_creation_date
540     ,p_attribute_category            => p_attribute_category
541     ,p_attribute1                    => p_attribute1
542     ,p_attribute2                    => p_attribute2
543     ,p_attribute3                    => p_attribute3
544     ,p_attribute4                    => p_attribute4
545     ,p_attribute5                    => p_attribute5
546     ,p_attribute6                    => p_attribute6
547     ,p_attribute7                    => p_attribute7
548     ,p_attribute8                    => p_attribute8
549     ,p_attribute9                    => p_attribute9
550     ,p_attribute10                   => p_attribute10
551     ,p_attribute11                   => p_attribute11
552     ,p_attribute12                   => p_attribute12
553     ,p_attribute13                   => p_attribute13
554     ,p_attribute14                   => p_attribute14
555     ,p_attribute15                   => p_attribute15
556     ,p_attribute16                   => p_attribute16
557     ,p_attribute17                   => p_attribute17
558     ,p_attribute18                   => p_attribute18
559     ,p_attribute19                   => p_attribute19
560     ,p_attribute20                   => p_attribute20
561     ,p_information_category          => p_information_category
562     ,p_information1                  => p_information1
563     ,p_information2                  => p_information2
564     ,p_information3                  => p_information3
565     ,p_information4                  => p_information4
566     ,p_information5                  => p_information5
567     ,p_information6                  => p_information6
568     ,p_information7                  => p_information7
569     ,p_information8                  => p_information8
570     ,p_information9                  => p_information9
571     ,p_information10                 => p_information10
572     ,p_information11                 => p_information11
573     ,p_information12                 => p_information12
574     ,p_information13                 => p_information13
575     ,p_information14                 => p_information14
576     ,p_information15                 => p_information15
577     ,p_information16                 => p_information16
578     ,p_information17                 => p_information17
579     ,p_information18                 => p_information18
580     ,p_information19                 => p_information19
581     ,p_information20 	             => p_information20
582     ,p_segment1                      => l_segment1
583     ,p_segment2                      => l_segment2
584     ,p_segment3                      => l_segment3
585     ,p_segment4                      => l_segment4
586     ,p_segment5                      => l_segment5
587     ,p_segment6                      => l_segment6
588     ,p_segment7                      => l_segment7
589     ,p_segment8                      => l_segment8
590     ,p_segment9                      => l_segment9
591     ,p_segment10                     => l_segment10
592     ,p_segment11                     => l_segment11
593     ,p_segment12                     => l_segment12
594     ,p_segment13                     => l_segment13
595     ,p_segment14                     => l_segment14
596     ,p_segment15                     => l_segment15
597     ,p_segment16                     => l_segment16
598     ,p_segment17                     => l_segment17
599     ,p_segment18                     => l_segment18
600     ,p_segment19                     => l_segment19
601     ,p_segment20                     => l_segment20
602     ,p_segment21                     => l_segment21
603     ,p_segment22                     => l_segment22
604     ,p_segment23                     => l_segment23
605     ,p_segment24                     => l_segment24
606     ,p_segment25                     => l_segment25
607     ,p_segment26                     => l_segment26
608     ,p_segment27                     => l_segment27
609     ,p_segment28                     => l_segment28
610     ,p_segment29                     => l_segment29
611     ,p_segment30                     => l_segment30
612     ,p_concat_segments               => p_concat_segments
613     ,p_grade_id                      => l_grade_id
614     ,p_object_version_number         => l_object_version_number
615     ,p_grade_definition_id           => l_grade_definition_id
616     ,p_name                          => l_name
617     ,p_effective_date		     => p_effective_date
618     ,p_language_code                 => l_language_code
619     ,p_short_name                    => p_short_name
620       );
621   exception
622     when hr_api.cannot_find_prog_unit then
623       hr_api.cannot_find_prog_unit_error
624         (p_module_name => 'CREATE_GRADE'
625         ,p_hook_type   => 'AP'
626         );
627     --
628     -- End of after hook process (create_grade)
629     --
630   end;
631   --
632   -- When in validation only mode raise the Validate_Enabled exception
633   --
634   if p_validate
635   then
636      raise hr_api.validate_enabled;
637   end if;
638   --
639   hr_utility.set_location(' Leaving:'||l_proc, 50);
640   --
641   -- Set OUT parameters
642   --
643    p_grade_id                := l_grade_id;
644    p_object_version_number := l_object_version_number;
645    p_grade_definition_id     := l_grade_definition_id;
646    p_name                  := l_name;
647    --
648    hr_utility.set_location(' Leaving:'||l_proc, 60);
649    --
650    exception
651    --
652    when hr_api.validate_enabled then
653      --
654      -- As the Validate_Enabled exception has been raised
655      -- we must rollback to the savepoint
656      --
657      ROLLBACK TO create_grade;
658      --
659      -- Set OUT parameters to null
660      -- Only set output warning arguments
661      -- (Any key or derived arguments must be set to null
662      -- when validation only mode is being used.)
663      --
664      if l_null_ind = 0
665      then
666         p_grade_definition_id      := null;
667      end if;
668      p_grade_id                    := null;
669      p_object_version_number     := null;
670      p_grade_definition_id         := null;
671      p_name                      := null;
672   --
673   hr_utility.set_location(' Leaving:'||l_proc, 70);
674   --
675   when others then
676      --
677      -- A validation or unexpected error has occurred
678      --
679      --
680      --
681      ROLLBACK TO create_grade;
682      --
683      hr_utility.set_location(' Leaving:'||l_proc, 80);
684      --
685      raise;
686      --
687 end create_grade;
688 --
689 -- ----------------------------------------------------------------------------
690 -- |------------------------< update_grade >----------------------------------|
691 -- ----------------------------------------------------------------------------
692 --
693 procedure update_grade(
694           p_validate                 in boolean  default false
695          ,p_grade_id                 in number
696          ,p_sequence                 in number   default hr_api.g_number
697          ,p_date_from                in date     default hr_api.g_date
698          ,p_effective_date           in date     default hr_api.g_date
699          ,p_date_to                  in date     default hr_api.g_date
700          ,p_request_id               in number   default hr_api.g_number
701          ,p_program_application_id   in number   default hr_api.g_number
702          ,p_program_id               in number   default hr_api.g_number
703          ,p_program_update_date      in date     default hr_api.g_date
704          ,p_attribute_category       in varchar2 default hr_api.g_varchar2
705          ,p_attribute1               in varchar2 default hr_api.g_varchar2
706          ,p_attribute2               in varchar2 default hr_api.g_varchar2
707          ,p_attribute3               in varchar2 default hr_api.g_varchar2
708          ,p_attribute4               in varchar2 default hr_api.g_varchar2
709          ,p_attribute5               in varchar2 default hr_api.g_varchar2
710          ,p_attribute6               in varchar2 default hr_api.g_varchar2
711          ,p_attribute7               in varchar2 default hr_api.g_varchar2
712          ,p_attribute8               in varchar2 default hr_api.g_varchar2
713          ,p_attribute9               in varchar2 default hr_api.g_varchar2
714          ,p_attribute10              in varchar2 default hr_api.g_varchar2
715          ,p_attribute11              in varchar2 default hr_api.g_varchar2
716          ,p_attribute12              in varchar2 default hr_api.g_varchar2
717          ,p_attribute13              in varchar2 default hr_api.g_varchar2
718          ,p_attribute14              in varchar2 default hr_api.g_varchar2
719          ,p_attribute15              in varchar2 default hr_api.g_varchar2
720          ,p_attribute16              in varchar2 default hr_api.g_varchar2
721          ,p_attribute17              in varchar2 default hr_api.g_varchar2
722          ,p_attribute18              in varchar2 default hr_api.g_varchar2
723          ,p_attribute19              in varchar2 default hr_api.g_varchar2
724          ,p_attribute20              in varchar2 default hr_api.g_varchar2
725          ,p_information_category     in varchar2 default hr_api.g_varchar2
726          ,p_information1             in varchar2 default hr_api.g_varchar2
727          ,p_information2             in varchar2 default hr_api.g_varchar2
728          ,p_information3             in varchar2 default hr_api.g_varchar2
729          ,p_information4             in varchar2 default hr_api.g_varchar2
730          ,p_information5             in varchar2 default hr_api.g_varchar2
731          ,p_information6             in varchar2 default hr_api.g_varchar2
732          ,p_information7             in varchar2 default hr_api.g_varchar2
733          ,p_information8             in varchar2 default hr_api.g_varchar2
734          ,p_information9             in varchar2 default hr_api.g_varchar2
735          ,p_information10            in varchar2 default hr_api.g_varchar2
736          ,p_information11            in varchar2 default hr_api.g_varchar2
737          ,p_information12            in varchar2 default hr_api.g_varchar2
738          ,p_information13            in varchar2 default hr_api.g_varchar2
739          ,p_information14            in varchar2 default hr_api.g_varchar2
740          ,p_information15            in varchar2 default hr_api.g_varchar2
741          ,p_information16            in varchar2 default hr_api.g_varchar2
742          ,p_information17            in varchar2 default hr_api.g_varchar2
743          ,p_information18            in varchar2 default hr_api.g_varchar2
744          ,p_information19            in varchar2 default hr_api.g_varchar2
745          ,p_information20            in varchar2 default hr_api.g_varchar2
746          ,p_last_update_date         in date     default hr_api.g_date
747          ,p_last_updated_by          in number   default hr_api.g_number
748          ,p_last_update_login        in number   default hr_api.g_number
749          ,p_created_by               in number   default hr_api.g_number
750          ,p_creation_date            in date     default hr_api.g_date
751          ,p_segment1                 in varchar2 default hr_api.g_varchar2
752          ,p_segment2                 in varchar2 default hr_api.g_varchar2
753          ,p_segment3                 in varchar2 default hr_api.g_varchar2
754          ,p_segment4                 in varchar2 default hr_api.g_varchar2
755          ,p_segment5                 in varchar2 default hr_api.g_varchar2
756          ,p_segment6                 in varchar2 default hr_api.g_varchar2
757          ,p_segment7                 in varchar2 default hr_api.g_varchar2
758          ,p_segment8                 in varchar2 default hr_api.g_varchar2
759          ,p_segment9                 in varchar2 default hr_api.g_varchar2
760          ,p_segment10                in varchar2 default hr_api.g_varchar2
761          ,p_segment11                in varchar2 default hr_api.g_varchar2
762          ,p_segment12                in varchar2 default hr_api.g_varchar2
763          ,p_segment13                in varchar2 default hr_api.g_varchar2
764          ,p_segment14                in varchar2 default hr_api.g_varchar2
765          ,p_segment15                in varchar2 default hr_api.g_varchar2
766          ,p_segment16                in varchar2 default hr_api.g_varchar2
767          ,p_segment17                in varchar2 default hr_api.g_varchar2
768          ,p_segment18                in varchar2 default hr_api.g_varchar2
769          ,p_segment19                in varchar2 default hr_api.g_varchar2
770          ,p_segment20                in varchar2 default hr_api.g_varchar2
771          ,p_segment21                in varchar2 default hr_api.g_varchar2
772          ,p_segment22                in varchar2 default hr_api.g_varchar2
773          ,p_segment23                in varchar2 default hr_api.g_varchar2
774          ,p_segment24                in varchar2 default hr_api.g_varchar2
775          ,p_segment25                in varchar2 default hr_api.g_varchar2
776          ,p_segment26                in varchar2 default hr_api.g_varchar2
777          ,p_segment27                in varchar2 default hr_api.g_varchar2
778          ,p_segment28                in varchar2 default hr_api.g_varchar2
779          ,p_segment29                in varchar2 default hr_api.g_varchar2
780          ,p_segment30                in varchar2 default hr_api.g_varchar2
781          ,p_language_code            in varchar2 default hr_api.userenv_lang
782          ,p_short_name               in varchar2 default hr_api.g_varchar2
783          ,p_concat_segments          in out nocopy varchar2
784          ,p_name                     in out nocopy varchar2
785          ,p_object_version_number    in out nocopy number
786          ,p_grade_definition_id      in out nocopy number
787          ,p_form_calling             in boolean default false --for bug 6522394
788          ) is
789   --
790   -- Declare cursors and local variables
791   l_name                  varchar2(240);
792   l_proc                  varchar2(72) := g_package||'update_grade';
793   l_api_updating          boolean;
794   l_effective_date        date;
795   l_date_to               per_grades.date_to%type;
796   l_sequence              per_grades.sequence%type;
797   l_grade_id              per_grades.grade_id%type;
798   l_date_from             per_grades.date_from%type;
799   l_short_name            per_grades.short_name%type;
800   l_business_group_id     per_grades.business_group_id%type;
801   l_grade_definition_id   per_grades.grade_definition_id%type
802                           := p_grade_definition_id;
803   l_flex_num              fnd_id_flex_segments.id_flex_num%type;
804   l_object_version_number per_grades.object_version_number%type;
805   l_segment1              varchar2(60) := p_segment1;
806   l_segment2              varchar2(60) := p_segment2;
807   l_segment3              varchar2(60) := p_segment3;
808   l_segment4              varchar2(60) := p_segment4;
809   l_segment5              varchar2(60) := p_segment5;
810   l_segment6              varchar2(60) := p_segment6;
811   l_segment7              varchar2(60) := p_segment7;
812   l_segment8              varchar2(60) := p_segment8;
813   l_segment9              varchar2(60) := p_segment9;
814   l_segment10             varchar2(60) := p_segment10;
815   l_segment11             varchar2(60) := p_segment11;
816   l_segment12             varchar2(60) := p_segment12;
817   l_segment13             varchar2(60) := p_segment13;
818   l_segment14             varchar2(60) := p_segment14;
819   l_segment15             varchar2(60) := p_segment15;
820   l_segment16             varchar2(60) := p_segment16;
821   l_segment17             varchar2(60) := p_segment17;
822   l_segment18             varchar2(60) := p_segment18;
823   l_segment19             varchar2(60) := p_segment19;
824   l_segment20             varchar2(60) := p_segment20;
825   l_segment21             varchar2(60) := p_segment21;
826   l_segment22             varchar2(60) := p_segment22;
827   l_segment23             varchar2(60) := p_segment23;
828   l_segment24             varchar2(60) := p_segment24;
829   l_segment25             varchar2(60) := p_segment25;
830   l_segment26             varchar2(60) := p_segment26;
831   l_segment27             varchar2(60) := p_segment27;
832   l_segment28             varchar2(60) := p_segment28;
833   l_segment29             varchar2(60) := p_segment29;
834   l_segment30             varchar2(60) := p_segment30;
835   l_language_code         varchar2(30) := p_language_code;
836   l_null_ind              number(1)    := 0;
837   l_old_seq               number; --for bug 6522394
838   --
839   -- Declare cursors
840   cursor isdel is
841          select pgd.id_flex_num
842            from per_grade_definitions pgd
843           where pgd.grade_definition_id = l_grade_definition_id;
844   --
845 
846  --start changes for bug 6522394
847    cursor csr_old_seq is
848    select sequence
849    from per_grades
850    where grade_id = p_grade_id;
851  --end changes for bug 6522394
852 
853   cursor c_segments is
854          select segment1,
855                 segment2,
856                 segment3,
857                 segment4,
858                 segment5,
859                 segment6,
860                 segment7,
861                 segment8,
862                 segment9,
863                 segment10,
864                 segment11,
865                 segment12,
866                 segment13,
867                 segment14,
868                 segment15,
869                 segment16,
870                 segment17,
871                 segment18,
872                 segment19,
873                 segment20,
874                 segment21,
875                 segment22,
876                 segment23,
877                 segment24,
878                 segment25,
879                 segment26,
880                 segment27,
881                 segment28,
882                 segment29,
883                 segment30
884            from per_grade_definitions
885           where grade_definition_id = l_grade_definition_id;
886   --
887 begin
888   --
889   hr_utility.set_location('Entering:'|| l_proc, 5);
890   --
891   -- Issue a savepoint
892   savepoint update_grade;
893   --
894   hr_utility.set_location(l_proc, 10);
895   --
896   -- Validate the language parameter. l_language_code should be passed
897   -- instead of p_language_code from now on, to allow an IN OUT parameter to
898   -- be passed through.
899   hr_api.validate_language_code(p_language_code => l_language_code);
900   --
901   l_grade_definition_id   := p_grade_definition_id;
902   l_object_version_number := p_object_version_number;
903   --
904   -- Validation in addition to Table Handlers
905   l_api_updating := per_grd_shd.api_updating(
906                     p_grade_id              => p_grade_id
907                    ,p_object_version_number => p_object_version_number);
908   --
909   hr_utility.set_location(l_proc, 15);
910   --
911   if not l_api_updating then
912     --
913     hr_utility.set_location(l_proc, 20);
914     --
915     -- As this an updating API, the grade should already exist.
916     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
917     hr_utility.raise_error;
918     --
919   else
920     --
921     if l_grade_definition_id is null then
922       --
923       l_null_ind := 0;
924       l_grade_definition_id := per_grd_shd.g_old_rec.grade_definition_id;
925       hr_utility.set_location(l_proc, 24);
926       --
927     else
928       --
929       -- get segment values if p_grade_definition_id entered with a value
930       -- set indicator to show p_grade_definition_id did not enter program null
931       l_null_ind := 1;
932       --
933       open c_segments;
934       fetch c_segments into
935             l_segment1,
936             l_segment2,
937             l_segment3,
938             l_segment4,
939             l_segment5,
940             l_segment6,
941             l_segment7,
942             l_segment8,
943             l_segment9,
944             l_segment10,
945             l_segment11,
946             l_segment12,
947             l_segment13,
948             l_segment14,
949             l_segment15,
950             l_segment16,
951             l_segment17,
952             l_segment18,
953             l_segment19,
954             l_segment20,
955             l_segment21,
956             l_segment22,
957             l_segment23,
958             l_segment24,
959             l_segment25,
960             l_segment26,
961             l_segment27,
962             l_segment28,
963             l_segment29,
964             l_segment30;
965       close c_segments;
966       --
967       hr_utility.set_location(l_proc, 27);
968       --
969     end if;
970     --
971   end if;
972   --
973   --start changes for bug 6522394
974   open csr_old_seq;
975   fetch csr_old_seq into l_old_seq;
976 
977   if csr_old_seq%found then
978     close csr_old_seq;
979   end if;
980   --end changes for bug 6522394
981 
982   hr_utility.set_location('Entering: call - update_grade_b', 35);
983   --
984   -- Call Before Process User Hook
985   begin
986     --
987     hr_grade_bk2.update_grade_b(
988        p_grade_id                      => p_grade_id
989       ,p_sequence                      => p_sequence
990       ,p_date_from                     => l_date_from
991       ,p_date_to                       => l_date_to
992       ,p_effective_date                => p_effective_date
993       ,p_request_id                    => p_request_id
994       ,p_program_application_id        => p_program_application_id
995       ,p_program_id                    => p_program_id
996       ,p_program_update_date           => p_program_update_date
997       ,p_attribute_category            => p_attribute_category
998       ,p_attribute1                    => p_attribute1
999       ,p_attribute2                    => p_attribute2
1000       ,p_attribute3                    => p_attribute3
1001       ,p_attribute4                    => p_attribute4
1002       ,p_attribute5                    => p_attribute5
1003       ,p_attribute6                    => p_attribute6
1004       ,p_attribute7                    => p_attribute7
1005       ,p_attribute8                    => p_attribute8
1006       ,p_attribute9                    => p_attribute9
1007       ,p_attribute10                   => p_attribute10
1008       ,p_attribute11                   => p_attribute11
1009       ,p_attribute12                   => p_attribute12
1010       ,p_attribute13                   => p_attribute13
1011       ,p_attribute14                   => p_attribute14
1012       ,p_attribute15                   => p_attribute15
1013       ,p_attribute16                   => p_attribute16
1014       ,p_attribute17                   => p_attribute17
1015       ,p_attribute18                   => p_attribute18
1016       ,p_attribute19                   => p_attribute19
1017       ,p_attribute20                   => p_attribute20
1018       ,p_information_category          => p_information_category
1019       ,p_information1                  => p_information1
1020       ,p_information2                  => p_information2
1021       ,p_information3                  => p_information3
1022       ,p_information4                  => p_information4
1023       ,p_information5                  => p_information5
1024       ,p_information6                  => p_information6
1025       ,p_information7                  => p_information7
1026       ,p_information8                  => p_information8
1027       ,p_information9                  => p_information9
1028       ,p_information10                 => p_information10
1029       ,p_information11                 => p_information11
1030       ,p_information12                 => p_information12
1031       ,p_information13                 => p_information13
1032       ,p_information14                 => p_information14
1033       ,p_information15                 => p_information15
1034       ,p_information16                 => p_information16
1035       ,p_information17                 => p_information17
1036       ,p_information18                 => p_information18
1037       ,p_information19                 => p_information19
1038       ,p_information20                 => p_information20
1039       ,p_last_update_date              => p_last_update_date
1040       ,p_last_updated_by               => p_last_updated_by
1041       ,p_last_update_login             => p_last_update_login
1042       ,p_created_by                    => p_created_by
1043       ,p_creation_date                 => p_creation_date
1044       ,p_segment1                      => l_segment1
1045       ,p_segment2                      => l_segment2
1046       ,p_segment3                      => l_segment3
1047       ,p_segment4                      => l_segment4
1048       ,p_segment5                      => l_segment5
1049       ,p_segment6                      => l_segment6
1050       ,p_segment7                      => l_segment7
1051       ,p_segment8                      => l_segment8
1052       ,p_segment9                      => l_segment9
1053       ,p_segment10                     => l_segment10
1054       ,p_segment11                     => l_segment11
1055       ,p_segment12                     => l_segment12
1056       ,p_segment13                     => l_segment13
1057       ,p_segment14                     => l_segment14
1058       ,p_segment15                     => l_segment15
1059       ,p_segment16                     => l_segment16
1060       ,p_segment17                     => l_segment17
1061       ,p_segment18                     => l_segment18
1062       ,p_segment19                     => l_segment19
1063       ,p_segment20                     => l_segment20
1064       ,p_segment21                     => l_segment21
1065       ,p_segment22                     => l_segment22
1066       ,p_segment23                     => l_segment23
1067       ,p_segment24                     => l_segment24
1068       ,p_segment25                     => l_segment25
1069       ,p_segment26                     => l_segment26
1070       ,p_segment27                     => l_segment27
1071       ,p_segment28                     => l_segment28
1072       ,p_segment29                     => l_segment29
1073       ,p_segment30                     => l_segment30
1074       ,p_language_code                 => l_language_code
1075       ,p_concat_segments               => p_concat_segments
1076       ,p_name                          => p_name
1077       ,p_short_name                    => p_short_name
1078       ,p_object_version_number         => p_object_version_number
1079       ,p_grade_definition_id           => p_grade_definition_id);
1080     --
1081   exception
1082     --
1083     when hr_api.cannot_find_prog_unit then
1084          hr_api.cannot_find_prog_unit_error(
1085                 p_module_name => 'UPDATE_GRADE'
1086                ,p_hook_type   => 'BP');
1087     --
1088   end; -- End of API User Hook for the before hook of update_grade
1089   --
1090   hr_utility.set_location(l_proc, 30);
1091   --
1092   open isdel;
1093   fetch isdel into l_flex_num;
1094   if isdel%notfound then
1095     --
1096     hr_utility.set_location(l_proc, 38);
1097     close isdel;
1098     --
1099     -- the flex structure has not been found
1100     hr_utility.set_message(801, 'HR_6039_ALL_CANT_GET_FFIELD');
1101     hr_utility.raise_error;
1102     --
1103   end if;
1104   --
1105   close isdel;
1106   hr_utility.set_location(l_proc, 40);
1107   l_date_from      := trunc(p_date_from);
1108   l_date_to        := trunc(p_date_to);
1109   --
1110   -- update grade definitions
1111   hr_utility.set_location(l_proc, 50);
1112   hr_utility.trace('GRD before upd_or_sel '||l_grade_definition_id);
1113   --
1114   hr_kflex_utility.upd_or_sel_keyflex_comb(
1115         p_appl_short_name     => 'PER'
1116        ,p_flex_code           => 'GRD'
1117        ,p_flex_num            => l_flex_num
1118        ,p_segment1            => l_segment1
1119        ,p_segment2            => l_segment2
1120        ,p_segment3            => l_segment3
1121        ,p_segment4            => l_segment4
1122        ,p_segment5            => l_segment5
1123        ,p_segment6            => l_segment6
1124        ,p_segment7            => l_segment7
1125        ,p_segment8            => l_segment8
1126        ,p_segment9            => l_segment9
1127        ,p_segment10           => l_segment10 -- fix for bug 4758481.
1128        ,p_segment11           => l_segment11
1129        ,p_segment12           => l_segment12
1130        ,p_segment13           => l_segment13
1131        ,p_segment14           => l_segment14
1132        ,p_segment15           => l_segment15
1133        ,p_segment16           => l_segment16
1134        ,p_segment17           => l_segment17
1135        ,p_segment18           => l_segment18
1136        ,p_segment19           => l_segment19
1137        ,p_segment20           => l_segment20
1138        ,p_segment21           => l_segment21
1139        ,p_segment22           => l_segment22
1140        ,p_segment23           => l_segment23
1141        ,p_segment24           => l_segment24
1142        ,p_segment25           => l_segment25
1143        ,p_segment26           => l_segment26
1144        ,p_segment27           => l_segment27
1145        ,p_segment28           => l_segment28
1146        ,p_segment29           => l_segment29
1147        ,p_segment30           => l_segment30
1148        ,p_concat_segments_in  => p_concat_segments
1149        ,p_ccid                => l_grade_definition_id
1150        ,p_concat_segments_out => l_name);
1151   --
1152   hr_utility.set_location(l_proc, 60);
1153   --
1154   per_grd_upd.upd(
1155         p_effective_date         => p_effective_date
1156        ,p_grade_id               => p_grade_id
1157        ,p_object_version_number  => l_object_version_number
1158        ,p_business_group_id      => l_business_group_id
1159        ,p_grade_definition_id    => l_grade_definition_id
1160        ,p_date_from              => p_date_from
1161        ,p_sequence               => p_sequence
1162        ,p_date_to                => p_date_to
1163        ,p_name                   => l_name
1164        ,p_short_name             => p_short_name
1165        ,p_request_id             => p_request_id
1166        ,p_program_application_id => p_program_application_id
1167        ,p_program_id             => p_program_id
1168        ,p_program_update_date    => p_program_update_date
1169        ,p_attribute_category     => p_attribute_category
1170        ,p_attribute1             => p_attribute1
1171        ,p_attribute2             => p_attribute2
1172        ,p_attribute3             => p_attribute3
1173        ,p_attribute4             => p_attribute4
1174        ,p_attribute5             => p_attribute5
1175        ,p_attribute6             => p_attribute6
1176        ,p_attribute7             => p_attribute7
1177        ,p_attribute8             => p_attribute8
1178        ,p_attribute9             => p_attribute9
1179        ,p_attribute10            => p_attribute10
1180        ,p_attribute11            => p_attribute11
1181        ,p_attribute12            => p_attribute12
1182        ,p_attribute13            => p_attribute13
1183        ,p_attribute14            => p_attribute14
1184        ,p_attribute15            => p_attribute15
1185        ,p_attribute16            => p_attribute16
1186        ,p_attribute17            => p_attribute17
1187        ,p_attribute18            => p_attribute18
1188        ,p_attribute19            => p_attribute19
1189        ,p_attribute20            => p_attribute20
1190        ,p_information_category   => p_information_category
1191        ,p_information1           => p_information1
1192        ,p_information2           => p_information2
1193        ,p_information3           => p_information3
1194        ,p_information4           => p_information4
1195        ,p_information5           => p_information5
1196        ,p_information6           => p_information6
1197        ,p_information7           => p_information7
1198        ,p_information8           => p_information8
1199        ,p_information9           => p_information9
1200        ,p_information10          => p_information10
1201        ,p_information11          => p_information11
1202        ,p_information12          => p_information12
1203        ,p_information13          => p_information13
1204        ,p_information14          => p_information14
1205        ,p_information15          => p_information15
1206        ,p_information16          => p_information16
1207        ,p_information17          => p_information17
1208        ,p_information18          => p_information18
1209        ,p_information19          => p_information19
1210        ,p_information20          => p_information20);
1211   --
1212   -- MLS Processing
1213   per_gdt_upd.upd_tl(
1214         p_language_code          => l_language_code
1215        ,p_grade_id               => p_grade_id
1216        ,p_name                   => p_name);
1217   --
1218 
1219   --start changes for bug 6522394
1220   if not p_form_calling then
1221 	declare
1222 	 l_exists varchar2(1) ;
1223 	 l_tmp_business_group_id number;
1224 	 l_date_from date;
1225 	l_date_to date;
1226 	l_date_to_old date;
1227 	l_eot date:=to_date('31-12-4712','dd-mm-yyyy');
1228 
1229 	 cursor csr_get_bgrp is
1230 	  select business_group_id,date_from,date_to
1231 	  from per_grades
1232 	  where grade_id = p_grade_id;
1233 
1234 	begin
1235 
1236 	open csr_get_bgrp;
1237 	fetch csr_get_bgrp into l_tmp_business_group_id,l_date_from,l_date_to;
1238 
1239 	if csr_get_bgrp%found then
1240 	 close csr_get_bgrp;
1241 	end if;
1242 
1243 	 per_grades_pkg.postup1(p_sequence,
1244 				l_old_seq,
1245 				p_last_updated_by,
1246 				p_last_update_login,
1247 				p_grade_id,
1248 				l_tmp_business_group_id,
1249 				l_exists );
1250 
1251 	 IF l_exists = 'Y' THEN
1252 
1253 	l_date_to_old := l_date_to;
1254 
1255 	if  p_date_from <> hr_api.g_date then
1256 	l_date_from := p_date_from;
1257 	end if;
1258 
1259 	if p_date_to <> hr_api.g_date then
1260 	l_date_to := p_date_to;
1261 	end if;
1262 
1263  	  per_grades_pkg.postup2(p_grade_id,
1264 				       l_tmp_business_group_id,
1265 				       l_date_from,
1266 				       l_date_to,
1267 				       l_eot,
1268 				       l_date_to_old);
1269 	END IF;
1270 	end;
1271   end if;
1272   --end changes for bug 6522394
1273 
1274   hr_utility.set_location('Entering: call - update_grade_a', 65);
1275   --
1276   begin
1277     --
1278     hr_grade_bk2.update_grade_a(
1279         p_grade_id               => p_grade_id
1280        ,p_sequence               => p_sequence
1281        ,p_date_from              => l_date_from
1282        ,p_date_to                => l_date_to
1283        ,p_request_id             => p_request_id
1284        ,p_program_application_id => p_program_application_id
1285        ,p_program_id             => p_program_id
1286        ,p_program_update_date    => p_program_update_date
1287        ,p_attribute_category     => p_attribute_category
1288        ,p_attribute1             => p_attribute1
1289        ,p_attribute2             => p_attribute2
1290        ,p_attribute3             => p_attribute3
1291        ,p_attribute4             => p_attribute4
1292        ,p_attribute5             => p_attribute5
1293        ,p_attribute6             => p_attribute6
1294        ,p_attribute7             => p_attribute7
1295        ,p_attribute8             => p_attribute8
1296        ,p_attribute9             => p_attribute9
1297        ,p_attribute10            => p_attribute10
1298        ,p_attribute11            => p_attribute11
1299        ,p_attribute12            => p_attribute12
1300        ,p_attribute13            => p_attribute13
1301        ,p_attribute14            => p_attribute14
1302        ,p_attribute15            => p_attribute15
1303        ,p_attribute16            => p_attribute16
1304        ,p_attribute17            => p_attribute17
1305        ,p_attribute18            => p_attribute18
1306        ,p_attribute19            => p_attribute19
1307        ,p_attribute20            => p_attribute20
1308        ,p_information_category   => p_information_category
1309        ,p_information1           => p_information1
1310        ,p_information2           => p_information2
1311        ,p_information3           => p_information3
1312        ,p_information4           => p_information4
1313        ,p_information5           => p_information5
1314        ,p_information6           => p_information6
1315        ,p_information7           => p_information7
1316        ,p_information8           => p_information8
1317        ,p_information9           => p_information9
1318        ,p_information10          => p_information10
1319        ,p_information11          => p_information11
1320        ,p_information12          => p_information12
1321        ,p_information13          => p_information13
1322        ,p_information14          => p_information14
1323        ,p_information15          => p_information15
1324        ,p_information16          => p_information16
1325        ,p_information17          => p_information17
1326        ,p_information18          => p_information18
1327        ,p_information19          => p_information19
1328        ,p_information20          => p_information20
1329        ,p_last_update_date       => p_last_update_date
1330        ,p_last_updated_by        => p_last_updated_by
1331        ,p_last_update_login      => p_last_update_login
1332        ,p_created_by             => p_created_by
1333        ,p_creation_date          => p_creation_date
1334        ,p_segment1               => l_segment1
1335        ,p_segment2               => l_segment2
1336        ,p_segment3               => l_segment3
1337        ,p_segment4               => l_segment4
1338        ,p_segment5               => l_segment5
1339        ,p_segment6               => l_segment6
1340        ,p_segment7               => l_segment7
1341        ,p_segment8               => l_segment8
1342        ,p_segment9               => l_segment9
1343        ,p_segment10              => l_segment10
1344        ,p_segment11              => l_segment11
1345        ,p_segment12              => l_segment12
1346        ,p_segment13              => l_segment13
1347        ,p_segment14              => l_segment14
1348        ,p_segment15              => l_segment15
1349        ,p_segment16              => l_segment16
1350        ,p_segment17              => l_segment17
1351        ,p_segment18              => l_segment18
1352        ,p_segment19              => l_segment19
1353        ,p_segment20              => l_segment20
1354        ,p_segment21              => l_segment21
1355        ,p_segment22              => l_segment22
1356        ,p_segment23              => l_segment23
1357        ,p_segment24              => l_segment24
1358        ,p_segment25              => l_segment25
1359        ,p_segment26              => l_segment26
1360        ,p_segment27              => l_segment27
1361        ,p_segment28              => l_segment28
1362        ,p_segment29              => l_segment29
1363        ,p_segment30              => l_segment30
1364        ,p_language_code          => l_language_code
1365        ,p_concat_segments        => p_concat_segments
1366        ,p_name                   => p_name
1367        ,p_short_name             => p_short_name
1368        ,p_object_version_number  => p_object_version_number
1369        ,p_grade_definition_id    => p_grade_definition_id
1370        ,p_effective_date         => p_effective_date);
1371     --
1372   exception
1373     --
1374     when hr_api.cannot_find_prog_unit then
1375          hr_api.cannot_find_prog_unit_error(
1376                 p_module_name => 'UPDATE_GRADE'
1377                ,p_hook_type   => 'AP');
1378   end; -- End of API User Hook for the after hook of update_grade
1379   --
1380   hr_utility.set_location(l_proc, 90);
1381   --
1382   -- When in validation only mode raise the Validate_Enabled exception
1383   if p_validate then
1384     raise hr_api.validate_enabled;
1385   end if;
1386   --
1387   p_object_version_number := l_object_version_number;
1388   p_grade_definition_id   := l_grade_definition_id;
1389   p_name                  := l_name;
1390   --
1391   hr_utility.set_location(' Leaving:'||l_proc, 100);
1392   --
1393 exception
1394   --
1395   when hr_api.validate_enabled then
1396     --
1397     -- As the Validate_Enabled exception has been raised
1398     -- we must rollback to the savepoint
1399     rollback to update_grade;
1400     --
1401     -- Only set output warning arguments
1402     -- (Any key or derived arguments must be set to null
1403     -- when validation only mode is being used.)
1404     p_object_version_number := p_object_version_number;
1405     if l_null_ind = 0 then
1406       p_grade_definition_id := null;
1407     end if;
1408     p_name := null;
1409     --
1410   when others then
1411     --
1412     -- A validation or unexpected error has occured
1413     rollback to update_grade;
1414     hr_utility.set_location(' Leaving:'||l_proc, 120);
1415     raise;
1416   --
1417 end update_grade;
1418 --
1419 -- ----------------------------------------------------------------------------
1420 -- |---------------------------< delete_grade >-------------------------------|
1421 -- ----------------------------------------------------------------------------
1422 --
1423 
1424 procedure delete_grade
1425   (p_validate                      in     boolean
1426   ,p_grade_id                      in     number
1427   ,p_object_version_number         in out nocopy number) IS
1428 
1429   l_object_version_number       number(9);
1430   l_proc                varchar2(72) := g_package||'DELETE_GRADE';
1431 begin
1432   hr_utility.set_location('Entering:'|| l_proc, 10);
1433 
1434   --
1435   -- Issue a savepoint
1436   --
1437   savepoint DELETE_GRADE;
1438 
1439   --
1440   -- Call Before Process User Hook
1441   --
1442   begin
1443   hr_grade_bk3.delete_grade_b
1444     (p_validate                   =>  p_validate
1445     ,p_grade_id                   =>  p_grade_id
1446     ,p_object_version_number      =>  p_object_version_number
1447     );
1448   exception
1449     when hr_api.cannot_find_prog_unit then
1450       hr_api.cannot_find_prog_unit_error
1451         (p_module_name => 'DELETE_GRADE'
1452         ,p_hook_type   => 'BP'
1453         );
1454   end;
1455   hr_utility.set_location(l_proc, 20);
1456   --
1457   -- MLS Processing
1458   --
1459   per_gdt_del.del_tl(p_grade_id  => p_grade_id);
1460   --
1461   hr_utility.set_location(l_proc, 30);
1462   --
1463   -- Process Logic
1464   --
1465   l_object_version_number := p_object_version_number;
1466   --
1467   per_grd_del.del
1468   (p_grade_id                      => p_grade_id
1469   ,p_object_version_number         => l_object_version_number);
1470   --
1471   hr_utility.set_location(l_proc, 40);
1472   --
1473   -- Call After Process User Hook
1474   --
1475  begin
1476   hr_grade_bk3.delete_grade_a
1477     (p_validate                   =>  p_validate
1478     ,p_grade_id                   =>  p_grade_id
1479     ,p_object_version_number      =>  l_object_version_number);
1480   exception
1481     when hr_api.cannot_find_prog_unit then
1482       hr_api.cannot_find_prog_unit_error
1483         (p_module_name => 'DELETE_GRADE'
1484         ,p_hook_type   => 'AP'
1485         );
1486   end;
1487   --
1488   -- When in validation only mode raise the Validate_Enabled exception
1489   --
1490   if p_validate then
1491     raise hr_api.validate_enabled;
1492   end if;
1493   --
1494   -- Set all output arguments
1495   --
1496   --
1497   p_object_version_number := l_object_version_number;
1498 
1499   hr_utility.set_location(' Leaving:'||l_proc, 100);
1500 exception
1501   when hr_api.validate_enabled then
1502     hr_utility.set_location(' Leaving...:'||l_proc, 80);
1503     --
1504     -- As the Validate_Enabled exception has been raised
1505     -- we must rollback to the savepoint
1506     --
1507     rollback to DELETE_GRADE;
1508     --
1509     -- Only set output warning arguments
1510     -- (Any key or derived arguments must be set to null
1511     -- when validation only mode is being used.)
1512     --
1513   when others then
1514     hr_utility.set_location(' Leaving...:'||l_proc, 90);
1515     --
1516     -- A validation or unexpected error has occured
1517     --
1518     rollback to DELETE_GRADE;
1519     raise;
1520 end delete_grade;
1521 end hr_grade_api;