DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_SF52_DO_UPDATE

Source


1 PACKAGE BODY GHR_SF52_DO_UPDATE AS
2 /* $Header: gh52doup.pkb 120.61.12010000.5 2008/10/22 12:42:51 utokachi ship $ */
3 g_effective_date      date;
4 g_old_user_status      per_assignment_status_types.user_status%type;
5 --
6 -- Removed all cursors required to fetch noa_code, as it is already passed from ghr_pa_requests (FRONT END)
7 --
8 -- *******************************
9 -- procedure Generic_Update_Extra_Info
10 -- *******************************
11 --
12 
13 --      This procedure call the appropriate API to update DDF extra information.
14 
15 Procedure Generic_Update_Extra_Info
16 (P_PA_REQUEST_REC               IN    GHR_PA_REQUESTS%ROWTYPE
17 ,p_l_information_type           IN        varchar2
18 ,p_extra_info_id                IN      number
19 ,p_l_object_version_number      IN out nocopy number
20 ,p_information1                 IN      varchar2 default hr_api.g_varchar2
21 ,p_information2                 IN      varchar2 default hr_api.g_varchar2
22 ,p_information3                 IN      varchar2 default hr_api.g_varchar2
23 ,p_information4                 IN      varchar2 default hr_api.g_varchar2
24 ,p_information5                 IN      varchar2 default hr_api.g_varchar2
25 ,p_information6                 IN      varchar2 default hr_api.g_varchar2
26 ,p_Information7                 IN      varchar2 default hr_api.g_varchar2
27 ,p_information8                 IN      varchar2 default hr_api.g_varchar2
28 ,p_information9                 IN      varchar2 default hr_api.g_varchar2
29 ,p_information10                      IN        varchar2 default hr_api.g_varchar2
30 ,p_information11                        IN      varchar2 default hr_api.g_varchar2
31 ,p_information12                        IN      varchar2 default hr_api.g_varchar2
32 ,p_information13                        IN      varchar2 default hr_api.g_varchar2
33 ,p_information14                        IN      varchar2 default hr_api.g_varchar2
34 ,p_information15                        IN      varchar2 default hr_api.g_varchar2
35 ,p_information16                        IN      varchar2 default hr_api.g_varchar2
36 ,p_information17                        IN      varchar2 default hr_api.g_varchar2
37 ,p_information18                        IN      varchar2 default hr_api.g_varchar2
38 ,p_information19                        IN      varchar2 default hr_api.g_varchar2
39 ,p_information20                        IN      varchar2 default hr_api.g_varchar2
40 ,p_information21                        IN      varchar2 default hr_api.g_varchar2
41 ,p_information22                        IN      varchar2 default hr_api.g_varchar2
42 ,p_information23                        IN      varchar2 default hr_api.g_varchar2
43 ,p_information24                        IN      varchar2 default hr_api.g_varchar2
44 ,p_information25                        IN      varchar2 default hr_api.g_varchar2
45 ,p_information26                        IN      varchar2 default hr_api.g_varchar2
46 ,p_information27                        IN      varchar2 default hr_api.g_varchar2
47 ,p_information28                        IN      varchar2 default hr_api.g_varchar2
48 ,p_information29                        IN      varchar2 default hr_api.g_varchar2
49 ,p_information30                        IN      varchar2 default hr_api.g_varchar2)  is
50 
51 --
52   l_proc            varchar2(70) := 'Generic Update  Extra Info';
53   l_id            number;
54   l_ovn             number;
55   l_initial_ovn             number;
56   l_index                 varchar2(10);
57   l_extra_info_id   number(15);
58   l_extra_info_rec  ghr_api.extra_info_rec_type;
59 --
60   l_asg_cre_extra_info_id       per_assignment_extra_info.assignment_extra_info_id%type;
61   l_asg_cre_ovn                         per_assignment_extra_info.object_version_number%type;
62   l_per_cre_extra_info_id       per_people_extra_info.person_extra_info_id%type;
63   l_per_cre_ovn                         per_people_extra_info.object_version_number%type;
64   l_pos1_cre_extra_info_id      per_position_extra_info.position_extra_info_id%type;
65   l_pos1_cre_ovn                        per_position_extra_info.object_version_number%type;
66 --
67   l_information1           varchar2(150);
68   l_information2           varchar2(150);
69   l_information3           varchar2(150);
70   l_information4           varchar2(150);
71   l_information5           varchar2(150);
72   l_information6           varchar2(150);
73   l_information7           varchar2(150);
74   l_information8           varchar2(150);
75   l_information9           varchar2(150);
76   l_information10          varchar2(150);
77   l_information11          varchar2(150);
78   l_information12          varchar2(150);
79   l_information13          varchar2(150);
80   l_information14          varchar2(150);
81   l_information15          varchar2(150);
82   l_information16          varchar2(150);
83   l_information17          varchar2(150);
84   l_information18          varchar2(150);
85   l_information19          varchar2(150);
86   l_information20          varchar2(150);
87   l_information21          varchar2(150);
88   l_information22          varchar2(150);
89   l_information23          varchar2(150);
90   l_information24          varchar2(150);
91   l_information25          varchar2(150);
92   l_information26          varchar2(150);
93   l_information27          varchar2(150);
94   l_information28          varchar2(150);
95   l_information29          varchar2(150);
96   l_information30          varchar2(150);
97 --
98 
99 -- Cursor to select the primary key of the respective Extra info tables for the specific
100 -- entity Id and the InformationType
101 
102    Cursor c_asg_ei is
103      select assignment_extra_info_id,
104             object_version_number
105      from   per_assignment_extra_info
106      where  assignment_id    = l_id
107      and    information_type = p_l_information_type;
108 
109    Cursor c_per_ei is
110      select person_extra_info_id,
111             object_version_number
112      from   per_people_extra_info
113      where  person_id        = l_id
114      and    information_type = p_l_information_type;
115 
116    Cursor c_pos_ei is
117      select position_extra_info_id,
118             object_version_number
119      from   per_position_extra_info
120      where  position_id      = l_id
121      and    information_type = p_l_information_type;
122 
123 begin
124 --
125   hr_utility.set_location('Entering ' || l_proc,5);
126   l_initial_ovn := p_l_object_version_number;
127 
128   l_extra_info_id := NULL;
129 
130   If upper(substr(P_l_Information_Type,8,3))   = 'ASG' then
131     l_index     := 'aei';
132     l_id        := P_Pa_request_rec.Employee_Assignment_id;
133     l_extra_info_id  := p_extra_info_id;
134   hr_utility.set_location('Assignment id is ' ||l_id || '  ' || l_proc,6);
135   hr_utility.set_location('l_extra_info_id is ' ||l_extra_info_id || '  ' || l_proc,7);
136   Elsif upper(substr(P_l_Information_Type,8,3))   = 'PER' then
137     l_index     := 'pei';
138     l_id        := P_Pa_request_rec.person_id;
139     l_extra_info_id  := p_extra_info_id;
140   Elsif upper(substr(P_l_Information_Type,8,3))   = 'POS' then
141     l_index     := 'poei';
142     l_id        := nvl(P_Pa_request_rec.to_position_id,p_pa_request_rec.from_position_id);
143     hr_utility.set_location('EXTRA INFO ID  '||  to_char(p_extra_info_id),1);
144     l_extra_info_id  := p_extra_info_id;
145  -- Rohini
146  Elsif upper(p_l_information_type )= 'GHR_US_RETAINED_GRADE' then
147     l_index     :=  'pei';
148     l_id        :=  P_Pa_request_rec.person_id;
149     l_extra_info_id  := p_extra_info_id;
150  -- Rohini
151 
152   Else
153     hr_utility.set_message(8301,'GHR_38132_INVALID_INFO_TYPE');
154     hr_utility.raise_error;
155   End if;
156 
157   hr_utility.set_location(l_proc,10);
158 
159 -- The foll. code sets the information<n> to null , if they get passed in as null
160 -- and is then used in case of create Extr Info .This was done so that
161 -- we could work with just one procedure for both update as well as create of
162 -- extra information, with all the parameters defaulted to hr_api.g_varchar2
163 -- therby ensuring that while updating, none of the existing data gets over-written.
164 
165   l_extra_info_id := p_extra_info_id;
166   hr_utility.set_location('l_extra_info_id is ' ||l_extra_info_id || '  ' || l_proc,8);
167   If p_information1 = hr_api.g_varchar2 THEN
168     l_information1 := null;
169   Else
170     l_information1 := p_information1;
171   End if;
172   IF p_information2 = hr_api.g_varchar2 THEN
173     l_information2 := null;
174   Else
175     l_information2 := p_information2;
176   End if;
177   IF p_information3 = hr_api.g_varchar2 THEN
178     l_information3 := null;
179   ELSE
180     l_information3 := p_information3;
181   END IF;
182   IF p_information4 = hr_api.g_varchar2 THEN
183     l_information4 := null;
184   ELSE
185     l_information4 := p_information4;
186         END IF;
187   IF p_information5 = hr_api.g_varchar2 THEN
188     l_information5 := null;
189   ELSE
190     l_information5 := p_information5;
191   END IF;
192   IF p_information6 = hr_api.g_varchar2 THEN
193     l_information6 := null;
194   ELSE
195     l_information6 := p_information6;
196   END IF;
197   IF p_information7 = hr_api.g_varchar2 THEN
198     l_information7 := null;
199   ELSE
200     l_information7 := p_information7;
201   END IF;
202   IF p_information8 = hr_api.g_varchar2 THEN
203     l_information8 := null;
204   ELSE
205     l_information8 := p_information8;
206   END IF;
207   IF p_information9 = hr_api.g_varchar2 THEN
208    l_information9 := null;
209   ELSE
210    l_information9 := p_information9;
211   END IF;
212   IF p_information10 = hr_api.g_varchar2 THEN
213     l_information10 := null;
214   ELSE
215     l_information10 := p_information10;
216   END IF;
217   IF p_information11 = hr_api.g_varchar2 THEN
218     l_information11 := null;
219   ELSE
220    l_information11 := p_information11;
221   END IF;
222   IF p_information12 = hr_api.g_varchar2 THEN
223     l_information12 := null;
224   ELSE
225     l_information12 := p_information12;
226   END IF;
227   IF p_information13 = hr_api.g_varchar2 THEN
228     l_information13 := null;
229   ELSE
230     l_information13 := p_information13;
231   END IF;
232   IF p_information14 = hr_api.g_varchar2 THEN
233     l_information14 := null;
234   ELSE
235     l_information14 := p_information14;
236   END IF;
237   IF p_information15 = hr_api.g_varchar2 THEN
238     l_information15 := null;
239   ELSE
240     l_information15 := p_information15;
241   END IF;
242   IF p_information16 = hr_api.g_varchar2 THEN
243    l_information16 := null;
244   ELSE
245     l_information16 := p_information16;
246   END IF;
247   IF p_information17 = hr_api.g_varchar2 THEN
248     l_information17 := null;
249   ELSE
250     l_information17 := p_information17;
251   END IF;
252   IF p_information18 = hr_api.g_varchar2 THEN
253    l_information18 := null;
254   ELSE
255    l_information18 := p_information18;
256   END IF;
257   IF p_information19 = hr_api.g_varchar2 THEN
258    l_information19 := null;
259   ELSE
260    l_information19 := p_information19;
261   END IF;
262   IF p_information20 = hr_api.g_varchar2 THEN
263    l_information20 := null;
264   ELSE
265     l_information20 := p_information20;
266   END IF;
267   IF p_information21 = hr_api.g_varchar2 THEN
268     l_information21 := null;
269   ELSE
270     l_information21 := p_information21;
271   END IF;
272   IF p_information22 = hr_api.g_varchar2 THEN
273     l_information22 := null;
274   ELSE
275     l_information22 := p_information22;
276   END IF;
277   IF p_information23 = hr_api.g_varchar2 THEN
278     l_information23 := null;
279   ELSE
280     l_information23 := p_information23;
281   END IF;
282   IF p_information24 = hr_api.g_varchar2 THEN
283     l_information24 := null;
284   ELSE
285     l_information24 := p_information24;
286   END IF;
287   IF p_information25 = hr_api.g_varchar2 THEN
288     l_information25 := null;
289   ELSE
290    l_information25 := p_information25;
291   END IF;
292   IF p_information26 = hr_api.g_varchar2 THEN
293     l_information26 := null;
294   ELSE
295     l_information26 := p_information26;
296   END IF;
297   IF p_information27 = hr_api.g_varchar2 THEN
298     l_information27 := null;
299   ELSE
300     l_information27 := p_information27;
301   END IF;
302   IF p_information28 = hr_api.g_varchar2 THEN
303     l_information28 := null;
304   ELSE
305     l_information28 := p_information28;
306   END IF;
307   IF p_information29 = hr_api.g_varchar2 THEN
308     l_information29 := null;
309   ELSE
310     l_information29 := p_information29;
311   END IF;
312   IF p_information30 = hr_api.g_varchar2 THEN
313    l_information30 := null;
314   ELSE
315     l_information30 := p_information30;
316   END IF;
317 
318  If l_index = 'aei' then
319 -- There are chances that the history table didn't have date corresponding to an
320 -- Extra info, as of the given effective_date , but the extra info table itself might have
321 -- the data. This cursor fetches the extra info id  of the information_type to be updated
322 -- to ensure that the correct procedure is then called to create/udpate EI.
323   hr_utility.set_location('l_extra_info_id is ' ||l_extra_info_id || '  ' || l_proc,9);
324    If l_Extra_Info_Id  is null then
325      for asg_ei in c_asg_ei loop
326        l_extra_info_id := asg_ei.assignment_extra_info_id;
327        l_ovn           := asg_ei.object_version_number;
328      end loop;
329   hr_utility.set_location('l_extra_info_id is ' ||l_extra_info_id || '  ' || l_proc,10);
330    Else
331        l_ovn      := p_l_object_version_number;
332   hr_utility.set_location('l_extra_info_id is ' ||l_extra_info_id || '  ' || l_proc,11);
333    End if;
334 
335    If l_extra_info_id is null then
336      hr_utility.set_location(l_proc,15);
337      hr_assignment_extra_info_api.create_assignment_extra_info
338      ( p_assignment_id              =>    P_Pa_request_rec.Employee_Assignment_id
339       ,p_Information_type               =>    p_l_information_type
340       ,p_aei_information_category   =>    p_l_information_type
341       , p_aei_information1              =>    l_information1
342       , p_aei_information2              =>    l_information2
343       , p_aei_information3              =>    l_information3
344       , p_aei_information4              =>    l_information4
345       , p_aei_information5              =>    l_information5
346         , p_aei_information6            =>    l_information6
347         , p_aei_information7            =>    l_information7
348         , p_aei_information8            =>    l_information8
349         , p_aei_information9            =>    l_information9
350       , p_aei_information10             =>    l_information10
351         , p_aei_information11           =>    l_information11
352         , p_aei_information12           =>    l_information12
353         , p_aei_information13           =>    l_information13
354         , p_aei_information14         =>    l_information14
355         , p_aei_information15           =>    l_information15
356       , p_aei_information16             =>    l_information16
357         , p_aei_information17           =>    l_information17
358         , p_aei_information18           =>    l_information18
359         , p_aei_information19           =>    l_information19
360         , p_aei_information20           =>    l_information20
361         , p_aei_information21           =>    l_information21
362         , p_aei_information22           =>    l_information22
363         , p_aei_information23           =>    l_information23
364         , p_aei_information24           =>    l_information24
365         , p_aei_information25           =>    l_information25
366         , p_aei_information26           =>    l_information26
367         , p_aei_information27           =>    l_information27
368         , p_aei_information28           =>    l_information28
369         , p_aei_information29           =>    l_information29
370         , p_aei_information30           =>    l_information30
371         , p_assignment_extra_info_id  =>    l_asg_cre_extra_info_id
372         , p_object_version_number     =>    l_asg_cre_ovn );
373    Else
374      hr_utility.set_location(l_proc,20);
375      hr_assignment_extra_info_api.update_assignment_extra_info
376      ( p_assignment_extra_info_id =>    l_Extra_Info_Id
377      , p_object_version_number    =>    l_ovn
378      , p_aei_information1           =>    p_information1
379      , p_aei_information2           =>    p_information2
380      , p_aei_information3           =>    p_information3
381      , p_aei_information4           =>    p_information4
382      , p_aei_information5           =>    p_information5
383      , p_aei_information6         =>    p_information6
384      , p_aei_information7           =>    p_information7
385      , p_aei_information8           =>    p_information8
386      , p_aei_information9           =>    p_information9
387      , p_aei_information10          =>    p_information10
388      , p_aei_information11          =>    p_information11
389      , p_aei_information12          =>    p_information12
390      , p_aei_information13        =>    p_information13
391      , p_aei_information14          =>    p_information14
392      , p_aei_information15        =>    p_information15
393      , p_aei_information16          =>    p_information16
394      , p_aei_information17        =>    p_information17
395      , p_aei_information18          =>    p_information18
396      , p_aei_information19          =>    p_information19
397      , p_aei_information20          =>    p_information20
398      , p_aei_information21          =>    p_information21
399      , p_aei_information22          =>    p_information22
400      , p_aei_information23          =>    p_information23
401      , p_aei_information24          =>    p_information24
402      , p_aei_information25          =>    p_information25
403      , p_aei_information26          =>    p_information26
404      , p_aei_information27          =>    p_information27
405      , p_aei_information28          =>    p_information28
406      , p_aei_information29          =>    p_information29
407      , p_aei_information30          =>    p_information30);
408 --
409   End if;
410 End if;
411 --
412 
413 -- Update/Create Person Extra Info
414 --
415 --
416 If l_index = 'pei' then
417   hr_utility.set_location(l_proc,25);
418 
419    If l_Extra_Info_Id  is null then
420      hr_utility.set_location(to_char(l_id),1);
421      hr_utility.set_location(p_l_information_type,2);
422      for per_ei in c_per_ei loop
423        l_extra_info_id := per_ei.person_extra_info_id;
424        l_ovn           := per_ei.object_version_number;
425      end loop;
426     Else
427        l_ovn    :=  p_l_object_version_number;
428    End if;
429    hr_utility.set_location('pei_ovn is '  || to_char(l_ovn),1);
430    -- Bug#5045806 For Service Obligation EIT, Always create new EIT Record.
431    IF  P_l_Information_Type  = 'GHR_US_PER_SERVICE_OBLIGATION' THEN
432         l_extra_info_id := NULL;
433    END IF;
434    -- Bug#5045806
435    If l_extra_info_id is null then
436      hr_utility.set_location(l_proc,30);
437      hr_person_extra_info_api.create_person_extra_info
438      (p_Person_id                             =>    P_Pa_request_rec.Person_id
439      ,p_Information_type                =>    p_l_information_type
440      ,p_pei_information_category    =>    p_l_information_type
441      ,p_pei_information1                =>    l_information1
442      , p_pei_information2               =>    l_information2
443      , p_pei_information3               =>    l_information3
444      , p_pei_information4               =>    l_information4
445      , p_pei_information5               =>    l_information5
446      , p_pei_information6               =>    l_information6
447      , p_pei_information7               =>    l_information7
448      , p_pei_information8               =>    l_information8
449      , p_pei_information9               =>    l_information9
450      , p_pei_information10              =>    l_information10
451      , p_pei_information11              =>    l_information11
452      , p_pei_information12              =>    l_information12
453      , p_pei_information13              =>    l_information13
454      , p_pei_information14          =>    l_information14
455      , p_pei_information15              =>    l_information15
456      , p_pei_information16              =>    l_information16
457      , p_pei_information17              =>    l_information17
458      , p_pei_information18              =>    l_information18
459      , p_pei_information19              =>    l_information19
460      , p_pei_information20              =>    l_information20
461      , p_pei_information21              =>    l_information21
462      , p_pei_information22              =>    l_information22
463      , p_pei_information23              =>    l_information23
464      , p_pei_information24              =>    l_information24
465      , p_pei_information25              =>    l_information25
466      , p_pei_information26              =>    l_information26
467      , p_pei_information27              =>    l_information27
468      , p_pei_information28              =>    l_information28
469      , p_pei_information29              =>    l_information29
470      , p_pei_information30              =>    l_information30
471      ,p_person_extra_info_id        =>    l_per_cre_extra_info_id
472      ,p_object_version_number           =>    l_per_cre_ovn );
473   Else
474 --
475     hr_utility.set_location(l_proc,35);
476     hr_person_extra_info_api.update_person_extra_info
477     ( p_person_extra_info_id    =>    l_Extra_Info_Id
478     , p_object_version_number   =>    l_ovn
479     , p_pei_information1                =>    p_information1
480     , p_pei_information2                =>    p_information2
481     , p_pei_information3                =>    p_information3
482     , p_pei_information4                =>    p_information4
483     , p_pei_information5                =>    p_information5
484     , p_pei_information6                =>    p_information6
485     , p_pei_information7                =>    p_information7
486     , p_pei_information8                =>    p_information8
487     , p_pei_information9                =>    p_information9
488     , p_pei_information10               =>    p_information10
489     , p_pei_information11               =>    p_information11
490     , p_pei_information12               =>    p_information12
491     , p_pei_information13               =>    p_information13
492     , p_pei_information14               =>    p_information14
493     , p_pei_information15               =>    p_information15
494     , p_pei_information16               =>    p_information16
495     , p_pei_information17               =>    p_information17
496     , p_pei_information18               =>    p_information18
497     , p_pei_information19               =>    p_information19
498     , p_pei_information20               =>    p_information20
499     , p_pei_information21               =>    p_information21
500     , p_pei_information22               =>    p_information22
501     , p_pei_information23               =>    p_information23
502     , p_pei_information24               =>    p_information24
503     , p_pei_information25               =>    p_information25
504     , p_pei_information26               =>    p_information26
505     , p_pei_information27               =>    p_information27
506     , p_pei_information28               =>    p_information28
507     , p_pei_information29               =>    p_information29
508     , p_pei_information30               =>    p_information30);
509 --
510    End if;
511  End if;
512 --
513 --
514 -- Update/Create Position group1 Extra Info
515 --
516 --
517 If l_index = 'poei' then
518   hr_utility.set_location(l_proc,40);
519   If l_Extra_Info_Id  is null then
520     for pos_ei in c_pos_ei loop
521       l_extra_info_id := pos_ei.position_extra_info_id;
522       l_ovn := pos_ei.object_version_number;
523     end loop;
524   Else
525       l_ovn  :=  p_l_object_version_number;
526   End if;
527   hr_utility.set_location(l_proc,45);
528   If l_extra_info_id is null then
529     hr_position_extra_info_api.create_position_extra_info
530    ( p_position_id                      =>    P_Pa_request_rec.to_position_id
531    , p_Information_type               =>    p_l_information_type
532    , p_poei_information_category    =>    p_l_information_type
533    , p_poei_information1                =>    l_information1
534    , p_poei_information2                =>    l_information2
535    , p_poei_information3                =>    l_information3
536    , p_poei_information4                =>    l_information4
537    , p_poei_information5                =>    l_information5
538    , p_poei_information6                =>    l_information6
539    , p_poei_information7                =>    l_information7
540    , p_poei_information8                =>    l_information8
541    , p_poei_information9                =>    l_information9
542    , p_poei_information10               =>    l_information10
543    , p_poei_information11               =>    l_information11
544    , p_poei_information12               =>    l_information12
545    , p_poei_information13               =>    l_information13
546    , p_poei_information14           =>    l_information14
547    , p_poei_information15               =>    l_information15
548    , p_poei_information16           =>    l_information16
549    , p_poei_information17               =>    l_information17
550    , p_poei_information18               =>    l_information18
551    , p_poei_information19               =>    l_information19
552    , p_poei_information20               =>    l_information20
553    , p_poei_information21               =>    l_information21
554    , p_poei_information22               =>    l_information22
555    , p_poei_information23               =>    l_information23
556    , p_poei_information24               =>    l_information24
557    , p_poei_information25               =>    l_information25
558    , p_poei_information26               =>    l_information26
559    , p_poei_information27               =>    l_information27
560    , p_poei_information28               =>    l_information28
561    , p_poei_information29               =>    l_information29
562    , p_poei_information30               =>    l_information30
563    ,p_position_extra_info_id    =>    l_pos1_cre_extra_info_id
564    ,p_object_version_number     =>    l_pos1_cre_ovn
565    );
566 --
567  Else
568 --
569    hr_utility.set_location(l_proc,50);
570    hr_utility.set_location('GEN UPD' || to_char(l_Extra_Info_Id ),1);
571    hr_utility.set_location('GEN UPD' || to_char(p_l_Object_Version_Number ),1);
572 
573    hr_position_extra_info_api.update_position_extra_info
574   ( p_position_extra_info_id    =>    l_Extra_Info_Id
575   , p_object_version_number             =>    l_ovn
576   , p_poei_information1                 =>    p_information1
577   , p_poei_information2                 =>    p_information2
578   , p_poei_information3                 =>    p_information3
579   , p_poei_information4                 =>    p_information4
580   , p_poei_information5                 =>    p_information5
581   , p_poei_information6                 =>    p_information6
582   , p_poei_information7                 =>    p_information7
583   , p_poei_information8                 =>    p_information8
584   , p_poei_information9                 =>    p_information9
585   , p_poei_information10                =>    p_information10
586   , p_poei_information11                =>    p_information11
587   , p_poei_information12                =>    p_information12
588   , p_poei_information13                =>    p_information13
589   , p_poei_information14                =>    p_information14
590   , p_poei_information15                =>    p_information15
591   , p_poei_information16                =>    p_information16
592   , p_poei_information17                =>    p_information17
593   , p_poei_information18                =>    p_information18
594   , p_poei_information19                =>    p_information19
595   , p_poei_information20                =>    p_information20
596   , p_poei_information21                =>    p_information21
597   , p_poei_information22                =>    p_information22
598   , p_poei_information23                =>    p_information23
599   , p_poei_information24                =>    p_information24
600   , p_poei_information25                =>    p_information25
601   , p_poei_information26                =>    p_information26
602   , p_poei_information27                =>    p_information27
603   , p_poei_information28                =>    p_information28
604   , p_poei_information29                =>    p_information29
605   , p_poei_information30                =>    p_information30
606   );
607 --
608  End if;
609 End if;
610 --
611 --
612   hr_utility.set_location('Leaving ' ||l_proc,60);
613  Exception when others then
614           --
615           -- Reset IN OUT parameters and set OUT parameters
616           --
617           p_l_object_version_number := l_initial_ovn;
618           raise;
619 
620 End Generic_Update_Extra_Info;
621 
622 Procedure Update_Retained_Grade
623 (P_PA_REQUEST_REC               IN     GHR_PA_REQUESTS%ROWTYPE ,
624  P_Per_retained_grade           IN OUT NOCOPY GHR_API.Per_retained_grade_TYPE) IS
625 --
626 --
627 cursor c_702_rec is
628  select rei_information3,pei_information1,
629         pei.object_version_number ovn
630   from ghr_pa_request_extra_info rei,
631        per_people_extra_info pei
632  where pa_request_id = p_pa_request_rec.pa_request_id
633  and pei.person_extra_info_id = rei.rei_information3
634  and pei.information_type = 'GHR_US_RETAINED_GRADE'
635  and rei.information_type = 'GHR_US_PAR_TERM_RG_PROMO'
636  and nvl(rei.rei_information30,hr_api.g_varchar2) <> 'Original RPA';
637 --
638 cursor c_740_rec is
639  select rei_information3,pei_information1,
640         pei.object_version_number ovn
641   from ghr_pa_request_extra_info rei,
642        per_people_extra_info pei
643  where pa_request_id = p_pa_request_rec.pa_request_id
644  and pei.person_extra_info_id = rei.rei_information3
645  and pei.information_type = 'GHR_US_RETAINED_GRADE'
646  and rei.information_type = 'GHR_US_PAR_TERM_RG_POSN_CHG'
647  and (rei.rei_information5 is null or rei.rei_information5 = 'Y')
648  and nvl(rei.rei_information30,hr_api.g_varchar2) <> 'Original RPA';
649 
650 
651 l_retained_grade_rec          ghr_pay_calc.retained_grade_rec_type;
652 l_ret_grade_rec               ghr_pay_calc.retained_grade_rec_type;
653 -- Bug#4698321 created l_cur_date_from variable.
654 l_cur_date_from               per_people_extra_info.pei_information1%type;
655 l_new_date_to                 per_people_extra_info.pei_information1%type;
656 l_new_grade_or_level          per_people_extra_info.pei_information3%type;
657 l_new_pay_plan                per_people_extra_info.pei_information3%type;
658 l_new_pay_table               per_people_extra_info.pei_information3%type;
659 l_new_loc_percent             per_people_extra_info.pei_information3%type;
660 l_new_pay_basis               per_people_extra_info.pei_information3%type;
661 l_temp_step                   per_people_extra_info.pei_information9%type;
662 l_new_temp_step               per_people_extra_info.pei_information9%type;
663 l_new_step_or_rate            per_people_extra_info.pei_information4%type;
664 l_step_or_rate                per_people_extra_info.pei_information4%type;
665 l_ret_object_version_number   ghr_pa_requests.object_version_number%type;
666 l_ovn                         ghr_pa_requests.object_version_number%type;
667 
668 
669 CURSOR cur_temp_step
670 IS
671 SELECT  rei_information3 temp_step
672 FROM    ghr_pa_request_extra_info
673 WHERE   pa_request_id = p_pa_request_rec.pa_request_id
674 AND     information_type = 'GHR_US_PAR_RG_TEMP_PROMO';
675 
676 l_session                   ghr_history_api.g_session_var_type;
677 l_proc            varchar2(70) := 'Update_Retained_Grade';
678 l_per_retained_grade GHR_API.Per_retained_grade_TYPE;
679  -- Bug#4698321 Added pei_information1 to the cursor.
680  Cursor c_retained_grade_ovn  is
681    select object_version_number,
682           pei_information1,
683           pei_information2,
684           pei_information3,
685           pei_information4,
686           pei_information5,
687           pei_information6,
688           pei_information7,
689           pei_information8,
690           pei_information9
691    from   per_people_extra_info
692 where  person_extra_info_id = l_retained_grade_rec.person_extra_info_id;
693 
694 l_effective_date Date;
695 BEGIN
696     hr_utility.set_location('Entering '||l_proc,5);
697     l_per_retained_grade := P_Per_retained_grade;
698     ghr_history_api.get_g_session_var(l_session); -- Bug 3021003
699     hr_utility.set_location('Effective Date '||p_pa_request_rec.effective_date,1);
700     IF p_pa_request_rec.first_noa_code = '702' THEN
701         --702 Processing
702         hr_utility.set_location('702 RG Processing '||l_proc,10);
703         FOR rg_rec in c_702_rec LOOP
704             hr_utility.set_location('Effective Date '||p_pa_request_rec.effective_date,1);
705             hr_utility.set_location('702 RG Processing '||rg_rec.rei_information3,11);
706             IF fnd_date.canonical_to_date(rg_rec.pei_information1) >
707               (p_pa_request_rec.effective_date - 1) THEN
708                 hr_utility.set_message(8301,'GHR_38692_RG_TO_DATE_LESSER');
709                 hr_utility.raise_error;
710             END IF;
711             Generic_Update_Extra_Info
712               (p_pa_request_rec          =>   P_PA_REQUEST_REC
713               ,p_l_information_type      =>   'GHR_US_RETAINED_GRADE'
714               ,p_extra_info_id           =>   rg_rec.rei_information3
715               ,p_l_object_version_number =>   rg_rec.ovn
716               ,p_information2            =>   fnd_date.date_to_canonical(p_pa_request_rec.effective_date - 1)
717               );
718         END LOOP;
719     ELSIF p_pa_request_rec.first_noa_code = '740' THEN
720         --740 Processing
721         hr_utility.set_location('740 RG Processing '||l_proc,15);
722         FOR rg_rec in c_740_rec LOOP
723             hr_utility.set_location('Effective Date '||p_pa_request_rec.effective_date,1);
724             hr_utility.set_location('740 RG Processing '||rg_rec.rei_information3,12);
725             IF fnd_date.canonical_to_date(rg_rec.pei_information1) >
726             (p_pa_request_rec.effective_date - 1) THEN
727                 hr_utility.set_message(8301,'GHR_38692_RG_TO_DATE_LESSER');
728                 hr_utility.raise_error;
729             END IF;
730             Generic_Update_Extra_Info
731             (p_pa_request_rec          =>   P_PA_REQUEST_REC
732             ,p_l_information_type      =>   'GHR_US_RETAINED_GRADE'
733             ,p_extra_info_id           =>   rg_rec.rei_information3
734             ,p_l_object_version_number =>   rg_rec.ovn
735             ,p_information2            =>  fnd_date.date_to_canonical(p_pa_request_rec.effective_date - 1)
736             );
737         END LOOP;
738 -------Bug 5913362 -- Adding 890
739     ELSIF p_pa_request_rec.first_noa_code IN ('866', '890') THEN
740         -- 866 Processing
741         IF p_per_retained_grade.per_retained_grade_flag =  'Y' THEN
742            IF p_pa_request_rec.first_noa_code = '890' THEN
743                  l_effective_date := p_pa_request_rec.effective_date - 1;
744            ELSE
745                  l_effective_date := p_pa_request_rec.effective_date;
746            END IF;
747             --
748             hr_utility.set_location('866 RG Processing '||l_proc,15);
749             hr_utility.set_location('Inside 866 processing '||p_per_retained_grade.person_extra_info_id,1);
750             Generic_Update_Extra_Info
751             (p_pa_request_rec          =>   P_PA_REQUEST_REC
752             ,p_l_information_type      =>   'GHR_US_RETAINED_GRADE'
753             ,p_extra_info_id           =>   p_per_retained_grade.person_extra_info_id
754             ,p_l_object_version_number =>   p_per_retained_grade.object_version_number
755             ,p_information2            =>   fnd_date.date_to_canonical(l_effective_date)
756             );
757             FOR cur_temp_step_rec IN cur_temp_step LOOP
758                 l_new_temp_step  := cur_temp_step_rec.temp_step;
759             END LOOP;
760             IF  l_new_temp_step is not null  THEN
761                 l_retained_grade_rec :=
762                 ghr_pc_basic_pay.get_retained_grade_details
763                 (p_person_id      =>   p_pa_request_rec.person_id,
764                 p_effective_date  =>   p_pa_request_rec.effective_date,
765                 p_pa_request_id   =>   p_pa_request_rec.pa_request_id
766                 );
767                 IF l_retained_grade_rec.person_extra_info_id is not null then
768                     hr_utility.set_location('Inside 866 processing '||l_retained_grade_rec.person_extra_info_id,1);
769                     FOR retained_grade_ovn IN c_retained_grade_ovn LOOP
770                         l_ret_object_version_number := retained_grade_ovn.object_version_number;
771                         l_new_date_to             := retained_grade_ovn.pei_information2;
772                         l_new_grade_or_level      := retained_grade_ovn.pei_information3;
773                         l_new_step_or_rate        := retained_grade_ovn.pei_information4;
774                         l_new_pay_plan            := retained_grade_ovn.pei_information5;
775                         l_new_pay_table           := retained_grade_ovn.pei_information6;
776                         l_new_loc_percent         := retained_grade_ovn.pei_information7;
777                         l_new_pay_basis           := retained_grade_ovn.pei_information8;
778                         exit;
779                     END LOOP;
780                     ghr_history_api.get_g_session_var(l_session);
781                     hr_utility.set_location('Inside 866 processing ',2);
782                     IF l_session.noa_id_correct is null then
783                         -- End date the existing RG record
784                         hr_person_extra_info_api.update_person_extra_info
785                         (p_person_extra_info_id      =>  l_retained_grade_rec.person_extra_info_id,
786                         p_object_version_number     =>  l_ret_object_version_number,
787                         p_pei_information2          =>  fnd_date.date_to_canonical(p_pa_request_rec.effective_date )
788                         );
789                         hr_utility.set_location('Inside 866 processing ',3);
790                         -- Create the new RG Record with Temporary Promotion Step Value
791                         hr_person_extra_info_api.create_person_extra_info
792                         (p_person_id                =>  p_pa_request_rec.person_id,
793                         p_information_type         =>  'GHR_US_RETAINED_GRADE',
794                         p_pei_information_category =>  'GHR_US_RETAINED_GRADE',
795                         p_person_extra_info_id     =>  l_ret_grade_rec.person_extra_info_id,
796                         p_object_version_number    =>  l_ret_object_version_number,
797                         p_pei_information1         =>
798                         fnd_date.date_to_canonical(p_pa_request_rec.effective_date + 1),
799                         p_pei_information2         =>  l_new_date_to,
800                         p_pei_information3         =>  l_new_grade_or_level,
801                         p_pei_information4         =>  l_new_step_or_rate,
802                         p_pei_information5         =>  l_new_pay_plan,
803                         p_pei_information6         =>  l_new_pay_table,
804                         p_pei_information7         =>  l_new_loc_percent,
805                         p_pei_information8         =>  l_new_pay_basis,
806                         p_pei_information9         =>  l_new_temp_step
807                         );
808                         hr_utility.set_location('Inside 866 processing ',3);
809                     ELSE
810                         -- Update the TPS in Retain Grade record
811                         hr_person_extra_info_api.update_person_extra_info
812                         (p_person_extra_info_id      => l_retained_grade_rec.person_extra_info_id,
813                         p_object_version_number     =>  l_ret_object_version_number,
814                         p_pei_information9          =>  l_new_temp_step
815                         );
816                     END IF;
817                 END IF;
818             END IF;
819         END IF;
820     -- Sundar 3021003 Need to update Person EI with the retained grade for WGI, QSI actions, if Step is different
821     -- from Person EI.
822     ELSIF p_pa_request_rec.first_noa_code IN ('867','892','893') AND  l_session.noa_id_correct IS NOT NULL
823       AND p_pa_request_rec.PAY_RATE_DETERMINANT in ('A','B','E','F','U','V') THEN    -- Bug 3500132
824         l_retained_grade_rec :=
825         ghr_pc_basic_pay.get_retained_grade_details
826         (p_person_id      =>   p_pa_request_rec.person_id,
827         p_effective_date  =>   p_pa_request_rec.effective_date,
828         p_pa_request_id   =>   p_pa_request_rec.altered_pa_request_id
829         );
830         hr_utility.set_location('Inside Sun processing '||l_retained_grade_rec.person_extra_info_id,1);
831         IF l_retained_grade_rec.person_extra_info_id IS NOT NULL THEN
832             FOR retained_grade_ovn IN c_retained_grade_ovn LOOP
833                 l_ret_object_version_number := retained_grade_ovn.object_version_number;
834                 EXIT;
835             END LOOP;
836 			hr_utility.set_location('P_Per_retained_grade.step_or_rate '||P_Per_retained_grade.retain_step_or_rate,1);
837 			hr_utility.set_location('l_retained_grade_rec.step_or_rate '||l_retained_grade_rec.step_or_rate,1);
838 			IF (NVL(P_Per_retained_grade.retain_step_or_rate,-1) <> NVL(l_retained_grade_rec.step_or_rate,-1)) THEN
839                 hr_person_extra_info_api.update_person_extra_info
840                   (p_person_extra_info_id      =>  l_retained_grade_rec.person_extra_info_id,
841                    p_object_version_number     =>  l_ret_object_version_number,
842                    p_pei_information4          =>  P_Per_retained_grade.retain_step_or_rate
843                   );
844 			END IF;
845 			hr_utility.set_location('P_Per_retained_grade.temp_step '||P_Per_retained_grade.temp_step,1);
846 			hr_utility.set_location('l_retained_grade_rec.temp_step '||l_retained_grade_rec.temp_step,1);
847 			IF (NVL(P_Per_retained_grade.temp_step,-1) <> NVL(l_retained_grade_rec.temp_step,-1)) THEN
848 				hr_person_extra_info_api.update_person_extra_info
849 				  (p_person_extra_info_id      =>  l_retained_grade_rec.person_extra_info_id,
850 				   p_object_version_number     =>  l_ret_object_version_number,
851 				   p_pei_information9          =>  P_Per_retained_grade.temp_step
852 				  );
853 			END IF;
854 		END IF;
855     END IF;
856     --
857     -- SKIP the following process for NOA Code 866 as it is already handled in the above code.
858     -- However, don't skip NOACs 702,740 as they may not terminate RG. In some cases, they
859     -- may have effective RG record.
860 -------Bug 5913362 -- Adding 890
861     IF (ghr_pay_calc.g_fwfa_pay_calc_flag) and
862         p_pa_request_rec.first_noa_code NOT IN ('866', '890')THEN
863 
864         BEGIN
865             -- FWFA Changes Bug#4444609 Added the IF Condition.
866             l_retained_grade_rec := ghr_pc_basic_pay.get_retained_grade_details
867                                          (p_person_id      =>   p_pa_request_rec.person_id,
868                                          p_effective_date  =>   p_pa_request_rec.effective_date,
869                                          p_pa_request_id   =>   p_pa_request_rec.pa_request_id
870                                          );
871 
872             IF l_retained_grade_rec.person_extra_info_id is not null then
873                 hr_utility.set_location('Inside FWFA RG processing '||l_retained_grade_rec.person_extra_info_id,1);
874                 FOR retained_grade_ovn IN c_retained_grade_ovn LOOP
875                     l_ret_object_version_number := retained_grade_ovn.object_version_number;
876                     l_cur_date_from            := retained_grade_ovn.pei_information1;
877                     l_new_date_to               := retained_grade_ovn.pei_information2;
878                     l_new_grade_or_level        := retained_grade_ovn.pei_information3;
879                     l_new_step_or_rate          := retained_grade_ovn.pei_information4;
880                     l_new_pay_plan              := retained_grade_ovn.pei_information5;
881                     l_new_pay_table             := retained_grade_ovn.pei_information6;
882                     l_new_loc_percent           := retained_grade_ovn.pei_information7;
883                     l_new_pay_basis             := retained_grade_ovn.pei_information8;
884                     l_new_temp_step             := retained_grade_ovn.pei_information9;
885                     exit;
886                 END LOOP;
887 
888                 IF ghr_pay_calc.g_pay_table_upd_flag THEN
889                     l_new_pay_table  := p_per_retained_grade.retain_pay_table_id;
890                     p_per_retained_grade.per_retained_grade_flag :=  'Y';
891                 END IF;
892 
893                 IF p_pa_request_rec.first_noa_code in ('867','892','893') AND
894                    l_session.noa_id_correct IS NULL THEN
895                     -- Handled the retained step and temp.step cases separately
896                    p_per_retained_grade.per_retained_grade_flag :=  'Y';
897 
898 		            IF l_new_temp_step IS NOT NULL THEN
899                         IF TO_NUMBER(l_new_temp_step) < 9 THEN
900                             l_temp_step     :=  '0' ||(l_new_temp_step + 1 );
901                             l_new_temp_step :=  l_temp_step;
902                         ELSE
903                             l_temp_step :=   l_new_temp_step + 1 ;
904                             l_new_temp_step :=  l_temp_step;
905                         END IF;
906                     ELSE -- For Retained Grade
907                         if to_number(l_new_step_or_rate) < 9 then
908                             l_step_or_rate   := '0' ||(l_new_step_or_rate + 1 );
909                             l_new_step_or_rate := l_step_or_rate;
910                         ELSE
911                             l_step_or_rate   :=  l_new_step_or_rate + 1;
912                             l_new_step_or_rate := l_step_or_rate;
913                         END IF;
914                     END IF; -- If l_retained_grade_rec.temp_step is not null
915                     hr_utility.set_location('FWFA New Step or Rate for Ret Grd Rec. is  ' || l_new_step_or_rate,3);
916                     hr_utility.set_location('FWFA temp_step is  ' || l_new_temp_step,2);
917                 END IF;
918 
919                   ---BUG# 4999237 HANDLED FOR 894 TERMINATION OF PAY RETENTION
920                   -- Bug#5679022 Pass the g_step_or_rate in case of 894 for pay retention termination.
921                   IF p_pa_request_rec.first_noa_code = '894' THEN
922                      IF ghr_process_sf52.g_step_or_rate IS NOT NULL THEN
923                          l_new_step_or_rate := ghr_process_sf52.g_step_or_rate;
924                          p_per_retained_grade.per_retained_grade_flag :=  'Y';
925                      END IF;
926                   END IF;
927                   --END BUG 4999237
928 
929                 hr_utility.set_location('new Pay table id :'||p_per_retained_grade.retain_pay_table_id,20);
930                 -- Bug#4698321 IF the retained grade record starts on the same day of the action,
931                 -- update the same record. Otherwise, end date current record and create new record.
932                 -- Bug#4719037 RG record created unnecessarily where g_pay_table_upd_flag is FALSE.
933                 -- So, added the per_retained_grade_flag condition to avoid it.
934                 IF p_per_retained_grade.per_retained_grade_flag = 'Y' THEN
935                     IF TRUNC(fnd_date.canonical_to_date(l_cur_date_from)) = TRUNC(p_pa_request_rec.effective_date) THEN
936                         hr_utility.set_location('RG Start date Equal to RPA Effective Date ',22);
937                         Generic_Update_Extra_Info
938                         (p_pa_request_rec          =>   P_PA_REQUEST_REC
939                         ,p_l_information_type      =>   'GHR_US_RETAINED_GRADE'
940                         ,p_extra_info_id           =>   l_retained_grade_rec.person_extra_info_id
941                         ,p_l_object_version_number =>   l_ret_object_version_number
942                         ,p_information1            =>   l_cur_date_from
943                         ,p_information2            =>   l_new_date_to
944                         ,p_information3            =>   l_new_grade_or_level
945                         ,p_information4            =>   l_new_step_or_rate
946                         ,p_information5            =>   l_new_pay_plan
947                         ,p_information6            =>   l_new_pay_table
948                         ,p_Information7            =>   l_new_loc_percent
949                         ,p_information8            =>   l_new_pay_basis
950                         ,p_information9            =>   l_new_temp_step
951                        );
952                     ELSE
953                         hr_utility.set_location('RG Start date NOT EQUAL to RPA Effective Date ',27);
954                         Generic_Update_Extra_Info
955                         (p_pa_request_rec          =>   P_PA_REQUEST_REC
956                         ,p_l_information_type      =>   'GHR_US_RETAINED_GRADE'
957                         ,p_extra_info_id           =>   l_retained_grade_rec.person_extra_info_id
958                         ,p_l_object_version_number =>   l_ret_object_version_number
959                         ,p_information2            =>  fnd_date.date_to_canonical(p_pa_request_rec.effective_date - 1)
960                         );
961 
962                         -- Create the new RG Record with Temporary Promotion Step Value
963                         hr_person_extra_info_api.create_person_extra_info
964                         (p_person_id                =>  p_pa_request_rec.person_id,
965                         p_information_type         =>  'GHR_US_RETAINED_GRADE',
966                         p_pei_information_category =>  'GHR_US_RETAINED_GRADE',
967                         p_person_extra_info_id     =>  l_ret_grade_rec.person_extra_info_id,
968                         p_object_version_number    =>  l_ovn,
969                         p_pei_information1         =>
970                         fnd_date.date_to_canonical(p_pa_request_rec.effective_date),
971                         p_pei_information2         =>  l_new_date_to,
972                         p_pei_information3         =>  l_new_grade_or_level,
973                         p_pei_information4         =>  l_new_step_or_rate,
974                         p_pei_information5         =>  l_new_pay_plan,
975                         p_pei_information6         =>  l_new_pay_table,
976                         p_pei_information7         =>  l_new_loc_percent,
977                         p_pei_information8         =>  l_new_pay_basis,
978                         p_pei_information9         =>  l_new_temp_step
979                         );
980                     END IF;
981                     hr_utility.set_location('Inside FWFA processing ',3);
982                 END IF; -- per_retained_grade_flag
983             END IF;  -- l_retained_grade_rec.person_extra_info_id NOT NULL
984         EXCEPTION
985             -- IF No RG Record Exists, skip this updation.
986             WHEN ghr_pay_calc.pay_calc_message THEN
987                 NULL;
988             WHEN OTHERS THEN
989                 RAISE;
990         END;
991     END IF;
992     -- FWFA Changes
993 Exception when others then
994           --
995           -- Reset IN OUT parameters and set OUT parameters
996           --
997           P_Per_retained_grade := l_per_retained_grade;
998           raise;
999 
1000 END Update_Retained_Grade;
1001 --
1002 ------------------------------
1003 -- Procedure Update_edu_sit -- To create/Update Education Sp. Info Type
1004 -------------------------------
1005 
1006 Procedure update_edu_sit
1007 (p_pa_request_rec    in ghr_pa_requests%rowtype
1008 ) is
1009 
1010 l_proc                      varchar2(72) := 'Generic Sit';
1011 l_business_group_id         per_people_f.business_group_id%type;
1012 l_id_flex_num               fnd_id_flex_structures.id_flex_num%type;
1013 l_analysis_criteria_id      per_analysis_criteria.analysis_criteria_id%type;
1014 l_personal_analysis_id      per_person_analyses.person_analysis_id%type;
1015 l_education_level           ghr_pa_requests.education_level%type;
1016 l_year_degree_attained      ghr_pa_requests.year_degree_attained%type;
1017 l_academic_discipline       ghr_pa_requests.academic_discipline%type;
1018 l_object_version_number     number(9);
1019 l_multiple                  varchar2(1);
1020 l_session                   ghr_history_api.g_session_var_type;
1021 l_special_info              ghr_api.special_information_type;
1022 
1023 
1024 
1025 -- Cursor to fetch the id_flex_num for the "US Fed Education" structure
1026 
1027 Cursor c_flex_num is
1028   select id_flex_num
1029   from   fnd_id_flex_structures_tl
1030   where  id_flex_structure_name = 'US Fed Education'
1031   and    language = 'US';
1032 --  and    id_flex_code           = 'PEA'  --??
1033 --  and    application_id         =  800   --??
1034 
1035 -- Cursor to check if  the Special info type record already exists for the person
1036 
1037 Cursor c_person_sit is
1038   select analysis_criteria_id ,
1039          person_analysis_id   ,
1040          object_version_number
1041   from   per_person_analyses
1042   where  person_id    =  p_pa_request_rec.person_id
1043   and    id_flex_num  =  l_id_flex_num;
1044 
1045 --  Cursor to return the record with the highest education level (segment1) for the person for the specific id_flex_num
1046 
1047 Cursor     c_special_info is
1048   select   pea.analysis_criteria_id,
1049            pea.segment1 education_level,
1050            pea.segment2 academic_discipline,
1051            pea.segment3 year_degree_attained,
1052            pan.person_analysis_id,
1053            pan.object_version_number
1054   from     per_analysis_criteria pea,
1055            per_person_analyses pan
1056   where    pan.person_id             =  p_pa_request_rec.person_id
1057             and     pan.id_flex_num           =  l_id_flex_num
1058                 and     pea.id_flex_num           =  pan.id_flex_num
1059             and     p_pa_request_rec.effective_date
1060                 between nvl(pan.date_from,p_pa_request_rec.effective_date)
1061                 and     nvl(pan.date_to,p_pa_request_rec.effective_date)
1062                 and     p_pa_request_rec.effective_date
1063                 between nvl(pea.start_date_active,p_pa_request_rec.effective_date)
1064                 and     nvl(pea.end_date_active,p_pa_request_rec.effective_date)
1065                 and     pan.analysis_criteria_id        =  pea.analysis_criteria_id
1066   order by pea.segment1 desc;
1067 
1068 
1069 --
1070 Cursor c_edu_sit is
1071   select  segment1 education_level,
1072           segment2 academic_discipline,
1073           segment3 year_degree_attained
1074   from    per_analysis_criteria
1075   where   analysis_criteria_id = l_analysis_criteria_id
1076   and     id_flex_num          = l_id_flex_num;
1077 
1078 -- Cursor to select the business_group_id that the person belongs to
1079 
1080 Cursor  c_bgpid is
1081   select business_group_id
1082   from   per_all_people_f
1083   where  person_id = p_pa_request_rec.person_id
1084   and    p_pa_request_rec.effective_date
1085   between  effective_start_date and effective_end_date;
1086 
1087 -- Cursor to check if the specific special info. type is Multiple Occurring, depending on which
1088 -- we can then determine whether a record has to be created / Updated
1089 
1090 Cursor   c_multiple_occur is
1091   select multiple_occurrences_flag
1092   from   per_special_info_types sit
1093   where  business_group_id = l_business_group_id
1094   and    id_flex_num       = l_id_flex_num;
1095 
1096 
1097  -- determine whether to create or update sit
1098  -- 1 Get the id_flex_num for the id_flex_structure 'US Fed Education'
1099 
1100 begin
1101     hr_utility.set_location('Entering ' || l_proc,5);
1102 
1103     for bgp in c_bgpid loop
1104       hr_utility.set_location(l_proc,10);
1105       l_business_group_id := bgp.business_group_id;
1106     End loop;
1107 
1108     for flex_num in c_flex_num loop
1109       hr_utility.set_location(l_proc,12);
1110       l_id_flex_num  :=  flex_num.id_flex_num;
1111     end loop;
1112     hr_utility.set_location(l_proc,15);
1113 
1114  -- Check to see if the person already has an entry for the SIT
1115 
1116     for person_sit in c_person_sit loop
1117       hr_utility.set_location(l_proc,20);
1118       l_analysis_criteria_id  := person_sit.analysis_criteria_id;
1119       l_personal_analysis_id  := person_sit.person_analysis_id;
1120       l_object_version_number := person_sit.object_version_number;
1121     End loop;
1122 
1123 -- If l_analysis_Criteria_id is null, then create a sit.
1124 -- If it exists, and multiple_occurences allowed
1125 -- If it exists check if the values have to updated at all. If they are the same do not update
1126 -- else update_sit
1127 
1128 
1129 -- Note : If multiple_occurences are allowed, for the special_info_type, then
1130 --        Update only in case of a 'CORRECTION' ,else create new rows in pan and pea
1131 --        Also while retrieving , fetch the row that has the highest education level -??
1132 
1133 
1134    If l_analysis_criteria_id is null then
1135      hr_utility.set_location(l_proc,25);
1136      hr_sit_api.create_sit
1137      (p_person_id                  => p_pa_request_rec.person_id,
1138       p_business_group_id          => l_business_group_id,
1139       p_id_flex_num                => l_id_flex_num,
1140       p_effective_date             => p_pa_request_rec.effective_date,
1141       p_date_from                  => p_pa_request_rec.effective_date,
1142       p_segment1                   => p_pa_request_rec.education_level,
1143       p_segment2                   => p_pa_request_rec.academic_discipline,
1144       p_segment3                   => p_pa_request_rec.year_degree_attained,
1145       p_analysis_criteria_id       => l_analysis_criteria_id, --out
1146       p_person_analysis_id         => l_personal_analysis_id,
1147       p_pea_object_version_number  => l_object_version_number
1148      );
1149      hr_utility.set_location(l_proc,30);
1150 
1151    Else
1152      -- If sit already exists for the person and it can be multiple occurring, then
1153      -- if it is not a correction, then create  a new one, else update
1154         hr_utility.set_location(l_proc,35);
1155      /*
1156         Commented out nocopy by skutteti for bug # 655203 as multiple occurences flag need not be checked for edu sit.
1157      for  multiple_occur in c_multiple_occur loop
1158        hr_utility.set_location(l_proc,36);
1159        l_multiple :=  multiple_occur.multiple_occurrences_flag;
1160      end loop;
1161      */
1162 
1163     ghr_history_api.get_g_session_var(l_session);
1164      If l_session.noa_id_correct  is null then
1165        l_personal_analysis_id := Null;
1166        for special_info in c_special_info loop
1167          hr_utility.set_location(l_proc,40);
1168          l_education_level       := special_info.education_level;
1169          l_academic_discipline   := special_info.academic_discipline;
1170          l_year_degree_attained  :=  special_info.year_degree_attained;
1171          l_personal_analysis_id  :=   special_info.person_analysis_id;
1172          l_object_version_number :=  special_info.object_version_number;
1173          exit;
1174        End loop;
1175       Else -- read from history
1176         l_personal_analysis_id := Null;
1177         ghr_history_fetch.return_special_information
1178         (p_person_id          => p_pa_request_rec.person_id,
1179          p_structure_name     => 'US Fed Education',
1180          p_effective_date     => p_pa_request_rec.effective_date,
1181          p_special_info       => l_special_info
1182          );
1183          l_education_level       :=  l_special_info.segment1;
1184          l_academic_discipline   :=  l_special_info.segment2;
1185          l_year_degree_attained  :=  l_special_info.segment3;
1186          l_personal_analysis_id  :=  l_special_info.person_analysis_id;
1187          l_object_version_number :=  l_special_info.object_version_number;
1188      End if;
1189 
1190      hr_utility.set_location(l_proc,45);
1191 hr_utility.set_location('l_education_level is  '||l_education_level,46);
1192     hr_utility.set_location('l_academic_discipline is  '||l_academic_discipline,47);
1193     hr_utility.set_location('l_year_degree_attained is  '||l_year_degree_attained,48);
1194 
1195     hr_utility.set_location('p_pa_request_rec.education_level is  '||p_pa_request_rec.education_level,46);
1196     hr_utility.set_location('p_pa_request_rec.academic_discipline is  '||p_pa_request_rec.academic_discipline,46);
1197     hr_utility.set_location('p_pa_request_rec.year_degree_attained is  '||p_pa_request_rec.year_degree_attained,46);
1198 
1199      If nvl(l_education_level,hr_api.g_varchar2)     <> nvl(p_pa_request_rec.education_level,hr_api.g_varchar2)     or
1200         nvl(l_academic_discipline,hr_api.g_varchar2) <> nvl(p_pa_request_rec.academic_discipline,hr_api.g_varchar2) or
1201         to_char(nvl(l_year_degree_attained,hr_api.g_number))  <> to_char(nvl(p_pa_request_rec.year_degree_attained,hr_api.g_number)) then
1202 
1203         -- Commented out by skutteti for bug # 655203 as multiple occurences flag need not be checked for edu sit.
1204         -- If nvl(l_multiple,'Y') = 'Y' and l_session.noa_id_correct is null then
1205 
1206         If l_session.noa_id_correct is null or l_personal_analysis_id is null then
1207            hr_utility.set_location(l_proc,37);
1208       l_analysis_criteria_id  := null;
1209            hr_sit_api.create_sit
1210           (p_person_id                  => p_pa_request_rec.person_id,
1211            p_business_group_id          => l_business_group_id,
1212            p_id_flex_num                => l_id_flex_num,
1213            p_effective_date             => p_pa_request_rec.effective_date,
1214            p_date_from                  => p_pa_request_rec.effective_date,
1215            p_segment1                   => p_pa_request_rec.education_level,
1216            p_segment2                   => p_pa_request_rec.academic_discipline,
1217            p_segment3                   => to_char(p_pa_request_rec.year_degree_attained),
1218            p_analysis_criteria_id       => l_analysis_criteria_id, --out
1219            p_person_analysis_id         => l_personal_analysis_id,
1220            p_pea_object_version_number  => l_object_version_number
1221           );
1222         Else
1223       l_analysis_criteria_id  := null;
1224            hr_sit_api.update_sit
1225           (p_person_analysis_id         => l_personal_analysis_id,
1226            p_pea_object_version_number  => l_object_version_number,
1227            p_date_from                  => p_pa_request_rec.effective_date,   ---??
1228            p_segment1                   => p_pa_request_rec.education_level,
1229            p_segment2                   => p_pa_request_rec.academic_discipline,
1230            p_segment3                   => p_pa_request_rec.year_degree_attained,
1231            p_analysis_criteria_id       => l_analysis_criteria_id
1232            );
1233            hr_utility.set_location(l_proc,55);
1234         End if;
1235      End if;
1236   End if;
1237 End update_edu_sit;
1238 --
1239 
1240 
1241 --
1242 
1243 
1244 -- *************************
1245 -- Procedure  call_extra_info_api
1246 -- *************************
1247 --
1248 Procedure  call_extra_info_api
1249  (P_PA_REQUEST_REC                IN  GHR_PA_REQUESTS%ROWTYPE,
1250  P_Asg_Sf52                       IN OUT NOCOPY GHR_API.Asg_Sf52_TYPE,
1251  P_Asg_non_Sf52                   IN OUT NOCOPY GHR_API.Asg_non_Sf52_TYPE,
1252  P_Asg_nte_dates                  IN OUT NOCOPY GHR_API.Asg_nte_dates_TYPE,
1253  P_Per_Sf52                       IN OUT NOCOPY GHR_API.Per_Sf52_TYPE,
1254  P_Per_Group1                     IN OUT NOCOPY GHR_API.Per_Group1_TYPE,
1255  P_Per_Group2                     IN OUT NOCOPY GHR_API.Per_Group2_TYPE,
1256  P_Per_scd_info                   IN OUT NOCOPY GHR_API.Per_scd_info_TYPE,
1257  P_Per_retained_grade             IN OUT NOCOPY GHR_API.Per_retained_grade_TYPE,
1258  P_Per_probations                 IN OUT NOCOPY GHR_API.Per_probations_TYPE,
1259  P_Per_sep_retire                 IN OUT NOCOPY GHR_API.Per_sep_retire_TYPE,
1260  P_Per_security                   IN OUT NOCOPY GHR_API.Per_security_TYPE,
1261  --Bug#4486823 RRR Changes
1262  p_per_service_oblig              IN OUT NOCOPY GHR_API.Per_service_oblig_TYPE,
1263  P_Per_conversions                IN OUT NOCOPY GHR_API.Per_conversions_TYPE,
1264  -- BEN_EIT Changes
1265  p_per_benefit_info	          IN OUT nocopy ghr_api.per_benefit_info_type,
1266  P_Per_uniformed_services         IN OUT NOCOPY GHR_API.Per_uniformed_services_TYPE,
1267  P_Pos_oblig                      IN OUT NOCOPY GHR_API.Pos_oblig_TYPE,
1268  P_Pos_Grp2                       IN OUT NOCOPY GHR_API.Pos_Grp2_TYPE,
1269  P_Pos_Grp1                       IN OUT NOCOPY GHR_API.Pos_Grp1_TYPE,
1270  P_Pos_valid_grade                IN OUT NOCOPY GHR_API.Pos_valid_grade_TYPE,
1271  P_Pos_car_prog                   IN OUT NOCOPY GHR_API.Pos_car_prog_TYPE,
1272  p_Perf_appraisal                 IN out nocopy ghr_api.performance_appraisal_type,
1273  p_conduct_performance            IN out nocopy ghr_api.conduct_performance_type,
1274  P_Loc_Info                       IN OUT NOCOPY GHR_API.Loc_Info_TYPE,
1275  P_generic_Extra_Info_Rec         IN out nocopy GHR_api.generic_Extra_Info_Rec_Type,
1276  P_par_term_retained_grade        IN out nocopy GHR_api.par_term_retained_grade_type,
1277  p_per_race_ethnic_info      	  IN out nocopy ghr_api.per_race_ethnic_type,
1278  -- Bug #6312144 New RPA EIT Benefits
1279  p_ipa_benefits_cont              IN out nocopy ghr_api.per_ipa_ben_cont_info_type,
1280  p_retirement_info                IN out nocopy ghr_api.per_retirement_info_type)  is
1281 
1282 --
1283  l_proc             varchar2(70) := 'Call Extra Info';
1284  l_segment_rec      ghr_api.special_information_type;
1285  l_form_field_name  varchar2(50);
1286  l_posn_title_pm    varchar2(50);
1287  l_WS_pm            varchar2(50);
1288  l_DS_pm            varchar2(50);
1289  l_personnel_office_id   ghr_pa_requests.personnel_office_id%type;       --\
1290  l_org_structure_id      per_position_extra_info.poei_information5%type; -------bug#2623692
1291  l_Organ_Component       per_position_extra_info.poei_information5%type; --/
1292 -- JH Get To Position Title PM for Noa Code being updated. Bug 773851
1293   Cursor get_to_posn_title_pm is
1294     select  fpm.process_method_code
1295     from    ghr_noa_families         nof
1296            ,ghr_families             fam
1297            ,ghr_noa_fam_proc_methods fpm
1298            ,ghr_pa_data_fields       pdf
1299     where   nof.nature_of_action_id = p_pa_request_rec.first_noa_id
1300     and     nof.noa_family_code     = fam.noa_family_code
1301     and     nof.enabled_flag = 'Y'
1302     and     p_pa_request_rec.effective_date between nvl(nof.start_date_active,p_pa_request_rec.effective_date)
1303     and     nvl(nof.end_date_active,p_pa_request_rec.effective_date )
1304     and     fam.proc_method_flag = 'Y'
1305     and     fam.enabled_flag = 'Y'
1306     and     p_pa_request_rec.effective_date between nvl(fam.start_date_active,p_pa_request_rec.effective_date)
1307     and     nvl(fam.end_date_active,p_pa_request_rec.effective_date)
1308     and     fam.noa_family_code = fpm.noa_family_code
1309     and     fpm.pa_data_field_id = pdf.pa_data_field_id
1310     and     fpm.enabled_flag = 'Y'
1311     and     p_pa_request_rec.effective_date between nvl(fpm.start_date_active,p_pa_request_rec.effective_date)
1312     and     nvl(fpm.end_date_active,p_pa_request_rec.effective_date)
1313     and     pdf.form_field_name = l_form_field_name
1314     and     pdf.enabled_flag = 'Y'
1315     and     p_pa_request_rec.effective_date between nvl(pdf.date_from,p_pa_request_rec.effective_date)
1316     and     nvl(pdf.date_to,p_pa_request_rec.effective_date );
1317 
1318 ------------------ cursor created to handle Null Org Struct id for MRE Correction
1319 Cursor c_pei_null_OPM(p_position_id number) is
1320 select poei_information5 l_org_structure_id
1321 from per_position_extra_info
1322 where information_type='GHR_US_POS_GRP1' and position_id=p_position_id;
1323 
1324 ----------------------------------- cursor to handle changes to LAC codes for Correction to Apptmt action 1274541
1325 Cursor c_Corr_LAC_Codes(p_pa_request_id number) is
1326 select second_action_la_code1,second_action_la_code2,first_noa_code,second_noa_code,
1327 second_action_la_desc1,second_action_la_desc2 --Bug# 4941984(AFHR2)
1328 from ghr_pa_requests
1329 where pa_request_id=p_pa_request_id and first_noa_code='002';
1330 
1331 
1332 Cursor fam_code(p_second_noa_id number) is
1333 select noa_family_code from ghr_noa_families
1334 where nature_of_action_id=p_second_noa_id and noa_family_code='APP'
1335 AND
1336 nature_of_action_id not in (select nature_of_action_id from ghr_noa_families
1337 where noa_family_code='APPT_TRANS');
1338 
1339 --
1340 -- 2839332
1341 --
1342 Cursor Cur_Par_Asg(p_ssn VARCHAR2) is
1343 select par.first_noa_code
1344 from
1345 ghr_pa_requests par,
1346 per_Assignments_f asg
1347 where asg.assignment_id=par.employee_assignment_id
1348 and par.employee_national_identifier=p_ssn
1349 and noa_family_code not in
1350 ('NON_PAY_DUTY_STATUS','RETURN_TO_DUTY','CANCEL','CORRECT')
1351 and par.effective_date=asg.effective_start_date
1352 Order by effective_date asc;
1353 
1354 -- 2839332 Madhuri
1355 -- 3263014 Sundar Datatype of the parameters have been changed to table.column_name%type
1356 /*Cursor Cur_NTE_dates(p_ssn ghr_pa_requests.employee_national_identifier%type, p_noa_code ghr_pa_requests.first_noa_code%type) is
1357 select first_noa_information1 NTE_Dates
1358 from ghr_pa_requests
1359 where first_noa_code=p_noa_code
1360 and noa_family_code not in
1361 ('NON_PAY_DUTY_STATUS','RETURN_TO_DUTY','CANCEL','CORRECT')
1362 and employee_national_identifier=p_ssn;
1363 */
1364 -- Sundar Bug 3390876
1365 -- Get the effective date of Non-Pay duty status
1366 CURSOR cur_eff_date_non_pay(c_person_id ghr_pa_requests.person_id%type,c_eff_date ghr_pa_requests.effective_date%type)
1367 IS
1368 SELECT
1369   MAX(par.effective_date) eff_date
1370 FROM
1371   ghr_pa_requests par
1372 WHERE
1373   par.person_id= c_person_id  AND
1374   par.noa_family_code = 'NON_PAY_DUTY_STATUS' AND
1375   par.pa_notification_id IS NOT NULL AND
1376   NVL(par.first_noa_cancel_or_correct,'NULL') <> 'CANCEL' AND
1377   par.effective_date < c_eff_date;
1378 
1379 CURSOR cur_nte_date_aft_np(c_person_id ghr_pa_requests.person_id%type,
1380                            c_eff_date ghr_pa_requests.effective_date%type, c_rtd_date ghr_pa_requests.effective_date%type)
1381 IS
1382 SELECT
1383   par.first_noa_information1 nte_date
1384 FROM
1385   ghr_pa_requests par
1386 WHERE
1387   par.person_id= c_person_id  AND
1388   par.effective_date BETWEEN c_eff_date AND c_rtd_date AND
1389   par.pa_notification_id IS NOT NULL  AND
1390   NVL(par.first_noa_cancel_or_correct, 'NULL') <> 'CANCEL' AND
1391   par.first_noa_code IN ('508','515','517','522','548','549','553','554','571','590','750','760','761','762','765','769','770');
1392 
1393 /*CURSOR Cur_NTE_date_bef_np(c_person_id ghr_pa_requests.person_id%type,c_eff_date ghr_pa_requests.effective_date%type)
1394 IS
1395 SELECT
1396   first_noa_information1 NTE_Dates
1397 FROM
1398   ghr_pa_requests par,
1399   per_Assignments_f asg
1400 WHERE
1401   asg.assignment_id= par.employee_assignment_id AND
1402   asg.effective_start_date = par.effective_date AND
1403   par.person_id= c_person_id AND
1404   par.effective_date < c_eff_date AND
1405   par.noa_family_code NOT IN ('NON_PAY_DUTY_STATUS','RETURN_TO_DUTY','CANCEL','CORRECT')  AND
1406   par.pa_notification_id IS NOT NULL AND
1407   NVL(par.first_noa_cancel_or_correct, 'NULL') <> 'CANCEL'
1408   ORDER BY effective_date ASC;
1409 */
1410 l_noa_code              VARCHAR2(80);
1411 l_NTE_Dates             per_assignment_extra_info.aei_information4%TYPE;
1412 
1413 --
1414 -- for bug 3191704
1415 CURSOR cur_rei_poi(p_par_id in NUMBER)
1416 IS
1417 SELECT rei_information5
1418 FROM   ghr_pa_request_extra_info
1419 WHERE  pa_request_id=p_par_id
1420 AND    information_type='GHR_US_PAR_REALIGNMENT';
1421 
1422 target_poi              ghr_pa_requests.personnel_office_id%type;
1423 -- for bug 3191704
1424 
1425 --l_NTE_Dates   per_assignment_extra_info.aei_information4%TYPE;
1426 ---------------------------------------------------------- added 2 cursors for 1274541
1427 --Begin Bug 5919705
1428 l_grade_or_level ghr_pa_requests.to_grade_or_level%type;
1429 l_pay_plan       ghr_pa_requests.to_pay_plan%type;
1430 
1431 CURSOR cur_grd1 IS
1432     SELECT  gdf.segment1 pay_plan,
1433             gdf.segment2 grade_or_level
1434     FROM    per_grade_definitions gdf,
1435             per_grades grd
1436     WHERE   grd.grade_id            =   p_pos_valid_grade.target_grade
1437     AND     grd.grade_definition_id =   gdf.grade_definition_id
1438     AND     grd.business_group_id   =   FND_PROFILE.value('PER_BUSINESS_GROUP_ID');
1439 
1440 CURSOR cur_grd2 IS
1441     SELECT  grd.grade_id
1442     FROM    per_grade_definitions gdf,
1443             per_grades grd
1444     WHERE   grd.grade_definition_id = gdf.grade_definition_id
1445     and     gdf.segment1            = l_pay_plan
1446     and     gdf.segment2            = l_grade_or_level
1447     and     grd.business_group_id   = FND_PROFILE.value('PER_BUSINESS_GROUP_ID');
1448 --End Bug 5919705
1449 l_first_noa_code ghr_pa_requests.first_noa_code%type;
1450 l_second_noa_code ghr_pa_requests.second_noa_code%type;
1451 l_fam_code ghr_pa_requests.noa_family_code%type;
1452 
1453 l_Cur_Appt_Auth_1                       per_people_extra_info.pei_information8%type;
1454 l_Cur_Appt_Auth_2                       per_people_extra_info.pei_information9%type;
1455 --Bug# 4941984(AFHR2)
1456 l_Cur_Appt_Auth_desc1                   per_people_extra_info.pei_information22%type;
1457 l_Cur_Appt_Auth_desc2                   per_people_extra_info.pei_information23%type;
1458 --Bug# 4941984(AFHR2)
1459 
1460 -- No copy Changes variables.
1461  l_Asg_Sf52                         GHR_API.Asg_Sf52_TYPE;
1462  l_Asg_non_Sf52                     GHR_API.Asg_non_Sf52_TYPE;
1463  l_Asg_nte_dates                    GHR_API.Asg_nte_dates_TYPE;
1464  l_Per_Sf52                         GHR_API.Per_Sf52_TYPE;
1465  l_Per_Group1                       GHR_API.Per_Group1_TYPE;
1466  l_Per_Group2                       GHR_API.Per_Group2_TYPE;
1467  l_Per_scd_info                     GHR_API.Per_scd_info_TYPE;
1468  l_Per_retained_grade               GHR_API.Per_retained_grade_TYPE;
1469  l_Per_probations                   GHR_API.Per_probations_TYPE;
1470  l_Per_sep_retire                   GHR_API.Per_sep_retire_TYPE;
1471  l_Per_security                     GHR_API.Per_security_TYPE;
1472  --Bug#4486823 RRR Changes
1473  l_per_service_oblig                GHR_API.Per_service_oblig_TYPE;
1474  l_Per_conversions                  GHR_API.Per_conversions_TYPE;
1475  l_per_race_ethnic_info             ghr_api.per_race_ethnic_type; -- Race or National Origin changes
1476  -- BEN_EIT Changes
1477  l_per_benefit_info		    GHR_API.per_benefit_info_type;
1478  l_Per_uniformed_services           GHR_API.Per_uniformed_services_TYPE;
1479  l_Pos_oblig                        GHR_API.Pos_oblig_TYPE;
1480  l_Pos_Grp2                         GHR_API.Pos_Grp2_TYPE;
1481  l_Pos_Grp1                         GHR_API.Pos_Grp1_TYPE;
1482  l_Pos_valid_grade                  GHR_API.Pos_valid_grade_TYPE;
1483  l_Pos_car_prog                     GHR_API.Pos_car_prog_TYPE;
1484  l_Perf_appraisal                   ghr_api.performance_appraisal_type;
1485  l_conduct_performance              ghr_api.conduct_performance_type;
1486  l_Loc_Info                         GHR_API.Loc_Info_TYPE;
1487  l_generic_Extra_Info_Rec           GHR_api.generic_Extra_Info_Rec_Type;
1488  l_par_term_retained_grade          GHR_api.par_term_retained_grade_type;
1489 ---for bug 3267632
1490  l_agency_code_transfer_to          ghr_pa_requests.agency_code%type;
1491 --
1492 -- Bug 3390876
1493  l_np_eff_date ghr_pa_requests.effective_date%type;
1494  l_asg_ei_data per_assignment_extra_info%rowtype;
1495 Begin
1496 --
1497   hr_utility.set_location('Entering  ' ||l_proc,5);
1498   hr_utility.set_location('CALL EXT INFOper_serv_oblig_flag '||p_per_service_oblig.per_service_oblig_flag,10);
1499   --
1500   -- Remember IN OUT parameter IN values
1501   --
1502  l_Asg_Sf52                         := P_Asg_Sf52;
1503  l_Asg_non_Sf52                     := P_Asg_non_Sf52;
1504  l_Asg_nte_dates                    := P_Asg_nte_dates;
1505  l_Per_Sf52                         := P_Per_Sf52;
1506  l_Per_Group1                       := P_Per_Group1;
1507  l_Per_Group2                       := P_Per_Group2;
1508  l_Per_scd_info                     := P_Per_scd_info;
1509  l_Per_retained_grade               := P_Per_retained_grade;
1510  l_Per_probations                   := P_Per_probations;
1511  l_Per_sep_retire                   := P_Per_sep_retire;
1512  l_Per_security                     := P_Per_security;
1513  -- Bug#4486823 RRR changes
1514  l_per_service_oblig                := P_per_service_oblig;
1515  l_Per_conversions                  := P_Per_conversions;
1516  -- BEN_EIT Changes
1517  l_per_benefit_info                 := P_Per_benefit_info;
1518  l_Per_uniformed_services           := P_Per_uniformed_services;
1519  l_Pos_oblig                        := P_Pos_oblig;
1520  l_Pos_Grp2                         := P_Pos_Grp2;
1521  l_Pos_Grp1                         := P_Pos_Grp1;
1522  l_Pos_valid_grade                  := P_Pos_valid_grade;
1523  l_Pos_car_prog                     := P_Pos_car_prog;
1524  l_Perf_appraisal                   := P_Perf_appraisal;
1525  l_conduct_performance              := P_conduct_performance;
1526  l_Loc_Info                         := P_Loc_Info;
1527  l_generic_Extra_Info_Rec           := P_generic_Extra_Info_Rec;
1528  l_par_term_retained_grade          := P_par_term_retained_grade;
1529  l_per_race_ethnic_info		    := p_per_race_ethnic_info;
1530 
1531   IF P_asg_sf52.asg_sf52_flag  =  'Y'
1532   OR ghr_process_sf52.g_prd is not null THEN
1533   -- FWFA Changes
1534 --
1535     hr_utility.set_location(l_proc,10);
1536     Generic_Update_Extra_Info
1537     (
1538      p_pa_request_rec                   =>    P_PA_REQUEST_REC
1539     ,p_l_information_type               =>    'GHR_US_ASG_SF52'
1540     ,p_extra_info_id                    =>    p_asg_sf52.assignment_extra_info_id
1541     ,p_l_object_version_number          =>    p_asg_sf52.object_version_number
1542     ,p_information3                     =>    p_asg_sf52.step_or_rate
1543     ,p_information4                     =>    p_asg_sf52.tenure
1544     ,p_information5                     =>    p_asg_sf52.annuitant_indicator
1545     ,p_information6                     =>    nvl(ghr_process_sf52.g_prd,p_asg_sf52.pay_rate_determinant)
1546     ,p_information7                     =>    p_asg_sf52.work_schedule
1547     ,p_information8                     =>    p_asg_sf52.part_time_hours
1548     -- FWFA Changes Bug#4444609. Added NVL condition to handle the families that doesn't trigger pay calc.
1549     ,p_information9                     =>    P_Asg_Sf52.calc_pay_table
1550     -- FWFA Changes
1551     );
1552   End if;
1553 --
1554   If P_asg_non_sf52.asg_non_sf52_flag  =  'Y' then
1555 --
1556     hr_utility.set_location(l_proc,15);
1557     Generic_Update_Extra_Info
1558     (
1559      p_pa_request_rec                   =>      P_PA_REQUEST_REC
1560     ,p_l_information_type               =>      'GHR_US_ASG_NON_SF52'
1561     ,p_extra_info_id                    =>      p_asg_non_sf52.assignment_extra_info_id
1562     ,p_l_object_version_number          =>      p_asg_non_sf52.object_version_number
1563     ,p_information3                     =>      p_asg_non_sf52.date_arr_personnel_office
1564  -- ,p_information4                     =>      p_asg_non_sf52.duty_status
1565     ,p_information5                     =>      p_asg_non_sf52.key_emer_essential_empl
1566     ,p_information6                     =>      p_asg_non_sf52.non_disc_agmt_status
1567  -- ,p_information7                     =>      p_asg_non_sf52.date_wtop_exemp_expires
1568     ,p_information8                     =>      p_asg_non_sf52.parttime_indicator
1569     ,p_information9                     =>      p_asg_non_sf52.qualification_standard_waiver
1570  -- ,p_information10            =>      p_asg_non_sf52.trainee_promotion_id
1571  -- ,p_information11            =>      p_asg_non_sf52.date_trainee_promotion_expt
1572      );
1573    End if;
1574 --
1575 
1576    hr_utility.set_location('NTE DATES FLAG  ' || p_asg_nte_dates.asg_nte_dates_flag,1);
1577    If p_asg_nte_dates.asg_nte_dates_flag  =  'Y' then
1578 --
1579 --
1580 
1581    IF (p_pa_request_rec.noa_family_code =  'RETURN_TO_DUTY') THEN
1582 	/*  For PAR_ASG in Cur_Par_Asg(p_pa_request_rec.employee_national_identifier)
1583 	  Loop
1584 				  hr_utility.trace('Inside EMP SSN CURSOR');
1585 						 l_noa_code := PAR_ASG.first_noa_code;
1586 	  End Loop;
1587 
1588 	  hr_utility.set_location('NOA Code for NTE' || l_noa_code , 38);
1589 	  FOR NTE_Dates_rec in Cur_NTE_Dates(p_pa_request_rec.employee_national_identifier,l_noa_code) LOOP
1590 		  l_NTE_Dates := NTE_Dates_rec.NTE_Dates;
1591 	  END LOOP; */
1592 		-- Above Commented by Sundar Replaced it by the below code - Bug 3390876
1593 		-- Get effective date of the Non-Pay duty action.
1594 		FOR l_cur_eff_date_non_pay IN cur_eff_date_non_pay(p_pa_request_rec.person_id, NVL(p_pa_request_rec.effective_date,sysdate)) LOOP
1595 			l_np_eff_date := l_cur_eff_date_non_pay.eff_date;
1596 		END LOOP;
1597 		-- Get NTE Date (i.e. first_noa_information1) If any extension actions are done
1598 		-- after Non-Pay duty status
1599 		FOR l_cur_nte_date IN cur_nte_date_aft_np(p_pa_request_rec.person_id, l_np_eff_date, NVL(p_pa_request_rec.effective_date,sysdate)) LOOP
1600 			l_NTE_Dates := l_cur_nte_date.nte_date;
1601 		END LOOP;
1602 		-- If No record is found in the above cursor, then take NTE date from the assignment
1603 		-- prior to Non-pay-duty status
1604 		IF l_NTE_Dates IS NULL THEN
1605 /*			FOR l_Cur_NTE_date_bef_np in Cur_NTE_date_bef_np(p_pa_request_rec.person_id,l_np_eff_date) LOOP
1606 			  l_NTE_Dates := l_Cur_NTE_date_bef_np.NTE_Dates;
1607 			END LOOP; */
1608 			ghr_history_fetch.fetch_asgei ( p_assignment_id => p_pa_request_rec.employee_assignment_id,
1609                         p_information_type  => 'GHR_US_ASG_NTE_DATES',
1610                         p_date_effective    => (l_np_eff_date-1),
1611                         p_asg_ei_data       => l_asg_ei_data
1612                       );
1613 	-- Bug 3655891 Need to fetch Asg. NTE date from information 4 for Asg. NTE date.
1614 --                l_NTE_Dates := l_asg_ei_data.aei_information3;
1615 	              l_NTE_Dates := l_asg_ei_data.aei_information4;
1616 		END IF;
1617 		-- End Bug 3390876
1618 		IF l_NTE_Dates IS NOT NULL THEN
1619 			p_asg_nte_dates.assignment_nte := l_NTE_Dates;
1620 		END IF;
1621 	END IF;
1622  --
1623  --
1624  hr_utility.set_location(l_proc,20);
1625      Generic_Update_Extra_Info
1626      (
1627       p_pa_request_rec                  =>      P_PA_REQUEST_REC
1628      ,p_l_information_type              =>      'GHR_US_ASG_NTE_DATES'
1629      ,p_extra_info_id                   =>      p_asg_nte_dates.assignment_extra_info_id
1630      ,p_l_object_version_number         =>      p_asg_nte_dates.object_version_number
1631      ,p_information3                    =>      p_asg_nte_dates.asg_nte_start_date
1632      ,p_information4					  =>    p_asg_nte_dates.assignment_nte
1633      ,p_information5                    =>      p_asg_nte_dates.lwop_nte_start_date
1634      ,p_information6                    =>      p_asg_nte_dates.lwop_nte
1635      ,p_information7                    =>      p_asg_nte_dates.suspension_nte_start_date
1636      ,p_information8                    =>      p_asg_nte_dates.suspension_nte
1637      ,p_information9                    =>      p_asg_nte_dates.furlough_nte_start_date
1638      ,p_information10                   =>      p_asg_nte_dates.furlough_nte
1639      ,p_information11               =>    p_asg_nte_dates.lwp_nte_start_date
1640      ,p_information12               =>    p_asg_nte_dates.lwp_nte
1641      ,p_information13               =>    p_asg_nte_dates.sabatical_nte_start_date
1642      ,p_information14               =>    p_asg_nte_dates.sabatical_nte
1643  -- ,p_information15                =>    p_asg_nte_dates.assignment_number
1644  -- ,p_information16                  =>        p_asg_nte_dates.position_nte
1645      );
1646 --
1647 end if;
1648 --
1649 --
1650 --
1651 If p_per_sf52.per_sf52_flag  =  'Y' then
1652 --
1653   hr_utility.set_location(l_proc,30);
1654   Generic_Update_Extra_Info
1655   (
1656    p_pa_request_rec             =>      P_PA_REQUEST_REC
1657   ,p_l_information_type         =>      'GHR_US_PER_SF52'
1658   ,p_extra_info_id                      =>      p_per_sf52.person_extra_info_id
1659   ,p_l_object_version_number    =>      p_per_sf52.object_version_number
1660   ,p_information3                       =>      p_per_sf52.citizenship
1661   ,p_information4                       =>      p_per_sf52.veterans_preference
1662   ,p_information5                       =>      p_per_sf52.veterans_preference_for_rif
1663   ,p_information6                       =>      p_per_sf52.veterans_status
1664   );
1665  --
1666 end if;
1667 --
1668 
1669 ----------------------------------------------------------------------------------- code added for 1274541
1670 
1671 FOR corr_lac IN c_Corr_LAC_Codes(p_pa_request_rec.pa_request_id) LOOP
1672 l_first_noa_code := corr_lac.first_noa_code;
1673 l_second_noa_code:= corr_lac.second_noa_code;
1674 END LOOP;
1675 IF l_first_noa_code = '002' then
1676     If l_second_noa_code = p_pa_request_rec.first_noa_code then
1677         FOR fam_code_rec IN fam_code(p_pa_request_rec.first_noa_id)
1678         LOOP
1679             l_fam_code              := fam_code_rec.noa_family_code;
1680         END LOOP;
1681     end if;
1682 end if;
1683 
1684 If p_per_group1.per_group1_flag =  'Y' then
1685 --
1686 
1687 IF (l_first_noa_code='002' AND l_fam_code='APP') THEN
1688 
1689         FOR corr_lac_rec in c_Corr_LAC_Codes(p_pa_request_rec.pa_request_id)
1690         LOOP
1691 
1692          l_Cur_Appt_Auth_1             :=corr_lac_rec.second_action_la_code1;
1693          l_Cur_Appt_Auth_2             :=corr_lac_rec.second_action_la_code2;
1694          --Bug# 4941984(AFHR2)
1695          l_Cur_Appt_Auth_desc1         :=corr_lac_rec.second_action_la_desc1;
1696          l_Cur_Appt_Auth_desc2         :=corr_lac_rec.second_action_la_desc2;
1697          --Bug# 4941984(AFHR2)
1698         END LOOP;
1699 ELSE
1700         l_Cur_Appt_Auth_1             :=p_per_group1.org_appointment_auth_code1;
1701         l_Cur_Appt_Auth_2             :=p_per_group1.org_appointment_auth_code2;
1702         --Bug# 4941984(AFHR2)
1703         l_Cur_Appt_Auth_desc1         :=p_per_group1.org_appointment_desc1;
1704         l_Cur_Appt_Auth_desc2         :=p_per_group1.org_appointment_desc2;
1705         --Bug# 4941984(AFHR2)
1706 END IF;
1707 
1708 ---------------------------------------------------------------------------------- code added for 1274541
1709 
1710 
1711   hr_utility.set_location(l_proc,35);
1712   Generic_Update_Extra_Info
1713   (
1714    p_pa_request_rec             =>      P_PA_REQUEST_REC
1715   ,p_l_information_type         =>      'GHR_US_PER_GROUP1'
1716   ,p_extra_info_id            =>        p_per_group1.person_extra_info_id
1717   ,p_l_object_version_number  =>        p_per_group1.object_version_number
1718   ,p_information3                       =>      p_per_group1.appointment_type
1719   ,p_information4                       =>      p_per_group1.type_of_employment
1720   ,p_information5                       =>      p_per_group1.race_national_origin
1721 --,p_information6                     =>        p_per_group1.date_last_promotion
1722   ,p_information7                       =>      p_per_group1.agency_code_transfer_from
1723   ,p_information8                       =>      l_Cur_Appt_Auth_1
1724   ,p_information22                      =>      l_Cur_Appt_Auth_desc1--Bug# 4941984(AFHR2)
1725   ,p_information9                       =>      l_Cur_Appt_Auth_2
1726   ,p_information23                      =>      l_Cur_Appt_Auth_desc2--Bug# 4941984(AFHR2)
1727 --,p_information10            =>        p_per_group1.country_world_citizenship
1728   ,p_information11              =>      p_per_group1.handicap_code
1729 --,p_information12            =>        p_per_group1.consent_id
1730 --,p_information13              =>      p_per_group1.date_fehb_eligibility_expires
1731 --,p_information14            =>        p_per_group1.date_temp_eligibility_fehb
1732 --,p_information15            =>        p_per_group1.date_febh_dependent_cert_exp
1733 --,p_information16            =>        p_per_group1.family_member_emp_pref
1734 --,p_information17            =>        p_per_group1.family_member_status
1735   ,p_information21            =>        p_per_group1.retention_inc_review_date
1736    );
1737 --
1738 end if;
1739 --
1740 
1741 /* Note :  Since none of this data is currently being updated, why call the generic_update at all ??? */
1742 
1743 /*If p_per_group2.per_group2_flag   =  'Y' then
1744 --
1745 -- included date_stat_return_rights_expire for p_information7 and named the others correctly.
1746   hr_utility.set_location(l_proc,40);
1747   Generic_Update_Extra_Info
1748  (
1749   p_pa_request_rec              =>      P_PA_REQUEST_REC
1750  ,p_l_information_type          =>      'GHR_US_PER_GROUP2'
1751  ,p_extra_info_id                       =>      p_per_group2.person_extra_info_id
1752  ,p_l_object_version_number     =>      p_per_group2.object_version_number
1753  ,p_information3                        =>      p_per_group2.obligated_position_number
1754  ,p_information4                        =>      p_per_group2.obligated_position_type
1755  ,p_information5                        =>      p_per_group2.date_overseas_tour_expires
1756  ,p_information6                        =>      p_per_group2.date_return_rights_expires
1757  ,p_information7              =>    p_per_group2.date_stat_return_rights_expir
1758  ,p_information8                        =>      p_per_group2.civilian_duty_stat_contigency
1759  ,p_information9                        =>      p_per_group2.date_travel_agmt_pcs_expires
1760  ,p_information10                       =>      p_per_group2.draw_down_action_id
1761  );
1762 --
1763 end if;
1764 */
1765 --
1766 If p_per_scd_info.per_scd_info_flag   =  'Y' then
1767 --
1768   hr_utility.set_location(l_proc,45);
1769   Generic_Update_Extra_Info
1770   (
1771    p_pa_request_rec             =>      P_PA_REQUEST_REC
1772   ,p_l_information_type         =>      'GHR_US_PER_SCD_INFORMATION'
1773   ,p_extra_info_id              =>      p_per_scd_info.person_extra_info_id
1774   ,p_l_object_version_number    =>      p_per_scd_info.object_version_number
1775   ,p_information3                       =>      p_per_scd_info.scd_leave
1776   ,p_information4                       =>      p_per_scd_info.scd_civilian
1777   ,p_information5                       =>      p_per_scd_info.scd_rif
1778   ,p_information6                       =>      p_per_scd_info.scd_tsp
1779   ,p_information7                       =>      p_per_scd_info.scd_retirement
1780   -- Bug 4164083 eHRI New Attribution Changes
1781   ,p_information8                       =>      p_per_scd_info.scd_ses
1782   ,p_information9                       =>      p_per_scd_info.scd_spl_retirement
1783   -- End eHRI New Attribution Changes
1784    --bug 4443968
1785    ,p_information12                      =>    p_per_scd_info.scd_creditable_svc_annl_leave
1786    );
1787 --
1788 end if;
1789 --
1790 If p_per_probations.per_probation_flag   =  'Y' then
1791 --
1792   hr_utility.set_location(l_proc,50);
1793 
1794   Generic_Update_Extra_Info
1795   (
1796    p_pa_request_rec             =>      P_PA_REQUEST_REC
1797   ,p_l_information_type         =>      'GHR_US_PER_PROBATIONS'
1798   ,p_extra_info_id              =>      p_per_probations.person_extra_info_id
1799   ,p_l_object_version_number    =>      p_per_probations.object_version_number
1800   ,p_information3                       =>      p_per_probations.date_prob_trial_period_begin
1801   ,p_information4                       =>      p_per_probations.date_prob_trial_period_ends
1802   --,p_information8                       =>      p_per_probations.date_spvr_mgr_prob_begins --Bug 4588575
1803   ,p_information5                       =>      p_per_probations.date_spvr_mgr_prob_ends
1804   ,p_information6                       =>      p_per_probations.spvr_mgr_prob_completion
1805   ,p_information7                       =>      p_per_probations.date_ses_prob_expires
1806    );
1807 --
1808 end if;
1809 --
1810 -- added for 3267632
1811  If ( p_pa_request_rec.noa_family_code in ('APP','CONV_APP') ) Then
1812   l_agency_code_transfer_to            := NULL;
1813   p_per_sep_retire.per_sep_retire_flag :=  'Y';
1814  else
1815   l_agency_code_transfer_to            := p_per_sep_retire.agency_code_transfer_to;
1816  End if;
1817 -- added for 3267632
1818 --
1819 If p_per_sep_retire.per_sep_retire_flag =  'Y' then
1820 --
1821   hr_utility.set_location(l_proc,55);
1822   Generic_Update_Extra_Info
1823   (
1824    p_pa_request_rec             =>      P_PA_REQUEST_REC
1825   ,p_l_information_type         =>      'GHR_US_PER_SEPARATE_RETIRE'
1826   ,p_extra_info_id              =>      p_per_sep_retire.person_extra_info_id
1827   ,p_l_object_version_number    =>      p_per_sep_retire.object_version_number
1828   ,p_information3                       =>      p_per_sep_retire.fers_coverage
1829   ,p_information4                       =>      p_per_sep_retire.prev_retirement_coverage
1830   ,p_information5                       =>      p_per_sep_retire.frozen_service
1831   ,p_information6                       =>      p_per_sep_retire.naf_retirement_indicator
1832   ,p_information7                       =>      p_per_sep_retire.reason_for_separation
1833   ,p_information8                       =>      l_agency_code_transfer_to
1834 --,p_information9                       =>      p_per_sep_retire.date_projected_retirement
1835 --,p_information10              =>      p_per_sep_retire.mandatory_retirement_date
1836   ,p_information11              =>      p_per_sep_retire.separate_pkg_status_indicator -- Bug 1359482
1837 --,p_information12              =>      p_per_sep_retire.separate_pkg_register_number
1838 --,p_information13              =>      p_per_sep_retire.separate_pkg_pay_office_id
1839 --,p_information14              =>      p_per_sep_retire.date_ret_appl_received
1840 --,p_information15              =>      p_per_sep_retire.date_ret_pkg_sent_to_payroll
1841 --,p_information16              =>      p_per_sep_retire.date_ret_pkg_recv_payroll
1842 --,p_information17              =>      p_per_sep_retire.date_ret_pkg_to_opm
1843   );
1844 --
1845 end if;
1846 --
1847 
1848  /* Note :  Since none of this data is currently being updated, why call the generic_update at all ??? */
1849 
1850 /*If p_per_security.per_security_flag  =  'Y' then
1851 --
1852 hr_utility.set_location(l_proc,60);
1853 Generic_Update_Extra_Info(
1854   p_pa_request_rec              =>      P_PA_REQUEST_REC
1855  ,p_l_information_type          =>      'GHR_US_PER_SECURITY'
1856  ,p_extra_info_id                       =>      p_per_security.person_extra_info_id
1857  ,p_l_object_version_number     =>      p_per_security.object_version_number
1858  ,p_information3                        =>      p_per_security.sec_investigation_basis
1859  ,p_information4                        =>      p_per_security.type_of_sec_investigation
1860  ,p_information5                        =>      p_per_security.date_sec_invest_required
1861  ,p_information6                        =>      p_per_security.date_sec_invest_completed
1862  ,p_information7                        =>      p_per_security.personnel_sec_clearance
1863  ,p_information8                        =>      p_per_security.sec_clearance_eligilb_date
1864  ,p_information9                        =>      p_per_security.prp_sci_status_employment
1865 );
1866 --
1867 end if;
1868 */
1869   hr_utility.set_location('2. CALL EXT INFOper_serv_oblig_flag '||p_per_service_oblig.per_service_oblig_flag,20);
1870 -- Bug#4486823 RRR Changes
1871 IF p_per_service_oblig.per_service_oblig_flag  =  'Y' THEN
1872 --
1873 hr_utility.set_location('NAR'||l_proc,60);
1874 Generic_Update_Extra_Info(
1875   p_pa_request_rec              =>      P_PA_REQUEST_REC
1876  ,p_l_information_type          =>      'GHR_US_PER_SERVICE_OBLIGATION'
1877  ,p_extra_info_id               =>      p_per_service_oblig.person_extra_info_id
1878  ,p_l_object_version_number     =>      p_per_service_oblig.object_version_number
1879  ,p_information3                =>      p_per_service_oblig.service_oblig_type_code
1880  ,p_information4                =>      p_per_service_oblig.service_oblig_end_date
1881  ,p_information5                =>      p_per_service_oblig.service_oblig_start_date
1882 );
1883 --
1884 END IF;
1885 --
1886 -- Added for a patch -- ( for the enhancement)
1887 If p_per_conversions.per_conversions_flag =  'Y' then
1888 --
1889   hr_utility.set_location(l_proc,65);
1890 
1891  Generic_Update_Extra_Info
1892  (
1893   p_pa_request_rec              =>      P_PA_REQUEST_REC
1894  ,p_l_information_type          =>      'GHR_US_PER_CONVERSIONS'
1895  ,p_extra_info_id                       =>      p_per_conversions.person_extra_info_id
1896  ,p_l_object_version_number     =>      p_per_conversions.object_version_number
1897  ,p_information3                        =>      p_per_conversions.date_conv_career_begins
1898  ,p_information4                        =>      p_per_conversions.date_conv_career_due
1899  ,p_information5                        =>      p_per_conversions.date_recmd_conv_begins
1900  ,p_information7              =>    p_per_conversions.date_recmd_conv_due
1901  ,p_information6                        =>      p_per_conversions.date_vra_conv_due
1902  );
1903 --
1904 end if;
1905 --
1906 -- BEN_EIT Changes
1907 If p_per_benefit_info.per_benefit_info_flag =  'Y' then
1908 --
1909   hr_utility.set_location(l_proc,65);
1910 
1911  Generic_Update_Extra_Info
1912  (
1913   p_pa_request_rec              =>      P_PA_REQUEST_REC
1914  ,p_l_information_type          =>      'GHR_US_PER_BENEFIT_INFO'
1915  ,p_extra_info_id               =>      p_per_benefit_info.person_extra_info_id
1916  ,p_l_object_version_number     =>      p_per_benefit_info.object_version_number
1917  ,p_information3                =>      p_per_benefit_info.FEGLI_Date_Eligibility_Expires
1918  ,p_information4            => p_per_benefit_info.FEHB_Date_Eligibility_expires
1919  ,p_information5             => p_per_benefit_info.FEHB_Date_temp_eligibility
1920             ,p_information6        => p_per_benefit_info.FEHB_Date_dependent_cert_expir
1921             ,p_information7        => p_per_benefit_info.FEHB_LWOP_contingency_st_date
1922             ,p_information8        => p_per_benefit_info.FEHB_LWOP_contingency_end_date
1923             ,p_information10       => p_per_benefit_info.FEHB_Child_equiry_court_date
1924             ,p_information11       => p_per_benefit_info.FERS_Date_eligibility_expires
1925             ,p_information12       => p_per_benefit_info.FERS_Election_Date
1926             ,p_information13       => p_per_benefit_info.FERS_Election_Indicator
1927             ,p_information14       => p_per_benefit_info.TSP_Agncy_Contrib_Elig_date
1928             ,p_information15       => p_per_benefit_info.TSP_Emp_Contrib_Elig_date
1929 	      -- 6312144 Added the following RPA -- EIT Benefits segments
1930 	    ,p_information16       => p_per_benefit_info.FEGLI_Assignment_Ind
1931             ,p_information17       => p_per_benefit_info.FEGLI_Post_Elec_Basic_Ins_Amt
1932             ,p_information18       => p_per_benefit_info.FEGLI_Court_Order_Ind
1933             ,p_information19       => p_per_benefit_info.Desg_FEGLI_Benf_Ind
1934             ,p_information20       => p_per_benefit_info.FEHB_Event_Code
1935   );
1936 --
1937 end if;
1938 
1939 -- Race or National Origin changes
1940 If p_per_race_ethnic_info.p_race_ethnic_info_flag =  'Y' then
1941 --
1942   hr_utility.set_location(l_proc,68);
1943 
1944  Generic_Update_Extra_Info
1945  (
1946   p_pa_request_rec              =>      P_PA_REQUEST_REC
1947  ,p_l_information_type          =>      'GHR_US_PER_ETHNICITY_RACE'
1948  ,p_extra_info_id               =>      p_per_race_ethnic_info.person_extra_info_id
1949  ,p_l_object_version_number     =>      p_per_race_ethnic_info.object_version_number
1950  ,p_information3                =>      p_per_race_ethnic_info.p_hispanic
1951  ,p_information4            	=> 		p_per_race_ethnic_info.p_american_indian
1952  ,p_information5             	=> 		p_per_race_ethnic_info.p_asian
1953 ,p_information6        			=> 		p_per_race_ethnic_info.p_black_afr_american
1954 ,p_information7        			=> 		p_per_race_ethnic_info.p_hawaiian_pacific
1955 ,p_information8        			=> 		p_per_race_ethnic_info.p_white
1956   );
1957 --
1958 end if;
1959 
1960 
1961 
1962 --
1963 If p_per_uniformed_services.per_uniformed_services_flag  =  'Y' then
1964 --
1965   hr_utility.set_location(l_proc,70);
1966 
1967   Generic_Update_Extra_Info
1968   (
1969    p_pa_request_rec             =>      P_PA_REQUEST_REC
1970   ,p_l_information_type         =>      'GHR_US_PER_UNIFORMED_SERVICES'
1971   ,p_extra_info_id              =>      p_per_uniformed_services.person_extra_info_id
1972   ,p_l_object_version_number    =>      p_per_uniformed_services.object_version_number
1973 --,p_information3                       =>      p_per_uniformed_services.reserve_category
1974 --,p_information4                       =>      p_per_uniformed_services.military_recall_status
1975   ,p_information5                       =>      p_per_uniformed_services.creditable_military_service
1976 --,p_information6                       =>      p_per_uniformed_services.date_retired_uniform_service
1977 --,p_information7                       =>      p_per_uniformed_services.uniform_service_component
1978 --,p_information8                       =>      p_per_uniformed_services.uniform_service_designation
1979 --,p_information9                       =>      p_per_uniformed_services.retirement_grade
1980 --,p_information10              =>      p_per_uniformed_services.military_retire_waiver_ind
1981 --,p_information11              =>      p_per_uniformed_services.exception_retire_pay_ind
1982   );
1983 --
1984 end if;
1985 --
1986 If p_pos_valid_grade.pos_valid_grade_flag =  'Y' then
1987 --
1988   hr_utility.set_location(l_proc,75);
1989     --Begin Bug 5919705
1990     FOR p_cur_grd1 in  cur_grd1 LOOP
1991         l_grade_or_level := p_cur_grd1.grade_or_level;
1992         l_pay_plan := p_cur_grd1.pay_plan;
1993     END LOOP;
1994     --BEGIN Bug# 7499540
1995     /*IF (p_pa_request_rec.first_noa_code ='890' OR p_pa_request_rec.second_noa_code ='890') AND
1996         p_pa_request_rec.from_pay_plan ='GM' and p_pa_request_rec.to_pay_plan='GS' AND
1997         l_pay_plan ='GM' THEN
1998 
1999         l_pay_plan := 'GS';*/
2000     IF (substr(p_pa_request_rec.first_noa_code,1,2) ='89' OR
2001         SUBSTR(p_pa_request_rec.second_noa_code,1,2) ='89') AND
2002         p_pa_request_rec.from_pay_plan = l_pay_plan AND
2003         p_pa_request_rec.from_pay_plan <> p_pa_request_rec.to_pay_plan AND
2004         SUBSTR(p_pa_request_rec.from_pay_plan,1,1) = SUBSTR(p_pa_request_rec.to_pay_plan,1,1) AND
2005         SUBSTR(p_pa_request_rec.from_pay_plan,1,1) IN('W','G','Y') THEN
2006 
2007          l_pay_plan := p_pa_request_rec.to_pay_plan;
2008      --END Bug# 7499540
2009         FOR p_cur_grd2 in  cur_grd2 LOOP
2010             p_pos_valid_grade.target_grade := p_cur_grd2.grade_id;
2011         END LOOP;
2012     END IF;
2013     --End Bug 5919705
2014   Generic_Update_Extra_Info
2015   (
2016    p_pa_request_rec             =>      P_PA_REQUEST_REC
2017   ,p_l_information_type         =>      'GHR_US_POS_VALID_GRADE'
2018   ,p_extra_info_id              =>      p_pos_valid_grade.position_extra_info_id
2019   ,p_l_object_version_number    =>      p_pos_valid_grade.object_version_number
2020   ,p_information3                       =>      p_pos_valid_grade.valid_grade
2021   ,p_information4                       =>      p_pos_valid_grade.target_grade
2022   ,p_information5                       =>      p_pos_valid_grade.pay_table_id
2023   ,p_information6                       =>      p_pos_valid_grade.pay_basis
2024   ,p_information7                       =>      p_pos_valid_grade.employment_category_group
2025   );
2026 -- Bug#4699682
2027 IF ghr_pay_calc.g_pay_table_upd_flag THEN
2028     ghr_mlc_pkg.position_history_update (p_position_id    => P_PA_REQUEST_REC.to_position_id,
2029                                          p_effective_date => P_PA_REQUEST_REC.effective_date,
2030                                          p_table_id       => P_PA_REQUEST_REC.from_pay_table_identifier,
2031                                          p_upd_tableid    => p_pos_valid_grade.pay_table_id);
2032 END IF;
2033 
2034 --
2035 end if;
2036 --
2037 
2038 If p_Pos_grp1.pos_grp1_flag =  'Y' then
2039 --
2040   hr_utility.set_location(l_proc,80);
2041   hr_utility.set_location('bef upd ' || 'PEID' || to_char(p_pos_grp1.position_extra_info_id),1);
2042   hr_utility.set_location('bef upd ' || 'PEOVN' || to_char(p_pos_grp1.object_version_number),1);
2043 
2044 -- JH Include WS/PTH if To Position PM is UE or APUE and to_posn <> from_posn. Bug 773851
2045 -- Bug 2462929 If WS pm in APUE or UE then update WS/PTH.
2046   hr_utility.set_location('To Posn ID ' || p_pa_request_rec.to_position_id ,81);
2047   hr_utility.set_location('From Posn ID ' || p_pa_request_rec.from_position_id ,81);
2048 
2049   l_form_field_name := 'TO_POSITION_TITLE';
2050   FOR pm_rec in get_to_posn_title_pm LOOP
2051     l_posn_title_pm := pm_rec.process_method_code;
2052   END Loop;
2053 
2054   l_form_field_name := 'WORK_SCHEDULE';
2055   FOR pm_rec in get_to_posn_title_pm LOOP
2056     l_WS_pm := pm_rec.process_method_code;
2057   END Loop;
2058 
2059   hr_utility.set_location('To Posn PM ' || l_posn_title_pm ,81);
2060   IF p_pa_request_rec.to_position_id IS NOT NULL AND l_posn_title_pm in ('APUE','UE')
2061     AND nvl(p_pa_request_rec.to_position_id,hr_api.g_number) <>
2062     nvl(p_pa_request_rec.from_position_id,hr_api.g_number)
2063     OR p_pa_request_rec.to_position_id IS NOT NULL AND l_WS_pm in ('APUE','UE')
2064     OR nvl(p_pa_request_rec.first_noa_code,hr_api.g_number) = '782'
2065     OR nvl(p_pa_request_rec.second_noa_code,hr_api.g_number) = '782'
2066  THEN
2067     hr_utility.set_location('Posn Update With WS/PTH' || l_posn_title_pm ,81);
2068 
2069 ---------------------------- bug#2623692
2070 
2071 if( p_pos_grp1.organization_structure_id is null) then
2072                 FOR OPM_CUR IN c_pei_null_OPM(p_pa_request_rec.from_position_id) LOOP
2073                         l_Organ_Component              :=OPM_CUR.l_org_structure_id;
2074                 END LOOP;
2075 else
2076  l_Organ_Component              :=p_pos_grp1.organization_structure_id;
2077 end if;
2078 
2079 if (p_pa_request_rec.first_noa_code='790' or p_pa_request_rec.second_noa_code='790') then
2080 --l_personnel_office_id:=p_pa_request_rec.personnel_office_id;
2081 -- bug 3191704
2082 	FOR poi_rec IN cur_rei_poi(p_pa_request_rec.pa_request_id)
2083 	LOOP
2084 	 target_poi := poi_rec.rei_information5;
2085 	END LOOP;
2086 	--
2087 	IF target_poi IS NOT NULL THEN
2088 	  l_personnel_office_id:=target_poi;
2089 	ELSE
2090 	  l_personnel_office_id:=p_pa_request_rec.personnel_office_id;
2091 	END IF;
2092 	-- IF target POI is not null check
2093 else
2094 l_personnel_office_id:=p_pos_grp1.personnel_office_id;
2095 end if;
2096 ---------------------------------- bug#2623692
2097 
2098     Generic_Update_Extra_Info
2099     (p_pa_request_rec               => P_PA_REQUEST_REC
2100     ,p_l_information_type           => 'GHR_US_POS_GRP1'
2101     ,p_extra_info_id              => p_pos_grp1.position_extra_info_id
2102     ,p_l_object_version_number    => p_pos_grp1.object_version_number
2103     ,p_information3                 => l_personnel_office_id
2104     ,p_information4                 => p_pos_grp1.office_symbol
2105     ,p_information5                 => l_Organ_Component
2106     -- Bug#3816651 Uncommented p_information6.
2107     ,p_information6                 => p_pos_grp1.occupation_category_code  -- This is actually the occ_series  on the DDf and not occ_code
2108     ,p_information7                 => p_pos_grp1.flsa_category
2109     ,p_information8                 => p_pos_grp1.bargaining_unit_status
2110 --Bug #6356058
2111   --  ,p_information9                 => p_pos_grp1.competitive_level
2112     ,p_information10              => p_pos_grp1.work_schedule
2113     ,p_information11              => p_pos_grp1.functional_class
2114     ,p_information12              => p_pos_grp1.position_working_title
2115   --,p_information13              => p_pos_grp1.position_sensitivity
2116   --,p_information14              => p_pos_grp1.security_access
2117   --,p_information15              => p_pos_grp1.prp_sci
2118     ,p_information16              => p_pos_grp1.supervisory_status
2119   --,p_information17              => p_pos_grp1.type_employee_supervised
2120     ,p_information18              => p_pos_grp1.payroll_office_id
2121   --,p_information19              => p_pos_grp1.timekeeper
2122   --,p_information20              => p_pos_grp1.competitive_area
2123     ,p_information21              => p_pos_grp1.positions_organization
2124     ,p_information23              => p_pos_grp1.part_time_hours
2125     );
2126   ELSE
2127     -- Standard Update
2128     hr_utility.set_location('Posn Update Without WS/PTH' || l_posn_title_pm ,81);
2129     Generic_Update_Extra_Info
2130     (p_pa_request_rec             => P_PA_REQUEST_REC
2131     ,p_l_information_type         => 'GHR_US_POS_GRP1'
2132     ,p_extra_info_id              => p_pos_grp1.position_extra_info_id
2133     ,p_l_object_version_number    => p_pos_grp1.object_version_number
2134     ,p_information3                 => p_pos_grp1.personnel_office_id
2135     ,p_information4                 => p_pos_grp1.office_symbol
2136     ,p_information5                 => p_pos_grp1.organization_structure_id
2137     -- Bug#3816651 Uncommented p_information6
2138     ,p_information6                 => p_pos_grp1.occupation_category_code  -- This is actually the occ_series  on the DDf and not occ_code
2139     ,p_information7                 => p_pos_grp1.flsa_category
2140     ,p_information8                 => p_pos_grp1.bargaining_unit_status
2141 --Bug #6356058
2142   --  ,p_information9                 => p_pos_grp1.competitive_level
2143   --,p_information10              => p_pos_grp1.work_schedule
2144     ,p_information11              => p_pos_grp1.functional_class
2145     ,p_information12              => p_pos_grp1.position_working_title
2146   --,p_information13              => p_pos_grp1.position_sensitivity
2147   --,p_information14              => p_pos_grp1.security_access
2148   --,p_information15              => p_pos_grp1.prp_sci
2149     ,p_information16              => p_pos_grp1.supervisory_status
2150   --,p_information17              => p_pos_grp1.type_employee_supervised
2151     ,p_information18              => p_pos_grp1.payroll_office_id
2152   --,p_information19              => p_pos_grp1.timekeeper
2153   --,p_information20              => p_pos_grp1.competitive_area
2154     ,p_information21              => p_pos_grp1.positions_organization
2155   --,p_information23              => p_pos_grp1.part_time_hours
2156     );
2157   END IF;
2158 --
2159 end if;
2160 
2161 If p_pos_grp2.pos_grp2_flag =  'Y' then
2162 --
2163   hr_utility.set_location('bef upd ' || 'PEID 2 ' || to_char(p_pos_grp2.position_extra_info_id),1);
2164   hr_utility.set_location('bef upd ' || 'PEOVN 2' || to_char(p_pos_grp2.object_version_number),1);
2165 
2166   Generic_Update_Extra_Info
2167   (
2168    p_pa_request_rec             =>      P_PA_REQUEST_REC
2169   ,p_l_information_type         =>      'GHR_US_POS_GRP2'
2170   ,p_extra_info_id              =>      p_pos_grp2.position_extra_info_id
2171   ,p_l_object_version_number    =>      p_pos_grp2.object_version_number
2172   ,p_information3               =>      p_pos_grp2.position_occupied
2173   ,p_information4               =>      p_pos_grp2.organization_function_code
2174 --,p_information5               =>      p_pos_grp2.date_position_classified
2175 --,p_information6               =>      p_pos_grp2.date_last_position_audit
2176 --,p_information7               =>      p_pos_grp2.classification_official
2177 --,p_information8               =>      p_pos_grp2.language_required
2178 --,p_information9               =>      p_pos_grp2.drug_test
2179 --,p_information10              =>      p_pos_grp2.financial_statement
2180 --,p_information11              =>      p_pos_grp2.training_program_id
2181 --,p_information12              =>      p_pos_grp2.key_emergency_essential
2182   ,p_information13              =>      p_pos_grp2.appropriation_code1
2183   ,p_information14              =>      p_pos_grp2.appropriation_code2
2184 --,p_information15              =>      p_pos_grp2.intelligence_position_ind
2185 --,p_information16              =>      p_pos_grp2.leo_position_indicator
2186 );
2187 --
2188 end if;
2189 --
2190  /* Note :  Since none of this data is currently being updated, why call the generic_update at all ??? */
2191 
2192 /*
2193 If p_pos_oblig.pos_oblig_flag =  'Y' then
2194 --
2195   hr_utility.set_location(l_proc,90);
2196   Generic_Update_Extra_Info
2197   (
2198    p_pa_request_rec             =>      P_PA_REQUEST_REC
2199   ,p_l_information_type         =>      'GHR_US_POS_OBLIG'
2200   ,p_extra_info_id              =>      p_pos_oblig.position_extra_info_id
2201   ,p_l_object_version_number    =>      p_pos_oblig.object_version_number
2202   ,p_information3               =>      p_pos_oblig.expiration_date
2203   ,p_information4               =>      p_pos_oblig.obligation_type
2204   ,p_information5               =>      p_pos_oblig.employee_ssn
2205   );
2206 --
2207 end if;
2208 */
2209 --
2210 
2211  /* Note :  Since none of this data is currently being updated, why call the generic_update at all ??? */
2212 
2213 /*
2214 If p_pos_car_prog.pos_car_prog_flag =  'Y' then
2215 --
2216 hr_utility.set_location(l_proc,95);
2217 Generic_Update_Extra_Info(
2218   p_pa_request_rec              =>      P_PA_REQUEST_REC
2219  ,p_l_information_type          =>      'GHR_US_POS_CAR_PROG'
2220  ,p_extra_info_id               =>      p_pos_car_prog.position_extra_info_id
2221  ,p_l_object_version_number     =>      p_pos_car_prog.object_version_number
2222  ,p_information3                =>      p_pos_car_prog.career_program_id
2223  ,p_information4                =>      p_pos_car_prog.career_program_type
2224  ,p_information5                =>      p_pos_car_prog.change_reasons
2225  ,p_information6                =>      p_pos_car_prog.career_field_id
2226  ,p_information7                =>      p_pos_car_prog.career_program_code
2227  ,p_information8                =>      p_pos_car_prog.acteds_key_position);
2228 --
2229 end if;
2230 */
2231 
2232 hr_utility.set_location(l_proc,100);
2233 
2234 
2235 -- Bug # 6312144 changes related to benefits continuation
2236 If p_ipa_benefits_cont.per_ben_cont_info_flag =  'Y' then
2237    hr_utility.set_location(l_proc,65);
2238 
2239  Generic_Update_Extra_Info
2240  (
2241   p_pa_request_rec              =>      P_PA_REQUEST_REC
2242  ,p_l_information_type          =>      'GHR_US_PER_BENEFITS_CONT'
2243  ,p_extra_info_id               =>      p_ipa_benefits_cont.person_extra_info_id
2244  ,p_l_object_version_number     =>      p_ipa_benefits_cont.object_version_number
2245  ,p_information1                =>      p_ipa_benefits_cont.FEGLI_Indicator
2246  ,p_information2                =>      p_ipa_benefits_cont.FEGLI_Election_Date
2247  ,p_information3                =>      p_ipa_benefits_cont.FEGLI_Elec_Not_Date
2248  ,p_information4                =>      p_ipa_benefits_cont.FEHB_Indicator
2249  ,p_information5                =>      p_ipa_benefits_cont.FEHB_Election_Date
2250  ,p_information6                =>      p_ipa_benefits_cont.FEHB_Elec_Notf_Date
2251  ,p_information7                =>      p_ipa_benefits_cont.Retirement_Indicator
2252  ,p_information12               =>      p_ipa_benefits_cont.Retirement_Elec_Date
2253  ,p_information8                =>      p_ipa_benefits_cont.Retirement_Elec_Notf_Date
2254  ,p_information9                =>      p_ipa_benefits_cont.Cont_Term_Insuff_Pay_Elec_Date
2255  ,p_information10               =>      p_ipa_benefits_cont.Cont_Term_Insuff_Pay_Notf_Date
2256  ,p_information11               =>      p_ipa_benefits_cont.Cont_Term_Insuff_Pmt_Type_Code);
2257 
2258 End IF;
2259 
2260 -- Bug # 6312144 changes related to retirement system information
2261 If p_retirement_info.per_retirement_info_flag =  'Y' then
2262    hr_utility.set_location(l_proc,65);
2263 
2264  Generic_Update_Extra_Info
2265  (
2266   p_pa_request_rec              =>      P_PA_REQUEST_REC
2267  ,p_l_information_type          =>      'GHR_US_PER_RETIRMENT_SYS_INFO'
2268  ,p_extra_info_id               =>      p_retirement_info.person_extra_info_id
2269  ,p_l_object_version_number     =>      p_retirement_info.object_version_number
2270  ,p_information1                =>      p_retirement_info.special_population_code
2271  ,p_information2                =>      p_retirement_info.App_Exc_CSRS_Ind
2272  ,p_information3                =>      p_retirement_info.App_Exc_FERS_Ind
2273  ,p_information4                =>      p_retirement_info.FICA_Coverage_Ind1
2274  ,p_information5                =>      p_retirement_info.FICA_Coverage_Ind2);
2275 
2276 End IF;
2277 --
2278 
2279 -- Call special info type api to update education details
2280 
2281 If p_pa_request_rec.education_level      is not null or
2282    p_pa_request_rec.academic_discipline  is not null or
2283    p_pa_request_rec.year_degree_attained is not null then
2284 
2285   hr_utility.set_location(l_proc,102);
2286   update_edu_sit(p_pa_request_rec     => p_pa_request_rec);
2287 
2288 End if;
2289 
2290 --
2291 -- Call special info type api to update performance_appraisal details
2292 --
2293 If p_perf_appraisal.perf_appr_flag = 'Y' then
2294 
2295   hr_utility.set_location(l_proc,104);
2296   l_segment_rec.segment1              :=  p_perf_appraisal.appraisal_type;
2297   l_segment_rec.segment2              :=  p_perf_appraisal.rating_rec;
2298   l_segment_rec.segment3              :=  p_perf_appraisal.date_effective;
2299   l_segment_rec.segment4              :=  p_perf_appraisal.rating_rec_pattern;
2300   l_segment_rec.segment5              :=  p_perf_appraisal.rating_rec_level;
2301   l_segment_rec.segment6              :=  p_perf_appraisal.date_appr_ends;
2302     --Bug# 4753117 28-Feb-07	Veeramani  assigning appraisal start date
2303   l_segment_rec.segment17             :=  p_perf_appraisal.date_appr_starts;
2304   l_segment_rec.segment7              :=  p_perf_appraisal.unit;
2305   l_segment_rec.segment8              :=  p_perf_appraisal.org_structure_id;
2306   l_segment_rec.segment9              :=  p_perf_appraisal.office_symbol;
2307   l_segment_rec.segment10             :=  p_perf_appraisal.pay_plan;
2308   l_segment_rec.segment11             :=  p_perf_appraisal.grade;
2309   l_segment_rec.segment12             :=  p_perf_appraisal.date_due;
2310   l_segment_rec.segment13             :=  p_perf_appraisal.appraisal_system_identifier;
2311   l_segment_rec.segment14             :=  p_perf_appraisal.date_init_appr_due;
2312   l_segment_rec.segment15             :=  p_perf_appraisal.optional_information;
2313   l_segment_rec.person_analysis_id    :=  p_perf_appraisal.person_analysis_id;
2314   l_segment_rec.object_version_number :=  p_perf_appraisal.object_version_number;
2315   l_segment_rec.segment16             :=  p_perf_appraisal.performance_rating_points;
2316 
2317   hr_utility.set_location(l_proc||'  l_segment_rec.segment16       '||  l_segment_rec.segment16,101);
2318 
2319   generic_update_sit
2320   (p_segment_rec              =>  l_segment_rec,
2321    p_special_information_type =>  'US Fed Perf Appraisal',
2322    p_pa_request_rec           =>  p_pa_request_rec
2323    );
2324 
2325 End if;
2326 
2327 -- Call special info type api to update conduct_performance details
2328 
2329 If p_conduct_performance.cond_perf_flag = 'Y' then
2330 
2331   l_segment_rec.segment1              :=  p_conduct_performance.cause_of_disc_action;
2332   l_segment_rec.segment2              :=  p_conduct_performance.date_of_adverse_action;
2333   l_segment_rec.segment3              :=  p_conduct_performance.days_suspended;
2334   l_segment_rec.segment4              :=  p_conduct_performance.date_suspension_over_30;
2335   l_segment_rec.segment5              :=  p_conduct_performance.date_suspension_under_30;
2336   l_segment_rec.segment6              :=  p_conduct_performance.pip_action_taken;
2337   l_segment_rec.segment7              :=  p_conduct_performance.pip_begin_date;
2338   l_segment_rec.segment8              :=  p_conduct_performance.pip_end_date;
2339   l_segment_rec.segment9              :=  p_conduct_performance.pip_extensions;
2340   l_segment_rec.segment10             :=  p_conduct_performance.pip_length;
2341   l_segment_rec.segment11             :=  p_conduct_performance.date_reprimand_expires;
2342   l_segment_rec.segment12             :=  p_conduct_performance.adverse_action_noac;
2343   l_segment_rec.person_analysis_id    :=  p_conduct_performance.person_analysis_id;
2344   l_segment_rec.object_version_number :=  p_conduct_performance.object_version_number;
2345 
2346   generic_update_sit
2347  (p_pa_request_rec               => p_pa_request_rec,
2348   p_special_information_type     => 'US Fed Conduct Perf',
2349   p_segment_rec                  => l_segment_rec
2350   );
2351 End if;
2352 --
2353 --
2354   update_retained_grade
2355   (p_pa_request_rec           => p_pa_request_rec,
2356    p_per_retained_grade       => p_per_retained_grade );
2357 --
2358 --
2359 hr_utility.set_location('Leaving  ' || l_proc,110);
2360 Exception when others then
2361  --
2362  -- Reset IN OUT parameters and set OUT parameters
2363  --
2364  P_Asg_Sf52                         := l_Asg_Sf52;
2365  P_Asg_non_Sf52                     := l_Asg_non_Sf52;
2366  P_Asg_nte_dates                    := l_Asg_nte_dates;
2367  P_Per_Sf52                         := l_Per_Sf52;
2368  P_Per_Group1                       := l_Per_Group1;
2369  P_Per_Group2                       := l_Per_Group2;
2370  P_Per_scd_info                     := l_Per_scd_info;
2371  P_Per_retained_grade               := l_Per_retained_grade;
2372  P_Per_probations                   := l_Per_probations;
2373  P_Per_sep_retire                   := l_Per_sep_retire;
2374  P_Per_security                     := l_Per_security;
2375  --Bug#4486823
2376  P_per_service_oblig                := l_per_service_oblig;
2377  P_Per_conversions                  := l_Per_conversions;
2378  P_Per_uniformed_services           := l_Per_uniformed_services;
2379  P_Pos_oblig                        := l_Pos_oblig;
2380  P_Pos_Grp2                         := l_Pos_Grp2;
2381  P_Pos_Grp1                         := l_Pos_Grp1;
2382  P_Pos_valid_grade                  := l_Pos_valid_grade;
2383  P_Pos_car_prog                     := l_Pos_car_prog;
2384  P_Perf_appraisal                   := l_Perf_appraisal;
2385  P_conduct_performance              := l_conduct_performance;
2386  P_Loc_Info                         := l_Loc_Info;
2387  P_generic_Extra_Info_Rec           := l_generic_Extra_Info_Rec;
2388  P_par_term_retained_grade          := l_par_term_retained_grade;
2389  p_per_race_ethnic_info				:= l_per_race_ethnic_info; -- Race or National Origin changes
2390  raise;
2391 
2392 end call_extra_info_api;
2393 
2394 
2395 
2396 --  ********************************
2397 --  Function get_asg_status_type
2398 --  ********************************
2399 --- Bug# 4672772 added Parameter p_assignment_id
2400  Procedure get_asg_status_type
2401  (p_noa_code           in  ghr_nature_of_actions.code%type,
2402   p_business_group_id  in  per_people_f.business_group_id%type,
2403   p_assignment_id	   in  number,
2404   p_status_type_id     out nocopy per_assignment_status_types.assignment_status_type_id%type,
2405   p_activate_flag      out nocopy varchar2,
2406   p_suspend_flag       out nocopy varchar2,
2407   p_terminate_flag     out nocopy varchar2
2408  )
2409  is
2410 
2411  l_proc                varchar2(70) := 'get_asg_status_type';
2412  l_system_status       per_assignment_status_types.per_system_status%type;
2413  l_user_status         per_assignment_status_types.user_status%type;
2414  l_asg_status_type_id  number;
2415  l_active_flag         varchar2(1) := 'N';
2416 
2417 
2418  cursor    c_asg_status_type is
2419    select  ast.assignment_status_type_id,
2420            ast.active_flag
2421    from    per_assignment_status_types ast
2422    where   ast.per_system_status                      =    l_system_status
2423    and     ast.user_status                            like '%' || l_user_status || '%'
2424    and     nvl(ast.business_group_id,hr_api.g_number) =  hr_api.g_number
2425    and     ast.legislation_code                       =  'US';
2426 
2427  cursor    c_asg_status_type_471 is
2428    select  ast.assignment_status_type_id,
2429            ast.active_flag
2430    from    per_assignment_status_types ast
2431    where   ast.per_system_status                      =    l_system_status
2432    and     ast.user_status                            like '%' || l_user_status || '%'
2433    and     instr(ast.user_status,'NTE')               = 0
2434    and     nvl(ast.business_group_id,hr_api.g_number) =  hr_api.g_number
2435    and     ast.legislation_code                       =  'US';
2436 -- Bug# 4672772 Begin
2437 	l_user_apnt_status			per_assignment_status_types.user_status%type;
2438 	l_user_apnt_eff_date		date;
2439 	CURSOR	c_user_apnt_status IS
2440 	select 	ast.user_status,asg.effective_start_date
2441 	from	per_assignment_status_types ast,
2442 			per_all_assignments_f asg
2443 	where	ast.assignment_status_type_id = asg.assignment_status_type_id
2444 	and		asg.assignment_id = p_assignment_id
2445 	and 	asg.primary_flag = 'Y'
2446 	order by asg.effective_start_date;
2447 
2448 -- Bug# 4672772 End
2449 --Begin Bug# 6083404
2450     l_user_actv_apnt_status			per_assignment_status_types.user_status%type;
2451     CURSOR c_user_actv_appt IS
2452     select 	ast.user_status
2453     from	per_assignment_status_types ast,
2454             per_all_assignments_f asg
2455     where	ast.assignment_status_type_id = asg.assignment_status_type_id
2456     and		asg.assignment_id = p_assignment_id
2457     and 	asg.primary_flag = 'Y'
2458     and user_status='Active Appointment';
2459 --end Bug# 6083404
2460 
2461 
2462 -- to include , the dates and active_flag in the where clause -- ??
2463 
2464 -- The follwing code , decides the User status and the System Status for
2465 --  the person's assignment depending on the NOA, and then identifies the
2466 --  Assignment_status_type_id associated with it. Also it passes the
2467 -- respective flag parameters to indicate whether the assignment has to be
2468 -- activated, terminated or suspended
2469 
2470  begin
2471    If p_noa_code is not null then
2472       if p_noa_code in
2473 		  ('100','101','107','120','124','130','132','140','141','142','143','145','146','147','150','151','155',
2474 		   '156','157','170','198','199','280','292','293','500','501','507','520','524','540','541','542','543',
2475 		   '546','550','551','555','570','702','713') then
2476 			IF ( p_noa_code in ('702','713') AND g_old_user_status = 'Term Limited Appt' ) THEN
2477             --Bug# 4602352 Modified Temp. Appointment NTE to Term Limited Appt
2478 				l_system_status :=  'ACTIVE_ASSIGN'; -- 'ACTIVE'
2479 				l_user_status    := g_old_user_status;
2480 				p_activate_flag :=  'Y';
2481 				--Fix for 3698464
2482 			-- Begin Bug# 4672772
2483 			ELSIF ( p_noa_code in ('702','713') AND g_old_user_status = 'Temp. Promotion NTE' ) THEN
2484 				FOR user_apnt_status_rec IN c_user_apnt_status
2485 				LOOP
2486 					l_user_apnt_status := user_apnt_status_rec.user_status;
2487 					l_user_apnt_eff_date := user_apnt_status_rec.effective_start_date;
2488 					EXIT;
2489 				END LOOP;
2490                 --Begin Bug#6083404
2491                 FOR user_actv_appt_rec IN c_user_actv_appt
2492                 LOOP
2493                     l_user_actv_apnt_status := user_actv_appt_rec.user_status;
2494                     EXIT;
2495                 END LOOP;
2496                 --End Bug# 6083404
2497 				IF l_user_apnt_status = 'Temp. Appointment NTE'
2498                      and nvl(l_user_actv_apnt_status,'XXX') <>'Active Appointment' THEN
2499                     --Bug# 6083404 added l_user_actv_apnt_status condition
2500 					l_system_status :=  'ACTIVE_ASSIGN'; -- 'ACTIVE'
2501 					l_user_status   :=  l_user_apnt_status;
2502 					p_activate_flag :=  'Y';
2503 				ELSE
2504 					l_system_status :=  'ACTIVE_ASSIGN'; -- 'ACTIVE'
2505 					l_user_status   :=  'Active Appointment'; -- Active Appointment'
2506 					p_activate_flag :=  'Y';
2507 				END IF;
2508 			-- End Bug# 4672772
2509 			ELSE -- 3698464 Madhuri
2510 				l_system_status :=  'ACTIVE_ASSIGN'; -- 'ACTIVE'
2511 				l_user_status   :=  'Active Appointment'; -- Active Appointment'
2512 				p_activate_flag :=  'Y';
2513 			END IF;
2514       elsif p_noa_code = '471' then
2515         l_system_status  := 'SUSP_ASSIGN';
2516         l_user_status    := 'Furlough';
2517         p_suspend_flag   :=  'Y';
2518       elsif p_noa_code = '472' then
2519         l_system_status  := 'SUSP_ASSIGN';
2520         l_user_status    := 'Furlough NTE';
2521         p_suspend_flag :=  'Y';
2522       elsif p_noa_code = '462' then
2523         l_system_status  := 'ACTIVE_ASSIGN';
2524         l_user_status    := 'Leave With Pay NTE';
2525         p_activate_flag :=  'Y';
2526       elsif p_noa_code = '460' then
2527         l_system_status  := 'SUSP_ASSIGN';
2528         l_user_status    := 'Leave Without Pay NTE';
2529         p_suspend_flag :=  'Y';
2530       elsif p_noa_code = '473' then
2531         l_system_status  := 'SUSP_ASSIGN';
2532         l_user_status    := 'Leave Without Pay US'; --instead of Mil
2533         p_suspend_flag :=  'Y';
2534       elsif p_noa_code = '430' then
2535         l_system_status  := 'SUSP_ASSIGN';
2536         l_user_status    := 'Non Pay';
2537         p_suspend_flag :=  'Y';
2538       elsif p_noa_code = '480' then
2539         l_system_status  := 'ACTIVE_ASSIGN';
2540         l_user_status    := 'Sabbatical NTE';
2541         p_activate_flag :=  'Y';
2542       elsif p_noa_code in
2543         ('300','301','302','303','304','312','317','330','350','356','390') then
2544         l_system_status  := 'TERM_ASSIGN';
2545         l_user_status    := 'Separated';
2546         p_terminate_flag :=  'Y';
2547       elsif p_noa_code = '450' then
2548         l_system_status  := 'SUSP_ASSIGN';
2549         l_user_status    := 'Suspension NTE';
2550         p_suspend_flag :=  'Y';
2551       elsif p_noa_code = '452' then
2552         l_system_status  := 'SUSP_ASSIGN';
2553         l_user_status    := 'Suspension Indefinite';
2554         p_suspend_flag :=  'Y';
2555       elsif p_noa_code in --Bug# 4602352 Removed 108,508
2556         ('112','115','117','122','148','149','153','154','171','190',
2557          '512','515','517','522','548','549','553','554','571','590','750') then
2558         l_system_status  := 'ACTIVE_ASSIGN';
2559         l_user_status    := 'Temp. Appointment NTE';
2560         p_activate_flag :=  'Y';
2561       --Begin Bug# 4602352
2562       elsif p_noa_code in ('108','508') then
2563         l_system_status  := 'ACTIVE_ASSIGN';
2564         l_user_status    := 'Term Limited Appt';
2565         p_activate_flag :=  'Y';
2566       --End Bug# 4602352
2567       elsif p_noa_code = '703' then
2568         --Begin Bug# 4602352
2569         IF (g_old_user_status = 'Term Limited Appt' ) THEN
2570                 l_system_status  := 'ACTIVE_ASSIGN';
2571                 l_user_status    := 'Term Limited Appt';
2572                 p_activate_flag :=  'Y';
2573         ELSE --End Bug# 4602352
2574             l_system_status  := 'ACTIVE_ASSIGN';
2575             l_user_status    := 'Temp. Promotion NTE';
2576             p_activate_flag :=  'Y';
2577         END IF;--Bug# 4602352
2578       elsif p_noa_code in ('351','352','353','355','357','385') then
2579         l_system_status  := 'TERM_ASSIGN';  -- TERM_???????
2580         l_user_status    := 'Terminate Appointment'; -- 'Termination Appointment'
2581         p_terminate_flag :=  'Y';
2582         -- Start Bug 3048114
2583       elsif p_noa_code in ('740') THEN
2584         IF g_old_user_status = 'Temp. Promotion NTE' THEN
2585 	        l_system_status :=  'ACTIVE_ASSIGN'; -- 'ACTIVE'
2586 		    l_user_status   :=  'Active Appointment'; -- Active Appointment'
2587 	        p_activate_flag :=  'Y';
2588             -- End Bug 3048114
2589 	    ELSIF g_old_user_status = 'Term Limited Appt'  THEN --Bug# 4602352
2590             l_system_status :=  'ACTIVE_ASSIGN'; -- 'ACTIVE'
2591             l_user_status    := g_old_user_status;
2592             p_activate_flag :=  'Y';
2593 	    END IF; --Fix for 3698464
2594       elsif p_noa_code = '721' then           -- for Temp Appointmt NTE, bug# 3215526
2595         l_system_status  := 'ACTIVE_ASSIGN';  -- 'ACTIVE'
2596         l_user_status    := g_old_user_status;
2597         p_activate_flag :=  'Y';
2598       end if;
2599     end if;
2600     If l_system_status is not null and
2601       l_user_status   is not null then
2602        hr_utility.set_location('user_status ' || l_user_status,1);
2603        hr_utility.set_location('System status  ' || l_system_status,2);
2604       If p_noa_code = '471' then
2605       ----------- changed cursor name from c_Asg_status_type to c_Asg_status_type_471 for bug#2139010
2606         for asg_status_type_471 in c_asg_status_type_471 loop
2607           l_asg_status_type_id  :=  asg_status_type_471.assignment_status_type_id;
2608           l_active_flag         :=  asg_status_type_471.active_flag;
2609         end loop;
2610       Else
2611         for asg_status_type in c_asg_status_type loop
2612           l_asg_status_type_id  :=  asg_status_type.assignment_status_type_id;
2613           l_active_flag         :=  asg_status_type.active_flag;
2614         end loop;
2615       End if;
2616       If l_asg_status_type_id is null then
2617         hr_utility.set_message(8301,'GHR_38180_STATUS_TYPE_UNDEF');
2618         hr_utility.raise_error;
2619       End if;
2620       If l_active_flag   = 'N' then
2621         hr_utility.set_message(8301,'GHR_38181_STATUS_TYPE_INACTIVE');
2622         hr_utility.raise_error;
2623       End if;
2624     End if;
2625     p_status_type_id := l_asg_status_type_id;
2626  Exception when others then
2627     --
2628     -- Reset IN OUT parameters and set OUT parameters
2629     --
2630     p_status_type_id     := null;
2631     p_activate_flag      := null;
2632     p_suspend_flag       := null;
2633     p_terminate_flag     := null;
2634     raise;
2635 
2636  End get_asg_status_type;
2637 
2638 
2639 ------------------------------------------------------------------------------------------
2640 -------------------------------- < return_update_mode > ----------------------------------
2641 ------------------------------------------------------------------------------------------
2642 
2643 --This function returns the update_mode to be used while calling the apis, depending on
2644 -- the effective_date the SF52 is processed.
2645 
2646 
2647   Function return_update_mode
2648   (p_id              in     per_people_f.person_id%type,
2649    p_effective_date  in     date,
2650    p_table_name      in     varchar2
2651   ) return varchar2 is
2652 
2653   l_proc     varchar2(72) := 'return_update_mode';
2654   l_eed      date;
2655   l_esd      date;
2656   l_mode     varchar2(20) := 'CORRECTION';
2657   l_exists  boolean := FALSE;
2658 
2659 
2660   cursor     c_update_mode_p is
2661     select   per.effective_start_date ,
2662              per.effective_end_date
2663     from     per_all_people_f per
2664     where    per.person_id = p_id
2665     and      p_effective_date
2666     between  per.effective_start_date
2667     and      per.effective_end_date;
2668 
2669   cursor     c_update_mode_p1 is
2670     select   per.effective_start_date ,
2671              per.effective_end_date
2672     from     per_all_people_f per
2673     where    per.person_id = p_id
2674     and      p_effective_date  <  per.effective_start_date;
2675 
2676 
2677    cursor     c_update_mode_a is
2678     select   asg.effective_start_date ,
2679              asg.effective_end_date
2680     from     per_all_assignments_f asg
2681     where    asg.assignment_id = p_id
2682     and      p_effective_date
2683     between  asg.effective_start_date
2684     and      asg.effective_end_date;
2685 
2686    cursor     c_update_mode_a1 is
2687     select   asg.effective_start_date ,
2688              asg.effective_end_date
2689     from     per_all_assignments_f asg
2690     where    asg.assignment_id = p_id
2691     and      p_effective_date  <  asg.effective_start_date;
2692 
2693 
2694 
2695   cursor     c_update_mode_pos is
2696     select   pos.effective_start_date ,
2697              pos.effective_end_date
2698     from     hr_all_positions_f pos
2699     where    pos.position_id = p_id
2700     and      p_effective_date
2701     between  pos.effective_start_date
2702     and      pos.effective_end_date;
2703 
2704   cursor     c_update_mode_pos1 is
2705     select   pos.effective_start_date ,
2706              pos.effective_end_date
2707     from     hr_all_positions_f pos
2708     where    pos.position_id = p_id
2709     and      p_effective_date  <  pos.effective_start_date;
2710 
2711 
2712   Begin
2713     hr_utility.set_location('Entering  ' || l_proc,5);
2714     If p_table_name = 'PER_PEOPLE_F' then --per
2715       hr_utility.set_location(l_proc,10);
2716       for update_mode in c_update_mode_p loop
2717         hr_utility.set_location(l_proc,15);
2718         l_esd := update_mode.effective_start_date;
2719         l_eed := update_mode.effective_end_date;
2720       end loop;
2721       hr_utility.set_location(l_proc,20);
2722       If l_esd = p_effective_date then
2723         hr_utility.set_location(l_proc,25);
2724         l_mode := 'CORRECTION';
2725       Elsif l_esd < p_effective_date and
2726             to_char(l_eed,'YYYY/MM/DD') = '4712/12/31' then
2727         hr_utility.set_location(l_proc,30);
2728         l_mode := 'UPDATE';
2729       -- end if;
2730       Elsif  l_esd <  p_effective_date  then
2731         hr_utility.set_location(l_proc,35);
2732         for update_mode1 in c_update_mode_p1 loop
2733           hr_utility.set_location(l_proc,40);
2734           l_exists := true;
2735           exit;
2736         end loop;
2737         If l_exists then
2738           hr_utility.set_location(l_proc,45);
2739           l_mode := 'UPDATE_CHANGE_INSERT';
2740         Else
2741           hr_utility.set_location(l_proc,50);
2742           l_mode := 'CORRECTION';
2743         End if;
2744       End if;
2745         If l_mode is null then
2746           hr_utility.set_message(8301,'GHR_GET_DATE_TRACK_FAILED');
2747           hr_utility.set_message_token('TABLE_NAME','per_people_f');
2748           hr_utility.raise_error;
2749         End if;
2750         hr_utility.set_location(l_proc,55);
2751     Elsif p_table_name = 'PER_ASSIGNMENTS_F' then
2752       hr_utility.set_location(l_proc,60);
2753       for update_mode in c_update_mode_a loop
2754         hr_utility.set_location(l_proc,65);
2755         l_esd := update_mode.effective_start_date;
2756         l_eed := update_mode.effective_end_date;
2757       end loop;
2758       If l_esd = p_effective_date then
2759         hr_utility.set_location(l_proc,70);
2760         l_mode := 'CORRECTION';
2761       Elsif l_esd < p_effective_date and
2762             to_char(l_eed,'YYYY/MM/DD') = '4712/12/31' then
2763         hr_utility.set_location(l_proc,75);
2764         l_mode := 'UPDATE';                           --  to end date a row and then create a new row
2765       Elsif  l_esd <  p_effective_date  then
2766         hr_utility.set_location(l_proc,80);
2767         for update_mode1 in c_update_mode_a1 loop
2768           hr_utility.set_location(l_proc,85);
2769           l_exists := true;
2770           exit;
2771         end loop;
2772         If l_exists then
2773           hr_utility.set_location(l_proc,90);
2774           l_mode := 'UPDATE_CHANGE_INSERT';              -- to insert a row between 2 existing rows
2775         Else
2776           hr_utility.set_location(l_proc,95);
2777           l_mode := 'CORRECTION';
2778         End if;
2779         hr_utility.set_location(l_proc,100);
2780       End if;
2781       hr_utility.set_location(l_proc,105);
2782       hr_utility.set_location('UPDATE_MODE  :   ' || l_mode,2);
2783       If l_mode is null then
2784         hr_utility.set_message(8301,'GHR_GET_DATE_TRACK_FAILED');
2785         hr_utility.set_message_token('TABLE_NAME','per_assignments_f');
2786         hr_utility.raise_error;
2787       End if;
2788     Elsif p_table_name = 'HR_ALL_POSITIONS_F' then
2789       hr_utility.set_location(l_proc,110);
2790       for update_mode in c_update_mode_pos loop
2791         hr_utility.set_location(l_proc,115);
2792         l_esd := update_mode.effective_start_date;
2793         l_eed := update_mode.effective_end_date;
2794       end loop;
2795       If l_esd = p_effective_date then
2796         hr_utility.set_location(l_proc,120);
2797         l_mode := 'CORRECTION';
2798       Elsif l_esd < p_effective_date and
2799             to_char(l_eed,'YYYY/MM/DD') = '4712/12/31' then
2800         hr_utility.set_location(l_proc,125);
2801         l_mode := 'UPDATE';                           --  to end date a row and then create a new row
2802       Elsif  l_esd <  p_effective_date  then
2803         hr_utility.set_location(l_proc,130);
2804         for update_mode1 in c_update_mode_pos1 loop
2805           hr_utility.set_location(l_proc,135);
2806           l_exists := true;
2807           exit;
2808         end loop;
2809         If l_exists then
2810           hr_utility.set_location(l_proc,140);
2811           l_mode := 'UPDATE_CHANGE_INSERT';              -- to insert a row between 2 existing rows
2812         Else
2813           hr_utility.set_location(l_proc,145);
2814           l_mode := 'CORRECTION';
2815         End if;
2816         hr_utility.set_location(l_proc,150);
2817       End if;
2818       hr_utility.set_location(l_proc,155);
2819       hr_utility.set_location('UPDATE_MODE  :   ' || l_mode,2);
2820       If l_mode is null then
2821         hr_utility.set_message(8301,'GHR_GET_DATE_TRACK_FAILED');
2822         hr_utility.set_message_token('TABLE_NAME','HR_ALL_POSITIONS_F');
2823         hr_utility.raise_error;
2824       End if;
2825     End if;
2826     return l_mode;
2827     hr_utility.set_location('Leaving ' ||l_proc,160);
2828 End return_update_mode;
2829 
2830 
2831 
2832 
2833 --  ***********************
2834 --  procedure Process_Family
2835 --  ***********************
2836 --
2837 procedure  Process_Family
2838 (P_PA_REQUEST_REC             IN OUT NOCOPY  GHR_PA_REQUESTS%ROWTYPE,
2839  P_AGENCY_CODE                IN      varchar2 )   is
2840 
2841 l_noa_code                     ghr_nature_of_actions.code%type;
2842 --
2843 l_pa_request_rec               ghr_pa_requests%rowtype;
2844 l_proc                         varchar2(70)   := 'Process_family';
2845 l_hr_person_api_update         varchar2(1)    := 'N';
2846 l_hr_applicant_api_hire        varchar2(1)    := 'N';
2847 l_employee_api_update_criteria varchar2(1)    := 'N';
2848 l_hr_employee_api_hire_ex      varchar2(1)    := 'N';
2849 l_hr_applicant_api_create_sec  varchar2(1)    := 'N';
2850 l_hire_employee                varchar2(1)    := 'N';
2851 l_create_address                 varchar2(1)    := 'N';
2852 l_update_address               varchar2(1)    := 'N';
2853 l_update_person                varchar2(1)    := 'N';
2854 l_secondary_asg                varchar2(1)    := 'N';
2855 l_address_line1                          per_addresses.address_line1%type;
2856 l_address_line2                          per_addresses.address_line2%type;
2857 l_address_line3                  per_addresses.address_line3%type;
2858 l_town_or_city                    per_addresses.town_or_city%type;
2859 l_region_2                        per_addresses.region_2%type;
2860 l_city                           per_addresses.town_or_city%type;
2861 l_state                                  per_addresses.region_2%type;
2862 l_postal_code                    per_addresses.postal_code%type;
2863 l_country                                per_addresses.country%type;
2864 l_noa_family_name                      varchar2(60);
2865 l_noa_family_code              ghr_noa_families.noa_family_code%type;
2866 --
2867 -- hr_person_api.update_person out variables
2868 --
2869 l_per_upd_employee_number        per_people_f.employee_number%type;
2870 l_per_upd_effective_start_date   per_people_f.effective_start_date%type;
2871 l_per_upd_effective_end_date     per_people_f.effective_end_date%type;
2872 l_per_upd_full_name              per_people_f.full_name%type;
2873 l_per_upd_comment_id             per_people_f.comment_id%type;
2874 l_per_upd_name_comb_warn         boolean;
2875 l_per_upd_assgn_payroll_warn     boolean;
2876 l_per_person_type_id             per_people_f.person_type_id%type;
2877 l_per_national_identifier        per_people_f.national_identifier%type;
2878 l_per_first_name                 per_people_f.first_name%type;
2879 l_per_last_name                  per_people_f.last_name%type;
2880 l_per_middle_names               per_people_f.middle_names%type;
2881 l_per_date_of_birth              per_people_f.date_of_birth%type;
2882 
2883 --
2884 l_concatenated_segments          hr_soft_coding_keyflex.concatenated_segments%type;
2885 l_asg_upd_effective_start_date   per_assignments_f.effective_start_date%type;
2886 l_asg_upd_effective_end_date     per_assignments_f.effective_end_date%type;
2887 l_asg_upd_special_ceil_step_id   per_assignments_f.special_ceiling_step_id%type;
2888 l_asg_upd_people_group_id        per_assignments_f.people_group_id%type;
2889 l_asg_upd_group_name             pay_people_groups.group_name%type;
2890 l_asg_upd_org_now_man_warn         boolean;
2891 l_asg_upd_other_manager_warn       boolean ;
2892 l_asg_upd_spp_delete_warning     boolean;
2893 l_asg_upd_entries_chan_warn      varchar2(10);
2894 l_asg_upd_tax_dist_chan_warn     boolean;
2895 --
2896 -- Hire applicant out variables
2897 
2898 --
2899  l_per_hire_employee_number        per_people_f.employee_number%type;
2900  l_per_hire_eff_start_date         per_people_f.effective_start_date%type;
2901  l_per_hire_eff_end_date           per_people_f.effective_end_date%type;
2902  l_per_hire_un_asg_del_warn        boolean;
2903  l_per_hire_asg_pay_warn           boolean;
2904  l_per_hire_oversubs_vac_id  number;
2905 --
2906 
2907 -- Return to duty (active) out variables
2908 --
2909 l_asg_act_eff_start_date          per_assignments_f.effective_start_date%type;
2910 l_asg_act_eff_end_date            per_assignments_f.effective_end_date%type;
2911 --
2912 --Suspend employee out variables
2913 --
2914 l_asg_sus_eff_start_date          per_assignments_f.effective_start_date%type;
2915 l_asg_sus_eff_end_date            per_assignments_f.effective_end_date%type;--
2916 
2917 -- Create addresses out variables
2918 --
2919 l_per_add_address_id              per_addresses.address_id%type;
2920 l_per_add_ovr_number              per_addresses.object_version_number%type;
2921 --
2922 
2923 -- Final Process out variables
2924 --
2925 l_asg_fnl_eff_start_date          per_assignments_f.effective_start_date%type;
2926 l_asg_fnl_eff_end_date            per_assignments_f.effective_end_date%type;
2927 l_asg_fnl_org_now_no_manager      boolean;
2928 l_asg_fnl_future_chan_warn        boolean;
2929 l_asg_fnl_entries_chan_warn       varchar2(1);
2930 --
2931 --
2932 l_per_object_version_number       per_people_f.object_version_number%type;
2933 l_asg_object_version_number     per_assignments_f.object_version_number%type;
2934 l_add_object_version_number       per_addresses.object_version_number%type;
2935 l_person_id                             per_people_f.person_id%type;
2936 l_person_type_id                per_people_f.person_type_id%type;
2937 l_date1                         ghr_pa_requests.effective_date%type;
2938 l_address_id                      per_addresses.address_id%type;
2939 l_person_type                     per_person_types.system_person_type%type;
2940 --l_sec_assignmemt_id             per_assignments_f.assignment_id%type;
2941 --l_assignment_status_type_id   per_assignment_status_types.assignment_status_type_id%type;
2942 --
2943 l_asg_trm_eff_start_date          per_assignments_f.effective_start_date%type;
2944 l_asg_trm_eff_end_date            per_assignments_f.effective_end_date%type;
2945 l_emp_trm_eff_end_date          per_assignments_f.effective_end_date%type;
2946 l_asg_future_changes_warning    boolean;
2947 l_supervisor_warning            boolean;
2948 l_event_warning                 boolean;
2949 l_interview_warning             boolean;
2950 l_review_warning                boolean;
2951 l_recruiter_warning             boolean;
2952 l_entries_changed_warning       varchar2(1);
2953 l_dod_warning                   boolean;
2954 l_pay_proposal_warning          boolean;
2955 l_org_now_no_manager_warning    boolean;
2956 --asg_future_changes_warning    boolean;
2957 --l_entries_changed_warning     boolean;
2958 l_pds_object_version_number     number;
2959 
2960 l_assignment_id                 per_assignments_f.assignment_id%type;
2961 l_asg_status_type_id            number(9);
2962 l_update_mode                   varchar2(30) := 'UPDATE';
2963 l_activate_flag                 varchar2(1)  := 'N';
2964 l_suspend_flag                  varchar2(1)  := 'N';
2965 l_terminate_flag                varchar2(1)  := 'N';
2966 l_employee_update_flag          varchar2(1)  := 'N';
2967 l_update_gre                    varchar2(1)  := 'N';
2968 l_rehire_ex_emp                 varchar2(1 ) := 'N';
2969 l_period_of_service_id          number;
2970 l_payroll_id                    pay_payrolls_f.payroll_id%type;
2971 l_payroll_name                  pay_payrolls_f.payroll_name%type;
2972 l_business_group_id             per_people_f.business_group_id%type;
2973 l_orig_hire_warning             boolean;
2974 
2975 l_working_hours                 per_assignments_f.normal_hours%type;
2976 
2977 l_SOFT_CODING_KEYFLEX_ID        NUMBER;
2978 l_COMMENT_ID                    NUMBER;
2979 l_EFFECTIVE_START_DATE          DATE  ;
2980 l_EFFECTIVE_END_DATE            DATE  ;
2981 l_CONCATENNATED_SEGMENTS        VARCHAR2(150) ;
2982 l_NO_MANAGERS_WARNING           BOOLEAN  ;
2983 l_OTHER_MANAGER_WARNING         BOOLEAN  ;
2984 l_tax_unit_id                   number;
2985 
2986 l_del_ovn                       number(9);
2987 l_asg_id                        number(15);
2988 l_v_start_date                  date;
2989 l_v_end_date                    date;
2990 l_county_name                   per_addresses.region_1%type;
2991 l_count_rec                     number;
2992 
2993 l_session                       ghr_history_api.g_session_var_type;
2994 
2995 -- POSITION ABOLISH out parameters
2996 l_val_grd_chg_wng               boolean;
2997 l_pos_definition_id             number;
2998 l_name                          varchar2(240);
2999 l_pos_object_version_number     per_addresses.object_version_number%type;
3000 
3001 
3002 l_asg_payroll_id                number;
3003 -- added for ds change
3004 l_asg_location_id               number;
3005 l_temp_asg_loc_id               number;
3006 l_dum_char                      varchar2(240);
3007 l_dum_number                    number;
3008 l_position_data_rec_type        ghr_sf52_pos_update.position_data_rec_type;
3009 -- Variables used for Update GRE
3010 l_from_org_id                   hr_organization_units.organization_id%type;
3011 l_to_org_id                     hr_organization_units.organization_id%type;
3012 l_result_code                   varchar2(100);
3013 l_address_data                  per_addresses%rowtype;
3014 l_hr_user_type                  varchar2(20);
3015 
3016 l_old_system_status             per_assignment_status_types.per_system_status%type;
3017 
3018 l_remark_id                     ghr_remarks.remark_id%type;
3019 l_remark_description            ghr_remarks.description%type;
3020 l_pa_remark_id                  ghr_pa_remarks.pa_remark_id%type;
3021 l_rem_ovn                       ghr_pa_remarks.OBJECT_VERSION_NUMBER%type;
3022 l_form_field_name               varchar2(50);
3023 l_posn_title_pm                 varchar2(50);
3024 l_WS_pm                         varchar2(50);
3025 l_DS_pm                         varchar2(50);
3026 l_old_effective_start_date      date;
3027 
3028 -- Cursors declaration
3029 --
3030 -- Family Code
3031 
3032  Cursor c_noa_family_code IS
3033    Select fam.noa_family_code
3034    from   ghr_noa_families    nfa,
3035    ghr_families               fam
3036    where  nfa.nature_of_action_id  = p_pa_request_rec.first_noa_id
3037    and    nfa.noa_family_code      = fam.noa_family_code
3038    and    fam.update_hr_flag       = 'Y';
3039 
3040 -- Business group of the person
3041 
3042  Cursor  c_bus_gp is
3043    select per.business_group_id
3044    from   per_all_people_f per
3045   where   per.person_id = p_pa_request_rec.person_id
3046   and     g_effective_date between
3047           per.effective_start_date
3048   and     per.effective_end_date;
3049 
3050 -- Period of service
3051 
3052  Cursor  c_pds is
3053    select pds.period_of_service_id,
3054           pds.object_version_number
3055    from   per_periods_of_service pds
3056    where  pds.person_id   = p_pa_request_rec.person_id
3057    and    pds.date_start  <= g_effective_date
3058    and    pds.actual_termination_date is null
3059    order by 1 asc;
3060 
3061 
3062 -- Person Type
3063 
3064 cursor c_person_type is
3065   Select ppt.system_person_type,
3066          ppf.person_type_id
3067   from   per_person_types ppt,
3068          per_all_people_f     ppf
3069   where  ppf.person_id      = P_pa_request_rec.person_id
3070   and    ppt.person_type_id = ppf.person_type_id
3071   and    g_effective_date  between ppf.effective_start_date
3072   and    ppf.effective_end_date;
3073 
3074 
3075 -- Cursor to fetch all the assignment (pertaining to applications) records,
3076 -- except the one that gets passed from the Form
3077 -- The foll. cursor is currently not being used.
3078 
3079   Cursor c_other_asg is
3080     select asg.assignment_id,
3081            asg.object_version_number
3082     from   per_all_assignments_f asg
3083     where  asg.person_id         =  p_pa_request_rec.person_id
3084     and    asg.assignment_id    <>  p_pa_request_rec.employee_assignment_id;
3085 
3086 
3087 --  EX_Employee person type
3088 
3089   Cursor c_ex_emp_per_type is
3090     select ppt.person_type_id
3091     from   per_person_types ppt
3092     where  ppt.business_group_id  = l_business_group_id
3093     and    ppt.system_person_type = 'EX_EMP'
3094 --    and    ppt.user_person_type   = 'Ex-employee'
3095     and    ppt.active_flag        = 'Y'
3096     order by ppt.person_type_id asc;
3097 
3098 --
3099 
3100 -- Person Address
3101 --
3102 --May have to read from History depending on the action and effective date
3103 cursor c_address_type is
3104 select
3105           pad.address_id,
3106         pad.object_version_number,
3107           pad.address_line1,
3108           pad.address_line2,
3109           pad.address_line3,
3110           pad.town_or_city,
3111           pad.region_2,
3112           pad.postal_code,
3113           pad.country
3114 from
3115           per_addresses pad
3116 where
3117           pad.person_id = p_pa_request_rec.person_id
3118 and     g_effective_date + 1
3119 between pad.date_from and nvl(pad.date_to,g_effective_date + 1)
3120 and     pad.primary_flag = 'Y';
3121 --
3122 -- Start Bug 1316321
3123 -- Cursor for  selecting corresponding secondary addresses for the primay
3124 -- address for end dating -- same cursor used for creating new secondary addresses
3125 cursor c_sec_address is
3126 select
3127           pad.address_id,
3128         pad.object_version_number,
3129           pad.address_line1 ,
3130           pad.address_line2 ,
3131           pad.address_line3 ,
3132           pad.town_or_city ,
3133           pad.region_2 ,
3134           pad.region_1 ,
3135           pad.postal_code ,
3136           pad.country ,
3137           pad.address_type,
3138           pad.primary_flag
3139 from
3140           per_addresses pad
3141 where
3142           pad.person_id = p_pa_request_rec.person_id
3143 and     g_effective_date
3144 between pad.date_from and nvl(pad.date_to,g_effective_date)
3145 and pad.primary_flag <> 'Y';
3146 
3147 cursor c_upd_primary_address(p_pa_request_id IN NUMBER,
3148                              p_address_id    IN NUMBER)
3149        is
3150   SELECT pah.information1
3151   FROM ghr_pa_history pah
3152   WHERE pah.table_name = 'PER_ADDRESSES'
3153     AND pah.information1 = p_address_id
3154     AND pah.pa_request_id IN
3155          (
3156           SELECT pa_request_id
3157             FROM ghr_pa_requests
3158           CONNECT BY prior pa_request_id = altered_pa_request_id
3159            START WITH pa_request_id = p_pa_request_id
3160          );
3161 --
3162 cursor  county_name is
3163  select  c.county_name
3164  from    pay_us_counties   c ,
3165          pay_us_city_names t ,
3166          pay_us_states     s,
3167          pay_us_zip_codes  z
3168  where   s.state_abbrev = p_pa_request_rec.forwarding_region_2
3169  and     t.city_name   =  p_pa_request_rec.forwarding_town_or_city
3170  and     t.state_code  = s.state_code
3171  and     t.state_code  = c.state_code
3172  and     t.county_code = c.county_code
3173  and     z.city_code   = t.city_code
3174  and     substr(p_pa_request_rec.forwarding_postal_code,1,5)
3175  between z.zip_start and z.zip_end
3176  and     z.state_code  =  t.state_code
3177  and     z.county_code = t.county_code;
3178 
3179 --
3180 
3181 -- Object_version_number and Normal Hours  - Asg
3182 
3183 cursor    asg_ovn(p_assignment_id in number) is
3184   select  paf.object_version_number,
3185           paf.business_group_id,
3186           paf.normal_hours,
3187           paf.location_id,
3188           paf.payroll_id
3189   from    per_all_assignments_f  paf
3190   where   paf.assignment_id = p_assignment_id
3191   and     g_effective_date
3192   between paf.effective_start_date
3193   and     paf.effective_end_date;
3194 
3195 -- Object_version_number  - Person
3196 
3197 cursor per_ovn is
3198   select ppf.object_version_number,
3199          ppf.business_group_id ,
3200          ppf.employee_number,
3201          ppf.national_identifier,
3202          ppf.date_of_birth,
3203          ppf.first_name,
3204          ppf.last_name,
3205          ppf.middle_names
3206   from   per_all_people_f  ppf
3207   where  ppf.person_id = P_pa_request_rec.person_id
3208   and    g_effective_date between ppf.effective_start_date
3209          and ppf.effective_end_date;
3210 
3211 -- payroll id
3212 
3213  Cursor   c_payroll_name is
3214   select  rei_information3 payroll_id
3215   from    ghr_pa_request_extra_info
3216   where   pa_request_id       =   p_pa_request_rec.pa_request_id
3217   and     information_type    =   'GHR_US_PAR_PAYROLL_TYPE';
3218 
3219  Cursor    c_payroll_id is
3220    select  payroll_id
3221    from    pay_payrolls_f
3222    where   period_type        = 'Bi-Week'
3223    and     payroll_name       = l_payroll_name
3224    and     business_group_id  = l_business_group_id
3225    and     p_pa_request_rec.effective_date
3226    between effective_start_date and effective_end_date;
3227 
3228  Cursor    c_bw_payroll is
3229    select  pay.payroll_id
3230    from    pay_payrolls_f pay
3231    where   pay.payroll_name = 'Biweekly Payroll'
3232    and     g_effective_date
3233    between pay.effective_start_date and pay.effective_end_date
3234    and     business_group_id  = l_business_group_id;
3235 
3236 -- position object_version_number
3237 
3238   Cursor  c_pos_ovn is
3239     select pos.object_version_number
3240     from   hr_all_positions_f pos -- Venkat
3241     where  pos.position_id = p_pa_request_rec.from_position_id
3242     and p_pa_request_rec.effective_date between
3243     pos.effective_start_date and pos.effective_end_date;
3244 
3245 -- Tax Unit Id - GRE
3246 
3247  Cursor   c_tax_unit_org is
3248    select tax.tax_unit_id
3249    from   hr_tax_units_v tax
3250    where  tax_unit_id = p_pa_request_rec.to_organization_id;
3251 
3252  Cursor  c_tax_unit_bg is
3253    select tax.tax_unit_id
3254    from   hr_tax_units_v tax
3255    where  tax_unit_id = l_business_group_id;
3256 
3257 -- Getting from Organization_id
3258 
3259   Cursor  c_from_org_id is
3260     select pos.organization_id
3261     from   hr_all_positions_f pos
3262     where  pos.position_id = p_pa_request_rec.from_position_id
3263     and p_pa_request_rec.effective_date between
3264     pos.effective_start_date and pos.effective_end_date;
3265 
3266 -- Getting to Organization_id
3267 
3268   Cursor  c_to_org_id is
3269     select pos.organization_id
3270     from   hr_all_positions_f pos
3271     where  pos.position_id = p_pa_request_rec.to_position_id
3272     and p_pa_request_rec.effective_date between
3273     pos.effective_start_date and pos.effective_end_date;
3274 
3275 -- Getting Old User Status
3276 
3277   Cursor c_user_status is
3278   select ast.user_status,
3279          ast.per_system_status,
3280          asg.effective_start_date
3281   from
3282     per_assignment_status_types ast,
3283     per_all_assignments_f asg
3284     where asg.assignment_id = l_assignment_id
3285     and ast.assignment_status_type_id = asg.assignment_status_type_id
3286     and     g_effective_date
3287     between asg.effective_start_date
3288     and     asg.effective_end_date;
3289 
3290 -- Bug#2839332 Cursor to get the Assignment Status
3291 -- before NON_PAY_DUTY_STATUS Action for "RETURN TO DUTY" action.
3292 
3293 /****** Bug 5923426 Commented the cursor and wrote a modified one.
3294    Cursor c_user_old_status is
3295    Select asg.assignment_status_type_id
3296     from   per_assignments_f asg
3297     where  asg.assignment_id = l_assignment_id
3298     and    l_old_effective_start_date between asg.effective_start_date
3299                                           and asg.effective_end_date;
3300 ********/
3301 --- Bug 5923426 start
3302 
3303     Cursor c_user_old_status is
3304     Select past.per_system_status ,asg.assignment_status_type_id
3305     from   per_assignments_f asg,per_assignment_status_types past
3306     where  asg.assignment_id = l_assignment_id
3307     and asg.assignment_status_type_id = past.assignment_status_type_id
3308     order by  asg.effective_start_date desc;
3309 
3310 --- Bug 5923426 end
3311 
3312 -- JH Get To Position Title PM for Noa Code being updated.
3313   Cursor get_to_posn_title_pm is
3314     select  fpm.process_method_code
3315     from    ghr_noa_families         nof
3316            ,ghr_families             fam
3317            ,ghr_noa_fam_proc_methods fpm
3318            ,ghr_pa_data_fields       pdf
3319     where   nof.nature_of_action_id = p_pa_request_rec.first_noa_id
3320     and     nof.noa_family_code     = fam.noa_family_code
3321     and     nof.enabled_flag = 'Y'
3322     and     p_pa_request_rec.effective_date between nvl(nof.start_date_active,p_pa_request_rec.effective_date)
3323     and     nvl(nof.end_date_active,p_pa_request_rec.effective_date)
3324     and     fam.proc_method_flag = 'Y'
3325     and     fam.enabled_flag = 'Y'
3326     and     p_pa_request_rec.effective_date between nvl(fam.start_date_active,p_pa_request_rec.effective_date)
3327     and     nvl(fam.end_date_active,p_pa_request_rec.effective_date)
3328     and     fam.noa_family_code = fpm.noa_family_code
3329     and     fpm.pa_data_field_id = pdf.pa_data_field_id
3330     and     fpm.enabled_flag = 'Y'
3331     and     p_pa_request_rec.effective_date between nvl(fpm.start_date_active,p_pa_request_rec.effective_date)
3332     and     nvl(fpm.end_date_active,p_pa_request_rec.effective_date)
3333     and     pdf.form_field_name = l_form_field_name
3334     and     pdf.enabled_flag = 'Y'
3335     and     p_pa_request_rec.effective_date between nvl(pdf.date_from,p_pa_request_rec.effective_date)
3336     and     nvl(pdf.date_to,p_pa_request_rec.effective_date);
3337 --
3338 -- 3324737
3339 CURSOR RTD_asg_status( p_asg_id    NUMBER,
3340                 p_eff_date  DATE  )
3341 IS
3342 SELECT effective_date
3343 FROM   ghr_pa_Requests
3344 WHERE effective_date        <= p_eff_Date
3345 and   person_id = p_pa_request_rec.person_id
3346 --and   employee_assignment_id = p_Asg_id
3347 -- for performance reasons
3348 and pa_notification_id is not null
3349 and   noa_family_code        = 'NON_PAY_DUTY_STATUS'
3350 ORDER BY pa_request_id desc;
3351 
3352 l_rtd_date              DATE;
3353 --3324737
3354 --
3355 --
3356 l_assgn_id             NUMBER;
3357 l_eff_date             DATE;
3358 l_NTE_Dates            per_assignment_extra_info.aei_information4%TYPE;
3359 l_active_flag          varchar2(1);
3360 l_RTD_noa_code         VARCHAR2(80);
3361 l_bg_id                NUMBER;
3362 
3363 --
3364 -- 2839332
3365 --
3366 
3367 -- Bug 3215139
3368 CURSOR get_occ_code(c_position_id hr_all_positions_f.position_id%type, c_effective_date hr_all_positions_f.effective_start_date%type) IS
3369    SELECT pos.job_id
3370    FROM hr_all_positions_f pos
3371    WHERE pos.position_id = c_position_id
3372    AND c_effective_date BETWEEN pos.effective_start_date and pos.effective_end_date;
3373 
3374 CURSOR	get_segment(c_business_group_id per_people_f.business_group_id%type) IS
3375   SELECT	ORG_INFORMATION5
3376     FROM  	HR_ORGANIZATION_INFORMATION
3377    WHERE  	ORG_INFORMATION_CONTEXT = 'GHR_US_ORG_INFORMATION'
3378     	  AND	ORGANIZATION_ID = c_business_group_id;
3379 
3380 l_agency_segment hr_organization_information.org_information5%type;
3381 l_pos_agency_code VARCHAR2(30);
3382 
3383 CURSOR c_get_agency_code(c_segment hr_organization_information.org_information5%type,
3384 						 c_position_id hr_all_positions_f.position_id%type,
3385 						 c_effective_date hr_all_positions_f.effective_start_date%type) IS
3386 	SELECT DECODE(c_segment,'SEGMENT1',SEGMENT1,
3387                                 'SEGMENT2',SEGMENT2,
3388                                 'SEGMENT3',SEGMENT3,
3389                                 'SEGMENT4',SEGMENT4,
3390                                 'SEGMENT5',SEGMENT5,
3391                                 'SEGMENT6',SEGMENT6,
3392                                 'SEGMENT7',SEGMENT7,
3393                                 'SEGMENT8',SEGMENT8,
3394                                 'SEGMENT9',SEGMENT9,
3395                                 'SEGMENT10',SEGMENT10,
3396                                 'SEGMENT11',SEGMENT11,
3397                                 'SEGMENT12',SEGMENT12,
3398                                 'SEGMENT13',SEGMENT13,
3399                                 'SEGMENT14',SEGMENT14,
3400                                 'SEGMENT15',SEGMENT15,
3401                                 'SEGMENT16',SEGMENT16,
3402                                 'SEGMENT17',SEGMENT17,
3403                                 'SEGMENT18',SEGMENT18,
3404                                 'SEGMENT19',SEGMENT19,
3405                                 'SEGMENT20',SEGMENT20,
3406                                 'SEGMENT21',SEGMENT21,
3407                                 'SEGMENT22',SEGMENT22,
3408                                 'SEGMENT23',SEGMENT23,
3409                                 'SEGMENT24',SEGMENT24,
3410                                 'SEGMENT25',SEGMENT25,
3411                                 'SEGMENT26',SEGMENT26,
3412                                 'SEGMENT27',SEGMENT27,
3413                                 'SEGMENT28',SEGMENT28,
3414                                 'SEGMENT29',SEGMENT29,
3415                                 'SEGMENT30',SEGMENT30) agency_code
3416     FROM per_position_definitions ppd, hr_all_positions_f pos
3417 	WHERE pos.position_definition_id = ppd.position_definition_id
3418 	AND pos.position_id = c_position_id
3419 	AND c_effective_date BETWEEN pos.effective_start_date AND pos.effective_end_date;
3420 
3421 ------------------------
3422 
3423 l_update_occ_code VARCHAR2(1) := 'N';
3424 l_pos_job_id hr_all_positions_f.job_id%type;
3425 
3426 
3427 --Bug 3381960
3428 -- Get Assignment position for the person
3429 CURSOR c_get_asg_position(c_assignment_id per_all_assignments_f.assignment_id%type,
3430 						  c_effective_date per_all_assignments_f.effective_start_date%type) IS
3431 SELECT position_id
3432 FROM per_all_assignments_f asg
3433 WHERE asg.assignment_id = c_assignment_id
3434 AND c_effective_date BETWEEN asg.effective_start_date AND asg.effective_end_date;
3435 l_asg_position per_all_assignments_f.position_id%type;
3436 
3437 
3438 --Pradeep
3439 CURSOR cur_get_nte_date IS
3440     SELECT rei_information12 nte_date, rei_information11 amount
3441     FROM ghr_pa_request_extra_info
3442     WHERE rei_information_category='GHR_US_PAR_MD_DDS_PAY'
3443     AND   pa_request_id =  p_pa_request_rec.pa_request_id;
3444 
3445  CURSOR check_remarks is
3446     SELECT remark_id
3447     FROM   ghr_pa_remarks
3448     WHERE  pa_request_id = p_pa_request_rec.pa_request_id
3449     AND    remark_id =
3450            (select remark_id from ghr_remarks
3451             where code = 'BBB');
3452 
3453 
3454 
3455 
3456  Cursor  cur_get_remark_code(p_remark_id ghr_remarks.remark_id%TYPE) is
3457    select   rem.code
3458    from     ghr_remarks  rem
3459    where    rem.remark_id  =  p_remark_id
3460    and      rem.enabled_flag = 'Y'
3461    and      nvl(p_pa_request_rec.effective_date,sysdate)
3462    between  rem.date_from and nvl(rem.date_to,nvl(p_pa_request_rec.effective_date, trunc(sysdate)));
3463 
3464  l_mddds_special_pay_nte_date ghr_pa_request_extra_info.rei_information12%TYPE;
3465  l_mddds_total_special_pay    ghr_pa_request_extra_info.rei_information11%TYPE;
3466  l_check_remarks	      BOOLEAN := FALSE;
3467  l_rpa_remark_code            ghr_remarks.code%TYPE;
3468  l_rpa_remark_id	      ghr_remarks.remark_id%TYPE;
3469 
3470  --bug 4542437
3471  l_position_id                ghr_pa_requests.from_position_id%TYPE  :=NULL;
3472  l_job_id                     per_all_assignments_f.job_id%TYPE      :=NULL;
3473  l_org_id                     per_all_assignments_f.organization_id%TYPE :=NULL;
3474  l_grade_id                   per_position_extra_info.poei_information3%TYPE :=NULL;
3475  l_pos_ei_data                per_position_extra_info%ROWTYPE;
3476 Begin
3477     --
3478     -- Remember IN OUT parameter IN values
3479     --
3480     l_pa_request_rec := p_pa_request_rec;
3481 
3482  g_effective_date  :=  nvl(p_pa_request_rec.effective_date,sysdate);
3483  hr_utility.set_location('g_eff_date ' || to_char(g_effective_date),1);
3484 
3485  -- if Realignment then change the organization name in position
3486  if p_pa_request_rec.first_noa_code = '790' then
3487     l_position_data_rec_type.position_id            := p_pa_request_rec.to_position_id;
3488     l_position_data_rec_type.organization_id        := p_pa_request_rec.to_organization_id;
3489     l_position_data_rec_type.agency_code_subelement := p_agency_code;
3490     l_position_data_rec_type.effective_date   :=  g_effective_date;
3491     hr_utility.set_location('realign -pos ' || p_pa_request_rec.to_organization_id,1);
3492     ----l_position_data_rec_type.datetrack_mode := return_update_mode
3493     ----               (p_id                 => p_pa_request_rec.to_position_id,
3494     ----                p_effective_date     => p_pa_request_rec.effective_date,
3495     ----                p_table_name         => 'HR_ALL_POSITIONS_F'
3496     ----               );
3497    -- Start Bug 1613367
3498     For ovn in asg_ovn(p_pa_request_rec.employee_assignment_id) loop
3499       l_temp_asg_loc_id           := ovn.location_id;
3500     End loop;
3501     IF nvl(p_pa_request_rec.duty_station_location_id,hr_api.g_number)
3502          <> nvl(l_temp_asg_loc_id,hr_api.g_number) then
3503       l_position_data_rec_type.location_id        := p_pa_request_rec.duty_station_location_id;
3504     ELSE
3505       l_position_data_rec_type.location_id        := NULL;
3506     END IF;
3507     -- End Bug 1613367
3508 
3509     ghr_sf52_pos_update.update_position_info
3510                         (p_pos_data_rec   =>  l_position_data_rec_type
3511                         );
3512 /* -- SEt flag to update assignment with the targer org.
3513     l_employee_api_update_criteria := 'Y';
3514 */
3515 
3516  end if;
3517 
3518     -- Start Inserting AAA Remark
3519 
3520  hr_utility.set_location('Before the Remark creation - From PB '||p_pa_request_rec.from_pay_basis,3);
3521  hr_utility.set_location('Before the Remark creation - To PB '||p_pa_request_rec.to_pay_basis,3);
3522  hr_utility.set_location('Before the Remark creation - PRD  '||p_pa_request_rec.pay_rate_determinant,3);
3523 
3524 IF p_pa_request_rec.from_pay_basis <> p_pa_request_rec.to_pay_basis and
3525    p_pa_request_rec.pay_rate_determinant in ('A','B','E','F','U','V') THEN
3526 
3527  hr_utility.set_location('Inside the Remark creation ',3);
3528  ghr_mass_actions_pkg.get_remark_id_desc
3529       (p_remark_code     =>  'AAA',
3530        p_effective_date  =>  g_effective_date,
3531        p_remark_id       =>  l_remark_id,
3532        p_remark_desc     =>  l_remark_description
3533        );
3534 
3535 
3536   ghr_pa_remarks_api.create_pa_remarks
3537   (
3538    p_PA_REQUEST_ID                     =>    p_pa_request_rec.pa_request_id,
3539    p_REMARK_ID                         =>    l_remark_id,
3540    p_DESCRIPTION                       =>    l_remark_description,
3541    P_PA_REMARK_ID                      =>    l_pa_remark_id,
3542    p_OBJECT_VERSION_NUMBER             =>    l_rem_ovn
3543    );
3544 END IF;
3545  hr_utility.set_location('Passed  Remark creation ',5);
3546     -- End Inserting AAA Remark
3547 
3548 -- Start Populating BBB Remark
3549  IF p_pa_request_rec.first_noa_code = '850' THEN
3550     hr_utility.set_location('Inside the Remark creation ',3);
3551     --Check if user has entered any comments. If so do not populate BBB.
3552     hr_utility.set_location('Pa Request Id'||p_pa_request_rec.pa_request_id,3);
3553 
3554   FOR check_remarks_rec in check_remarks
3555   LOOP
3556 	l_check_remarks := TRUE;
3557 	l_rpa_remark_id  := check_remarks_rec.remark_id;
3558 	EXIT;
3559   END LOOP;
3560 
3561   FOR cur_get_nte_date_rec IN  cur_get_nte_date
3562   LOOP
3563     l_mddds_special_pay_nte_date := cur_get_nte_date_rec.nte_date;
3564     l_mddds_total_special_pay    :=  cur_get_nte_date_rec.amount;
3565   END LOOP;
3566 
3567   IF NOT l_check_remarks THEN
3568 
3569 	  ghr_mass_actions_pkg.get_remark_id_desc
3570 	       (p_remark_code     =>  'BBB',
3571 		p_effective_date  =>  g_effective_date,
3572 		p_remark_id       =>  l_remark_id,
3573 		p_remark_desc     =>  l_remark_description
3574 		);
3575 
3576 	  l_remark_description := replace(l_remark_description,'_')
3577 				  ||to_char(fnd_date.canonical_to_date(l_mddds_special_pay_nte_date),'DD-MON-RRRR');
3578 
3579 	  --while terminating the MDDDS_SPECIAL_PAY element it should delete the  remarks also.
3580 	  IF ( l_mddds_total_special_pay <> 0 )
3581 	     and ( l_mddds_total_special_pay IS NOT NULL ) THEN
3582 
3583 		   ghr_pa_remarks_api.create_pa_remarks
3584 		   (
3585 		    p_PA_REQUEST_ID                     =>    p_pa_request_rec.pa_request_id,
3586 		    p_REMARK_ID                         =>    l_remark_id,
3587 		    p_DESCRIPTION                       =>    l_remark_description,
3588 		    P_PA_REMARK_ID                      =>    l_pa_remark_id,
3589 		    p_OBJECT_VERSION_NUMBER             =>    l_rem_ovn,
3590 		    p_remark_code_information1          =>    l_mddds_special_pay_nte_date
3591 		    );
3592 
3593 
3594 	   END IF;
3595      ELSE
3596 	  --while terminating the MDDDS_SPECIAL_PAY element it should delete the  remarks also.
3597 	  IF ( l_mddds_total_special_pay = 0 )
3598 	     OR ( l_mddds_total_special_pay IS NULL ) THEN
3599 
3600 		hr_utility.set_location('Inside else'||l_rpa_remark_id ,10);
3601 		FOR get_remark_code_rec IN cur_get_remark_code(l_rpa_remark_id)
3602 		LOOP
3603 		   l_rpa_remark_code := get_remark_code_rec.code;
3604 		END LOOP;
3605 		hr_utility.set_location('Remark Code already entered ' ||l_rpa_remark_code,11);
3606 		IF l_rpa_remark_code='BBB' THEN
3607 			-- While terminating the element if BBB remark is present then
3608 			hr_utility.set_message(8301,'GHR_38877_850_REMARK');
3609 			hr_utility.raise_error;
3610 		END IF;
3611 	END IF;
3612 
3613     END IF;
3614  END IF;
3615  --End of Populating BBB remark.
3616 
3617 
3618 
3619  hr_utility.set_location('Entering  ' ||l_proc,5);
3620 
3621  l_noa_family_code := null;
3622  for family_code in c_noa_family_code loop
3623    l_noa_family_code := family_code.noa_family_code;
3624  End loop;
3625 
3626  l_person_type   :=  null;
3627 
3628   -- fetch person_type
3629  l_person_type    := null;
3630  for person_type in c_person_type loop
3631    l_person_type    :=  person_type.system_person_type;
3632    l_person_type_id := person_type.person_type_id;
3633    exit;
3634  end loop;
3635 
3636  if l_person_type is null then
3637    hr_utility.set_message(8301,'GHR_38133_INVALID_PERSON');
3638    hr_utility.raise_error;
3639  end if;
3640  hr_utility.set_location(l_proc,10);
3641 
3642 --
3643 
3644 for  bus_gp in c_bus_gp loop
3645   l_business_group_id      := bus_gp.business_group_id;
3646 end loop;
3647 
3648 -- if Change in data element then change the job id in position
3649  if p_pa_request_rec.first_noa_code = '800' then
3650 	-- Bug 3786467
3651 	-- Get Agency code segment from ORG EI
3652 	FOR l_get_segment IN get_segment(l_business_group_id) LOOP
3653 		l_agency_segment := l_get_segment.org_information5;
3654 	END LOOP;
3655 	-- Get Agency code from Position
3656 	FOR l_get_agency_code IN c_get_agency_code(l_agency_segment,p_pa_request_rec.to_position_id,p_pa_request_rec.effective_date) LOOP
3657 		l_pos_agency_code := l_get_agency_code.agency_code;
3658 	END LOOP;
3659 	-- Get Job id value from the Core Position form
3660 	-- Bug 3215139 Sundar
3661 	FOR l_get_occ_code IN get_occ_code(p_pa_request_rec.to_position_id,nvl(p_pa_request_rec.effective_date,trunc(sysdate))) LOOP
3662 	   l_pos_job_id := l_get_occ_code.job_id;
3663 	END LOOP;
3664 	hr_utility.set_location('p_agency_code' ||p_agency_code,1);
3665 	hr_utility.set_location('Position agency_code' ||l_pos_agency_code,1);
3666 	-- Need to update Position only if OCC_CODE is different in RPA form than the Position.
3667 	-- Commented for testing
3668 	IF (p_pa_request_rec.to_job_id <> l_pos_job_id) OR (p_agency_code <> l_pos_agency_code) THEN
3669 		l_position_data_rec_type.position_id            := p_pa_request_rec.to_position_id;
3670 		l_position_data_rec_type.job_id                 := p_pa_request_rec.to_job_id;
3671 		l_position_data_rec_type.agency_code_subelement := p_agency_code;
3672 		l_position_data_rec_type.effective_date         := g_effective_date;
3673 		hr_utility.set_location('change in data element-pos ' || p_pa_request_rec.to_job_id,1);
3674 		l_position_data_rec_type.datetrack_mode := return_update_mode
3675 					   (p_id                 => p_pa_request_rec.to_position_id,
3676 						p_effective_date     => p_pa_request_rec.effective_date,
3677 						p_table_name         => 'HR_ALL_POSITIONS_F'
3678 					   );
3679 
3680 		ghr_sf52_pos_update.update_position_info
3681 							(p_pos_data_rec   =>  l_position_data_rec_type
3682 							);
3683 			l_update_occ_code := 'Y';
3684 	END IF; -- If p_pa_request_rec.to_job_id <> l_pos_job_id
3685 	-- End 3215139
3686  end if;
3687 
3688 
3689 
3690   ghr_history_api.get_g_session_var(l_session);
3691   hr_utility.set_location('NOA ID CORRECT  :  ' || l_session.noa_id_correct,1);
3692 
3693 If l_noa_family_code  =   'APP' then
3694   hr_utility.set_location(l_proc,15);
3695   l_per_object_version_number   := null;
3696   for ovn  in per_ovn loop
3697     l_business_group_id         := ovn.business_group_id;
3698     l_per_object_version_number := ovn.object_version_number;
3699     l_per_upd_employee_number   := ovn.employee_number;
3700   end loop;
3701   if l_per_object_version_number is null then
3702     hr_utility.set_message(8301,'GHR_38133_INVALID_PERSON');
3703     hr_utility.raise_error;
3704   end if;
3705 
3706   If l_person_type = 'APL' then    -- and the action is not correction
3707     hr_utility.set_location(l_proc,20);
3708     l_hr_applicant_api_hire              := 'Y';
3709     l_update_mode                        := 'CORRECTION';
3710     l_activate_flag                      := 'Y';
3711   End if;
3712    --Bug# 6711759 Included the person type EX_EMP_APL
3713   If l_person_type in ('EX_EMP','EX_EMP_APL') then
3714     hr_utility.set_location(l_proc,21);
3715       l_rehire_ex_emp                      := 'Y';
3716       l_activate_flag                      := 'Y';
3717   End if;
3718 
3719   -- Code added by skutteti on 13-jul-98 bug #699856
3720   If nvl(p_pa_request_rec.From_Position_Id, hr_api.g_number) <>
3721      nvl(p_pa_request_rec.to_position_id,   hr_api.g_number) then
3722      l_employee_api_update_criteria := 'Y';
3723      l_update_gre              := 'Y';
3724   end if;
3725 
3726 --End of  cases exclusive case for Appointment family
3727  Else   -- If noa_family_code <> 'APP'
3728   If l_person_type = 'EX_EMP' then
3729     hr_utility.set_location(l_proc,25);
3730     l_rehire_ex_emp            :=  'Y';
3731     l_activate_flag              :=  'Y';
3732     l_employee_api_update_criteria := 'Y';
3733     l_update_gre              := 'Y'; -- Added Venkat Bug # 1239688
3734   End if;
3735   If p_pa_request_rec.to_position_id is not null then
3736     If nvl(p_pa_request_rec.From_Position_Id,hr_api.g_number) <>  P_pa_request_rec.to_position_id
3737      then
3738      hr_utility.set_location('Non Appointment -- To pos <> From Pos - GRE  ' ||l_proc,41);
3739      l_employee_api_update_criteria := 'Y';
3740      l_update_gre       := 'Y';
3741      l_update_mode      := 'UPDATE';  -- If action is Correction,then update_mode = 'CORRECTION'
3742    end if;
3743   End if;
3744 
3745 	-- Bug 3381960
3746 	IF p_pa_request_rec.to_position_id IS NOT NULL THEN
3747 		-- Get Assignment Position. If it's not equal to To position of RPA, then assignment
3748 		-- should be updated
3749 
3750 		FOR l_get_asg_position IN c_get_asg_position(p_pa_request_rec.employee_assignment_id,
3751 													p_pa_request_rec.effective_date) LOOP
3752 			l_asg_position := l_get_asg_position.position_id;
3753 		END LOOP;
3754 		hr_utility.set_location('Assg Pos   ' ||l_asg_position,41);
3755 		IF l_asg_position IS NOT NULL AND (p_pa_request_rec.to_position_id <> l_asg_position) THEN
3756 			hr_utility.set_location('To pos <> Assg Pos   ' ||l_proc,41);
3757 			l_employee_api_update_criteria := 'Y';
3758 		END IF;
3759 
3760 	END IF;
3761 
3762    --
3763    --  Added by subbu on 25-Feb-98. Assignment information has to be updated irrespective
3764    --  of the change in position for REALIGNMENT
3765    --
3766    if l_noa_family_code = 'REALIGNMENT' then
3767       hr_utility.set_location('realign' || p_pa_request_rec.to_organization_id,1);
3768       l_employee_api_update_criteria := 'Y';
3769       l_update_gre                   := 'Y';
3770    end if;
3771    --
3772    --  Added by subbu on 13-Jul-98. Assignment information has to be updated irrespective
3773    --  of the change in position for NOA 713 (change to lower grade)
3774    --
3775    --if l_noa_family_code = 'SALARY_CHG' then
3776         if p_pa_request_rec.to_grade_or_level is not null and
3777        nvl(p_pa_request_rec.from_grade_or_level,hr_api.g_varchar2) <> p_pa_request_rec.to_grade_or_level then
3778       l_employee_api_update_criteria := 'Y';
3779    end if;
3780    --
3781    -- Update of Pay Plan GG to Assignmentn 855 processing.
3782    -- Added by AVR on 07-APR-2004.
3783    -- Bug#5089732 Added the l_noa_family_code condition.
3784      IF p_pa_request_rec.first_noa_code = '855'
3785         OR
3786         p_pa_request_rec.second_noa_code = '855'
3787         OR
3788         l_noa_family_code = 'REASSIGNMENT' --Bug# 7209120
3789         OR
3790         l_noa_family_code like 'GHR_SAL%' THEN
3791 
3792         IF nvl(p_pa_request_rec.from_pay_plan,hr_api.g_varchar2) <> p_pa_request_rec.to_pay_plan then
3793              l_employee_api_update_criteria := 'Y';
3794         END IF;
3795      END IF;
3796    --
3797    --  Added by Dan on 09-Jun-98. Assignment information has to be updated irrespective
3798    --  of the change in position for NOA 800 (change in data element)
3799    --
3800    if l_noa_family_code = 'CHG_DATA_ELEMENT' then
3801       hr_utility.set_location('realign' || p_pa_request_rec.to_job_id,3);
3802 	  IF (l_update_occ_code = 'Y') THEN -- Sundar 3215139 Need to update assignment only if position is updated
3803       l_employee_api_update_criteria := 'Y';
3804 	  END IF;
3805    end if;
3806 
3807 --BUG 4542437
3808 if l_noa_family_code = 'NON_PAY_DUTY_STATUS' then
3809     hr_utility.set_location('Family code Non pay duty status ',500);
3810     IF p_pa_request_rec.to_position_id  IS  NULL THEN
3811         hr_utility.set_location('To position id is null but position id is changed by a retro',519);
3812         l_position_id  := p_pa_request_rec.from_position_id;
3813         hr_utility.set_location('l_position id '||l_position_id,525);
3814         --Getting job id
3815         FOR l_get_occ_code IN   get_occ_code(p_pa_request_rec.from_position_id,nvl(p_pa_request_rec.effective_date,trunc(sysdate))) LOOP
3816             l_job_id := l_get_occ_code.job_id;
3817         END LOOP;
3818         hr_utility.set_location('job_id '||l_job_id,545);
3819         ---Getting organization id
3820         for get_org_id in c_from_org_id loop
3821             l_org_id := get_org_id.organization_id;
3822         end loop;
3823         hr_utility.set_location('l_oraganization id '||l_org_id,575);
3824         -- Get Assignment Position. If it's not equal to To position of RPA, then assignment
3825         -- should be updated
3826         FOR l_get_asg_position IN c_get_asg_position(p_pa_request_rec.employee_assignment_id, p_pa_request_rec.effective_date) LOOP
3827             l_asg_position := l_get_asg_position.position_id;
3828         END LOOP;
3829         hr_utility.set_location('Assg Pos   ' ||l_asg_position,599);
3830 
3831         --Getting Grade id
3832         ghr_history_fetch.fetch_positionei
3833             (p_position_id         => l_position_id
3834             ,p_information_type    => 'GHR_US_POS_VALID_GRADE'
3835             ,p_date_effective      => p_pa_request_rec.effective_date
3836             ,p_pos_ei_data         => l_pos_ei_data);
3837 
3838         l_grade_id := l_pos_ei_data.poei_information3;
3839 
3840         hr_utility.set_location('l_grade id for the new position '||l_grade_id,875);
3841 	    --Bug# 6010971, added grade_id condition
3842         IF l_asg_position IS NOT NULL
3843              AND ((l_position_id <> l_asg_position)
3844                     OR (nvl(P_pa_request_rec.to_grade_id,hr_api.g_number) <> nvl(l_grade_id,hr_api.g_number)))
3845              THEN
3846                 hr_utility.set_location('To pos <> Assg Pos   ' ||l_proc,650);
3847                 l_employee_api_update_criteria := 'Y';
3848         END IF;
3849         --Bug# 6010971
3850 
3851    END IF; --p_pa_request_rec.to_position_id  IS  NULL
3852 END IF; --l_noa_family_code = 'NON_PAY_DUTY_STATUS'
3853 
3854 
3855    -- Name change
3856    if l_noa_family_code = 'CHG_NAME' then
3857      l_update_person              := 'Y';
3858    elsif  l_noa_family_code  = 'RETURN_TO_DUTY' then
3859      hr_utility.set_location(l_proc,45);
3860      l_activate_flag  := 'Y';
3861    elsif l_noa_family_code  =  'NON_PAY_DUTY_STATUS' then
3862      hr_utility.set_location(l_proc,50);
3863      l_suspend_flag   := 'Y';
3864    elsif l_noa_family_code  =  'SEPARATION' then
3865      hr_utility.set_location(l_proc,55);
3866      l_terminate_flag := 'Y';
3867      IF  P_pa_request_rec.FORWARDING_ADDRESS_LINE1      is not null or
3868        P_pa_request_rec.FORWARDING_ADDRESS_LINE2        is not null or
3869        P_pa_request_rec.FORWARDING_ADDRESS_LINE3        is not null or
3870        P_pa_request_rec.FORWARDING_TOWN_OR_CITY         is not null or
3871        P_pa_request_rec.FORWARDING_REGION_2         is not null or
3872        P_pa_request_rec.FORWARDING_POSTAL_CODE      is not null or
3873        P_pa_request_rec.FORWARDING_COUNTRY          is not null  THEN
3874        hr_utility.set_location(l_proc,60);
3875        FOR address in c_address_type LOOP
3876          l_address_id                := address.address_id;
3877          l_add_object_version_number := address.object_version_number;
3878          l_address_line1             := address.address_line1;
3879          l_address_line2             := address.address_line2;
3880          l_address_line3             := address.address_line3;
3881          l_town_or_city              := address.town_or_city;
3882          l_region_2                  := address.region_2;
3883          l_postal_code               := address.postal_code;
3884          l_country                   := address.country;
3885        END LOOP;
3886        hr_utility.set_location('Dump Address data' || l_proc,61);
3887        hr_utility.set_location('p_pa_request_rec.FORWARDING_ADDRESS_LINE1 ' ||substr(p_pa_request_rec.FORWARDING_ADDRESS_LINE1,1,40),62 );
3888        hr_utility.set_location('p_pa_request_rec.FORWARDING_ADDRESS_LINE2 ' ||substr(p_pa_request_rec.FORWARDING_ADDRESS_LINE2,1,40),63 );
3889        hr_utility.set_location('p_pa_request_rec.FORWARDING_ADDRESS_LINE3 ' ||substr(p_pa_request_rec.FORWARDING_ADDRESS_LINE3,1,40),64 );
3890        hr_utility.set_location('p_pa_request_rec.FORWARDING_TOWN_OR_CITY ' ||p_pa_request_rec.FORWARDING_TOWN_OR_CITY,65 );
3891        hr_utility.set_location('p_pa_request_rec.FORWARDING_REGION_2 ' ||substr(p_pa_request_rec.FORWARDING_REGION_2,1,40),66 );
3892        hr_utility.set_location('p_pa_request_rec.FORWARDING_POSTAL_CODE ' ||p_pa_request_rec.FORWARDING_POSTAL_CODE,67 );
3893        hr_utility.set_location('p_pa_request_rec.FORWARDING_COUNTRY ' ||substr(p_pa_request_rec.FORWARDING_COUNTRY,1,40),68 );
3894        hr_utility.set_location('l_ADDRESS_LINE1 ' ||substr(l_ADDRESS_LINE1,1,40),69 );
3895        hr_utility.set_location('l_ADDRESS_LINE2 ' ||substr(l_ADDRESS_LINE2,1,40),70 );
3896        hr_utility.set_location('l_ADDRESS_LINE3 ' ||substr(l_ADDRESS_LINE3,1,40),71 );
3897        hr_utility.set_location('l_TOWN_OR_CITY ' ||l_TOWN_OR_CITY,72 );
3898        hr_utility.set_location('l_REGION_2 ' ||substr(l_REGION_2,1,40),73 );
3899        hr_utility.set_location('l_POSTAL_CODE ' ||l_POSTAL_CODE,74 );
3900        hr_utility.set_location('l_COUNTRY ' ||substr(l_COUNTRY,1,40),75 );
3901        IF l_session.noa_id_correct is null THEN
3902          IF  nvl(p_pa_request_rec.FORWARDING_ADDRESS_LINE1,hr_api.g_varchar2) = nvl(l_address_line1 ,hr_api.g_varchar2) and
3903              nvl(p_pa_request_rec.FORWARDING_ADDRESS_LINE2 ,hr_api.g_varchar2)= nvl(l_address_line2 ,hr_api.g_varchar2) and
3904              nvl(p_pa_request_rec.FORWARDING_ADDRESS_LINE3 ,hr_api.g_varchar2)= nvl(l_address_line3 ,hr_api.g_varchar2) and
3905              nvl(p_pa_request_rec.FORWARDING_TOWN_OR_CITY ,hr_api.g_varchar2) = nvl(l_town_or_city ,hr_api.g_varchar2) and
3906              nvl(p_pa_request_rec.FORWARDING_REGION_2 ,hr_api.g_varchar2)     = nvl(l_region_2 ,hr_api.g_varchar2) and
3907              nvl(p_pa_request_rec.FORWARDING_POSTAL_CODE ,hr_api.g_varchar2)  = nvl(l_postal_code ,hr_api.g_varchar2) and
3908              nvl(P_pa_request_rec.FORWARDING_COUNTRY ,hr_api.g_varchar2)      = nvl(l_country ,hr_api.g_varchar2) THEN
3909            null;
3910            hr_utility.set_location('Non Correction -- No Action ' || l_proc,76);
3911          ELSE
3912            l_create_address  := 'Y';
3913            hr_utility.set_location('Non Correction -- Create Address ' || l_proc,77);
3914          END IF;
3915        ELSE
3916          hr_utility.set_location('altered_pa_request_id is ' ||l_session.altered_pa_request_id ,65);
3917          hr_utility.set_location('noa_id_correct is ' ||l_session.noa_id_correct ,66);
3918          hr_utility.set_location('address_id is ' || l_address_id, 66);
3919          open c_upd_primary_address(l_session.altered_pa_request_id, l_address_id);
3920          fetch c_upd_primary_address into l_address_id;
3921          hr_utility.set_location('address_id is ' || l_address_id, 66);
3922 
3923          IF c_upd_primary_address%NOTFOUND then
3924            IF  nvl(p_pa_request_rec.FORWARDING_ADDRESS_LINE1,hr_api.g_varchar2) = nvl(l_address_line1 ,hr_api.g_varchar2) and
3925              nvl(p_pa_request_rec.FORWARDING_ADDRESS_LINE2 ,hr_api.g_varchar2)= nvl(l_address_line2 ,hr_api.g_varchar2) and
3926              nvl(p_pa_request_rec.FORWARDING_ADDRESS_LINE3 ,hr_api.g_varchar2)= nvl(l_address_line3 ,hr_api.g_varchar2) and
3927              nvl(p_pa_request_rec.FORWARDING_TOWN_OR_CITY ,hr_api.g_varchar2) = nvl(l_town_or_city ,hr_api.g_varchar2) and
3928              nvl(p_pa_request_rec.FORWARDING_REGION_2 ,hr_api.g_varchar2)     = nvl(l_region_2 ,hr_api.g_varchar2) and
3929              nvl(p_pa_request_rec.FORWARDING_POSTAL_CODE ,hr_api.g_varchar2)  = nvl(l_postal_code ,hr_api.g_varchar2) and
3930              nvl(P_pa_request_rec.FORWARDING_COUNTRY ,hr_api.g_varchar2)      = nvl(l_country ,hr_api.g_varchar2) THEN
3931              NULL;
3932              hr_utility.set_location('Correction -- No Action ' || l_proc,69);
3933            ELSE
3934              l_create_address := 'Y';
3935              hr_utility.set_location('Correction -- Create Address ' || l_proc,71);
3936            END IF;
3937          ELSE
3938            l_update_address := 'Y';
3939            hr_utility.set_location('Correction -- Update Address ' || l_proc,68);
3940          END IF;
3941          close c_upd_primary_address;
3942        END IF;
3943      END IF;
3944    ELSE
3945      hr_utility.set_location(l_proc,78);
3946    END IF;
3947 END IF;
3948 
3949 
3950 --   ***********
3951 --   Calling APIs
3952 --   ***********
3953 
3954 -- Fetch OVN for per_people_f, while processing hire_applicant and name change
3955 
3956 If  l_hr_applicant_api_hire  = 'Y' or
3957     l_rehire_ex_emp          = 'Y' or
3958     l_update_person          = 'Y' then
3959   l_per_object_version_number   := null;
3960   For ovn  in per_ovn loop
3961     l_business_group_id         := ovn.business_group_id;
3962     l_per_object_version_number := ovn.object_version_number;
3963     l_per_upd_employee_number   := ovn.employee_number;
3964   End loop;
3965   If l_per_object_version_number is null then
3966     hr_utility.set_message(8301,'GHR_38133_INVALID_PERSON');
3967     hr_utility.raise_error;
3968   End if;
3969 End if;
3970 --
3971 -- An Appointment Family can now only have 'APL's and hence only hire_applicants can be called.
3972 
3973 --  Before calling the hire_applicant, should delete all the other assignments for the person
3974 --  except the one that has been passed in. Call per_asg_del.del in 'ZAP' mode.
3975 --  If it's a CORRECTION to an Appointment , then should not call it
3976 
3977 -- Hire Applicant
3978 
3979 
3980 If l_hr_applicant_api_hire              = 'Y'  and l_session.noa_id_correct is null    then
3981   hr_utility.set_location(l_proc,75);
3982   hr_utility.set_location('Emp number is   ' || l_per_hire_employee_number,1);
3983  begin
3984   savepoint hire_app;
3985   hr_applicant_api.hire_applicant
3986  (P_HIRE_DATE                                   => g_effective_date
3987  ,P_PERSON_ID                                   => p_pa_request_rec.person_id
3988  ,P_ASSIGNMENT_ID                               => l_assignment_id
3989  ,P_PER_OBJECT_VERSION_NUMBER                 => l_per_object_version_number
3990  ,P_EMPLOYEE_NUMBER                             => l_per_hire_employee_number
3991  ,P_PER_EFFECTIVE_START_DATE                    => l_per_hire_eff_start_date
3992  ,P_PER_EFFECTIVE_END_DATE                      => l_per_hire_eff_end_date
3993  ,P_UNACCEPTED_ASG_DEL_WARNING                => l_per_hire_un_asg_del_warn
3994  ,P_ASSIGN_PAYROLL_WARNING                      => l_per_hire_asg_pay_warn
3995 , p_oversubscribed_vacancy_id                   => l_per_hire_oversubs_vac_id -- Bug# 1316490 -- Venkat --6/19
3996  );
3997   Exception
3998  when others then
3999    if substr(sqlerrm(sqlcode),1,19) = 'ORA-20001: APP-7975' then
4000     rollback to hire_app;
4001     hr_utility.set_message(8301,'GHR_38555_HIRE_ON_ACC_DATE') ;
4002     hr_utility.raise_error;
4003    Else
4004      rollback to hire_app;
4005      raise;
4006    End if;
4007  End;
4008 End if;
4009 
4010  l_assignment_id   := p_pa_request_rec.employee_assignment_id;
4011 
4012 If l_rehire_ex_emp = 'Y' and l_session.noa_id_correct is null then
4013   hr_utility.set_location(l_proc,76);
4014    Begin
4015     savepoint rehire_ex;
4016    hr_employee_api.re_hire_ex_employee
4017    (p_hire_date                  =>  p_pa_request_rec.effective_date
4018    ,p_person_id                  =>  p_pa_request_rec.person_id
4019    ,p_per_object_version_number  =>  l_per_object_version_number
4020  --  ,p_person_type_id           =>
4021    ,p_rehire_reason              =>  'Rehire'
4022    ,p_assignment_id              =>  l_assignment_id
4023    ,p_asg_object_version_number  =>  l_asg_object_version_number
4024    ,p_per_effective_start_date   =>  l_per_hire_eff_start_date
4025    ,p_per_effective_end_date     =>  l_per_hire_eff_end_date
4026    ,p_assignment_sequence        =>  l_dum_number
4027    ,p_assignment_number          =>  l_dum_char
4028    ,p_assign_payroll_warning     =>  l_per_hire_asg_pay_warn
4029    );
4030 -- Fix for 655045
4031    -- Start Changes for 3150551
4032    /*
4033    delete from per_person_list_changes
4034    where person_id =  p_pa_request_rec.person_id
4035    and  nvl(termination_flag,hr_api.g_varchar2) = 'Y';
4036    */
4037    hr_security_internal.clear_from_person_list_changes
4038    ( p_person_id => p_pa_request_rec.person_id );
4039    -- End Changes for 3150551
4040    Exception
4041    when others then
4042     rollback to rehire_ex;
4043     raise;
4044   End;
4045 End if;
4046 
4047 --Note : It looks like if the person_type_id is not passed in, then it defaults to the system_person_type of 'EMP' anyway .
4048 --       and therefore not passing it in.
4049 p_pa_request_rec.employee_assignment_id     :=   l_assignment_id;
4050 -- Bug# 1235958: Update of l_assignment_id for history records.
4051 ghr_history_api.get_g_session_var(l_session);
4052 l_session.assignment_id := l_assignment_id;
4053 ghr_history_api.set_g_session_var(l_session);
4054 
4055 
4056 -- fetch assignment Business_group, Object_version_number and Normal Hours
4057 
4058 l_asg_object_version_number   := null;
4059 For ovn in asg_ovn(l_assignment_id) loop
4060   l_business_group_id         := ovn.business_group_id;
4061   l_asg_object_version_number := ovn.object_version_number;
4062   l_working_hours             := ovn.normal_hours;
4063   l_asg_payroll_id            := ovn.payroll_id;
4064 -- added for duty_station change
4065   l_asg_location_id           := ovn.location_id;
4066 End loop;
4067 hr_utility.set_location(l_proc,95);
4068 If l_asg_object_version_number is null then
4069   hr_utility.set_message(8301,'GHR_38135_INVALID_ASGN');
4070   hr_utility.raise_error;
4071 End if;
4072 
4073 -- Bug 2082615
4074 -- Store the old Asg Status Type in g_old_user_status for using in later stages
4075 
4076     for asg_stat_rec in c_user_status loop
4077       g_old_user_status   := asg_stat_rec.user_status;
4078       l_old_system_status := asg_stat_rec.per_system_status;
4079       l_old_effective_start_date := asg_stat_rec.effective_start_date -1; --bug 2839332
4080       hr_utility.set_location('Old User status is '||g_old_user_status,96);
4081       hr_utility.set_location('Old system status '|| l_old_system_status,999);
4082       exit;
4083     end loop;
4084 
4085  If l_old_system_status <> 'SUSP_ASSIGN' or
4086   (l_noa_family_code = 'SEPARATION' or l_noa_family_code = 'RETURN_TO_DUTY' ) then
4087 
4088 -- Bug 2839332
4089     IF (l_noa_family_code = 'RETURN_TO_DUTY') THEN
4090         FOR rtd_rec in RTD_asg_status(p_pa_request_rec.employee_assignment_id,p_pa_request_rec.effective_date)
4091         LOOP
4092             l_old_effective_start_date := rtd_rec.effective_date-1;
4093             exit;
4094         END LOOP;
4095 
4096         for asg_stat_old_rec in c_user_old_status loop
4097             --- Bug 5923426 start
4098             IF asg_stat_old_rec.per_system_status <>'SUSP_ASSIGN' THEN
4099                 l_asg_status_type_id := asg_stat_old_rec.assignment_status_type_id;
4100                 exit;
4101             END IF;
4102             --- Bug 5923426 end
4103         end loop;
4104         hr_utility.set_location('Assignment status type id '|| l_asg_status_type_id,997);
4105 	    l_activate_flag := 'Y';
4106 	    -- Bug 2839332
4107         --Bug# 6010971
4108         IF nvl(P_pa_request_rec.to_grade_id,hr_api.g_number) <> nvl(l_grade_id,hr_api.g_number) then
4109             l_employee_api_update_criteria := 'Y';
4110         end if;
4111         --Bug# 6010971
4112     ELSE --(l_noa_family_code = 'RETURN_TO_DUTY')
4113 		-- Added p_assigment_id for Bug#4672772
4114         get_asg_status_type(p_noa_code       => p_pa_request_rec.first_noa_code,
4115                         p_business_group_id  => l_business_group_id,
4116                         p_assignment_id      => p_pa_request_rec.employee_assignment_id,
4117                         p_status_type_id     => l_asg_status_type_id,
4118                         p_activate_flag      => l_activate_flag,
4119                         p_suspend_flag       => l_suspend_flag,
4120                         p_terminate_flag     => l_terminate_flag
4121                          );
4122     END IF; --(l_noa_family_code = 'RETURN_TO_DUTY')
4123  End if; -- l_old_system_status <> 'SUSP_ASSIGN'
4124 
4125 --
4126 -- fetch payroll_id
4127 -- Note  : Fetch has to be done only in cases where the user has not input a value in the
4128 --         specific  DDF.
4129 
4130 l_payroll_id   := null;
4131 
4132 For payroll in c_payroll_name loop
4133   l_payroll_id := payroll.payroll_id;
4134 End loop;
4135 
4136 If l_payroll_id is null then
4137 
4138   -- If payroll_id in the assignment record is null then
4139   If l_asg_payroll_id is null then
4140     For bw_payroll in c_bw_payroll loop
4141       l_payroll_id  := bw_payroll.payroll_id;
4142        exit;
4143     End loop;
4144   Else
4145     l_payroll_id := l_asg_payroll_id;
4146   End if;
4147 End if;
4148 
4149 If l_payroll_id is null then
4150   hr_utility.set_message(8301,'GHR_38183_PAY_NOT_EXISTS');
4151   hr_utility.raise_error;
4152 End if;
4153 
4154 --Pradeep start of bug #4148743
4155 If l_payroll_id  <> l_asg_payroll_id THEN
4156     l_employee_api_update_criteria := 'Y';
4157 end if;
4158 --Pradeep end of bug #4148743
4159 
4160 
4161 If nvl(p_pa_request_rec.duty_station_location_id,hr_api.g_number) <> nvl(l_asg_location_id,hr_api.g_number) then
4162    l_employee_api_update_criteria     := 'Y';
4163 End if;
4164 
4165 --
4166 --  calling hr_assignment_api.update_emp_asg_criteria
4167 --
4168 If l_employee_api_update_criteria  = 'Y' or l_update_gre = 'Y' then
4169  -- Function to determine update_mode
4170   l_update_mode := return_update_mode
4171                    (p_id                 => p_pa_request_rec.employee_assignment_id,
4172                     p_effective_date     => p_pa_request_rec.effective_date,
4173                     p_table_name         => 'PER_ASSIGNMENTS_F'
4174                    );
4175   hr_utility.set_location(l_proc,90);
4176   hr_utility.set_location('Asg id ' || to_char(l_assignment_id),3);
4177   hr_utility.set_location('pay id ' || to_char(l_payroll_id),4);
4178   hr_utility.set_location('l_update_gre is '||l_update_gre,91);
4179 
4180  If l_update_gre = 'Y' then
4181    -- get the GRE . Passed into the foll. api as the p_tax_unit
4182    for tax_unit in c_tax_unit_org loop
4183      l_tax_unit_id := tax_unit.tax_unit_id;
4184    end loop;
4185    If l_tax_unit_id is null then
4186     for tax_unit in c_tax_unit_bg loop
4187       l_tax_unit_id := tax_unit.tax_unit_id;
4188     end loop;
4189    End if;
4190 
4191   hr_utility.set_location(l_proc,92);
4192   begin
4193    savepoint update_emp_asg;
4194    hr_assignment_api.update_us_emp_asg
4195    (p_assignment_id          => p_pa_request_rec.employee_assignment_id,
4196     p_object_version_number  => l_asg_object_version_number,
4197     p_effective_date         => g_effective_date,
4198     p_datetrack_update_mode  => l_update_mode,
4199     p_comment_id             => l_comment_id,
4200     p_tax_unit               => l_tax_unit_id, -- gre
4201     p_soft_coding_keyflex_id => l_soft_coding_keyflex_id,
4202     p_effective_start_date   => l_asg_upd_effective_start_date,
4203     p_effective_end_date     => l_asg_upd_effective_end_date,
4204     p_concatenated_segments  => l_concatenated_segments,
4205     p_no_managers_warning    => l_asg_upd_org_now_man_warn,
4206     p_other_manager_warning  => l_asg_upd_other_manager_warn
4207    );
4208     l_update_mode    := 'CORRECTION';
4209    Exception
4210     When others then
4211       rollback to update_emp_asg;
4212       raise;
4213    End;
4214  End if;
4215   hr_utility.set_location('After update_us_emp_asg '||l_proc,93);
4216  If l_employee_api_update_criteria = 'Y' then
4217   hr_utility.set_location('Before  update_emp_asg_criteria ',94);
4218 hr_utility.set_location('checking how correction updates the record',500);
4219 hr_utility.set_location('the to position id passed',500);
4220   hr_assignment_api.update_emp_asg_criteria
4221      (p_effective_date                          => g_effective_date
4222      ,p_datetrack_update_mode                   => l_update_mode
4223      ,p_assignment_id                           => l_assignment_id
4224      ,p_object_version_number                   => l_asg_object_version_number
4225      ,P_PAYROLL_ID                              => l_payroll_id
4226      ,p_position_id                             => nvl(P_pa_request_rec.to_position_id,l_position_id) --nvl added for bug 4542437
4227      ,p_job_id                                  => nvl(P_pa_request_rec.to_job_id,l_job_id) --nvl added for bug 4542437
4228      ,p_location_id                             => P_pa_request_rec.duty_station_location_id
4229      ,p_organization_id                         => nvl(P_pa_request_rec.to_organization_id,l_org_id)--nvl added for bug 4542437
4230      ,p_grade_id                                => nvl(P_pa_request_rec.to_grade_id,l_grade_id) --nvl added for bug 4542437
4231      ,p_effective_start_date                    => l_asg_upd_effective_start_date
4232      ,p_effective_end_date                      => l_asg_upd_effective_end_date
4233      ,p_special_ceiling_step_id                 => l_asg_upd_special_ceil_step_id
4234      ,p_people_group_id                         => l_asg_upd_people_group_id
4235      ,p_group_name                              => l_asg_upd_group_name
4236      ,p_org_now_no_manager_warning              => l_asg_upd_org_now_man_warn
4237      ,p_other_manager_warning                   => l_asg_upd_other_manager_warn
4238      ,p_spp_delete_warning                      => l_asg_upd_spp_delete_warning
4239      ,p_entries_changed_warning                 => l_asg_upd_entries_chan_warn
4240      ,p_tax_district_changed_warning            => l_asg_upd_tax_dist_chan_warn
4241      );
4242  End if;
4243 End if;
4244 --
4245   hr_utility.set_location('After update_emp_asg_criteria '||l_proc,95);
4246  If l_activate_flag = 'Y' and l_session.noa_id_correct is null  then
4247    hr_utility.set_location(l_proc,120);
4248    l_update_mode := return_update_mode
4249                    (p_id                 => p_pa_request_rec.employee_assignment_id,
4250                     p_effective_date     => p_pa_request_rec.effective_date,
4251                     p_table_name         => 'PER_ASSIGNMENTS_F'
4252                    );
4253    Begin
4254     savepoint activate;
4255 
4256    hr_assignment_api.activate_emp_asg
4257    (p_effective_date                  => g_effective_date
4258    ,p_datetrack_update_mode             => l_update_mode
4259    ,p_assignment_id                   => l_assignment_id
4260    ,p_assignment_status_type_id         => l_asg_status_type_id
4261    ,p_object_version_number             => l_asg_object_version_number
4262    ,p_effective_start_date            => l_asg_act_eff_start_date
4263    ,p_effective_end_date              => l_asg_act_eff_end_date
4264    );
4265   Exception
4266    when others then
4267      rollback to activate;
4268     raise;
4269   end;
4270  Elsif l_suspend_flag = 'Y' and l_session.noa_id_correct is null then  -- is a suspension and not a correction
4271    hr_utility.set_location(l_proc,125);
4272     l_update_mode := return_update_mode
4273                     (p_id                 => p_pa_request_rec.employee_assignment_id,
4274                      p_effective_date     => p_pa_request_rec.effective_date,
4275                      p_table_name         => 'PER_ASSIGNMENTS_F'
4276                     );
4277     Begin
4278      savepoint suspend;
4279     hr_assignment_api.suspend_emp_asg
4280    (p_effective_date                    => g_effective_date
4281    ,p_datetrack_update_mode             => l_update_mode
4282    ,p_assignment_id                     => l_assignment_id
4283    ,p_object_version_number             => l_asg_object_version_number
4284    ,p_assignment_status_type_id         => l_asg_status_type_id
4285    ,p_effective_start_date              => l_asg_sus_eff_start_date
4286    ,p_effective_end_date                => l_asg_sus_eff_end_date
4287    );
4288    Exception
4289     when others then
4290       rollback to suspend;
4291      raise;
4292    End;
4293 --        elsif l_terminate_asg_flag = 'Y' then
4294  Elsif l_terminate_flag = 'Y' then
4295 
4296    hr_utility.set_location(l_proc,130);
4297    hr_utility.set_location('NOA ID CORRECT  :  ' || l_session.noa_id_correct,1);
4298    If l_session.noa_id_correct is  null then
4299      hr_utility.set_location(l_proc,132);
4300      l_emp_trm_eff_end_date :=  null;
4301 
4302      for pds in c_pds loop
4303        l_period_of_service_id      := pds.period_of_service_id;
4304        l_pds_object_version_number := pds.object_version_number;
4305        exit;
4306      end loop;
4307 
4308      for ex_emp_type in c_ex_emp_per_type  loop
4309        l_person_type_id := ex_emp_type.person_type_id;
4310        exit;
4311      end loop;
4312      begin
4313       savepoint terminate;
4314      l_date1 := g_effective_date;
4315      hr_ex_employee_api.actual_termination_emp
4316     (p_effective_date                 => g_effective_date
4317     ,p_period_of_service_id           => l_period_of_service_id
4318     ,p_object_version_number          => l_pds_object_version_number
4319     ,p_actual_termination_date        => g_effective_date
4320     ,p_last_standard_process_date     => l_date1
4321     ,p_person_type_id                 => l_person_type_id
4322     ,p_assignment_status_type_id      => l_asg_status_type_id    -- the one derived using the fn. get_asg_status_type
4323     ,p_supervisor_warning             => l_supervisor_warning
4324     ,p_event_warning                  => l_event_warning
4325     ,p_interview_warning              => l_interview_warning
4326     ,p_review_warning                 => l_review_warning
4327     ,p_recruiter_warning              => l_recruiter_warning
4328     ,p_asg_future_changes_Warning     => l_asg_future_changes_warning
4329     ,p_entries_changed_warning        => l_entries_changed_warning
4330     ,p_pay_proposal_warning           => l_pay_proposal_warning
4331     ,p_dod_warning                    => l_dod_warning
4332     );
4333     -- Start Changes for 3150551
4334     /*
4335     insert into per_person_list_changes
4336        (person_id
4337        ,security_profile_id
4338        ,include_flag
4339        ,termination_flag)
4340        select l.person_id
4341        ,l.security_profile_id
4342        ,'Y'
4343        ,'Y'
4344        from per_person_list l
4345        where l.person_id =  p_pa_request_rec.person_id
4346          and not exists
4347               (Select 1
4348                From   per_person_list_changes pplc
4349                Where  pplc.person_id           = p_pa_request_rec.person_id
4350                And    pplc.security_profile_id = l.security_profile_id
4351               );
4352     */
4353     hr_security_internal.copy_to_person_list_changes
4354    (p_person_id => p_pa_request_rec.person_id );
4355     -- End Changes for 3150551
4356    Exception
4357     when others then
4358       rollback to terminate;
4359       raise;
4360    End;
4361 
4362     l_emp_trm_eff_end_date           := null;
4363  -- g_effective_date + 1;
4364    -- Checking whether Payroll installed or not. Skipping Final Process if the the Payrol
4365    -- Installed. If there is no payroll installed then doing Finall process.
4366    -- Assuming HR_USER_TYPE will be 'PER' if the payroll is not installed, so doing Final
4367    -- Process for HR user
4368     l_hr_user_type := fnd_profile.value('HR_USER_TYPE');
4369     IF l_hr_user_type = 'PER' THEN
4370       begin
4371 
4372         savepoint final_process;
4373         hr_ex_employee_api.final_process_emp
4374         (p_period_of_service_id          => l_period_of_service_id
4375         ,p_object_version_number         => l_pds_object_version_number
4376         ,p_final_process_date            => g_effective_date
4377         ,p_org_now_no_manager_warning    => l_org_now_no_manager_warning
4378         ,p_asg_future_changes_warning    => l_asg_future_changes_warning
4379         ,p_entries_changed_warning       => l_entries_changed_warning
4380         );
4381       EXCEPTION
4382         WHEN OTHERS THEN
4383         rollback to final_process;
4384         raise;
4385       END;
4386     END IF;
4387   END IF;
4388    --if 352 then need to end date position as well -- Rohini
4389    -- Bug 2835138 Sundar End date position only for MTO.
4390     IF (p_pa_request_rec.first_noa_code  = '352') AND (UPPER(SUBSTR(p_pa_request_rec.request_number,1,3)) = 'MTO') THEN
4391      l_position_data_rec_type.position_id   :=  p_pa_request_rec.from_position_id;
4392 --since in case of a SEPARATION, the to fields are all closed
4393 	-- Bug 3431540 Need to end date only on the next date of separation.
4394      l_position_data_rec_type.effective_date       :=  g_effective_date + 1;
4395      l_position_data_rec_type.effective_end_date   :=  g_effective_date + 1;
4396 	 -- End Bug 3431540
4397      l_position_data_rec_type.datetrack_mode := return_update_mode
4398                    (p_id                 => p_pa_request_rec.to_position_id,
4399                     p_effective_date     => p_pa_request_rec.effective_date,
4400                     p_table_name         => 'HR_ALL_POSITIONS_F'
4401                    );
4402      ghr_sf52_pos_update.update_position_info
4403      (p_pos_data_rec    =>  l_position_data_rec_type);
4404    END IF; -- If NOA is 352
4405 
4406 END IF;
4407 
4408 
4409 -- Name change  -- The same should cope up with both normal and correction actions
4410 If l_update_person  = 'Y' then
4411   hr_utility.set_location(l_proc,138);
4412   l_update_mode := return_update_mode
4413                    (p_id                 => p_pa_request_rec.person_id,
4414                     p_effective_date     => p_pa_request_rec.effective_date,
4415                     p_table_name         => 'PER_PEOPLE_F'
4416                    );
4417 
4418   hr_person_api.update_person
4419   (p_effective_date           =>  g_effective_date
4420   ,p_datetrack_update_mode    =>  l_update_mode
4421   ,p_person_id                =>  p_pa_request_rec.person_id
4422   ,p_object_version_number    =>  l_per_object_version_number
4423   ,p_employee_number          =>  l_per_upd_employee_number
4424   ,p_last_name                =>  p_pa_request_rec.employee_last_name
4425   ,p_first_name               =>  p_pa_request_rec.employee_first_name
4426   ,p_middle_names             =>  p_pa_request_rec.employee_middle_names
4427   ,p_national_identifier      =>  p_pa_request_rec.employee_national_identifier
4428   ,p_date_of_birth            =>  p_pa_request_rec.employee_date_of_birth
4429   ,p_effective_start_date     =>  l_per_upd_effective_start_date
4430   ,p_effective_end_date       =>  l_per_upd_effective_end_date
4431   ,p_full_name                =>  l_per_upd_full_name
4432   ,p_comment_id               =>  l_per_upd_comment_id
4433   ,p_name_combination_warning =>  l_per_upd_name_comb_warn
4434   ,p_assign_payroll_warning   =>  l_per_upd_assgn_payroll_warn
4435   ,p_orig_hire_warning        =>  l_orig_hire_warning
4436   );
4437 
4438 End if;
4439 --
4440 
4441 -- Address creation
4442 l_hr_user_type := fnd_profile.value('HR_USER_TYPE');
4443 hr_utility.set_location('in address'||l_hr_user_type,1000);
4444 IF l_hr_user_type = 'INT' THEN
4445 hr_utility.set_location('in per addresses',1000);
4446 If l_create_address = 'Y' or l_update_address = 'Y' then
4447 hr_utility.set_location('in upd addresses',1000);
4448    for county in county_name loop
4449       l_county_name := county.county_name;
4450    end loop;
4451    If   l_create_address  = 'Y' then
4452       -- 6919898 End dating the primary and secondary address
4453       -- only if exists If primary address does not exists just creating the new primary address
4454       -- to a person
4455       If l_address_id is not null  then
4456          hr_utility.set_location(l_proc,145);
4457         --- End dating all the secondary addresses for existing primary address
4458          for sec_address in c_sec_address loop
4459 
4460            hr_person_address_api.update_us_person_address
4461            (p_effective_date              => g_effective_date
4462            ,p_date_to                     => g_effective_date
4463 	   ,p_address_id                  => sec_address.address_id
4464 	   ,p_object_version_number       => sec_address.object_version_number
4465 	   );
4466 	 end loop;
4467 	   hr_utility.set_location('l_address_id'||l_address_id,1000);
4468 	    -- End dating the existing primary address
4469 	   hr_person_address_api.update_us_person_address
4470 	     (p_effective_date              => g_effective_date
4471 	     ,p_date_to                     => g_effective_date
4472 	     ,p_address_id                  => l_address_id
4473 	     ,p_object_version_number       => l_add_object_version_number
4474 	     );
4475        End If;	 -- l_address_id is not null
4476       -- Creating new primary address for forwarding address
4477       hr_person_address_api.create_us_person_address
4478      (p_effective_date              => g_effective_date
4479      ,p_person_id                   => p_pa_request_rec.person_id
4480      ,p_primary_flag                => 'Y'
4481      ,p_date_from                   => g_effective_date + 1
4482      ,p_address_line1               => p_pa_request_rec.forwarding_address_line1
4483      ,p_address_line2               => p_pa_request_rec.forwarding_address_line2
4484      ,p_address_line3               => p_pa_request_rec.forwarding_address_line3
4485      ,p_city                        => p_pa_request_rec.forwarding_town_or_city
4486      ,p_state                       => p_pa_request_rec.forwarding_region_2
4487      ,p_county                      => l_county_name
4488      ,p_zip_code                    => p_pa_request_rec.forwarding_postal_code
4489      ,p_country                     => p_pa_request_rec.forwarding_country
4490      ,p_address_id                  => l_per_add_address_id
4491      ,p_object_version_number       => l_per_add_ovr_number
4492      );
4493      --Creating new secondary addresses
4494      for sec_address in c_sec_address loop
4495      hr_person_address_api.create_us_person_address
4496      (p_effective_date              => g_effective_date
4497      ,p_person_id                   => p_pa_request_rec.person_id
4498      ,p_primary_flag                => 'N'
4499      ,p_date_from                   => g_effective_date + 1
4500      ,p_address_line1               => sec_address.address_line1
4501      ,p_address_line2               => sec_address.address_line2
4502      ,p_address_line3               => sec_address.address_line3
4503      ,p_city                        => sec_address.town_or_city
4504      ,p_state                       => sec_address.region_2
4505      ,p_county                      => sec_address.region_1
4506      ,p_zip_code                    => sec_address.postal_code
4507      ,p_country                     => sec_address.country
4508      ,p_address_type                => sec_address.address_type
4509      ,p_address_id                  => l_per_add_address_id
4510      ,p_object_version_number       => l_per_add_ovr_number
4511      );
4512      end loop;
4513    End if;
4514 
4515 --Update address -- In case of a correction, may be updating some entry in the address
4516 
4517   If l_update_address = 'Y' then
4518     hr_utility.set_location(l_proc,150);
4519     hr_person_address_api.update_us_person_address
4520    (p_address_id                      => l_address_id
4521    ,p_object_version_number           => l_add_object_version_number
4522    ,p_effective_date                  => g_effective_date
4523    ,p_address_line1                   => p_pa_request_rec.forwarding_address_line1
4524    ,p_address_line2                     => p_pa_request_rec.forwarding_address_line2
4525    ,p_address_line3                     => p_pa_request_rec.forwarding_address_line3
4526    ,p_city                              => p_pa_request_rec.forwarding_town_or_city
4527    ,p_state                             => p_pa_request_rec.forwarding_region_2
4528    ,p_county                        => l_county_name
4529    ,p_zip_code                      => p_pa_request_rec.forwarding_postal_code
4530    ,p_country                       => p_pa_request_rec.forwarding_country
4531    );
4532   End if;
4533 End if;
4534 ELSIF l_hr_user_type = 'PER' THEN
4535 If l_create_address = 'Y' or l_update_address = 'Y' then
4536    for county in county_name loop
4537           l_county_name := county.county_name;
4538    end loop;
4539    If   l_create_address  = 'Y' then
4540     -- 6919898 End dating the primary and secondary address
4541       -- only if exists If primary address does not exists just creating the new primary address
4542       -- to a person
4543       If l_address_id is not null  then
4544        hr_utility.set_location(l_proc,145);
4545        --- End dating all the secondary addresses for existing primary address
4546        for sec_address in c_sec_address loop
4547           hr_person_address_api.update_person_address
4548 	  (p_effective_date              => g_effective_date
4549 	  ,p_date_to                     => g_effective_date
4550 	  ,p_address_id                  => sec_address.address_id
4551 	  ,p_object_version_number       => sec_address.object_version_number
4552 	  );
4553        end loop;
4554 	  -- End dating the existing primary address
4555 	  hr_person_address_api.update_person_address
4556 	  (p_effective_date              => g_effective_date
4557 	  ,p_date_to                     => g_effective_date
4558 	  ,p_address_id                  => l_address_id
4559 	  ,p_object_version_number       => l_add_object_version_number
4560 	  );
4561       End If;
4562      -- Creating new primary address for forwarding address
4563      hr_person_address_api.create_person_address
4564      (p_effective_date              => g_effective_date
4565      ,p_person_id                   => p_pa_request_rec.person_id
4566      ,p_primary_flag                => 'Y'
4567      ,p_style                       => 'US_GLB_FED'  -- Bug# 4725292
4568      ,p_date_from                   => g_effective_date + 1
4569      ,p_address_line1               => p_pa_request_rec.forwarding_address_line1
4570      ,p_address_line2               => p_pa_request_rec.forwarding_address_line2
4571      ,p_address_line3               => p_pa_request_rec.forwarding_address_line3
4572      ,p_town_or_city                => p_pa_request_rec.forwarding_town_or_city
4573      ,p_region_1                    => l_county_name
4574      ,p_region_2                    => p_pa_request_rec.forwarding_region_2
4575      ,p_postal_code                    => p_pa_request_rec.forwarding_postal_code
4576      ,p_country                     => p_pa_request_rec.forwarding_country
4577      ,p_address_id                  => l_per_add_address_id
4578      ,p_object_version_number       => l_per_add_ovr_number
4579      );
4580      --Creating new secondary addresses
4581      for sec_address in c_sec_address loop
4582      hr_person_address_api.create_person_address
4583      (p_effective_date              => g_effective_date
4584      ,p_person_id                   => p_pa_request_rec.person_id
4585      ,p_primary_flag                => 'N'
4586      ,p_style                       => 'US_GLB_FED'  -- Bug# 4725292
4587      ,p_date_from                   => g_effective_date + 1
4588      ,p_address_line1               => sec_address.address_line1
4589      ,p_address_line2               => sec_address.address_line2
4590      ,p_address_line3               => sec_address.address_line3
4591      ,p_town_or_city                => sec_address.town_or_city
4592      ,p_region_2                    => sec_address.region_2
4593      ,p_region_1                    => sec_address.region_1
4594      ,p_postal_code                 => sec_address.postal_code
4595      ,p_country                     => sec_address.country
4596      ,p_address_type                => sec_address.address_type
4597      ,p_address_id                  => l_per_add_address_id
4598      ,p_object_version_number       => l_per_add_ovr_number
4599      );
4600      end loop;
4601    End if;
4602 
4603 --Update address -- In case of a correction, may be updating some entry in the address
4604 
4605   If l_update_address = 'Y' then
4606     hr_utility.set_location(l_proc,150);
4607     hr_person_address_api.update_person_address
4608    (p_address_id                      => l_address_id
4609    ,p_object_version_number           => l_add_object_version_number
4610    ,p_effective_date                  => g_effective_date
4611    ,p_address_line1                   => p_pa_request_rec.forwarding_address_line1
4612    ,p_address_line2                   => p_pa_request_rec.forwarding_address_line2
4613    ,p_address_line3                   => p_pa_request_rec.forwarding_address_line3
4614    ,p_town_or_city                    => p_pa_request_rec.forwarding_town_or_city
4615    ,p_region_2                        => p_pa_request_rec.forwarding_region_2
4616    ,p_region_1                        => l_county_name
4617    ,p_postal_code                     => p_pa_request_rec.forwarding_postal_code
4618    ,p_country                         => p_pa_request_rec.forwarding_country
4619    );
4620   End if;
4621 End if;
4622 END IF;
4623 
4624 
4625 -- The foll. is to determine whether or not there are changes in either -- SSN / DOB /NAMES of
4626 -- the employee , while doing a CORRECTION action only.
4627 
4628 If l_session.noa_id_correct is not null then
4629   for per in per_ovn loop
4630     l_business_group_id            :=  per.business_group_id;
4631     l_per_object_version_number    :=  per.object_version_number;
4632     l_per_upd_employee_number      :=  per.employee_number;
4633     l_per_national_identifier      :=  per.national_identifier;
4634     l_per_first_name               :=  per.first_name;
4635     l_per_last_name                :=  per.last_name;
4636     l_per_middle_names             :=  per.middle_names;
4637     l_per_date_of_birth            :=  per.date_of_birth;
4638   end loop;
4639   hr_utility.set_location(l_proc,138);
4640 
4641   if  nvl(p_pa_request_rec.employee_national_identifier,hr_api.g_varchar2) <>  nvl(l_per_national_identifier,hr_api.g_varchar2) or
4642       nvl(p_pa_request_rec.employee_date_of_birth,hr_api.g_date)           <> nvl(l_per_date_of_birth,hr_api.g_date) or
4643       nvl(p_pa_request_rec.employee_last_name,hr_api.g_varchar2)           <> nvl(l_per_last_name,hr_api.g_varchar2) or
4644         nvl(p_pa_request_rec.employee_first_name,hr_api.g_varchar2)          <> nvl(l_per_first_name,hr_api.g_varchar2)or
4645       nvl(p_pa_request_rec.employee_middle_names,hr_api.g_varchar2)        <> nvl(l_per_middle_names,hr_api.g_varchar2) then
4646 
4647     l_update_mode := return_update_mode
4648                    (p_id                 => p_pa_request_rec.person_id,
4649                     p_effective_date     => p_pa_request_rec.effective_date,
4650                     p_table_name         => 'PER_PEOPLE_F'
4651                    );
4652 
4653     hr_person_api.update_person
4654     (p_effective_date           =>  g_effective_date
4655     ,p_datetrack_update_mode    =>  l_update_mode
4656     ,p_person_id                =>  p_pa_request_rec.person_id
4657     ,p_object_version_number    =>  l_per_object_version_number
4658     ,p_employee_number          =>  l_per_upd_employee_number
4659     ,p_last_name                =>  p_pa_request_rec.employee_last_name
4660     ,p_first_name               =>  p_pa_request_rec.employee_first_name
4661     ,p_middle_names             =>  p_pa_request_rec.employee_middle_names
4662     ,p_national_identifier      =>  p_pa_request_rec.employee_national_identifier
4663     ,p_date_of_birth            =>  p_pa_request_rec.employee_date_of_birth
4664     ,p_effective_start_date     =>  l_per_upd_effective_start_date
4665     ,p_effective_end_date       =>  l_per_upd_effective_end_date
4666     ,p_full_name                =>  l_per_upd_full_name
4667     ,p_comment_id               =>  l_per_upd_comment_id
4668     ,p_name_combination_warning =>  l_per_upd_name_comb_warn
4669     ,p_assign_payroll_warning   =>  l_per_upd_assgn_payroll_warn
4670     ,p_orig_hire_warning        =>  l_orig_hire_warning
4671     );
4672 
4673   End if;
4674 End if;
4675 
4676 --
4677 /* -- Not supported for the September Release
4678 If l_noa_family_code = 'POS_ABOLISH' then
4679   for pos_ovn in c_pos_ovn loop
4680      l_pos_object_version_number :=  pos_ovn.object_version_number;
4681   end loop;
4682   hr_position_api.update_position
4683  (p_position_id                  => p_pa_request_rec.from_position_id,
4684   p_date_end                     => p_pa_request_rec.effective_date,
4685   p_object_version_number        => l_pos_object_version_number,
4686   p_position_definition_id       => l_pos_definition_id,
4687   p_name                         => l_name,
4688   p_valid_grades_changed_warning => l_val_grd_chg_wng
4689  );
4690 End if;
4691 */
4692 
4693 ----
4694 -- JH Adding update to Position's Location bug 773795
4695 -- This update is irrespective of family and is based on to_position being not null
4696 -- and the To Position process method
4697 -- Bug 2462929 For change in DS we must consider DS process method, if APUE/UE update Position.
4698 ----
4699 hr_utility.set_location('Update Positions Location  ' || l_proc,151);
4700 IF p_pa_request_rec.to_position_id IS NOT NULL THEN
4701 
4702   l_form_field_name := 'TO_POSITION_TITLE';
4703   FOR pm_rec in get_to_posn_title_pm LOOP
4704     l_posn_title_pm := pm_rec.process_method_code;
4705   END Loop;
4706 
4707   l_form_field_name := 'DUTY_STATION_CODE';
4708   FOR pm_rec in get_to_posn_title_pm LOOP
4709     l_DS_pm := pm_rec.process_method_code;
4710   END Loop;
4711 
4712   hr_utility.set_location('To Posn PM ' || l_posn_title_pm ,151);
4713   IF l_posn_title_pm = 'UE' OR
4714      (l_posn_title_pm = 'APUE' AND
4715                        nvl(p_pa_request_rec.to_position_id,hr_api.g_number) <> nvl(p_pa_request_rec.from_position_id,hr_api.g_number)) OR
4716      l_DS_pm in ('APUE','UE') OR
4717      (p_pa_request_rec.effective_date >= to_date('2007/01/07','YYYY/MM/DD') AND p_pa_request_rec.first_noa_code = '894') THEN
4718     ghr_sf52_pos_update.update_positions_location(
4719       p_position_id    => p_pa_request_rec.to_position_id,
4720       p_location_id    => p_pa_request_rec.duty_station_location_id,
4721       p_effective_date => p_pa_request_rec.effective_date);
4722   END IF;
4723 END IF;
4724 ----
4725 
4726 hr_utility.set_location('Leaving  ' || l_proc,155);
4727 Exception when others then
4728           --
4729           -- Reset IN OUT parameters and set OUT parameters
4730           --
4731           p_pa_request_rec := l_pa_request_rec;
4732           raise;
4733 
4734 End Process_Family;
4735 --
4736 
4737 --  ********************************
4738 --  procedure  Process_Salary_Info
4739 --  ********************************
4740 --
4741 Procedure Process_salary_Info
4742 (p_pa_request_rec         in      ghr_pa_requests%rowtype
4743  ,p_wgi             in out nocopy  ghr_api.within_grade_increase_type
4744 ,p_retention_allow_review         in out nocopy ghr_api.retention_allow_review_type
4745  ,p_capped_other_pay      in number default null
4746 ) is
4747 
4748 l_proc                        varchar2(70)  := 'Process_salary_info';
4749 l_noa_family_code             ghr_families.noa_family_code%type;
4750 l_adj_basic_pay_warn            boolean;
4751 l_element_entry_id            number;
4752 l_basic_pay_warn              boolean;
4753 l_locality_adj_warn           boolean;
4754 l_total_salary_warn           Boolean;
4755 l_within_grade_increase_warn  boolean;
4756 l_wgi_due_date                date;
4757 l_wgi_pay_date                date;
4758 l_lei_date                    varchar2(60);                 -- Bug 3111719
4759 v_payroll_id                  number;
4760 v_asg_effective_start_date    date;
4761 v_asg_effective_end_date      date;
4762 l_retained_grade_rec          ghr_pay_calc.retained_grade_rec_type;
4763 l_ret_grade_rec               ghr_pay_calc.retained_grade_rec_type;
4764 l_new_date_to                 per_people_extra_info.pei_information1%type;
4765 l_new_grade_or_level          per_people_extra_info.pei_information3%type;
4766 l_new_pay_plan                per_people_extra_info.pei_information3%type;
4767 l_new_pay_table               per_people_extra_info.pei_information3%type;
4768 l_new_loc_percent             per_people_extra_info.pei_information3%type;
4769 l_new_pay_basis               per_people_extra_info.pei_information3%type;
4770 l_new_step_or_rate            per_people_extra_info.pei_information4%type;
4771 l_cur_step_or_rate            per_people_extra_info.pei_information4%type;
4772 l_new_temp_step               per_people_extra_info.pei_information9%type;
4773 l_ret_object_version_number   ghr_pa_requests.object_version_number%type;
4774 l_effective_date              date;
4775 l_session                   ghr_history_api.g_session_var_type;
4776 l_value               varchar2(30);
4777 l_multiple_error_flag boolean;
4778 l_entitled_other_pay         number;
4779 
4780 
4781 
4782 -- Cursor declarations
4783 
4784 Cursor     c_ele_entry(ele_name varchar2,
4785                        ipv_name varchar2,
4786                        eff_date date,
4787                        bg_id   number
4788                       ) is
4789    select  eev.screen_entry_value screen_entry_value,
4790            ele.element_entry_id
4791    from    pay_element_types_f elt,
4792            pay_input_values_f ipv,
4793            pay_element_entries_f ele,
4794            pay_element_entry_values_f eev
4795    where   trunc(eff_date)
4796    between elt.effective_start_date  and     elt.effective_end_date
4797    and     trunc(eff_date)
4798    between ipv.effective_start_date  and ipv.effective_end_date
4799    and     trunc(eff_date)
4800    between ele.effective_start_date  and ele.effective_end_date
4801    and     trunc(eff_date)
4802    between eev.effective_start_date  and eev.effective_end_date
4803    and     elt.element_type_id       = ipv.element_type_id
4804    and     upper(elt.element_name)   = upper(ele_name)
4805    and     ipv.input_value_id        = eev.input_value_id
4806    and     ele.assignment_id         = p_pa_request_rec.employee_assignment_id
4807    and     ele.element_entry_id + 0  = eev.element_entry_id
4808    and     upper(ipv.name)           = upper( ipv_name)
4809 --   and     NVL(elt.business_group_id,0)     = NVL(ipv.business_group_id,0)    -- modified by Ashley
4810    and    (elt.business_group_id is null or elt.business_group_id = bg_id);
4811 
4812 
4813  Cursor c_retained_grade_ovn  is
4814    select object_version_number,
4815           pei_information2,
4816           pei_information3,
4817           pei_information4,
4818           pei_information5,
4819           pei_information6,
4820           pei_information7,
4821           pei_information8,
4822           pei_information9
4823    from   per_people_extra_info
4824    where  person_extra_info_id = l_retained_grade_rec.person_extra_info_id;
4825 
4826 l_wgi                      ghr_api.within_grade_increase_type;
4827 l_retention_allow_review   ghr_api.retention_allow_review_type;
4828 
4829 
4830 CURSOR cur_temp_step
4831 IS
4832 SELECT  rei_information3 temp_step
4833 FROM    ghr_pa_request_extra_info
4834 WHERE   pa_request_id = p_pa_request_rec.pa_request_id
4835 AND     information_type = 'GHR_US_PAR_RG_TEMP_PROMO';
4836 
4837 -- Start of code for Payroll Integration
4838 -- Payroll Integration
4839 Cursor Cur_bg(p_assignment_id NUMBER,p_eff_date DATE) is
4840        Select distinct business_group_id bg
4841        from per_assignments_f
4842        where assignment_id = p_assignment_id
4843        and   p_eff_date between effective_start_date
4844              and effective_end_date;
4845 
4846 Cursor Cur_Sal_Basis_name(p_bg_id NUMBER,p_ele_name VARCHAR2)
4847  IS
4848 Select pb.pay_basis_id
4849 From pay_element_types_f ele,
4850      pay_input_values_f inp,
4851      per_pay_bases pb
4852 where ele.business_group_id=p_bg_id
4853 and upper(element_name)=upper(p_ele_name)
4854 and ele.business_group_id=inp.business_group_id
4855 and ele.element_type_id=inp.element_type_id
4856 and inp.input_value_id=pb.input_value_id;
4857 
4858 Cursor Cur_asg_det_for_SB_upd(p_asg_id NUMBER,
4859                                 p_eff_date DATE)
4860 is
4861 select object_version_number   ovn,
4862          people_group_id         ppl_grp_id,
4863          special_ceiling_step_id spcl_clng_stp_id,
4864          soft_coding_keyflex_id  scl_kff_id,
4865          effective_start_date    start_date,
4866          effective_end_date      end_date,
4867          payroll_id
4868 from  per_assignments_f
4869 where assignment_id=p_asg_id
4870 -- and  position_id = p_pa_request_rec.to_position_id
4871 and  p_eff_date
4872      between effective_start_date and effective_end_date;
4873 
4874 l_SB_ovn                      per_assignments_f.object_version_number%type;
4875 l_ppl_grp_id               per_assignments_f.people_group_id%type;
4876 l_spcl_clng_stp_id         per_assignments_f.special_ceiling_step_id%type;
4877 l_scl_kff_id               per_assignments_f.soft_coding_keyflex_id%type;
4878 l_eff_start_date           per_assignments_f.effective_start_date%type;
4879 l_eff_end_date             per_assignments_f.effective_end_date%type;
4880 l_payroll_id               per_assignments_f.payroll_id%type;
4881 l_group_name               pay_people_groups.group_name%type;
4882 l_org_now_man_warn         boolean;
4883 l_other_manager_warn       boolean;
4884 l_spp_delete_warning       boolean;
4885 l_entries_chan_warn        varchar2(10);
4886 l_tax_dist_chan_warn       boolean;
4887 
4888 -- sal admin fields
4889 l_pay_proposal_id number;
4890 l_sal_admin_ovn number;
4891 l_ele_entry_id number;
4892 l_payroll_warn boolean;
4893 l_approve_warn  boolean;
4894 l_sal_warn  boolean;
4895 l_date_warn  boolean;
4896 
4897 l_bg_id                    NUMBER;
4898 l_sal_basis                VARCHAR2(80);
4899 l_sal_basis_type           VARCHAR2(80);
4900 l_sal_basis_id             NUMBER;
4901 l_basic_sal_rate           VARCHAR2(80);
4902 l_inp_val_id               VARCHAR2(80);
4903 l_pay_basis                VARCHAR2(80);
4904 -- to map pay basis to sal basis
4905 
4906 l_new_element_name         VARCHAR2(80);
4907 l_eff_Date                 DATE;
4908 
4909 Cursor Cur_proposal_exists (p_assignment_id IN NUMBER,
4910                             p_eff_date IN DATE) is
4911 Select ppp.pay_proposal_id       proposal_id,
4912        ppp.object_version_number ovn
4913 from   per_pay_proposals ppp
4914 where  ppp.assignment_id = p_assignment_id
4915 and    change_date       = p_eff_date;
4916 
4917 l_proposal_id          NUMBER;
4918 l_pay_intg             BOOLEAN:=FALSE;
4919 
4920 ll_element_link_id        pay_element_links_f.element_link_id%type;
4921 ll_input_value_id         pay_input_values_f.input_value_id%type;
4922 ll_element_entry_id       pay_element_entries_f.element_entry_id%type;
4923 ll_value                  pay_element_entry_values_f.screen_entry_value%type;
4924 ll_object_version_number  pay_element_entries_f.object_version_number%type;
4925 ll_multiple_error_flag    varchar2(50);
4926 l_error_text              varchar2(4000);
4927 l_dt_mode                 varchar2(200);
4928 
4929 cursor cur_ex_emp (p_person_id IN Number, p_effective_date IN Date)  is
4930 select 1
4931 from  per_person_types pet,
4932       per_people_f     per
4933 where pet.person_type_id = per.person_type_id
4934 and   per.person_id      = p_person_id
4935 and   p_effective_date
4936       between per.effective_start_date and per.effective_end_date
4937 and   pet.system_person_type = 'EX_EMP';
4938 
4939 l_asg_del_ovn                  NUMBER;
4940 l_org_now_no_manager_warning   BOOLEAN;
4941 l_validation_start_date        DATE;
4942 l_validation_end_date          DATE;
4943 l_effective_start_date         DATE;
4944 l_effective_end_date           DATE;
4945 l_payroll_value                NUMBER;
4946 l_fam_code                     VARCHAR2(80);
4947 ll_payroll_value               NUMBER;
4948 l_del_pay_prop                 BOOLEAN:=FALSE;
4949 l_ex_emp                       BOOLEAN := FALSE;
4950 l_ovn   NUMBER;
4951 --
4952 -- Payroll Integration
4953 -- End of variable declaration for Payroll Integration
4954 --
4955 
4956 -- No need for this cursor
4957 -- The values are properly passed
4958 -- Bug 3263140
4959 CURSOR cur_wgi_due
4960 IS
4961 SELECT  rei_information4 wgi_due
4962 FROM    ghr_pa_request_extra_info
4963 WHERE   pa_request_id = p_pa_request_rec.pa_request_id
4964 AND     information_type = 'GHR_US_PAR_SALARY_CHG';
4965 --
4966 -- Bug 3953455 Cursor to fetch the To step for both normal and correction actions.
4967 CURSOR cur_get_step(c_pa_request_id ghr_pa_requests.pa_request_id%type)
4968 IS
4969 SELECT par_orig.from_step_or_rate step1, par_corr.from_step_or_rate step2
4970 FROM ghr_pa_requests par_orig , ghr_pa_requests par_corr
4971 where par_orig.pa_request_id = par_corr.altered_pa_request_id
4972 and par_corr.pa_request_id = c_pa_request_id;
4973 
4974 l_orig_pa_from_step ghr_pa_requests.to_step_or_rate%type;
4975 l_corr_pa_from_step ghr_pa_requests.to_step_or_rate%type;
4976 l_call_wgi_dates BOOLEAN;
4977 
4978 -- End Bug 3953455
4979 
4980 -- -- Bug 4031919 Cursor to check if pay plan is eligible for WGI or not.
4981 l_is_wgi_eligible BOOLEAN;
4982 l_wgi_cleared BOOLEAN;
4983 l_to_pay_plan ghr_pa_requests.to_pay_plan%type;
4984 l_wgi_exists BOOLEAN;
4985 l_wgi_new_name VARCHAR2(250);
4986 
4987 CURSOR c_wgi_pay_plan(c_pay_plan ghr_pa_requests.to_pay_plan%TYPE)  IS
4988   SELECT 1
4989   FROM   ghr_pay_plans gpp
4990   WHERE  gpp.pay_plan         =  c_pay_plan
4991   AND    gpp.wgi_enabled_flag = 'Y';
4992 
4993 CURSOR c_get_pay_plan(c_pa_request_id ghr_pa_requests.pa_request_id%type) IS
4994 SELECT to_pay_plan
4995 FROM ghr_pa_requests par
4996 WHERE par.pa_request_id = c_pa_request_id;
4997 
4998 -----GPPA Update46 Start.
4999 cursor cur_eq_ppl (c_pay_plan ghr_pay_plans.pay_plan%type)
5000 IS
5001 select EQUIVALENT_PAY_PLAN
5002 from ghr_pay_plans
5003 where pay_plan = c_pay_plan;
5004 
5005 l_equ_pay_plan ghr_pay_plans.equivalent_pay_plaN%type;
5006 -----GPPA Update46 End.
5007 
5008 CURSOR c_check_ele(c_element_name pay_element_types_f.element_name%type,
5009 		   c_effective_date pay_element_entries_f.effective_start_date%type,
5010 		   c_assignment_id pay_element_entries_f.assignment_id%type) IS
5011 SELECT 1
5012 FROM pay_element_entries_f pee, pay_element_types_f pet
5013 WHERE pee.element_type_id = pet.element_type_id
5014 AND c_effective_date BETWEEN pee.effective_start_date AND pee.effective_end_date
5015 AND c_effective_date BETWEEN pet.effective_start_date AND pet.effective_end_date
5016 AND pet.element_name = c_element_name
5017 AND pee.assignment_id = c_assignment_id;
5018 
5019 --Pradeep start of Bug 3306515
5020 l_retention_allow_percentage    ghr_pa_requests.to_retention_allow_percentage%type;
5021 l_retention_allowance           ghr_pa_requests.to_retention_allowance%type;
5022 l_multi_error_flag              boolean;
5023 --Pradeep end of Bug 3306515
5024 
5025 Begin
5026 
5027 
5028     --
5029     hr_utility.set_location('Entering  ' ||l_proc,5);
5030     -- Remember IN OUT parameter IN values
5031     --
5032     l_wgi                      := p_wgi;
5033     l_retention_allow_review   := p_retention_allow_review;
5034     l_call_wgi_dates := FALSE;
5035     l_is_wgi_eligible := FALSE; -- Bug 4031919
5036     l_wgi_cleared := FALSE;-- Bug 4031919
5037     l_wgi_exists := FALSE;-- Bug 4031919
5038 
5039      --Pradeep start of Bug 3306515
5040      -- Get the session variables.
5041      ghr_history_api.get_g_session_var(l_session);
5042      --Pradeep end of Bug 3306515
5043 
5044 --
5045 -- Processing  Basic pay
5046 --
5047 -- Code added/ Modified for Payroll Integration
5048 --
5049 ----**********************************************************************
5050 --           CHECK # :- Existence of PAYROLL Product
5051 ----**********************************************************************
5052 IF (hr_utility.chk_product_install('GHR','US')  = TRUE
5053  and hr_utility.chk_product_install('PAY', 'US') = TRUE
5054  and fnd_profile.value('HR_USER_TYPE')='INT')
5055 THEN
5056 l_pay_intg:=TRUE;
5057 ELSE
5058 l_pay_intg:=FALSE;
5059 END IF;
5060 ----**********************************************************************
5061 --
5062    If p_pa_request_rec.first_noa_code = '866' then
5063      l_effective_date  :=   trunc(p_pa_request_rec.effective_date + 1 );
5064    Else
5065      l_effective_date  :=   trunc(p_pa_request_rec.effective_date);
5066    End if;
5067 -------Bug 5913362 -- Adding 890
5068 /**** Here for 890 date is not like 866.
5069    if p_pa_request_rec.first_noa_code = '890' AND
5070       p_pa_request_rec.input_pay_rate_determinant in ('A','B','E','F','U','V') then
5071      l_effective_date  :=   trunc(p_pa_request_rec.effective_date + 1 );
5072    Else
5073      l_effective_date  :=   trunc(p_pa_request_rec.effective_date);
5074    End if;
5075 *****/
5076    --
5077    -----Find out the Person system person type
5078    --
5079 
5080    FOR cur_ex_emp_rec IN cur_ex_emp (p_pa_request_rec.person_id, l_effective_date)
5081    LOOP
5082      l_ex_emp := TRUE;
5083      hr_utility.set_location('Person is an Ex employee for the given date  ' ||l_proc,5);
5084     END LOOP;
5085 
5086   hr_utility.set_location(to_char(l_effective_date),1);
5087 -- Processing  Basic pay
5088 --
5089   hr_utility.set_location('Entering  ' ||l_proc,5);
5090 
5091 -- pick business group id
5092           For BG_rec in Cur_BG(p_pa_request_rec.employee_assignment_id,
5093                                  l_effective_date)
5094           Loop
5095           l_bg_id:=BG_rec.bg;
5096           End Loop;
5097 --
5098 -- When to_basic_pay is not null
5099   If p_pa_request_rec.to_basic_pay  is not null then
5100       hr_utility.set_location(l_proc || to_char(p_pa_request_rec.effective_date),10);
5101 --
5102 -- Code added for Payroll Integration
5103 --
5104    IF l_pay_intg
5105    -- Only when GHR and Payroll are installed can the following be performed
5106    THEN
5107     -- Salary Basis Type can be Monthly,Annual,Hourly
5108         If (p_pa_request_rec.from_pay_basis is NULL and
5109                p_pa_request_rec.to_pay_basis is not NULL) then
5110            l_pay_basis:=p_pa_request_rec.to_pay_basis;
5111          elsif (p_pa_request_rec.from_pay_basis is NOT NULL and
5112              p_pa_request_rec.to_pay_basis is NULL) then
5113            l_pay_basis:=p_pa_request_rec.from_pay_basis;
5114          elsif (p_pa_request_rec.from_pay_basis is NOT NULL and
5115               p_pa_request_rec.to_pay_basis is NOT NULL) then
5116            l_pay_basis:=p_pa_request_rec.to_pay_basis;
5117          End If;
5118 
5119        -- Picking the new Basic Salary Rate Element
5120           l_new_element_name:=pqp_fedhr_uspay_int_utils.return_new_element_name(
5121                             p_fedhr_element_name => 'Basic Salary Rate',
5122                             p_business_group_id  => l_bg_id,
5123                             p_effective_date     => l_effective_date,
5124                             p_pay_basis          => NVL(l_pay_basis,'PA'));
5125 
5126            hr_utility.trace('The New Element Name is :'||l_new_element_name);
5127 
5128            --
5129         -- Update the Assignment id with the Salary Basis Obtained in above step
5130         -- If not for this step Salary Admin form wont pick the Basic Sal Value
5131         --
5132          hr_utility.trace('NOA FAMILY CODE :'||p_pa_request_rec.noa_family_code);
5133          -- Check# 1
5134          IF (p_pa_request_rec.first_noa_cancel_or_correct ='CORRECT') THEN
5135 
5136            -- Check# 2
5137            -- the following if condition is to avoid error of deleting salary proposal
5138            -- for correction actions not involving pay changes. Ex - realignment, Other pay etc
5139            IF ( nvl(p_pa_request_rec.to_basic_pay,0) <> nvl(p_pa_request_rec.from_basic_pay,0)
5140              OR nvl(p_pa_request_rec.from_pay_basis,'NPB') <> nvl(p_pa_request_rec.to_pay_basis,'NPB'))
5141            THEN
5142 
5143               For Proposal_rec IN Cur_proposal_exists
5144                (p_pa_request_rec.employee_assignment_id,l_effective_date)
5145               Loop
5146                 l_pay_proposal_id   := proposal_rec.proposal_id;
5147                 l_sal_admin_ovn     := proposal_rec.ovn;
5148               End Loop;
5149 
5150               hr_utility.trace('Before call to Delete Salary Proposal :'||l_dt_mode);
5151 --            if p_pa_request_rec.noa_family_code in ('APP','CONV_APP') then
5152               -- Check# 3
5153               IF (l_pay_proposal_id is not null ) THEN
5154 
5155                 hr_maintain_proposal_api.delete_salary_proposal
5156                   (
5157                   p_pay_proposal_id      => l_pay_proposal_id ,
5158                   p_business_group_id    => l_bg_id             ,
5159                   p_object_version_number => l_sal_admin_ovn            ,
5160                   p_validate              => FALSE            ,
5161                   p_salary_warning        => l_sal_warn
5162                   );
5163                 l_del_pay_prop :=TRUE;
5164               END IF;
5165              -- End of Check# 3
5166            END IF;
5167            -- End of Check# 2
5168          END IF;
5169          -- End of Check# 1
5170 
5171            -- Picking the Salary Basis based on the to_pay_basis during RPA
5172           For Sal_Basis_Name in Cur_Sal_Basis_name(l_bg_id,l_new_element_name)
5173           Loop
5174           l_sal_basis_id := Sal_Basis_Name.pay_basis_id;
5175           hr_utility.trace('The sal basis id is :'||to_char(l_sal_basis_id));
5176           End Loop;
5177          --
5178          --
5179          l_dt_mode := return_update_mode
5180                    (p_id                 => p_pa_request_rec.employee_assignment_id,
5181                     p_effective_date     => l_effective_date,
5182                     p_table_name         => 'PER_ASSIGNMENTS_F'
5183                    );
5184 
5185           hr_utility.trace('l_dt_mode is :'||l_dt_mode);
5186 
5187          -- collecting details for salary basis updation
5188          For SB_upd in Cur_asg_det_for_SB_upd(p_pa_request_rec.employee_assignment_id,
5189                                               l_effective_Date)
5190          Loop
5191          l_SB_ovn           := SB_upd.ovn;
5192          l_ppl_grp_id       := SB_upd.ppl_grp_id;
5193          l_spcl_clng_stp_id := SB_upd.spcl_clng_stp_id;
5194          l_scl_kff_id       := SB_upd.scl_kff_id;
5195          l_eff_start_date   := SB_upd.start_date;
5196          l_eff_end_date     := SB_upd.end_date;
5197          l_payroll_id       := SB_upd.payroll_id;
5198          End Loop;
5199 
5200         --
5201         -- Update the Assignment id with the Salary Basis Obtained in above step
5202         -- If not for this step Salary Admin form wont pick the Basic Sal Value
5203         hr_utility.trace('assignment id is :'||p_pa_request_rec.employee_assignment_id);
5204         hr_utility.trace('EFF DATE :'||l_effective_date);
5205         hr_utility.trace('l_sb_ovn:'||l_SB_ovn);
5206         hr_utility.trace('l_payroll_id:'||l_payroll_id);
5207         hr_utility.trace('l_sal_basis_id:'||l_sal_basis_id);
5208 
5209         hr_assignment_api.update_emp_asg_criteria
5210           (p_effective_date               => l_effective_date
5211           ,p_datetrack_update_mode        => l_dt_mode
5212           ,p_assignment_id                => p_pa_request_rec.employee_assignment_id
5213           ,p_object_version_number        => l_SB_ovn
5214           ,P_PAYROLL_ID                   => l_payroll_id
5215           ,p_pay_basis_id                 => l_sal_basis_id
5216           ,p_position_id                  => P_pa_request_rec.to_position_id
5217           ,p_job_id                       => P_pa_request_rec.to_job_id
5218           ,p_location_id                  => P_pa_request_rec.duty_station_location_id
5219           ,p_organization_id              => P_pa_request_rec.to_organization_id
5220           ,p_grade_id                     => P_pa_request_rec.to_grade_id
5221           ,p_effective_start_date         => l_eff_start_date
5222           ,p_effective_end_date           => l_eff_end_date
5223           ,p_special_ceiling_step_id      => l_spcl_clng_stp_id
5224           ,p_people_group_id              => l_ppl_grp_id
5225           ,p_group_name                   => l_group_name
5226           ,p_org_now_no_manager_warning   => l_org_now_man_warn
5227           ,p_other_manager_warning        => l_other_manager_warn
5228           ,p_spp_delete_warning           => l_spp_delete_warning
5229           ,p_entries_changed_warning      => l_entries_chan_warn
5230           ,p_tax_district_changed_warning => l_tax_dist_chan_warn
5231            );
5232           --
5233        hr_utility.trace('After Update Person record under gh52doup.pkb');
5234        --
5235 
5236       -- Blocking the call to use Core call for salary admin creation
5237         For Proposal_rec IN Cur_proposal_exists
5238              (p_pa_request_rec.employee_assignment_id,l_effective_date)
5239         Loop
5240         l_pay_proposal_id   := proposal_rec.proposal_id;
5241         l_sal_admin_ovn     := proposal_rec.ovn;
5242         End Loop;
5243 
5244 
5245          if ((p_pa_request_rec.noa_family_code <> 'APP')
5246            OR
5247           (p_pa_request_rec.noa_family_code = 'CONV_APP' and NOT l_ex_emp)) then
5248            ghr_element_api.retrieve_element_info
5249           (p_element_name          => 'Basic Salary Rate'
5250           ,p_input_value_name      => 'Rate'
5251           ,p_assignment_id         => p_pa_request_rec.employee_assignment_id
5252           ,p_effective_date        => l_effective_date
5253           ,p_processing_type       => 'R'
5254           ,p_element_link_id       => ll_element_link_id
5255           ,p_input_value_id        => ll_input_value_id
5256           ,p_element_entry_id      => ll_element_entry_id
5257           ,p_value                 => ll_value
5258           ,p_object_version_number => ll_object_version_number
5259           ,p_multiple_error_flag   => ll_multiple_error_flag
5260           );
5261         end if;
5262 
5263         hr_utility.trace('employee Asg id  before proposal ..:'||
5264                                     to_char(p_pa_request_rec.employee_assignment_id));
5265         hr_utility.trace('Element entry id before proposal ..:'||to_char(ll_element_entry_id));
5266         hr_utility.trace('Business grp  id before proposal ..:'||to_char(l_bg_id));
5267 
5268      IF l_pay_proposal_id is null then
5269         if (nvl(p_pa_request_rec.from_basic_pay, 0) <> nvl(p_pa_request_rec.to_basic_pay,0)) then
5270         hr_maintain_proposal_api.insert_salary_proposal
5271         (
5272          p_pay_proposal_id           => l_pay_proposal_id
5273         ,p_assignment_id             => p_pa_request_rec.employee_assignment_id
5274         ,p_business_group_id         => l_bg_id
5275         ,p_change_date               => l_effective_date
5276         ,p_proposed_salary_n         => p_pa_request_rec.to_basic_pay
5277         ,p_object_version_number     => l_sal_admin_ovn
5278         ,p_element_entry_id          => ll_element_entry_id
5279         ,p_inv_next_sal_date_warning => l_date_warn
5280         ,p_proposed_salary_warning   => l_sal_warn
5281         ,p_approved_warning          => l_approve_warn
5282         ,p_payroll_warning           => l_payroll_warn
5283         ,p_multiple_components       => 'N'
5284         ,p_approved                  => 'Y'
5285         );
5286         end if;
5287      ELSE
5288         if (nvl(p_pa_request_rec.from_basic_pay, 0) <> nvl(p_pa_request_rec.to_basic_pay,0)) then
5289         -- if the pay proposal is not deleted in the above step then delete, no otherwise
5290           if (not l_del_pay_prop) then
5291             hr_maintain_proposal_api.delete_salary_proposal(
5292                                  p_pay_proposal_id       =>  l_pay_proposal_id
5293                                 ,p_business_group_id     =>  l_bg_id
5294                                 ,p_object_version_number =>  l_sal_admin_ovn
5295                                 ,p_validate              =>  FALSE
5296                                 ,p_salary_warning        =>  l_sal_warn);
5297            end if;
5298         hr_maintain_proposal_api.insert_salary_proposal
5299         (
5300          p_pay_proposal_id           => l_pay_proposal_id
5301         ,p_assignment_id             => p_pa_request_rec.employee_assignment_id
5302         ,p_business_group_id         => l_bg_id
5303         ,p_change_date               => l_effective_date
5304         ,p_proposed_salary_n         => p_pa_request_rec.to_basic_pay
5305         ,p_object_version_number     => l_sal_admin_ovn
5306         ,p_element_entry_id          => ll_element_entry_id
5307         ,p_inv_next_sal_date_warning => l_date_warn
5308         ,p_proposed_salary_warning   => l_sal_warn
5309         ,p_approved_warning          => l_approve_warn
5310         ,p_payroll_warning           => l_payroll_warn
5311         ,p_multiple_components       => 'N'
5312         ,p_approved                  => 'Y'
5313         );
5314 
5315        end if;
5316 
5317       END IF;
5318    -- if Payroll is not installed
5319    ELSIF NOT l_pay_intg
5320    THEN
5321      ghr_element_api.process_sf52_element
5322         (p_assignment_id        =>      p_pa_request_rec.employee_assignment_id
5323         ,p_element_name         =>      'Basic Salary Rate'
5324         ,p_input_value_name1    =>      'Rate'
5325         ,p_value1               =>      to_char(p_pa_request_rec.to_basic_pay)
5326         ,p_effective_date       =>    l_effective_date
5327         ,p_process_warning      =>      l_adj_basic_pay_warn
5328       );
5329    END IF;
5330   -- if Payroll integration not being used.
5331 --
5332 -- Code added/ Modified for Payroll Integration
5333 --
5334 
5335   /* To be included after Martin Reid's element api handles the create and update warning
5336    if l_adj_basic_pay_warn = FALSE then
5337       hr_utility.set_message(8301,'GHR_38136_FAIL_TO_UPD_SALARY');
5338       hr_utility.raise_error;
5339    end if;
5340    */
5341  end if;
5342 --
5343 --
5344 -- Processing  Adjusted basic pay
5345 --
5346 If p_pa_request_rec.to_adj_basic_pay  is not null then
5347     hr_utility.set_location(l_proc,20);
5348 
5349     ghr_element_api.process_sf52_element
5350         (p_assignment_id        =>      p_pa_request_rec.employee_assignment_id
5351         ,p_element_name         =>      'Adjusted Basic Pay'
5352         ,p_input_value_name1    =>      'Amount'
5353         ,p_value1               =>      to_char(p_pa_request_rec.to_adj_basic_pay)
5354         ,p_effective_date       =>      l_effective_date
5355         ,p_process_warning      =>      l_basic_pay_warn
5356       );
5357 --
5358 --
5359 
5360 /*if l_adj_basic_pay_warn = FALSE then
5361      hr_utility.set_message(8301,'GHR_38137_FL_TO_UPD_ADJ_BS_PY');
5362      hr_utility.raise_error;
5363    end if;
5364 */
5365 end if;
5366 --
5367 -- Bug 2333719 GM IT pay calculations. Pay calc will set a global variable for
5368 --             Unadjusted Basic Pay.
5369 --
5370 -- Processing  Unadjusted Basic Pay
5371 --
5372 If p_pa_request_rec.to_adj_basic_pay  is not null then
5373    if ghr_pay_calc.g_gm_unadjd_basic_pay is not null and ghr_pay_calc.g_gm_unadjd_basic_pay <> 0 then
5374     hr_utility.set_location(l_proc,21);
5375 
5376     ghr_element_api.process_sf52_element
5377         (p_assignment_id        =>      p_pa_request_rec.employee_assignment_id
5378         ,p_element_name         =>      'Unadjusted Basic Pay'
5379         ,p_input_value_name1    =>      'Amount'
5380         ,p_value1               =>      to_char(ghr_pay_calc.g_gm_unadjd_basic_pay)
5381         ,p_effective_date       =>      l_effective_date
5382         ,p_process_warning      =>      l_basic_pay_warn
5383       );
5384    end if;
5385 --
5386 --
5387 end if;
5388 --
5389 -- Bug 2333719 GM IT Code End.
5390 --
5391 -- Processing  Locality adjustment
5392 --
5393 If p_pa_request_rec.to_locality_adj is not null then
5394    hr_utility.set_location(l_proc,30);
5395    -- FWFA Changes Bug#4444609: Modify 'Locality Pay' to 'Locality Pay or SR Supplement'
5396    ghr_element_api.process_sf52_element
5397    (p_assignment_id     =>      p_pa_request_rec.employee_assignment_id
5398    ,p_element_name      =>      'Locality Pay or SR Supplement'
5399    ,p_input_value_name1 =>      'Rate'
5400 -- 'Rate' was put by Ashu Gupta in place of 'Amount'
5401    ,p_value1          =>        to_char(p_pa_request_rec.to_locality_adj)
5402    ,p_effective_date    =>      l_effective_date
5403    ,p_process_warning   =>      l_locality_adj_warn
5404     );
5405     -- FWFA Changes
5406 End if;
5407 
5408 --
5409 
5410 /*if l_locality_adj_warn  = FALSE then
5411     hr_utility.set_message(8301,'GHR_38138_FAIL_TO_UPD_LOC_ADJ');
5412     hr_utility.raise_error;
5413   end if;
5414 */
5415 --end if;
5416 --
5417 
5418 --
5419 -- Processing  Total Salary
5420 --
5421 If p_pa_request_rec.to_total_salary is not null then
5422    -- Bug#4486823 RRR Changes. Added the IF Condition to Restrict the element updation
5423    -- for GHR_INCENTIVE Family.
5424    IF p_pa_request_rec.first_noa_code IN ('815','816','825','827') OR
5425       p_pa_request_rec.second_noa_code IN ('815','816','825','827')  THEN
5426       NULL;
5427    ELSE
5428      hr_utility.set_location(l_proc,45);
5429     ghr_element_api.process_sf52_element
5430     (p_assignment_id     =>     p_pa_request_rec.employee_assignment_id
5431     ,p_element_name      =>   'Total Pay'
5432     ,p_input_value_name1 =>     'Amount'
5433     ,p_value1            =>     to_char(p_pa_request_rec.to_total_salary)
5434     ,p_effective_date    =>     l_effective_date
5435     ,p_process_warning   =>     l_total_salary_warn
5436     );
5437    END IF;
5438  --
5439 /*  if l_total_salary_warn = FALSE then
5440     hr_utility.set_message(8301,'GHR_38139_FAIL_TO_UPD_TOT_SAL');
5441     hr_utility.raise_error;
5442   end if;
5443 */
5444 end if;
5445 --
5446 --  Processing Other Pay
5447 
5448 --If p_pa_request_rec.noa_family_code  = 'OTHER_PAY' then
5449 
5450   If p_pa_request_rec.to_other_pay_amount  is not null then
5451     -- Code to calculate Entitled Other Pay for Pay capped actions
5452     l_entitled_other_pay := p_pa_request_rec.to_other_pay_amount;
5453     IF p_capped_other_pay is not null THEN
5454                 l_entitled_other_pay := nvl(p_pa_request_rec.to_au_overtime, 0) +
5455                         nvl(p_pa_request_rec.to_availability_pay        , 0) +
5456                         nvl(p_pa_request_rec.to_retention_allowance     , 0) +
5457                         nvl(p_pa_request_rec.to_supervisory_differential, 0) +
5458                         nvl(p_pa_request_rec.to_staffing_differential   , 0);
5459     END IF;
5460     hr_utility.set_location(l_proc,55);
5461     ghr_element_api.process_sf52_element
5462    (p_assignment_id     =>      p_pa_request_rec.employee_assignment_id
5463    ,p_element_name      =>      'Other Pay'
5464    ,p_input_value_name1 =>      'Amount'
5465    ,p_value1          =>        to_char(l_entitled_other_pay)
5466    ,p_input_value_name2 =>      'Capped Other Pay'
5467    ,p_value2          =>        to_char(p_capped_other_pay)
5468    ,p_effective_date    =>    l_effective_date
5469    ,p_process_warning   =>      l_adj_basic_pay_warn
5470     );
5471   Else  --if p_pa_request_rec.other_pay_amount is null
5472      -- According to John, any other pay and its sub elements can be nullified only by processing an 'OTHER_PAY' action
5473     If p_pa_request_rec.noa_family_code = 'OTHER_PAY' then
5474       hr_utility.set_location(l_proc,32);
5475 
5476       l_new_element_name := pqp_fedhr_uspay_int_utils.return_new_element_name(
5477                   p_fedhr_element_name => 'Other Pay',
5478                   p_business_group_id  => l_bg_id,
5479                   p_effective_date     => p_pa_request_rec.effective_date,
5480                   p_pay_basis          => NULL);
5481 
5482       l_element_entry_id := NULL;
5483       for ele_entry in  c_ele_entry(ele_name      => l_new_element_name,
5484                                     ipv_name      => 'Amount',
5485                                     eff_date      =>  l_effective_date,
5486                                     bg_id         =>  l_bg_id
5487                                     ) loop
5488 
5489         l_element_entry_id := ele_entry.element_entry_id;
5490       End loop;
5491       If l_element_entry_id is not null then
5492         ghr_element_api.process_sf52_element
5493        (p_assignment_id         =>      p_pa_request_rec.employee_assignment_id
5494        ,p_element_name        =>        'Other Pay'
5495        ,p_input_value_name1     =>      'Amount'
5496        ,p_value1                    =>  to_char(p_pa_request_rec.to_other_pay_amount)
5497        ,p_effective_date        =>    l_effective_date
5498        ,p_process_warning       =>      l_adj_basic_pay_warn
5499        );
5500       End if;
5501     End if;
5502   End if;
5503 
5504 
5505 --  Processing  AUO
5506 
5507  If p_pa_request_rec.to_auo_premium_pay_indicator  is not null or
5508     p_pa_request_rec.to_au_overtime               is not null  then
5509    hr_utility.set_location(l_proc,60);
5510    ghr_element_api.process_sf52_element
5511    (p_assignment_id     =>      p_pa_request_rec.employee_assignment_id
5512    ,p_element_name      =>      'AUO'
5513    ,p_input_value_name1 =>      'Premium Pay Ind'
5514    ,p_value1          =>    p_pa_request_rec.to_auo_premium_pay_indicator
5515    ,p_input_value_name2 =>    'Amount'
5516    ,p_value2            =>    to_char(p_pa_request_rec.to_au_overtime)
5517    ,p_effective_date    =>    l_effective_date
5518    ,p_process_warning   =>      l_adj_basic_pay_warn
5519    );
5520 
5521    ghr_element_api.process_sf52_element
5522    (p_assignment_id     =>      p_pa_request_rec.employee_assignment_id
5523    ,p_element_name      =>     'Premium Pay'
5524    ,p_input_value_name1 =>      'Premium Pay Ind'
5525    ,p_value1          =>    p_pa_request_rec.to_auo_premium_pay_indicator
5526    ,p_input_value_name2 =>    'Amount'
5527    ,p_value2            =>    to_char(p_pa_request_rec.to_au_overtime)
5528    ,p_effective_date    =>    l_effective_date
5529    ,p_process_warning   =>      l_adj_basic_pay_warn
5530    );
5531  Else  --if p_pa_request_rec.auo is null
5532 
5533    If p_pa_request_rec.first_noa_code = '818' then
5534      hr_utility.set_location(l_proc,32);
5535      l_element_entry_id := NULL;
5536 
5537      l_new_element_name :=
5538          pqp_fedhr_uspay_int_utils.return_new_element_name(
5539                     p_fedhr_element_name => 'AUO',
5540                     p_business_group_id  => l_bg_id,
5541                     p_effective_date     => p_pa_request_rec.effective_date,
5542                     p_pay_basis          => NULL);
5543 
5544      for ele_entry in  c_ele_entry(ele_name      => l_new_element_name,
5545                                    ipv_name      => 'Amount',
5546                                    eff_date      =>  l_effective_date,
5547                                    bg_id         =>  l_bg_id
5548                                    ) loop
5549 
5550        l_element_entry_id := ele_entry.element_entry_id;
5551      End loop;
5552      if l_element_entry_id is not null then
5553         ghr_element_api.process_sf52_element
5554        (p_assignment_id         =>      p_pa_request_rec.employee_assignment_id
5555        ,p_element_name        =>        'AUO'
5556        ,p_input_value_name1     =>      'Premium Pay Ind'
5557        ,p_value1                    =>    p_pa_request_rec.to_auo_premium_pay_indicator
5558        ,p_input_value_name2   =>    'Amount'
5559        ,p_value2              =>    to_char(p_pa_request_rec.to_au_overtime)
5560        ,p_effective_date        =>    l_effective_date
5561        ,p_process_warning       =>      l_adj_basic_pay_warn
5562        );
5563 
5564       ghr_element_api.process_sf52_element
5565       (p_assignment_id          =>      p_pa_request_rec.employee_assignment_id
5566       ,p_element_name         =>        'Premium Pay'
5567       ,p_input_value_name1      =>      'Premium Pay Ind'
5568       ,p_value1             =>    p_pa_request_rec.to_auo_premium_pay_indicator
5569       ,p_input_value_name2    =>    'Amount'
5570       ,p_value2               =>    to_char(p_pa_request_rec.to_au_overtime)
5571       ,p_effective_date         =>    l_effective_date
5572       ,p_process_warning        =>      l_adj_basic_pay_warn
5573       );
5574      End if;
5575    End if;
5576  End if;
5577 
5578 -- Processing Availability pay
5579 
5580 -- Note : The sequences of the Inp. Values 1 and 2 for the element, 'Availability Pay' has
5581 --  been swapped. According to Jon's list in new changes after September:
5582 -- Can change only when the seed data changes.
5583 
5584 If p_pa_request_rec.to_ap_premium_pay_indicator  is not null or
5585    p_pa_request_rec.to_availability_pay         is not null  then
5586    hr_utility.set_location(l_proc,65);
5587    ghr_element_api.process_sf52_element
5588    (p_assignment_id     =>      p_pa_request_rec.employee_assignment_id
5589    ,p_element_name      =>      'Availability Pay'
5590    ,p_input_value_name1 =>      'Premium Pay Ind'
5591    ,p_value1          =>    p_pa_request_rec.to_ap_premium_pay_indicator
5592    ,p_input_value_name2 =>    'Amount'
5593    ,p_value2            =>    to_char(p_pa_request_rec.to_availability_pay)
5594    ,p_effective_date    =>    l_effective_date
5595    ,p_process_warning   =>      l_adj_basic_pay_warn
5596    );
5597 
5598    ghr_element_api.process_sf52_element
5599    (p_assignment_id     =>      p_pa_request_rec.employee_assignment_id
5600    ,p_element_name      =>      'Premium Pay'
5601    ,p_input_value_name1 =>    'Premium Pay Ind'
5602    ,p_value1            =>    p_pa_request_rec.to_ap_premium_pay_indicator
5603    ,p_input_value_name2 =>      'Amount'
5604    ,p_value2          =>    to_char(p_pa_request_rec.to_availability_pay)
5605    ,p_effective_date    =>    l_effective_date
5606    ,p_process_warning   =>      l_adj_basic_pay_warn
5607    );
5608  Else  --if p_pa_request_rec.avaiability_pay is null
5609    If p_pa_request_rec.first_noa_code = '819' then
5610      hr_utility.set_location(l_proc,32);
5611      l_element_entry_id := NULL;
5612 
5613      l_new_element_name :=
5614           pqp_fedhr_uspay_int_utils.return_new_element_name(
5615                 p_fedhr_element_name => 'Availability Pay',
5616                 p_business_group_id  => l_bg_id,
5617                 p_effective_date     => p_pa_request_rec.effective_date,
5618                 p_pay_basis          => NULL);
5619 
5620 
5621      for ele_entry in  c_ele_entry(ele_name      => l_new_element_name,
5622                                    ipv_name      => 'Amount',
5623                                    eff_date      =>  l_effective_date,
5624                                    bg_id         =>  l_bg_id
5625                                   ) loop
5626 
5627        l_element_entry_id := ele_entry.element_entry_id;
5628      End loop;
5629      if l_element_entry_id is not null then
5630        hr_utility.set_location(l_proc,33);
5631        ghr_element_api.process_sf52_element
5632       (p_assignment_id          =>      p_pa_request_rec.employee_assignment_id
5633       ,p_element_name         =>        'Availability Pay'
5634       ,p_input_value_name1  =>  'Premium Pay Ind'
5635       ,p_value1             =>    p_pa_request_rec.to_ap_premium_pay_indicator
5636       ,p_input_value_name2  =>  'Amount'
5637       ,p_value2             =>  to_char(p_pa_request_rec.to_availability_pay)
5638       ,p_effective_date     =>    l_effective_date
5639       ,p_process_warning    =>  l_adj_basic_pay_warn
5640       );
5641 
5642        ghr_element_api.process_sf52_element
5643        (p_assignment_id         =>      p_pa_request_rec.employee_assignment_id
5644        ,p_element_name        =>        'Premium Pay'
5645        ,p_input_value_name1     =>      'Premium Pay Ind'
5646          ,p_value1                  =>    p_pa_request_rec.to_ap_premium_pay_indicator
5647          ,p_input_value_name2   =>    'Amount'
5648          ,p_value2              =>    to_char(p_pa_request_rec.to_availability_pay)
5649        ,p_effective_date        =>    l_effective_date
5650          ,p_process_warning     =>      l_adj_basic_pay_warn
5651        );
5652      End if;
5653    End if;
5654  End if;
5655 
5656 -- Processing Supervisory Differential
5657 --
5658 -- Code added/ Modified for Payroll Integration
5659 -- Modifying the input value name from Percent to Percentage
5660 -- this change is done only for Supervisory diff and Retention Allowance
5661 --
5662 
5663 hr_utility.trace('Element Name (new) is :'||l_new_element_name);
5664 hr_utility.trace('Supv Diff Amt process_sf52 :'||p_pa_request_rec.to_supervisory_differential);
5665 hr_utility.trace('Supv Diff % Process_sf52 :'||p_pa_request_rec.to_supervisory_diff_percentage);
5666 
5667  If p_pa_request_rec.to_supervisory_differential is not null or
5668     p_pa_request_rec.to_supervisory_diff_percentage is not null then
5669     hr_utility.set_location(l_proc,70);
5670     ghr_element_api.process_sf52_element
5671     (p_assignment_id     =>     p_pa_request_rec.employee_assignment_id
5672     ,p_element_name      =>     'Supervisory Differential'
5673     ,p_input_value_name1 =>     'Amount'
5674     ,p_value1          =>       to_char(p_pa_request_rec.to_supervisory_differential)
5675     ,p_input_value_name2 =>     'Percentage'
5676     ,p_value2          =>       to_char(p_pa_request_rec.to_supervisory_diff_percentage)
5677     ,p_effective_date    =>    l_effective_date
5678     ,p_process_warning   =>     l_adj_basic_pay_warn
5679     );
5680 
5681  Else  --if p_pa_request_rec.superv. diff is null
5682     If p_pa_request_rec.noa_family_code = 'OTHER_PAY' then
5683       hr_utility.set_location(l_proc,32);
5684       l_element_entry_id := NULL;
5685       l_new_element_name :=
5686               pqp_fedhr_uspay_int_utils.return_new_element_name(
5687              p_fedhr_element_name => 'Supervisory Differential',
5688              p_business_group_id  => l_bg_id,
5689              p_effective_date     => p_pa_request_rec.effective_date,
5690              p_pay_basis          => NULL);
5691 
5692       for ele_entry in  c_ele_entry(
5693                                     ele_name      => l_new_element_name,
5694                                     ipv_name      => 'Amount',
5695                                     eff_date      =>  l_effective_date,
5696                                     bg_id         =>  l_bg_id
5697                                     ) loop
5698 
5699         l_element_entry_id := ele_entry.element_entry_id;
5700       End loop;
5701       If l_element_entry_id is not null then
5702         ghr_element_api.process_sf52_element
5703        (p_assignment_id         =>      p_pa_request_rec.employee_assignment_id
5704        ,p_element_name        =>        'Supervisory Differential'
5705        ,p_input_value_name1     =>      'Amount'
5706        ,p_value1                    =>  to_char(p_pa_request_rec.to_supervisory_differential)
5707        ,p_input_value_name2   =>        'Percentage'
5708        ,p_value2                    =>  to_char(p_pa_request_rec.to_supervisory_diff_percentage)
5709        ,p_effective_date        =>    l_effective_date
5710        ,p_process_warning       =>      l_adj_basic_pay_warn
5711        );
5712       End if;
5713    End if;
5714  End if;
5715 --
5716 -- Code added/ Modified for Payroll Integration
5717 -- Modifying the input value name from Percent to Percentage
5718 -- this change is done only for Supervisory diff and Retention Allowance
5719 --
5720 ------------------------------------------------------------------------------
5721 /************* Commenting the Staffing Differetial code... 05-AUG-2003 by AVR.
5722 --Processing Staffing Differential
5723 
5724 If p_pa_request_rec.to_staffing_differential is not null or
5725    p_pa_request_rec.to_staffing_diff_percentage is not null then
5726 
5727    hr_utility.set_location(l_proc,75);
5728    ghr_element_api.process_sf52_element
5729    (p_assignment_id     =>      p_pa_request_rec.employee_assignment_id
5730    ,p_element_name      =>      'Staffing Differential'
5731    ,p_input_value_name1 =>      'Amount'
5732    ,p_value1          =>        to_char(p_pa_request_rec.to_staffing_differential)
5733    ,p_input_value_name2 =>      'Percent'
5734    ,p_value2          =>        to_char(p_pa_request_rec.to_staffing_diff_percentage)
5735    ,p_effective_date    =>    l_effective_date
5736    ,p_process_warning   =>      l_adj_basic_pay_warn
5737    );
5738 Else  --if p_pa_request_rec.staff. diff is null
5739     If p_pa_request_rec.noa_family_code = 'OTHER_PAY' then
5740       hr_utility.set_location(l_proc,32);
5741       l_element_entry_id := NULL;
5742       l_new_element_name :=
5743                  pqp_fedhr_uspay_int_utils.return_new_element_name(
5744                       p_fedhr_element_name => 'Staffing Differential',
5745                       p_business_group_id  => l_bg_id,
5746                       p_effective_date     => p_pa_request_rec.effective_date,
5747                       p_pay_basis          => NULL);
5748 
5749       for ele_entry in  c_ele_entry(ele_name      =>  l_new_element_name,
5750                                     ipv_name      => 'Amount',
5751                                     eff_date      =>  l_effective_date,
5752                                      bg_id         =>  l_bg_id
5753                                     ) loop
5754 
5755         l_element_entry_id := ele_entry.element_entry_id;
5756       End loop;
5757       If l_element_entry_id is not null then
5758         ghr_element_api.process_sf52_element
5759        (p_assignment_id         =>      p_pa_request_rec.employee_assignment_id
5760        ,p_element_name        =>        'Staffing Differential'
5761        ,p_input_value_name1     =>      'Amount'
5762        ,p_value1                    =>  to_char(p_pa_request_rec.to_staffing_differential)
5763        ,p_input_value_name2     =>      'Percent'
5764        ,p_value2                    =>  to_char(p_pa_request_rec.to_staffing_diff_percentage)
5765        ,p_effective_date        =>    l_effective_date
5766        ,p_process_warning       =>      l_adj_basic_pay_warn
5767        );
5768       End if;
5769    End if;
5770 End if;
5771 ***********************/
5772 
5773 
5774 -- Processing retention Allowance
5775 --
5776 -- Code added/ Modified for Payroll Integration
5777 -- Modifying the input value name from Percent to Percentage
5778 -- this change is done only for Supervisory diff and Retention Allowance
5779 --
5780 hr_utility.trace('Element Name (new) is :'||l_new_element_name);
5781 hr_utility.trace('Ret Allw Amt process_sf52 :'||p_pa_request_rec.to_retention_allowance);
5782 hr_utility.trace('Ret Allw % Process_sf52 :'||p_pa_request_rec.to_retention_allow_percentage);
5783 
5784 
5785 --Pradeep start of Bug 3306515 - Ret All % Pay Cap.
5786 --Get the Retention Allowance and calculate % based on the Percentage.
5787 hr_utility.trace('Pradeep p_pa_request_rec.noa_family_code:'||p_pa_request_rec.noa_family_code);
5788 
5789 IF  p_pa_request_rec.to_retention_allow_percentage is null
5790   AND p_pa_request_rec.to_retention_allowance is not null THEN
5791 
5792 	-- Bug 4689374
5793 	IF p_pa_request_rec.pay_rate_determinant IN ('3','4','J','K','U','V') AND
5794 		p_pa_request_rec.effective_date >= to_date('01/05/2005','dd/mm/yyyy') THEN
5795 			l_retention_allow_percentage := NULL;
5796 			hr_utility.trace('Inside fwfa');
5797 	ELSE
5798 		IF ( p_pa_request_rec.noa_family_code like 'GHR_SAL%'
5799 		 OR p_pa_request_rec.noa_family_code ='OTHER_PAY' )
5800 		 THEN
5801 
5802 			 hr_utility.trace('Pradeep l_session.noa_id_correct:'||l_session.noa_id_correct);
5803 			 IF l_session.noa_id_correct is null THEN
5804 
5805 			  ghr_api.retrieve_element_entry_value (p_element_name    =>  'Retention Allowance'
5806 						   ,p_input_value_name      => 'Amount'
5807 						   ,p_assignment_id         =>  p_pa_request_rec.employee_assignment_id
5808 						   ,p_effective_date        => l_effective_date
5809 						   ,p_value                 => l_retention_allowance
5810 						   ,p_multiple_error_flag   => l_multi_error_flag);
5811 
5812 				l_retention_allow_percentage :=
5813 				   trunc((l_retention_allowance/p_pa_request_rec.from_basic_pay)*100,2);
5814 			 ELSE
5815 
5816 			--Get the  To side Retention Allowance for corrections.
5817 				hr_utility.trace('Pradeep Correction RA Amount:'||p_pa_request_rec.to_retention_allowance);
5818 				l_retention_allow_percentage :=
5819 				   trunc((p_pa_request_rec.to_retention_allowance/p_pa_request_rec.to_basic_pay)*100,2);
5820 			 END IF; -- IF l_session.noa_id_corr
5821 		END IF;-- IF ( p_pa_request_rec.noa_f
5822     END IF; -- IF p_pa_request_rec.pay_rate_determinant IN ('3','4',
5823 
5824 END IF;
5825 --Pradeep End of Bug 3306515 - Ret All % Pay Cap.
5826 
5827 If p_pa_request_rec.to_retention_allowance is not null or
5828    p_pa_request_rec.to_retention_allow_percentage is not null then
5829 
5830 -- Bug 2627003
5831  IF p_pa_request_rec.to_retention_allowance=0 THEN
5832     p_retention_allow_review.review_date:=NULL;
5833  END IF;
5834 -- Bug 2627003
5835 
5836    hr_utility.set_location(l_proc,80);
5837    ghr_element_api.process_sf52_element
5838    (p_assignment_id     =>      p_pa_request_rec.employee_assignment_id
5839    ,p_element_name      =>      'Retention Allowance'
5840    ,p_input_value_name1 =>      'Amount'
5841    ,p_value1          =>        to_char(p_pa_request_rec.to_retention_allowance)
5842    ,p_input_value_name2 =>      'Percentage'
5843    --3306515 added l_retention_allow_percentage
5844    ,p_value2          =>        to_char(nvl(p_pa_request_rec.to_retention_allow_percentage,l_retention_allow_percentage))
5845 
5846    ,p_input_value_name3 =>      'Date'
5847    ,p_value3          =>        fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_retention_allow_review.review_date))
5848    ,p_effective_date    =>    l_effective_date
5849    ,p_process_warning   =>      l_adj_basic_pay_warn
5850    );
5851 Else  --if p_pa_request_rec.ret. allowance is null
5852     If p_pa_request_rec.noa_family_code = 'OTHER_PAY' then
5853       hr_utility.set_location(l_proc,32);
5854       l_element_entry_id := NULL;
5855 
5856       l_new_element_name :=
5857           pqp_fedhr_uspay_int_utils.return_new_element_name(
5858                 p_fedhr_element_name => 'Retention Allowance',
5859                 p_business_group_id  => l_bg_id,
5860                 p_effective_date     => p_pa_request_rec.effective_date,
5861                 p_pay_basis          => NULL);
5862 
5863       for ele_entry in  c_ele_entry(ele_name      => l_new_element_name,
5864                                     ipv_name      => 'Amount',
5865                                     eff_date      =>  l_effective_date,
5866                                      bg_id         =>  l_bg_id
5867                                     ) loop
5868 
5869          l_element_entry_id := ele_entry.element_entry_id;
5870       End loop;
5871 
5872       If l_element_entry_id is not null then
5873 
5874 -- Bug 2627003
5875 	IF p_pa_request_rec.to_retention_allowance IS NULL THEN
5876            p_retention_allow_review.review_date:=NULL;
5877         END IF;
5878 -- Bug 2627003 Adding inp val date for processing
5879 
5880 	ghr_element_api.process_sf52_element
5881        (p_assignment_id         =>      p_pa_request_rec.employee_assignment_id
5882        ,p_element_name        =>      'Retention Allowance'
5883        ,p_input_value_name1     =>      'Amount'
5884        ,p_value1                    =>  to_char(p_pa_request_rec.to_retention_allowance)
5885        ,p_input_value_name2     =>      'Percentage'
5886        ,p_value2              =>        to_char(p_pa_request_rec.to_retention_allow_percentage)
5887        ,p_input_value_name3     =>      'Date'
5888        ,p_value3              =>     fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_retention_allow_review.review_date))
5889        ,p_effective_date        =>    l_effective_date
5890        ,p_process_warning       =>      l_adj_basic_pay_warn
5891        );
5892       End if;
5893    End if;
5894 End if;
5895 --
5896 -- Code added/ Modified for Payroll Integration
5897 -- Modifying the input value name from Percent to Percentage
5898 -- this change is done only for Supervisory diff and Retention Allowance
5899 --
5900 ---------------------------------------------------------------------------------------------
5901 -- Processing  Within Grade Increase
5902 --
5903 l_wgi_due_date := null;
5904 ---- Bug 3263140
5905 -- No need for this cursor as the values are properly passed.
5906 -- Instead of the cursor the below written statement is enough
5907 /*FOR ctr_wgi_due IN cur_wgi_due LOOP
5908    l_wgi_due_date := fnd_date.canonical_to_date(ctr_wgi_due.wgi_due);
5909 END LOOP; */
5910 
5911    l_wgi_due_date := fnd_date.canonical_to_date(p_wgi.p_date_wgi_due);
5912 
5913    hr_utility.set_location('WGI Due date ' || l_wgi_due_date,150);
5914    hr_utility.set_location('p_pa_request_rec.noa_family_code ' || p_pa_request_rec.noa_family_code,150);
5915      -- GPPA 46 Update. l_to_pay_plan is not getting initialized. So, added the
5916      -- following code to initialize the l_to_pay_plan value.
5917 
5918     g_retained_grade_info := null;
5919     --BUG # 6628794 Added to update to pay plan with pa request pay plan before updating with
5920      -- retained grade pay plan if temp step is null
5921     l_to_pay_plan := p_pa_request_rec.to_pay_plan;
5922     IF p_pa_request_rec.pay_rate_determinant in ('A','B','E','F','U','V') THEN
5923 	    l_retained_grade_rec :=  ghr_pc_basic_pay.get_retained_grade_details
5924                               (p_person_id       =>   p_pa_request_rec.person_id,
5925                                p_effective_date  =>   p_pa_request_rec.effective_date,
5926                                p_pa_request_id   =>   p_pa_request_rec.pa_request_id
5927                               );
5928         hr_utility.set_location('l_retained_pay_plan:'||l_retained_grade_rec.pay_plan,155);
5929 	--BUG # 6628749
5930 	IF l_retained_grade_rec.temp_step is NULL THEN
5931              l_to_pay_plan := l_retained_grade_rec.pay_plan;
5932         END IF;
5933 
5934             g_retained_grade_info := l_retained_grade_rec;
5935     END IF;
5936     --BUG # 6628749 as already defaulted with pa request rec to_pay_plan above
5937     -- commented the below code
5938   /*  IF l_retained_grade_rec.temp_step is NULL THEN
5939         l_to_pay_plan := l_retained_grade_rec.pay_plan;
5940     ELSE
5941         l_to_pay_plan := p_pa_request_rec.to_pay_plan;
5942     END IF;*/
5943     hr_utility.set_location('l_to_pay_plan:'||l_to_pay_plan,156);
5944    FOR cur_eq_ppl_rec IN cur_eq_ppl(l_to_pay_plan)
5945    LOOP
5946           l_equ_pay_plan   := cur_eq_ppl_rec.EQUIVALENT_PAY_PLAN;
5947           exit;
5948    END LOOP;
5949    hr_utility.set_location('l_equ_pay_plan:'||l_equ_pay_plan,157);
5950 ------GPPA Update 46 changes - For SES employees WGI element should not be created for 891, 892 , 890 and 897 NOACs.
5951 -- OR condition for Pay Plan FE is added as FE is nomore ES equ pay plan
5952 IF NOT ((l_equ_pay_plan = 'ES' OR l_to_pay_plan='FE')
5953         AND p_pa_request_rec.first_noa_code IN ('891', '892', '890', '897')) THEN
5954 
5955   IF  nvl(p_pa_request_rec.noa_family_code,hr_api.g_varchar2) IN
5956          ('APP',
5957           'APP_TRANSFER',
5958           'RETURN_TO_DUTY',
5959           'CHG_WORK_SCHED',
5960           'CHG_HOURS',
5961           'CHG_SCD',
5962           'DENIAL_WGI',
5963           'CONV_APP')
5964      OR
5965      (
5966         nvl(p_pa_request_rec.noa_family_code,hr_api.g_varchar2) LIKE 'GHR_SAL%' AND
5967         nvl(p_pa_request_rec.first_noa_code,hr_api.g_varchar2) NOT IN ('894','895','850')
5968      ) THEN
5969 
5970        IF nvl(p_pa_request_rec.noa_family_code,hr_api.g_varchar2) IN
5971           ('APP',
5972            'APP_TRANSFER',
5973            'RETURN_TO_DUTY',
5974            'CHG_WORK_SCHED',
5975            'CHG_HOURS',
5976            'CHG_SCD',
5977            'DENIAL_WGI',
5978 	   'CONV_APP') THEN
5979 	 -- Bug 4031919 If Conversion to appointment and we're moving from WGI to Non-WGI position
5980 	 -- End date the WGI element
5981 	  IF nvl(p_pa_request_rec.noa_family_code,hr_api.g_varchar2) = 'CONV_APP' THEN
5982 		-- If Correction action, then take pay plan from Original action
5983 		IF l_session.noa_id_correct IS NOT NULL AND p_pa_request_rec.to_pay_plan IS NULL THEN
5984 			FOR l_get_pay_plan IN c_get_pay_plan(p_pa_request_rec.altered_pa_request_id) LOOP
5985 				l_to_pay_plan := l_get_pay_plan.to_pay_plan;
5986 			END LOOP;
5987 		ELSE
5988 			l_to_pay_plan := p_pa_request_rec.to_pay_plan;
5989 		END IF;
5990 
5991 
5992 		IF l_to_pay_plan IS NOT NULL THEN
5993 			--
5994 			FOR l_wgi_pay_plan IN c_wgi_pay_plan(l_to_pay_plan) LOOP
5995 				l_is_wgi_eligible := TRUE;
5996 			END LOOP;
5997 
5998 
5999 		-- If Pay plan is not eligible, update with NULL
6000 			IF l_is_wgi_eligible = FALSE THEN
6001 				-- Check if WGI element is present or not. If present only we need to update
6002 				-- Get Element Name
6003 				l_wgi_new_name := pqp_fedhr_uspay_int_utils.return_new_element_name(
6004 										p_fedhr_element_name =>'Within Grade Increase',
6005 										p_business_group_id => l_bg_id,
6006 										p_effective_date => p_pa_request_rec.effective_date);
6007 				FOR l_check_wgi IN c_check_ele(l_wgi_new_name,p_pa_request_rec.effective_date,	p_pa_request_rec.employee_assignment_id) LOOP
6008 					l_wgi_exists := TRUE;
6009 				END LOOP;
6010 
6011 				IF l_wgi_exists = TRUE THEN
6012 					ghr_element_api.process_sf52_element
6013 					   (p_assignment_id        =>   p_pa_request_rec.employee_assignment_id
6014 					   ,p_element_name         =>  'Within Grade Increase'
6015 					   ,p_input_value_name2    =>   'Date Due'
6016 					   ,p_value2               =>   NULL
6017 					   ,p_input_value_name3    =>   'Pay Date'
6018 					   ,p_value3               =>   NULL
6019 					   ,p_input_value_name4    =>   'Last Equivalent Increase'
6020 					   ,p_value4               =>   NULL
6021 					   ,p_input_value_name5    =>   'Postponmt Effective'
6022 					   ,p_value5               =>   NULL
6023 					   ,p_effective_date       =>    l_effective_date
6024 					   ,p_process_warning      =>    l_within_grade_increase_warn
6025 					    );
6026 					    l_wgi_cleared := TRUE;
6027 				END IF;
6028 			END IF; -- IF l_is_wgi_eligible = FALSE
6029 		END IF;
6030 	  END IF; -- IF nvl(p_pa_request_rec.noa_family_code,hr_api.g_varchar2) = 'CONV_APP'
6031 
6032         -- proceed only if date_wgi_due is not null
6033           l_wgi_due_date := fnd_date.canonical_to_date(p_wgi.p_date_wgi_due);
6034           IF l_wgi_due_date IS NOT NULL AND l_wgi_cleared = FALSE THEN
6035             ghr_sf52_do_update.get_wgi_dates
6036             (p_pa_request_rec     => p_pa_request_rec,
6037              p_wgi_due_date       => l_wgi_due_date,
6038              p_wgi_pay_date       => l_wgi_pay_date,
6039              p_retained_grade_rec => l_retained_grade_rec,
6040 	     p_dlei  => NULL
6041              );
6042 	     hr_utility.set_location('Inside If loop',511);
6043             ghr_element_api.process_sf52_element
6044            (p_assignment_id        =>   p_pa_request_rec.employee_assignment_id
6045            ,p_element_name         =>  'Within Grade Increase'
6046            ,p_input_value_name2    =>   'Date Due'
6047            ,p_value2               =>   fnd_date.date_to_displaydate(l_wgi_due_date)     --AVR
6048            ,p_input_value_name3    =>   'Pay Date'
6049            ,p_value3               =>   fnd_date.date_to_displaydate(l_wgi_pay_date)  --AVR
6050            ,p_input_value_name4    =>   'Last Equivalent Increase'
6051            ,p_value4               =>   fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_wgi.p_last_equi_incr))
6052            ,p_input_value_name5    =>   'Postponmt Effective'
6053            ,p_value5               =>
6054                       fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_wgi.p_date_wgi_postpone_effective)) --AVR
6055            ,p_effective_date       =>    l_effective_date
6056            ,p_process_warning      =>    l_within_grade_increase_warn
6057             );
6058 	 -- If WGI Due date is not entered for Appointment and Conversion to Appointment, atleast create
6059 	 -- WGI element with Last equivalent increase.
6060 	 -- Bug 3998686 In correction action, if DLEI is present and WGI Due date is cleared,
6061 	 -- it comes here. Need to update NULL in that case. .
6062 	 ELSIF nvl(p_pa_request_rec.noa_family_code,hr_api.g_varchar2) IN ('APP','CONV_APP')
6063 		AND p_wgi.p_last_equi_incr IS NOT NULL AND l_wgi_cleared = FALSE THEN
6064 	     hr_utility.set_location('Inside elsif loop',511);
6065             ghr_element_api.process_sf52_element
6066            (p_assignment_id        =>   p_pa_request_rec.employee_assignment_id
6067            ,p_element_name         =>  'Within Grade Increase'
6068 	   ,p_input_value_name2    =>   'Date Due'
6069            ,p_value2               =>   NULL  -- Bug 3998686
6070            ,p_input_value_name3    =>   'Pay Date'
6071            ,p_value3               =>   NULL -- Bug 3998686
6072            ,p_input_value_name4    =>   'Last Equivalent Increase'
6073            ,p_value4               =>   fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_wgi.p_last_equi_incr))
6074            ,p_input_value_name5    =>   'Postponmt Effective'
6075            ,p_value5               =>
6076                       fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_wgi.p_date_wgi_postpone_effective)) --AVR
6077            ,p_effective_date       =>    l_effective_date
6078            ,p_process_warning      =>    l_within_grade_increase_warn
6079             );
6080          END IF; -- IF l_wgi_due_date IS NOT NULL THEN
6081         ELSE
6082 	      -- Bug 3953455
6083 	      -- If it's a correction action, and not in 702,703,713 then
6084 	      -- check for the To step. if it's different then need to call get_wgi_dates.
6085               IF (l_session.noa_id_correct is not null and
6086 	          p_pa_request_rec.first_noa_code NOT in ('702','703','713')) THEN
6087 		     -- Get the To step values
6088 		     FOR l_get_step IN cur_get_step(p_pa_request_rec.pa_request_id) LOOP
6089 			l_orig_pa_from_step := l_get_step.step1;
6090 			l_corr_pa_from_step := l_get_step.step2;
6091 		     END LOOP;
6092 
6093 		     IF l_corr_pa_from_step IS NOT NULL THEN
6094 			IF l_orig_pa_from_step <> l_corr_pa_from_step THEN
6095 				l_call_wgi_dates := TRUE;
6096 			END IF;
6097 		     END IF;
6098 		     -- Bug 4025190
6099 		     IF p_wgi.p_date_wgi_due IS NOT NULL OR p_wgi.p_last_equi_incr IS NOT NULL THEN
6100 			l_call_wgi_dates := TRUE;
6101 		     END IF;
6102 		     -- Bug 4025190
6103 	      END IF;
6104 	      -- End Bug 3953455
6105 
6106           -- CALL only if not a CORRECTION Action
6107           -- Bug#2099054 added OR Condition to handle
6108           -- a CORRECTION Action for noa codes 702,703,713 (Bug 3263140)
6109               If (l_session.noa_id_correct is null) OR
6110                 (l_session.noa_id_correct is not null and
6111                     p_pa_request_rec.first_noa_code in ('702','703','713')) OR
6112 			l_call_wgi_dates = TRUE
6113 		    THEN
6114 
6115                IF p_pa_request_rec.first_noa_code in ( '702','703','713') THEN
6116                  l_wgi_due_date := fnd_date.canonical_to_date(p_wgi.p_date_wgi_due);
6117                  hr_utility.set_location('702 -- l_wgi_due_date is ' || l_wgi_due_date,1);
6118                END IF;
6119 
6120                IF not (p_pa_request_rec.first_noa_code = '702' AND
6121                   g_old_user_status = 'Temp. Promotion NTE' )THEN
6122 			-- Call get_wgi_dates irrespective of whether Due date is entered or not.
6123 			-- Removed the condition which checked for Due date not null condition
6124 			-- Bug 3940682, 3941877, 3617295, TAR 4141454.995
6125 			ghr_sf52_do_update.get_wgi_dates
6126 			(p_pa_request_rec    => p_pa_request_rec,
6127 			p_wgi_due_date      => l_wgi_due_date,
6128 			p_wgi_pay_date      => l_wgi_pay_date,
6129 			p_retained_grade_rec => l_retained_grade_rec,
6130 			p_dlei  => fnd_date.canonical_to_date(p_wgi.p_last_equi_incr)
6131 			);
6132 		     -- Start of  3111719
6133 		     -- For QSI action get the current LEI date.
6134 		     -- Bug 3993664 - Included NOA 867...
6135              -- Bug#5666880 - Included NOA 896, 897
6136              IF (p_pa_request_rec.first_noa_code  IN ('892','867','896','897') OR
6137                          p_pa_request_rec.second_noa_code IN ('892','867','896','897')) THEN
6138                 hr_utility.set_location('inside NOA Code 897',9999999);
6139        			ghr_history_fetch.fetch_element_entry_value
6140                           (p_element_name          =>  'Within Grade Increase',
6141                            p_input_value_name      =>  'Last Equivalent Increase',
6142                            p_assignment_id         =>  p_pa_request_rec.employee_assignment_id,
6143                            p_date_effective        =>  p_pa_request_rec.effective_date,
6144                            p_screen_entry_value    =>  l_lei_date
6145                            );
6146                          p_wgi.p_last_equi_incr := l_lei_date;
6147 		     END IF;
6148            -- End of 3111719
6149 		-- Bug 3709414 Retrieving Last equivalent increase date if it's not entered in RPA EIT.
6150 		hr_utility.set_location('p_wgi.p_last_equi_incr is ' || p_wgi.p_last_equi_incr,1);
6151 		   IF (p_pa_request_rec.first_noa_code = '713' OR p_pa_request_rec.second_noa_code = '713')
6152 						AND p_wgi.p_last_equi_incr IS NULL THEN
6153 			   ghr_history_fetch.fetch_element_entry_value
6154                           (p_element_name          =>  'Within Grade Increase',
6155                            p_input_value_name      =>  'Last Equivalent Increase',
6156                            p_assignment_id         =>  p_pa_request_rec.employee_assignment_id,
6157                            p_date_effective        =>  p_pa_request_rec.effective_date,
6158                            p_screen_entry_value    =>  l_lei_date
6159                            );
6160                          p_wgi.p_last_equi_incr := l_lei_date;
6161 		   END IF;
6162 
6163 		   -- Bug 3617295 DLEI should be updated with RPA effective date
6164 		   IF p_pa_request_rec.first_noa_code = '855' OR p_pa_request_rec.second_noa_code = '855' THEN
6165 			p_wgi.p_last_equi_incr := fnd_date.date_to_canonical(p_pa_request_rec.effective_date); -- Bug 3991240
6166 		   END IF;
6167 		   -- End Bug 3617295
6168 
6169 		   hr_utility.set_location('l_wgi_due_date calculated is ' || l_wgi_due_date,1);
6170            hr_utility.set_location('lei date calculated is ' || p_wgi.p_last_equi_incr,2);
6171            hr_utility.set_location('l_wgi_pay_date calculated is ' || l_wgi_pay_date,3);
6172 
6173              ghr_element_api.process_sf52_element
6174                (p_assignment_id        =>  p_pa_request_rec.employee_assignment_id
6175                ,p_element_name         =>  'Within Grade Increase'
6176                ,p_input_value_name2    =>  'Date Due'
6177                ,p_value2               =>  fnd_date.date_to_displaydate(l_wgi_due_date)  --AVR
6178                ,p_input_value_name3    =>  'Pay Date'
6179                ,p_value3               =>   fnd_date.date_to_displaydate(l_wgi_pay_date) --AVR
6180                ,p_input_value_name4    =>  'Last Equivalent Increase'
6181                ,p_value4               =>   fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_wgi.p_last_equi_incr))
6182                ,p_input_value_name5    =>   'Postponmt Effective'
6183                ,p_value5               =>
6184                 fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_wgi.p_date_wgi_postpone_effective)) --AVR
6185                ,p_effective_date       =>    l_effective_date
6186                ,p_process_warning      =>    l_within_grade_increase_warn
6187                 );
6188             END IF; -- IF not (p_pa_request_rec.first_noa_code = '702'
6189        End if; -- If (l_session.noa_id_correct is null) OR
6190      End if;
6191    Else
6192      If p_wgi.p_date_wgi_due                is not null or
6193        p_wgi.p_wgi_pay_date                 is not null  or
6194        p_wgi.p_date_wgi_postpone_effective  is not null  then
6195        hr_utility.set_location(l_proc,85);
6196        hr_utility.set_location('date due  ' || p_wgi.p_date_wgi_due,1);
6197        hr_utility.set_location('determ due' || p_wgi.p_date_wgi_postpone_effective,2);
6198 
6199        ghr_element_api.process_sf52_element
6200        (p_assignment_id      =>    p_pa_request_rec.employee_assignment_id
6201        ,p_element_name       =>   'Within Grade Increase'
6202        ,p_input_value_name2  =>   'Date Due'
6203        ,p_value2             =>
6204                fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_wgi.p_date_wgi_due)) --AVR
6205        ,p_input_value_name3  =>  'Pay Date'
6206        ,p_value3             =>
6207                fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_wgi.p_wgi_pay_date)) --AVR
6208            ,p_input_value_name4    =>  'Last Equivalent Increase'
6209            ,p_value4               =>   fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_wgi.p_last_equi_incr))
6210        ,p_input_value_name5  =>   'Postponmt Effective'
6211        ,p_value5             =>
6212            fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_wgi.p_date_wgi_postpone_effective)) ---AVR
6213        ,p_effective_date     =>    l_effective_date
6214        ,p_process_warning    =>    l_within_grade_increase_warn
6215        );
6216     end if;
6217  End if;
6218 END IF;    ------l_equ_pay_plan = 'ES'
6219 
6220  -- FWFA Changes. Restrict this update if the update happens already in call_extra_info_api.
6221 
6222 
6223 
6224 IF NOT(ghr_pay_calc.g_fwfa_pay_calc_flag) AND
6225       NOT(ghr_pay_calc.g_gl_upd_flag) THEN
6226          ghr_history_api.get_g_session_var(l_session);
6227     IF p_pa_request_rec.first_noa_code = '894' and
6228          ghr_process_sf52.g_prd IS NOT NULL AND
6229          l_session.noa_id_correct IS NULL THEN
6230          IF ghr_process_sf52.g_prd in ('A','B','E','F','U','V') THEN
6231 	     l_new_step_or_rate := ghr_process_sf52.g_step_or_rate;
6232              l_retained_grade_rec :=  ghr_pc_basic_pay.get_retained_grade_details
6233                               (p_person_id       =>   p_pa_request_rec.person_id,
6234                                p_effective_date  =>   p_pa_request_rec.effective_date,
6235                                p_pa_request_id   =>   p_pa_request_rec.pa_request_id
6236                               );
6237         END IF;
6238      END IF;
6239        hr_utility.set_location('ret person extra info id : ' || l_retained_grade_rec.person_extra_info_id,1);
6240 
6241 -------Bug 5913362 -- Adding 890
6242        If l_retained_grade_rec.person_extra_info_id is not null
6243        and p_pa_request_rec.first_noa_code NOT IN ('866', '890')  then
6244           hr_utility.set_location('update retained grade info',1);
6245           for retained_grade_ovn in c_retained_grade_ovn loop
6246             l_ret_object_version_number := retained_grade_ovn.object_version_number;
6247             if p_pa_request_rec.first_noa_code in ('867','892','893','894')
6248                then
6249               l_new_date_to             := retained_grade_ovn.pei_information2;
6250               l_new_grade_or_level      := retained_grade_ovn.pei_information3;
6251               l_new_pay_plan            := retained_grade_ovn.pei_information5;
6252               l_new_pay_table           := retained_grade_ovn.pei_information6;
6253               l_new_loc_percent         := retained_grade_ovn.pei_information7;
6254               l_new_pay_basis           := retained_grade_ovn.pei_information8;
6255               l_cur_step_or_rate        := retained_grade_ovn.pei_information4;
6256               l_new_temp_step        := retained_grade_ovn.pei_information9;
6257             end if;
6258           end loop;
6259           If p_pa_request_rec.first_noa_code in ('867','892','893','894') then
6260            hr_utility.set_location('procesing 867,892,893,894',1);
6261            ghr_history_api.get_g_session_var(l_session);
6262            If l_session.noa_id_correct is null then
6263            hr_utility.set_location('procesing 867,892,893,894 not a corr',1);
6264 ----Bug 6193571 start
6265              if p_pa_request_rec.first_noa_code = '894'
6266                 AND l_new_step_or_rate is not null
6267                     AND ghr_process_sf52.g_prd IS NOT NULL then
6268               hr_person_extra_info_api.update_person_extra_info
6269               (p_person_extra_info_id      =>  l_retained_grade_rec.person_extra_info_id,
6270                p_object_version_number     =>  l_ret_object_version_number,
6271                p_pei_information2          =>  fnd_date.date_to_canonical(p_pa_request_rec.effective_date - 1)
6272                );
6273              end if;
6274              If p_pa_request_rec.first_noa_code in ('867','892','893') then
6275 --- Bug 6193571  end
6276               hr_person_extra_info_api.update_person_extra_info
6277               (p_person_extra_info_id      =>  l_retained_grade_rec.person_extra_info_id,
6278                p_object_version_number     =>  l_ret_object_version_number,
6279                p_pei_information2          =>  fnd_date.date_to_canonical(p_pa_request_rec.effective_date - 1)
6280                );
6281              end if;
6282            IF p_pa_request_rec.first_noa_code in ('867','892','893') THEN
6283              l_new_step_or_rate := l_retained_grade_rec.step_or_rate;
6284              l_new_temp_step := l_retained_grade_rec.temp_step;
6285            hr_utility.set_location('TPS 1 ',1);
6286            END IF;
6287            hr_utility.set_location('TPS 1a '||l_new_temp_step,1);
6288            IF l_new_temp_step is NOT NULL THEN
6289            hr_utility.set_location('TPS 1b '||l_new_temp_step,1);
6290               hr_person_extra_info_api.create_person_extra_info
6291               (p_person_id                =>  p_pa_request_rec.person_id,
6292                p_information_type         =>  'GHR_US_RETAINED_GRADE',
6293                p_pei_information_category =>  'GHR_US_RETAINED_GRADE',
6294                p_person_extra_info_id     =>  l_ret_grade_rec.person_extra_info_id,
6295                p_object_version_number    =>  l_ret_object_version_number,
6296                p_pei_information1         =>  fnd_date.date_to_canonical(p_pa_request_rec.effective_date),
6297                p_pei_information2         =>  l_new_date_to,
6298                p_pei_information3         =>  l_new_grade_or_level,
6299                p_pei_information4         =>  l_cur_step_or_rate,
6300                p_pei_information5         =>  l_new_pay_plan,
6301                p_pei_information6         =>  l_new_pay_table,
6302                p_pei_information7         =>  l_new_loc_percent,
6303                p_pei_information8         =>  l_new_pay_basis,
6304                p_pei_information9         =>  l_new_temp_step
6305               );
6306            ELSE
6307            hr_utility.set_location('TPS 2 '||l_new_step_or_rate,2);
6308 ---Bug 6024225 Added nvl value for 894 action. Need to check this at a later time.
6309 
6310 --- Bug 6193571 start
6311              if p_pa_request_rec.first_noa_code = '894'
6312                 AND l_new_step_or_rate is not null
6313                     AND ghr_process_sf52.g_prd IS NOT NULL then
6314               hr_person_extra_info_api.create_person_extra_info
6315               (p_person_id                =>  p_pa_request_rec.person_id,
6316                p_information_type         =>  'GHR_US_RETAINED_GRADE',
6317                p_pei_information_category =>  'GHR_US_RETAINED_GRADE',
6318                p_person_extra_info_id     =>  l_ret_grade_rec.person_extra_info_id,
6319                p_object_version_number    =>  l_ret_object_version_number,
6320                p_pei_information1         =>  fnd_date.date_to_canonical(p_pa_request_rec.effective_date),
6321                p_pei_information2         =>  l_new_date_to,
6322                p_pei_information3         =>  l_new_grade_or_level,
6323                p_pei_information4         =>  nvl(l_new_step_or_rate,l_cur_step_or_rate),
6324                p_pei_information5         =>  l_new_pay_plan,
6325                p_pei_information6         =>  l_new_pay_table,
6326                p_pei_information7         =>  l_new_loc_percent,
6327                p_pei_information8         =>  l_new_pay_basis
6328               );
6329              end if;
6330              IF p_pa_request_rec.first_noa_code in ('867','892','893') THEN
6331 ----Bug 6193571 end
6332               hr_person_extra_info_api.create_person_extra_info
6333               (p_person_id                =>  p_pa_request_rec.person_id,
6334                p_information_type         =>  'GHR_US_RETAINED_GRADE',
6335                p_pei_information_category =>  'GHR_US_RETAINED_GRADE',
6336                p_person_extra_info_id     =>  l_ret_grade_rec.person_extra_info_id,
6337                p_object_version_number    =>  l_ret_object_version_number,
6338                p_pei_information1         =>  fnd_date.date_to_canonical(p_pa_request_rec.effective_date),
6339                p_pei_information2         =>  l_new_date_to,
6340                p_pei_information3         =>  l_new_grade_or_level,
6341                p_pei_information4         =>  nvl(l_new_step_or_rate,l_cur_step_or_rate),
6342                p_pei_information5         =>  l_new_pay_plan,
6343                p_pei_information6         =>  l_new_pay_table,
6344                p_pei_information7         =>  l_new_loc_percent,
6345                p_pei_information8         =>  l_new_pay_basis
6346               );
6347              end if;
6348             END IF;
6349           End if;
6350         Else
6351            hr_utility.set_location('TPS 3 '||l_new_step_or_rate,3);
6352           hr_person_extra_info_api.update_person_extra_info
6353           (p_person_extra_info_id      =>  l_retained_grade_rec.person_extra_info_id,
6354            p_object_version_number     =>  l_ret_object_version_number,
6355            p_pei_information4          =>  l_retained_grade_rec.step_or_rate
6356           );
6357        End if;
6358      End if;
6359 END IF;
6360 --
6361 -- Temp. Promo RG processing for 703 Actions
6362 -- Create a new RG row with the Temporary promotion step value
6363 -- and End date the current RG row with effective date minus one
6364     -- Get the Temporary Promotion Step Value
6365   l_new_temp_step := NULL;
6366   IF p_pa_request_rec.first_noa_code in ('703') THEN
6367     FOR cur_temp_step_rec IN cur_temp_step LOOP
6368       l_new_temp_step  := cur_temp_step_rec.temp_step;
6369     END LOOP;
6370     hr_utility.set_location('TPS 4 '||l_new_temp_step,4);
6371     IF  l_new_temp_step is not null  THEN
6372       l_retained_grade_rec :=
6373        ghr_pc_basic_pay.get_retained_grade_details
6374          (p_person_id      =>   p_pa_request_rec.person_id,
6375          p_effective_date  =>   p_pa_request_rec.effective_date,
6376          p_pa_request_id   =>   p_pa_request_rec.pa_request_id
6377          );
6378       IF l_retained_grade_rec.person_extra_info_id is not null then
6379         hr_utility.set_location('Inside 703 processing '||l_retained_grade_rec.person_extra_info_id,1);
6380         FOR retained_grade_ovn IN c_retained_grade_ovn LOOP
6381           l_ret_object_version_number := retained_grade_ovn.object_version_number;
6382           l_new_date_to             := retained_grade_ovn.pei_information2;
6383           l_new_grade_or_level      := retained_grade_ovn.pei_information3;
6384           l_new_step_or_rate        := retained_grade_ovn.pei_information4;
6385           l_new_pay_plan            := retained_grade_ovn.pei_information5;
6386           l_new_pay_table           := retained_grade_ovn.pei_information6;
6387           l_new_loc_percent         := retained_grade_ovn.pei_information7;
6388           l_new_pay_basis           := retained_grade_ovn.pei_information8;
6389           exit;
6390         END LOOP;
6391         ghr_history_api.get_g_session_var(l_session);
6392         hr_utility.set_location('Inside 703 processing ',2);
6393         IF l_session.noa_id_correct is null then
6394           -- End date the existing RG record
6395           hr_person_extra_info_api.update_person_extra_info
6396           (p_person_extra_info_id      =>  l_retained_grade_rec.person_extra_info_id,
6397           p_object_version_number     =>  l_ret_object_version_number,
6398           p_pei_information2          =>  fnd_date.date_to_canonical(p_pa_request_rec.effective_date - 1)
6399           );
6400           hr_utility.set_location('Inside 703 processing ',3);
6401           -- Create the new RG Record with Temporary Promotion Step Value
6402           hr_person_extra_info_api.create_person_extra_info
6403           (p_person_id                =>  p_pa_request_rec.person_id,
6404           p_information_type         =>  'GHR_US_RETAINED_GRADE',
6405           p_pei_information_category =>  'GHR_US_RETAINED_GRADE',
6406           p_person_extra_info_id     =>  l_ret_grade_rec.person_extra_info_id,
6407           p_object_version_number    =>  l_ret_object_version_number,
6408           p_pei_information1         =>  fnd_date.date_to_canonical(p_pa_request_rec.effective_date),
6409           p_pei_information2         =>  l_new_date_to,
6410           p_pei_information3         =>  l_new_grade_or_level,
6411           p_pei_information4         =>  l_new_step_or_rate,
6412           p_pei_information5         =>  l_new_pay_plan,
6413           p_pei_information6         =>  l_new_pay_table,
6414           p_pei_information7         =>  l_new_loc_percent,
6415           p_pei_information8         =>  l_new_pay_basis,
6416           p_pei_information9         =>  l_new_temp_step
6417           );
6418           hr_utility.set_location('Inside 703 processing ',3);
6419         ELSE
6420           -- Update the current RG
6421           hr_utility.set_location('Inside 703 correction processing '||l_new_temp_step,4);
6422           hr_person_extra_info_api.update_person_extra_info
6423           (p_person_extra_info_id     =>  l_retained_grade_rec.person_extra_info_id,
6424           p_object_version_number     =>  l_ret_object_version_number,
6425           p_pei_information9          =>  l_new_temp_step
6426           );
6427         END IF;
6428       END IF;
6429     END IF;
6430   END IF;
6431 --
6432 -- Temp. Promo RG processing for 740 action
6433 -- Create a new RG record with the null Temporary promotion step value
6434 -- and End date the current RG row withe effective date minus one
6435    -- Get the Temporary Promotion Step Value
6436    IF p_pa_request_rec.first_noa_code in ('740') THEN
6437     BEGIN --Bug 3941836 added being and end for this.
6438       l_retained_grade_rec :=
6439        ghr_pc_basic_pay.get_retained_grade_details
6440          (p_person_id      =>   p_pa_request_rec.person_id,
6441          p_effective_date  =>   p_pa_request_rec.effective_date,
6442          p_pa_request_id   =>   p_pa_request_rec.pa_request_id
6443          );
6444      EXCEPTION
6445        WHEN OTHERS THEN
6446           NULL;
6447      END;
6448      IF l_retained_grade_rec.person_extra_info_id is not null then
6449        hr_utility.set_location('Inside 740 processing '||l_retained_grade_rec.person_extra_info_id,1);
6450        FOR retained_grade_ovn IN c_retained_grade_ovn LOOP
6451          l_ret_object_version_number := retained_grade_ovn.object_version_number;
6452          l_new_date_to             := retained_grade_ovn.pei_information2;
6453          l_new_grade_or_level      := retained_grade_ovn.pei_information3;
6454          l_new_step_or_rate        := retained_grade_ovn.pei_information4;
6455          l_new_pay_plan            := retained_grade_ovn.pei_information5;
6456          l_new_pay_table           := retained_grade_ovn.pei_information6;
6457          l_new_loc_percent         := retained_grade_ovn.pei_information7;
6458          l_new_pay_basis           := retained_grade_ovn.pei_information8;
6459          l_new_temp_step           := retained_grade_ovn.pei_information9;
6460          exit;
6461        END LOOP;
6462        hr_utility.set_location('Inside 740 processing ',2);
6463        ghr_history_api.get_g_session_var(l_session);
6464        IF l_new_temp_step IS NOT NULL and l_session.noa_id_correct IS NULL THEN
6465          -- End date the existing RG record
6466          hr_person_extra_info_api.update_person_extra_info
6467          (p_person_extra_info_id      =>  l_retained_grade_rec.person_extra_info_id,
6468          p_object_version_number     =>  l_ret_object_version_number,
6469          p_pei_information2          =>  fnd_date.date_to_canonical(p_pa_request_rec.effective_date - 1)
6470          );
6471          hr_utility.set_location('Inside 740 processing ',3);
6472          -- Create the new RG Record with null Temporary Promotion Step Value
6473          hr_person_extra_info_api.create_person_extra_info
6474          (p_person_id                =>  p_pa_request_rec.person_id,
6475          p_information_type         =>  'GHR_US_RETAINED_GRADE',
6476          p_pei_information_category =>  'GHR_US_RETAINED_GRADE',
6477          p_person_extra_info_id     =>  l_ret_grade_rec.person_extra_info_id,
6478          p_object_version_number    =>  l_ret_object_version_number,
6479          p_pei_information1         =>  fnd_date.date_to_canonical(p_pa_request_rec.effective_date),
6480          p_pei_information2         =>  l_new_date_to,
6481          p_pei_information3         =>  l_new_grade_or_level,
6482          p_pei_information4         =>  l_new_step_or_rate,
6483          p_pei_information5         =>  l_new_pay_plan,
6484          p_pei_information6         =>  l_new_pay_table,
6485          p_pei_information7         =>  l_new_loc_percent,
6486          p_pei_information8         =>  l_new_pay_basis
6487          );
6488          hr_utility.set_location('Inside 740 processing ',3);
6489        END IF;
6490      END IF;
6491    END IF;
6492 hr_utility.set_location('Leaving  ' ||l_proc,100);
6493 Exception when others then
6494           --
6495           -- Reset IN OUT parameters and set OUT parameters
6496           --
6497           p_wgi                      := l_wgi;
6498           p_retention_allow_review   := l_retention_allow_review;
6499           raise;
6500 
6501 end Process_salary_Info;
6502 --
6503 --
6504 --
6505 --  ********************************
6506 --  procedure  Process_Non_Salary_Info
6507 --  ********************************
6508 --
6509 Procedure Process_non_salary_Info
6510 (p_pa_request_rec             in            ghr_pa_requests%rowtype
6511 ,p_recruitment_bonus          in out nocopy ghr_api.recruitment_bonus_type
6512 ,p_relocation_bonus           in out nocopy ghr_api.relocation_bonus_type
6513 ,p_student_loan_repay         in out nocopy ghr_api.student_loan_repay_type
6514  --Pradeep
6515  ,p_mddds_special_pay          in out nocopy ghr_api.mddds_special_pay_type
6516 ,p_premium_pay_ind             in out nocopy ghr_api.premium_pay_ind_type
6517 ,p_gov_award                  in out nocopy ghr_api.government_awards_type
6518 ,p_entitlement                in out nocopy ghr_api.entitlement_type
6519 -- Bug#2759379 Added FEGLI parameter
6520 ,p_fegli                      in out nocopy ghr_api.fegli_type
6521 ,p_foreign_lang_prof_pay      in out nocopy ghr_api.foreign_lang_prof_pay_type
6522 -- Bug# 3385386 Added FTA parameter
6523 ,p_fta                        in out nocopy ghr_api.fta_type
6524 ,p_edp_pay                    in out nocopy ghr_api.edp_pay_type
6525 ,p_hazard_pay                 in out nocopy ghr_api.hazard_pay_type
6526 ,p_health_benefits            in out nocopy ghr_api.health_benefits_type
6527 ,p_danger_pay                 in out nocopy ghr_api.danger_pay_type
6528 ,p_imminent_danger_pay        in out nocopy ghr_api.imminent_danger_pay_type
6529 ,p_living_quarters_allow      in out nocopy ghr_api.living_quarters_allow_type
6530 ,p_post_diff_amt              in out nocopy ghr_api.post_diff_amt_type
6531 ,p_post_diff_percent          in out nocopy ghr_api.post_diff_percent_type
6532 ,p_sep_maintenance_allow      in out nocopy ghr_api.sep_maintenance_allow_type
6533 ,p_supplemental_post_allow    in out nocopy ghr_api.supplemental_post_allow_type
6534 ,p_temp_lodge_allow           in out nocopy ghr_api.temp_lodge_allow_type
6535 ,p_premium_pay                in out nocopy ghr_api.premium_pay_type
6536 ,p_retirement_annuity         in out nocopy ghr_api.retirement_annuity_type
6537 ,p_severance_pay              in out nocopy ghr_api.severance_pay_type
6538 ,p_thrift_saving_plan         in out nocopy ghr_api.thrift_saving_plan
6539 ,p_health_ben_pre_tax         in out nocopy ghr_api.health_ben_pre_tax_type
6540 ) is
6541 
6542 l_proc                        varchar2(70) := 'Process_Non_salary_info';
6543 l_warning                     boolean;
6544 l_effective_date              date;
6545 --
6546 -- No copy Changes.
6547 l_recruitment_bonus           ghr_api.recruitment_bonus_type;
6548 l_relocation_bonus            ghr_api.relocation_bonus_type;
6549 l_gov_award                   ghr_api.government_awards_type;
6550 l_entitlement                 ghr_api.entitlement_type;
6551 l_foreign_lang_prof_pay       ghr_api.foreign_lang_prof_pay_type;
6552 -- Bug# 3385386 Added l_fta variable
6553 l_fta                         ghr_api.fta_type;
6554 l_edp_pay                     ghr_api.edp_pay_type;
6555 l_hazard_pay                  ghr_api.hazard_pay_type;
6556 l_health_benefits             ghr_api.health_benefits_type;
6557 l_danger_pay                  ghr_api.danger_pay_type;
6558 l_imminent_danger_pay         ghr_api.imminent_danger_pay_type;
6559 l_living_quarters_allow       ghr_api.living_quarters_allow_type;
6560 l_post_diff_amt               ghr_api.post_diff_amt_type;
6561 l_post_diff_percent           ghr_api.post_diff_percent_type;
6562 l_sep_maintenance_allow       ghr_api.sep_maintenance_allow_type;
6563 l_supplemental_post_allow     ghr_api.supplemental_post_allow_type;
6564 l_temp_lodge_allow            ghr_api.temp_lodge_allow_type;
6565 l_premium_pay                 ghr_api.premium_pay_type;
6566 l_retirement_annuity          ghr_api.retirement_annuity_type;
6567 l_severance_pay               ghr_api.severance_pay_type;
6568 l_thrift_saving_plan          ghr_api.thrift_saving_plan;
6569 l_health_ben_pre_tax          ghr_api.health_ben_pre_tax_type;
6570 l_student_loan_repay          ghr_api.student_loan_repay_type;
6571 -- Bug#4486823 RRR Changes
6572 l_total_salary                ghr_pa_requests.to_total_salary%TYPE;
6573 --
6574         PROCEDURE Create_incentive_Remark(p_pa_request_id  IN NUMBER,
6575                                           p_effective_date IN DATE,
6576                                           p_category   IN VARCHAR2,
6577                                           p_noa_code   IN VARCHAR2,
6578                                           p_percent    IN NUMBER,
6579                                           p_amount     IN NUMBER,
6580                   			              p_payment_date IN DATE,
6581                                           p_end_date     IN DATE) IS
6582 
6583                 l_remark_id           ghr_remarks.remark_id%TYPE;
6584                 l_pa_remark_id        ghr_pa_remarks.pa_remark_id%TYPE;
6585                 l_object_version_nbr  ghr_pa_remarks.object_version_number%TYPE;
6586                 l_remark_desc         ghr_remarks.description%TYPE;
6587                 l_remark_information1 ghr_pa_remarks.remark_code_information1%TYPE;
6588                 l_remark_information2 ghr_pa_remarks.remark_code_information2%TYPE;
6589                 l_remark_information3 ghr_pa_remarks.remark_code_information3%TYPE;
6590                 l_remark_information4 ghr_pa_remarks.remark_code_information4%TYPE;
6591                 l_remark_information5 ghr_pa_remarks.remark_code_information5%TYPE;
6592                 l_remark_desc_out     ghr_remarks.description%TYPE;
6593                 l_end_date            DATE;
6594 
6595 
6596             BEGIN
6597                 l_end_date := p_end_date;
6598                 ghr_mass_actions_pkg.get_remark_id_desc
6599                 (p_remark_code       => 'ZZZ',
6600                 p_effective_date    => p_effective_date,
6601                 p_remark_id         => l_remark_id,
6602                 p_remark_desc       => l_remark_desc);
6603 
6604                 l_remark_information1 := NULL;
6605                 l_remark_information2 := NULL;
6606                 l_remark_information3 := NULL;
6607                 l_remark_information4 := NULL;
6608                 l_remark_information5 := NULL;
6609 
6610                 IF p_percent IS NOT NULL THEN
6611                     IF p_category = 'Biweekly' THEN
6612 
6613                         -- Bug#5039100
6614                         IF p_percent = 0 THEN
6615                             -- Change the remark from 'As on' to 'As of' : Bug:5170178
6616                             l_remark_information1 := 'Retention Incentive Biweekly is terminated as of '||fnd_date.date_to_displaydate(p_payment_date);
6617                         ELSE
6618                             -- Added this IF condition to remove the end date if end date is '4712/12/31' : Bug#5170178
6619                             IF l_end_date IS NULL THEN
6620                                 l_remark_information1 := p_category||' is '||p_percent||'% of Earned Basic Pay to be paid from '
6621                                                ||fnd_date.date_to_displaydate(p_payment_date);
6622                             ELSE
6623                                 l_remark_information1 := p_category||' is '||p_percent||'% of Earned Basic Pay to be paid from '
6624                                                ||fnd_date.date_to_displaydate(p_payment_date) ||' to '
6625                                                ||fnd_date.date_to_displaydate(l_end_date);
6626                             END IF;
6627                         END IF;
6628                     ELSE
6629                         l_remark_information1 := p_category||' is '||p_percent||'% of Earned Basic Pay to be paid '
6630                                             ||fnd_date.date_to_displaydate(p_payment_date);
6631                     END IF;
6632                 ELSE
6633                     IF p_category = 'Biweekly' THEN
6634                         -- Added this IF condition to remove the end date if end date is '4712/12/31' : Bug#5170178
6635                         IF l_end_date IS NULL THEN
6636                             l_remark_information1 := p_category||' of $'||p_amount||' to be paid from '
6637                                             ||fnd_date.date_to_displaydate(p_payment_date);
6638                             ELSE
6639                             l_remark_information1 := p_category||' of $'||p_amount||' to be paid from '
6640                                             ||fnd_date.date_to_displaydate(p_payment_date) ||' to '
6641                                             ||fnd_date.date_to_displaydate(l_end_date);
6642 
6643                         END IF;
6644                    ELSE
6645                         l_remark_information1 := p_category||' of $'||p_amount||' to be paid '
6646                                             ||fnd_date.date_to_displaydate(p_payment_date);
6647                     END IF;
6648                 END IF;
6649 
6650 
6651                 --Pradeep commented l_remark_desc and added l_remark_desc_out for the Bug#3974979.
6652                 ghr_mass_actions_pkg.replace_insertion_values
6653                 (p_desc              => l_remark_desc,
6654                 p_information1      => l_remark_information1,
6655                 p_information2      => l_remark_information2,
6656                 p_information3      => l_remark_information3,
6657                 p_information4      => l_remark_information4,
6658                 p_information5      => l_remark_information5,
6659                 p_desc_out          => l_remark_desc_out
6660                     );
6661                 l_remark_desc := l_remark_desc_out;
6662 
6663                 ghr_pa_remarks_api.create_pa_remarks
6664                      (p_pa_request_id            => p_pa_request_id,
6665                       p_remark_id                => l_remark_id,
6666                       p_description              => l_remark_desc,
6667                       p_remark_code_information1 => l_remark_information1,
6668                       p_remark_code_information2 => l_remark_information2,
6669                       p_remark_code_information3 => l_remark_information3,
6670                       p_remark_code_information4 => l_remark_information4,
6671                       p_remark_code_information5 => l_remark_information5,
6672                       p_pa_remark_id             => l_pa_remark_id,
6673                       p_object_version_number    => l_object_version_nbr);
6674             END create_incentive_remark;
6675 
6676             PROCEDURE Upd_sep_incn_elements(p_pa_request_id   IN ghr_pa_requests.pa_request_id%TYPE
6677                                             ,p_assignment_id   IN ghr_pa_requests.employee_assignment_id%TYPE
6678                                             ,p_effective_date  IN ghr_pa_requests.effective_date%TYPE
6679                                             ,p_payment_option  IN ghr_pa_requests.pa_incentive_payment_option%TYPE
6680                                             ,p_first_noa_code  IN ghr_pa_requests.first_noa_code%TYPE
6681                                             ,p_second_noa_code IN ghr_pa_requests.second_noa_code%TYPE) IS
6682 
6683                Cursor c_inc_catg_details(l_pa_request_id NUMBER) IS
6684                 SELECT pa_incentive_category_amount amount,
6685                        pa_incentive_category_pmnt_dt payment_date
6686                 FROM   ghr_pa_incentives
6687                 where  pa_request_id = l_pa_request_id
6688                 order by pa_incentive_category_pmnt_dt;
6689 
6690 
6691                 CURSOR c_nonrec_incntv_ele_info (ele_name    in varchar2
6692                                                 ,asg_id      in number
6693                                                 ,eff_date    in date
6694                                                 ,bg_id       in number) is
6695                 select       ele.element_entry_id,
6696                              ipv.name,
6697                              ipv.input_value_id,
6698                              ipv.uom,
6699                              eev.screen_entry_value screen_entry_value,
6700                              ele.object_version_number
6701                       from pay_element_types_f elt,
6702                            pay_input_values_f ipv,
6703                            pay_element_entries_f ele,
6704                            pay_element_entry_values_f eev
6705                      where trunc(eff_date) between elt.effective_start_date
6706                                    and elt.effective_end_date
6707                        and trunc(eff_date) between ipv.effective_start_date
6708                                    and ipv.effective_end_date
6709                        and trunc(eff_date) between ele.effective_start_date
6710                                    and ele.effective_end_date
6711                        and trunc(eff_date) between eev.effective_start_date
6712                                    and eev.effective_end_date
6713                        and elt.element_type_id = ipv.element_type_id
6714                        and upper(elt.element_name) = upper(ele_name)
6715                        and ipv.input_value_id = eev.input_value_id
6716                        and ele.assignment_id = asg_id
6717                        and ele.element_entry_id + 0 = eev.element_entry_id
6718                        and (elt.business_group_id is null or elt.business_group_id = bg_id)
6719                     order by ele.element_entry_id,ipv.input_value_id;
6720 
6721                     cursor c_business_group (asg_id number, eff_date date) is
6722                     select asg.business_group_id
6723                     from per_all_assignments_f asg
6724                     where asg.assignment_id = asg_id
6725                     and eff_date between asg.effective_start_date
6726                     and asg.effective_end_date;
6727 
6728 
6729                     l_value1              pay_element_entry_values_f.screen_entry_value%type;
6730                     l_value2              pay_element_entry_values_f.screen_entry_value%type;
6731                     l_value3              pay_element_entry_values_f.screen_entry_value%type;
6732                     l_amount1             pay_element_entry_values_f.screen_entry_value%type;
6733                     l_amount2             pay_element_entry_values_f.screen_entry_value%type;
6734                     l_date1               pay_element_entry_values_f.screen_entry_value%type;
6735                     l_date2               pay_element_entry_values_f.screen_entry_value%type;
6736                     l_business_group_id   per_business_groups.business_group_id%type;
6737                     l_input_value_id1     pay_input_values_f.input_value_id%type;
6738                     l_input_value_id2     pay_input_values_f.input_value_id%type;
6739                     l_input_value_id3     pay_input_values_f.input_value_id%type;
6740                     l_element_entry_id      pay_element_entries_f.element_entry_id%type;
6741                     l_object_version_number pay_element_entries_f.object_version_number%type;
6742                     l_update_mode          VARCHAR2(25);
6743                     l_ctr		           NUMBER;
6744                     l_element_ctr	       NUMBER;
6745                     l_update_warning        boolean;
6746                     l_effective_start_date  date;
6747                     l_effective_end_date    date;
6748 
6749                 BEGIN
6750 
6751                     l_ctr := 0;
6752                     for c_business_group_rec in c_business_group (p_assignment_id, p_effective_date)
6753                     loop
6754                         l_business_group_id    := c_business_group_rec.business_group_id;
6755                         exit;
6756                     end loop;
6757 
6758                     FOR c_incdet_rec IN c_inc_catg_details(p_pa_request_id)
6759                     LOOP
6760                         l_ctr := l_ctr + 1;
6761                         IF l_ctr = 1 THEN
6762                             l_amount1 := c_incdet_rec.amount;
6763                             l_date1   := fnd_date.date_to_displaydate(c_incdet_rec.payment_date);
6764                         ELSE -- ie. l_ctr =2
6765                             l_amount2 := c_incdet_rec.amount;
6766                             l_date2   :=  fnd_date.date_to_displaydate(c_incdet_rec.payment_date);
6767                         END IF;
6768                     END LOOP;
6769 
6770                     l_ctr := 0;
6771                     l_element_ctr := 0;
6772 
6773                     FOR c_ele_info_rec IN c_nonrec_incntv_ele_info('Separation Incentive Lump Sum'
6774                                                                    ,p_assignment_id
6775                                                                    ,p_effective_date
6776                                                                    ,l_business_group_id)
6777                     LOOP
6778                         l_ctr := l_ctr + 1;
6779                         IF l_ctr <= 3 THEN
6780                             l_element_entry_id      := c_ele_info_rec.element_entry_id;
6781                             l_object_version_number := c_ele_info_rec.object_version_number;
6782 
6783                             IF c_ele_info_rec.name = 'Amount'  THEN
6784                                 l_input_value_id1 := c_ele_info_rec.input_value_id;
6785                                 l_value1          := c_ele_info_rec.screen_entry_value;
6786                             ELSIF c_ele_info_rec.name = 'Payment Date' THEN
6787                                 l_input_value_id2 := c_ele_info_rec.input_value_id;
6788                                 l_value2          := c_ele_info_rec.screen_entry_value;
6789                             ELSIF c_ele_info_rec.name = 'Payment Option' THEN
6790                                 l_input_value_id3 := c_ele_info_rec.input_value_id;
6791                                 l_value3          := c_ele_info_rec.screen_entry_value;
6792                             END IF;
6793 
6794                             IF l_ctr = 3 THEN
6795 
6796                                 BEGIN
6797                                    l_element_ctr := l_element_ctr + 1;
6798                                    IF l_element_ctr = 1 THEN
6799                                         l_value1  := NVL(l_amount1,l_value1);
6800                                         l_value2  := NVL(l_date1, l_value2);
6801                                     ELSIF l_element_ctr = 2 THEN
6802                                         l_value1  := NVL(l_amount2,l_value1);
6803                                         l_value2  := NVL(l_date2, l_value2);
6804                                     END IF;
6805                                     savepoint upd_ent;
6806                                     l_update_mode  :=  'CORRECTION';
6807                                     py_element_entry_api.update_element_entry
6808                                         (p_datetrack_update_mode        => l_update_mode
6809                                         ,p_effective_date               => p_effective_date
6810                                         ,p_business_group_id            => l_business_group_id
6811                                         ,p_element_entry_id             => l_element_entry_id
6812                                         ,p_object_version_number        => l_object_version_number
6813                                         ,p_input_value_id1              => l_input_value_id1
6814                                         ,p_entry_value1                 => l_value1
6815                                         ,p_input_value_id2              => l_input_value_id2
6816                                         ,p_entry_value2                 => l_value2
6817                                         ,p_input_value_id3              => l_input_value_id3
6818                                         ,p_entry_value3                 => l_value3
6819                                         ,p_effective_start_date         => l_effective_start_date
6820                                         ,p_effective_end_date           => l_effective_end_date
6821                                         ,p_update_warning               => l_update_warning);
6822 
6823                                          create_incentive_remark(p_pa_request_id => p_pa_request_id,
6824                                             p_effective_date => p_effective_date,
6825                                             p_category      => 'Installment '||to_char(l_element_ctr),
6826                                             p_noa_code      => '825',
6827                                             p_percent       => NULL,
6828                                             p_amount        => l_value1,
6829                                             p_payment_date  => l_value2,
6830                                             p_end_date      => NULL);
6831                                 Exception
6832                                     when others then
6833                                     rollback to upd_ent;
6834                                     raise;
6835                                 End;
6836                                 l_ctr := 0;
6837                             END IF;
6838                         END IF;
6839                     END LOOP;
6840                 END Upd_sep_incn_elements;
6841 
6842 
6843         -- Bug#4486823   RRR Changes
6844         -- This procedure processes the elements for Incentive Family.
6845         --  Depending on the user entry, the related elements will be processed.
6846         PROCEDURE process_incentive_elements(p_pa_request_id   IN ghr_pa_requests.pa_request_id%TYPE
6847                                             ,p_assignment_id   IN ghr_pa_requests.employee_assignment_id%TYPE
6848                                             ,p_effective_date  IN ghr_pa_requests.effective_date%TYPE
6849                                             ,p_payment_option  IN ghr_pa_requests.pa_incentive_payment_option%TYPE
6850                                             ,p_first_noa_code  IN ghr_pa_requests.first_noa_code%TYPE
6851                                             ,p_second_noa_code IN ghr_pa_requests.second_noa_code%TYPE
6852                                             ,p_total_amount    IN ghr_pa_requests.to_total_salary%TYPE
6853                                            ) IS
6854 
6855              Cursor c_inc_catg_details(l_pa_request_id NUMBER) IS
6856             SELECT pa_incentive_category,
6857                    pa_incentive_category_amount,
6858                    pa_incentive_category_percent,
6859                    pa_incentive_category_pmnt_dt,
6860                    pa_incentive_category_end_date
6861             FROM   ghr_pa_incentives
6862             where  pa_request_id = l_pa_request_id
6863             order by pa_incentive_category_pmnt_dt;
6864 
6865             l_installment_ctr NUMBER(10);
6866             l_payment_type    VARCHAR2(150);
6867             l_noa_code        VARCHAR2(150);
6868             l_session         ghr_history_api.g_session_var_type;
6869 
6870         BEGIN
6871 	        hr_utility.set_location('Entering process_incentive_elements'||p_pa_request_id,0);
6872             l_installment_ctr := 0;
6873             ghr_history_api.get_g_session_var(l_session);
6874             IF l_session.noa_id_correct IS NOT NULL and
6875                p_payment_option = 'H' and
6876                (p_first_noa_code = '825' OR p_second_noa_code ='825') THEN
6877                     Upd_sep_incn_elements(p_pa_request_id
6878                                             ,p_assignment_id
6879                                             ,p_effective_date
6880                                             ,p_payment_option
6881                                             ,p_first_noa_code
6882                                             ,p_second_noa_code);
6883             ELSE
6884                 FOR c_incdet_rec IN c_inc_catg_details(p_pa_request_id)
6885                 LOOP
6886                     hr_utility.set_location('Inside For Loop, Category: '||c_incdet_rec.pa_incentive_category,10);
6887                     hr_utility.set_location('Inside For Loop, NOA Code: '||p_first_noa_code,20);
6888                     hr_utility.set_location('Inside For Loop, ASG ID  : '||p_assignment_id,30);
6889                     -- This is a special case. Till now, we have never created the same element twice in a
6890                     -- single RPA action. If process_sf52_element is called, only one of these two elements
6891                     -- will be updated with both the values.And the latest values will retain. To avoid that,
6892                     -- update the elements separately here itself.
6893 
6894 
6895                     IF c_incdet_rec.pa_incentive_category = 'Biweekly' THEN
6896                         l_payment_type := c_incdet_rec.pa_incentive_category;
6897                         IF  p_first_noa_code = '815' OR
6898                             (p_first_noa_code = '002' AND p_second_noa_code = '815') THEN
6899                              ghr_element_api.process_sf52_element
6900                             (p_assignment_id        =>    p_assignment_id
6901                             ,p_element_name         =>    'Recruitment Incentive Biweekly'
6902                             ,p_input_value_name1    =>    'Biweekly Amount'
6903                             ,p_value1               =>    c_incdet_rec.pa_incentive_category_amount
6904                             ,p_input_value_name2    =>    'Total Amount'
6905                             ,p_value2               =>    p_total_amount
6906                             ,p_input_value_name3    =>    'Payment Option'
6907                             ,p_value3               =>    p_payment_option
6908                             ,p_input_value_name4    =>    'Payment Type'
6909                             ,p_value4               =>    l_payment_type
6910                             ,p_value15              =>    c_incdet_rec.pa_incentive_category_end_date
6911                             ,p_effective_date       =>    c_incdet_rec.pa_incentive_category_pmnt_dt
6912                             ,p_process_warning      =>    l_warning
6913                             );
6914                         END IF;
6915                         IF (p_first_noa_code = '816') OR
6916                             (p_first_noa_code = '002' AND p_second_noa_code = '816') THEN
6917                             ghr_element_api.process_sf52_element
6918                             (p_assignment_id        =>    p_assignment_id
6919                             ,p_element_name         =>    'Relocation Incentive Biweekly'
6920                             ,p_input_value_name1    =>    'Biweekly Amount'
6921                             ,p_value1               =>    c_incdet_rec.pa_incentive_category_amount
6922                             ,p_input_value_name2    =>    'Total Amount'
6923                             ,p_value2               =>    p_total_amount
6924                             ,p_input_value_name3    =>    'Payment Option'
6925                             ,p_value3               =>    p_payment_option
6926                             ,p_input_value_name4    =>    'Payment Type'
6927                             ,p_value4               =>    l_payment_type
6928                             ,p_value15              =>    c_incdet_rec.pa_incentive_category_end_date
6929                             ,p_effective_date       =>    c_incdet_rec.pa_incentive_category_pmnt_dt
6930                             ,p_process_warning      =>    l_warning
6931                             );
6932                         END IF;
6933 
6934                         -- Bug#3941541 Separation Incentive Elements.
6935                         IF (p_first_noa_code = '825') OR
6936                            (p_second_noa_code = '825') OR
6937                            (p_first_noa_code = '002' AND p_second_noa_code = '825') THEN
6938                             ghr_element_api.process_sf52_element
6939                             (p_assignment_id        =>    p_assignment_id
6940                             ,p_element_name         =>    'Separation Incentive Biweekly'
6941                             ,p_input_value_name1    =>    'Biweekly Amount'
6942                             ,p_value1               =>    c_incdet_rec.pa_incentive_category_amount
6943                             ,p_input_value_name2    =>    'Total Amount'
6944                             ,p_value2               =>    p_total_amount
6945                             ,p_input_value_name3    =>    'Payment Start Date'
6946                             ,p_value3               =>    c_incdet_rec.pa_incentive_category_pmnt_dt
6947                             ,p_input_value_name4    =>    'Payment End Date'
6948                             ,p_value4               =>    c_incdet_rec.pa_incentive_category_end_date
6949                             ,p_effective_date       =>    p_effective_date
6950                             ,p_process_warning      =>    l_warning
6951                             );
6952                         END IF;
6953                         -- End of Bug#3941541
6954 
6955                         IF (p_first_noa_code = '827') OR
6956                            (p_first_noa_code = '002' AND p_second_noa_code = '827') THEN
6957                            -- Bug#5039100
6958         --This code is commented for the bug#5307606
6959 /*                           IF p_payment_option = 'B' AND c_incdet_rec.pa_incentive_category_percent = 0 THEN
6960                                 ghr_element_api.process_sf52_element
6961                                 (p_assignment_id        =>    p_assignment_id
6962                                 ,p_element_name         =>    'Retention Incentive Biweekly'
6963                                 ,p_input_value_name1    =>    'Percent'
6964                                 ,p_value1               =>    c_incdet_rec.pa_incentive_category_percent
6965                                 ,p_input_value_name2    =>    'Payment Option'
6966                                 ,p_value2               =>    p_payment_option
6967                                 ,p_input_value_name3    =>    'Payment Type'
6968                                 ,p_value3               =>    l_payment_type
6969                                 ,p_effective_date       =>    c_incdet_rec.pa_incentive_category_pmnt_dt
6970                                 ,p_process_warning      =>    l_warning
6971                                 );
6972 
6973                            ELSE*/
6974         --This code is commented for the bug#5307606
6975 
6976                                 ghr_element_api.process_sf52_element
6977                                 (p_assignment_id        =>    p_assignment_id
6978                                 ,p_element_name         =>    'Retention Incentive Biweekly'
6979                                 ,p_input_value_name1    =>    'Percent'
6980                                 ,p_value1               =>    c_incdet_rec.pa_incentive_category_percent
6981                                 ,p_input_value_name2    =>    'Payment Option'
6982                                 ,p_value2               =>    p_payment_option
6983                                 ,p_input_value_name3    =>    'Payment Type'
6984                                 ,p_value3               =>    l_payment_type
6985                                 ,p_value15              =>    c_incdet_rec.pa_incentive_category_end_date
6986                                 ,p_effective_date       =>    c_incdet_rec.pa_incentive_category_pmnt_dt
6987                                 ,p_process_warning      =>    l_warning
6988                                 );
6989 --                            END IF;  --This code is commented for the bug#5307606
6990                         END IF;
6991                     ELSE
6992                         IF c_incdet_rec.pa_incentive_category = 'Installment' THEN
6993                             l_installment_ctr := l_installment_ctr + 1;
6994                             l_payment_type := c_incdet_rec.pa_incentive_category ||' '|| to_char(l_installment_ctr);
6995                         ELSE
6996                             l_payment_type := c_incdet_rec.pa_incentive_category ;
6997                         END IF;
6998                         IF  p_first_noa_code = '815' OR
6999                             (p_first_noa_code = '002' AND p_second_noa_code = '815') THEN
7000                              ghr_element_api.process_sf52_element
7001                             (p_assignment_id        =>    p_assignment_id
7002                             ,p_element_name         =>    'Recruitment Incentive Lump Sum'
7003                             ,p_input_value_name1    =>    'Percent'
7004                             ,p_value1               =>    c_incdet_rec.pa_incentive_category_percent
7005                             ,p_input_value_name2    =>    'Amount'
7006                             ,p_value2               =>    c_incdet_rec.pa_incentive_category_amount
7007                             ,p_input_value_name3    =>    'Payment Option'
7008                             ,p_value3               =>    p_payment_option
7009                             ,p_input_value_name4    =>    'Payment Type'
7010                             ,p_value4               =>    l_payment_type
7011                             ,p_effective_date       =>    c_incdet_rec.pa_incentive_category_pmnt_dt
7012                             ,p_process_warning      =>    l_warning
7013                             );
7014                         END IF;
7015                         IF (p_first_noa_code = '816') OR
7016                             (p_first_noa_code = '002' AND p_second_noa_code = '816') THEN
7017                             ghr_element_api.process_sf52_element
7018                             (p_assignment_id        =>    p_assignment_id
7019                             ,p_element_name         =>    'Relocation Incentive Lump Sum'
7020                             ,p_input_value_name1    =>    'Percent'
7021                             ,p_value1               =>    c_incdet_rec.pa_incentive_category_percent
7022                             ,p_input_value_name2    =>    'Amount'
7023                             ,p_value2               =>    c_incdet_rec.pa_incentive_category_amount
7024                             ,p_input_value_name3    =>    'Payment Option'
7025                             ,p_value3               =>    p_payment_option
7026                             ,p_input_value_name4    =>    'Payment Type'
7027                             ,p_value4               =>    l_payment_type
7028                             ,p_effective_date       =>    c_incdet_rec.pa_incentive_category_pmnt_dt
7029                             ,p_process_warning      =>    l_warning
7030                             );
7031                         END IF;
7032 
7033                          -- Bug#3941541 Separation Incentive Elements.
7034                         IF (p_first_noa_code = '825') OR
7035                            (p_second_noa_code = '825') OR
7036                            (p_first_noa_code = '002' AND p_second_noa_code = '825') THEN
7037                             ghr_element_api.process_sf52_element
7038                             (p_assignment_id        =>    p_assignment_id
7039                             ,p_element_name         =>    'Separation Incentive Lump Sum'
7040                             ,p_input_value_name1    =>    'Amount'
7041                             ,p_value1               =>    c_incdet_rec.pa_incentive_category_amount
7042                             ,p_input_value_name2    =>    'Payment Date'
7043                             ,p_value2               =>    c_incdet_rec.pa_incentive_category_pmnt_dt
7044                             ,p_input_value_name3    =>    'Payment Option'
7045                             ,p_value3               =>    p_payment_option
7046                             ,p_effective_date       =>    p_effective_date
7047                             ,p_process_warning      =>    l_warning
7048                             );
7049                         END IF;
7050                         -- End of Bug#3941541
7051 
7052                         IF (p_first_noa_code = '827') OR
7053                            (p_first_noa_code = '002' AND p_second_noa_code = '827') THEN
7054                             ghr_element_api.process_sf52_element
7055                             (p_assignment_id        =>    p_assignment_id
7056                             ,p_element_name         =>    'Retention Incentive Lump Sum'
7057                             ,p_input_value_name1    =>    'Percent'
7058                             ,p_value1               =>    c_incdet_rec.pa_incentive_category_percent
7059                             ,p_input_value_name2    =>    'Payment Option'
7060                             ,p_value2               =>    p_payment_option
7061                             ,p_input_value_name3    =>    'Payment Type'
7062                             ,p_value3               =>    l_payment_type
7063                             ,p_effective_date       =>    c_incdet_rec.pa_incentive_category_pmnt_dt
7064                             ,p_process_warning      =>    l_warning
7065                             );
7066                         END IF;
7067                     END IF;
7068                     IF p_first_noa_code IN ('001','002') THEN
7069                         l_noa_code := p_second_noa_code;
7070                     ELSE
7071                         l_noa_code := p_first_noa_code;
7072                     END IF;
7073                     create_incentive_remark(p_pa_request_id => p_pa_request_id,
7074                                             p_effective_date => p_effective_date,
7075                                             p_category      => l_payment_type,
7076                                             p_noa_code      => l_noa_code,
7077                                             p_percent       => c_incdet_rec.pa_incentive_category_percent,
7078                                             p_amount        => c_incdet_rec.pa_incentive_category_amount,
7079                                             p_payment_date  => c_incdet_rec.pa_incentive_category_pmnt_dt,
7080                                             p_end_date      => c_incdet_rec.pa_incentive_category_end_date);
7081 
7082                 END LOOP;
7083             END IF;
7084         END process_incentive_elements;
7085 
7086 Begin
7087 
7088  --
7089  -- Remember IN OUT parameter IN values
7090  --
7091  l_recruitment_bonus           := p_recruitment_bonus;
7092  l_relocation_bonus            := p_relocation_bonus;
7093  l_student_loan_repay          := p_student_loan_repay;
7094 
7095  l_gov_award                   := p_gov_award;
7096  l_entitlement                 := p_entitlement;
7097  l_foreign_lang_prof_pay       := p_foreign_lang_prof_pay;
7098  -- Bug# 3385386
7099  l_fta                         := p_fta;
7100  l_edp_pay                     := p_edp_pay;
7101  l_hazard_pay                  := p_hazard_pay;
7102  l_health_benefits             := p_health_benefits;
7103  l_danger_pay                  := p_danger_pay;
7104  l_imminent_danger_pay         := p_imminent_danger_pay;
7105  l_living_quarters_allow       := p_living_quarters_allow;
7106  l_post_diff_amt               := p_post_diff_amt;
7107  l_post_diff_percent           := p_post_diff_percent;
7108  l_sep_maintenance_allow       := p_sep_maintenance_allow;
7109  l_supplemental_post_allow     := p_supplemental_post_allow;
7110  l_temp_lodge_allow            := p_temp_lodge_allow;
7111  l_premium_pay                 := p_premium_pay;
7112  l_retirement_annuity          := p_retirement_annuity;
7113  l_severance_pay               := p_severance_pay;
7114  l_thrift_saving_plan          := p_thrift_saving_plan;
7115  l_health_ben_pre_tax          := p_health_ben_pre_tax;
7116 
7117 --
7118 --
7119   If p_pa_request_rec.first_noa_code = '866' then
7120     l_effective_date  :=   trunc(p_pa_request_rec.effective_date + 1 );
7121   Else
7122     l_effective_date  :=   trunc(p_pa_request_rec.effective_date);
7123   End if;
7124 -------Bug 5913362 -- Adding 890
7125 /**** Here for 890 date is not like 866.
7126    if p_pa_request_rec.first_noa_code = '890' AND
7127       p_pa_request_rec.input_pay_rate_determinant in ('A','B','E','F','U','V') then
7128      l_effective_date  :=   trunc(p_pa_request_rec.effective_date + 1 );
7129    Else
7130      l_effective_date  :=   trunc(p_pa_request_rec.effective_date);
7131    End if;
7132 ****/
7133 
7134   hr_utility.set_location('Entering  ' || l_proc,5);
7135   -- Processing  FEGLI
7136 
7137   --
7138   If p_pa_request_rec.fegli is not null then
7139      hr_utility.set_location(l_proc,10);
7140          -- BEN_EIT Changes Commented the following code
7141 	     -- as input value2 is moved to Benefits EIT
7142 	    /* -- Bug 3238026 Added condition for CHG_FEGLI
7143          IF (p_pa_request_rec.noa_family_code = 'CHG_FEGLI') THEN
7144                 hr_utility.set_location('Entering IF fegli',123456);
7145                   ghr_element_api.process_sf52_element
7146                 (p_assignment_id        =>      p_pa_request_rec.employee_assignment_id
7147                 ,p_element_name         =>      'FEGLI'
7148                 ,p_input_value_name1    =>      'FEGLI'
7149                         -- Bug#2759379  Added Input Value2 here.
7150                 ,p_input_value_name2    =>      'Eligibility Expiration'
7151                 ,p_value2               =>
7152                 fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_fegli.eligibility_expiration))
7153                 ,p_value1               =>      p_pa_request_rec.fegli
7154                 ,p_effective_date       =>      l_effective_date
7155                 ,p_process_warning      =>      l_warning
7156                 );
7157         ELSE
7158 	    */
7159                 hr_utility.set_location('Entering ELSE fegli',123456);
7160                   ghr_element_api.process_sf52_element
7161                 (p_assignment_id          =>    p_pa_request_rec.employee_assignment_id
7162                 ,p_element_name           =>    'FEGLI'
7163                 ,p_input_value_name1      =>    'FEGLI'
7164                 ,p_value1                 =>    p_pa_request_rec.fegli
7165                 ,p_effective_date         =>      l_effective_date
7166                 ,p_process_warning        =>    l_warning
7167                   );
7168         -- END IF;
7169         -- End Bug 3238026
7170 
7171   /* To be included after Martin Reid's element api handles the create and update warning
7172     if l_fegli_warn = FALSE then
7173        hr_utility.set_message(8301,'GHR_38141_FAIL_TO_UPD_FEGLI');
7174          hr_utility.raise_error;
7175     end if;
7176   */
7177   END IF;
7178   --
7179   -- Processing  retirement plan
7180   --
7181   If p_pa_request_rec.retirement_plan is not null then
7182       hr_utility.set_location(l_proc,20);
7183       ghr_element_api.process_sf52_element
7184         (p_assignment_id        =>      p_pa_request_rec.employee_assignment_id
7185         ,p_element_name         =>      'Retirement Plan'
7186         ,p_input_value_name1    =>      'Plan'
7187         ,p_value1                     =>         p_pa_request_rec.retirement_plan
7188         ,p_effective_date               =>      l_effective_date
7189         ,p_process_warning      =>      l_warning
7190       );
7191   --
7192      /*
7193      if l_retirement_plan_warn = FALSE then
7194         hr_utility.set_message(8301,'GHR_38142_FAIL_TO_UPD_RET_PLN');
7195           hr_utility.raise_error;
7196      end if;
7197      */
7198   end if;
7199   --
7200   --
7201   -- Processing  recruitment bonus
7202   --
7203   If p_recruitment_bonus.p_recruitment_bonus is not null or
7204      p_recruitment_bonus.p_date_recruit_exp  is not null  then
7205       hr_utility.set_location(l_proc,30);
7206       hr_utility.set_location(l_proc || p_recruitment_bonus.p_date_recruit_exp,31);
7207       hr_utility.set_location(l_proc ||to_char(p_pa_request_rec.employee_assignment_id),35);
7208       ghr_element_api.process_sf52_element
7209       (p_assignment_id          =>      p_pa_request_rec.employee_assignment_id
7210         ,p_element_name         =>      'Recruitment Bonus'
7211         ,p_input_value_name1    =>      'Amount'
7212         ,p_value1                       =>      p_recruitment_bonus.p_recruitment_bonus
7213         ,p_input_value_name2    =>      'Expiration Date'
7214         ,p_value2                       =>
7215              fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_recruitment_bonus.p_date_recruit_exp)) --AVR
7216 		  ,p_input_value_name3    =>      'Percentage'
7217         ,p_value3               =>      p_recruitment_bonus.p_percentage
7218 
7219         ,p_effective_date               =>      l_effective_date
7220         ,p_process_warning      =>      l_warning
7221       );
7222 
7223     /*
7224     if l_recruitment_bonus_warn = FALSE then
7225       hr_utility.set_message(8301,'GHR_38143_FAIL_TO_UPD_RCRT_BON');
7226         hr_utility.raise_error;
7227     end if;
7228     */
7229   end if;
7230   --
7231   -- Processing  relocation bonus
7232   --
7233   hr_utility.set_location('Rel. Bonus' || p_relocation_bonus.p_relocation_bonus,1);
7234   If p_relocation_bonus.p_relocation_bonus  is not null or
7235     p_relocation_bonus.p_date_reloc_exp    is not null  then
7236      hr_utility.set_location(l_proc,40);
7237      ghr_element_api.process_sf52_element
7238         (p_assignment_id        =>      p_pa_request_rec.employee_assignment_id
7239         ,p_element_name       =>        'Relocation Bonus'
7240         ,p_input_value_name1    =>      'Amount'
7241         ,p_value1                       =>       p_relocation_bonus.p_relocation_bonus
7242         ,p_input_value_name2    =>      'Expiration Date'
7243         ,p_value2                     =>
7244             fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_relocation_bonus.p_date_reloc_exp)) --AVR
7245 		  ,p_input_value_name3    =>      'Percentage'
7246         ,p_value3               =>      p_relocation_bonus.p_percentage
7247         ,p_effective_date               =>      l_effective_date
7248         ,p_process_warning      =>      l_warning
7249      );
7250   --
7251   /*
7252    if l_relocation_bonus_warn = FALSE then
7253       hr_utility.set_message(8301,'GHR_38144_FAIL_TO_UPD_REL_BON');
7254       hr_utility.raise_error;
7255    end if;
7256   */
7257   end if;
7258   --
7259 -- Student Loan Repayment Changes
7260   If p_pa_request_rec.first_noa_code = '817' or p_pa_request_rec.second_noa_code = '817' then
7261   If p_student_loan_repay.p_amount is not null or
7262     p_student_loan_repay.p_review_date is not null  then
7263          IF (p_student_loan_repay.p_repay_schedule = 'L') THEN
7264 	     hr_utility.set_location(l_proc,40);
7265 	     ghr_element_api.process_sf52_element
7266 		(p_assignment_id        =>      p_pa_request_rec.employee_assignment_id
7267 	        ,p_element_name       =>        'Student Loan Repayment LumpSum'
7268 		,p_input_value_name1    =>      'Amount'
7269 	        ,p_value1               =>       p_student_loan_repay.p_amount
7270 		,p_input_value_name2    =>      'Review Date'
7271 	        ,p_value2                     =>
7272 		    fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_student_loan_repay.p_review_date))
7273 	        ,p_effective_date               =>      l_effective_date
7274 		,p_process_warning      =>      l_warning
7275 	     );
7276          ELSIF (p_student_loan_repay.p_repay_schedule = 'R') THEN
7277 	     hr_utility.set_location(l_proc,40);
7278 	     ghr_element_api.process_sf52_element
7279 		(p_assignment_id        =>      p_pa_request_rec.employee_assignment_id
7280 	        ,p_element_name       =>        'Student Loan Repayment'
7281 		,p_input_value_name1    =>      'Amount'
7282 	        ,p_value1               =>       (p_student_loan_repay.p_amount)
7283 		,p_input_value_name2    =>      'Review Date'
7284 	        ,p_value2                     =>
7285 		    fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_student_loan_repay.p_review_date))
7286 	        ,p_effective_date               =>      l_effective_date
7287 		,p_process_warning      =>      l_warning
7288 	     );
7289 	 END IF;
7290   --
7291   end if;
7292  END IF;
7293  --
7294   -- processing awards_bonus
7295   --
7296   If  p_gov_award.award_flag = 'Y' then
7297      hr_utility.set_location(l_proc,50);
7298      hr_utility.set_location('Date awRd' || p_gov_award.date_award_earned,1);
7299      hr_utility.set_location('Award Agency ' || p_gov_award.award_Agency,1);
7300      hr_utility.set_location('Award Percentage ' || p_pa_request_rec.award_percentage,1);
7301      hr_utility.set_location('Date Exemp' || p_gov_award.date_exemp_award,1);
7302 -- Bug # 1061084
7303      hr_utility.set_location('Appropriation Code' || p_gov_award.award_appropriation_code,1);
7304      ghr_element_api.process_sf52_element
7305         (p_assignment_id        =>      p_pa_request_rec.employee_assignment_id
7306         ,p_element_name         => 'Federal Awards'
7307         ,p_input_value_name1    =>      'Award Agency'
7308         ,p_value1               =>       p_gov_award.award_agency
7309         ,p_input_value_name2    =>      'Award Type'
7310         ,p_value2               =>      p_gov_award.award_type
7311       ,p_input_value_name3    =>    'Amount or Hours'
7312       ,p_value3               =>    p_pa_request_rec.award_amount
7313       ,p_input_value_name4      =>      'Percentage'
7314         ,p_value4                       =>      p_pa_request_rec.award_percentage
7315         ,p_input_value_name5    =>      'Group Award'
7316         ,p_value5                     =>        p_gov_award.group_award
7317         ,p_input_value_name6    =>      'Tangible Benefit Dollars'
7318         ,p_value6                     =>        p_gov_award.tangible_benefit_dollars
7319       ,p_input_value_name8    =>    'Date Award Earned'
7320       ,p_value8               =>
7321              fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_gov_award.date_award_earned)) --AVR
7322         ,p_input_value_name9    =>      'Appropriation Code'
7323         ,p_value9                     =>        p_gov_award.award_appropriation_code
7324       ,p_input_value_name10   =>    'Date Ex Emp Award Paid'
7325       ,p_value10              =>
7326              fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_gov_award.date_exemp_award))
7327         ,p_effective_date               =>      l_effective_date
7328         ,p_process_warning      =>      l_warning
7329       );
7330   End if;
7331   --
7332   -- process entitlement
7333   --
7334   if p_entitlement.entitlement_flag = 'Y' then
7335      hr_utility.set_location(l_proc,60);
7336      ghr_element_api.process_sf52_element
7337         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7338         ,p_element_name         =>    'Entitlement'
7339         ,p_input_value_name1    =>    'Code'
7340         ,p_value1               =>    p_entitlement.entitlement_code
7341         ,p_input_value_name2    =>    'Amount or Percent'
7342         ,p_value2               =>    p_entitlement.entitlement_amt_percent
7343         ,p_effective_date       =>    l_effective_date
7344         ,p_process_warning      =>    l_warning
7345       );
7346   end if;
7347   --
7348   -- process foreign lang profiency pay
7349   --
7350   if p_foreign_lang_prof_pay.for_lang_flag = 'Y' then
7351      hr_utility.set_location(l_proc,70);
7352      ghr_element_api.process_sf52_element
7353         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7354         ,p_element_name         =>   'Foreign Lang Proficiency Pay'
7355         ,p_input_value_name1    =>    'Certification Date'
7356         ,p_value1               =>
7357          fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_foreign_lang_prof_pay.certification_date)) --AVR
7358         ,p_input_value_name2    =>    'Pay Level or Rate'
7359         ,p_value2               =>    p_foreign_lang_prof_pay.pay_level_or_rate
7360         ,p_effective_date             =>    l_effective_date
7361         ,p_process_warning      =>    l_warning
7362       );
7363   end if;
7364   --
7365   -- Bug#3385386 process foreign Transfer Allowance(FTA) element
7366   --
7367   if p_fta.fta_flag = 'Y' then
7368      hr_utility.set_location(l_proc,75);
7369      ghr_element_api.process_sf52_element
7370         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7371         ,p_element_name         =>   'Foreign Transfer Allowance'
7372         ,p_input_value_name1    =>    'Last Action Code'
7373         ,p_value1               =>     p_fta.last_action_code
7374         ,p_input_value_name2    =>    'Number Family Members'
7375         ,p_value2               =>    p_fta.number_family_members
7376         ,p_input_value_name3    =>    'Miscellaneous Expense'
7377         ,p_value3               =>    p_fta.Miscellaneous_Expense
7378         ,p_input_value_name4    =>    'Wardrobe Expense'
7379         ,p_value4               =>    p_fta.Wardrobe_Expense
7380         ,p_input_value_name5    =>    'Pre Departure Sub Expense'
7381         ,p_value5               =>    p_fta.Pre_Departure_Subs_Expense
7382         ,p_input_value_name6    =>    'Lease Penalty Expense'
7383         ,p_value6               =>   p_fta.Lease_Penalty_Expense
7384         ,p_input_value_name7    =>    'Amount'
7385         ,p_value7               =>    p_fta.amount
7386 	,p_effective_date       =>    l_effective_date
7387         ,p_process_warning      =>    l_warning
7388       );
7389   end if;
7390   --
7391   -- process edp pay
7392   --
7393   if p_edp_pay.edp_flag = 'Y' then
7394      hr_utility.set_location(l_proc,80);
7395      ghr_element_api.process_sf52_element
7396         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7397         ,p_element_name         =>    'EDP Pay'
7398         ,p_input_value_name1    =>    'Premium Pay Ind'
7399         ,p_value1               =>    p_edp_pay.premium_pay_indicator
7400         ,p_input_value_name2    =>    'EDP Type'
7401         ,p_value2               =>    p_edp_pay.edp_type
7402         ,p_effective_date       =>    l_effective_date
7403         ,p_process_warning      =>    l_warning
7404       );
7405   end if;
7406   --
7407   --
7408   -- process hazard pay
7409   --
7410   if p_hazard_pay.hazard_flag = 'Y' then
7411      hr_utility.set_location(l_proc,85);
7412      ghr_element_api.process_sf52_element
7413         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7414         ,p_element_name         =>    'Hazard Pay'
7415         ,p_input_value_name1    =>    'Premium Pay Ind'
7416         ,p_value1               =>    p_hazard_pay.premium_pay_indicator
7417         ,p_input_value_name2    =>    'Hazard Type'
7418         ,p_value2               =>    p_hazard_pay.hazard_type
7419         ,p_effective_date       =>    l_effective_date
7420         ,p_process_warning      =>    l_warning
7421       );
7422   end if;
7423   --
7424   -- process health benefits
7425   -- Sundar Benefits EIT Enhancement
7426   if p_health_benefits.health_benefits_flag = 'Y' then
7427      hr_utility.set_location(l_proc,90);
7428 	 IF ghr_utility.is_ghr_ben_fehb = 'TRUE' THEN
7429 			NULL;
7430 	 ELSE
7431 			 ghr_element_api.process_sf52_element
7432 				(p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7433 				,p_element_name         =>    'Health Benefits'
7434 				,p_input_value_name1    =>    'Enrollment'
7435 				,p_value1               =>    p_health_benefits.enrollment
7436 				,p_input_value_name2    =>    'Health Plan'
7437 				,p_value2               =>    p_health_benefits.health_plan
7438 				,p_input_value_name3    =>    'Temps Total Cost'
7439 				,p_value3               =>    p_health_benefits.temps_total_cost
7440 				,p_input_value_name4    =>    'Pre tax Waiver'
7441 				,p_value4               =>    p_health_benefits.pre_tax_waiver
7442 				,p_effective_date       =>    l_effective_date
7443 				,p_process_warning      =>    l_warning
7444 			  );
7445 	END IF; -- IF ghr_utility.is_ghr_ben_fehb THEN
7446   end if;
7447   --
7448   --
7449   -- process health benefits pre tax
7450   --
7451   if p_health_ben_pre_tax.health_ben_pre_tax_flag = 'Y' then
7452      hr_utility.set_location(l_proc,90);
7453 	 IF ghr_utility.is_ghr_ben_fehb = 'TRUE' THEN
7454 		NULL;
7455 	 ELSE
7456 			 ghr_element_api.process_sf52_element
7457 				(p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7458 				,p_element_name         =>    'Health Benefits Pre tax'
7459 				,p_input_value_name1    =>    'Enrollment'
7460 				,p_value1               =>    p_health_ben_pre_tax.enrollment
7461 				,p_input_value_name2    =>    'Health Plan'
7462 				,p_value2               =>    p_health_ben_pre_tax.health_plan
7463 				,p_input_value_name3    =>    'Temps Total Cost'
7464 				,p_value3               =>    p_health_ben_pre_tax.temps_total_cost
7465 				,p_effective_date       =>    l_effective_date
7466 				,p_process_warning      =>    l_warning
7467 			  );
7468 	  END IF; -- IF ghr_utility.is_ghr_ben_fehb = TRUE THEN
7469   end if;
7470   --
7471   -- process danger pay
7472   --
7473   if p_danger_pay.danger_flag = 'Y' then
7474      hr_utility.set_location(l_proc,100);
7475      ghr_element_api.process_sf52_element
7476         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7477         ,p_element_name         =>   'Danger Pay'
7478         ,p_input_value_name1    =>    'Last Action Code'
7479         ,p_value1               =>    p_danger_pay.last_action_code
7480         ,p_input_value_name2    =>    'Location'
7481         ,p_value2               =>    p_danger_pay.location
7482         ,p_effective_date       =>    l_effective_date
7483         ,p_process_warning      =>    l_warning
7484       );
7485   end if;
7486   --
7487   -- process imminent danger pay
7488   --
7489   if p_imminent_danger_pay.imminent_danger_flag = 'Y' then
7490      hr_utility.set_location(l_proc,110);
7491      ghr_element_api.process_sf52_element
7492         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7493         ,p_element_name         =>    'Imminent Danger Pay'
7494         ,p_input_value_name1    =>    'Amount'
7495         ,p_value1               =>    p_imminent_danger_pay.amount
7496         ,p_input_value_name2    =>    'Last Action Code'
7497         ,p_value2               =>    p_imminent_danger_pay.last_action_code
7498         ,p_input_value_name3    =>    'Location'
7499         ,p_value3               =>    p_imminent_danger_pay.location
7500         ,p_effective_date       =>    l_effective_date
7501         ,p_process_warning      =>    l_warning
7502       );
7503   end if;
7504   --
7505   -- process living_quarters_allow
7506   --
7507   if p_living_quarters_allow.living_quarters_allow_flag = 'Y' then
7508      hr_utility.set_location(l_proc,120);
7509      ghr_element_api.process_sf52_element
7510         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7511         ,p_element_name         =>    'Living Quarters Allowance'
7512         ,p_input_value_name1    =>    'Purchase Amount'
7513         ,p_value1               =>    p_living_quarters_allow.purchase_amount
7514         ,p_input_value_name2    =>    'Purchase Date'
7515         ,p_value2               =>
7516          fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_living_quarters_allow.purchase_date)) --AVR
7517         ,p_input_value_name3    =>    'Rent Amount'
7518         ,p_value3               =>    p_living_quarters_allow.rent_amount
7519         ,p_input_value_name4    =>    'Utility Amount'
7520         ,p_value4               =>    p_living_quarters_allow.utility_amount
7521         ,p_input_value_name5    =>    'Last Action Code'
7522         ,p_value5               =>    p_living_quarters_allow.last_action_code
7523         ,p_input_value_name6    =>    'Location'
7524         ,p_value6               =>    p_living_quarters_allow.location
7525         ,p_input_value_name7    =>    'Quarters Type'
7526         ,p_value7               =>    p_living_quarters_allow.quarters_type
7527         ,p_input_value_name8    =>    'Shared Percent'
7528         ,p_value8               =>    p_living_quarters_allow.shared_percent
7529         ,p_input_value_name9    =>    'Num Family Members'
7530         ,p_value9               =>    p_living_quarters_allow.no_of_family_members
7531         ,p_input_value_name10    =>   'Summer Record Ind'
7532         ,p_value10               =>   p_living_quarters_allow.summer_record_ind
7533         ,p_input_value_name11    =>   'Quarters Group'
7534         ,p_value11               =>   p_living_quarters_allow.quarters_group
7535         ,p_input_value_name12    =>   'Currency'
7536         ,p_value12               =>   p_living_quarters_allow.currency
7537         ,p_effective_date       =>    l_effective_date
7538         ,p_process_warning      =>    l_warning
7539       );
7540   end if;
7541   --
7542   -- process post differential amount
7543   --
7544   if p_post_diff_amt.post_diff_amt_flag  = 'Y' then
7545      hr_utility.set_location(l_proc,130);
7546      ghr_element_api.process_sf52_element
7547         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7548    --     ,p_element_name         =>    'Post Differential Amount' -- Bug 2645878 Elements renamed
7549         ,p_element_name         =>    'Post Allowance'
7550         ,p_input_value_name1    =>    'Amount'
7551         ,p_value1               =>    p_post_diff_amt.amount
7552         ,p_input_value_name2    =>    'Last Action Code'
7553         ,p_value2               =>    p_post_diff_amt.last_action_code
7554         ,p_input_value_name3    =>    'Location'
7555         ,p_value3               =>    p_post_diff_amt.location
7556         ,p_input_value_name4    =>    'Num Family Members'
7557         ,p_value4               =>    p_post_diff_amt.no_of_family_members
7558         ,p_effective_date       =>    l_effective_date
7559         ,p_process_warning      =>    l_warning
7560       );
7561   end if;
7562   --
7563   -- process post differential percent
7564   --
7565   if p_post_diff_percent.post_diff_percent_flag  = 'Y' then
7566      hr_utility.set_location(l_proc,140);
7567      hr_utility.set_location('subbu'||p_post_diff_percent.percent,141);
7568      hr_utility.set_location('subbu'||p_post_diff_percent.last_action_code,142);
7569      hr_utility.set_location('subbu'||p_post_diff_percent.location,143);
7570 
7571      ghr_element_api.process_sf52_element
7572         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7573 --        ,p_element_name         =>    'Post Differential Percent' -- Bug 2645878 Element renamed
7574         ,p_element_name         =>    'Post Differential'
7575         ,p_input_value_name1    =>    'Percentage'
7576         ,p_value1               =>    p_post_diff_percent.percent
7577         ,p_input_value_name2    =>    'Last Action Code'
7578         ,p_value2               =>    p_post_diff_percent.last_action_code
7579         ,p_input_value_name3    =>    'Location'
7580         ,p_value3               =>    p_post_diff_percent.location
7581         ,p_effective_date       =>    l_effective_date
7582         ,p_process_warning      =>    l_warning
7583       );
7584   end if;
7585   --
7586   -- process sep_maintenance_allow
7587   --
7588   if p_sep_maintenance_allow.sep_maint_allow_flag  = 'Y' then
7589      hr_utility.set_location(l_proc,150);
7590      ghr_element_api.process_sf52_element
7591         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7592         ,p_element_name         =>    'Separate Maintenance Allowance'
7593         ,p_input_value_name1    =>    'Amount'
7594         ,p_value1               =>    p_sep_maintenance_allow.amount
7595         ,p_input_value_name2    =>    'Last Action Code'
7596         ,p_value2               =>    p_sep_maintenance_allow.last_action_code
7597         ,p_input_value_name3    =>    'Category'
7598         ,p_value3               =>    p_sep_maintenance_allow.category
7599         ,p_effective_date       =>    l_effective_date
7600         ,p_process_warning      =>    l_warning
7601       );
7602   end if;
7603   --
7604   -- process supplemental_post_allow
7605   --
7606   if p_supplemental_post_allow.sup_post_allow_flag  = 'Y' then
7607      hr_utility.set_location(l_proc,160);
7608      ghr_element_api.process_sf52_element
7609         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7610         ,p_element_name         =>   'Supplemental Post Allowance'
7611         ,p_input_value_name1    =>    'Amount'
7612         ,p_value1               =>    p_supplemental_post_allow.amount
7613         ,p_effective_date       =>    l_effective_date
7614         ,p_process_warning      =>    l_warning
7615       );
7616   end if;
7617   --
7618   -- process temp_lodge_allow
7619   --
7620   if p_temp_lodge_allow.temp_lodge_allow_flag  = 'Y' then
7621      hr_utility.set_location(l_proc,170);
7622      ghr_element_api.process_sf52_element
7623         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7624         ,p_element_name         =>   'Temporary Lodging Allowance'
7625         ,p_input_value_name1    =>    'Allowance Type'
7626         ,p_value1               =>    p_temp_lodge_allow.allowance_type
7627         ,p_input_value_name2    =>    'Daily Rate'
7628         ,p_value2               =>    p_temp_lodge_allow.daily_rate
7629         ,p_effective_date       =>    l_effective_date
7630         ,p_process_warning      =>    l_warning
7631       );
7632   end if;
7633   --
7634   -- process premium_pay
7635   --
7636   if p_premium_pay.premium_pay_flag  = 'Y' then
7637      hr_utility.set_location(l_proc,180);
7638      ghr_element_api.process_sf52_element
7639         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7640         ,p_element_name         =>   'Premium Pay'
7641         ,p_input_value_name1    =>    'Premium Pay Ind'
7642         ,p_value1               =>    p_premium_pay.premium_pay_ind
7643         ,p_input_value_name2    =>    'Amount'
7644         ,p_value2               =>    p_premium_pay.amount
7645         ,p_effective_date       =>    l_effective_date
7646         ,p_process_warning      =>    l_warning
7647       );
7648   end if;
7649   --
7650   -- process retirement_annuity
7651   --
7652   if p_retirement_annuity.retirement_annuity_flag  = 'Y' then
7653      hr_utility.set_location(l_proc,190);
7654      ghr_element_api.process_sf52_element
7655         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7656         ,p_element_name         =>   'Retirement Annuity'
7657         ,p_input_value_name1    =>    'Sum'
7658         ,p_value1               =>    p_retirement_annuity.annuity_sum
7659         ,p_input_value_name2    =>    'Eligibility Expires'
7660         ,p_value2               =>
7661          fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_retirement_annuity.eligibility_expires)) --AVR
7662         ,p_effective_date       =>    l_effective_date
7663         ,p_process_warning      =>    l_warning
7664       );
7665   end if;
7666   --
7667   -- process severance_pay
7668   --
7669   if p_severance_pay.severance_pay_flag  = 'Y' then
7670      hr_utility.set_location(l_proc,200);
7671      ghr_element_api.process_sf52_element
7672         (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7673         ,p_element_name         =>    'Severance Pay'
7674         ,p_input_value_name1    =>    'Amount'
7675         ,p_value1               =>    p_severance_pay.amount
7676         ,p_input_value_name2    =>    'Total Entitlement Weeks'
7677         ,p_value2               =>    p_severance_pay.total_entitlement_weeks
7678         ,p_input_value_name3    =>    'Number Weeks Paid'
7679         ,p_value3               =>    p_severance_pay.number_weeks_paid
7680         ,p_input_value_name4    =>    'Weekly Amount'
7681         ,p_value4               =>    p_severance_pay.weekly_amount
7682         ,p_effective_date       =>    l_effective_date
7683         ,p_process_warning      =>    l_warning
7684       );
7685   end if;
7686   --
7687   -- process thrift_saving_plan
7688   --
7689   if p_thrift_saving_plan.tsp_flag  = 'Y' then
7690      hr_utility.set_location(l_proc,210);
7691 	 IF ghr_utility.is_ghr_ben_tsp = 'TRUE' THEN
7692 			 NULL;
7693 	 ELSE
7694              -- Bug#4582970 Removed Agncy Elig Date, Emp Elig Date values.
7695 			 ghr_element_api.process_sf52_element
7696 				(p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7697 				,p_element_name         =>  'TSP'
7698 				,p_input_value_name1    =>    'Amount'
7699 				,p_value1               =>    p_thrift_saving_plan.amount
7700 				,p_input_value_name2    =>    'Rate'
7701 				,p_value2               =>    p_thrift_saving_plan.rate
7702 				,p_input_value_name6    =>    'Status'
7703 				,p_value6               =>    p_thrift_saving_plan.status
7704 				,p_input_value_name7    =>    'Status Date'
7705 				,p_value7               =>
7706 				 fnd_date.date_to_displaydate(fnd_date.canonical_to_date(p_thrift_saving_plan.status_date)) --AVR
7707 				,p_effective_date       =>    l_effective_date
7708 				,p_process_warning      =>    l_warning
7709 			  );
7710 	  END IF; -- IF ghr_utility.is_ghr_ben_tsp
7711   end if;
7712   --
7713   --Pradeep.
7714      --Process MDDDS Special Pay
7715       if p_mddds_special_pay.mddds_special_pay_flag = 'Y' then
7716         hr_utility.set_location(l_proc,215);
7717 
7718 	--Bug 3531369
7719 	p_mddds_special_pay.amount := NVL(p_mddds_special_pay.Full_Time_Status,0) + NVL(p_mddds_special_pay.Length_of_Service,0) +
7720 					 NVL(p_mddds_special_pay.Scarce_Specialty,0) + NVL(p_mddds_special_pay.Specialty_or_Board_Cert,0) +
7721 					 NVL(p_mddds_special_pay.Geographic_Location,0) + NVL(p_mddds_special_pay.Exceptional_Qualifications,0) +
7722 					 NVL(p_mddds_special_pay.Executive_Position,0) + NVL(p_mddds_special_pay.Dentist_post_graduate_training,0);
7723         --Bug 3531369
7724         ghr_element_api.process_sf52_element
7725            (p_assignment_id        =>    p_pa_request_rec.employee_assignment_id
7726            ,p_element_name         =>    'MDDDS Special Pay'
7727            ,p_input_value_name1    =>    'Full Time Status'
7728            ,p_value1               =>    p_mddds_special_pay.Full_Time_Status
7729            ,p_input_value_name2    =>    'Length of Service'
7730            ,p_value2               =>    p_mddds_special_pay.Length_of_Service
7731            ,p_input_value_name3    =>    'Scarce Specialty'
7732            ,p_value3               =>    p_mddds_special_pay.Scarce_Specialty
7733            ,p_input_value_name4    =>    'Specialty or Board Certification'
7734            ,p_value4               =>    p_mddds_special_pay.Specialty_or_Board_Cert
7735            ,p_input_value_name5    =>    'Geographic Location'
7736            ,p_value5               =>    p_mddds_special_pay.Geographic_Location
7737            ,p_input_value_name6    =>    'Exceptional Qualifications'
7738            ,p_value6               =>    p_mddds_special_pay.Exceptional_Qualifications
7739            ,p_input_value_name7    =>    'Executive Position'
7740            ,p_value7               =>    p_mddds_special_pay.Executive_Position
7741            ,p_input_value_name8    =>    'Dentist Post Graduate Training'
7742            ,p_value8               =>    p_mddds_special_pay.Dentist_post_graduate_training
7743 	   ,p_input_value_name9    =>    'Amount'
7744            ,p_value9               =>    p_mddds_special_pay.amount
7745            ,p_input_value_name10    =>    'MDDDS Special Pay NTE Date'
7746            ,p_value10               =>    fnd_date.date_to_displaydate(p_mddds_special_pay.mddds_special_pay_date)
7747            ,p_effective_date       =>    l_effective_date
7748            ,p_process_warning      =>    l_warning
7749          );
7750      end if;
7751 
7752      --
7753      --Pradeep
7754      If p_mddds_special_pay.premium_pay_ind is not null then
7755         hr_utility.set_location(l_proc,220);
7756         ghr_element_api.process_sf52_element
7757    	   (p_assignment_id     =>    p_pa_request_rec.employee_assignment_id
7758    	   ,p_element_name      =>    'Premium Pay'
7759    	   ,p_input_value_name1 =>    'Premium Pay Ind'
7760    	   --,p_value1            =>    p_premium_pay.premium_pay_ind
7761 	   --Pradeep changed this as one EIT for both Premium pay and MD/DDS Special Pay
7762             ,p_value1            =>    p_mddds_special_pay.premium_pay_ind
7763    	   ,p_effective_date    =>    l_effective_date
7764    	   ,p_process_warning   =>    l_warning
7765    	   );
7766    end if;
7767   --
7768 
7769      --
7770      --Pradeep
7771      If p_premium_pay_ind.premium_pay_ind is not null then
7772         hr_utility.set_location(l_proc,225);
7773         ghr_element_api.process_sf52_element
7774    	   (p_assignment_id     =>    p_pa_request_rec.employee_assignment_id
7775    	   ,p_element_name      =>    'Premium Pay'
7776    	   ,p_input_value_name1 =>    'Premium Pay Ind'
7777    	   ,p_value1            =>    p_premium_pay_ind.premium_pay_ind
7778            ,p_effective_date    =>    l_effective_date
7779    	   ,p_process_warning   =>    l_warning
7780    	   );
7781      end if;
7782 
7783 
7784      -- Bug#4486823 RRR Changes
7785      -- Process Incentive elements
7786      hr_utility.set_location('first noa '||p_pa_request_rec.first_noa_code ||';second noa :'||p_pa_request_rec.second_noa_code,50);
7787      hr_utility.set_location('noa family :'||p_pa_request_rec.noa_family_code,55);
7788      IF (p_pa_request_rec.noa_family_code = 'GHR_INCENTIVE') OR
7789         (p_pa_request_rec.first_noa_code = '002' AND p_pa_request_rec.second_noa_desc like '%Incentive%') OR
7790 	(p_pa_request_rec.first_noa_code = '825' OR p_pa_request_rec.second_noa_code = '825' ) THEN
7791         hr_utility.set_location('before calling process_incentive_elements'||p_pa_request_rec.pa_request_id,10);
7792         IF p_pa_request_rec.pa_incentive_payment_option = 'B' THEN
7793             l_total_salary := p_pa_request_rec.to_total_salary;
7794         ELSE
7795             l_total_salary := NULL;
7796         END IF;
7797         process_incentive_elements(p_pa_request_id => p_pa_request_rec.pa_request_id,
7798                                    p_assignment_id => p_pa_request_rec.employee_assignment_id,
7799                                    p_effective_date => p_pa_request_rec.effective_date,
7800                                    p_payment_option => p_pa_request_rec.pa_incentive_payment_option,
7801                                    p_first_noa_code => p_pa_request_rec.first_noa_code,
7802                                    p_second_noa_code => p_pa_request_rec.second_noa_code,
7803                                    p_total_amount    => l_total_salary
7804                                    );
7805      END IF;
7806   --
7807 
7808   hr_utility.set_location('Leaving ' ||l_proc,60);
7809   --
7810   Exception when others then
7811           --
7812           -- Reset IN OUT parameters and set OUT parameters
7813           --
7814           p_recruitment_bonus           := l_recruitment_bonus;
7815           p_relocation_bonus            := l_relocation_bonus;
7816 	  p_student_loan_repay          := l_student_loan_repay;
7817           p_gov_award                   := l_gov_award;
7818           p_entitlement                 := l_entitlement;
7819           p_foreign_lang_prof_pay       := l_foreign_lang_prof_pay;
7820 	  p_fta                         := l_fta;
7821           p_edp_pay                     := l_edp_pay;
7822           p_hazard_pay                  := l_hazard_pay;
7823           p_health_benefits             := l_health_benefits;
7824           p_danger_pay                  := l_danger_pay;
7825           p_imminent_danger_pay         := l_imminent_danger_pay;
7826           p_living_quarters_allow       := l_living_quarters_allow;
7827           p_post_diff_amt               := l_post_diff_amt;
7828           p_post_diff_percent           := l_post_diff_percent;
7829           p_sep_maintenance_allow       := l_sep_maintenance_allow;
7830           p_supplemental_post_allow     := l_supplemental_post_allow;
7831           p_temp_lodge_allow            := l_temp_lodge_allow;
7832           p_premium_pay                 := l_premium_pay;
7833           p_retirement_annuity          := l_retirement_annuity;
7834           p_severance_pay               := l_severance_pay;
7835           p_thrift_saving_plan          := l_thrift_saving_plan;
7836           p_health_ben_pre_tax          := l_health_ben_pre_tax;
7837           raise;
7838 
7839 END Process_non_salary_Info;
7840 --
7841 --
7842 --
7843 Procedure get_wgi_dates
7844 (p_pa_request_rec        in      ghr_pa_requests%rowtype,
7845  p_wgi_due_date          in out nocopy  date,
7846  p_wgi_pay_date          out nocopy     date,
7847  p_retained_grade_rec    out nocopy     ghr_pay_calc.retained_grade_rec_type,
7848  p_dlei			 in date
7849 )
7850 is
7851 
7852 l_proc                varchar2(72) := 'get_wgi_dates';
7853 l_initial_wgi_due_date date;
7854 l_payroll_id          pay_payrolls_f.payroll_id%type;
7855 l_eq_pay_plan         ghr_pay_plans.pay_plan%type;
7856 l_from_step           ghr_pa_requests.to_step_or_rate%type;
7857 l_wgi_due_Date        varchar2(60);
7858 l_wgi_pay_date        date;
7859 l_wait_period         ghr_pay_plan_waiting_periods.waiting_period%type;
7860 l_pay_plan                  ghr_pay_plans.pay_plan%type;
7861 l_step_or_rate        ghr_pa_requests.to_step_or_rate%type;
7862 l_retained_grade_rec  ghr_pay_calc.retained_grade_rec_type;
7863 l_maximum_step        ghr_pa_requests.to_step_or_rate%type;
7864 l_grade_or_level      ghr_pa_requests.to_grade_or_level%type;
7865 l_user_table_id       pay_user_tables.user_table_id%TYPE;
7866 
7867 l_lei_date                    varchar2(60); -- Bug 3709414
7868 
7869 Cursor c_payroll is
7870   select rei_information3 payroll_type
7871   from   ghr_pa_request_extra_info
7872   where  pa_request_id       =   p_pa_request_rec.pa_request_id
7873   and    information_type    =   'GHR_US_PAR_PAYROLL_TYPE';
7874 
7875 Cursor c_payroll_id is
7876   select asg.payroll_id
7877   from   per_all_assignments_f asg
7878   where  asg.assignment_id = p_pa_request_rec.employee_assignment_id;
7879 
7880 Cursor   c_equiv_pay_plan  is
7881   select gpp.equivalent_pay_plan,gpp.maximum_Step
7882   from   ghr_pay_plans gpp
7883   where  gpp.pay_plan         =  l_pay_plan
7884   and    gpp.wgi_enabled_flag = 'Y';                   -- **also check for WGI enabled flag
7885                                                      -- **calculate WGI only for eligible pay_plans and PRD
7886 Cursor   c_next_step is                             -- ** WGI due date is null if the person has reached the max. step
7887   select gpw.to_step    -- l_from_step
7888   from   ghr_pay_plan_waiting_periods gpw
7889   where  gpw.from_Step  =  l_step_or_rate
7890   and    gpw.pay_plan   =  l_eq_pay_plan;  -- pay plan -????
7891 
7892 Cursor   c_waiting_period is
7893   select gpw.waiting_period   -- l_wait_period
7894   from   ghr_pay_plan_waiting_periods gpw
7895   where  gpw.pay_plan  = l_eq_pay_plan
7896   and    gpw.from_step = l_from_step; -- p_pa_request_rec.to_step_or_rate
7897 
7898 
7899 Cursor  c_next_pay_date is
7900   select ptp.start_Date
7901   from   per_time_periods ptp
7902   where  ptp.payroll_id = l_payroll_id  -- in case of p_wgi_due_date not null also get the payroll id
7903   and    ptp.start_date >= p_wgi_due_date
7904   order  by ptp.start_date asc ;
7905 
7906 --
7907 
7908 equiv_pay_plan  c_equiv_pay_plan%rowtype;
7909 
7910 Procedure get_gm_wgi_dates
7911 is
7912 
7913 l_proc         varchar2(72) := 'get_gm_wgi_dates';
7914 l_step4value   varchar2(80);
7915 l_step7value   varchar2(80);
7916 l_step10value  varchar2(80);
7917 l_dummy_date   date;
7918 l_pos_ei_data   per_position_extra_info%ROWTYPE;
7919 
7920 Begin
7921   hr_utility.set_location('entering  ' || l_proc,5);
7922   If nvl(p_pa_request_rec.pay_Rate_determinant,hr_api.g_varchar2) in ('A','B','E','F') then
7923     for next_from_step in c_next_Step loop
7924       hr_utility.set_location(l_proc,34);
7925       l_step_or_rate  := next_from_step.to_step;
7926     end loop;
7927   Else
7928    -- get the user table id for the position in all other cases .
7929     ghr_history_fetch.fetch_positionei
7930     (
7931      p_position_id         => p_pa_request_rec.to_position_id
7932     ,p_information_type    => 'GHR_US_POS_VALID_GRADE'
7933     ,p_date_effective      => p_pa_request_rec.effective_date
7934     ,p_pos_ei_data         => l_pos_ei_data
7935     );
7936   --
7937     l_user_table_id := l_pos_ei_data.poei_information5;
7938   End if;
7939   -- get table values for the given payplan.,grade or level, step or rate, pay table combination.
7940   ghr_pay_calc.get_pay_table_value
7941   (p_user_table_id     =>  l_user_table_id,
7942    p_pay_plan          =>  'GS',
7943    p_grade_or_level    =>  l_grade_or_level,
7944    p_step_or_rate      =>  '04',
7945    p_effective_date    =>  p_pa_request_rec.effective_date,
7946    p_pt_value          =>  l_step4value,
7947    p_pt_eff_start_date => l_dummy_date,
7948    p_pt_eff_end_date   => l_dummy_date
7949   );
7950   If p_pa_request_rec.to_basic_pay  < l_step4value then
7951      p_wgi_due_date :=  p_pa_request_rec.effective_date + 364;
7952   Else
7953     ghr_pay_calc.get_pay_table_value
7954     (p_user_table_id     =>  l_user_table_id,
7955      p_pay_plan          =>  'GS',
7956      p_grade_or_level    =>  l_grade_or_level,
7957      p_step_or_rate      =>  '07',
7958      p_effective_date    =>  p_pa_request_rec.effective_date,
7959      p_pt_value          =>  l_step7value,
7960      p_pt_eff_start_date => l_dummy_date,
7961      p_pt_eff_end_date   => l_dummy_date
7962     );
7963     If p_pa_request_rec.to_basic_pay between l_step4value and l_step7value then
7964       p_wgi_due_date := p_pa_request_rec.effective_date + 728;
7965     Else
7966       ghr_pay_calc.get_pay_table_value
7967       (p_user_table_id     =>  l_user_table_id,
7968        p_pay_plan          =>  'GS',
7969        p_grade_or_level    =>  l_grade_or_level,
7970        p_step_or_rate      =>  '10',
7971        p_effective_date    =>  p_pa_request_rec.effective_date,
7972        p_pt_value          =>  l_step10value,
7973        p_pt_eff_start_date => l_dummy_date,
7974        p_pt_eff_end_date   => l_dummy_date
7975        );
7976        If p_pa_request_rec.to_basic_pay < l_step10value then
7977          p_wgi_due_date := p_pa_request_rec.effective_date + 1092;
7978        Else
7979          p_wgi_due_date := Null;
7980        End if;
7981     End if;
7982  End if;
7983 End get_gm_wgi_dates;
7984 
7985 begin
7986 
7987   hr_utility.set_location('Entering   ' || l_proc,5);
7988   l_initial_wgi_due_date := p_wgi_due_date;
7989 
7990   p_wgi_pay_date := null;
7991 
7992   for payroll in c_payroll loop
7993     l_payroll_id  := payroll.payroll_type;
7994   end loop;
7995 
7996   If l_payroll_id is null then
7997     for payroll in c_payroll_id  loop
7998       l_payroll_id  :=  payroll.payroll_id;
7999     End loop;
8000   End if;
8001 
8002   If l_payroll_id is null then
8003     hr_utility.set_location(l_proc,20);
8004     hr_utility.set_message(8301,'GHR_38268_ASG_NO_PAYROLL');
8005     hr_utility.raise_error;
8006   End if;
8007 
8008   hr_utility.set_location('PAYROLLID  '  || to_char(l_payroll_id),1);
8009 
8010   -- Calculate WGI only when  PRD is one of the foll.
8011 
8012   If p_pa_request_rec.pay_rate_determinant in ('0','5','6','7','M') then
8013     l_pay_plan       := p_pa_request_rec.to_pay_plan;
8014     l_step_or_rate   := p_pa_request_rec.to_step_or_rate;
8015     l_grade_or_level := p_pa_request_rec.to_grade_or_level;
8016   Elsif p_pa_request_rec.pay_rate_determinant in ('A','B','E','F') then
8017     Begin
8018        l_retained_grade_rec :=  ghr_pc_basic_pay.get_retained_grade_details
8019                               (p_person_id       =>   p_pa_request_rec.person_id,
8020                                p_effective_date  =>   p_pa_request_rec.effective_date,
8021                                p_pa_request_id   =>   p_pa_request_rec.pa_request_id
8022                               );
8023      l_pay_plan        :=  l_retained_grade_rec.pay_plan;
8024      hr_utility.set_location('temp_step is  ' || l_retained_grade_rec.temp_step,1);
8025      If l_retained_grade_rec.temp_step is not null
8026      then
8027       l_step_or_rate    :=  l_retained_grade_rec.temp_step;
8028       l_pay_plan        :=  p_pa_request_rec.to_pay_plan; -- Fix for bug 3023252
8029       hr_utility.set_location('New Step or Rate for Ret Grd Rec. is  ' || l_step_or_rate,1);
8030       hr_utility.set_location('New pay plan is  ' || l_pay_plan,1);
8031      else
8032       l_step_or_rate    :=  l_retained_grade_rec.step_or_rate;
8033         hr_utility.set_location('New Step or Rate for Ret Grd Rec. is  ' || l_step_or_rate,2);
8034      end if; -- If l_retained_grade_rec.temp_step is not null
8035      l_grade_or_level  :=  l_retained_grade_rec.grade_or_level;
8036      l_user_table_id   :=  l_retained_grade_rec.user_table_id;
8037      If p_pa_request_rec.first_noa_code in ('867','892','893')
8038      OR p_pa_request_rec.second_noa_code in ('867','892','893') then -- Bug 3953455 added second noa code to condition
8039        -- Bug#3304788 Modified the following if condition.
8040        -- Handled the retained step and temp.step cases separately
8041         If l_retained_grade_rec.temp_step is not null then
8042             if to_number(l_retained_grade_rec.temp_step) < 9 then
8043                 p_retained_grade_rec.temp_step :=   '0' ||(l_retained_grade_rec.temp_step + 1 );
8044                 l_step_or_rate :=  p_retained_grade_rec.temp_step;
8045             ELSE
8046                 p_retained_grade_rec.temp_step :=   l_retained_grade_rec.temp_step + 1 ;
8047                 l_step_or_rate :=  p_retained_grade_rec.temp_step;
8048             END IF;
8049         ELSE -- For Retained Grade
8050             if to_number(l_retained_grade_rec.step_or_rate) < 9 then
8051                 l_step_or_rate   := '0' ||(l_retained_grade_Rec.step_or_rate + 1 );
8052             ELSE
8053                 l_step_or_rate   :=  l_retained_grade_rec.step_or_rate + 1;
8054             END IF;
8055         END IF; -- If l_retained_grade_rec.temp_step is not null
8056         hr_utility.set_location('New Step or Rate for Ret Grd Rec. is  ' || l_step_or_rate,3);
8057         hr_utility.set_location('temp_step is  ' || p_retained_grade_rec.temp_step,2);
8058         p_retained_grade_rec.step_or_rate := l_step_or_rate;
8059         p_retained_Grade_rec.person_extra_info_id := l_retained_grade_rec.person_extra_info_id;
8060      End if; --  If p_pa_request_rec.first_noa_code in ('867',
8061 
8062      Exception
8063        when  ghr_pay_calc.pay_calc_message then
8064         Null;
8065      End;
8066 
8067   Else -- else for -- If p_pa_request_rec.pay_rate_de
8068     l_pay_plan := null;
8069     p_wgi_due_date := null;
8070     p_wgi_pay_date := null;
8071   End if; -- If p_pa_request_rec.pay_rate_determinant in ('0','
8072 
8073 
8074   If l_pay_plan is not null then
8075    If p_wgi_due_date is null then
8076       hr_utility.set_location(l_proc,10);
8077       If l_pay_plan = 'GM' then
8078         get_gm_wgi_dates;
8079   --        Null;
8080       Else
8081         hr_utility.set_location(l_proc,15);
8082         -- Changed FOR LOOP, and showing error message conditionally. Dinesh Jan 12, 98
8083         open c_equiv_pay_plan;
8084         fetch c_equiv_pay_plan into equiv_pay_plan;
8085         l_eq_pay_plan  := equiv_pay_plan.equivalent_pay_plan;
8086         l_maximum_step := equiv_pay_plan.maximum_step;
8087         if c_equiv_pay_plan%FOUND then
8088           If l_eq_pay_plan is null then
8089             hr_utility.set_location(l_proc,26);
8090             hr_utility.set_message(8301,'GHR_38269_NO_EQ_PAY_PLAN');
8091             hr_utility.raise_error;
8092           End if;
8093         else
8094           hr_utility.set_location(l_proc,25);
8095           close c_equiv_pay_plan;
8096           return;
8097         end if;
8098         close c_equiv_pay_plan;
8099 
8100 
8101         hr_utility.set_location(l_proc,30);
8102 
8103         -- proceed only if the to_step_or_rate is less than the maximum step
8104 
8105         hr_utility.set_location('Step or rate ' || l_step_or_rate,1);
8106         hr_utility.set_location('Max. Step or rate ' || l_maximum_step,1);
8107         l_from_step := l_step_or_rate;
8108 
8109          If  to_number(l_step_or_rate) <  to_number(l_maximum_step) then
8110            hr_utility.set_location('step or rate less than max.   ' || l_step_or_rate,1);
8111 
8112             IF (p_pa_request_rec.first_noa_code = '892' or p_pa_request_rec.second_noa_code = '892')  AND
8113                (p_retained_grade_rec.step_or_rate not in (4,7,10)  or l_from_step not  in (4,7,10))
8114                       THEN
8115                hr_utility.set_location('Do not calc. WGI Dates for all steps in QSI ',1);
8116          -- Start of Bug 3111719
8117 	 -- Return the current WGI due date for steps other than 4,7,10 in QSI.
8118                ghr_history_fetch.fetch_element_entry_value
8119                    (p_element_name          =>  'Within Grade Increase',
8120                     p_input_value_name      =>  'Date Due',
8121                     p_assignment_id         =>  p_pa_request_rec.employee_assignment_id,
8122                     p_date_effective        =>  p_pa_request_rec.effective_date,
8123                     p_screen_entry_value    =>  l_wgi_due_date
8124                    );
8125 
8126                 p_wgi_due_date  :=   fnd_date.canonical_to_date(l_wgi_due_date);
8127          -- End of Bug 3111719.
8128 	 -- Bug 3709414 New Approach-- For 713 actions take from element entry
8129   	 -- If DLEI is entered, use that to calculate Due Date, else retain the old date
8130 	    ELSIF (p_pa_request_rec.first_noa_code  = '713'  OR p_pa_request_rec.second_noa_code  = '713') AND p_dlei IS NULL THEN
8131 		ghr_history_fetch.fetch_element_entry_value
8132 			  (p_element_name          =>  'Within Grade Increase',
8133 			   p_input_value_name      =>  'Date Due',
8134 			   p_assignment_id         =>  p_pa_request_rec.employee_assignment_id,
8135 			   p_date_effective        =>  p_pa_request_rec.effective_date,
8136 			   p_screen_entry_value    =>  l_lei_date
8137 			   );
8138 		p_wgi_due_date := fnd_date.canonical_to_date(l_lei_date);
8139             ELSE
8140                hr_utility.set_location(l_proc,40);
8141                If l_from_Step is not null then
8142                  for waiting_period in c_waiting_period loop
8143                    hr_utility.set_location(l_proc,45);
8144                    l_wait_period := waiting_period.waiting_period;
8145                  end loop;
8146                  If (p_pa_request_rec.first_noa_code = '892' or  p_pa_request_rec.second_noa_code = '892') and
8147                     (p_retained_grade_rec.step_or_rate in (4,7)  or l_from_step in (4,7)) then
8148                    -- get current WGI Due Date
8149                    ghr_history_fetch.fetch_element_entry_value
8150                    (p_element_name          =>  'Within Grade Increase',
8151                     p_input_value_name      =>  'Date Due',
8152                     p_assignment_id         =>  p_pa_request_rec.employee_assignment_id,
8153                     p_date_effective        =>  p_pa_request_rec.effective_date,
8154                     p_screen_entry_value    =>  l_wgi_due_date
8155                    );
8156 
8157                    hr_utility.set_location(l_proc,25);
8158                     p_wgi_due_date  :=   fnd_date.canonical_to_date(l_wgi_due_date) + 364;
8159 		-- If it's NOA 713 and DLEI is entered, it enters here
8160 		-- Need to use DLEI to calculate WGI due date instead of effective date
8161 		-- Code added as part of WGI Enhancments/Bug fixes
8162 		ELSIF (p_pa_request_rec.first_noa_code = '713' or  p_pa_request_rec.second_noa_code = '713') THEN
8163 			hr_utility.set_location('Entering 713 - dlei is not null',333);
8164 			p_wgi_due_date := p_dlei + l_wait_period;
8165 		-- End WGI Changes for NOA 713
8166                 ELSE
8167                    If l_wait_period is not null then
8168                      hr_utility.set_location(l_proc,26);
8169                      p_wgi_due_date  :=  p_pa_request_rec.effective_date + l_wait_period;
8170                  END IF;
8171                END IF;
8172              END IF;
8173            END IF; -- Case 892 --01/Feb
8174          Else   -- else for l_step_or_rate <  l_maximum_step
8175            -- if the employee has reached the max. step
8176            hr_utility.set_location('emp. has reached the max. step',2);
8177             p_wgi_due_date := null;  -- Venkat -- Uncommented bug #954104
8178             p_wgi_pay_date := null;
8179          End if;
8180        End if; -- GM pay plan check
8181      End if; -- WGI due date is Null
8182 
8183       hr_utility.set_location('DUE DATE ' || to_char(p_wgi_due_date),1);
8184       If p_wgi_due_date is not null then
8185         hr_utility.set_location(l_proc,55);
8186         for next_pay_date  in c_next_pay_date loop
8187           hr_utility.set_location(l_proc,60);
8188           p_wgi_pay_date :=  next_pay_date.start_date;
8189           exit;
8190          end loop;
8191       End if;
8192     hr_utility.set_location('Leaving   ' ||l_proc,65);
8193   End if;
8194 Exception when others then
8195           --
8196           -- Reset IN OUT parameters and set OUT parameters
8197           --
8198           p_wgi_due_date := l_initial_wgi_due_date;
8199           p_wgi_pay_date := null;
8200           p_retained_grade_rec := null;
8201           raise;
8202 
8203 
8204 End get_wgi_dates;
8205 --
8206 Procedure generic_update_sit
8207 (p_pa_request_rec           in   ghr_pa_requests%rowtype,
8208  p_special_information_type in   fnd_id_flex_structures_tl.id_flex_structure_name%type,
8209  p_segment_rec              in   ghr_api.special_information_type
8210 )
8211 is
8212 
8213 l_proc                  varchar2(72) := 'Generic Update  SIT';
8214 l_object_version_number per_people_f.object_version_number%type;
8215 l_session               ghr_history_api.g_session_var_type;
8216 l_multiple              varchar2(1);
8217 l_analysis_criteria_id  per_analysis_criteria.analysis_criteria_id%type;
8218 l_person_analysis_id    per_person_analyses.person_analysis_id%type;
8219 l_business_group_id     per_people_f.business_group_id%type;
8220 l_id_flex_num           fnd_id_flex_structures.id_flex_num%type;
8221 -- Bug#4054110,4069798 Added l_date_from variable
8222 l_date_from             DATE;
8223 
8224  Cursor    c_bgpid is
8225   select   business_group_id
8226   from     per_all_people_f
8227   where    person_id = p_pa_request_rec.person_id;
8228 
8229 Cursor   c_flex_num is
8230   select id_flex_num
8231   from   fnd_id_flex_structures_tl
8232   where  id_flex_structure_name =  p_special_information_type
8233   and    id_flex_code           = 'PEA'  --??
8234   and    application_id         =  800
8235   and    language               = 'US';   --??
8236 
8237 Cursor   c_multiple_occur is
8238   select multiple_occurrences_flag
8239   from   per_special_info_types sit
8240   where  business_group_id = l_business_group_id
8241   and    id_flex_num       = l_id_flex_num;
8242 
8243 -- Bug#4054110,4069798 Added cursor c_date_from to fetch the
8244 -- start date of SIT record.
8245 Cursor c_date_from is
8246 Select date_from
8247 from per_person_analyses
8248 where person_analysis_id = p_segment_rec.person_analysis_id;
8249 
8250 BEGIN
8251 
8252     hr_utility.set_location('Entering   ' || l_proc,5);
8253 
8254     for bgpid in c_bgpid loop
8255        l_business_group_id := bgpid.business_group_id;
8256     end loop;
8257 
8258     -- Get the id_flex_num
8259     for flex_num in c_flex_num loop
8260        hr_utility.set_location(l_proc,12);
8261        l_id_flex_num  :=  flex_num.id_flex_num;
8262     end loop;
8263     hr_utility.set_location(l_proc,15);
8264 
8265     for  multiple_occur in c_multiple_occur loop
8266          hr_utility.set_location(l_proc,36);
8267          l_multiple :=  multiple_occur.multiple_occurrences_flag;
8268     end loop;
8269 
8270     l_object_version_number := p_segment_rec.object_version_number;
8271     l_person_analysis_id    := p_segment_rec.person_analysis_id;
8272 
8273 
8274     if p_segment_rec.person_analysis_id is null then
8275        hr_utility.set_location(l_proc,25);
8276        begin
8277           savepoint cr_sit;
8278           hr_sit_api.create_sit
8279           (p_person_id                  => p_pa_request_rec.person_id,
8280            p_business_group_id          => l_business_group_id,
8281            p_id_flex_num                => l_id_flex_num,
8282            p_effective_date             => p_pa_request_rec.effective_date,
8283            p_date_from                  => p_pa_request_rec.effective_date,
8284            p_segment1                   => p_segment_rec.segment1,
8285            p_segment2                   => p_segment_rec.segment2,
8286            p_segment3                   => p_segment_rec.segment3,
8287            p_segment4                   => p_segment_rec.segment4,
8288            p_segment5                   => p_segment_rec.segment5,
8289            p_segment6                   => p_segment_rec.segment6,
8290            p_segment7                   => p_segment_rec.segment7,
8291            p_segment8                   => p_segment_rec.segment8,
8292            p_segment9                   => p_segment_rec.segment9,
8293            p_segment10                  => p_segment_rec.segment10,
8294            p_segment11                  => p_segment_rec.segment11,
8295            p_segment12                  => p_segment_rec.segment12,
8296            p_segment13                  => p_segment_rec.segment13,
8297            p_segment14                  => p_segment_rec.segment14,
8298            p_segment15                  => p_segment_rec.segment15,
8299            p_segment16                  => p_segment_rec.segment16,
8300            p_segment17                  => p_segment_rec.segment17,
8301            p_segment18                  => p_segment_rec.segment18,
8302            p_segment19                  => p_segment_rec.segment19,
8303            p_segment20                  => p_segment_rec.segment20,
8304            p_segment21                  => p_segment_rec.segment21,
8305            p_segment22                  => p_segment_rec.segment22,
8306            p_segment23                  => p_segment_rec.segment23,
8307            p_segment24                  => p_segment_rec.segment24,
8308            p_segment25                  => p_segment_rec.segment25,
8309            p_segment26                  => p_segment_rec.segment26,
8310            p_segment27                  => p_segment_rec.segment27,
8311            p_segment28                  => p_segment_rec.segment28,
8312            p_segment29                  => p_segment_rec.segment29,
8313            p_segment30                  => p_segment_rec.segment30,
8314            p_person_analysis_id         => l_person_analysis_id,
8315            p_pea_object_version_number  => l_object_version_number,
8316            p_analysis_criteria_id       => l_analysis_criteria_id
8317            );
8318            Exception when others then
8319            rollback to cr_sit;
8320            raise;
8321        End;
8322        hr_utility.set_location(l_proc,30);
8323     Else
8324        Begin
8325           -- Bug#4054110,4069798 Fetching the SIT start date for SIT US Fed Perf Apprisal.
8326           IF p_special_information_type = 'US Fed Perf Appraisal' THEN
8327               Open c_date_from;
8328    	      Fetch c_date_from into l_date_from;
8329 	      Close c_date_from;
8330 	  ELSE
8331 	    l_date_from := p_pa_request_rec.effective_date;
8332 	  End IF;
8333 
8334           savepoint upd_sit;
8335           hr_sit_api.update_sit
8336           (p_person_analysis_id         => p_segment_rec.person_analysis_id,
8337            p_date_from                  => l_date_from,
8338            p_segment1                   => p_segment_rec.segment1,
8339            p_segment2                   => p_segment_rec.segment2,
8340            p_segment3                   => p_segment_rec.segment3,
8341            p_segment4                   => p_segment_rec.segment4,
8342            p_segment5                   => p_segment_rec.segment5,
8343            p_segment6                   => p_segment_rec.segment6,
8344            p_segment7                   => p_segment_rec.segment7,
8345            p_segment8                   => p_segment_rec.segment8,
8346            p_segment9                   => p_segment_rec.segment9,
8347            p_segment10                  => p_segment_rec.segment10,
8348            p_segment11                  => p_segment_rec.segment11,
8349            p_segment12                  => p_segment_rec.segment12,
8350            p_segment13                  => p_segment_rec.segment13,
8351            p_segment14                  => p_segment_rec.segment14,
8352            p_segment15                  => p_segment_rec.segment15,
8353            p_segment16                  => p_segment_rec.segment16,
8354            p_segment17                  => p_segment_rec.segment17,
8355            p_segment18                  => p_segment_rec.segment18,
8356            p_segment19                  => p_segment_rec.segment19,
8357            p_segment20                  => p_segment_rec.segment20,
8358            p_segment21                  => p_segment_rec.segment21,
8359            p_segment22                  => p_segment_rec.segment22,
8360            p_segment23                  => p_segment_rec.segment23,
8361            p_segment24                  => p_segment_rec.segment24,
8362            p_segment25                  => p_segment_rec.segment25,
8363            p_segment26                  => p_segment_rec.segment26,
8364            p_segment27                  => p_segment_rec.segment27,
8365            p_segment28                  => p_segment_rec.segment28,
8366            p_segment29                  => p_segment_rec.segment29,
8367            p_segment30                  => p_segment_rec.segment30,
8368            p_analysis_criteria_id       => l_analysis_criteria_id,
8369            p_pea_object_version_number  => l_object_version_number
8370           );
8371           Exception
8372           when others then
8373                rollback to upd_sit;
8374                raise;
8375        End;
8376     End if;
8377 
8378 end; -- END OF generic_update_sit
8379 end  GHR_SF52_DO_UPDATE;