DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_NON_SF52_EXTRA_INFO

Source


1 PACKAGE BODY GHR_NON_SF52_EXTRA_INFO  AS
2 /* $Header: ghddfdef.pkb 120.80.12020000.19 2012/12/20 06:23:04 utokachi ship $ */
3 
4 g_package varchar2(33) :=  '  GHR_SF52_DDF_INFO.';
5 
6 --Begin Bug# 14514445
7 l_valid_grade_name   VARCHAR2(150);
8 l_target_grade_name   VARCHAR2(150);
9 
10 cursor grade_id(p_grade_id in varchar2) is
11 select NAME from PER_GRADES
12 where GRADE_ID = to_number(p_grade_id);
13 --End Bug# 14514445
14 
15 Procedure term_ret_grade
16 ( p_pa_request_id in ghr_pa_requests.pa_request_id%type,
17   p_person_id     in per_people_f.person_id%type,
18   p_first_noa_id  in ghr_pa_requests.first_noa_id%type,
19   p_second_noa_id  in ghr_pa_requests.second_noa_id%type,
20   p_effective_date in ghr_pa_requests.effective_date%type,
21   p_refresh_flag   in varchar2 )
22 is
23 
24     --Begin Bug 5923620
25     CURSOR GET_ASSIGNEMNT_ID IS
26         SELECT assignment_id
27         FROM per_all_assignments_f
28         WHERE person_id = p_person_id
29         AND p_effective_date between effective_start_date AND effective_end_date;
30 
31     l_assignment_id       per_assignments_f.assignment_id%type;
32     l_asg_ei_data         per_assignment_extra_info%rowtype;
33     l_session             ghr_history_api.g_session_var_type;
34     l_session1            ghr_history_api.g_session_var_type;
35     --End Bug 5923620
36 
37       l_pei_id    per_people_extra_info.person_extra_info_id%type;
38       l_rei_rec   ghr_pa_request_extra_info%rowtype ;
39       l_org_rec   ghr_pa_request_ei_shadow%rowtype;
40       l_ret_grade1 ghr_pa_request_extra_info.rei_information4%type;
41       l_noa_code  ghr_nature_of_actions.code%type;
42       l_first_noa_code  ghr_nature_of_actions.code%type;
43       l_second_noa_code  ghr_nature_of_actions.code%type;
44       l_existed   BOOLEAN := FALSE;
45       l_altered_pa_request_id ghr_pa_requests.altered_pa_request_id%type;
46       l_retained_grade_rec          ghr_pay_calc.retained_grade_rec_type;
47 
48       cursor c_noa_code(p_noa_id in ghr_pa_requests.first_noa_id%type) is
49       select code from ghr_nature_of_actions
50       where nature_of_action_id =  p_noa_id;
51 
52       Cursor c_702 is
53       SELECT pei_information1 From_Date,
54              pei_information2 To_date,
55 	     pei_information3,
56 	     pei_information4,
57 	     pei_information5,
58 	     pei_information6,
59 	     pei_information7,
60 	     pei_information8,
61 	     pei_information9,
62              person_extra_info_id
63       FROM   per_people_extra_info pei,
64               pay_user_tables put
65       WHERE  pei.person_id = p_person_id
66       AND    pei.information_type = 'GHR_US_RETAINED_GRADE'
67       AND    put.user_table_id = ghr_general.return_number(pei.pei_information6)
68       AND    NVL(fnd_date.canonical_to_date(pei.pei_information1) ,p_effective_date)
69              <= p_effective_date
70       AND     nvl(fnd_date.canonical_to_date(pei.pei_information2),p_effective_date)
71                                        >= p_effective_date
72       UNION
73       SELECT pei_information1 From_Date,
74              pei_information2 To_date,
75 	     pei_information3,
76 	     pei_information4,
77 	     pei_information5,
78 	     pei_information6,
79 	     pei_information7,
80 	     pei_information8,
81 	     pei_information9,
82              person_extra_info_id
83       FROM   per_people_extra_info pei2, ghr_pa_request_extra_info rei,
84              pay_user_tables put
85       WHERE  pei2.information_type = 'GHR_US_RETAINED_GRADE'
86       AND    rei.information_type  = 'GHR_US_PAR_TERM_RG_PROMO'
87       AND    pei2.person_extra_info_id
88                  = ghr_general.return_number(rei.rei_information3)
89       AND    (rei.rei_information5     = 'Y' or rei.rei_information5 is NULL )
90       AND    put.user_table_id
91                 = ghr_general.return_number(pei2.pei_information6)
92       AND    rei.pa_request_id        = l_altered_pa_request_id
93       order by 1;
94 
95        --Bug # 5584845
96      /* Cursor c_866(p_person_extra_info_id in
97                      per_people_extra_info.person_extra_info_id%type) is
98       SELECT pei_information1,
99               pei_information2,
100               pei_information3,
101 	      pei_information4,
102               pei_information5,
103 	      pei_information6,
104               pei_information7,
105 	      pei_information8,
106               pei_information9,
107                person_extra_info_id
108       FROM   per_people_extra_info pei
109       WHERE  pei.person_extra_info_id = p_person_extra_info_id;*/
110 
111       Cursor c_866
112           is
113       SELECT  pei_information1,
114               pei_information2,
115               pei_information3,
116 	      pei_information4,
117               pei_information5,
118 	      pei_information6,
119               pei_information7,
120 	      pei_information8,
121               pei_information9,
122               person_extra_info_id
123       FROM   per_people_extra_info pei,pay_user_tables put
124       WHERE  pei.person_id = p_person_id
125       AND    pei.information_type = 'GHR_US_RETAINED_GRADE'
126       AND    put.user_table_id    = pei.pei_information6
127       AND    p_effective_date
128              BETWEEN NVL(fnd_date.canonical_to_date(pei.pei_information1) ,p_effective_date)
129              AND NVL(fnd_date.canonical_to_date(pei.pei_information2),p_effective_date);
130 
131 
132 
133       --Bug # 5584845
134 
135       cursor c_866_rei_correct is
136       SELECT  pei_information1,
137               pei_information2,
138               pei_information3,
139 	      pei_information4,
140               pei_information5,
141 	      pei_information6,
142               pei_information7,
143 	      pei_information8,
144               pei_information9,
145                person_extra_info_id
146       FROM   per_people_extra_info pei
147       WHERE  pei.person_extra_info_id in (
148                SELECT rei_information3
149                FROM ghr_pa_request_extra_info
150                WHERE pa_request_id = l_altered_pa_request_id
151                AND information_type = 'GHR_US_PAR_TERM_RET_GRADE');
152 
153 
154       Cursor c_740_pei is
155       SELECT  pei_information1 From_Date,
156               pei_information2 To_date,
157               pei_information3 ,
158 	      pei_information4,
159               pei_information5,
160 	      pei_information6,
161 	      pei_information7,
162 	      pei_information8,
163 	      pei_information9,
164               person_extra_info_id,
165 	      null terminate_flag,
166 	      null original_rpa
167       FROM   per_people_extra_info pei,pay_user_tables put
168       WHERE  pei.person_id = p_person_id
169       AND    pei.information_type = 'GHR_US_RETAINED_GRADE'
170       AND    put.user_table_id    = pei.pei_information6
171       AND    p_effective_date
172              BETWEEN NVL(fnd_date.canonical_to_date(pei.pei_information1) ,p_effective_date)
173              AND NVL(fnd_date.canonical_to_date(pei.pei_information2),p_effective_date)
174       UNION
175       SELECT  pei_information1 From_Date,
176               pei_information2 To_date,
177               pei_information3,
178 	      pei_information4,
179               pei_information5,
180 	      pei_information6,
181 	      pei_information7,
182 	      pei_information8,
183 	      pei_information9,
184               person_extra_info_id,
185 	      rei_information5 terminate_flag,
186 	      'Original RPA' origianl_rpa
187       FROM   per_people_extra_info pei2, ghr_pa_request_extra_info rei,
188              pay_user_tables put
189       WHERE  pei2.information_type = 'GHR_US_RETAINED_GRADE'
190       AND    rei.information_type  = 'GHR_US_PAR_TERM_RG_POSN_CHG'
191       AND    pei2.person_extra_info_id
192               = ghr_general.return_number(rei.rei_information3)
193       AND    put.user_table_id
194               = ghr_general.return_number(pei2.pei_information6)
195       AND    rei.rei_information5     = 'Y'
196       AND    rei.pa_request_id        = l_altered_pa_request_id
197       order by 1;
198 
199       cursor c_740_rei is
200        select rei_information3,rei_information4
201        from ghr_pa_request_extra_info
202        where pa_request_id = p_pa_request_id
203        and information_type = 'GHR_US_PAR_TERM_RG_POSN_CHG';
204 
205       cursor c_702_rei is
206        select rei_information3,rei_information4
207        from ghr_pa_request_extra_info
208        where pa_request_id = p_pa_request_id
209        and information_type = 'GHR_US_PAR_TERM_RG_PROMO';
210 
211     cursor c_altered_par_rec is
212       select altered_pa_request_id from ghr_pa_requests
213       where pa_request_id = p_pa_request_id;
214 
215 	--Bug#4126188 Begin
216 	cursor c_position(p_pa_req_id in number) is
217 	SELECT from_position_id,to_position_id
218 	FROM ghr_pa_requests
219 	WHERE pa_request_id = p_pa_req_id;
220 
221 	l_pos_ei_data         per_position_extra_info%rowtype;
222 	l_from_position_id    ghr_pa_requests.from_position_id%type;
223 	l_to_position_id      ghr_pa_requests.to_position_id%type;
224 	l_from_poid           ghr_pa_requests.personnel_office_id%type;
225 	l_to_poid             ghr_pa_requests.personnel_office_id%type;
226 	--Bug#4126188 End
227 
228 
229     BEGIN
230        IF p_person_id IS NOT NULL THEN
231         --Begin Bug 5923620
232         FOR C_GET_ASSIGNMENNT_ID IN GET_ASSIGNEMNT_ID LOOP
233             l_assignment_id := C_GET_ASSIGNMENNT_ID.assignment_id;
234         end loop;
235         --end Bug 5923620
236          -- Get Altered PA Request ID to find out Retain Grade records
237          -- terminated in Original Action
238          for altered_par_rec in c_altered_par_rec loop
239            l_altered_pa_request_id := altered_par_rec.altered_pa_request_id;
240          end loop;
241          FOR noa_code IN c_noa_code(p_first_noa_id) LOOP
242            l_first_noa_code := noa_code.code;
243            exit;
244          END LOOP;
245          FOR noa_code IN c_noa_code(p_second_noa_id) LOOP
246            l_second_noa_code := noa_code.code;
247            exit;
248          END LOOP;
249 
250          hr_utility.set_location('first noa code '||l_first_noa_code , 1);
251          hr_utility.set_location('second noa code '||l_second_noa_code, 2);
252          IF l_first_noa_code = '002' THEN
253             l_noa_code := l_second_noa_code;
254          ELSE
255             l_noa_code := l_first_noa_code;
256          END IF;
257          hr_utility.set_location('l_noa_code is '||l_noa_code, 2);
258          -- Delete the RPA EI if there is a change in Effective Date or
259          -- Person
260          IF p_refresh_flag = 'N' THEN
261              IF (nvl(p_effective_date,hr_api.g_date)
262                 <> nvl(ghr_par_shd.g_old_rec.effective_date,hr_api.g_date)) or
263                 (nvl(p_person_id,hr_api.g_number)
264                 <> nvl(ghr_par_shd.g_old_rec.person_id,hr_api.g_number)) then
265                hr_utility.set_location('Inside the Delete IF '||l_noa_code, 2);
266                -- Delete from ghr_pa_request_extra_info
267                DELETE ghr_pa_request_extra_info
268                WHERE INFORMATION_TYPE in ( 'GHR_US_PAR_TERM_RET_GRADE',
269                                              'GHR_US_PAR_TERM_RG_PROMO',
270                                              'GHR_US_PAR_TERM_RG_POSN_CHG')
271                AND   PA_REQUEST_ID = p_pa_request_id;
272 
273                -- Delete from ghr_pa_request_ei_shadow
274                DELETE ghr_pa_request_ei_shadow
275                WHERE INFORMATION_TYPE in ( 'GHR_US_PAR_TERM_RET_GRADE',
276                                              'GHR_US_PAR_TERM_RG_PROMO',
277                                              'GHR_US_PAR_TERM_RG_POSN_CHG')
278                AND   PA_REQUEST_ID = p_pa_request_id;
279              END IF;
280          END IF;
281          IF l_noa_code IN ( '866' ,'890')  THEN
282              hr_utility.set_location('Inside the c_866 loop'||l_noa_code, 3);
283              -- Delete from ghr_pa_request_extra_info
284              DELETE ghr_pa_request_extra_info
285              WHERE INFORMATION_TYPE = 'GHR_US_PAR_TERM_RET_GRADE'
286              AND   PA_REQUEST_ID = p_pa_request_id;
287 
288              -- Delete from ghr_pa_request_ei_shadow
289              DELETE ghr_pa_request_ei_shadow
290              WHERE INFORMATION_TYPE = 'GHR_US_PAR_TERM_RET_GRADE'
291              AND   PA_REQUEST_ID = p_pa_request_id;
292 	     --8288066 Added the below or condition for dual actions
293          ELSIF l_noa_code = '702'  or (l_noa_code not in ('001','002') and l_second_noa_code  = '702') THEN
294            FOR pei_id IN c_702_rei LOOP
295              hr_utility.set_location('Inside the c_702_rei loop'||l_noa_code, 3);
296              -- Delete from ghr_pa_request_extra_info
297              DELETE ghr_pa_request_extra_info
298              WHERE INFORMATION_TYPE = 'GHR_US_PAR_TERM_RG_PROMO'
299              AND   PA_REQUEST_ID = p_pa_request_id;
300 
301              -- Delete from ghr_pa_request_ei_shadow
302              DELETE ghr_pa_request_ei_shadow
303              WHERE INFORMATION_TYPE = 'GHR_US_PAR_TERM_RG_PROMO'
304              AND   PA_REQUEST_ID = p_pa_request_id;
305              EXIT;
306            END LOOP;
307 	   --8288066 Added the below or condition for dual actions
308         ELSIF l_noa_code = '740' or (l_noa_code not in ('001','002') and l_second_noa_code  = '740') THEN
309            hr_utility.set_location('Inside the 740 processing'||l_noa_code, 3);
310            l_existed := FALSE;
311            for pei_rec in c_740_pei loop
312                hr_utility.set_location('PEI rec id'||pei_rec.person_extra_info_id, 4);
313              for rei_rec in c_740_rei loop
314                hr_utility.set_location('   REI rec id'||rei_rec.rei_information3, 5);
315                IF pei_rec.person_extra_info_id = rei_rec.rei_information3 THEN
316                  l_existed := TRUE;
317                  EXIT;
318                ELSE
319                  l_existed := FALSE;
320                END IF;
321              end loop;
322              IF not l_existed THEN
323                -- Insert into RPA Extra Info
324                l_rei_rec.rei_information3   :=  pei_rec.person_extra_info_id;
325 	       --l_rei_rec.rei_information4   :=  pei_rec.ret_grade;
326                l_rei_rec.rei_information5   :=  nvl(pei_rec.terminate_flag,'N'); -- Terminate Record
327                l_rei_rec.rei_information30  :=  pei_rec.original_rpa;
328                l_rei_rec.information_type   :=  'GHR_US_PAR_TERM_RG_POSN_CHG';
329                l_rei_rec.pa_request_id      :=  p_pa_request_id;
330 	       l_rei_rec.rei_information7   :=  pei_rec.From_Date;
331 	       l_rei_rec.rei_information8   :=  pei_rec.To_Date;
332 	       l_rei_rec.rei_information9   :=  pei_rec.pei_information3;
333 	       l_rei_rec.rei_information10   :=  pei_rec.pei_information4;
334 	       l_rei_rec.rei_information11   :=  pei_rec.pei_information5;
335 	       l_rei_rec.rei_information12  :=  pei_rec.pei_information6;
336 	       l_rei_rec.rei_information13  :=  pei_rec.pei_information8;
337 	       l_rei_rec.rei_information14  :=  pei_rec.pei_information9;
338 
339 			--Bug#4126188 Begin
340 			FOR c_posn_to_frm IN c_position(p_pa_req_id => p_pa_request_id) LOOP
341 				l_from_position_id :=c_posn_to_frm.from_position_id;
342 				l_to_position_id := c_posn_to_frm.to_position_id;
343 			END LOOP;
344 
345 			--Bug # 8340229
346       		        If l_to_position_id is null and l_first_noa_code = '002' then
347              		   for c_orig_posn in c_position(p_pa_req_id => l_altered_pa_request_id) LOOP
348 		               l_to_position_id := c_orig_posn.to_position_id;
349                   	   END LOOP;
350               		end if;
351 			ghr_history_fetch.fetch_positionei
352 			(p_position_id            =>  l_from_position_id,
353 			p_information_type       =>  'GHR_US_POS_GRP1',
354 			p_date_effective         =>  trunc(nvl(p_effective_date,sysdate)),
355 			p_pos_ei_data            =>  l_pos_ei_data
356 			);
357 			l_from_poid := l_pos_ei_data.poei_information3;
358 
359 			ghr_history_fetch.fetch_positionei
360 				(p_position_id        =>  l_to_position_id,
361 				p_information_type   =>  'GHR_US_POS_GRP1',
362 				p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
363 				p_pos_ei_data        =>  l_pos_ei_data
364 				);
365 				l_to_poid := l_pos_ei_data.poei_information3;
366 			--Begin Bug 5923620
367             IF l_from_poid = l_to_poid THEN
368 
369                 IF l_first_noa_code = '002' THEN
370                     ghr_history_api.get_g_session_var(l_session);
371                     l_session1 := l_session;
372                     l_session.noa_id_correct := NULL;
373                     ghr_history_api.reinit_g_session_var;
374                     ghr_history_api.set_g_session_var(l_session);
375                     ghr_history_fetch.fetch_asgei
376                     (p_assignment_id          => l_assignment_id,
377                     p_information_type  	  =>  'GHR_US_ASG_NON_SF52',
378                     p_date_effective         =>  p_effective_date-1,
379                     p_asg_ei_data       	  =>  l_asg_ei_data );
380 
381                     ghr_history_api.reinit_g_session_var;
382                     ghr_history_api.set_g_session_var(l_session1);
383                 ELSE
384                     ghr_history_fetch.fetch_asgei
385                     (p_assignment_id          =>  l_assignment_id,
386                     p_information_type  	  =>  'GHR_US_ASG_NON_SF52',
387                     p_date_effective         =>  p_effective_date,
388                     p_asg_ei_data       	  =>  l_asg_ei_data);
389                 END IF;
390 		set_ei(l_org_rec.rei_information15,l_asg_ei_data.aei_information3,l_rei_rec.rei_information15,'Y');
391                 --end Bug 5923620
392             ELSIF l_from_poid <> l_to_poid THEN
393                 set_ei(l_org_rec.rei_information15,fnd_date.date_to_canonical(p_effective_date),
394                 l_rei_rec.rei_information15,'Y');
395             END IF;
396 			--Bug#4126188 End
397 
398                generic_populate_extra_info
399                 (p_rei_rec    =>  l_rei_rec,
400                  p_org_rec    =>  l_org_rec,
401                  p_flag       =>  'C'
402                 );
403                l_existed := FALSE;
404              END IF;
405            end loop;
406          END IF;
407          hr_utility.set_location('Before creating RPA EI'||l_noa_code, 4);
408 	 -- 8288066 Added the below or condition for dual actions
409         IF l_noa_code = '702' or (l_noa_code not in ('001','002') and l_second_noa_code  = '702') THEN
410            FOR pei_id IN c_702 LOOP
411              hr_utility.set_location('In side creation of RPA EI'||l_noa_code, 4);
412              l_rei_rec.rei_information3   :=  pei_id.person_extra_info_id;
413              --l_rei_rec.rei_information4   :=  pei_id.ret_grade;
414              l_rei_rec.rei_information5   :=  null;
415              l_rei_rec.information_type   := 'GHR_US_PAR_TERM_RG_PROMO';
416              l_rei_rec.pa_request_id      :=  p_pa_request_id;
417 	     l_rei_rec.rei_information8   :=  pei_id.From_Date;
418 	     l_rei_rec.rei_information9   :=  pei_id.To_Date;
419 	     l_rei_rec.rei_information10   :=  pei_id.pei_information3;
420 	     l_rei_rec.rei_information11   :=  pei_id.pei_information4;
421 	     l_rei_rec.rei_information12  :=  pei_id.pei_information5;
422 	     l_rei_rec.rei_information13  :=  pei_id.pei_information6;
423 	     l_rei_rec.rei_information14  :=  pei_id.pei_information8;
424 	     l_rei_rec.rei_information15  :=  pei_id.pei_information9;
425 
426 
427              generic_populate_extra_info
428             (p_rei_rec    =>  l_rei_rec,
429              p_org_rec    =>  l_org_rec,
430              p_flag       =>  'C'
431               );
432            END LOOP;
433          ELSIF l_noa_code IN ('866', '890')  THEN
434            IF l_altered_pa_request_id is not null THEN
435              FOR pei_id IN c_866_rei_correct LOOP
436                hr_utility.set_location('866 rei correct ' , 1);
437 	       l_ret_grade1 :=  pei_id.pei_information1 || '..'|| pei_id.pei_information2 ||
438               '..' || pei_id.pei_information3 || '..' || pei_id.pei_information4 ||
439               '..' || pei_id.pei_information5 || '..' || pei_id.pei_information6 ||
440               '..' || pei_id.pei_information7 || '..' || pei_id.pei_information8
441               || '..' || pei_id.pei_information9;
442                l_rei_rec.rei_information3   :=  pei_id.person_extra_info_id;
443                l_rei_rec.rei_information4   :=  l_ret_grade1;
444                l_rei_rec.rei_information5   :=  null;
445        	       l_rei_rec.rei_information6   := pei_id.pei_information1;
446        	       l_rei_rec.rei_information7   := pei_id.pei_information2;
447        	       l_rei_rec.rei_information8   := pei_id.pei_information3;
448       	       l_rei_rec.rei_information9   := pei_id.pei_information4;
449        	       l_rei_rec.rei_information10  := pei_id.pei_information5;
450        	       l_rei_rec.rei_information11  := pei_id.pei_information6;
451        	       l_rei_rec.rei_information12  := pei_id.pei_information7;
452        	       l_rei_rec.rei_information13  := pei_id.pei_information8;
453        	       l_rei_rec.rei_information14  := pei_id.pei_information9;
454                l_rei_rec.information_type   := 'GHR_US_PAR_TERM_RET_GRADE';
455                l_rei_rec.pa_request_id      := p_pa_request_id;
456                generic_populate_extra_info
457               (p_rei_rec    =>  l_rei_rec,
458                p_org_rec    =>  l_org_rec,
459                p_flag       =>  'C'
460                 );
461              END LOOP;
462            ELSE
463 			 ---------- Bug# 2569180 To avoid PL/SQL Error
464 			 BEGIN
465 				 l_retained_grade_rec :=  ghr_pc_basic_pay.get_retained_grade_details
466 								  (p_person_id       =>   p_person_id,
467 								   p_effective_date  =>   p_effective_date,
468 								   p_pa_request_id   =>   p_pa_request_id
469 								  );
470 			 EXCEPTION
471 				WHEN ghr_pay_calc.pay_calc_message THEN
472 					NULL;
473 			 END;
474 			 ---------- Bug# 2569180 To avoid PL/SQL Error
475 
476              hr_utility.set_location('866 non correct ' , 2);
477               --  FOR pei_id IN c_866(l_retained_grade_rec.person_extra_info_id) LOOP
478 	     FOR pei_id IN c_866  LOOP
479 	       l_ret_grade1 := pei_id.pei_information1 || '..'|| pei_id.pei_information2 ||
480               '..' || pei_id.pei_information3 || '..' || pei_id.pei_information4 ||
481               '..' || pei_id.pei_information5 || '..' || pei_id.pei_information6 ||
482               '..' || pei_id.pei_information7 || '..' || pei_id.pei_information8
483               || '..' || pei_id.pei_information9;
484 
485                l_rei_rec.rei_information3   :=  pei_id.person_extra_info_id;
486                l_rei_rec.rei_information4   :=  l_ret_grade1;
487                l_rei_rec.rei_information5   :=  null;
488 	       l_rei_rec.rei_information6   := pei_id.pei_information1;
489        	       l_rei_rec.rei_information7   := pei_id.pei_information2;
490        	       l_rei_rec.rei_information8   := pei_id.pei_information3;
491       	       l_rei_rec.rei_information9   := pei_id.pei_information4;
492        	       l_rei_rec.rei_information10  := pei_id.pei_information5;
493        	       l_rei_rec.rei_information11  := pei_id.pei_information6;
494        	       l_rei_rec.rei_information12  := pei_id.pei_information7;
495        	       l_rei_rec.rei_information13  := pei_id.pei_information8;
496        	       l_rei_rec.rei_information14  := pei_id.pei_information9;
497                l_rei_rec.information_type   :=  'GHR_US_PAR_TERM_RET_GRADE';
498                l_rei_rec.pa_request_id      :=  p_pa_request_id;
499                generic_populate_extra_info
500                 (p_rei_rec    =>  l_rei_rec,
501                 p_org_rec    =>  l_org_rec,
502                 p_flag       =>  'C'
503                );
504              END LOOP;
505            END IF;
506          END IF;
507        END IF;
508      END term_ret_grade;
509 
510 Procedure populate_noa_spec_extra_info
511 (p_pa_request_id        in   number						,
512  p_first_noa_id         in   number 			  		,
513  p_second_noa_id        in   number 			   		,
514  p_person_id      	in   per_people_f.person_id%type 		,
515  p_assignment_id  	in   per_assignments_f.assignment_id%type ,
516  p_position_id    	in   per_positions.position_id%type 	,
517  p_effective_date 	in   ghr_pa_requests.effective_date%type 	,
518  p_refresh_flag         in   varchar2 	default 'Y'
519 )
520 is
521 l_proc                  varchar2(72) := g_package || 'populate_noa_spec_extra_info';
522 l_information_type      ghr_pa_request_extra_info.information_type%type;
523 l_dum_information_type  ghr_pa_request_extra_info.information_type%type;
524 l_flag                  varchar2(1);
525 l_rei_rec               ghr_pa_request_extra_info%rowtype;
526 l_org_rec               ghr_pa_request_ei_shadow%rowtype;
527 l_new_rei_rec           ghr_pa_request_extra_info%rowtype;
528 l_refresh_flag          varchar2(1);
529 
530 cursor c_rei_rec is
531       select rei.pa_request_extra_info_id,
532              rei.object_version_number
533       from   ghr_pa_request_extra_info rei
534       where  rei.pa_request_id    = p_pa_request_id
535       and    rei.information_type NOT IN ('GHR_US_PAR_PAYROLL_TYPE',
536                                           'GHR_US_PAR_PERF_APPRAISAL',
537                                           'GHR_US_PAR_GEN_AGENCY_DATA',
538                                           'GHR_US_PD_GEN_EMP')
539       and    rei.information_type not in
540             (Select  pit.information_type
541              from    ghr_pa_request_info_types  pit,
542                      ghr_noa_families           nfa,
543                      ghr_families               fam
544              where   nfa.nature_of_action_id  in (p_first_noa_id, p_second_noa_id)
545              and     nfa.noa_family_code      = fam.noa_family_code
546              and     fam.pa_info_type_flag    = 'Y'
547              and     pit.noa_family_code      = fam.noa_family_code);
548            ----  and     pit.information_type     LIKE 'GHR_US%');
549 
550       cursor c_noa_code(p_noa_id in ghr_pa_requests.first_noa_id%type) is
551       select code from ghr_nature_of_actions
552       where nature_of_action_id =  p_noa_id;
553 
554     cursor c_altered_par_rec is
555       select altered_pa_request_id from ghr_pa_requests
556       where pa_request_id = p_pa_request_id;
557 
558       l_noa_code  ghr_nature_of_actions.code%type;
559       l_first_noa_code  ghr_nature_of_actions.code%type;
560       l_second_noa_code  ghr_nature_of_actions.code%type;
561       l_altered_pa_request_id   ghr_pa_requests.pa_request_id%type;
562 
563  cursor c_orig_rei_rec is
564       select *
565       from   ghr_pa_request_extra_info a
566       where  a.pa_request_id    = l_altered_pa_request_id
567       and    a.information_type like 'GHR_US%'
568       and    a.information_type not in (
569        select information_type from
570         ghr_pa_request_extra_info b
571        where b.pa_request_id = p_pa_request_id );
572 
573 Begin
574   hr_utility.set_location('Entering   '  || l_proc,5);
575   FOR noa_code IN c_noa_code(p_first_noa_id) LOOP
576     l_first_noa_code := noa_code.code;
577     exit;
578   END LOOP;
579   FOR noa_code IN c_noa_code(p_second_noa_id) LOOP
580     l_second_noa_code := noa_code.code;
581     exit;
582   END LOOP;
583   hr_utility.set_location('first noa code '||l_first_noa_code , 1);
584   hr_utility.set_location('second noa code '||l_second_noa_code, 2);
585   IF l_first_noa_code = '002' THEN
586     l_noa_code := l_second_noa_code;
587   ELSE
588     l_noa_code := l_first_noa_code;
589   END IF;
590   hr_utility.set_location('l_noa_code is '||l_noa_code, 2);
591   --Added the OR condition for dual actions
592   IF (l_second_noa_code in ('702','866','890','740') and l_first_noa_code = '002' ) OR
593      l_first_noa_code in ('702','866','890','740')  OR (l_first_noa_code not in ('001','002')
594      and l_second_noa_code in ('702','866','890','740'))
595   THEN
596     -- New Processing for Termination of Retain Grade
597     -- Start
598     term_ret_grade(p_pa_request_id      => p_pa_request_id,
599                         p_person_id      => p_person_id,
600                         p_first_noa_id   => p_first_noa_id,
601                         p_second_noa_id  => p_second_noa_id,
602                         p_effective_date => p_effective_date,
603                         p_refresh_flag   =>  p_refresh_flag );
604     -- End
605   END IF;
606   If p_first_noa_id is not null then
607     hr_utility.set_location(l_proc,30);
608     hr_utility.set_location('PER ID'||p_person_id,30);
609     --
610     fetch_noa_spec_extra_info
611         (p_pa_request_id        =>  p_pa_request_id,
612          p_noa_id               =>  p_first_noa_id,
613          p_person_id            =>  p_person_id,
614          p_assignment_id        =>  p_assignment_id,
615          p_position_id          =>  p_position_id,
616          p_effective_date       =>  trunc(nvl(p_effective_date,sysdate)),
617          p_refresh_flag         =>  p_refresh_flag
618          );
619     hr_utility.set_location(l_proc,65);
620   End if;
621 
622     hr_utility.set_location('PER ID' || p_person_id,65);
623     hr_utility.set_location('Second NOa ID ' || p_second_noa_id,65);
624   If p_second_noa_id is not null then
625      --Bug#4089400 commented second-noa-code not in 702,866,740 clause
626      IF l_first_noa_code = '002'  then   --(l_second_noa_code not in ('702','866','740')) and
627          for altered_par_rec in c_altered_par_rec loop
628            l_altered_pa_request_id := altered_par_rec.altered_pa_request_id;
629          end loop;
630          hr_utility.set_location('Creation of new RPA EI Records' ,67);
631       -- Fetch the original rpa extra information and create new RPA Extra info records
632       -- with current PA request id
633          FOR orig_rei_rec IN c_orig_rei_rec LOOP
634                l_new_rei_rec := orig_rei_rec;
635                l_new_rei_rec.pa_request_id            := p_pa_request_id;
636                l_new_rei_rec.pa_request_extra_info_id := NULL;
637                hr_utility.set_location('Creation of new RPA EI Records'||l_new_rei_rec.information_type ,65);
638 	       -- Begin bug# 12572750
639 		-- Removed Detail start date and end date so passing null values to error free for previous records
640 	       IF l_new_rei_rec.information_type = 'GHR_US_PAR_DET_INFO' AND
641 		  (l_new_rei_rec.rei_information1 IS NOT NULL OR l_new_rei_rec.rei_information2 IS NOT NULL) THEN
642 		hr_utility.set_location('Nullify rei_information1 and rei_information2 '|| l_proc ,166);
643 		l_new_rei_rec.rei_information1 := NULL;
644 		l_new_rei_rec.rei_information2 := NULL;
645 	       END IF;
646 	       -- End bug# 12572750
647                generic_populate_extra_info
648               (p_rei_rec    =>  l_new_rei_rec,
649                p_org_rec    =>  l_org_rec,
650                p_flag       =>  'C'
651                 );
652           END LOOP;
653 
654   end if;
655     fetch_noa_spec_extra_info
656         (p_pa_request_id       =>  p_pa_request_id,
657          p_noa_id               =>  p_second_noa_id,
658          p_person_id            =>  p_person_id,
659          p_assignment_id        =>  p_assignment_id,
660          p_position_id          =>  p_position_id,
661          p_effective_date       =>  trunc(nvl(p_effective_date,sysdate)),
662          p_refresh_flag         =>  p_refresh_flag
663          );
664     hr_utility.set_location(l_proc,150);
665   End if;
666   --
667   -- delete all the extra info records which are not required for the new noa code
668   --
669   for rei_rec in c_rei_rec loop
670      l_rei_rec.pa_request_extra_info_id :=  rei_rec.pa_request_extra_info_id ;
671      l_rei_rec.object_version_number    :=  rei_rec.object_version_number ;
672      l_flag := 'D';
673      hr_utility.set_location(l_proc,160);
674      generic_populate_extra_info
675      (p_rei_rec    =>  l_rei_rec,
676       p_org_rec    =>  l_org_rec,
677       p_flag       =>  l_flag
678      );
679   end loop;
680 
681   --
682   hr_utility.set_location('Leaving   ' || l_proc,135);
683   --
684 End  populate_noa_spec_extra_info;
685 
686 
687 Procedure fetch_noa_spec_extra_info
688 (p_pa_request_id        in   number,
689  p_noa_id    		in   number,
690  p_person_id      	in   per_people_f.person_id%type,
691  p_assignment_id  	in   per_assignments_f.assignment_id%type,
692  p_position_id    	in   per_positions.position_id%type,
693  p_effective_date 	in   ghr_pa_requests.effective_date%type,
694  p_refresh_flag         in   varchar2 default 'Y'
695 )
696  is
697 
698  l_per_ei_data         per_people_extra_info%rowtype;
699  l_asg_ei_data         per_assignment_extra_info%rowtype;
700  l_pos_ei_data         per_position_extra_info%rowtype;
701  l_multiple_error_flag boolean;
702  l_noa_id              ghr_nature_of_actions.nature_of_action_id%type;
703  l_proc                varchar2(72):=  g_package || 'noa_spec_extra_info';
704  l_information_type    ghr_pa_request_info_types.information_type%type;
705  l_update_rei          varchar2(1) := 'N';
706  l_exists              boolean     :=  FALSE;
707  l_value               varchar2(30);
708  l_rei_rec             ghr_pa_request_extra_info%rowtype;  -- as in the ddf and then subsequently overwrittwn with data to be updated
709  l_org_rec             ghr_pa_request_ei_shadow%rowtype;  -- original from the duplicate table
710  l_old_rei_rec         ghr_pa_request_extra_info%rowtype;
711  l_flag                varchar2(1);
712  l_refresh_flag        varchar2(1);
713  l_rei_rec_exists      varchar2(1);
714  l_person_id           per_people_f.person_id%type;
715  l_assignment_id       per_assignments_f.assignment_id%type;
716  l_ret_review_date     varchar2(30);
717  l_eff_date     date;
718  l_position_id         per_positions.position_id%type;
719  l_per_refresh_flag    varchar2(1);
720  l_asg_refresh_flag    varchar2(1);
721  l_pos_refresh_flag    varchar2(1);
722  -- Bug#4089400
723  l_noa_family_code       ghr_noa_families.noa_family_code%type;
724  -- Bug#5039072 Added the following two parameters.
725  l_first_noa_code        ghr_pa_requests.first_noa_code%type;
726  l_la_code1              ghr_pa_requests.first_action_la_code1%type;
727  l_la_code2              ghr_pa_requests.first_action_la_code2%type;
728  l_sec_la_code1          ghr_pa_requests.second_action_la_code1%type;
729  l_sec_la_code2          ghr_pa_requests.second_action_la_code2%type;
730  l_payment_option        ghr_pa_requests.pa_incentive_payment_option%type;
731  l_application_id fnd_application.application_id%type;
732  l_resp_id fnd_responsibility.responsibility_id%type;
733 
734   -- Begin Bug#4126188
735  l_from_position_id    ghr_pa_requests.from_position_id%type;
736  l_to_position_id      ghr_pa_requests.to_position_id%type;
737  l_second_noa_code     ghr_pa_requests.second_noa_code%type;
738  l_from_poid           ghr_pa_requests.personnel_office_id%type;
739  l_to_poid             ghr_pa_requests.personnel_office_id%type;
740  l_session             ghr_history_api.g_session_var_type;
741  l_session1            ghr_history_api.g_session_var_type;
742 
743  CURSOR c_pa_req_2noa_dtls is
744         SELECT second_noa_code
745         FROM ghr_pa_requests
746         WHERE  pa_request_id = p_pa_request_id;
747 -- End Bug#4126188
748 
749  cursor c_rei_rec is
750       select pa_request_extra_info_id,
751              rei_information1,
752              rei_information2,
753              rei_information3,
754              rei_information4,
755              rei_information5,
756              rei_information6,
757              rei_information7,
758              rei_information8,
759              rei_information9,
760              rei_information10,
761              rei_information11,
762              rei_information12,
763 		 rei_information13,
764              rei_information14,
765              rei_information15,
766              rei_information16,
767              rei_information17,
768              rei_information18,
769              rei_information19,
770              rei_information20,
771              rei_information21,
772              rei_information22,
773 		 rei_information23,
774              rei_information24,
775              rei_information25,
776              rei_information26,
777              rei_information27,
778              rei_information28,
779              rei_information29,
780              rei_information30,
781              object_version_number
782       from   ghr_pa_request_extra_info
783       where  pa_request_id    = p_pa_request_id
784       and    information_type = l_information_type;
785 
786 cursor c_org_rei_rec is
787       select pa_request_extra_info_id,
788              rei_information1,
789              rei_information2,
790              rei_information3,
791              rei_information4,
792              rei_information5,
793              rei_information6,
794              rei_information7,
795              rei_information8,
796              rei_information9,
797              rei_information10,
798              rei_information11,
799              rei_information12,
800 		 rei_information13,
801              rei_information14,
802              rei_information15,
803              rei_information16,
804              rei_information17,
805              rei_information18,
806              rei_information19,
807              rei_information20,
808              rei_information21,
809              rei_information22,
810 		 rei_information23,
811              rei_information24,
812              rei_information25,
813              rei_information26,
814              rei_information27,
815              rei_information28,
816              rei_information29,
817              rei_information30
818       from   ghr_pa_request_ei_shadow
819       where  pa_request_extra_info_id = l_rei_rec.pa_request_extra_info_id;
820 
821    -- Bug#3941541 Added effective date condition to the cursor.
822    Cursor c_info_types(c_application_id fnd_application.application_id%type,c_resp_id fnd_responsibility.responsibility_id%type) is
823      Select  pit.information_type
824      from    ghr_pa_request_info_types  pit,
825              ghr_noa_families           nfa,
826              ghr_families               fam
827      where   nfa.nature_of_action_id  = p_noa_id
828      and     nfa.noa_family_code      = fam.noa_family_code
829      and     p_effective_date between NVL(nfa.start_date_active,p_effective_date)
830 				  and NVL(nfa.end_date_active,p_effective_date)
831      and     fam.pa_info_type_flag    = 'Y'
832      and     pit.noa_family_code      = fam.noa_family_code
833      and     pit.information_type     like 'GHR_US%'
834      --Bug#3942126 Added the following clause.
835      and     pit.active_inactive_flag = 'Y'
836 	 and      pit.information_type IN
837      (SELECT information_type
838         from per_info_type_security
839         where application_id = c_application_id
840         and responsibility_id = c_resp_id);
841 
842 
843    cursor c_get_effective_date is
844      Select effective_date
845        from ghr_pa_requests
846      where pa_request_id = p_pa_request_id;
847 
848  -- Bug#4089400
849  cursor c_noa_fam_code  is
850         select par.noa_family_code noa_family_code,
851                par.first_noa_code  first_noa_code,
852 	       par.second_noa_code  second_noa_code,
853                par.first_action_la_code1 la_code1,
854 	       par.first_action_la_code2 la_code2,
855 	       par.second_action_la_code1 sec_la_code1,
856 	       par.second_action_la_code2 sec_la_code2,
857                par.pa_incentive_payment_option payment_option
858         from   ghr_pa_requests par
859         where  pa_request_id = p_pa_request_id;
860 
861      cursor c_noac_1xx is
862         SELECT par.effective_date
863         FROM ghr_nature_of_actions noa,
864              ghr_pa_requests par,
865              ghr_pay_plans pp
866         WHERE  noa.nature_of_action_id = par.first_noa_id
867          and   par.pa_request_id = p_pa_request_id
868          and pp.pay_plan = par.to_pay_plan
869          and pp.equivalent_pay_plan in ('GS','FW')
870          and substr(noa.code,1,1) = '1'
871          AND noa.code <> '130';
872 
873      cursor c_noac_5xx is
874         SELECT par.effective_date
875         FROM ghr_nature_of_actions noa,
876              ghr_pa_requests par,
877              ghr_pay_plans pp
878         WHERE  (noa.nature_of_action_id = par.first_noa_id
879                ---Bug# 8263918
880                OR
881 	      (noa.nature_of_action_id = par.second_noa_id
882 	       and
883 	       par.first_noa_code not in ('001','002')))
884            ---Bug# 8263918
885          and   par.pa_request_id = p_pa_request_id
886          and pp.pay_plan = par.to_pay_plan
887          and pp.equivalent_pay_plan in ('GS','FW')
888          and substr(noa.code,1,1) = '5'
889          AND noa.code not in  ('542','543','546','548','549');
890 
891      cursor c_noac_130 is
892         SELECT par.effective_date
893         FROM ghr_nature_of_actions noa,
894              ghr_pa_requests par,
895              ghr_pay_plans pp
896         WHERE  noa.nature_of_action_id = par.first_noa_id
897          and   par.pa_request_id = p_pa_request_id
898          and pp.pay_plan = par.to_pay_plan
899          and pp.equivalent_pay_plan in ('GS','FW')
900          AND noa.code = '130'
901          AND par.first_action_la_code1 = 'KVM';
902 
903      cursor c_noac_sal_chg is
904        SELECT par.effective_date
905        FROM ghr_nature_of_actions noa,
906             ghr_pa_requests par,
907             ghr_pay_plans pp
908         WHERE (noa.nature_of_action_id = par.first_noa_id
909         ---Bug# 8263918
910                OR
911 	      (noa.nature_of_action_id = par.second_noa_id
912 	       and
913 	       par.first_noa_code not in ('001','002')))
914            ---Bug# 8263918
915         AND par.pa_request_id = p_pa_request_id
916         AND pp.pay_plan = par.to_pay_plan
917         AND pp.equivalent_pay_plan in ('GS','FW')
918         AND code in  ('702','703','891','893');
919 
920      -- Bug#5657744 Created the cursor
921      CURSOR c_afhr_noac_sal_chg IS
922      SELECT par.effective_date
923        FROM ghr_pa_requests par
924       WHERE par.pa_request_id = p_pa_request_id
925         AND par.first_noa_code IN  ('890','891','892','893');
926 
927 
928      cursor c_pp_and_grade is
929         SELECT to_pay_plan,to_grade_or_level,
930                from_pay_plan,from_grade_or_level
931         FROM ghr_pa_requests
932         WHERE pa_request_id = p_pa_request_id;
933 
934      -- Bug 4280026
935 cursor c_position is
936 	SELECT from_position_id,to_position_id
937 	FROM ghr_pa_requests
938 	WHERE pa_request_id = p_pa_request_id;
939 
940 
941 l_dummy                 varchar2(1);
942 l_dlei_date             date := null;
943 -- Bug#5657744
944 l_psi                   VARCHAR2(10);
945 
946 cursor c_req_num is
947    select request_number from ghr_pa_requests
948    where pa_request_id = p_pa_request_id;
949  /*Start - BUG 6129752-DATE ARRIVED PERSONNEL OFFICE CHANGING TO WRONG DATE ON CORRECTION TO PROMOTION
950 Following cursor has been added to fetch assignment id when p_assignment_id is null. */
951 
952 CURSOR GET_ASSIGNEMNT_ID IS
953 SELECT assignment_id
954 	FROM per_all_assignments_f
955 	WHERE person_id = p_person_id
956 		AND p_effective_date between effective_start_date AND effective_end_date;
957 /*End Bug -6129752 */
958 -- populate rei_information with appt_info
959 
960  Procedure appt_info is
961    Begin
962 
963    -- Read from history if person id is not null
964       hr_utility.set_location('Person inside appt_info is  ' || to_char(l_person_id),1);
965      If l_person_id is not null then
966       hr_utility.set_location('Person inside appt_info is  ' || to_char(l_person_id),1);
967           -- if the person_id is not the same as the old person_id then do the foll.
968        -- If l_person_id <> nvl(ghr_par_shd.g_old_rec.person_id,hr_api.g_number) then
969        -- a) Get PER_GROUP1 Information
970       l_refresh_flag   :=  l_per_refresh_flag;
971        ghr_history_fetch.fetch_peopleei
972        (p_person_id          =>  l_person_id,
973         p_information_type   =>  'GHR_US_PER_GROUP1',
974         p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
975         p_per_ei_data        =>  l_per_ei_data
976        );
977        --  set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information3,l_rei_rec.rei_information3,l_refresh_flag);
978 	--   l_org_rec.rei_information3  :=  l_per_ei_data.pei_information3;
979          -- Bug 1371770
980          --IF l_per_ei_data.pei_information11 is null THEN
981          --    l_rei_rec.rei_information8 := '05';
982          --ELSE
983 	 --Bug # 13581524 modified  to default '05'  in set ei itself
984              set_ei(l_org_rec.rei_information8,NVL(l_per_ei_data.pei_information11,'05'),l_rei_rec.rei_information8,l_refresh_flag);
985              l_org_rec.rei_information8  :=  NVL(l_per_ei_data.pei_information11,'05');
986      --    END IF;
987 /*
988          set_ei(l_org_rec.rei_information10,l_per_ei_data.pei_information8,l_rei_rec.rei_information10,l_refresh_flag);
989          l_org_rec.rei_information10 :=  l_per_ei_data.pei_information8;
990          set_ei(l_org_rec.rei_information11,l_per_ei_data.pei_information9,l_rei_rec.rei_information11,l_refresh_flag);
991          l_org_rec.rei_information11 :=  l_per_ei_data.pei_information9;
992 */
993          set_ei(l_org_rec.rei_information16,l_per_ei_data.pei_information5,l_rei_rec.rei_information16,l_refresh_flag);
994          l_org_rec.rei_information16 :=  l_per_ei_data.pei_information5;
995          set_ei(l_org_rec.rei_information17,l_per_ei_data.pei_information4,l_rei_rec.rei_information17,l_refresh_flag);
996          l_org_rec.rei_information17 :=  l_per_ei_data.pei_information4;
997 
998        l_per_ei_data               :=  null;
999 
1000         -- b) Get PER_UNIFORMED_SERVICES Information
1001 	--Begin Bug# 12557463, commented following and added in  proc ghr_scd_info
1002        /*
1003        ghr_history_fetch.fetch_peopleei
1004        (p_person_id          =>  l_person_id,
1005         p_information_type   =>  'GHR_US_PER_UNIFORMED_SERVICES',
1006         p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
1007         p_per_ei_data        =>  l_per_ei_data
1008        );
1009           set_ei(l_org_rec.rei_information4,l_per_ei_data.pei_information5,l_rei_rec.rei_information4,l_refresh_flag);
1010          l_org_rec.rei_information4   := l_per_ei_data.pei_information5;
1011        l_per_ei_data               :=  null;
1012        */
1013        --End Bug# 12557463
1014          -- c) Get PER_SEPARATE_RETIRE Information
1015        ghr_history_fetch.fetch_peopleei
1016        (p_person_id          =>  l_person_id,
1017         p_information_type   =>  'GHR_US_PER_SEPARATE_RETIRE',
1018         p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
1019         p_per_ei_data        =>  l_per_ei_data
1020        );
1021          hr_utility.set_location('per_sep_retire' ,1);
1022          --Begin Bug# 12557463, commented following and added in  proc ghr_scd_info
1023 	 /*set_ei(l_org_rec.rei_information7,l_per_ei_data.pei_information5,l_rei_rec.rei_information7,l_refresh_flag);
1024                   hr_utility.set_location('per_sep_retire' || l_rei_rec.rei_information7 ,2);
1025        l_org_rec.rei_information7  :=  l_per_ei_data.pei_information5;
1026        */
1027        --End Bug# 12557463
1028          set_ei(l_org_rec.rei_information14,l_per_ei_data.pei_information4,l_rei_rec.rei_information14,l_refresh_flag);
1029         l_org_rec.rei_information14 :=  l_per_ei_data.pei_information4;
1030          set_ei(l_org_rec.rei_information19,l_per_ei_data.pei_information3,l_rei_rec.rei_information19,l_refresh_flag);
1031         l_org_rec.rei_information19 :=  l_per_ei_data.pei_information3;
1032 
1033        l_per_ei_data               :=  null;
1034 
1035 
1036 
1037 
1038 
1039 
1040 
1041 
1042 
1043 	   IF ghr_utility.is_ghr_nfc = 'TRUE' THEN
1044          --  Get PER_LEAVE Information
1045 				 hr_utility.set_location('per_leave_info' ,1);
1046 			   ghr_history_fetch.fetch_peopleei
1047 			   (p_person_id          =>  l_person_id,
1048 				p_information_type   =>  'GHR_US_PER_LEAVE_INFO',
1049 				p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
1050 				p_per_ei_data        =>  l_per_ei_data
1051 			   );
1052 				--IF l_per_ei_data.pei_information4 is NULL THEN
1053 				--   l_rei_rec.rei_information20 := 'N';
1054 				--ELSE
1055 				 --Bug # 13581524 modified  to default 'N'  in set ei itself
1056 				 set_ei(l_org_rec.rei_information20,NVL(l_per_ei_data.pei_information4,'N'),l_rei_rec.rei_information20,l_refresh_flag);
1057 				--END IF;
1058 			   l_per_ei_data               :=  null;
1059 
1060 			  --Gain Or Lose
1061 				 set_ei(l_org_rec.rei_information21,'1B',l_rei_rec.rei_information21,l_refresh_flag);
1062 		END IF;
1063     End if;
1064 
1065      If l_assignment_id is not null then
1066 
1067         -- Get ASG_NON_SF52 data
1068          l_refresh_flag  := l_asg_refresh_flag;
1069          ghr_history_fetch.fetch_asgei
1070          (p_assignment_id          =>  l_assignment_id,
1071           p_information_type       =>  'GHR_US_ASG_NON_SF52',
1072           p_date_effective         =>  nvl(p_effective_date,trunc(sysdate)),
1073           p_asg_ei_data            =>  l_asg_ei_data
1074          );
1075 
1076      -- added on 02-oct-98 by skutteti to autopopulate with the effective date
1077      --  set_ei(l_org_rec.rei_information5,fnd_date.date_to_canonical(p_effective_date),
1078      --        l_rei_rec.rei_information5,l_refresh_flag);
1079      --  set_ei(l_org_rec.rei_information5,l_asg_ei_data.aei_information3,
1080      --        l_rei_rec.rei_information5,l_refresh_flag);
1081      --  l_org_rec.rei_information5   :=  l_asg_ei_data.aei_information3;
1082 
1083      --  added on 3-dec-99 -- Refer bug 963634
1084        for c_get_eff_rec in c_get_effective_date  loop
1085          set_ei(l_org_rec.rei_information5,fnd_date.date_to_canonical(c_get_eff_rec.effective_date),
1086                 l_rei_rec.rei_information5,l_refresh_flag);
1087          exit;
1088        end loop;
1089 
1090          set_ei(l_org_rec.rei_information9,l_asg_ei_data.aei_information6,l_rei_rec.rei_information9,l_refresh_flag);
1091            l_org_rec.rei_information9   :=  l_asg_ei_data.aei_information6;
1092          set_ei(l_org_rec.rei_information12,l_asg_ei_data.aei_information8,l_rei_rec.rei_information12,l_refresh_flag);
1093            l_org_rec.rei_information12  :=  l_asg_ei_data.aei_information8;
1094          set_ei(l_org_rec.rei_information15,l_asg_ei_data.aei_information9,l_rei_rec.rei_information15,l_refresh_flag);
1095            l_org_rec.rei_information15  :=  l_asg_ei_data.aei_information9;
1096          l_asg_ei_data                :=  null;
1097      End if;
1098 
1099      If l_position_id is not null then
1100         l_refresh_flag := l_pos_refresh_flag;
1101          ghr_history_fetch.fetch_positionei
1102          (p_position_id            =>  l_position_id,
1103           p_information_type       =>  'GHR_US_POS_GRP1',
1104           p_date_effective         =>  trunc(nvl(p_effective_date,sysdate)),
1105           p_pos_ei_data            =>  l_pos_ei_data
1106          );
1107          set_ei(l_org_rec.rei_information13,l_pos_ei_data.poei_information12,l_rei_rec.rei_information13,l_refresh_flag);
1108            l_org_rec.rei_information13  :=  l_pos_ei_data.poei_information12;
1109            hr_utility.set_location('posei in test ei - ' || l_pos_ei_data.poei_information12,2);
1110          l_pos_ei_data                :=  null;
1111 	--Begin Bug# 14514445
1112 	hr_utility.set_location('promotion_eligibility_date Position Id in appt_info '|| l_position_id,350);
1113 	ghr_history_fetch.fetch_positionei
1114 		(p_position_id                => l_position_id,
1115 		p_information_type           => 'GHR_US_POS_VALID_GRADE',
1116 		p_date_effective             =>  trunc(nvl(p_effective_date,sysdate)),
1117 		p_pos_ei_data                =>  l_pos_ei_data
1118 		);
1119 	FOR  grade_name in grade_id(l_pos_ei_data.poei_information3) LOOP
1120 		l_valid_grade_name := grade_name.name;
1121 		exit;
1122 	END LOOP;
1123 	FOR  grade_name in grade_id(l_pos_ei_data.poei_information4) LOOP
1124 		l_target_grade_name := grade_name.name;
1125 		exit;
1126 	END LOOP;
1127 	hr_utility.set_location('promotion_eligibility_date Valid Grade in appt_info '|| l_valid_grade_name,351);
1128 	hr_utility.set_location('promotion_eligibility_date Target Grade in appt_info '|| l_target_grade_name,352);
1129 
1130 	IF SUBSTR(l_valid_grade_name,1,2) = SUBSTR(l_target_grade_name,1,2) AND
1131 	   TO_NUMBER(SUBSTR(l_valid_grade_name,4,5)) < TO_NUMBER(SUBSTR(l_target_grade_name,4,5)) THEN
1132 	        hr_utility.set_location('promotion_eligibility_date default in appt_info '|| l_valid_grade_name,353);
1133 		set_ei(l_org_rec.rei_information28,fnd_date.date_to_canonical(p_effective_date+365),l_rei_rec.rei_information28,l_refresh_flag);
1134 	END IF;
1135 	l_pos_ei_data  :=  null;
1136 	--End Bug# 14514445
1137      End if;
1138      hr_utility.set_location('Appt_info Family Code: '||l_noa_family_code,10);
1139      IF NVL(l_noa_family_code,'C') <> 'CORRECT' THEN
1140          OPEN c_noac_1xx;
1141          FETCH c_noac_1xx INTO l_dlei_date;
1142            IF l_dlei_date is not null THEN
1143              set_ei(l_org_rec.rei_information18,
1144                fnd_date.date_to_canonical(l_dlei_date),
1145                     l_rei_rec.rei_information18,'Y');
1146            ELSE
1147              set_ei(l_org_rec.rei_information18,
1148                null,l_rei_rec.rei_information18,'Y');
1149            END IF;
1150           CLOSE c_noac_1xx;
1151       END IF;
1152       -- Bug # 12652438 Default the value to 'P'
1153       IF NVL(l_noa_family_code,'C') <> 'CORRECT' THEN
1154         set_ei(l_org_rec.rei_information24,'P',l_rei_rec.rei_information24,'Y');
1155       ELSE
1156         IF l_rei_rec.rei_information24 IS NULL THEN
1157 	   l_rei_rec.rei_information24 := 'P';
1158 	END IF;
1159       END IF;
1160 
1161       --BUG # 14276354
1162 	       l_per_ei_data := NULL;
1163        ghr_history_fetch.fetch_peopleei
1164        (p_person_id          =>  l_person_id,
1165         p_information_type   =>  'GHR_US_PER_GROUP2',
1166         p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
1167         p_per_ei_data        =>  l_per_ei_data
1168        );
1169 
1170        set_ei(l_org_rec.rei_information25,l_per_ei_data.pei_information11,l_rei_rec.rei_information25,l_refresh_flag);
1171        l_org_rec.rei_information25 :=  l_per_ei_data.pei_information11;
1172        set_ei(l_org_rec.rei_information26,l_per_ei_data.pei_information12,l_rei_rec.rei_information26,l_refresh_flag);
1173        l_org_rec.rei_information26 :=  l_per_ei_data.pei_information12;
1174        set_ei(l_org_rec.rei_information27,l_per_ei_data.pei_information13,l_rei_rec.rei_information27,l_refresh_flag);
1175        l_org_rec.rei_information27 :=  l_per_ei_data.pei_information13;
1176       --BUG # 14276354
1177 
1178    End appt_info;
1179 
1180 Procedure appt_benefits is
1181       l_tenure   ghr_pa_requests.tenure%type;
1182       l_retirement_plan ghr_pa_requests.retirement_plan%type;
1183       l_noa_code  ghr_pa_requests.first_noa_code%type;
1184       l_fegli    ghr_pa_requests.fegli%type;
1185       l_prev_fegli    ghr_pa_requests.fegli%type;
1186       l_scd      ghr_pa_requests.SERVICE_COMP_DATE%type;
1187       l_payroll_id pay_payrolls_f.payroll_id%type;
1188       l_pa_request_id ghr_pa_requests.pa_request_id%type;
1189       l_effective_date ghr_pa_requests.effective_date%type;
1190       l_start_date per_time_periods.start_date%type;
1191 	  l_family_code ghr_pa_requests.noa_family_code%type;
1192 	  l_new_element_name pay_element_types_f.element_name%type;
1193 	  l_bus_group_id per_all_people_f.business_group_id%type;
1194 	  l_fehb_exists BOOLEAN;
1195 	  l_tsp_exists BOOLEAN;
1196 	  l_health_plan pay_element_entry_values_f.screen_entry_value%type;
1197 	  l_enrollment_option pay_element_entry_values_f.screen_entry_value%type;
1198 	  l_pre_tax_waiver pay_element_entry_values_f.screen_entry_value%type;
1199 	  l_date_temp_elig date;
1200 	  l_tsp_status pay_element_entry_values_f.screen_entry_value%type;
1201 	  l_tsp_status_date date;
1202 	  l_agency_contrib_date date;
1203 	  l_second_noa_code ghr_pa_requests.second_noa_code%type;
1204      --8793163
1205      l_second_noa_id   ghr_pa_requests.second_noa_id%type;
1206      l_second_noa_family_code ghr_pa_requests.noa_family_code%type;
1207       --8793163
1208 
1209      CURSOR c_pa_req_details is
1210         SELECT *
1211         FROM ghr_pa_requests
1212         WHERE  pa_request_id = p_pa_request_id;
1213 
1214 	 CURSOR c_payroll_id(c_pa_request_id ghr_pa_requests.pa_request_id%type) IS
1215 	SELECT rei_information3 payroll_id
1216 	  FROM   ghr_pa_request_extra_info
1217 	  WHERE  pa_request_id       =   c_pa_request_id
1218 	  AND    information_type    =   'GHR_US_PAR_PAYROLL_TYPE';
1219 
1220      CURSOR c_start_date(c_payroll_id pay_payrolls_f.payroll_id%type, c_year varchar2, c_month varchar2) IS
1221         SELECT min(start_date) start_date
1222 	   FROM per_time_periods
1223 	   WHERE payroll_id = c_payroll_id
1224 	   AND TO_CHAR(start_date,'YYYY') = c_year
1225 	   AND TO_CHAR(start_date,'MM') = c_month;
1226 
1227 	CURSOR c_element_entry(c_assignment_id pay_element_entries_f.assignment_id%type,
1228 							c_element_name pay_element_types_f.element_name%type,
1229 							c_effective_date pay_element_entries_f.effective_start_date%type) IS
1230 	SELECT 1
1231 		FROM pay_element_entries_f ele
1232 		WHERE ele.assignment_id = c_assignment_id
1233 		AND c_effective_date BETWEEN ele.effective_start_date AND effective_end_date
1234 		AND ele.element_type_id = (SELECT elt.element_type_id
1235 									FROM pay_element_types_f elt
1236 									WHERE element_name = c_element_name
1237 									AND c_effective_date BETWEEN elt.effective_start_date AND elt.effective_end_date);
1238 
1239 	CURSOR c_element_value (c_element_name pay_element_types_f.element_name%type,
1240 				 c_assignment_id per_all_assignments_f.assignment_id%type,
1241 				 c_effective_date pay_element_entries_f.effective_start_date%type
1242 				 ) is
1243           SELECT a.element_name           element_name,
1244                  b.NAME                   ipv_name,
1245                  f.input_value_id         input_value_id,
1246                  e.effective_start_date   effective_start_date,
1247                  e.effective_end_date     effective_end_date,
1248                  e.element_entry_id       element_entry_id,
1249                  e.assignment_id          assignment_id,
1250                  e.object_version_number  object_version_number,
1251                  f.element_entry_value_id element_entry_value_id,
1252                  f.screen_entry_value     screen_entry_value
1253             FROM pay_element_types_f        a,
1254                  pay_input_values_f         b,
1255                  pay_element_entries_f      e,
1256                  pay_element_entry_values_f f
1257            WHERE a.element_type_id = b.element_type_id AND
1258                  e.element_type_id = a.element_type_id AND
1259                  f.element_entry_id = e.element_entry_id AND
1260                  f.input_value_id = b.input_value_id AND
1261                  e.assignment_id = c_assignment_id AND a.element_name = c_element_name AND
1262                  c_effective_date BETWEEN e.effective_start_date AND e.effective_end_date AND
1263 /*Start Bug#6082557 Added three more condition in the where clause.*/
1264                  c_effective_date BETWEEN b.effective_start_date AND b.effective_end_date AND
1265                  c_effective_date BETWEEN a.effective_start_date AND a.effective_end_date AND
1266                  c_effective_date BETWEEN f.effective_start_date AND f.effective_end_date;
1267 /*End Bug#6082557 */
1268 
1269 --Begin Bug 14062681
1270 CURSOR c_first_nte_date is
1271         SELECT first_noa_information1
1272         FROM ghr_pa_requests
1273         WHERE  pa_request_id = p_pa_request_id;
1274 
1275 l_nte_date	ghr_pa_requests.first_noa_information1%type;
1276 --End Bug 14062681
1277 
1278 
1279   BEGIN
1280        l_noa_code := NULL;
1281        FOR pa_rec in c_pa_req_details LOOP
1282          l_noa_code        := pa_rec.first_noa_code;
1283 		 l_family_code     := pa_rec.noa_family_code;
1284          l_tenure          := pa_rec.tenure;
1285          l_retirement_plan := pa_rec.retirement_plan;
1286          l_fegli           := pa_rec.fegli;
1287          l_scd             := pa_rec.service_comp_date;
1288 	     l_pa_request_id   := pa_rec.pa_request_id;
1289 	     l_effective_date  := NVL(pa_rec.effective_date,SYSDATE);
1290 		 l_person_id       := pa_rec.person_id;
1291 		 l_second_noa_code := pa_rec.second_noa_code;
1292 		 --8793163
1293 		 l_second_noa_id   := pa_rec.second_noa_id;
1294 		 l_second_noa_family_code := ghr_pa_requests_pkg.get_noa_pm_family (l_second_noa_id,p_effective_date);
1295 		 --8793163
1296        END LOOP;
1297 
1298 	   l_fehb_exists := FALSE;
1299 	   l_tsp_exists := FALSE;
1300            -- 6976435 added the below condition for defaulting health benefits for dual actions
1301    	   IF l_second_noa_code IS NULL or (l_noa_code not in ('001','002') and l_second_noa_code IS NOT NULL) THEN
1302 		IF l_family_code = 'APP' THEN
1303 
1304 		-- Date FEHB Eligibility Expires
1305 		-- Enrollment
1306 		-- Pre Tax Waiver
1307 		--- Bug# 14062681 removed noa 190 from list
1308 		   IF l_noa_code in
1309 			 ( '100', '101', '107', '108', '120',
1310 			 '124', '140', '141',
1311 			 '142', '143', '146',
1312 			 '148','170') THEN
1313 			 set_ei(l_org_rec.rei_information3,
1314 			  fnd_date.date_to_canonical(nvl(p_effective_date,sysdate)+60),
1315 			 l_rei_rec.rei_information3,'Y');
1316 			 set_ei(l_org_rec.rei_information6, 'X',
1317 			 l_rei_rec.rei_information6,'Y');
1318 		   ELSE
1319 			--- Begin Bug# 14062681
1320 			FOR l_first_nte_date IN c_first_nte_date LOOP
1321 				l_nte_date := fnd_date.canonical_to_date(l_first_nte_date.first_noa_information1);
1322 			END LOOP;
1323 			IF l_noa_code in ('115','171','190') AND l_nte_date >  p_effective_date+365 THEN
1324 				set_ei(l_org_rec.rei_information3,
1325 				fnd_date.date_to_canonical(nvl(p_effective_date,sysdate)+60),
1326 				 l_rei_rec.rei_information3,'Y');
1327 				 set_ei(l_org_rec.rei_information6, 'X',
1328 				 l_rei_rec.rei_information6,'Y');
1329 			ELSE
1330 			--- End Bug# 14062681
1331 			 set_ei(l_org_rec.rei_information3,
1332 			 NULL,l_rei_rec.rei_information3,'Y');
1333 			 set_ei(l_org_rec.rei_information6, 'Z',
1334 			 l_rei_rec.rei_information6,'Y');
1335 			END IF;--- Bug# 14062681
1336 		   END IF; -- IF l_noa_code in
1337 
1338 		   -- Pre tax waiver -- Bug 4653096
1339 			IF l_noa_code in
1340 			 ( '100', '101', '107', '108', '120',
1341 			 '124', '130','132', '140', '141',
1342 			 '142', '143', '145','146', '147',
1343 			 '148','170', '190' ) THEN
1344 				 set_ei(l_org_rec.rei_information9, 'N',
1345 				 l_rei_rec.rei_information9,'Y');
1346 			ELSE
1347 				 set_ei(l_org_rec.rei_information9,NULL,
1348 					 l_rei_rec.rei_information9,'Y');
1349 			END IF;
1350 
1351 
1352 		-- Health Plan
1353 		   set_ei(l_org_rec.rei_information5, 'ZZ',
1354 			 l_rei_rec.rei_information5,'Y');
1355 		-- Date Temp Eligibility FEHB
1356 		   IF l_noa_code in
1357 			 ( '115', '122', '149', '171') and
1358 			   nvl(l_tenure,hr_api.g_varchar2) = '0' THEN
1359 			 set_ei(l_org_rec.rei_information4,
1360 			  fnd_date.date_to_canonical(add_months(nvl(p_effective_date,TRUNC(sysdate)),12)+1),
1361 			 l_rei_rec.rei_information4,'Y');
1362 		   ELSE
1363 			 set_ei(l_org_rec.rei_information4,
1364 			 NULL,l_rei_rec.rei_information4,'Y');
1365 		   END IF; -- IF l_noa_code in Date Temp Eligibility FEHB
1366 
1367 		-- FEGLI Eligibility Expiration
1368 		--- Bug# 14062681 removed noa 171 from list
1369 		   IF nvl(l_fegli,hr_api.g_varchar2) <> 'A0' AND
1370 		   l_noa_code NOT IN ('130','132','145','147','115', '122', '149') THEN -- Bug 4669419
1371 			-- Begin Bug# 10198463
1372 			IF l_effective_date < to_date('01/10/2010','DD/MM/RRRR') THEN
1373 				set_ei(l_org_rec.rei_information10,
1374 				  fnd_date.date_to_canonical(nvl(p_effective_date,TRUNC(sysdate))+31),
1375 				 l_rei_rec.rei_information10,'Y');
1376 
1377 			 ELSE
1378 			 -- End Bug# 10198463
1379 				 set_ei(l_org_rec.rei_information10,
1380 				  fnd_date.date_to_canonical(nvl(p_effective_date,TRUNC(sysdate))+60),
1381 				 l_rei_rec.rei_information10,'Y');
1382 			 END IF; -- End Bug# 10198463
1383 		   ELSE
1384 			--- Begin Bug# 14062681
1385 			FOR l_first_nte_date IN c_first_nte_date LOOP
1386 				l_nte_date := fnd_date.canonical_to_date(l_first_nte_date.first_noa_information1);
1387 			END LOOP;
1388 			IF l_noa_code in ('171') AND l_nte_date >  p_effective_date+365 THEN
1389 				set_ei(l_org_rec.rei_information10,
1390 				  fnd_date.date_to_canonical(nvl(p_effective_date,TRUNC(sysdate))+60),
1391 				 l_rei_rec.rei_information10,'Y');
1392 			ELSE
1393 			--- End Bug# 14062681
1394 			 set_ei(l_org_rec.rei_information10,NULL,
1395 			 l_rei_rec.rei_information10,'Y');
1396 			END IF; --- Bug# 14062681
1397 		   END IF;
1398 		 -- TSP SCD
1399 		 --Begin Bug# 12557463, commented following and added in  proc ghr_scd_info
1400 			/*IF nvl(l_retirement_plan,hr_api.g_varchar2)
1401 			  in ('D','K','L','M','N','P') THEN
1402 			 set_ei(l_org_rec.rei_information12,
1403 			 fnd_date.date_to_canonical(nvl(l_scd,TRUNC(sysdate))),
1404 			 l_rei_rec.rei_information12,'Y');
1405 			ELSE
1406 			 set_ei(l_org_rec.rei_information12,NULL,
1407 			 l_rei_rec.rei_information12,'Y');
1408 			END IF; -- IF nvl(l_retirement_pl
1409 			*/
1410 		 --End Bug# 12557463
1411 		 -- TSP Rate
1412 		         --Bug# 15941036 added Retirement codes DR,KR,LR,MR,NR,PR effective from 01-Jan-2013
1413 			IF l_effective_date >= fnd_date.canonical_to_date('2013/01/01') AND l_noa_code NOT IN  ('130','132') THEN
1414 			     IF nvl(l_retirement_plan,hr_api.g_varchar2) IN ('D','K','L','M','N','P','1','3','6','C','E','F','G','R','T','H','W',
1415 			                                                     'DR','KR','LR','MR','NR','PR') AND l_tsp_status IS NULL THEN
1416 					 set_ei(l_org_rec.rei_information14,'03', l_rei_rec.rei_information14,'Y');
1417 
1418 			     END IF; -- IF nvl(l_retirement_plan,hr_api
1419 			ELSIF l_effective_date > to_date('31/07/2010','DD/MM/RRRR') AND l_noa_code NOT IN  ('130','132') THEN
1420 				IF nvl(l_retirement_plan,hr_api.g_varchar2) IN ('D','K','L','M','N','P','1','3','6','C','E','F','G','R','T','H','W') AND l_tsp_status IS NULL THEN
1421 					 set_ei(l_org_rec.rei_information14,'03', l_rei_rec.rei_information14,'Y');
1422 
1423 				END IF; -- IF nvl(l_retirement_plan,hr_api.
1424 			END IF; -- IF l_effective_date > to_date('31/07/2010','DD/MM/RRRR')
1425 
1426 		 -- TSP Status
1427 		         --Bug# 15941036 added Retirement codes DR,KR,LR,MR,NR,PR effective from 01-Jan-2013
1428 			IF l_effective_date >= fnd_date.canonical_to_date('2013/01/01') AND l_noa_code NOT IN  ('130','132') THEN
1429 				IF nvl(l_retirement_plan,hr_api.g_varchar2) IN ('D','K','L','M','N','P','1','3','6','C','E','F','G','R','T','H','W',
1430 				                                                'DR','KR','LR','MR','NR','PR') THEN
1431 					 set_ei(l_org_rec.rei_information15,'A', l_rei_rec.rei_information15,'Y');
1432 				END IF; -- IF nvl(l_retirement_plan,hr_api.
1433 			ELSIF l_effective_date > to_date('31/07/2010','DD/MM/RRRR') AND l_noa_code NOT IN  ('130','132') THEN
1434 				IF nvl(l_retirement_plan,hr_api.g_varchar2) IN ('D','K','L','M','N','P','1','3','6','C','E','F','G','R','T','H','W') THEN
1435 					 set_ei(l_org_rec.rei_information15,'A', l_rei_rec.rei_information15,'Y');
1436 				END IF; -- IF nvl(l_retirement_plan,hr_api.
1437 			ELSE
1438 				--Begin Bug# 11924967
1439 				IF l_effective_date < to_date('22/06/2009','DD/MM/RRRR') AND
1440 				   nvl(l_retirement_plan,hr_api.g_varchar2) in ('D','K','L','M','N','P') THEN
1441 				   set_ei(l_org_rec.rei_information15,'I',l_rei_rec.rei_information15,'Y');
1442 				--End Bug 11924967
1443 				ELSIF nvl(l_retirement_plan,hr_api.g_varchar2)
1444 				  in ('D','K','L','M','N','P') THEN
1445 				 set_ei(l_org_rec.rei_information15,'E',
1446 				 l_rei_rec.rei_information15,'Y');-- Bug# 8622486 modified I to E
1447 				ELSIF nvl(l_retirement_plan,hr_api.g_varchar2)
1448 				  in ('2','4','5') THEN
1449 				 set_ei(l_org_rec.rei_information15,NULL,
1450 				 l_rei_rec.rei_information15,'Y');
1451 				ELSIF nvl(l_retirement_plan,hr_api.g_varchar2)
1452 				  in ('1','3','8','9','C','E','F','G','H','R','T',
1453 					  'W' ) THEN
1454 				 set_ei(l_org_rec.rei_information15,'E',
1455 				 l_rei_rec.rei_information15,'Y');
1456 				ELSE
1457 				 set_ei(l_org_rec.rei_information15,NULL,
1458 				 l_rei_rec.rei_information15,'Y');
1459 				END IF; -- IF nvl(l_retirement_plan,hr_api.
1460 
1461 			END IF; -- IF l_effective_date > to_date('31/07/2010','DD/MM/RRRR')
1462 		 -- TSP Status Date
1463 			IF NVL(l_retirement_plan,hr_api.g_varchar2)
1464 			NOT IN ('2','4','5') THEN
1465 					set_ei(l_org_rec.rei_information16,fnd_date.date_to_canonical(l_effective_date),
1466 					l_rei_rec.rei_information16,'Y');
1467 					set_ei(l_org_rec.rei_information18,NULL,l_rei_rec.rei_information18,'Y'); --  TSP Emp Contrib Elig Date
1468 			ELSE
1469 				 set_ei(l_org_rec.rei_information16,NULL, l_rei_rec.rei_information16,'Y');
1470 				 set_ei(l_org_rec.rei_information18,NULL,l_rei_rec.rei_information18,'Y');  -- TSP Emp Contrib Elig Date
1471 			END IF; -- -- TSP Status Date
1472 		--Begin Bug# 8622486
1473 		 -- TSP Agency Contrib Elig Date
1474 		 --Bug# 15941036 added Retirement codes DR,KR,LR,MR,NR,PR
1475 			IF NVL(l_retirement_plan,hr_api.g_varchar2) IN ('D', 'K', 'L', 'M', 'N', 'P','DR','KR','LR','MR','NR','PR') THEN
1476 			set_ei(l_org_rec.rei_information17,fnd_date.date_to_canonical(l_effective_date), l_rei_rec.rei_information17,'Y');
1477 			/*
1478 			 -- Get Payroll ID
1479 				FOR l_cur_payroll_id IN c_payroll_id(l_pa_request_id) LOOP
1480 					l_payroll_id := l_cur_payroll_id.payroll_id;
1481 				END LOOP;
1482 			--Bug#6312182 Changed the logic to determine TSP Agency Contribution Eligibilty date.
1483 				IF to_number(to_char(l_effective_date,'MM')) BETWEEN 6 AND 11 THEN
1484 					FOR l_cur_start_date IN c_start_date(l_payroll_id,to_char(l_effective_date+365,'YYYY'), '06') LOOP
1485 						l_start_date := l_cur_start_date.start_date;
1486 					END LOOP;
1487 				ELSE
1488 					FOR l_cur_start_date IN c_start_date(l_payroll_id,to_char(l_effective_date+31,'YYYY'), '12') LOOP
1489 						l_start_date := l_cur_start_date.start_date;
1490 					END LOOP;
1491 				END IF; -- IF to_number(to_char(l_effective_date,'MM'))
1492 			--Bug#6312182
1493 				set_ei(l_org_rec.rei_information17,fnd_date.date_to_canonical(l_start_date), l_rei_rec.rei_information17,'Y');
1494 			*/
1495 			--End Bug# 8622486
1496 			ELSE
1497 				set_ei(l_org_rec.rei_information17,NULL,l_rei_rec.rei_information17,'Y');
1498 			END IF; -- IF NVL(l_retirement_plan,hr_a
1499 		 -- TSP Emp Contrib Elig Date
1500 
1501 		END IF; -- If Family code is Appointment
1502 
1503 		/*
1504 			############ For Conversion to Appointment and Extension action #################
1505 		*/
1506 
1507                  --8793163 For Dual Actions Benefits need to defaulted even if second action is conversion to appointment
1508 		IF (l_family_code = 'CONV_APP' OR nvl(l_second_noa_family_code,hr_api.g_varchar2) = 'CONV_APP') OR l_family_code = 'EXT_NTE' THEN
1509 			fnd_profile.get('PER_BUSINESS_GROUP_ID',l_bus_group_id);
1510 			-- Check if FEHB exists
1511 			l_new_element_name := pqp_fedhr_uspay_int_utils.return_new_element_name('Health Benefits',l_bus_group_id,l_effective_date,null);
1512 			FOR l_element_entry_cur IN c_element_entry(p_assignment_id , l_new_element_name, l_effective_date)  LOOP
1513 				l_fehb_exists := TRUE;
1514 				hr_utility.set_location('Health benefits present',111);
1515 				EXIT;
1516 			END LOOP;
1517 			-- Check if FEHB Pre tax exists
1518 			IF l_fehb_exists = FALSE THEN
1519 				l_new_element_name := pqp_fedhr_uspay_int_utils.return_new_element_name('Health Benefits Pre tax',l_bus_group_id,l_effective_date,null);
1520 				FOR l_element_entry_cur IN c_element_entry(p_assignment_id , l_new_element_name, l_effective_date)  LOOP
1521 					l_fehb_exists := TRUE;
1522 					hr_utility.set_location('Health benefits pre tax present',111);
1523 					EXIT;
1524 				END LOOP;
1525 			END IF;
1526 
1527 			IF l_fehb_exists = TRUE THEN
1528 				FOR l_cur_element IN c_element_value(l_new_element_name,p_assignment_id, l_effective_date) LOOP
1529 					  IF l_cur_element.ipv_name = 'Enrollment' THEN
1530 						l_enrollment_option := l_cur_element.screen_entry_value;
1531 					  ELSIF l_cur_element.ipv_name = 'Health Plan' THEN
1532 						l_health_plan := l_cur_element.screen_entry_value;
1533 					  ELSIF l_cur_element.ipv_name = 'Pre tax Waiver' THEN
1534 						l_pre_tax_waiver := l_cur_element.screen_entry_value;
1535 					  END IF;
1536 				END LOOP;
1537 			END IF;
1538 -- Bug 4702325
1539    l_new_element_name := pqp_fedhr_uspay_int_utils.return_new_element_name('FEGLI',l_bus_group_id,l_effective_date,null);
1540    FOR l_cur_element IN c_element_value(l_new_element_name,p_assignment_id, l_effective_date) LOOP
1541      IF l_cur_element.ipv_name = 'FEGLI' THEN
1542        l_prev_fegli:= l_cur_element.screen_entry_value;
1543      END IF;
1544    END LOOP;
1545 
1546 			hr_utility.set_location('Option' || l_enrollment_option,111);
1547 			hr_utility.set_location('Health Plan' || l_health_plan,111);
1548 			hr_utility.set_location('Prev. FEGLI ' || l_prev_fegli,111);
1549 			hr_utility.set_location('l_person_id ' || l_person_id,111);
1550 			hr_utility.set_location('p_effective_date ' || p_effective_date,111);
1551 
1552 			 ghr_history_fetch.fetch_peopleei
1553 						(p_person_id          =>  l_person_id,
1554 						 p_information_type   =>  'GHR_US_PER_BENEFIT_INFO',
1555 						 p_date_effective     =>  nvl(l_effective_date,trunc(sysdate)),
1556 						 p_per_ei_data        =>  l_per_ei_data
1557 						 );
1558 
1559 			l_date_temp_elig := fnd_date.canonical_to_date(l_per_ei_data.pei_information5);
1560 			l_agency_contrib_date := fnd_date.canonical_to_date(l_per_ei_data.pei_information14);
1561 
1562 			hr_utility.set_location('l_date_temp_elig' || l_per_ei_data.pei_information5,111);
1563 			--8793163 For Dual Actions Benefits need to defaulted even if second action is conversion to appointment
1564 			IF l_family_code = 'CONV_APP' OR nvl(l_second_noa_family_code,hr_api.g_varchar2) = 'CONV_APP' THEN
1565 				IF l_fehb_exists = FALSE OR (l_fehb_exists = TRUE AND NVL(l_enrollment_option,'Z') = 'Z') THEN
1566 					-- FEHB Eligibility expires
1567 
1568 					--8793163 Added for second noa code
1569 					IF l_noa_code IN ('500', '501', '507', '508', '520', '524', '540', '541', '542', '543', '546', '548', '570', '590') OR
1570 					   l_second_noa_code IN ('500', '501', '507', '508', '520', '524', '540', '541', '542', '543', '546', '548', '570', '590') THEN
1571 						hr_utility.set_location('inside 1st',121);
1572 						set_ei(l_org_rec.rei_information3, fnd_date.date_to_canonical(nvl(p_effective_date,sysdate)+60),l_rei_rec.rei_information3,'Y');
1573 					END IF;
1574 
1575  				        --8793163 Added for second noa code
1576 					-- FEHB Temp eligibility expires
1577 					IF l_noa_code IN ('515','522','549','571') OR
1578 					   l_second_noa_code IN ('515','522','549','571')  THEN
1579 						 set_ei(l_org_rec.rei_information4,
1580 						  fnd_date.date_to_canonical(add_months(nvl(l_effective_date,TRUNC(sysdate)),12)+1),l_rei_rec.rei_information4,'Y');
1581 					END IF;
1582 					-- Health Plan
1583 					IF NVL(l_health_plan,'ZZ') = 'ZZ' THEN
1584 						set_ei(l_org_rec.rei_information5, 'ZZ', l_rei_rec.rei_information5,'Y');
1585 					END IF; -- Health Plan IF l_fehb_exists = FALSE OR (l_fehb_
1586 					-- Enrollment
1587 					set_ei(l_org_rec.rei_information6, 'X', l_rei_rec.rei_information6,'Y');
1588 					-- Pre Tax waiver
1589 
1590 					--8793163 Added for second noa code
1591 					IF l_noa_code IN ('500','501','507','508','520','524','540','541','542','543','546','548','570','590') OR
1592 					   l_second_noa_code IN ('500','501','507','508','520','524','540','541','542','543','546','548','570','590') THEN
1593 						set_ei(l_org_rec.rei_information9, 'N', l_rei_rec.rei_information9,'Y');
1594 					END IF;
1595 				END IF; -- IF l_fehb_exists = FALSE OR
1596 
1597 				-- FEGLI Eligibility expires
1598 				IF NVL(l_fegli,hr_api.g_varchar2) <> 'A0' AND
1599 					NVL(l_prev_fegli,hr_api.g_varchar2) = 'A0'  THEN
1600 					-- Begin Bug# 10198463
1601 					IF l_effective_date < to_date('01/10/2010','DD/MM/RRRR') THEN
1602 						set_ei(l_org_rec.rei_information10, fnd_date.date_to_canonical(nvl(l_effective_date,TRUNC(sysdate))+31),
1603 						l_rei_rec.rei_information10,'Y');
1604 					ELSE
1605 					-- Begin Bug# 10198463
1606 						set_ei(l_org_rec.rei_information10, fnd_date.date_to_canonical(nvl(l_effective_date,TRUNC(sysdate))+60),
1607 						l_rei_rec.rei_information10,'Y');
1608 					END IF;-- Begin Bug# 10198463
1609 				END IF;
1610 
1611 				-- Check if TSP exists
1612 				l_new_element_name := NULL;
1613 				l_new_element_name := pqp_fedhr_uspay_int_utils.return_new_element_name('TSP',l_bus_group_id,l_effective_date,null);
1614 				FOR l_element_entry_cur IN c_element_entry(p_assignment_id , l_new_element_name, l_effective_date)  LOOP
1615 					l_tsp_exists := TRUE;
1616 					hr_utility.set_location('TSP present',111);
1617 					EXIT;
1618 				END LOOP;
1619 
1620 				IF l_tsp_exists = TRUE THEN
1621 					FOR l_cur_element IN c_element_value(l_new_element_name,p_assignment_id, l_effective_date) LOOP
1622 					  IF l_cur_element.ipv_name = 'Status' then
1623 						l_tsp_status := substr(l_cur_element.screen_entry_value,1,1);
1624 					  ELSIF l_cur_element.ipv_name = 'Status Date' then
1625 						l_tsp_status_date := fnd_date.canonical_to_date(l_cur_element.screen_entry_value);
1626 					  END IF;
1627 					END LOOP;
1628 				END IF; -- IF l_tsp_exists = TRUE TH
1629 
1630 				-- TSP SCD
1631 				--Begin Bug# 12557463, commented following and added in  proc ghr_scd_info
1632 				/*IF nvl(l_retirement_plan,hr_api.g_varchar2) IN ('D','K','L','M','N','P') AND l_tsp_status IS NULL THEN
1633 				 set_ei(l_org_rec.rei_information12, fnd_date.date_to_canonical(nvl(l_scd,TRUNC(sysdate))), l_rei_rec.rei_information12,'Y');
1634 				ELSE
1635 				 set_ei(l_org_rec.rei_information12,NULL, l_rei_rec.rei_information12,'Y');
1636 				END IF; -- IF nvl(l_retirement_pl
1637 				*/
1638 				--End Bug# 12557463
1639 			 -- TSP Rate
1640 				--Bug# 15941036 added Retirement codes DR,KR,LR,MR,NR,PR effective from 01-Jan-2013
1641 			        IF l_effective_date >= fnd_date.canonical_to_date('2013/01/01') THEN
1642 					IF nvl(l_retirement_plan,hr_api.g_varchar2) IN ('D','K','L','M','N','P','1','3','6','C','E','F','G','R','T','H','W',
1643 					       'DR','KR','LR','MR','NR','PR') AND l_tsp_status IS NULL THEN
1644 						 set_ei(l_org_rec.rei_information14,'03', l_rei_rec.rei_information14,'Y');
1645 					END IF; -- IF nvl(l_retirement_plan,hr_api.
1646 				ELSIF l_effective_date > to_date('31/07/2010','DD/MM/RRRR') THEN
1647 					IF nvl(l_retirement_plan,hr_api.g_varchar2) IN ('D','K','L','M','N','P','1','3','6','C','E','F','G','R','T','H','W') AND l_tsp_status IS NULL THEN
1648 						 set_ei(l_org_rec.rei_information14,'03', l_rei_rec.rei_information14,'Y');
1649 
1650 					END IF; -- IF nvl(l_retirement_plan,hr_api.
1651 				END IF; -- IF l_effective_date > to_date('31/07/2010','DD/MM/RRRR')
1652 
1653 			 -- TSP Status
1654 				hr_utility.set_location('TSP status' || l_tsp_status,111);
1655 				--Bug# 15941036 added Retirement codes DR,KR,LR,MR,NR,PR effective from 01-Jan-2013
1656 			        IF l_effective_date >= fnd_date.canonical_to_date('2013/01/01') THEN
1657 				        IF nvl(l_retirement_plan,hr_api.g_varchar2) IN ('D','K','L','M','N','P','1','3','6','C','E','F','G','R','T','H','W',
1658 					      'DR','KR','LR','MR','NR','PR') AND l_tsp_status IS NULL THEN
1659 						 set_ei(l_org_rec.rei_information15,'A', l_rei_rec.rei_information15,'Y');
1660 					END IF; -- IF nvl(l_retirement_plan,hr_api.
1661 				ELSIF l_effective_date > to_date('31/07/2010','DD/MM/RRRR') THEN
1662 					IF nvl(l_retirement_plan,hr_api.g_varchar2) IN ('D','K','L','M','N','P','1','3','6','C','E','F','G','R','T','H','W') AND l_tsp_status IS NULL THEN
1663 						 set_ei(l_org_rec.rei_information15,'A', l_rei_rec.rei_information15,'Y');
1664 					END IF; -- IF nvl(l_retirement_plan,hr_api.
1665 				ELSE
1666 					--Begin Bug# 11924967
1667 					IF l_effective_date < to_date('22/06/2009','DD/MM/RRRR') AND
1668 					   nvl(l_retirement_plan,hr_api.g_varchar2) in ('D','K','L','M','N','P') THEN
1669 					   set_ei(l_org_rec.rei_information15,'I',l_rei_rec.rei_information15,'Y');
1670 					--End Bug 11924967
1671 					ELSIF nvl(l_retirement_plan,hr_api.g_varchar2) IN ('D','K','L','M','N','P') AND l_tsp_status IS NULL THEN
1672 						 set_ei(l_org_rec.rei_information15,'E', l_rei_rec.rei_information15,'Y');
1673 					ELSIF nvl(l_retirement_plan,hr_api.g_varchar2) IN ('2','4','5') THEN
1674 						 set_ei(l_org_rec.rei_information15,NULL, l_rei_rec.rei_information15,'Y');
1675 					ELSIF nvl(l_retirement_plan,hr_api.g_varchar2) IN ('1','3','8','9','C','E','F','G','H','R','T','W' ) and l_tsp_status IS NULL THEN
1676 						 set_ei(l_org_rec.rei_information15,'E', l_rei_rec.rei_information15,'Y');
1677 					ELSE
1678 						 set_ei(l_org_rec.rei_information15,NULL, l_rei_rec.rei_information15,'Y');
1679 					END IF; -- IF nvl(l_retirement_plan,hr_api.
1680 				END IF; -- IF l_effective_date > to_date('31/07/2010','DD/MM/RRRR')
1681 
1682 			 -- TSP Status Date
1683 				IF NVL(l_retirement_plan,hr_api.g_varchar2) NOT IN ('2','4','5') AND l_tsp_status_date IS NULL THEN
1684 					set_ei(l_org_rec.rei_information16,fnd_date.date_to_canonical(l_effective_date), l_rei_rec.rei_information16,'Y');
1685 				ELSE
1686 					set_ei(l_org_rec.rei_information16,NULL, l_rei_rec.rei_information16,'Y');
1687 				END IF; -- -- TSP Status Date
1688 			 --Begin Bug# 8622486
1689 			 -- TSP Agency Contrib Elig Date
1690 			 --Bug# 15941036 added Retirement codes DR,KR,LR,MR,NR,PR
1691 				IF NVL(l_retirement_plan,hr_api.g_varchar2) IN ('D', 'K', 'L', 'M', 'N', 'P','DR','KR','LR','MR','NR','PR') AND l_agency_contrib_date IS NULL THEN
1692 				set_ei(l_org_rec.rei_information17,fnd_date.date_to_canonical(l_effective_date), l_rei_rec.rei_information17,'Y');
1693 				/*
1694 				 -- Get Payroll ID
1695 					FOR l_cur_payroll_id IN c_payroll_id(l_pa_request_id) LOOP
1696 						l_payroll_id := l_cur_payroll_id.payroll_id;
1697 					END LOOP;
1698 				--Bug#6312182 Changed the logic to determine TSP Agency Contribution Eligibilty date.
1699 				        IF to_number(to_char(l_effective_date,'MM')) BETWEEN 6 AND 11 THEN
1700                    		          	FOR l_cur_start_date IN c_start_date(l_payroll_id,to_char(l_effective_date+365,'YYYY'), '06') LOOP
1701 							l_start_date := l_cur_start_date.start_date;
1702 						END LOOP;
1703 				        ELSE
1704 				          	FOR l_cur_start_date IN c_start_date(l_payroll_id,to_char(l_effective_date+31,'YYYY'), '12') LOOP
1705 							l_start_date := l_cur_start_date.start_date;
1706 						END LOOP;
1707 
1708 					END IF; -- IF to_number(to_char(l_effective_date,'MM'))
1709 				--Bug#6312182
1710 					set_ei(l_org_rec.rei_information17,fnd_date.date_to_canonical(l_start_date), l_rei_rec.rei_information17,'Y');
1711 				*/
1712 				--end Bug# 8622486
1713 				ELSE
1714 					set_ei(l_org_rec.rei_information17,NULL,l_rei_rec.rei_information17,'Y');
1715 				END IF; -- IF NVL(l_retirement_plan,hr_a
1716 
1717 			ELSIF l_family_code = 'EXT_NTE' THEN
1718 				IF l_noa_code IN ('760','762') THEN
1719 					hr_utility.set_location('l_enrollment_option ' || l_enrollment_option,121);
1720 					hr_utility.set_location('l_date_temp_elig ' || to_char(l_date_temp_elig,'dd/mm/yyyy'),121);
1721 					IF l_fehb_exists = TRUE AND NVL(l_enrollment_option,'Z') = 'Z' THEN
1722 						-- FEHB Eligibility date,Enrollment
1723 						--bug# 12761010 moved rei_information3 to below
1724 						IF l_date_temp_elig <= l_effective_date THEN
1725 							set_ei(l_org_rec.rei_information3,fnd_date.date_to_canonical(l_date_temp_elig+1),l_rei_rec.rei_information3,'Y');
1726 							set_ei(l_org_rec.rei_information6, 'X', l_rei_rec.rei_information6,'Y');
1727 						END IF; -- IF l_date_temp_elig
1728 					END IF; -- IF l_fehb_exists = TRUE
1729 				END IF; -- IF l_noa_code IN ('760','762') THEN
1730 
1731 				-- Health Plan
1732 				IF l_fehb_exists = FALSE THEN
1733 					set_ei(l_org_rec.rei_information5, 'ZZ', l_rei_rec.rei_information5,'Y');
1734 				END IF; -- IF l_fehb_exists = FALSE THEN
1735 			END IF; -- IF l_family_code = 'CONV_APP' THEN
1736 		END IF; -- IF l_family_code = 'CONV_APP' OR l_family_code = 'EXT_NTE'
1737 	END IF; -- If l_second_noa_code is not null
1738   END appt_benefits;
1739 ---Title38 Requirement...
1740 -- populate rei_information with mddds_pay
1741 -- GHR_US_PAR_MD_DDS_PAY
1742 --
1743 
1744  Procedure mddds_pay is
1745    Begin
1746 
1747    -- Read from history if person id is not null
1748       hr_utility.set_location('Person inside mddds_pay is  ' || to_char(l_person_id),1);
1749      If l_assignment_id is not null then
1750       hr_utility.set_location('Person inside mddds_pay is  ' || to_char(l_person_id),1);
1751 
1752       l_refresh_flag   :=  l_per_refresh_flag;
1753 
1754       ghr_api.retrieve_element_entry_value
1755           (p_element_name         => 'MDDDS Special Pay',
1756            p_input_value_name     => 'Full Time Status',
1757            p_assignment_id        =>  l_assignment_id,
1758            p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
1759            p_value                =>  l_value,
1760            p_multiple_error_flag  =>  l_multiple_error_flag
1761               );
1762       set_ei(l_org_rec.rei_information9,  l_value,  l_rei_rec.rei_information9,  l_refresh_flag);
1763 
1764       ghr_api.retrieve_element_entry_value
1765           (p_element_name         => 'MDDDS Special Pay',
1766            p_input_value_name     => 'Length of Service',
1767            p_assignment_id        =>  l_assignment_id,
1768            p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
1769            p_value                =>  l_value,
1770            p_multiple_error_flag  =>  l_multiple_error_flag
1771               );
1772       set_ei(l_org_rec.rei_information10, l_value,  l_rei_rec.rei_information10, l_refresh_flag);
1773 
1774       ghr_api.retrieve_element_entry_value
1775           (p_element_name         => 'MDDDS Special Pay',
1776            p_input_value_name     => 'Scarce Specialty',
1777            p_assignment_id        =>  l_assignment_id,
1778            p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
1779            p_value                =>  l_value,
1780            p_multiple_error_flag  =>  l_multiple_error_flag
1781               );
1782       set_ei(l_org_rec.rei_information3,  l_value,  l_rei_rec.rei_information3,  l_refresh_flag);
1783 
1784       ghr_api.retrieve_element_entry_value
1785           (p_element_name         => 'MDDDS Special Pay',
1786            p_input_value_name     => 'Specialty or Board Certification',
1787            p_assignment_id        =>  l_assignment_id,
1788            p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
1789            p_value                =>  l_value,
1790            p_multiple_error_flag  =>  l_multiple_error_flag
1791               );
1792       set_ei(l_org_rec.rei_information4,  l_value,  l_rei_rec.rei_information4,  l_refresh_flag);
1793 
1794       ghr_api.retrieve_element_entry_value
1795           (p_element_name         => 'MDDDS Special Pay',
1796            p_input_value_name     => 'Geographic Location',
1797            p_assignment_id        =>  l_assignment_id,
1798            p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
1799            p_value                =>  l_value,
1800            p_multiple_error_flag  =>  l_multiple_error_flag
1801               );
1802       set_ei(l_org_rec.rei_information5,  l_value,  l_rei_rec.rei_information5,  l_refresh_flag);
1803 
1804       ghr_api.retrieve_element_entry_value
1805           (p_element_name         => 'MDDDS Special Pay',
1806            p_input_value_name     => 'Exceptional Qualifications',
1807            p_assignment_id        =>  l_assignment_id,
1808            p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
1809            p_value                =>  l_value,
1810            p_multiple_error_flag  =>  l_multiple_error_flag
1811               );
1812       set_ei(l_org_rec.rei_information6,  l_value,  l_rei_rec.rei_information6,  l_refresh_flag);
1813 
1814       ghr_api.retrieve_element_entry_value
1815           (p_element_name         => 'MDDDS Special Pay',
1816            p_input_value_name     => 'Executive Position',
1817            p_assignment_id        =>  l_assignment_id,
1818            p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
1819            p_value                =>  l_value,
1820            p_multiple_error_flag  =>  l_multiple_error_flag
1821               );
1822       set_ei(l_org_rec.rei_information7,  l_value,  l_rei_rec.rei_information7,  l_refresh_flag);
1823 
1824       ghr_api.retrieve_element_entry_value
1825           (p_element_name         => 'MDDDS Special Pay',
1826            p_input_value_name     => 'Dentist Post Graduate Training',
1827            p_assignment_id        =>  l_assignment_id,
1828            p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
1829            p_value                =>  l_value,
1830            p_multiple_error_flag  =>  l_multiple_error_flag
1831               );
1832       set_ei(l_org_rec.rei_information8,  l_value,  l_rei_rec.rei_information8,  l_refresh_flag);
1833 
1834       ghr_api.retrieve_element_entry_value
1835           (p_element_name         => 'MDDDS Special Pay',
1836            p_input_value_name     => 'Amount',
1837            p_assignment_id        =>  l_assignment_id,
1838            p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
1839            p_value                =>  l_value,
1840            p_multiple_error_flag  =>  l_multiple_error_flag
1841               );
1842       set_ei(l_org_rec.rei_information11, l_value,  l_rei_rec.rei_information11, l_refresh_flag);
1843 
1844       if l_rei_rec.rei_information11 is null then
1845          l_rei_rec.rei_information11 := 0;
1846       end if;
1847 
1848       ghr_api.retrieve_element_entry_value
1849           (p_element_name         => 'MDDDS Special Pay',
1850            p_input_value_name     => 'MDDDS Special Pay NTE Date',
1851            p_assignment_id        =>  l_assignment_id,
1852            p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
1853            p_value                =>  l_value,
1854            p_multiple_error_flag  =>  l_multiple_error_flag
1855               );
1856       set_ei(l_org_rec.rei_information12, l_value,  l_rei_rec.rei_information12, l_refresh_flag);
1857 
1858       ghr_api.retrieve_element_entry_value
1859           (p_element_name         => 'Premium Pay',
1860            p_input_value_name     => 'Premium Pay Ind',
1861            p_assignment_id        =>  l_assignment_id,
1862            p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
1863            p_value                =>  l_value,
1864            p_multiple_error_flag  =>  l_multiple_error_flag
1865               );
1866       set_ei(l_org_rec.rei_information13, l_value,  l_rei_rec.rei_information13, l_refresh_flag);
1867 
1868     End if;
1869 End mddds_pay;
1870 
1871 
1872 --Title 38 requirement
1873 -- Populate Premium_pay_ind for 855.
1874 Procedure premium_pay_ind IS
1875 
1876 BEGIN
1877 
1878    If l_assignment_id is not null then
1879       hr_utility.set_location('Person inside premium_pay_ind is  ' || to_char(l_person_id),1);
1880       l_refresh_flag   :=  l_per_refresh_flag;
1881 
1882       ghr_api.retrieve_element_entry_value
1883           (p_element_name         => 'Premium Pay',
1884            p_input_value_name     => 'Premium Pay Ind',
1885            p_assignment_id        =>  l_assignment_id,
1886            p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
1887            p_value                =>  l_value,
1888            p_multiple_error_flag  =>  l_multiple_error_flag
1889               );
1890       set_ei(l_org_rec.rei_information3, l_value,  l_rei_rec.rei_information3, l_refresh_flag);
1891 
1892    End If;
1893 
1894 END premium_pay_ind;
1895 
1896 Procedure appt_transfer is                       -- set / reset l_update_rei
1897      Begin
1898           -- Read from history if person id is not null
1899        hr_utility.set_location('appt_transfer - person id  ' || l_person_id,1);
1900        --Bug 3128526. Changed p_person_id -> l_person_id
1901        If l_person_id is not null then
1902           l_refresh_flag := l_per_refresh_flag;
1903             ghr_history_fetch.fetch_peopleei
1904             (p_person_id          =>  l_person_id,
1905              p_information_type   =>  'GHR_US_PER_GROUP1',
1906              p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
1907              p_per_ei_data        =>  l_per_ei_data
1908              );
1909              --
1910              set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information7,l_rei_rec.rei_information3,l_refresh_flag);
1911              l_org_rec.rei_information3  :=  l_per_ei_data.pei_information7;
1912              --
1913              --set_ei(l_org_rec.rei_information4,l_per_ei_data.pei_information3,l_rei_rec.rei_information4,l_refresh_flag);
1914              --l_org_rec.rei_information4  :=  l_per_ei_data.pei_information3;
1915 
1916             --Bug 3128526. Added IF..ELSE to default the handicap code
1917 
1918              --IF l_per_ei_data.pei_information11 is null THEN
1919              --  l_rei_rec.rei_information10 := '05';
1920              --ELSE
1921 	     --Bug # 13581524 modified  to default '05' in set ei itself
1922                set_ei(l_org_rec.rei_information10,nvl(l_per_ei_data.pei_information11,'05'),l_rei_rec.rei_information10,l_refresh_flag);
1923                l_org_rec.rei_information10  :=  nvl(l_per_ei_data.pei_information11,'05');
1924             -- END IF;
1925 /*
1926 
1927 	       set_ei(l_org_rec.rei_information12,l_per_ei_data.pei_information8,l_rei_rec.rei_information12,l_refresh_flag);
1928              l_org_rec.rei_information12 :=  l_per_ei_data.pei_information8;
1929 
1930              set_ei(l_org_rec.rei_information13,l_per_ei_data.pei_information9,l_rei_rec.rei_information13,l_refresh_flag);
1931              l_org_rec.rei_information13 :=  l_per_ei_data.pei_information9;
1932 */
1933 
1934              set_ei(l_org_rec.rei_information18,l_per_ei_data.pei_information5,l_rei_rec.rei_information18,l_refresh_flag);
1935              l_org_rec.rei_information18 :=  l_per_ei_data.pei_information5;
1936 
1937              hr_utility.set_location('RINO ' || l_rei_rec.rei_information17,1);
1938              hr_utility.set_location('RINO _CORE ' || l_per_ei_data.pei_information5,2);
1939 
1940              set_ei(l_org_rec.rei_information19,l_per_ei_data.pei_information4,l_rei_rec.rei_information19,l_refresh_flag);
1941              l_org_rec.rei_information19 :=  l_per_ei_data.pei_information4;
1942              --Begin Bug# 12557463, commented following and added in  proc ghr_scd_info
1943              /*l_per_ei_data               :=  null;
1944 
1945 		 ghr_history_fetch.fetch_peopleei
1946             (p_person_id          =>  l_person_id,
1947              p_information_type   =>  'GHR_US_PER_UNIFORMED_SERVICES',
1948              p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
1949              p_per_ei_data        =>  l_per_ei_data
1950              );
1951               set_ei(l_org_rec.rei_information6,l_per_ei_data.pei_information5,l_rei_rec.rei_information6,l_refresh_flag);
1952               l_org_rec.rei_information6   := l_per_ei_data.pei_information5;  */
1953              --End Bug# 12557463
1954               l_per_ei_data               :=  null;
1955 
1956              ghr_history_fetch.fetch_peopleei
1957             (p_person_id          =>  l_person_id,
1958              p_information_type   =>  'GHR_US_PER_SEPARATE_RETIRE',
1959              p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
1960              p_per_ei_data        =>  l_per_ei_data
1961              );
1962             hr_utility.set_location('original ' || l_org_rec.rei_information3,1);
1963             hr_utility.set_location(' person' || l_per_ei_data.pei_information7,1);
1964             hr_utility.set_location('rei ' || l_rei_rec.rei_information3,1);
1965 
1966              -- This seems wrong ???? set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information7,l_rei_rec.rei_information3,l_refresh_flag);
1967             -- l_org_rec.rei_information3  :=  l_per_ei_data.pei_information7;
1968 
1969             hr_utility.set_location('original ' || l_org_rec.rei_information3,1);
1970             hr_utility.set_location(' person' || l_per_ei_data.pei_information7,1);
1971             hr_utility.set_location('rei ' || l_rei_rec.rei_information3,1);
1972              --Begin Bug# 12557463, commented following and added in  proc ghr_scd_info
1973              /*set_ei(l_org_rec.rei_information9,l_per_ei_data.pei_information5,l_rei_rec.rei_information9,l_refresh_flag);
1974              l_org_rec.rei_information9  :=  l_per_ei_data.pei_information5;*/
1975              --End Bug# 12557463
1976              set_ei(l_org_rec.rei_information16,l_per_ei_data.pei_information4,l_rei_rec.rei_information16,l_refresh_flag);
1977              l_org_rec.rei_information16 :=  l_per_ei_data.pei_information4;
1978              set_ei(l_org_rec.rei_information21,l_per_ei_data.pei_information3,l_rei_rec.rei_information21,l_refresh_flag);
1979              l_org_rec.rei_information21 :=  l_per_ei_data.pei_information3;
1980 
1981              l_per_ei_data               :=  null;
1982 
1983  --bug 4443968
1984 	  --Begin Bug# 12557463, commented following and added in  proc ghr_scd_info
1985 	   /*ghr_history_fetch.fetch_peopleei
1986              (p_person_id          =>  l_person_id,
1987               p_information_type   =>  'GHR_US_PER_SCD_INFORMATION',
1988               p_date_effective     =>  nvl (p_effective_date, trunc(sysdate)),
1989               p_per_ei_data        =>  l_per_ei_data
1990              );
1991 
1992 	set_ei(l_org_rec.rei_information25,l_per_ei_data.pei_information12,l_rei_rec.rei_information25,l_refresh_flag);
1993                l_org_rec.rei_information25 := l_per_ei_data.pei_information12;
1994 
1995 	l_per_ei_data  :=  null;*/
1996 	--End Bug# 12557463
1997 
1998 	IF ghr_utility.is_ghr_nfc = 'TRUE' THEN
1999 			 --  Get PER_LEAVE Information
2000 			 hr_utility.set_location('per_leave_info' ,1);
2001 		   ghr_history_fetch.fetch_peopleei
2002 		   (p_person_id          =>  l_person_id,
2003 			p_information_type   =>  'GHR_US_PER_LEAVE_INFO',
2004 			p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2005 			p_per_ei_data        =>  l_per_ei_data
2006 		   );
2007 			--IF l_per_ei_data.pei_information4 is NULL THEN
2008 			--   l_rei_rec.rei_information22 := 'N';
2009 			--ELSE
2010 			--Bug # 13581524 modified  to default 'N'  in set ei itself
2011 			 set_ei(l_org_rec.rei_information22,NVL(l_per_ei_data.pei_information4,'N'),l_rei_rec.rei_information22,l_refresh_flag);
2012 			--END IF;
2013 		   l_per_ei_data               :=  null;
2014 		  --Gain Or Lose
2015 			 set_ei(l_org_rec.rei_information23,'1B',l_rei_rec.rei_information23,l_refresh_flag);
2016 		END IF;		-- IF ghr_utility.is_ghr_nfc = 'TRUE'
2017        End if;
2018         If l_assignment_id is not null then
2019           l_refresh_flag := l_asg_refresh_flag;
2020             ghr_history_fetch.fetch_asgei
2021             (p_assignment_id          =>  l_assignment_id,
2022              p_information_type  	  =>  'GHR_US_ASG_NON_SF52',
2023              p_date_effective         =>  nvl(p_effective_date,trunc(sysdate)),
2024              p_asg_ei_data       	  =>  l_asg_ei_data
2025              );
2026 
2027           -- added on 2-oct-98 to autopopulate date arrived personnel office by the
2028           -- effective date
2029           --    set_ei(l_org_rec.rei_information7,fnd_date.date_to_canonical(p_effective_date),
2030           --           l_rei_rec.rei_information7,l_refresh_flag);
2031           --  set_ei(l_org_rec.rei_information7,l_asg_ei_data.aei_information3,
2032           --         l_rei_rec.rei_information7,l_refresh_flag);
2033           --  l_org_rec.rei_information7   :=  l_asg_ei_data.aei_information3;
2034 
2035          -- added on 3-dec-99 -- Refer bug 963634
2036        for c_get_eff_rec in c_get_effective_date  loop
2037           set_ei(l_org_rec.rei_information7,fnd_date.date_to_canonical(c_get_eff_rec.effective_date),
2038              l_rei_rec.rei_information7,l_refresh_flag);
2039           exit;
2040        end loop;
2041               set_ei(l_org_rec.rei_information11,l_asg_ei_data.aei_information6,l_rei_rec.rei_information11,l_refresh_flag);
2042               l_org_rec.rei_information11  :=  l_asg_ei_data.aei_information6;
2043 -- 3 to 8
2044               set_ei(l_org_rec.rei_information14,l_asg_ei_data.aei_information8,l_rei_rec.rei_information14,l_refresh_flag);
2045               l_org_rec.rei_information14  :=  l_asg_ei_data.aei_information8;
2046 
2047               set_ei(l_org_rec.rei_information17,l_asg_ei_data.aei_information9,l_rei_rec.rei_information17,l_refresh_flag);
2048               l_org_rec.rei_information17  :=  l_asg_ei_data.aei_information9;
2049 
2050             l_asg_ei_data                :=  null;
2051              /*ghr_api.retrieve_element_entry_value
2052               (p_element_name         => 'Within Grade Increase',
2053                p_input_value_name     => 'Date Due',
2054                p_assignment_id        =>  l_assignment_id,
2055                p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
2056                p_value                =>  l_value,
2057                p_multiple_error_flag  =>  l_multiple_error_flag
2058               );
2059                 set_ei(l_org_rec.rei_information7,l_value,l_rei_rec.rei_information6,l_refresh_flag);
2060                 l_org_rec.rei_information7 := l_value; */
2061           End if;
2062           --Check whether the follwing assignment would work correct in all cases
2063           If l_position_id is not null then
2064             l_refresh_flag := l_pos_refresh_flag;
2065               ghr_history_fetch.fetch_positionei
2066               (p_position_id            =>  l_position_id,
2067                p_information_type  	  =>  'GHR_US_POS_GRP1',
2068                p_date_effective         =>  nvl(p_effective_date,trunc(sysdate)),
2069                p_pos_ei_data       	  =>  l_pos_ei_data
2070               );
2071               If l_pos_ei_data.position_extra_info_id is not null then
2072                 set_ei(l_org_rec.rei_information15,l_pos_ei_data.poei_information12,l_rei_rec.rei_information15,l_refresh_flag);
2073                 l_org_rec.rei_information15  :=  l_pos_ei_data.poei_information12;
2074               End if;
2075               l_pos_ei_data                :=  null;
2076 		--Begin Bug# 14514445
2077 		hr_utility.set_location('promotion_eligibility_date Position Id in appt_transfer '|| l_position_id,350);
2078 		ghr_history_fetch.fetch_positionei
2079 			(p_position_id                => l_position_id,
2080 			p_information_type           => 'GHR_US_POS_VALID_GRADE',
2081 			p_date_effective             =>  trunc(nvl(p_effective_date,sysdate)),
2082 			p_pos_ei_data                =>  l_pos_ei_data
2083 			);
2084 		FOR  grade_name in grade_id(l_pos_ei_data.poei_information3) LOOP
2085 			l_valid_grade_name := grade_name.name;
2086 			exit;
2087 		END LOOP;
2088 		FOR  grade_name in grade_id(l_pos_ei_data.poei_information4) LOOP
2089 			l_target_grade_name := grade_name.name;
2090 			exit;
2091 		END LOOP;
2092 		hr_utility.set_location('promotion_eligibility_date Valid Grade in appt_transfer '|| l_valid_grade_name,351);
2093 		hr_utility.set_location('promotion_eligibility_date Target Grade in appt_transfer '|| l_target_grade_name,352);
2094 
2095 		IF SUBSTR(l_valid_grade_name,1,2) = SUBSTR(l_target_grade_name,1,2) AND
2096 		   TO_NUMBER(SUBSTR(l_valid_grade_name,4,5)) < TO_NUMBER(SUBSTR(l_target_grade_name,4,5)) THEN
2097 			hr_utility.set_location('promotion_eligibility_date default '|| l_valid_grade_name,353);
2098 			set_ei(l_org_rec.rei_information27,fnd_date.date_to_canonical(p_effective_date+365),l_rei_rec.rei_information27,l_refresh_flag);
2099 		END IF;
2100 		l_pos_ei_data  :=  null;
2101 		--End Bug# 14514445
2102 	  End if;
2103            hr_utility.set_location('Appt_transfer Family Code: '||l_noa_family_code,10);
2104       IF NVL(l_noa_family_code,'C') <> 'CORRECT' THEN
2105           OPEN c_noac_130;
2106           FETCH c_noac_130 INTO l_dlei_date;
2107             IF l_dlei_date is not null THEN
2108               set_ei(l_org_rec.rei_information20,
2109                fnd_date.date_to_canonical(l_dlei_date),
2110                     l_rei_rec.rei_information20,'Y');
2111             ELSE
2112               set_ei(l_org_rec.rei_information20,
2113                 null,l_rei_rec.rei_information20,'Y');
2114             END IF;
2115           CLOSE c_noac_130;
2116       END IF;
2117 
2118 
2119 
2120        -- Bug # 12652438 Default the value to 'P'
2121      IF NVL(l_noa_family_code,'C') <> 'CORRECT' THEN
2122         set_ei(l_org_rec.rei_information26,'P',l_rei_rec.rei_information26,'Y');
2123      ELSE
2124         IF l_rei_rec.rei_information26 IS NULL THEN
2125 	   l_rei_rec.rei_information26 := 'P';
2126 	END IF;
2127      END IF;
2128 
2129 End appt_transfer;
2130 
2131 
2132 Procedure conv_appt is
2133        Begin
2134           -- Read from history if person id is not null
2135            If l_person_id is not null then
2136              l_refresh_flag := l_per_refresh_flag;
2137              ghr_history_fetch.fetch_peopleei
2138             (p_person_id          =>  l_person_id,
2139              p_information_type   =>  'GHR_US_PER_GROUP1',
2140              p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2141              p_per_ei_data        =>  l_per_ei_data
2142              );
2143                set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information3,l_rei_rec.rei_information3,l_refresh_flag);
2144                l_org_rec.rei_information3  :=  l_per_ei_data.pei_information3;
2145                set_ei(l_org_rec.rei_information7,l_per_ei_data.pei_information11,l_rei_rec.rei_information7,l_refresh_flag);
2146                l_org_rec.rei_information7  :=  l_per_ei_data.pei_information11;
2147                set_ei(l_org_rec.rei_information12,l_per_ei_data.pei_information5,l_rei_rec.rei_information12,l_refresh_flag);
2148                l_org_rec.rei_information12 :=  l_per_ei_data.pei_information5;
2149                set_ei(l_org_rec.rei_information13,l_per_ei_data.pei_information4,l_rei_rec.rei_information13,l_refresh_flag);
2150                l_org_rec.rei_information13 :=  l_per_ei_data.pei_information4;
2151 
2152 
2153 	       --BUG # 14276354
2154 	       l_per_ei_data := NULL;
2155                ghr_history_fetch.fetch_peopleei
2156                (p_person_id          =>  l_person_id,
2157                 p_information_type   =>  'GHR_US_PER_GROUP2',
2158                 p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2159                 p_per_ei_data        =>  l_per_ei_data
2160                );
2161 
2162 	       set_ei(l_org_rec.rei_information23,l_per_ei_data.pei_information11,l_rei_rec.rei_information23,l_refresh_flag);
2163                l_org_rec.rei_information23  :=  l_per_ei_data.pei_information11;
2164                set_ei(l_org_rec.rei_information24,l_per_ei_data.pei_information12,l_rei_rec.rei_information24,l_refresh_flag);
2165                l_org_rec.rei_information24  :=  l_per_ei_data.pei_information12;
2166                set_ei(l_org_rec.rei_information25,l_per_ei_data.pei_information13,l_rei_rec.rei_information25,l_refresh_flag);
2167                l_org_rec.rei_information25 :=  l_per_ei_data.pei_information13;
2168 	         --BUG # 14276354
2169 
2170              --Begin Bug# 12557463, commented following and added in  proc ghr_scd_info
2171 	     /*l_per_ei_data               :=  null;
2172 
2173 		 ghr_history_fetch.fetch_peopleei
2174             (p_person_id          =>  l_person_id,
2175              p_information_type   =>  'GHR_US_PER_UNIFORMED_SERVICES',
2176              p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2177              p_per_ei_data        =>  l_per_ei_data
2178              );
2179                 set_ei(l_org_rec.rei_information4,l_per_ei_data.pei_information5,l_rei_rec.rei_information4,l_refresh_flag);
2180                 l_org_rec.rei_information4   := l_per_ei_data.pei_information5; */
2181 		--End Bug# 12557463
2182              l_per_ei_data               :=  null;
2183              ghr_history_fetch.fetch_peopleei
2184             (p_person_id          =>  l_person_id,
2185              p_information_type   =>  'GHR_US_PER_SEPARATE_RETIRE',
2186              p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2187              p_per_ei_data        =>  l_per_ei_data
2188              );
2189 	       --Begin Bug# 12557463, commented following and added in  proc ghr_scd_info
2190                --set_ei(l_org_rec.rei_information6,l_per_ei_data.pei_information5,l_rei_rec.rei_information6,l_refresh_flag);
2191                --l_org_rec.rei_information6  :=  l_per_ei_data.pei_information5;
2192 	       --End Bug# 12557463
2193                set_ei(l_org_rec.rei_information10,l_per_ei_data.pei_information4,l_rei_rec.rei_information10,l_refresh_flag);
2194                l_org_rec.rei_information10 :=  l_per_ei_data.pei_information4;
2195              set_ei(l_org_rec.rei_information21,l_per_ei_data.pei_information3,l_rei_rec.rei_information21,l_refresh_flag);
2196              l_org_rec.rei_information21 :=  l_per_ei_data.pei_information3;
2197               l_per_ei_data               :=  null;
2198              ghr_history_fetch.fetch_peopleei
2199             (p_person_id          =>  l_person_id,
2200              p_information_type   =>  'GHR_US_PER_CONVERSIONS',
2201              p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2202              p_per_ei_data        =>  l_per_ei_data
2203              );
2204           --
2205           -- commented out the following as autopopulating is not required for these fields
2206           -- 13-oct-98 by skutteti for the conversion rpa ddf update requirement
2207           --   set_ei(l_org_rec.rei_information14,l_per_ei_data.pei_information3,l_rei_rec.rei_information14,l_refresh_flag);
2208           --   l_org_rec.rei_information14 :=  l_per_ei_data.pei_information3;
2209           --   set_ei(l_org_rec.rei_information15,l_per_ei_data.pei_information4,l_rei_rec.rei_information15,l_refresh_flag);
2210           --   l_org_rec.rei_information15 :=  l_per_ei_data.pei_information4;
2211           --   set_ei(l_org_rec.rei_information16,l_per_ei_data.pei_information5,l_rei_rec.rei_information16,l_refresh_flag);
2212           --   l_org_rec.rei_information16 :=  l_per_ei_data.pei_information5;
2213           --   set_ei(l_org_rec.rei_information17,l_per_ei_data.pei_information7,l_rei_rec.rei_information17,l_refresh_flag);
2214           --   l_org_rec.rei_information17 :=  l_per_ei_data.pei_information7;
2215           --   set_ei(l_org_rec.rei_information18,l_per_ei_data.pei_information6,l_rei_rec.rei_information18,l_refresh_flag);
2216           --   l_org_rec.rei_information18 :=  l_per_ei_data.pei_information6;
2217              l_per_ei_data               :=  null;
2218          --  Get PER_LEAVE Information
2219          hr_utility.set_location('per_leave_info' ,1);
2220 		IF ghr_utility.is_ghr_nfc = 'TRUE' THEN
2221 		   ghr_history_fetch.fetch_peopleei
2222 		   (p_person_id          =>  l_person_id,
2223 			p_information_type   =>  'GHR_US_PER_LEAVE_INFO',
2224 			p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2225 			p_per_ei_data        =>  l_per_ei_data
2226 		   );
2227 			--IF l_per_ei_data.pei_information4 is NULL THEN
2228 			--   l_rei_rec.rei_information22 := 'N';
2229 			--ELSE
2230 			--Bug # 13581524 modified  to default 'N'  in set ei itself
2231 			 set_ei(l_org_rec.rei_information22,NVL(l_per_ei_data.pei_information4,'N'),l_rei_rec.rei_information22,l_refresh_flag);
2232                		--END IF;
2233 		   l_per_ei_data               :=  null;
2234         END IF; -- IF ghr_utility.is_ghr_nfc = 'TR
2235   End if;
2236           If NVL(l_assignment_id,p_assignment_id) is not null then
2237              l_refresh_flag := l_asg_refresh_flag;
2238             ghr_history_fetch.fetch_asgei
2239             (p_assignment_id          =>  l_assignment_id,
2240              p_information_type  	  =>  'GHR_US_ASG_NON_SF52',
2241              p_date_effective         =>  nvl(p_effective_date,trunc(sysdate)),
2242              p_asg_ei_data       	  =>  l_asg_ei_data
2243              );
2244              --Begin Bug#4126188
2245 			--set_ei(l_org_rec.rei_information5,l_asg_ei_data.aei_information3,l_rei_rec.rei_information5,l_refresh_flag);
2246 			 --End Bug#4126188
2247 			set_ei(l_org_rec.rei_information8,l_asg_ei_data.aei_information8,l_rei_rec.rei_information8,l_refresh_flag);
2248 			set_ei(l_org_rec.rei_information11,l_asg_ei_data.aei_information9,l_rei_rec.rei_information11,l_refresh_flag);
2249              -- Start Bug 1318341
2250 
2251              --Bug#5527363 Modified the l_assignment_id parameter passed.
2252              ghr_api.retrieve_element_entry_value
2253               (p_element_name         => 'Within Grade Increase',
2254                p_input_value_name     => 'Date Due',
2255                p_assignment_id        =>  NVL(l_assignment_id,p_assignment_id),
2256                p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
2257                p_value                =>  l_value,
2258                p_multiple_error_flag  =>  l_multiple_error_flag
2259               );
2260 
2261                 set_ei(l_org_rec.rei_information19,l_value,l_rei_rec.rei_information19,l_refresh_flag);
2262              -- End Bug 1318341
2263              l_asg_ei_data                :=  null;
2264           End if;
2265           --Check whether the follwing assignment would work correct in all cases
2266           If l_position_id is not null then
2267              l_refresh_flag := l_pos_refresh_flag;
2268            -- Make sure that the foll. check is correct
2269             ghr_history_fetch.fetch_positionei
2270             (p_position_id            =>  l_position_id,
2271              p_information_type  	  =>  'GHR_US_POS_GRP1',
2272              p_date_effective         =>  nvl(p_effective_date,trunc(sysdate)),
2273              p_pos_ei_data       	  =>  l_pos_ei_data
2274              );
2275               set_ei(l_org_rec.rei_information9,l_pos_ei_data.poei_information12,l_rei_rec.rei_information9,l_refresh_flag);
2276              l_pos_ei_data                :=  null;
2277 	     --Begin Bug# 14514445
2278 		hr_utility.set_location('promotion_eligibility_date Position Id in conv_appt '|| l_position_id,350);
2279 		ghr_history_fetch.fetch_positionei
2280 			(p_position_id                => l_position_id,
2281 			p_information_type           => 'GHR_US_POS_VALID_GRADE',
2282 			p_date_effective             =>  trunc(nvl(p_effective_date,sysdate)),
2283 			p_pos_ei_data                =>  l_pos_ei_data
2284 			);
2285 		FOR  grade_name in grade_id(l_pos_ei_data.poei_information3) LOOP
2286 			l_valid_grade_name := grade_name.name;
2287 			exit;
2288 		END LOOP;
2289 		FOR  grade_name in grade_id(l_pos_ei_data.poei_information4) LOOP
2290 			l_target_grade_name := grade_name.name;
2291 			exit;
2292 		END LOOP;
2293 		hr_utility.set_location('promotion_eligibility_date Valid Grade in conv_appt '|| l_valid_grade_name,351);
2294 		hr_utility.set_location('promotion_eligibility_date Target Grade in conv_appt '|| l_target_grade_name,352);
2295 
2296 		IF SUBSTR(l_valid_grade_name,1,2) = SUBSTR(l_target_grade_name,1,2) AND
2297 		   TO_NUMBER(SUBSTR(l_valid_grade_name,4,5)) < TO_NUMBER(SUBSTR(l_target_grade_name,4,5)) THEN
2298 			hr_utility.set_location('promotion_eligibility_date default in conv_appt '|| l_valid_grade_name,353);
2299 			set_ei(l_org_rec.rei_information26,fnd_date.date_to_canonical(p_effective_date+365),l_rei_rec.rei_information26,l_refresh_flag);
2300 		END IF;
2301 		l_pos_ei_data :=  null;
2302 		--End Bug# 14514445
2303           End if;
2304 		  --Bug#4126188 Begin
2305 		FOR c_posn_to_frm IN c_position LOOP
2306 			l_from_position_id :=c_posn_to_frm.from_position_id;
2307 			l_to_position_id := c_posn_to_frm.to_position_id;
2308 		END LOOP;
2309 
2310 			ghr_history_fetch.fetch_positionei
2311 			(p_position_id            =>  l_from_position_id,
2312 			p_information_type       =>  'GHR_US_POS_GRP1',
2313 			p_date_effective         =>  trunc(nvl(p_effective_date,sysdate)),
2314 			p_pos_ei_data            =>  l_pos_ei_data
2315 			);
2316 			l_from_poid := l_pos_ei_data.poei_information3;
2317 			l_pos_ei_data := NULL;
2318 
2319 			ghr_history_fetch.fetch_positionei
2320 			(p_position_id            =>  l_to_position_id,
2321 			p_information_type       =>  'GHR_US_POS_GRP1',
2322 			p_date_effective         =>  trunc(nvl(p_effective_date,sysdate)),
2323 			p_pos_ei_data            =>  l_pos_ei_data
2324 			);
2325 			l_to_poid := l_pos_ei_data.poei_information3;
2326 			l_pos_ei_data := NULL;
2327 			IF l_from_poid = l_to_poid THEN
2328 				IF l_noa_family_code = 'CORRECT' THEN
2329 					ghr_history_api.get_g_session_var(l_session);
2330 					l_session1 := l_session;
2331 					l_session.noa_id_correct := NULL;
2332 					ghr_history_api.reinit_g_session_var;
2333 					ghr_history_api.set_g_session_var(l_session);
2334 					ghr_history_fetch.fetch_asgei
2335 						(p_assignment_id          =>  NVL(l_assignment_id,p_assignment_id),
2336 						 p_information_type  	  =>  'GHR_US_ASG_NON_SF52',
2337 						 p_date_effective         =>  p_effective_date-1,
2338 						 p_asg_ei_data       	  =>  l_asg_ei_data );
2339 					ghr_history_api.reinit_g_session_var;
2340 					ghr_history_api.set_g_session_var(l_session1);
2341 				ELSE
2342 					ghr_history_fetch.fetch_asgei
2343 					(p_assignment_id          =>  NVL(l_assignment_id,p_assignment_id),
2344 					p_information_type  	  =>  'GHR_US_ASG_NON_SF52',
2345 					p_date_effective         =>  p_effective_date,
2346 					p_asg_ei_data       	  =>  l_asg_ei_data);
2347 				END IF;
2348 				set_ei(l_org_rec.rei_information5,l_asg_ei_data.aei_information3,l_rei_rec.rei_information5,l_refresh_flag);
2349 		/*Start - Bug 7295154*/
2350 			ELSIF l_to_poid IS NULL AND l_noa_family_code = 'CORRECT'  THEN
2351 			  ghr_history_fetch.fetch_asgei
2352 				(p_assignment_id          =>  NVL(l_assignment_id,p_assignment_id),
2353 				p_information_type       =>  'GHR_US_ASG_NON_SF52',
2354 				p_date_effective         =>  nvl(p_effective_date,trunc(sysdate)),
2355 				p_asg_ei_data            =>  l_asg_ei_data
2356 				);
2357 			 set_ei(l_org_rec.rei_information5,l_asg_ei_data.aei_information3,l_rei_rec.rei_information5,'Y');
2358 		/*End - Bug 7295154*/
2359 			ELSE
2360 				FOR c_get_eff_rec in c_get_effective_date
2361 				LOOP
2362 					IF (l_rei_rec.rei_information5 IS NULL) OR
2363 					(l_noa_family_code = 'CORRECT'  AND l_rei_rec.rei_information5 IS NOT NULL) THEN
2364 					set_ei(l_org_rec.rei_information5,fnd_date.date_to_canonical(c_get_eff_rec.effective_date),
2365 					l_rei_rec.rei_information5,l_refresh_flag);
2366 					END IF;
2367 					exit;
2368 				END LOOP;
2369 			END IF;
2370 		--Bug#4126188 End
2371           hr_utility.set_location('conv_Appt Family Code: '||l_noa_family_code,10);
2372           IF NVL(l_noa_family_code,'C') <> 'CORRECT' THEN
2373               OPEN c_noac_5xx;
2374               FETCH c_noac_5xx INTO l_dlei_date;
2375               IF l_dlei_date is not null THEN
2376                 FOR get_pay_grd  in c_pp_and_grade LOOP
2377                   IF nvl(get_pay_grd.to_grade_or_level,0)
2378                     > nvl(get_pay_grd.from_grade_or_level,1)
2379                    and get_pay_grd.to_pay_plan = get_pay_grd.from_pay_plan
2380                   THEN
2381                     set_ei(l_org_rec.rei_information20,
2382                       fnd_date.date_to_canonical(l_dlei_date),
2383                       l_rei_rec.rei_information20,'Y');
2384                   END IF;
2385                 END LOOP;
2386               ELSE
2387                 set_ei(l_org_rec.rei_information20,
2388                   null,l_rei_rec.rei_information20,'Y');
2389               END IF;
2390               CLOSE c_noac_5xx;
2391           END IF;
2392        End conv_appt;
2393 
2394        Procedure return_to_duty
2395        is
2396        Begin
2397 
2398          If l_person_id  is not null then
2399           l_refresh_flag := l_per_refresh_flag;
2400              --Begin Bug# 12557463, commented following and added in  proc ghr_scd_info
2401 	     /*ghr_history_fetch.fetch_peopleei
2402              (p_person_id          =>  l_person_id,
2403               p_information_type   =>  'GHR_US_PER_UNIFORMED_SERVICES',
2404               p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2405               p_per_ei_data        =>  l_per_ei_data
2406              );
2407                set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information5,l_rei_rec.rei_information3,l_refresh_flag);
2408              l_per_ei_data  := null;
2409 
2410              ghr_history_fetch.fetch_peopleei
2411              (p_person_id          =>  l_person_id,
2412               p_information_type   =>  'GHR_US_PER_SEPARATE_RETIRE',
2413               p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2414               p_per_ei_data        l_per_ei_data
2415               );
2416                set_ei(l_org_rec.rei_information5,l_per_ei_data.pei_information5,l_rei_rec.rei_information5,l_refresh_flag);*/
2417               --End Bug# 12557463
2418              -- Bug 3966783 changes
2419              IF NVL(l_noa_family_code,'C') = 'CORRECT' THEN
2420                 ghr_history_fetch.fetch_peopleei
2421                 (p_person_id          =>  l_person_id,
2422                  p_information_type   =>  'GHR_US_PER_GROUP1',
2423                  p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2424                  p_per_ei_data        =>  l_per_ei_data
2425                  );
2426                  set_ei(l_org_rec.rei_information8,l_per_ei_data.pei_information4,l_rei_rec.rei_information8,l_refresh_flag);
2427               END IF;
2428               l_per_ei_data  := null;
2429          End if;
2430 
2431         If l_assignment_id is not null then
2432           l_refresh_flag := l_asg_refresh_flag;
2433             ghr_history_fetch.fetch_asgei
2434             (p_assignment_id      =>  l_assignment_id,
2435              p_information_type   =>  'GHR_US_ASG_NON_SF52',
2436              p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2437              p_asg_ei_data        =>  l_asg_ei_data
2438             );
2439                set_ei(l_org_rec.rei_information6,l_asg_ei_data.aei_information6,l_rei_rec.rei_information6,l_refresh_flag);
2440                set_ei(l_org_rec.rei_information7,l_asg_ei_data.aei_information8,l_rei_rec.rei_information7,l_refresh_flag);
2441 
2442             l_asg_ei_data  := null;
2443             -- do not populate within grade increase.
2444 
2445           End if;
2446 
2447 	  --Bug # 12652438
2448 	  IF NVL(l_noa_family_code,'C') <> 'CORRECT' THEN
2449 	     IF l_first_noa_code in ('280','292','293') THEN
2450 		set_ei(l_org_rec.rei_information10,'P',l_rei_rec.rei_information10,'Y');
2451              END IF;
2452           ELSE
2453 	    IF l_rei_rec.rei_information10  IS NULL THEN
2454 	        IF l_second_noa_code in ('280','292','293') THEN
2455 		   l_rei_rec.rei_information10  :=  'P';
2456 		END IF;
2457 	    END IF;
2458 
2459           END IF;
2460       End return_to_duty;
2461 
2462      Procedure  reassignment is
2463      Begin
2464        If l_assignment_id is not null then
2465           l_refresh_flag := l_asg_refresh_flag;
2466            ghr_history_fetch.fetch_asgei
2467            (p_assignment_id      =>  l_assignment_id,
2468             p_information_type   =>  'GHR_US_ASG_NON_SF52',
2469             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2470             p_asg_ei_data        =>  l_asg_ei_data
2471            );
2472                set_ei(l_org_rec.rei_information4,l_asg_ei_data.aei_information8,l_rei_rec.rei_information4,l_refresh_flag);
2473                set_ei(l_org_rec.rei_information6,l_asg_ei_data.aei_information9,l_rei_rec.rei_information6,l_refresh_flag);
2474 
2475           l_asg_ei_data  := null;
2476        End if;
2477        If l_position_id is not null then
2478           l_refresh_flag := l_pos_refresh_flag;
2479            ghr_history_fetch.fetch_positionei
2480            (p_position_id        =>  l_position_id,
2481             p_information_type   =>  'GHR_US_POS_GRP1',
2482             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2483             p_pos_ei_data        =>  l_pos_ei_data
2484             );
2485              set_ei(l_org_rec.rei_information5,l_pos_ei_data.poei_information12,l_rei_rec.rei_information5,l_refresh_flag);
2486 		   l_pos_ei_data := null;
2487 
2488         /* Bug # 1794090
2489 
2490            ghr_history_fetch.fetch_positionei
2491            (p_position_id        =>  l_position_id,
2492             p_information_type   =>  'GHR_US_POS_GRP2',
2493             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2494             p_pos_ei_data        =>  l_pos_ei_data
2495             );
2496              set_ei(l_org_rec.rei_information3,l_pos_ei_data.poei_information12,l_rei_rec.rei_information3,l_refresh_flag);
2497 
2498            l_pos_ei_data := null;
2499       */
2500        --Begin Bug# 14514445
2501 	hr_utility.set_location('promotion_eligibility_date Position Id in reassignment '|| l_position_id,350);
2502 	ghr_history_fetch.fetch_positionei
2503 		(p_position_id                => l_position_id,
2504 		p_information_type           => 'GHR_US_POS_VALID_GRADE',
2505 		p_date_effective             =>  trunc(nvl(p_effective_date,sysdate)),
2506 		p_pos_ei_data                =>  l_pos_ei_data
2507 		);
2508 	FOR  grade_name in grade_id(l_pos_ei_data.poei_information3) LOOP
2509 		l_valid_grade_name := grade_name.name;
2510 		exit;
2511 	END LOOP;
2512 	FOR  grade_name in grade_id(l_pos_ei_data.poei_information4) LOOP
2513 		l_target_grade_name := grade_name.name;
2514 		exit;
2515 	END LOOP;
2516 	hr_utility.set_location('promotion_eligibility_date Valid Grade in reassignment '|| l_valid_grade_name,351);
2517 	hr_utility.set_location('promotion_eligibility_date Target Grade in reassignment '|| l_target_grade_name,352);
2518 
2519 	IF SUBSTR(l_valid_grade_name,1,2) = SUBSTR(l_target_grade_name,1,2) AND
2520 	   TO_NUMBER(SUBSTR(l_valid_grade_name,4,5)) < TO_NUMBER(SUBSTR(l_target_grade_name,4,5)) THEN
2521 		hr_utility.set_location('promotion_eligibility_date default in reassignment '|| l_valid_grade_name,353);
2522 		ghr_history_fetch.fetch_peopleei
2523 		    (p_person_id          =>  l_person_id,
2524 		     p_information_type   =>  'GHR_US_PER_GROUP1',
2525 		     p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2526 		     p_per_ei_data        =>  l_per_ei_data
2527 		     );
2528 		-- Bug# 16023085 modified l_per_ei_data.pei_information19 to l_per_ei_data.pei_information29
2529                set_ei(l_org_rec.rei_information8,l_per_ei_data.pei_information29,l_rei_rec.rei_information8,l_refresh_flag);
2530 
2531 	       l_per_ei_data := NULL;
2532 	END IF;
2533 	l_pos_ei_data :=  null;
2534 	--End Bug# 14514445
2535        End if;
2536 	   --Bug#4126188 Begin
2537 		FOR c_posn_to_frm IN c_position LOOP
2538 			l_from_position_id :=c_posn_to_frm.from_position_id;
2539 			l_to_position_id := c_posn_to_frm.to_position_id;
2540 		END LOOP;
2541 			ghr_history_fetch.fetch_positionei
2542 			(p_position_id            =>  l_from_position_id,
2543 			p_information_type       =>  'GHR_US_POS_GRP1',
2544 			p_date_effective         =>  trunc(nvl(p_effective_date,sysdate)),
2545 			p_pos_ei_data            =>  l_pos_ei_data
2546 			);
2547 			l_from_poid := l_pos_ei_data.poei_information3;
2548 			l_pos_ei_data := NULL;
2549 
2550 			ghr_history_fetch.fetch_positionei
2551            (p_position_id        =>  l_to_position_id,
2552             p_information_type   =>  'GHR_US_POS_GRP1',
2553             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2554             p_pos_ei_data        =>  l_pos_ei_data
2555             );
2556 			l_to_poid := l_pos_ei_data.poei_information3;
2557 			l_pos_ei_data := NULL;
2558 			IF l_from_poid = l_to_poid THEN
2559 				IF nvl(l_noa_family_code,'C') = 'CORRECT' THEN
2560 
2561 	              ghr_history_api.get_g_session_var(l_session);
2562 				  l_session1 := l_session;
2563                   l_session.noa_id_correct := NULL;
2564 				  ghr_history_api.reinit_g_session_var;
2565 				  ghr_history_api.set_g_session_var(l_session);
2566 					ghr_history_fetch.fetch_asgei
2567 						(p_assignment_id          =>  NVL(l_assignment_id,p_assignment_id),
2568 						p_information_type       =>  'GHR_US_ASG_NON_SF52',
2569 						p_date_effective         =>  p_effective_date-1,
2570 						p_asg_ei_data            =>  l_asg_ei_data
2571 						);
2572 						ghr_history_api.reinit_g_session_var;
2573 						ghr_history_api.set_g_session_var(l_session1);
2574 				ELSE
2575 					ghr_history_fetch.fetch_asgei
2576 						(p_assignment_id          =>  NVL(l_assignment_id,p_assignment_id),
2577 						p_information_type       =>  'GHR_US_ASG_NON_SF52',
2578 						p_date_effective         =>  nvl(p_effective_date,trunc(sysdate)),
2579 						p_asg_ei_data            =>  l_asg_ei_data
2580 						);
2581 				END IF;
2582 				set_ei(l_org_rec.rei_information7,l_asg_ei_data.aei_information3,l_rei_rec.rei_information7,l_refresh_flag);
2583 			ELSE
2584 				FOR c_get_eff_rec in c_get_effective_date
2585 				LOOP
2586 				IF l_org_rec.rei_information7 IS NULL THEN
2587 					set_ei(l_org_rec.rei_information7,fnd_date.date_to_canonical(c_get_eff_rec.effective_date),
2588 					l_rei_rec.rei_information7,l_refresh_flag);
2589 				ELSIF (nvl(l_noa_family_code,'C') = 'CORRECT' AND l_org_rec.rei_information7 IS NOT NULL) THEN
2590 					set_ei(l_org_rec.rei_information7,fnd_date.date_to_canonical(c_get_eff_rec.effective_date),
2591 					l_rei_rec.rei_information7,l_refresh_flag);
2592 				END IF;
2593 				exit;
2594 				END LOOP;
2595 			END IF;
2596 		--Bug#4126188 End
2597      End reassignment;
2598 
2599       -- Added realign procedure to fix bug 3593584
2600      Procedure  realign is
2601      Begin
2602        -- Bug#3593584 The following variable is used in procedure realign
2603        -- to populate the Extra info only when noa_family_code = 'CORRECT'
2604        hr_utility.set_location('l_noa_family_code '|| l_noa_family_code,10);
2605        -- Bug#4089400 Moved the cursor to the begining of the main procedure.
2606        IF NVL(l_noa_family_code,'C') = 'CORRECT' THEN
2607          If l_assignment_id is not null then
2608           l_refresh_flag := l_asg_refresh_flag;
2609            ghr_history_fetch.fetch_asgei
2610            (p_assignment_id      =>  l_assignment_id,
2611             p_information_type   =>  'GHR_US_ASG_NON_SF52',
2612             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2613             p_asg_ei_data        =>  l_asg_ei_data
2614            );
2615                set_ei(l_org_rec.rei_information3,l_asg_ei_data.aei_information3,l_rei_rec.rei_information3,l_refresh_flag);
2616                l_asg_ei_data  := null;
2617        End if;
2618        If l_position_id is not null then
2619           l_refresh_flag := l_pos_refresh_flag;
2620            ghr_history_fetch.fetch_positionei
2621            (p_position_id        =>  l_position_id,
2622             p_information_type   =>  'GHR_US_POS_GRP1',
2623             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2624             p_pos_ei_data        =>  l_pos_ei_data
2625             );
2626            set_ei(l_org_rec.rei_information4,l_pos_ei_data.poei_information18,l_rei_rec.rei_information4,l_refresh_flag);
2627 	   set_ei(l_org_rec.rei_information5,l_pos_ei_data.poei_information3,l_rei_rec.rei_information5,l_refresh_flag);
2628 	   set_ei(l_org_rec.rei_information6,l_pos_ei_data.poei_information4,l_rei_rec.rei_information6,l_refresh_flag);
2629 	   --Bug 3593584 Populate positions' organization,
2630 	   set_ei(l_org_rec.rei_information8,l_pos_ei_data.poei_information21,l_rei_rec.rei_information8,l_refresh_flag);
2631 	   set_ei(l_org_rec.rei_information11,l_pos_ei_data.poei_information5,l_rei_rec.rei_information11,l_refresh_flag);
2632 
2633 	   l_pos_ei_data := null;
2634 
2635            ghr_history_fetch.fetch_positionei
2636            (p_position_id        =>  l_position_id,
2637             p_information_type   =>  'GHR_US_POS_GRP2',
2638             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2639             p_pos_ei_data        =>  l_pos_ei_data
2640             );
2641            set_ei(l_org_rec.rei_information7,l_pos_ei_data.poei_information4,l_rei_rec.rei_information7,l_refresh_flag);
2642            l_pos_ei_data := null;
2643 
2644        End if;
2645      END IF;
2646      End realign;
2647      -- Added realign procedure to fix bug 3593584
2648 
2649   Procedure chg_data_element is
2650 	cursor c_bg is
2651 	SELECT 	business_group_id
2652 	FROM		per_positions
2653 	WHERE		position_id = l_position_id;
2654 	l_agency_code	ghr_pa_requests.agency_code%type;
2655 	l_bg_id		per_positions.business_group_id%type;
2656      Begin
2657        If  l_position_id is not null then
2658           l_refresh_flag := l_pos_refresh_flag;
2659 	     ghr_history_fetch.fetch_positionei
2660            (p_position_id        =>  l_position_id,
2661             p_information_type   =>  'GHR_US_POS_GRP1',
2662             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2663             p_pos_ei_data        =>  l_pos_ei_data
2664            );
2665              set_ei(l_org_rec.rei_information3,l_pos_ei_data.poei_information3,l_rei_rec.rei_information3,l_refresh_flag);
2666            l_pos_ei_data := null;
2667 		FOR c_bg_id	in c_bg LOOP
2668 			l_bg_id := c_bg_id.business_group_id;
2669 		END LOOP;
2670 		l_agency_code	:= ghr_api.get_position_agency_code_pos
2671 						(p_position_id		=>	l_position_id
2672 						,p_business_group_id	=>	l_bg_id
2673                         ,p_effective_date       => nvl(p_effective_date,trunc(sysdate)));
2674             set_ei(l_org_rec.rei_information4,l_agency_code,l_rei_rec.rei_information4,l_refresh_flag);
2675 			-- Begin Bug# 4126188
2676 			set_ei(l_org_rec.rei_information5,fnd_date.date_to_canonical(p_effective_date),l_rei_rec.rei_information5,l_refresh_flag);
2677 			-- End Bug# 4126188
2678        End if;
2679 
2680      End chg_data_element;
2681 
2682      Procedure chg_retire_plan is
2683      Begin
2684        If l_person_id is not null then
2685           l_refresh_flag := l_per_refresh_flag;
2686            ghr_history_fetch.fetch_peopleei
2687            (p_person_id          =>  l_person_id,
2688             p_information_type   =>  'GHR_US_PER_UNIFORMED_SERVICES',
2689             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2690             p_per_ei_data        =>  l_per_ei_data
2691            );
2692              set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information5,l_rei_rec.rei_information3,l_refresh_flag);
2693            l_per_ei_data  := null;
2694 
2695            ghr_history_fetch.fetch_peopleei
2696            (p_person_id          =>  l_person_id,
2697             p_information_type   =>  'GHR_US_PER_SEPARATE_RETIRE',
2698             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2699             p_per_ei_data        =>  l_per_ei_data
2700            );
2701              set_ei(l_org_rec.rei_information4,l_per_ei_data.pei_information3,l_rei_rec.rei_information4,l_refresh_flag);
2702              set_ei(l_org_rec.rei_information5,l_per_ei_data.pei_information5,l_rei_rec.rei_information5,l_refresh_flag);
2703              set_ei(l_org_rec.rei_information6,l_per_ei_data.pei_information4,l_rei_rec.rei_information6,l_refresh_flag);
2704            l_per_ei_data  := null;
2705 	   --Begin Bug# 14769681
2706 
2707            ghr_history_fetch.fetch_peopleei
2708            (p_person_id          =>  l_person_id,
2709             p_information_type   =>  'GHR_US_PER_SCD_INFORMATION',
2710             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2711             p_per_ei_data        =>  l_per_ei_data
2712            );
2713              set_ei(l_org_rec.rei_information7,l_per_ei_data.pei_information6,l_rei_rec.rei_information7,l_refresh_flag);
2714            l_per_ei_data  := null;
2715 	   --Begin Bug# 14769681
2716        End if;
2717      End chg_retire_plan;
2718      --
2719      --
2720      Procedure chg_scd is
2721      Begin
2722        If l_person_id is not null then
2723           l_refresh_flag := l_per_refresh_flag;
2724            ghr_history_fetch.fetch_peopleei
2725            (p_person_id          =>  l_person_id,
2726             p_information_type   =>  'GHR_US_PER_SCD_INFORMATION',
2727             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2728             p_per_ei_data        =>  l_per_ei_data
2729            );
2730 	   --Modified for EHRI reports 3675673
2731 	     set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information5,l_rei_rec.rei_information3,l_refresh_flag);
2732              set_ei(l_org_rec.rei_information4,l_per_ei_data.pei_information4,l_rei_rec.rei_information4,l_refresh_flag);
2733      	     set_ei(l_org_rec.rei_information8,l_per_ei_data.pei_information7,l_rei_rec.rei_information8,l_refresh_flag);
2734 			  set_ei(l_org_rec.rei_information9,l_per_ei_data.pei_information6,l_rei_rec.rei_information9,l_refresh_flag);
2735 	     -- SCD Retirement
2736 
2737 		  -- Bug 4164083 eHRI New Attribution Changes
2738        	     set_ei(l_org_rec.rei_information10,l_per_ei_data.pei_information8,l_rei_rec.rei_information10,l_refresh_flag);
2739  		     set_ei(l_org_rec.rei_information11,l_per_ei_data.pei_information9,l_rei_rec.rei_information11,l_refresh_flag);
2740 
2741 		  -- End eHRI New Attribution Changes
2742 
2743 	   --bug 4443968
2744 	     set_ei(l_org_rec.rei_information12,l_per_ei_data.pei_information12,l_rei_rec.rei_information12,l_refresh_flag);
2745 
2746 	     l_per_ei_data  := null;
2747 
2748            ghr_history_fetch.fetch_peopleei
2749            (p_person_id          =>  l_person_id,
2750             p_information_type   =>  'GHR_US_PER_UNIFORMED_SERVICES',
2751             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2752             p_per_ei_data        =>  l_per_ei_data
2753            );
2754              set_ei(l_org_rec.rei_information5,l_per_ei_data.pei_information5,l_rei_rec.rei_information5,l_refresh_flag);
2755            l_per_ei_data  := null;
2756 
2757            ghr_history_fetch.fetch_peopleei
2758            (p_person_id          =>  l_person_id,
2759             p_information_type   =>  'GHR_US_PER_SEPARATE_RETIRE',
2760             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2761             p_per_ei_data        =>  l_per_ei_data
2762            );
2763              set_ei(l_org_rec.rei_information6,l_per_ei_data.pei_information5,l_rei_rec.rei_information6,l_refresh_flag);
2764              set_ei(l_org_rec.rei_information7,l_per_ei_data.pei_information4,l_rei_rec.rei_information7,l_refresh_flag);
2765            l_per_ei_data  := null;
2766 
2767       End if;
2768      End chg_scd;
2769 
2770      --Begin bug# 14751665,15882322,15882330
2771      PROCEDURE prv_ret_info IS
2772      BEGIN
2773 	  IF l_person_id IS NOT NULL THEN
2774 	    l_refresh_flag := l_per_refresh_flag;
2775 
2776 	    hr_utility.set_location ('l_refresh_flag in prv_ret_info is '
2777 				     || l_refresh_flag, 4);
2778 
2779 	    ghr_history_fetch.fetch_peopleei
2780 				(p_person_id        => l_person_id
2781 			       , p_information_type => 'GHR_US_PER_SEPARATE_RETIRE'
2782 			       , p_date_effective   => nvl (p_effective_date, trunc (sysdate))
2783 			       , p_per_ei_data      => l_per_ei_data);
2784 
2785 	    set_ei (l_org_rec.rei_information1, l_per_ei_data.pei_information4
2786 		  , l_rei_rec.rei_information1, l_refresh_flag);
2787 
2788 	    l_per_ei_data := NULL;
2789 	  END IF;
2790      END prv_ret_info;
2791 
2792      --End Bug# 14751665,15882322,15882330
2793     --
2794     --Bug#2146912
2795     --
2796     Procedure scd_tsp is
2797     begin
2798 
2799       If l_person_id is not null then
2800           l_refresh_flag := l_per_refresh_flag;
2801            hr_utility.set_location('l_refresh_flag is ' || l_refresh_flag,1);
2802            ghr_history_fetch.fetch_peopleei
2803            (p_person_id          =>  l_person_id,
2804             p_information_type   =>  'GHR_US_PER_SCD_INFORMATION',
2805             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2806             p_per_ei_data        =>  l_per_ei_data
2807            );
2808              set_ei(l_org_rec.rei_information12,l_per_ei_data.pei_information6,
2809                     l_rei_rec.rei_information12,l_refresh_flag);
2810            l_per_ei_data  := null;
2811 
2812       End if;
2813     End scd_tsp;
2814     --
2815     --
2816     Procedure non_pay_duty  is
2817       l_special_info       ghr_api.special_information_type;
2818     begin
2819 
2820       If l_person_id is not null then
2821           l_refresh_flag := l_per_refresh_flag;
2822           hr_utility.set_location('l_refresh_flag is ' || l_refresh_flag,4);
2823           IF NVL(l_noa_family_code,'C') = 'CORRECT' THEN
2824              ghr_history_fetch.fetch_peopleei
2825              (p_person_id          =>  l_person_id,
2826               p_information_type   =>  'GHR_US_PER_GROUP1',
2827               p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2828               p_per_ei_data        =>  l_per_ei_data
2829              );
2830              set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information4,l_rei_rec.rei_information3,l_refresh_flag);
2831           END IF;
2832           l_per_ei_data  := null;
2833 
2834       End if;
2835 
2836 
2837       --Bug 12652438
2838       hr_utility.set_location('l_noa_family_code'||l_noa_family_code,1000);
2839       IF NVL(l_noa_family_code,'C') <> 'CORRECT'  THEN
2840 
2841          IF l_first_noa_code = '430' THEN
2842 	    set_ei(l_org_rec.rei_information15,'O',l_rei_rec.rei_information15,'Y');
2843 	 ELSIF l_first_noa_code = '450' THEN
2844 	    set_ei(l_org_rec.rei_information15,'S',l_rei_rec.rei_information15,'Y');
2845          ELSIF l_first_noa_code = '452' THEN
2846  	    set_ei(l_org_rec.rei_information15,'T',l_rei_rec.rei_information15,'Y');
2847 	 ELSIF l_first_noa_code = '460' THEN
2848 	    set_ei(l_org_rec.rei_information15,'L',l_rei_rec.rei_information15,'Y');
2849 	 ELSIF l_first_noa_code = '480' THEN
2850 	    set_ei(l_org_rec.rei_information15,'P',l_rei_rec.rei_information15,'Y');
2851 	 END IF;
2852 
2853      ELSE
2854            hr_utility.set_location('l_rei_rec.rei_information15 '||l_rei_rec.rei_information15 ,1000);
2855 hr_utility.set_location('l_first_noa_code '||l_first_noa_code ,1000);
2856        IF l_rei_rec.rei_information15  IS NULL THEN
2857          IF l_second_noa_code = '430' THEN
2858 	     l_rei_rec.rei_information15 :=  'O';
2859 
2860 	 ELSIF l_second_noa_code = '450' THEN
2861 	     l_rei_rec.rei_information15 :=  'S';
2862 	     hr_utility.set_location('l_rei_rec.rei_information15 '||l_rei_rec.rei_information15 ,1000);
2863          ELSIF l_second_noa_code = '452' THEN
2864  	     l_rei_rec.rei_information15 :=  'T';
2865 	 ELSIF l_second_noa_code = '460' THEN
2866 	     l_rei_rec.rei_information15 :=  'L';
2867 	 ELSIF l_second_noa_code = '480' THEN
2868 	     l_rei_rec.rei_information15 :=  'P';
2869 	 END IF;
2870        END IF;
2871      END IF;
2872 
2873 
2874 
2875 
2876     End non_pay_duty;
2877     --
2878     --
2879     Procedure lwop_info  is
2880       l_special_info       ghr_api.special_information_type;
2881     begin
2882 
2883       If l_person_id is not null then
2884           l_refresh_flag := l_per_refresh_flag;
2885           hr_utility.set_location('l_refresh_flag is ' || l_refresh_flag,5);
2886           IF NVL(l_noa_family_code,'C') = 'CORRECT' THEN
2887              ghr_history_fetch.fetch_peopleei
2888              (p_person_id          =>  l_person_id,
2889               p_information_type   =>  'GHR_US_PER_GROUP1',
2890               p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2891               p_per_ei_data        =>  l_per_ei_data
2892              );
2893              set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information4,l_rei_rec.rei_information3,l_refresh_flag);
2894           END IF;
2895           l_per_ei_data  := null;
2896       End if;
2897 
2898       --Bug # 12652438
2899       IF NVL(l_noa_family_code,'C') <> 'CORRECT' THEN
2900          IF l_first_noa_code = '471' THEN
2901 	    set_ei(l_org_rec.rei_information6,'P',l_rei_rec.rei_information6,'Y');
2902 	 ELSIF  l_first_noa_code = '472' THEN
2903     	    set_ei(l_org_rec.rei_information6,'G',l_rei_rec.rei_information6,'Y');
2904 	 ELSIF  l_first_noa_code = '473' THEN
2905 	 --Bug # 11060755
2906 	     IF NVL(l_la_code2,'@@@') = 'QRD' THEN
2907 	       set_ei(l_org_rec.rei_information6,'Q',l_rei_rec.rei_information6,'Y');
2908 	     ELSE
2909 	       set_ei(l_org_rec.rei_information6,'U',l_rei_rec.rei_information6,'Y');
2910 	     END IF;
2911          END IF;
2912       ELSE
2913         IF l_rei_rec.rei_information6 IS NULL THEN
2914 	   IF l_second_noa_code = '471' THEN
2915                l_rei_rec.rei_information6 := 'P';
2916 	   ELSIF  l_second_noa_code = '472' THEN
2917     	       l_rei_rec.rei_information6 := 'G';
2918 	   ELSIF  l_second_noa_code = '473' THEN
2919 	    --Bug # 11060755
2920 	     IF NVL(l_sec_la_code2,'@@@') = 'QRD' THEN
2921 	       l_rei_rec.rei_information6 := 'Q';
2922 	     ELSE
2923 	       l_rei_rec.rei_information6 := 'U';
2924 	     END IF;
2925            END IF;
2926         END IF;
2927        END IF;
2928     End lwop_info;
2929     --
2930     --
2931     Procedure gov_awards  is
2932      cursor c_bg1 is
2933         SELECT  business_group_id
2934         FROM            per_positions
2935         WHERE           position_id = p_position_id;
2936      cursor c_noa_code is
2937         SELECT 'X'
2938         FROM ghr_nature_of_actions
2939         WHERE  nature_of_action_id = p_noa_id
2940          and code in ('825','840','841','842','843','844','845','846',
2941                         '847','848','849','878','879' ); -- Bug 3266198 Added 848 and 849 to the NOA codes.
2942      l_agency_code   ghr_pa_requests.agency_code%type;
2943      l_bg_id         per_positions.business_group_id%type;
2944 
2945     --
2946     begin
2947        --
2948        -- populate the date award earned field with the effective_date
2949        --
2950      IF NVL(l_noa_family_code,'C') <> 'CORRECT' THEN  -- Bug 2836175
2951        l_refresh_flag   :=  l_per_refresh_flag;
2952        hr_utility.set_location('eff. date is  '  || fnd_date.date_to_canonical(p_effective_date),1);
2953 
2954        --set_ei(l_org_rec.rei_information9, fnd_date.date_to_canonical(p_effective_date), l_rei_rec.rei_information9, l_refresh_flag);
2955        --Bug 2833942
2956        set_ei(l_org_rec.rei_information9, NVL(l_rei_rec.rei_information9,fnd_date.date_to_canonical(p_effective_date)), l_rei_rec.rei_information9, l_refresh_flag);
2957 
2958        hr_utility.set_location('Eff date ' || p_effective_date,1);
2959        hr_utility.set_location('Info9 for Gov Awards ' || l_org_rec.rei_information9,1);
2960        -- Start Bug 1379280
2961        FOR c_noa_code1 in c_noa_code LOOP
2962        IF p_position_id is NOT NULL then
2963          FOR c_bg_id     in c_bg1 LOOP
2964            l_bg_id := c_bg_id.business_group_id;
2965          END LOOP;
2966          l_agency_code   := ghr_api.get_position_agency_code_pos
2967 			    (p_position_id          =>      p_position_id
2968 			    ,p_business_group_id    =>      l_bg_id);
2969          set_ei(l_org_rec.rei_information3, substr(l_agency_code,1,2), l_rei_rec.rei_information3, l_refresh_flag);
2970        END IF;
2971        END LOOP;
2972        IF l_position_id is not null then
2973          l_refresh_flag := l_pos_refresh_flag;
2974          ghr_history_fetch.fetch_positionei
2975          (p_position_id        =>  l_position_id,
2976          p_information_type   =>  'GHR_US_POS_GRP2',
2977          p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
2978          p_pos_ei_data        =>  l_pos_ei_data);
2979          set_ei(l_org_rec.rei_information10,l_pos_ei_data.poei_information13,l_rei_rec.rei_information10,l_refresh_flag);
2980        END IF;
2981      END IF;
2982 
2983        -- End Bug 1379280
2984        --
2985     End gov_awards;
2986     --
2987     -- Bug#5039072 Added procedure service_obligation.
2988     Procedure service_obligation IS
2989         l_serv_oblig_code VARCHAR2(50);
2990         l_serv_oblig_stdt DATE;
2991         l_serv_oblig_enddt DATE;
2992     BEGIN
2993         --
2994         hr_utility.set_location('Entering Service Obligation. l_person_id '||l_person_id,0);
2995         hr_utility.set_location('shadow type code '||l_org_rec.rei_information3,1);
2996         hr_utility.set_location('shadow start date '||l_org_rec.rei_information5,1);
2997         hr_utility.set_location('shadow end date '||l_org_rec.rei_information4,1);
2998         hr_utility.set_location('RPAEIT type code '||l_rei_rec.rei_information3,1);
2999         hr_utility.set_location('RPAEIT start date '||l_rei_rec.rei_information5,1);
3000         hr_utility.set_location('RPAEIT end date '||l_rei_rec.rei_information4,1);
3001 
3002         l_serv_oblig_code := NULL;
3003         l_serv_oblig_stdt := NULL;
3004         l_serv_oblig_enddt := NULL;
3005 
3006         If p_person_id is not null then
3007             l_refresh_flag := l_per_refresh_flag;
3008 
3009             IF l_first_noa_code IN ('815','816') THEN
3010                 IF l_la_code1 IN ('V8V') THEN
3011                     l_serv_oblig_code := 'A4';
3012                 ELSE
3013                     l_serv_oblig_code := '04';
3014                 END IF;
3015             ELSE
3016                 IF l_la_code1 IN ('VPR','VPS') AND
3017                    NVL(l_payment_option,'B') <> 'B' THEN
3018                     l_serv_oblig_code := 'A1';
3019                 END IF;
3020             END IF;
3021 
3022         -- Bug#5132121 Service Obligation for Student Loan and MD/DDS
3023         IF l_first_noa_code IN ('817') THEN
3024           l_serv_oblig_code := '02';
3025         END IF;
3026         IF l_first_noa_code IN ('850') THEN
3027           l_serv_oblig_code := 'A3';
3028         END IF;
3029         IF l_first_noa_code IN ('480') THEN
3030           l_serv_oblig_code := 'A5';
3031         END IF;
3032         -- Bug#5132121 Service Obligation for Student Loan and MD/DDS
3033 
3034             set_ei(l_org_rec.rei_information3,l_serv_oblig_code,l_rei_rec.rei_information3,l_refresh_flag);
3035             -- Bug#5039072 If the Service Oblig Type is NULL THEN Don't default the Start Date.
3036             IF  l_serv_oblig_code IS NULL THEN
3037                 set_ei(l_org_rec.rei_information4,l_serv_oblig_stdt,l_rei_rec.rei_information4,l_refresh_flag);
3038                 set_ei(l_org_rec.rei_information5,l_serv_oblig_enddt,l_rei_rec.rei_information5,l_refresh_flag);
3039             ELSE
3040                 set_ei(l_org_rec.rei_information4,fnd_date.date_to_canonical(p_effective_date),l_rei_rec.rei_information4,l_refresh_flag);
3041                 set_ei(l_org_rec.rei_information5,l_serv_oblig_enddt,l_rei_rec.rei_information5,l_refresh_flag);
3042             END IF;
3043             l_per_ei_data  := null;
3044         End if;
3045     END service_obligation;
3046     --
3047     --
3048     Procedure  chg_sched_hours is
3049         -- Bug#2468297
3050         Cursor c_work_sch is
3051                select work_schedule
3052                from ghr_pa_requests
3053                where pa_request_id = p_pa_request_id;
3054 
3055         l_work_schedule ghr_pa_requests.work_schedule%type;
3056     Begin
3057        If l_assignment_id is not null then
3058           l_refresh_flag := l_asg_refresh_flag;
3059            ghr_history_fetch.fetch_asgei
3060            (p_assignment_id      =>  l_assignment_id,
3061             p_information_type   =>  'GHR_US_ASG_NON_SF52',
3062             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
3063             p_asg_ei_data        =>  l_asg_ei_data
3064            );
3065           --Bug#2468297
3066           FOR work_sch in c_work_sch
3067           LOOP
3068              l_work_schedule := work_sch.work_schedule;
3069           END LOOP;
3070 
3071           If l_work_schedule in ('B','F','G','I','J') then
3072              l_asg_ei_data.aei_information8:=NULL;
3073           End If;
3074 
3075             set_ei(l_org_rec.rei_information7,l_asg_ei_data.aei_information8,
3076                    l_rei_rec.rei_information7,l_refresh_flag);
3077           l_asg_ei_data  := null;
3078        End if;
3079     End chg_sched_hours;
3080     --
3081     Procedure chg_in_tenure  is
3082     --
3083 
3084     begin
3085        --
3086           -- Read from history if person id is not null
3087           IF p_person_id is not null THEN
3088             l_refresh_flag := l_per_refresh_flag;
3089             ghr_history_fetch.fetch_peopleei
3090             (p_person_id          =>  p_person_id,
3091              p_information_type   =>  'GHR_US_PER_GROUP1',
3092              p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
3093              p_per_ei_data        =>  l_per_ei_data
3094              );
3095             set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information3,l_rei_rec.rei_information3,l_refresh_flag);
3096             l_org_rec.rei_information3  :=  l_per_ei_data.pei_information3;
3097           END IF;
3098 	  l_per_ei_data := NULL;
3099        --
3100     End chg_in_tenure;
3101     -- Bug#2759379 Added procedure chg_in_fegli
3102     Procedure chg_in_fegli is
3103     --
3104     begin
3105        --
3106           -- Fetch the element entry value
3107           IF l_assignment_id is not null THEN
3108             l_refresh_flag := l_per_refresh_flag;
3109             ghr_api.retrieve_element_entry_value
3110               (p_element_name         => 'FEGLI',
3111                p_input_value_name     => 'Eligibility Expiration',
3112                p_assignment_id        =>  l_assignment_id,
3113                p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
3114                p_value                =>  l_value,
3115                p_multiple_error_flag  =>  l_multiple_error_flag
3116               );
3117                 set_ei(l_org_rec.rei_information1,l_value,l_rei_rec.rei_information1,l_refresh_flag);
3118           END IF;
3119        --
3120     End chg_in_fegli;
3121     --
3122     Procedure nfc_separation is
3123     --
3124     begin
3125       IF ghr_utility.is_ghr_nfc = 'TRUE' THEN
3126         set_ei(l_org_rec.rei_information12,'1B',l_rei_rec.rei_information12,l_refresh_flag);
3127       END IF;
3128     end nfc_separation;
3129 
3130     -- Bug 4724337 Race or National Origin changes
3131     procedure ethnic_race_info is
3132     begin
3133     	  l_per_ei_data := null;
3134     	  -- Read from history if person id is not null
3135           IF l_person_id IS NOT NULL THEN
3136             l_refresh_flag := l_per_refresh_flag;
3137             ghr_history_fetch.fetch_peopleei
3138             (p_person_id          =>  p_person_id,
3139              p_information_type   =>  'GHR_US_PER_ETHNICITY_RACE',
3140              p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
3141              p_per_ei_data        =>  l_per_ei_data
3142              );
3143             set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information3,l_rei_rec.rei_information3,l_refresh_flag);
3144             set_ei(l_org_rec.rei_information4,l_per_ei_data.pei_information4,l_rei_rec.rei_information4,l_refresh_flag);
3145 			set_ei(l_org_rec.rei_information5,l_per_ei_data.pei_information5,l_rei_rec.rei_information5,l_refresh_flag);
3146 			set_ei(l_org_rec.rei_information6,l_per_ei_data.pei_information6,l_rei_rec.rei_information6,l_refresh_flag);
3147 			set_ei(l_org_rec.rei_information7,l_per_ei_data.pei_information7,l_rei_rec.rei_information7,l_refresh_flag);
3148 			set_ei(l_org_rec.rei_information8,l_per_ei_data.pei_information8,l_rei_rec.rei_information8,l_refresh_flag);
3149 		  END IF;
3150     end ethnic_race_info;
3151 
3152     -- End Bug 4724337 Race or National Origin changes
3153 
3154 
3155      -- Bug#3385386 Added procedure foreign_transfer_allowance
3156     Procedure fta is
3157     --
3158     begin
3159         --
3160         -- Fetch the element entry value
3161         IF l_assignment_id is not null THEN
3162             l_refresh_flag := l_per_refresh_flag;
3163              ghr_api.retrieve_element_entry_value
3164             (p_element_name         => 'Foreign Transfer Allowance',
3165             p_input_value_name     => 'Last Action Code',
3166             p_assignment_id        =>  l_assignment_id,
3167             p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
3168             p_value                =>  l_value,
3169             p_multiple_error_flag  =>  l_multiple_error_flag
3170               );
3171             set_ei(l_org_rec.rei_information3,  l_value,  l_rei_rec.rei_information3,  l_refresh_flag);
3172             l_value := NULL;
3173             ghr_api.retrieve_element_entry_value
3174             (p_element_name         => 'Foreign Transfer Allowance',
3175             p_input_value_name     => 'Number Family Members',
3176             p_assignment_id        =>  l_assignment_id,
3177             p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
3178             p_value                =>  l_value,
3179             p_multiple_error_flag  =>  l_multiple_error_flag
3180               );
3181             set_ei(l_org_rec.rei_information4,  l_value,  l_rei_rec.rei_information4,  l_refresh_flag);
3182             l_value := NULL;
3183             ghr_api.retrieve_element_entry_value
3184             (p_element_name         => 'Foreign Transfer Allowance',
3185             p_input_value_name     => 'Miscellaneous Expense',
3186             p_assignment_id        =>  l_assignment_id,
3187             p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
3188             p_value                =>  l_value,
3189             p_multiple_error_flag  =>  l_multiple_error_flag
3190               );
3191             set_ei(l_org_rec.rei_information5,  l_value,  l_rei_rec.rei_information5,  l_refresh_flag);
3192             l_value := NULL;
3193             ghr_api.retrieve_element_entry_value
3194             (p_element_name         => 'Foreign Transfer Allowance',
3195             p_input_value_name     => 'Wardrobe Expense',
3196             p_assignment_id        =>  l_assignment_id,
3197             p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
3198             p_value                =>  l_value,
3199             p_multiple_error_flag  =>  l_multiple_error_flag
3200               );
3201             set_ei(l_org_rec.rei_information6,  l_value,  l_rei_rec.rei_information6,  l_refresh_flag);
3202             l_value := NULL;
3203             ghr_api.retrieve_element_entry_value
3204             (p_element_name         => 'Foreign Transfer Allowance',
3205             p_input_value_name     => 'Pre Departure Sub Expense',
3206             p_assignment_id        =>  l_assignment_id,
3207             p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
3208             p_value                =>  l_value,
3209             p_multiple_error_flag  =>  l_multiple_error_flag
3210               );
3211             set_ei(l_org_rec.rei_information7,  l_value,  l_rei_rec.rei_information7,  l_refresh_flag);
3212             l_value := NULL;
3213             ghr_api.retrieve_element_entry_value
3214             (p_element_name         => 'Foreign Transfer Allowance',
3215             p_input_value_name     => 'Lease Penalty Expense',
3216             p_assignment_id        =>  l_assignment_id,
3217             p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
3218             p_value                =>  l_value,
3219             p_multiple_error_flag  =>  l_multiple_error_flag
3220               );
3221             set_ei(l_org_rec.rei_information8,  l_value,  l_rei_rec.rei_information8,  l_refresh_flag);
3222                         l_value := NULL;
3223              ghr_api.retrieve_element_entry_value
3224             (p_element_name         => 'Foreign Transfer Allowance',
3225             p_input_value_name     => 'Amount',
3226             p_assignment_id        =>  l_assignment_id,
3227             p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
3228             p_value                =>  l_value,
3229             p_multiple_error_flag  =>  l_multiple_error_flag
3230               );
3231              -- Bug#3754136 Added the format mask to the field l_value.
3232 	     set_ei(l_org_rec.rei_information9, to_char(to_number(l_value),'FM999990.90'),
3233 	                      l_rei_rec.rei_information9,  l_refresh_flag);
3234                         l_value := NULL;
3235         END IF;
3236        --
3237     End fta;
3238     --
3239 
3240     -- Bug 4280026
3241     Procedure key_emergency_essntl
3242     is
3243     Begin
3244 
3245        hr_utility.set_location('l_noa_family_code'||l_noa_family_code,1000);
3246        If l_noa_family_code = 'APP' then
3247           set_ei(l_org_rec.rei_information3,nvl(l_rei_rec.rei_information3,'0'),
3248 			l_rei_rec.rei_information3,'Y');
3249        Else
3250           For get_pos in c_position
3251           Loop
3252 	     --Bug # 13037077 Modified to fetch the latest value for correction actions
3253              If (nvl(get_pos.from_position_id,0) = nvl(get_pos.to_position_id,0))
3254                  or (l_noa_family_code = 'CORRECT') then
3255                 If l_assignment_id is not null then
3256                    -- Get ASG_NON_SF52 data
3257                    l_refresh_flag := l_asg_refresh_flag;
3258                    ghr_history_fetch.fetch_asgei
3259                    (p_assignment_id          =>  l_assignment_id,
3260                     p_information_type       =>  'GHR_US_ASG_NON_SF52',
3261                     p_date_effective         =>  nvl(p_effective_date,trunc(sysdate)),
3262                     p_asg_ei_data            =>  l_asg_ei_data
3263                    );
3264                    set_ei(l_org_rec.rei_information3,l_asg_ei_data.aei_information5,
3265 			l_rei_rec.rei_information3,l_refresh_flag);
3266                    l_asg_ei_data :=  null;
3267                 End If;
3268              Else
3269 
3270 	            hr_utility.set_location('l_noa_family_code'||l_noa_family_code,1000);
3271                 set_ei(l_org_rec.rei_information3,nvl(l_rei_rec.rei_information3,'0'),
3272 			l_rei_rec.rei_information3,'Y');
3273              End If;
3274           End Loop;
3275        End if;
3276     End key_emergency_essntl;
3277 
3278 
3279     -- Bug 5482191
3280     Procedure ghr_conv_dates is
3281    /* --Begin Bug# 4588575
3282     l_tenure       ghr_pa_requests.tenure%type;
3283     l_pos_occpied  ghr_pa_requests.position_occupied%type;
3284     l_pos_intel_pos VARCHAR(30);
3285     CURSOR c_pa_req_details is
3286     SELECT tenure,position_occupied
3287     FROM ghr_pa_requests
3288     WHERE  pa_request_id = p_pa_request_id;
3289    */ --Backout the changes done for Bug# 4588575
3290 
3291     Begin
3292        /* l_per_ei_data := null;
3293         If l_position_id is not null then
3294             ghr_history_fetch.fetch_positionei
3295                 (p_position_id           =>  l_position_id,
3296                 p_information_type       =>  'GHR_US_POS_GRP2',
3297                 p_date_effective         =>  trunc(nvl(p_effective_date,sysdate)),
3298                 p_pos_ei_data            =>  l_pos_ei_data
3299                 );
3300             l_pos_intel_pos := l_pos_ei_data.poei_information15;
3301             l_pos_ei_data := null;
3302         end if;
3303         FOR pa_rec in c_pa_req_details LOOP
3304             l_tenure        := pa_rec.tenure;
3305             l_pos_occpied   := pa_rec.position_occupied;
3306         END LOOP;
3307         --end Bug# 4588575
3308         */ --Backout the changes done for Bug# 4588575
3309         If l_person_id is not null then
3310             ghr_history_fetch.fetch_peopleei
3311                 (p_person_id          =>  l_person_id,
3312                 p_information_type   =>  'GHR_US_PER_CONVERSIONS',
3313                 p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
3314                 p_per_ei_data        =>  l_per_ei_data
3315                 );
3316             l_refresh_flag := l_per_refresh_flag;
3317            /* --Begin Bug# 4588575
3318             IF  nvl(l_tenure,hr_api.g_varchar2) = '2' and
3319                 nvl(l_pos_occpied,hr_api.g_varchar2) = '1' and
3320                 nvl(l_pos_intel_pos,hr_api.g_varchar2) <> '2' THEN
3321                 set_ei(l_org_rec.rei_information3,fnd_date.date_to_canonical(p_effective_date),
3322                 l_rei_rec.rei_information3,l_refresh_flag);
3323             ELSE
3324                 --end Bug# 4588575
3325                 */ --Backout the changes done for Bug# 4588575
3326                 set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information3,
3327 			l_rei_rec.rei_information3,l_refresh_flag);
3328            /* END IF;
3329             --Begin Bug# 4588575
3330             IF  nvl(l_tenure,hr_api.g_varchar2) = '2' and
3331                 nvl(l_pos_occpied,hr_api.g_varchar2) = '1' and
3332                 l_rei_rec.rei_information3 IS NOT NULL THEN
3333                 set_ei(l_org_rec.rei_information4,
3334                 fnd_date.date_to_canonical(add_months(p_effective_date,36)),
3335                 l_rei_rec.rei_information4,l_refresh_flag);
3336             ELSE
3337                 --End Bug# 4588575
3338                 */ --Backout the changes done for Bug# 4588575
3339                 set_ei(l_org_rec.rei_information4,l_per_ei_data.pei_information4,
3340 			l_rei_rec.rei_information4,l_refresh_flag);
3341            -- END IF;
3342 
3343             set_ei(l_org_rec.rei_information5,l_per_ei_data.pei_information5,
3344                      l_rei_rec.rei_information5,l_refresh_flag);
3345             /*--Begin Bug# 4588575
3346             IF  nvl(l_la_code1,hr_api.g_varchar2) = 'J8M'  THEN
3347                 set_ei( l_org_rec.rei_information6,
3348                 fnd_date.date_to_canonical(add_months(p_effective_date,24)),
3349                 l_rei_rec.rei_information6,l_refresh_flag);
3350             ELSE
3351                 --End Bug# 4588575
3352                 */ --Backout the changes done for Bug# 4588575
3353                 set_ei(l_org_rec.rei_information6,l_per_ei_data.pei_information6,
3354 			l_rei_rec.rei_information6,l_refresh_flag);
3355             --END IF;
3356             set_ei(l_org_rec.rei_information7,l_per_ei_data.pei_information7,
3357                      l_rei_rec.rei_information7,l_refresh_flag);
3358 
3359             hr_utility.set_location('rei_ei_data:'||l_rei_rec.rei_information7,0);
3360             l_per_ei_data :=  null;
3361         End If;
3362     End ghr_conv_dates;
3363 
3364    /* --Begin Bug# 4588575
3365     Procedure ghr_prob_info  is
3366         l_pos_occpied  ghr_pa_requests.position_occupied%type;
3367         CURSOR c_pa_req_details is
3368         SELECT position_occupied
3369         FROM ghr_pa_requests
3370         WHERE  pa_request_id = p_pa_request_id;
3371     Begin
3372         l_per_ei_data := null;
3373         If l_person_id is not null then
3374             ghr_history_fetch.fetch_peopleei
3375             (p_person_id          =>  l_person_id,
3376             p_information_type   =>  'GHR_US_PER_PROBATIONS',
3377             p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
3378             p_per_ei_data        =>  l_per_ei_data
3379             );
3380             l_refresh_flag := l_per_refresh_flag;
3381             IF l_first_noa_code not in('130','132','145','147') THEN
3382                 set_ei(l_org_rec.rei_information10,fnd_date.date_to_canonical(p_effective_date),
3383                     l_rei_rec.rei_information10,l_refresh_flag);
3384             ELSE
3385                 set_ei(l_org_rec.rei_information10,l_per_ei_data.pei_information3,
3386                     l_rei_rec.rei_information10,l_refresh_flag);
3387             END IF;
3388             FOR pa_rec in c_pa_req_details LOOP
3389                 l_pos_occpied   := pa_rec.position_occupied;
3390             END LOOP;
3391             IF l_first_noa_code not in('130','132','145','147') and l_pos_occpied = '1' THEN
3392                 set_ei(l_org_rec.rei_information11,
3393                     fnd_date.date_to_canonical(add_months(p_effective_date,12)),
3394                     l_rei_rec.rei_information11,l_refresh_flag);
3395             ELSIF l_first_noa_code not in('130','132','145','147') and l_pos_occpied = '2' THEN
3396                 set_ei(l_org_rec.rei_information11,
3397                     fnd_date.date_to_canonical(add_months(p_effective_date,24)),
3398                     l_rei_rec.rei_information11,l_refresh_flag);
3399             ELSE
3400                 set_ei(l_org_rec.rei_information11,
3401                     l_per_ei_data.pei_information4,
3402                     l_rei_rec.rei_information11,l_refresh_flag);
3403             END IF;
3404             l_pos_ei_data :=  null;
3405         end if;
3406     End ghr_prob_info;
3407     --end Bug# 4588575
3408 */ --Backout the changes done for Bug# 4588575
3409 --Begin Bug# 12557463
3410     Procedure ghr_scd_info  is
3411 
3412         CURSOR c_pa_req_details is
3413         SELECT *
3414         FROM ghr_pa_requests
3415         WHERE  pa_request_id = p_pa_request_id;
3416     --Begin Bug# 14001082
3417     l_service_comp_date      ghr_pa_requests.service_comp_date%type;
3418     l_retirement_plan        ghr_pa_requests.retirement_plan%type;
3419     l_family_code            ghr_pa_requests.noa_family_code%type;
3420     l_second_noa_id          ghr_pa_requests.second_noa_id%type;
3421     l_second_noa_family_code ghr_pa_requests.noa_family_code%type;
3422     --End Bug# 14001082
3423     Begin
3424 	hr_utility.set_location('Entering ddf ghr_scd_info '|| l_noa_family_code,1100);
3425         l_per_ei_data := null;
3426         If l_person_id is not null then
3427             l_refresh_flag := l_per_refresh_flag;
3428 	    FOR pa_rec in c_pa_req_details LOOP
3429 		  l_service_comp_date     := pa_rec.service_comp_date;
3430 		  --Begin Bug# 14001082
3431 		  l_retirement_plan       := pa_rec.retirement_plan;
3432 		  l_family_code		  := pa_rec.noa_family_code;
3433 		  l_second_noa_id	  := pa_rec.second_noa_id;
3434 		 l_second_noa_family_code := ghr_pa_requests_pkg.get_noa_pm_family (l_second_noa_id,p_effective_date);
3435 		 --End Bug# 14001082
3436 	    END LOOP;
3437 
3438             IF substr(l_first_noa_code,1,1) ='1' THEN
3439                 set_ei(l_org_rec.rei_information1,fnd_date.date_to_canonical(l_service_comp_date),
3440                     l_rei_rec.rei_information1,l_refresh_flag);
3441                 set_ei(l_org_rec.rei_information2,fnd_date.date_to_canonical(l_service_comp_date),
3442                     l_rei_rec.rei_information2,l_refresh_flag);
3443                 set_ei(l_org_rec.rei_information3,fnd_date.date_to_canonical(l_service_comp_date),
3444                     l_rei_rec.rei_information3,l_refresh_flag);
3445 		--Begin Bug# 14514445
3446 		set_ei(l_org_rec.rei_information10,fnd_date.date_to_canonical(l_service_comp_date),
3447 		    l_rei_rec.rei_information10,l_refresh_flag);
3448 		--End Bug# 14514445
3449 		--Bug# 15941036 added Retirement codes DR,KR,LR,MR,NR,PR effective from 01-Jan-2013
3450 		IF p_effective_date >= fnd_date.canonical_to_date('2013/01/01') AND
3451 		   nvl(l_retirement_plan,hr_api.g_varchar2) in ('D','K','L','M','N','P','DR','KR','LR','MR','NR','PR') THEN
3452 		    set_ei(l_org_rec.rei_information6,fnd_date.date_to_canonical(l_service_comp_date),
3453 			    l_rei_rec.rei_information6,l_refresh_flag);
3454 		ELSE
3455 		  IF nvl(l_retirement_plan,hr_api.g_varchar2) in ('D','K','L','M','N','P') THEN -- Bug# 14001082
3456 			set_ei(l_org_rec.rei_information6,fnd_date.date_to_canonical(l_service_comp_date),
3457 			    l_rei_rec.rei_information6,l_refresh_flag);
3458 	          --Begin Bug# 14001082
3459 		  ELSE
3460 			set_ei(l_org_rec.rei_information6,NULL,l_rei_rec.rei_information6,l_refresh_flag);
3461 		  END IF;
3462 		END IF;
3463 		--End Bug# 14001082
3464 	    ELSE
3465 	        ghr_history_fetch.fetch_peopleei
3466 		    (p_person_id         =>  l_person_id,
3467 		    p_information_type   =>  'GHR_US_PER_SCD_INFORMATION',
3468 		    p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
3469 		    p_per_ei_data        =>  l_per_ei_data
3470 		    );
3471                 set_ei(l_org_rec.rei_information1,l_per_ei_data.pei_information4,
3472                     l_rei_rec.rei_information1,l_refresh_flag);
3473                 set_ei(l_org_rec.rei_information2,l_per_ei_data.pei_information7,
3474                     l_rei_rec.rei_information2,l_refresh_flag);
3475 		set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information5,
3476                     l_rei_rec.rei_information3,l_refresh_flag);
3477 		set_ei(l_org_rec.rei_information4,l_per_ei_data.pei_information8,
3478                     l_rei_rec.rei_information4,l_refresh_flag);
3479 		set_ei(l_org_rec.rei_information5,l_per_ei_data.pei_information9,
3480                     l_rei_rec.rei_information5,l_refresh_flag);
3481 		--Begin Bug# 14514445
3482 		set_ei(l_org_rec.rei_information10,l_per_ei_data.pei_information13,
3483 		    l_rei_rec.rei_information10,l_refresh_flag);
3484 		--End Bug# 14514445
3485 		--Begin Bug# 14001082
3486 		--Bug# 15941036 added Retirement codes DR,KR,LR,MR,NR,PR effective from 01-Jan-2013
3487 		IF p_effective_date >= fnd_date.canonical_to_date('2013/01/01') AND
3488 		   (l_family_code IN ('CONV_APP','EXT_NTE') OR nvl(l_second_noa_family_code,hr_api.g_varchar2) = 'CONV_APP') AND
3489 		   nvl(l_retirement_plan,hr_api.g_varchar2) in ('D','K','L','M','N','P','DR','KR','LR','MR','NR','PR') AND
3490 		   l_per_ei_data.pei_information6 IS NULL THEN
3491 			set_ei(l_org_rec.rei_information6,fnd_date.date_to_canonical(l_service_comp_date),l_rei_rec.rei_information6,l_refresh_flag);
3492 		ELSIF (l_family_code IN ('CONV_APP','EXT_NTE') OR nvl(l_second_noa_family_code,hr_api.g_varchar2) = 'CONV_APP') AND
3493 		  nvl(l_retirement_plan,hr_api.g_varchar2) in ('D','K','L','M','N','P') AND l_per_ei_data.pei_information6 IS NULL THEN
3494 			set_ei(l_org_rec.rei_information6,fnd_date.date_to_canonical(l_service_comp_date),l_rei_rec.rei_information6,l_refresh_flag);
3495 		ELSE
3496 		        set_ei(l_org_rec.rei_information6,l_per_ei_data.pei_information6,l_rei_rec.rei_information6,l_refresh_flag);
3497 		END IF;
3498 		--End Bug# 14001082
3499 		set_ei(l_org_rec.rei_information8,l_per_ei_data.pei_information12,
3500                     l_rei_rec.rei_information8,l_refresh_flag);
3501 		l_per_ei_data    :=  null;
3502 		ghr_history_fetch.fetch_peopleei
3503 			(p_person_id          =>  l_person_id,
3504 			p_information_type   =>  'GHR_US_PER_UNIFORMED_SERVICES',
3505 			p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
3506 			p_per_ei_data        =>  l_per_ei_data);
3507 
3508 		set_ei(l_org_rec.rei_information7,l_per_ei_data.pei_information5,l_rei_rec.rei_information7,l_refresh_flag);
3509 		l_per_ei_data    :=  null;
3510 
3511 		ghr_history_fetch.fetch_peopleei
3512 			(p_person_id          =>  l_person_id,
3513 			p_information_type   =>  'GHR_US_PER_SEPARATE_RETIRE',
3514 			p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
3515 			p_per_ei_data        =>  l_per_ei_data);
3516 
3517 		set_ei(l_org_rec.rei_information9,l_per_ei_data.pei_information5,l_rei_rec.rei_information9,l_refresh_flag);
3518 		l_pos_ei_data :=  null;
3519             END IF;
3520         end if;
3521 
3522 	hr_utility.set_location('Leaving ddf ghr_scd_info '|| l_noa_family_code,1100);
3523     End ghr_scd_info;
3524 --End Bug# 12557463
3525 
3526     Procedure set_refresh_flags is
3527     Begin
3528 
3529       If p_person_id is not null then
3530         if (p_person_id =  nvl(ghr_par_shd.g_old_rec.person_id,hr_api.g_number) and
3531            (l_rei_rec_exists = 'N' or
3532             trunc(nvl(p_effective_date,sysdate)) <> trunc(nvl(ghr_par_shd.g_old_rec.effective_date,sysdate)))) or
3533 	  --Bug # 9006561 Added this condition to consider if the cancellation of one action and
3534 	  -- correction of another action of the same effective date has been processed consecutively
3535 	     (p_person_id   = nvl(ghr_par_shd.g_old_rec.person_id,hr_api.g_number) and
3536 	      p_pa_request_id <> nvl(ghr_par_shd.g_old_rec.pa_request_id ,hr_api.g_number) and
3537  	      trunc(nvl(p_effective_date,sysdate)) = trunc(nvl(ghr_par_shd.g_old_rec.effective_date,sysdate)))
3538            then
3539            hr_utility.set_location('change in eff. date only',2);
3540            l_person_id := p_person_id;
3541            l_per_refresh_flag := 'Y';
3542         Elsif p_person_id     <> nvl(ghr_par_shd.g_old_rec.person_id,hr_api.g_number) then
3543            hr_utility.set_location('person id has changed',3);
3544            l_person_id        := p_person_id;
3545            l_per_refresh_flag := 'N';
3546         Else
3547             l_person_id := null;
3548         End if;
3549         hr_utility.set_location('person id in  the condition - refresh flag N ' || to_char(l_person_id),1);
3550       End if;
3551       If p_assignment_id is not null then
3552         if (p_assignment_id    = nvl(ghr_par_shd.g_old_rec.employee_assignment_id,hr_api.g_number)  and
3553            (l_rei_rec_exists = 'N' or
3554             trunc(nvl(p_effective_date,sysdate)) <> trunc(nvl(ghr_par_shd.g_old_rec.effective_date,sysdate)))) or
3555 	   --Bug # 9006561 Added this condition to consider if the cancellation of one action and
3556 	  -- correction of another action of the same effective date has been processed consecutively
3557 	     (p_assignment_id   = nvl(ghr_par_shd.g_old_rec.employee_assignment_id,hr_api.g_number) and
3558 	      p_pa_request_id <> nvl(ghr_par_shd.g_old_rec.pa_request_id ,hr_api.g_number) and
3559  	      trunc(nvl(p_effective_date,sysdate)) = trunc(nvl(ghr_par_shd.g_old_rec.effective_date,sysdate)))
3560            then
3561            l_assignment_id := p_assignment_id;
3562            l_asg_refresh_flag := 'Y';
3563         Elsif p_assignment_id <> nvl(ghr_par_shd.g_old_rec.employee_assignment_id,hr_api.g_number) then
3564            l_assignment_id    := p_assignment_id;
3565            l_asg_refresh_flag := 'N';
3566         Else
3567            l_assignment_id := null;
3568         End if;
3569       End if;
3570       If p_position_id is not null then
3571         if (p_position_id      =  nvl(ghr_par_shd.g_old_rec.to_position_id,hr_api.g_number) and
3572            (l_rei_rec_exists = 'N' or
3573             trunc(nvl(p_effective_date,sysdate)) <> trunc(nvl(ghr_par_shd.g_old_rec.effective_date,sysdate)))) or
3574 	  --Bug # 9006561 Added this condition to consider if the cancellation of one action and
3575 	  -- correction of another action of the same effective date has been processed consecutively
3576 	     (p_position_id   = nvl(ghr_par_shd.g_old_rec.to_position_id,hr_api.g_number) and
3577 	      p_pa_request_id <> nvl(ghr_par_shd.g_old_rec.pa_request_id ,hr_api.g_number) and
3578  	      trunc(nvl(p_effective_date,sysdate)) = trunc(nvl(ghr_par_shd.g_old_rec.effective_date,sysdate)))
3579            then
3580            l_position_id      := p_position_id;
3581            l_pos_refresh_flag := 'Y';
3582         Elsif p_position_id   <> nvl(ghr_par_shd.g_old_rec.to_position_id,hr_api.g_number) then
3583            l_position_id      := p_position_id;
3584            l_pos_refresh_flag := 'Y';
3585         Else
3586            l_position_id := null;
3587         End if;
3588       End if;
3589     End set_refresh_flags;
3590     --
3591     --
3592  --Start of Bug# 6312144
3593     procedure ipa_benefits_cont is
3594     begin
3595     	  l_per_ei_data := null;
3596     	  -- Read from history if person id is not null
3597           IF l_person_id IS NOT NULL THEN
3598              l_refresh_flag := l_per_refresh_flag;
3599              ghr_history_fetch.fetch_peopleei
3600                 (p_person_id          =>  p_person_id,
3601                  p_information_type   =>  'GHR_US_PER_BENEFITS_CONT',
3602                  p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
3603                  p_per_ei_data        =>  l_per_ei_data
3604                  );
3605                   set_ei(l_org_rec.rei_information1,l_per_ei_data.pei_information1,l_rei_rec.rei_information1,l_refresh_flag);
3606                   set_ei(l_org_rec.rei_information2,l_per_ei_data.pei_information2,l_rei_rec.rei_information2,l_refresh_flag);
3607 	   	  set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information3,l_rei_rec.rei_information3,l_refresh_flag);
3608 		  set_ei(l_org_rec.rei_information4,l_per_ei_data.pei_information4,l_rei_rec.rei_information4,l_refresh_flag);
3609 		  set_ei(l_org_rec.rei_information5,l_per_ei_data.pei_information5,l_rei_rec.rei_information5,l_refresh_flag);
3610 		  set_ei(l_org_rec.rei_information6,l_per_ei_data.pei_information6,l_rei_rec.rei_information6,l_refresh_flag);
3611 		  set_ei(l_org_rec.rei_information7,l_per_ei_data.pei_information7,l_rei_rec.rei_information7,l_refresh_flag);
3612   		  set_ei(l_org_rec.rei_information12,l_per_ei_data.pei_information12,l_rei_rec.rei_information12,l_refresh_flag);
3613 		  set_ei(l_org_rec.rei_information8,l_per_ei_data.pei_information8,l_rei_rec.rei_information8,l_refresh_flag);
3614 		  set_ei(l_org_rec.rei_information9,l_per_ei_data.pei_information9,l_rei_rec.rei_information9,l_refresh_flag);
3615 		  set_ei(l_org_rec.rei_information10,l_per_ei_data.pei_information10,l_rei_rec.rei_information10,l_refresh_flag);
3616 		  set_ei(l_org_rec.rei_information11,l_per_ei_data.pei_information11,l_rei_rec.rei_information11,l_refresh_flag);
3617 	    END IF;
3618     end ipa_benefits_cont;
3619 
3620     procedure retirement_system_info is
3621     begin
3622     	  l_per_ei_data := null;
3623     	  -- Read from history if person id is not null
3624           IF l_person_id IS NOT NULL THEN
3625             l_refresh_flag := l_per_refresh_flag;
3626             ghr_history_fetch.fetch_peopleei
3627                 (p_person_id          =>  p_person_id,
3628                  p_information_type   =>  'GHR_US_PER_RETIRMENT_SYS_INFO',
3629                  p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
3630                  p_per_ei_data        =>  l_per_ei_data
3631                  );
3632                   set_ei(l_org_rec.rei_information1,l_per_ei_data.pei_information1,l_rei_rec.rei_information1,l_refresh_flag);
3633                   set_ei(l_org_rec.rei_information2,l_per_ei_data.pei_information2,l_rei_rec.rei_information2,l_refresh_flag);
3634 	   	  set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information3,l_rei_rec.rei_information3,l_refresh_flag);
3635 		  set_ei(l_org_rec.rei_information4,l_per_ei_data.pei_information4,l_rei_rec.rei_information4,l_refresh_flag);
3636 		  set_ei(l_org_rec.rei_information5,l_per_ei_data.pei_information5,l_rei_rec.rei_information5,l_refresh_flag);
3637 	  END IF;
3638     end retirement_system_info;
3639 
3640     procedure par_benefits is
3641     begin
3642     -- Read from history if person id is not null
3643           IF l_person_id IS NOT NULL THEN
3644             l_refresh_flag := l_per_refresh_flag;
3645             ghr_history_fetch.fetch_peopleei
3646                 (p_person_id          =>  p_person_id,
3647                  p_information_type   =>  'GHR_US_PER_BENEFIT_INFO',
3648                  p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
3649                  p_per_ei_data        =>  l_per_ei_data
3650                  );
3651                   set_ei(l_org_rec.rei_information1,l_per_ei_data.pei_information16,l_rei_rec.rei_information1,l_refresh_flag);
3652                   set_ei(l_org_rec.rei_information2,l_per_ei_data.pei_information17,l_rei_rec.rei_information2,l_refresh_flag);
3653 	   	  set_ei(l_org_rec.rei_information3,l_per_ei_data.pei_information18,l_rei_rec.rei_information3,l_refresh_flag);
3654 		  set_ei(l_org_rec.rei_information4,l_per_ei_data.pei_information19,l_rei_rec.rei_information4,l_refresh_flag);
3655 		  set_ei(l_org_rec.rei_information5,l_per_ei_data.pei_information20,l_rei_rec.rei_information5,l_refresh_flag);
3656 	  END IF;
3657     end par_benefits;
3658    --End of Bug# 6312144
3659 
3660      --Begin Bug# 8653508
3661    procedure detail_info is
3662 	l_detail_nte_date	ghr_pa_requests.first_noa_information1%type;
3663       CURSOR c_detail_nte_date is
3664         SELECT first_noa_information1
3665         FROM ghr_pa_requests
3666         WHERE  pa_request_id = p_pa_request_id;
3667     begin
3668 	If NVL(l_assignment_id,p_assignment_id) is not null then--bug# 11781442
3669 		l_refresh_flag := l_asg_refresh_flag;
3670 		ghr_history_fetch.fetch_asgei
3671 			(p_assignment_id      =>  NVL(l_assignment_id,p_assignment_id),--bug# 11781442
3672 			p_information_type   =>  'GHR_US_ASG_DET_INFO',
3673 			p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
3674 			p_asg_ei_data        =>  l_asg_ei_data
3675 			);
3676 
3677 		IF l_first_noa_code in ('730','930') THEN
3678 			--Begin Bug# 10182526, removed detail start and end dtes from RPA EIT, no defaulting is required
3679 			/*FOR c_detail_nte_date_rec in c_detail_nte_date LOOP
3680 				l_detail_nte_date := c_detail_nte_date_rec.first_noa_information1;
3681 			END LOOP;
3682 			set_ei(l_org_rec.rei_information1,fnd_date.date_to_canonical(p_effective_date),l_rei_rec.rei_information1,l_refresh_flag);
3683 			set_ei(l_org_rec.rei_information2,l_detail_nte_date,l_rei_rec.rei_information2,l_refresh_flag);*/--End Bug# 10182526
3684 			set_ei(l_org_rec.rei_information4,'N',l_rei_rec.rei_information4,l_refresh_flag);
3685 		ELSE
3686 			--Begin Bug# 10182526
3687 			/*set_ei(l_org_rec.rei_information1,l_asg_ei_data.aei_information1,l_rei_rec.rei_information1,l_refresh_flag);
3688 			IF l_first_noa_code in ('732','932') THEN
3689 				set_ei(l_org_rec.rei_information2,fnd_date.date_to_canonical(p_effective_date),l_rei_rec.rei_information2,l_refresh_flag);
3690 			else
3691 				FOR c_detail_nte_date_rec in c_detail_nte_date LOOP
3692 					l_detail_nte_date := c_detail_nte_date_rec.first_noa_information1;
3693 				END LOOP;
3694 				set_ei(l_org_rec.rei_information2,l_detail_nte_date,l_rei_rec.rei_information2,l_refresh_flag);
3695 			end if;*/--End Bug# 10182526
3696 			set_ei(l_org_rec.rei_information3,l_asg_ei_data.aei_information3,l_rei_rec.rei_information3,l_refresh_flag);
3697 			set_ei(l_org_rec.rei_information4,l_asg_ei_data.aei_information4,l_rei_rec.rei_information4,l_refresh_flag);
3698 			set_ei(l_org_rec.rei_information5,l_asg_ei_data.aei_information5,l_rei_rec.rei_information5,l_refresh_flag);
3699 			set_ei(l_org_rec.rei_information6,l_asg_ei_data.aei_information6,l_rei_rec.rei_information6,l_refresh_flag);
3700 			set_ei(l_org_rec.rei_information7,l_asg_ei_data.aei_information7,l_rei_rec.rei_information7,l_refresh_flag);
3701 			set_ei(l_org_rec.rei_information8,l_asg_ei_data.aei_information8,l_rei_rec.rei_information8,l_refresh_flag);
3702 			set_ei(l_org_rec.rei_information9,l_asg_ei_data.aei_information9,l_rei_rec.rei_information9,l_refresh_flag);
3703 			set_ei(l_org_rec.rei_information10,l_asg_ei_data.aei_information10,l_rei_rec.rei_information10,l_refresh_flag);
3704 			set_ei(l_org_rec.rei_information11,l_asg_ei_data.aei_information11,l_rei_rec.rei_information11,l_refresh_flag);
3705 			set_ei(l_org_rec.rei_information12,l_asg_ei_data.aei_information12,l_rei_rec.rei_information12,l_refresh_flag);
3706 			set_ei(l_org_rec.rei_information13,l_asg_ei_data.aei_information13,l_rei_rec.rei_information13,l_refresh_flag);
3707 		END IF;--Bug# 9583594
3708 	End if;
3709 
3710 	l_asg_ei_data  := null;
3711     end detail_info;
3712     --End Bug# 8653508
3713 
3714 Begin
3715 
3716      -- Bug#4089400 Getting the Family code to restrict DLEI calculation for Correction Actions.
3717      FOR c_noa_fam_code_rec IN c_noa_fam_code
3718      LOOP
3719         l_noa_family_code := c_noa_fam_code_rec.noa_family_code;
3720         -- Bug#5039072 RRR Changes.
3721         l_first_noa_code  := c_noa_fam_code_rec.first_noa_code;
3722 	l_second_noa_code :=  c_noa_fam_code_rec.second_noa_code;
3723         l_la_code1        := c_noa_fam_code_rec.la_code1;
3724         l_la_code2        := c_noa_fam_code_rec.la_code2;
3725 	 --Bug # 13376453, 11060755
3726 	l_sec_la_code1    := c_noa_fam_code_rec.sec_la_code1;
3727         l_sec_la_code2    := c_noa_fam_code_rec.sec_la_code2;
3728         l_payment_option  := c_noa_fam_code_rec.payment_option;
3729      END LOOP;
3730      hr_utility.set_location('l_noa_family_code '|| l_noa_family_code,10);
3731 
3732    l_resp_id := fnd_profile.value('RESP_ID');
3733    l_application_id := fnd_profile.value('RESP_APPL_ID');
3734      hr_utility.set_location('Resp id '|| l_resp_id,10);
3735      hr_utility.set_location('appl id '|| l_application_id,10);
3736    for c_info_type_rec in c_info_types(l_application_id,l_resp_id) loop
3737       l_information_type :=  c_info_type_rec.information_type;
3738       l_rei_rec := NULL;
3739 	  l_org_rec := NULL; -- Bug 4691293
3740       l_rei_rec_exists   := 'N';
3741 
3742       -- first populate l_rei_rec with existing values on pa_request_extra_info, if any
3743 
3744       for rei_rec in c_rei_rec loop
3745         l_rei_rec.pa_request_extra_info_id := rei_rec.pa_request_extra_info_id;
3746         l_rei_rec.rei_information1  := rei_rec.rei_information1;
3747         l_rei_rec.rei_information2  := rei_rec.rei_information2;
3748         l_rei_rec.rei_information3  := rei_rec.rei_information3;
3749         l_rei_rec.rei_information4  := rei_rec.rei_information4;
3750         l_rei_rec.rei_information5  := rei_rec.rei_information5;
3751         l_rei_rec.rei_information6  := rei_rec.rei_information6;
3752         l_rei_rec.rei_information7  := rei_rec.rei_information7;
3753         l_rei_rec.rei_information8  := rei_rec.rei_information8;
3754         l_rei_rec.rei_information9  := rei_rec.rei_information9;
3755         l_rei_rec.rei_information10 := rei_rec.rei_information10;
3756         l_rei_rec.rei_information11 := rei_rec.rei_information11;
3757         l_rei_rec.rei_information12 := rei_rec.rei_information12;
3758         l_rei_rec.rei_information13 := rei_rec.rei_information13;
3759         l_rei_rec.rei_information14 := rei_rec.rei_information14;
3760         l_rei_rec.rei_information15 := rei_rec.rei_information15;
3761         l_rei_rec.rei_information16 := rei_rec.rei_information16;
3762         l_rei_rec.rei_information17 := rei_rec.rei_information17;
3763         l_rei_rec.rei_information18 := rei_rec.rei_information18;
3764         l_rei_rec.rei_information19 := rei_rec.rei_information19;
3765         l_rei_rec.rei_information20 := rei_rec.rei_information20;
3766         l_rei_rec.rei_information21 := rei_rec.rei_information21;
3767         l_rei_rec.rei_information22 := rei_rec.rei_information22;
3768         l_rei_rec.rei_information23 := rei_rec.rei_information23;
3769         l_rei_rec.rei_information24 := rei_rec.rei_information24;
3770         l_rei_rec.rei_information25 := rei_rec.rei_information25;
3771         l_rei_rec.rei_information26 := rei_rec.rei_information26;
3772         l_rei_rec.rei_information27 := rei_rec.rei_information27;
3773         l_rei_rec.rei_information28 := rei_rec.rei_information28;
3774         l_rei_rec.rei_information29 := rei_rec.rei_information29;
3775         l_rei_rec.rei_information30 := rei_rec.rei_information30;
3776         l_rei_rec_exists := 'Y';  -- will be used in set_refresh_flags
3777       End loop;
3778 
3779       for rei_rec in c_org_rei_rec loop
3780         l_org_rec.rei_information1  := rei_rec.rei_information1;
3781         l_org_rec.rei_information2  := rei_rec.rei_information2;
3782         l_org_rec.rei_information3  := rei_rec.rei_information3;
3783         l_org_rec.rei_information4  := rei_rec.rei_information4;
3784         l_org_rec.rei_information5  := rei_rec.rei_information5;
3785         l_org_rec.rei_information6  := rei_rec.rei_information6;
3786         l_org_rec.rei_information7  := rei_rec.rei_information7;
3787         l_org_rec.rei_information8  := rei_rec.rei_information8;
3788         l_org_rec.rei_information9  := rei_rec.rei_information9;
3789         l_org_rec.rei_information10 := rei_rec.rei_information10;
3790         l_org_rec.rei_information11 := rei_rec.rei_information11;
3791         l_org_rec.rei_information12 := rei_rec.rei_information12;
3792         l_org_rec.rei_information13 := rei_rec.rei_information13;
3793         l_org_rec.rei_information14 := rei_rec.rei_information14;
3794         l_org_rec.rei_information15 := rei_rec.rei_information15;
3795         l_org_rec.rei_information16 := rei_rec.rei_information16;
3796         l_org_rec.rei_information17 := rei_rec.rei_information17;
3797         l_org_rec.rei_information18 := rei_rec.rei_information18;
3798         l_org_rec.rei_information19 := rei_rec.rei_information19;
3799         l_org_rec.rei_information20 := rei_rec.rei_information20;
3800         l_org_rec.rei_information21 := rei_rec.rei_information21;
3801         l_org_rec.rei_information22 := rei_rec.rei_information22;
3802         l_org_rec.rei_information23 := rei_rec.rei_information23;
3803         l_org_rec.rei_information24 := rei_rec.rei_information24;
3804         l_org_rec.rei_information25 := rei_rec.rei_information25;
3805         l_org_rec.rei_information26 := rei_rec.rei_information26;
3806         l_org_rec.rei_information27 := rei_rec.rei_information27;
3807         l_org_rec.rei_information28 := rei_rec.rei_information28;
3808         l_org_rec.rei_information29 := rei_rec.rei_information29;
3809         l_org_rec.rei_information30 := rei_rec.rei_information30;
3810       End loop;
3811 
3812 
3813       -- call the procedure to set the refresh flags
3814       If p_refresh_flag = 'N' then
3815           set_refresh_flags;
3816       Else
3817         hr_utility.set_location('p_refresh_flag is Y',3);
3818         l_per_refresh_flag := 'Y';
3819         l_asg_refresh_flag := 'Y';
3820         l_pos_refresh_flag := 'Y';
3821 
3822 	--Bug # 13037077 Modified to assign the ids
3823 	l_person_id := p_person_id;
3824         l_assignment_id := p_assignment_id;
3825         l_position_id   := p_position_id;
3826       End if;
3827       --
3828       hr_utility.set_location('INFO_TYPE_IS'|| l_information_type,0);
3829       hr_utility.set_location('PER ID is'|| l_person_id,0);
3830       if l_information_type = 'GHR_US_PAR_APPT_INFO' then
3831         hr_utility.set_location(l_proc,5);
3832         hr_utility.set_location('info type ' || l_information_type,1);
3833         appt_info;
3834       elsif l_information_type =  'GHR_US_PAR_MD_DDS_PAY' then
3835         hr_utility.set_location(l_proc,15);
3836         hr_utility.set_location('info type ' || l_information_type,3);
3837         mddds_pay;
3838       elsif l_information_type =  'GHR_US_PAR_PREMIUM_PAY_IND' then
3839         hr_utility.set_location(l_proc,15);
3840         hr_utility.set_location('info type ' || l_information_type,3);
3841         premium_pay_ind;
3842 
3843       elsif l_information_type =  'GHR_US_PAR_APPT_TRANSFER' then
3844         hr_utility.set_location(l_proc,10);
3845         hr_utility.set_location('info type ' || l_information_type,2);
3846         for c_req_num_rec in c_req_num loop
3847 	--Bug 3128526. Added 'NVL' to handle NULL values
3848           if nvl(c_req_num_rec.request_number,hr_api.g_number) <> 'MTI'||to_char(p_pa_request_id) then
3849             appt_transfer;
3850           end if;
3851         end loop;
3852       elsif l_information_type =  'GHR_US_PAR_CONV_APP' then
3853         hr_utility.set_location(l_proc,15);
3854         hr_utility.set_location('info type ' || l_information_type,3);
3855         conv_appt;
3856       elsif l_information_type = 'GHR_US_PAR_RETURN_TO_DUTY' then
3857         hr_utility.set_location(l_proc,20);
3858         hr_utility.set_location('info type ' || l_information_type,4);
3859         return_to_duty;
3860 	elsif l_information_type = 'GHR_US_PAR_REASSIGNMENT' then
3861         hr_utility.set_location(l_proc,25);
3862         hr_utility.set_location('info type ' || l_information_type,4);
3863         reassignment;
3864       elsif l_information_type = 'GHR_US_PAR_REALIGNMENT' then
3865         hr_utility.set_location(l_proc,30);
3866         hr_utility.set_location('info type ' || l_information_type,4);
3867         realign;
3868       elsif l_information_type =  'GHR_US_PAR_CHG_DATA_ELEMENT' then
3869         hr_utility.set_location(l_proc,45);
3870         hr_utility.set_location('info type ' || l_information_type,4);
3871         chg_data_element;
3872       elsif  l_information_type =  'GHR_US_PAR_CHG_RETIRE_PLAN' then
3873         hr_utility.set_location(l_proc,50);
3874         hr_utility.set_location('info type ' || l_information_type,4);
3875         chg_retire_plan;
3876 	--bug# 14030562, 12557463 commneted below as GHR_US_PAR_CHG_SCD disabled
3877       /*elsif  l_information_type =  'GHR_US_PAR_CHG_SCD' then
3878         hr_utility.set_location(l_proc,55);
3879         hr_utility.set_location('info type ' || l_information_type,4);
3880         chg_scd;   */
3881 	--Begin bug# 14751665,15882322,15882330
3882       elsif  l_information_type =  'GHR_US_PAR_PRV_RET_INFO' then
3883         hr_utility.set_location(l_proc ,55);
3884         hr_utility.set_location('info type ' || l_information_type,14);
3885         prv_ret_info;
3886       --End Bug# 14751665,15882322,15882330
3887       --Bug#2146912  Added condition for GHR_US_PAR_TSP
3888       elsif  l_information_type =  'GHR_US_PAR_TSP' then
3889         hr_utility.set_location(l_proc,60);
3890         hr_utility.set_location('info type ' || l_information_type,4);
3891         scd_tsp;
3892       elsif  l_information_type =  'GHR_US_PAR_NON_PAY_DUTY_STATUS' then
3893         hr_utility.set_location(l_proc,80);
3894         hr_utility.set_location('info type ' || l_information_type,4);
3895         non_pay_duty;
3896       elsif  l_information_type = 'GHR_US_PAR_LWOP_INFO' then
3897         hr_utility.set_location(l_proc,90);
3898         lwop_info;
3899       elsif  l_information_type = 'GHR_US_PAR_AWARDS_BONUS' then
3900         hr_utility.set_location(l_proc,95);
3901         gov_awards;
3902       elsif  l_information_type = 'GHR_US_PAR_CHG_HOURS' then
3903         hr_utility.set_location(l_proc,100);
3904         chg_sched_hours;
3905       elsif  l_information_type = 'GHR_US_PAR_CHG_TEN' then
3906         hr_utility.set_location(l_proc,110);
3907         chg_in_tenure;
3908       --  Bug#2759379 Added condition for GHR_US_PAR_FEGLI
3909       elsif  l_information_type = 'GHR_US_PAR_FEGLI'   then
3910         hr_utility.set_location(l_proc,120);
3911         chg_in_fegli;
3912       -- Bug#3385386 Added the following if condition.
3913       elsif  l_information_type = 'GHR_US_PAR_FOR_TRANSER_ALLOW'   then
3914         hr_utility.set_location(l_proc,125);
3915         fta;
3916       elsif  l_information_type = 'GHR_US_PAR_NFC_SEPARATION_INFO'   then
3917         hr_utility.set_location(l_proc,130);
3918         nfc_separation;
3919       elsif l_information_type = 'GHR_US_PAR_ETHNICITY_RACE'   then
3920       	hr_utility.set_location(l_proc,120);
3921 		hr_utility.set_location('info type ' || l_information_type,1);
3922         ethnic_race_info;
3923 	  elsif  l_information_type = 'GHR_US_PAR_BENEFITS'   then
3924         hr_utility.set_location(l_proc,125);
3925 		hr_utility.set_location('info type ' || l_information_type,1);
3926 	--Bug # 10420280 Modified to not to call benefits for correction
3927          IF NVL(l_noa_family_code,'C') <> 'CORRECT' THEN
3928              appt_benefits;
3929 	 END IF;
3930       --Bug# 5039072 Added procedure service_obligation.
3931       elsif  l_information_type = 'GHR_US_PAR_SERVICE_OBLIGATION'   then
3932         hr_utility.set_location(l_proc,130);
3933 		hr_utility.set_location('info type ' || l_information_type,1);
3934         service_obligation;
3935       -- Bug 4280026
3936       elsif  l_information_type = 'GHR_US_PAR_EMERG_ESSNTL_ASG'   then
3937         hr_utility.set_location(l_proc,135);
3938         hr_utility.set_location('info type ' || l_information_type,1);
3939         key_emergency_essntl;
3940       -- Bug 5482191
3941       elsif  l_information_type = 'GHR_US_PAR_CONVERSION_DATES'   then
3942         hr_utility.set_location(l_proc,140);
3943         hr_utility.set_location('info type ' || l_information_type,1);
3944         ghr_conv_dates;
3945       /*      --Begin Bug# 4588575
3946       elsif l_information_type = 'GHR_US_PAR_PROBATION_INFO' then
3947             hr_utility.set_location(l_proc,270);
3948             hr_utility.set_location('info type ' || l_information_type,270);
3949             ghr_prob_info;
3950       --end Bug# 4588575
3951             */ --Backout the changes done for Bug# 4588575
3952       --Begin Bug# 12557463
3953       elsif l_information_type = 'GHR_US_PAR_SCD_INFO' then
3954             hr_utility.set_location(l_proc,280);
3955             hr_utility.set_location('info type ' || l_information_type,280);
3956             ghr_scd_info;
3957        --End Bug# 12557463
3958 -- Modifications related to Bug#6312144 -- New RPA EIT Benefits
3959 -- Bug# 8653508 added INFO GHR_US_PAR_DET_BENEFIT_CONT
3960       elsif l_information_type IN  ('GHR_US_PAR_BENEFITS_CONT','GHR_US_PAR_DET_BENEFIT_CONT') then
3961        hr_utility.set_location(l_proc,5);
3962        hr_utility.set_location('info type ' || l_information_type,1);
3963        ipa_benefits_cont;
3964       -- Begin Bug# 8653508
3965       elsif l_information_type = ('GHR_US_PAR_DET_INFO') then
3966        hr_utility.set_location(l_proc,5);
3967        hr_utility.set_location('info type ' || l_information_type,1);
3968        detail_info;
3969        --End Bug# 8653508
3970       elsif l_information_type = 'GHR_US_PAR_RETIRMENT_SYS_INFO' then
3971        hr_utility.set_location(l_proc,5);
3972        hr_utility.set_location('info type ' || l_information_type,1);
3973        retirement_system_info;
3974       elsif l_information_type = 'GHR_US_PAR_BENEFIT_INFO' then
3975        hr_utility.set_location(l_proc,5);
3976        hr_utility.set_location('info type ' || l_information_type,1);
3977        par_benefits;
3978 -- Modifications related to Bug#6312144 -- New RPA EIT Benefits
3979       end if;
3980 
3981       --  No defaulting reqd. for the families (Recruitment Bonus, Relocation Bonus,
3982       --  Gov. Awards,salary_chg, denial_wgi,realignment,chg_hours,posn_chg
3983       --  because for these it makes no sense to default existing details
3984       --  as the user will have to enter only the current data and
3985       --  would not want to see the existing data.
3986       -- Bug#4089400 Added condition to skip the DLEI Processing for Correction Actions.
3987       IF l_information_type = 'GHR_US_PAR_SALARY_CHG' THEN
3988         IF NVL(l_noa_family_code,'C') <> 'CORRECT' THEN
3989             l_psi := ghr_pa_requests_pkg.get_personnel_system_indicator
3990                      (p_position_id,
3991                       p_effective_date);
3992 
3993             IF l_psi <> '00' THEN
3994                 OPEN c_afhr_noac_sal_chg;
3995                 FETCH c_afhr_noac_sal_chg INTO l_dlei_date;
3996                 IF l_dlei_date is not null THEN
3997                     set_ei(l_org_rec.rei_information5,
3998                       fnd_date.date_to_canonical(l_dlei_date),
3999                         l_rei_rec.rei_information5,'Y');
4000                 ELSE
4001                     -- Bug 3263140
4002                     --Setting the value to NULL only if the original value is NULL
4003                     IF l_org_rec.rei_information5 IS NULL THEN
4004 			set_ei(l_org_rec.rei_information5,
4005 			  null,l_rei_rec.rei_information5,'Y');
4006                     END IF;
4007                 END IF;
4008                 CLOSE c_afhr_noac_sal_chg;
4009 
4010             ELSE
4011 
4012                 OPEN c_noac_sal_chg;
4013                 FETCH c_noac_sal_chg INTO l_dlei_date;
4014                 IF l_dlei_date is not null THEN
4015                     set_ei(l_org_rec.rei_information5,
4016                       fnd_date.date_to_canonical(l_dlei_date),
4017                         l_rei_rec.rei_information5,'Y');
4018                 ELSE
4019                     -- Bug 3263140
4020                     --Setting the value to NULL only if the original value is NULL
4021                     IF l_org_rec.rei_information5 IS NULL THEN
4022 			set_ei(l_org_rec.rei_information5,
4023 			  null,l_rei_rec.rei_information5,'Y');
4024                     END IF;
4025                 END IF;
4026                 CLOSE c_noac_sal_chg;
4027             END IF;
4028         END IF;
4029 		-- Bug#4126188 Populating Date Arrived Personnel office
4030 		FOR c_posn_to_frm IN c_position LOOP
4031 			l_from_position_id :=c_posn_to_frm.from_position_id;
4032 			l_to_position_id := c_posn_to_frm.to_position_id;
4033 		END LOOP;
4034 		FOR pa_rec in c_pa_req_2noa_dtls LOOP
4035 			l_second_noa_code := pa_rec.second_noa_code;
4036 		END LOOP;
4037         IF l_first_noa_code IN ('702','703','713') OR
4038            (l_noa_family_code = 'CORRECT' AND l_second_noa_code IN ('702','703','713')) OR
4039            ---Bug# 8263918
4040 	    (l_first_noa_code is not null and l_second_noa_code is not null and l_second_noa_code in ('702','703','713')) THEN
4041         ---Bug# 8263918
4042 			ghr_history_fetch.fetch_positionei
4043 				(p_position_id            =>  l_from_position_id,
4044 				p_information_type       =>  'GHR_US_POS_GRP1',
4045 				p_date_effective         =>  trunc(nvl(p_effective_date,sysdate)),
4046 				p_pos_ei_data            =>  l_pos_ei_data
4047 				);
4048 			l_from_poid := l_pos_ei_data.poei_information3;
4049 			l_pos_ei_data := NULL;
4050 			ghr_history_fetch.fetch_positionei
4051 				(p_position_id            =>  l_to_position_id,
4052 				p_information_type       =>  'GHR_US_POS_GRP1',
4053 				p_date_effective         =>  trunc(nvl(p_effective_date,sysdate)),
4054 				p_pos_ei_data            =>  l_pos_ei_data
4055 				);
4056 			l_to_poid := l_pos_ei_data.poei_information3;
4057 		/*Start - Bug 6129752*/
4058     			IF p_assignment_id IS NULL THEN
4059 			   FOR C_GET_ASSIGNMENNT_ID IN GET_ASSIGNEMNT_ID LOOP
4060 	   			l_assignment_id := C_GET_ASSIGNMENNT_ID.assignment_id;
4061 				IF ( hr_utility.debug_enabled()) THEN
4062 			  	  hr_utility.set_location(' P_Assignment id is null and l_assignment is'||l_assignment_id,1733);
4063 				END IF;
4064 			   END LOOP;
4065 			END IF;
4066 		/*End - Bug 6129752*/
4067 			IF l_from_poid = l_to_poid THEN
4068 				IF l_noa_family_code = 'CORRECT' THEN
4069 	              ghr_history_api.get_g_session_var(l_session);
4070 				  l_session1 := l_session;
4071                   l_session.noa_id_correct := NULL;
4072 				  ghr_history_api.reinit_g_session_var;
4073 				  ghr_history_api.set_g_session_var(l_session);
4074 					ghr_history_fetch.fetch_asgei
4075 						(p_assignment_id          =>  NVL(l_assignment_id,p_assignment_id),
4076 						p_information_type       =>  'GHR_US_ASG_NON_SF52',
4077 						p_date_effective         =>  p_effective_date-1,
4078 						p_asg_ei_data            =>  l_asg_ei_data
4079 						);
4080 						ghr_history_api.reinit_g_session_var;
4081 						ghr_history_api.set_g_session_var(l_session1);
4082 				ELSE
4083 					ghr_history_fetch.fetch_asgei
4084 						(p_assignment_id          =>  NVL(l_assignment_id,p_assignment_id),
4085 						p_information_type       =>  'GHR_US_ASG_NON_SF52',
4086 						p_date_effective         =>  nvl(p_effective_date,trunc(sysdate)),
4087 						p_asg_ei_data            =>  l_asg_ei_data
4088 						);
4089 				END IF;
4090 			set_ei(l_org_rec.rei_information6,l_asg_ei_data.aei_information3,l_rei_rec.rei_information6,'Y');
4091 		/*Start - Bug 6129752*/
4092 			ELSIF l_to_poid IS NULL AND l_noa_family_code = 'CORRECT'  THEN
4093 			  ghr_history_fetch.fetch_asgei
4094 				(p_assignment_id          =>  NVL(l_assignment_id,p_assignment_id),
4095 				p_information_type       =>  'GHR_US_ASG_NON_SF52',
4096 				p_date_effective         =>  nvl(p_effective_date,trunc(sysdate)),
4097 				p_asg_ei_data            =>  l_asg_ei_data
4098 				);
4099 			 set_ei(l_org_rec.rei_information6,l_asg_ei_data.aei_information3,l_rei_rec.rei_information6,'Y');
4100 		/*End - Bug 6129752*/
4101 			ELSE
4102 				FOR c_get_eff_rec in c_get_effective_date
4103 				  LOOP
4104 					 set_ei(l_org_rec.rei_information6,fnd_date.date_to_canonical(c_get_eff_rec.effective_date), l_rei_rec.rei_information6,'Y');
4105 					  exit;
4106 				  END LOOP;
4107 			END IF;
4108 		--Begin Bug# 14514445
4109 		hr_utility.set_location('promotion_eligibility_date Position Id in Salary change '|| l_position_id,350);
4110 		l_pos_ei_data :=  null;
4111 		ghr_history_fetch.fetch_positionei
4112 			(p_position_id                => l_position_id,
4113 			p_information_type           => 'GHR_US_POS_VALID_GRADE',
4114 			p_date_effective             =>  trunc(nvl(p_effective_date,sysdate)),
4115 			p_pos_ei_data                =>  l_pos_ei_data
4116 			);
4117 		FOR  grade_name in grade_id(l_pos_ei_data.poei_information3) LOOP
4118 			l_valid_grade_name := grade_name.name;
4119 			exit;
4120 		END LOOP;
4121 		FOR  grade_name in grade_id(l_pos_ei_data.poei_information4) LOOP
4122 			l_target_grade_name := grade_name.name;
4123 			exit;
4124 		END LOOP;
4125 		hr_utility.set_location('promotion_eligibility_date Valid Grade in Salary change '|| l_valid_grade_name,351);
4126 		hr_utility.set_location('promotion_eligibility_date Target Grade in Salary change '|| l_target_grade_name,352);
4127 
4128 		IF SUBSTR(l_valid_grade_name,1,2) = SUBSTR(l_target_grade_name,1,2) AND
4129 		   TO_NUMBER(SUBSTR(l_valid_grade_name,4,5)) < TO_NUMBER(SUBSTR(l_target_grade_name,4,5)) THEN
4130 			hr_utility.set_location('promotion_eligibility_date default in Salary change '|| l_valid_grade_name,353);
4131 			IF l_first_noa_code IN ('702') THEN
4132 				set_ei(l_org_rec.rei_information7,fnd_date.date_to_canonical(p_effective_date+365),l_rei_rec.rei_information7,l_refresh_flag);
4133 			ELSE
4134 				ghr_history_fetch.fetch_peopleei
4135 				    (p_person_id          =>  l_person_id,
4136 				     p_information_type   =>  'GHR_US_PER_GROUP1',
4137 				     p_date_effective     =>  nvl(p_effective_date,trunc(sysdate)),
4138 				     p_per_ei_data        =>  l_per_ei_data
4139 				     );
4140 			-- Bug# 16023085 modified l_per_ei_data.pei_information19 to l_per_ei_data.pei_information29
4141 			       set_ei(l_org_rec.rei_information7,l_per_ei_data.pei_information29,l_rei_rec.rei_information7,l_refresh_flag);
4142 		       END IF;
4143 		       l_per_ei_data := NULL;
4144 		END IF;
4145 		l_pos_ei_data :=  null;
4146 		--End Bug# 14514445
4147         END IF; -- IF l_first_noa_code IN ('702','703','713') OR
4148         --Bug#4126188 End
4149       END IF;
4150 
4151       l_rei_rec.information_type  :=   l_information_type;
4152       l_rei_rec.pa_request_id     :=   p_pa_request_id;
4153 
4154         hr_utility.set_location('Test Null EI',110);
4155       If l_rei_rec.rei_information1  is not null or  l_rei_rec.rei_information2   is not null or
4156          l_rei_rec.rei_information3  is not null or  l_rei_rec.rei_information4   is not null or
4157          l_rei_rec.rei_information5  is not null or  l_rei_rec.rei_information6   is not null or
4158          l_rei_rec.rei_information7  is not null or  l_rei_rec.rei_information8   is not null or
4159          l_rei_rec.rei_information9  is not null or  l_rei_rec.rei_information10  is not null or
4160          l_rei_rec.rei_information11 is not null or  l_rei_rec.rei_information12  is not null or
4161          l_rei_rec.rei_information13 is not null or  l_rei_rec.rei_information14  is not null or
4162          l_rei_rec.rei_information15 is not null or  l_rei_rec.rei_information16  is not null or
4163          l_rei_rec.rei_information17 is not null or  l_rei_rec.rei_information18  is not null or
4164          l_rei_rec.rei_information19 is not null or  l_rei_rec.rei_information20  is not null or
4165          l_rei_rec.rei_information21 is not null or  l_rei_rec.rei_information22  is not null or
4166          l_rei_rec.rei_information23 is not null or  l_rei_rec.rei_information24  is not null or
4167          l_rei_rec.rei_information25 is not null or  l_rei_rec.rei_information26  is not null or
4168          l_rei_rec.rei_information27 is not null or  l_rei_rec.rei_information28  is not null or
4169          l_rei_rec.rei_information29 is not null or  l_rei_rec.rei_information30  is not null  then
4170          hr_utility.set_location('l_update_rei is Y ',1);
4171         l_update_rei := 'Y';
4172       Else
4173         l_update_rei     := 'N';
4174         hr_utility.set_location('l_update_rei is N ',1);
4175       End if;
4176 
4177         hr_utility.set_location('Test Null EI',110);
4178       determine_operation
4179       (p_pa_request_id            =>  p_pa_request_id,
4180        p_information_type         =>  l_information_type,
4181        p_update_rei               =>  l_update_rei,
4182        p_rei_rec                  =>  l_rei_rec,
4183        p_operation_flag           =>  l_flag,
4184        p_pa_request_extra_info_id =>  l_rei_rec.pa_request_extra_info_id,
4185        p_object_version_number    =>  l_rei_rec.object_version_number
4186       );
4187 
4188       hr_utility.set_location('PAR ' || to_char(l_rei_rec.pa_request_id),1);
4189       hr_utility.set_location('Info type ' || l_rei_rec.information_type,2);
4190       hr_utility.set_location('Flag ' || l_flag ,3);
4191 
4192       generic_populate_extra_info
4193       (p_rei_rec    =>  l_rei_rec,
4194        p_org_rec    =>  l_org_rec,
4195        p_flag       =>  l_flag
4196       );
4197   --
4198   end loop;
4199   --
4200 end fetch_noa_spec_extra_info;
4201 --
4202 --
4203 --
4204     Procedure fetch_generic_extra_info
4205     (p_pa_request_id        in  number,
4206      p_person_id            in  number,
4207      p_assignment_id        in  number,
4208      p_effective_date       in  date  ,
4209      p_refresh_flag         in  varchar2 default 'Y'
4210     )
4211      is
4212      l_perf_appraisal          ghr_api.special_information_type;
4213      l_update_rei              varchar2(1) := 'N';
4214      l_exists                  boolean  := FALSE;
4215      l_flag                    varchar2(1) := null;
4216      l_rei_rec                 ghr_pa_request_extra_info%rowtype;
4217      l_org_rec                 ghr_pa_request_ei_shadow%rowtype;
4218      l_person_id               per_people_f.person_id%type;
4219      l_assignment_id           per_assignments_f.assignment_id%type;
4220      l_per_refresh_flag        varchar2(1);
4221      l_asg_refresh_flag        varchar2(1);
4222      l_business_group_id       per_assignments_f.business_group_id%type;
4223      l_noa_family_code         ghr_noa_families.noa_family_code%type;
4224 
4225      l_proc                    varchar2(72) := g_package || 'fetch_generic_extra_info';
4226      l_information_type        ghr_pa_request_extra_info.information_type%type;
4227      l_person_type             per_person_types.system_person_type%type := hr_api.g_varchar2;
4228 
4229      cursor  c_bus_gp is
4230        select business_group_id
4231        from   per_people_f
4232        where  person_id = p_person_id
4233        and    nvl(p_effective_date,sysdate) between
4234              effective_start_date and effective_end_date;
4235 
4236       cursor c_rei_rec is
4237       select pa_request_extra_info_id,
4238              rei_information1,
4239              rei_information2,
4240              rei_information3,
4241              rei_information4,
4242              rei_information5,
4243              rei_information6,
4244              rei_information7,
4245              rei_information8,
4246              rei_information9,
4247              rei_information10,
4248              rei_information11,
4249              rei_information12,
4250 		 rei_information13,
4251              rei_information14,
4252              rei_information15,
4253              rei_information16,
4254              rei_information17,
4255              rei_information18,
4256              rei_information19,
4257              rei_information20,
4258              rei_information21,
4259              rei_information22,
4260 		 rei_information23,
4261              rei_information24,
4262              rei_information25,
4263              rei_information26,
4264              rei_information27,
4265              rei_information28,
4266              rei_information29,
4267              rei_information30,
4268              object_version_number
4269       from   ghr_pa_request_extra_info
4270       where  pa_request_id    = p_pa_request_id
4271       and    information_type = l_information_type;
4272 
4273    cursor c_org_rei_rec is
4274       select pa_request_extra_info_id,
4275              rei_information1,
4276              rei_information2,
4277              rei_information3,
4278              rei_information4,
4279              rei_information5,
4280              rei_information6,
4281              rei_information7,
4282              rei_information8,
4283              rei_information9,
4284              rei_information10,
4285              rei_information11,
4286              rei_information12,
4287 		 rei_information13,
4288              rei_information14,
4289              rei_information15,
4290              rei_information16,
4291              rei_information17,
4292              rei_information18,
4293              rei_information19,
4294              rei_information20,
4295              rei_information21,
4296              rei_information22,
4297 		 rei_information23,
4298              rei_information24,
4299              rei_information25,
4300              rei_information26,
4301              rei_information27,
4302              rei_information28,
4303              rei_information29,
4304              rei_information30
4305       from   ghr_pa_request_ei_shadow
4306       where  pa_request_extra_info_id = l_rei_rec.pa_request_extra_info_id;
4307 
4308      cursor c_payroll is
4309        select   payroll_id
4310        from     per_assignments_f asg
4311        where    asg.assignment_id = l_assignment_id
4312        and      trunc(nvl(p_effective_date,sysdate))
4313        between  asg.effective_start_date
4314        and      asg.effective_end_date;
4315 
4316     cursor c_noa_fam  is
4317      select par.noa_family_code
4318      from   ghr_pa_requests par
4319      where  pa_request_id = p_pa_request_id;
4320 
4321     Cursor c_def_payroll is
4322      select  pay.payroll_id
4323      from    pay_payrolls_f pay
4324      where   payroll_name  = 'Biweekly'
4325      and     nvl(p_effective_date,sysdate) between
4326              pay.effective_start_date and pay.effective_end_date
4327      and     business_group_id   =  l_business_group_id;
4328 
4329 -- Added by Venkat -- Bug # 1236354
4330  cursor   c_person_type is
4331    select  ppt.system_person_type
4332    from    per_person_types  ppt,
4333            per_people_f      ppf
4334    where   ppf.person_id       =  p_person_id
4335    and     ppt.person_type_id  =  ppf.person_type_id
4336    and     p_effective_date
4337    between ppf.effective_start_date
4338    and     ppf.effective_end_date;
4339 
4340 
4341 
4342      begin
4343        hr_utility.set_location('Entering fetch generic ',1);
4344        hr_utility.set_location('Entering  ' || l_proc,5);
4345        l_update_rei       := 'N';
4346        l_flag             := null;
4347        l_person_id        := p_person_id;
4348        l_assignment_id    := p_assignment_id;
4349        l_per_refresh_flag := p_refresh_flag;
4350        l_asg_refresh_flag := p_refresh_flag;
4351 
4352        l_flag :=  p_refresh_flag;
4353 
4354        for fam_code in c_noa_fam loop
4355          l_noa_family_code := fam_code.noa_family_code;
4356        end loop;
4357 
4358        If l_noa_family_code =  'APP' then
4359           l_flag             := 'Y';
4360           l_asg_refresh_flag := 'Y';
4361        End if;
4362 
4363        If p_refresh_flag = 'N' then
4364          l_person_id := p_person_id;
4365          If p_person_id is null  then
4366             If l_flag = 'N' then
4367             -- check if earlier had information and delete it
4368              l_information_type :=  'GHR_US_PAR_PAYROLL_TYPE' ;
4369              l_rei_rec          :=  Null;
4370              l_org_rec          :=  Null;
4371              for  rei_rec in c_rei_rec loop
4372                l_rei_rec.pa_request_extra_info_id  :=  rei_rec.pa_request_extra_info_id;
4373                l_rei_rec.object_version_number     :=  rei_rec.object_version_number;
4374              end loop;
4375              If l_rei_rec.pa_request_extra_info_id is not null then
4376                generic_populate_extra_info
4377                (p_rei_rec      => l_rei_rec,
4378  	          p_org_rec      => l_org_rec,
4379                 p_flag         => 'D'
4380                 );
4381               End if;
4382             End if;
4383 
4384 
4385            l_information_type :=  'GHR_US_PAR_PERF_APPRAISAL' ;
4386            l_rei_rec          :=  Null;
4387            l_org_rec          :=  Null;
4388 
4389            for  rei_rec in c_rei_rec loop
4390              l_rei_rec.pa_request_extra_info_id  :=  rei_rec.pa_request_extra_info_id;
4391              l_rei_rec.object_version_number     :=  rei_rec.object_version_number;
4392            end loop;
4393            If l_rei_rec.pa_request_extra_info_id is not null then
4394              generic_populate_extra_info
4395              (p_rei_rec      => l_rei_rec,
4396  	        p_org_rec      => l_org_rec,
4397               p_flag         => 'D'
4398              );
4399            End if;
4400 
4401            l_information_type  :=  Null;
4402            l_rei_rec           := Null;
4403            l_org_rec           := Null;
4404          End if;
4405 
4406          If p_person_id is not null then
4407             if  p_person_id      =  nvl(ghr_par_shd.g_old_rec.person_id,hr_api.g_number) and
4408                 trunc(nvl(p_effective_date,sysdate)) <> trunc(nvl(ghr_par_shd.g_old_rec.effective_date,sysdate))
4409                 then
4410               l_person_id    := p_person_id;
4411               l_per_refresh_flag := 'Y';
4412             Elsif p_person_id  <> nvl(ghr_par_shd.g_old_rec.person_id,hr_api.g_number) then
4413               l_person_id      := p_person_id;
4414               l_per_refresh_flag   := 'N';
4415             Else
4416               l_person_id := null;
4417             End if;
4418          End if;
4419 
4420 
4421         If p_assignment_id is not null and l_flag = 'N' then
4422           if  p_assignment_id      =  nvl(ghr_par_shd.g_old_rec.employee_assignment_id,hr_api.g_number)    and
4423                  trunc(nvl(p_effective_date,sysdate)) <> trunc(nvl(ghr_par_shd.g_old_rec.effective_date,sysdate))
4424                 then
4425               l_assignment_id    := p_assignment_id;
4426               l_asg_refresh_flag := 'Y';
4427             Elsif p_assignment_id  <> nvl(ghr_par_shd.g_old_rec.employee_assignment_id,hr_api.g_number) then
4428               --and  l_noa_family_code <> 'APP'
4429               l_assignment_id      := p_assignment_id;
4430               l_asg_refresh_flag   := 'N';
4431             Else
4432               l_assignment_id := null;
4433             End if;
4434      End if;
4435 
4436     End if;
4437 
4438      -- 1. For 'GHR_US_PAR_PAYROLL_TYPE'
4439 
4440        if l_assignment_id is not null
4441            or l_noa_family_code = 'APP' then
4442          l_information_type := 'GHR_US_PAR_PAYROLL_TYPE';
4443          for rei_rec in c_rei_rec loop
4444            l_rei_rec.pa_request_extra_info_id := rei_rec.pa_request_extra_info_id;
4445            l_rei_rec.rei_information1  := rei_rec.rei_information1;
4446            l_rei_rec.rei_information2  := rei_rec.rei_information2;
4447            l_rei_rec.rei_information3  := rei_rec.rei_information3;
4448            l_rei_rec.rei_information4  := rei_rec.rei_information4;
4449            l_rei_rec.rei_information5  := rei_rec.rei_information5;
4450            l_rei_rec.rei_information6  := rei_rec.rei_information6;
4451            l_rei_rec.rei_information7  := rei_rec.rei_information7;
4452            l_rei_rec.rei_information8  := rei_rec.rei_information8;
4453            l_rei_rec.rei_information9  := rei_rec.rei_information9;
4454            l_rei_rec.rei_information10 := rei_rec.rei_information10;
4455            l_rei_rec.rei_information11 := rei_rec.rei_information11;
4456            l_rei_rec.rei_information12 := rei_rec.rei_information12;
4457            l_rei_rec.rei_information13 := rei_rec.rei_information13;
4458            l_rei_rec.rei_information14 := rei_rec.rei_information14;
4459            l_rei_rec.rei_information15 := rei_rec.rei_information15;
4460            l_rei_rec.rei_information16 := rei_rec.rei_information16;
4461            l_rei_rec.rei_information17 := rei_rec.rei_information17;
4462            l_rei_rec.rei_information18 := rei_rec.rei_information18;
4463            l_rei_rec.rei_information19 := rei_rec.rei_information19;
4464            l_rei_rec.rei_information20 := rei_rec.rei_information20;
4465            l_rei_rec.rei_information21 := rei_rec.rei_information21;
4466            l_rei_rec.rei_information22 := rei_rec.rei_information22;
4467            l_rei_rec.rei_information23 := rei_rec.rei_information23;
4468            l_rei_rec.rei_information24 := rei_rec.rei_information24;
4469            l_rei_rec.rei_information25 := rei_rec.rei_information25;
4470            l_rei_rec.rei_information26 := rei_rec.rei_information26;
4471            l_rei_rec.rei_information27 := rei_rec.rei_information27;
4472            l_rei_rec.rei_information28 := rei_rec.rei_information28;
4473            l_rei_rec.rei_information29 := rei_rec.rei_information29;
4474            l_rei_rec.rei_information30 := rei_rec.rei_information30;
4475          End loop;
4476 
4477 
4478          for rei_rec in c_org_rei_rec loop
4479            l_org_rec.rei_information1  := rei_rec.rei_information1;
4480            l_org_rec.rei_information2  := rei_rec.rei_information2;
4481            l_org_rec.rei_information3  := rei_rec.rei_information3;
4482            l_org_rec.rei_information4  := rei_rec.rei_information4;
4483            l_org_rec.rei_information5  := rei_rec.rei_information5;
4484            l_org_rec.rei_information6  := rei_rec.rei_information6;
4485            l_org_rec.rei_information7  := rei_rec.rei_information7;
4486            l_org_rec.rei_information8  := rei_rec.rei_information8;
4487            l_org_rec.rei_information9  := rei_rec.rei_information9;
4488            l_org_rec.rei_information10 := rei_rec.rei_information10;
4489            l_org_rec.rei_information11 := rei_rec.rei_information11;
4490            l_org_rec.rei_information12 := rei_rec.rei_information12;
4491            l_org_rec.rei_information13 := rei_rec.rei_information13;
4492            l_org_rec.rei_information14 := rei_rec.rei_information14;
4493            l_org_rec.rei_information15 := rei_rec.rei_information15;
4494            l_org_rec.rei_information16 := rei_rec.rei_information16;
4495            l_org_rec.rei_information17 := rei_rec.rei_information17;
4496            l_org_rec.rei_information18 := rei_rec.rei_information18;
4497            l_org_rec.rei_information19 := rei_rec.rei_information19;
4498            l_org_rec.rei_information20 := rei_rec.rei_information20;
4499            l_org_rec.rei_information21 := rei_rec.rei_information21;
4500            l_org_rec.rei_information22 := rei_rec.rei_information22;
4501            l_org_rec.rei_information23 := rei_rec.rei_information23;
4502            l_org_rec.rei_information24 := rei_rec.rei_information24;
4503            l_org_rec.rei_information25 := rei_rec.rei_information25;
4504            l_org_rec.rei_information26 := rei_rec.rei_information26;
4505            l_org_rec.rei_information27 := rei_rec.rei_information27;
4506            l_org_rec.rei_information28 := rei_rec.rei_information28;
4507            l_org_rec.rei_information29 := rei_rec.rei_information29;
4508            l_org_rec.rei_information30 := rei_rec.rei_information30;
4509          end loop;
4510 
4511 
4512          hr_utility.set_location(l_proc,10);
4513          l_exists := FALSE;
4514 
4515          If nvl(l_noa_family_code,hr_api.g_varchar2) = 'APP'  then
4516            hr_utility.set_location(l_proc,11);
4517            l_asg_refresh_flag :=  'Y';
4518            If p_person_id is not null then
4519              for bus_gp in c_bus_gp loop
4520                 hr_utility.set_location('bus gp is  ' || bus_gp.business_group_id,12);
4521                 l_business_group_id  := bus_gp.business_group_id;
4522              end loop;
4523            Else
4524              fnd_profile.get('PER_BUSINESS_GROUP_ID',l_business_group_id);
4525              hr_utility.set_location('bus gp is  ' || l_business_group_id,13);
4526            End if;
4527            for def_payroll in c_def_payroll loop
4528               hr_utility.set_location(l_proc,14);
4529               l_exists := TRUE;
4530               set_ei(l_org_rec.rei_information3,to_char(def_payroll.payroll_id),l_rei_rec.rei_information3,l_asg_refresh_flag);
4531               l_rei_rec.information_type := 'GHR_US_PAR_PAYROLL_TYPE';
4532               exit;
4533            end  loop;
4534          ELSE  -- For conversion of exemployee defaults to 'Biweekly' -- Bug # 1236354
4535             hr_utility.set_location(l_proc,15);
4536             FOR person_type_rec in c_person_type LOOP
4537               l_person_type :=   person_type_rec.system_person_type;
4538               hr_utility.set_location(' Person Type is ' || l_person_type,16);
4539               EXIT;
4540             END LOOP;
4541             IF l_noa_family_code = 'CONV_APP' and  l_person_type = 'EX_EMP' THEN
4542               l_asg_refresh_flag :=  'Y';
4543               IF p_person_id is not null THEN
4544                 FOR bus_gp in c_bus_gp LOOP
4545                   hr_utility.set_location('bus gp is  ' || bus_gp.business_group_id,17);
4546                   l_business_group_id  := bus_gp.business_group_id;
4547                 END LOOP;
4548               END IF;
4549               FOR def_payroll in c_def_payroll LOOP
4550                 hr_utility.set_location(l_proc,18);
4551                 l_exists := TRUE;
4552                 set_ei(l_org_rec.rei_information3,to_char(def_payroll.payroll_id),l_rei_rec.rei_information3,l_asg_refresh_flag);
4553                 l_rei_rec.information_type := 'GHR_US_PAR_PAYROLL_TYPE';
4554                 exit;
4555               END LOOP;
4556             ELSE -- fetch payroll from employee's assignment record
4557               FOR payroll in C_payroll LOOP
4558                 hr_utility.set_location(l_proc,19);
4559                 l_exists := TRUE;
4560                 set_ei(l_org_rec.rei_information3,to_char(payroll.payroll_id),l_rei_rec.rei_information3,l_asg_refresh_flag);
4561                 l_rei_rec.information_type := 'GHR_US_PAR_PAYROLL_TYPE';
4562               END LOOP;
4563             END IF;
4564           END IF;
4565 
4566           If l_rei_rec.rei_information3 is not null then
4567             hr_utility.set_location(l_proc,20);
4568             l_update_rei           := 'Y';
4569           End if;
4570 
4571           l_rei_rec.pa_request_id      :=  p_pa_request_id;
4572            hr_utility.set_location(l_proc,25);
4573            determine_operation
4574 	     (p_pa_request_id            =>  p_pa_request_id,
4575             p_information_type         =>  'GHR_US_PAR_PAYROLL_TYPE',
4576             p_update_rei               =>  l_update_rei,
4577             p_rei_rec                  =>  l_rei_rec,
4578             p_operation_flag           =>  l_flag,
4579 	      p_pa_request_extra_info_id => l_rei_rec.pa_request_extra_info_id,
4580             p_object_version_number    => l_rei_rec.object_version_number
4581             );
4582 
4583            hr_utility.set_location(l_proc,30);
4584            generic_populate_extra_info
4585            (p_rei_rec            =>  l_rei_rec,
4586             p_org_rec            =>  l_org_rec,
4587             p_flag               =>  l_flag
4588             );
4589        End if;
4590 
4591        l_rei_rec := null;
4592        l_org_rec := null;
4593 
4594       --2. p_information_type = 'GHR_US_PAR_PERF_APPRAISAL' then
4595 
4596        l_update_rei := 'N';
4597        l_flag       := null;
4598        l_exists     := FALSE;
4599 
4600 
4601        If l_person_id is not null then
4602           l_information_type := 'GHR_US_PAR_PERF_APPRAISAL' ;
4603         for rei_rec in c_rei_rec loop
4604         l_exists := TRUE;
4605         l_rei_rec.pa_request_extra_info_id := rei_rec.pa_request_extra_info_id;
4606         l_rei_rec.rei_information1  := rei_rec.rei_information1;
4607         l_rei_rec.rei_information2  := rei_rec.rei_information2;
4608         l_rei_rec.rei_information3  := rei_rec.rei_information3;
4609         l_rei_rec.rei_information4  := rei_rec.rei_information4;
4610         l_rei_rec.rei_information5  := rei_rec.rei_information5;
4611         l_rei_rec.rei_information6  := rei_rec.rei_information6;
4612         l_rei_rec.rei_information7  := rei_rec.rei_information7;
4613         l_rei_rec.rei_information8  := rei_rec.rei_information8;
4614         l_rei_rec.rei_information9  := rei_rec.rei_information9;
4615         l_rei_rec.rei_information10 := rei_rec.rei_information10;
4616         l_rei_rec.rei_information11 := rei_rec.rei_information11;
4617         l_rei_rec.rei_information12 := rei_rec.rei_information12;
4618         l_rei_rec.rei_information13 := rei_rec.rei_information13;
4619         l_rei_rec.rei_information14 := rei_rec.rei_information14;
4620         l_rei_rec.rei_information15 := rei_rec.rei_information15;
4621         l_rei_rec.rei_information16 := rei_rec.rei_information16;
4622         l_rei_rec.rei_information17 := rei_rec.rei_information17;
4623         l_rei_rec.rei_information18 := rei_rec.rei_information18;
4624         l_rei_rec.rei_information19 := rei_rec.rei_information19;
4625         l_rei_rec.rei_information20 := rei_rec.rei_information20;
4626         l_rei_rec.rei_information21 := rei_rec.rei_information21;
4627         l_rei_rec.rei_information22 := rei_rec.rei_information22;
4628         l_rei_rec.rei_information23 := rei_rec.rei_information23;
4629         l_rei_rec.rei_information24 := rei_rec.rei_information24;
4630         l_rei_rec.rei_information25 := rei_rec.rei_information25;
4631         l_rei_rec.rei_information26 := rei_rec.rei_information26;
4632         l_rei_rec.rei_information27 := rei_rec.rei_information27;
4633         l_rei_rec.rei_information28 := rei_rec.rei_information28;
4634         l_rei_rec.rei_information29 := rei_rec.rei_information29;
4635         l_rei_rec.rei_information30 := rei_rec.rei_information30;
4636       End loop;
4637 
4638       for rei_rec in c_org_rei_rec loop
4639         l_org_rec.rei_information1  := rei_rec.rei_information1;
4640         l_org_rec.rei_information2  := rei_rec.rei_information2;
4641         l_org_rec.rei_information3  := rei_rec.rei_information3;
4642         l_org_rec.rei_information4  := rei_rec.rei_information4;
4643         l_org_rec.rei_information5  := rei_rec.rei_information5;
4644         l_org_rec.rei_information6  := rei_rec.rei_information6;
4645         l_org_rec.rei_information7  := rei_rec.rei_information7;
4646         l_org_rec.rei_information8  := rei_rec.rei_information8;
4647         l_org_rec.rei_information9  := rei_rec.rei_information9;
4648         l_org_rec.rei_information10 := rei_rec.rei_information10;
4649         l_org_rec.rei_information11 := rei_rec.rei_information11;
4650         l_org_rec.rei_information12 := rei_rec.rei_information12;
4651         l_org_rec.rei_information13 := rei_rec.rei_information13;
4652         l_org_rec.rei_information14 := rei_rec.rei_information14;
4653         l_org_rec.rei_information15 := rei_rec.rei_information15;
4654         l_org_rec.rei_information16 := rei_rec.rei_information16;
4655         l_org_rec.rei_information17 := rei_rec.rei_information17;
4656         l_org_rec.rei_information18 := rei_rec.rei_information18;
4657         l_org_rec.rei_information19 := rei_rec.rei_information19;
4658         l_org_rec.rei_information20 := rei_rec.rei_information20;
4659         l_org_rec.rei_information21 := rei_rec.rei_information21;
4660         l_org_rec.rei_information22 := rei_rec.rei_information22;
4661         l_org_rec.rei_information23 := rei_rec.rei_information23;
4662         l_org_rec.rei_information24 := rei_rec.rei_information24;
4663         l_org_rec.rei_information25 := rei_rec.rei_information25;
4664         l_org_rec.rei_information26 := rei_rec.rei_information26;
4665         l_org_rec.rei_information27 := rei_rec.rei_information27;
4666         l_org_rec.rei_information28 := rei_rec.rei_information28;
4667         l_org_rec.rei_information29 := rei_rec.rei_information29;
4668         l_org_rec.rei_information30 := rei_rec.rei_information30;
4669        end loop;
4670 
4671 
4672          hr_utility.set_location(l_proc,40);
4673          ghr_api.return_special_information
4674          (p_person_id            => l_person_id,
4675           p_structure_name       => 'US Fed Perf Appraisal',
4676           p_effective_date       =>  nvl(p_effective_date,trunc(sysdate)),
4677           p_special_info         =>  l_perf_appraisal
4678          );
4679            hr_utility.set_location(l_proc,45);
4680         -- use set_ei
4681            set_ei(l_org_rec.rei_information3,l_perf_appraisal.segment2,l_rei_rec.rei_information3,l_per_refresh_flag);
4682            set_ei(l_org_rec.rei_information4,l_perf_appraisal.segment4,l_rei_rec.rei_information4,l_per_refresh_flag);
4683 
4684 --Bug 3209817
4685 --For autopopulating 'Rating of Record Level' field
4686       IF ( l_noa_family_code IN ('APP','APPT_TRANS') )  THEN
4687            set_ei(l_org_rec.rei_information5,nvl(l_perf_appraisal.segment5,'X'),l_rei_rec.rei_information5,l_per_refresh_flag);
4688       ELSE
4689 	   set_ei(l_org_rec.rei_information5,l_perf_appraisal.segment5,l_rei_rec.rei_information5,l_per_refresh_flag);
4690        END IF;
4691 	   set_ei(l_org_rec.rei_information6,l_perf_appraisal.segment6,l_rei_rec.rei_information6,l_per_refresh_flag);
4692            -- added by skutteti on 6/10/98
4693            set_ei(l_org_rec.rei_information7,l_perf_appraisal.segment1,l_rei_rec.rei_information7,l_per_refresh_flag);
4694            set_ei(l_org_rec.rei_information8,l_perf_appraisal.segment14,l_rei_rec.rei_information8,l_per_refresh_flag);
4695            set_ei(l_org_rec.rei_information9,l_perf_appraisal.segment3,l_rei_rec.rei_information9,l_per_refresh_flag);
4696            set_ei(l_org_rec.rei_information10,l_perf_appraisal.segment7,l_rei_rec.rei_information10,l_per_refresh_flag);
4697            set_ei(l_org_rec.rei_information11,l_perf_appraisal.segment8,l_rei_rec.rei_information11,l_per_refresh_flag);
4698            set_ei(l_org_rec.rei_information12,l_perf_appraisal.segment9,l_rei_rec.rei_information12,l_per_refresh_flag);
4699            set_ei(l_org_rec.rei_information13,l_perf_appraisal.segment10,l_rei_rec.rei_information13,l_per_refresh_flag);
4700            set_ei(l_org_rec.rei_information14,l_perf_appraisal.segment11,l_rei_rec.rei_information14,l_per_refresh_flag);
4701            set_ei(l_org_rec.rei_information15,l_perf_appraisal.segment12,l_rei_rec.rei_information15,l_per_refresh_flag);
4702            set_ei(l_org_rec.rei_information16,l_perf_appraisal.segment13,l_rei_rec.rei_information16,l_per_refresh_flag);
4703            set_ei(l_org_rec.rei_information17,l_perf_appraisal.segment15,l_rei_rec.rei_information17,l_per_refresh_flag);
4704 	   set_ei(l_org_rec.rei_information18,l_perf_appraisal.segment16,l_rei_rec.rei_information18,l_per_refresh_flag);
4705 	  -- added by vmididho (4753117) on 05/mar/2007
4706            set_ei(l_org_rec.rei_information19,l_perf_appraisal.segment17,l_rei_rec.rei_information19,l_per_refresh_flag);
4707 
4708 
4709 
4710           -- l_rei_rec.rei_information3  :=   l_perf_appraisal.segment2;
4711           -- l_rei_rec.rei_information4  :=   l_perf_appraisal.segment4;
4712           -- l_rei_rec.rei_information5  :=   l_perf_appraisal.segment5;
4713           -- l_rei_rec.rei_information6  :=   l_perf_appraisal.segment6;
4714           -- l_rei_rec.information_type  :=   'GHR_US_PAR_PERF_APPRAISAL' ;
4715 
4716     /* If
4717             l_rei_rec.rei_information3  is not null or  l_rei_rec.rei_information4   is not null or
4718             l_rei_rec.rei_information5  is not null or  l_rei_rec.rei_information6   is not null or
4719             l_rei_rec.rei_information7  is not null or  l_rei_rec.rei_information8   is not null or
4720             l_rei_rec.rei_information9  is not null or  l_rei_rec.rei_information10  is not null or
4721             l_rei_rec.rei_information11 is not null or  l_rei_rec.rei_information12  is not null or
4722             l_rei_rec.rei_information13 is not null or  l_rei_rec.rei_information14  is not null or
4723             l_rei_rec.rei_information15 is not null or  l_rei_rec.rei_information16  is not null or
4724             l_rei_rec.rei_information17 is not null or  l_rei_rec.rei_information18  is not null then
4725 
4726             hr_utility.set_location(l_proc,50);
4727             l_update_rei    := 'Y';
4728          Else
4729            hr_utility.set_location(l_proc,55);
4730            l_update_rei     := 'N';
4731          End if;*/
4732 	 --Commented the above IF condition since 'US Fed Perf Appraisal' is a mandatory SIT
4733 	 -- and we will never have to delete this record from the Extra info table.!!
4734          ---Added for bug 3187894
4735          l_update_rei    := 'Y';
4736 	 ---
4737          l_rei_rec.pa_request_id    :=  p_pa_request_id;
4738          l_rei_rec.information_type :=  'GHR_US_PAR_PERF_APPRAISAL';
4739 
4740           hr_utility.set_location(l_proc,60);
4741 
4742          determine_operation
4743 	   (p_pa_request_id      	 =>  p_pa_request_id,
4744           p_information_type   	 =>  'GHR_US_PAR_PERF_APPRAISAL',
4745           p_update_rei               =>  l_update_rei,
4746           p_rei_rec                  =>  l_rei_rec,
4747           p_operation_flag           =>  l_flag,
4748 	    p_pa_request_extra_info_id =>  l_rei_rec.pa_request_extra_info_id,
4749           p_object_version_number    =>  l_rei_rec.object_version_number
4750           );
4751 
4752          hr_utility.set_location(l_proc,65);
4753          generic_populate_extra_info
4754          (p_rei_rec            =>  l_rei_rec,
4755           p_org_rec            =>  l_org_rec,
4756           p_flag               =>  l_flag
4757          );
4758          End if;
4759        hr_utility.set_location('Leaving ' || l_proc,70);
4760     End fetch_generic_extra_info;
4761 
4762 
4763 -- Get Information Type
4764    Procedure get_information_type
4765    (p_noa_id            in   ghr_nature_of_actions.nature_of_action_id%type,
4766     p_information_type  out NOCOPY ghr_pa_request_info_types.information_type%type
4767    )
4768    is
4769 
4770    l_proc    varchar2(72) := g_package  || 'get_information_type';
4771 
4772    Cursor c_info_type is
4773      Select  pit.information_type
4774      from    ghr_pa_request_info_types  pit,
4775              ghr_noa_families           nfa,
4776              ghr_families               fam
4777      where   nfa.nature_of_action_id  = p_noa_id
4778      and     nfa.noa_family_code      = fam.noa_family_code
4779      and     fam.pa_info_type_flag    = 'Y'
4780      and     pit.noa_family_code      = fam.noa_family_code
4781      and     pit.information_type    like 'GHR_US%';
4782 
4783 
4784    Begin
4785      If p_noa_id is not null then
4786        for info_type in  c_info_type loop
4787          p_information_type :=  info_type.information_type;
4788        end loop;
4789      Else
4790        p_information_type := null;
4791      End if;
4792 
4793  End get_information_type;
4794 
4795  Procedure determine_operation
4796  (p_pa_request_id        in    ghr_pa_requests.pa_request_id%type,
4797   p_information_type     in    ghr_pa_request_info_types.information_type%type,
4798   p_update_rei           in    varchar2,
4799   p_rei_rec              in    ghr_pa_request_extra_info%rowtype,
4800   p_operation_flag       out NOCOPY  varchar2,
4801   p_pa_request_extra_info_id out NOCOPY  ghr_pa_request_extra_info.pa_request_extra_info_id%type,
4802   p_object_version_number    out NOCOPY ghr_pa_requests.object_version_number%type
4803   ) is
4804 
4805    l_proc                      varchar2(72) :=  'determine_operation';
4806    l_object_version_number     ghr_pa_requests.object_version_number%type;
4807    l_pa_request_extra_info_id  ghr_pa_request_extra_info.pa_request_extra_info_id%type;
4808    l_exists                    boolean := FALSE;
4809    l_dummy                     ghr_pa_request_extra_info%rowtype;
4810    l_rei_rec                   ghr_pa_request_extra_info%rowtype;
4811    cursor c_rei_rec is
4812       select rei.pa_request_extra_info_id,
4813              rei.object_version_number,
4814              rei.rei_information1,
4815              rei.rei_information2,
4816              rei.rei_information3,
4817              rei.rei_information4,
4818              rei.rei_information5,
4819              rei.rei_information6,
4820              rei.rei_information7,
4821              rei.rei_information8,
4822              rei.rei_information9,
4823              rei.rei_information10,
4824              rei.rei_information11,
4825              rei.rei_information12,
4826              rei.rei_information13,
4827              rei.rei_information14,
4828              rei.rei_information15,
4829              rei.rei_information16,
4830              rei.rei_information17,
4831              rei.rei_information18,
4832              rei.rei_information19,
4833              rei.rei_information20,
4834              rei.rei_information21,
4835              rei.rei_information22,
4836              rei.rei_information23,
4837              rei.rei_information24,
4838              rei.rei_information25,
4839              rei.rei_information26,
4840              rei.rei_information27,
4841              rei.rei_information28,
4842              rei.rei_information29,
4843              rei.rei_information30
4844       from   ghr_pa_request_extra_info rei
4845       where  rei.pa_request_id    = p_pa_request_id
4846       and    rei.information_type = p_information_type;
4847 
4848    Begin
4849      hr_utility.set_location('Entering '|| l_proc,10);
4850      l_rei_rec      :=   p_rei_rec;
4851 
4852      for  rei_rec in c_rei_rec loop
4853        p_object_version_number     := rei_rec.object_version_number;
4854        p_pa_request_extra_info_id  := rei_rec.pa_request_extra_info_id;
4855 --       l_dummy.rei_information1    := rei_rec.rei_information1;
4856 --       l_dummy.rei_information2    := rei_rec.rei_information2;
4857        l_dummy.rei_information3    := rei_rec.rei_information3;
4858        l_dummy.rei_information4    := rei_rec.rei_information4;
4859        l_dummy.rei_information5    := rei_rec.rei_information5;
4860        l_dummy.rei_information6    := rei_rec.rei_information6;
4861        l_dummy.rei_information7    := rei_rec.rei_information7;
4862        l_dummy.rei_information8    := rei_rec.rei_information8;
4863        l_dummy.rei_information9    := rei_rec.rei_information9;
4864        l_dummy.rei_information10   := rei_rec.rei_information10;
4865        l_dummy.rei_information11    := rei_rec.rei_information11;
4866        l_dummy.rei_information12    := rei_rec.rei_information12;
4867        l_dummy.rei_information13    := rei_rec.rei_information13;
4868        l_dummy.rei_information14    := rei_rec.rei_information14;
4869        l_dummy.rei_information15    := rei_rec.rei_information15;
4870        l_dummy.rei_information16    := rei_rec.rei_information16;
4871        l_dummy.rei_information17    := rei_rec.rei_information17;
4872        l_dummy.rei_information18    := rei_rec.rei_information18;
4873        l_dummy.rei_information19    := rei_rec.rei_information19;
4874        l_dummy.rei_information20   := rei_rec.rei_information20;
4875        l_dummy.rei_information21    := rei_rec.rei_information21;
4876        l_dummy.rei_information22    := rei_rec.rei_information22;
4877        l_dummy.rei_information23    := rei_rec.rei_information23;
4878        l_dummy.rei_information24    := rei_rec.rei_information24;
4879        l_dummy.rei_information25    := rei_rec.rei_information25;
4880        l_dummy.rei_information26    := rei_rec.rei_information26;
4881        l_dummy.rei_information27    := rei_rec.rei_information27;
4882        l_dummy.rei_information28    := rei_rec.rei_information28;
4883        l_dummy.rei_information29    := rei_rec.rei_information29;
4884        l_dummy.rei_information30    := rei_rec.rei_information30;
4885        hr_utility.set_location(l_proc,20);
4886        l_exists := true;
4887      end loop;
4888 
4889   -- If non-sf52 data already exists, then as a result of the new changes, there might be need to update/ delete it.
4890   --    If there are changes, then update else do nothing.
4891   --    If the update_flag (update_rei) is 'N' , then delete the existing data.
4892   -- Else if non-sf52 does not exists, then if update_rei = 'Y', then Create. else do nothing.
4893 
4894 
4895      If l_exists then
4896        hr_utility.set_location(' rei exists ',1);
4897        If p_update_rei = 'Y' then
4898          hr_utility.set_location(' Update ',1);
4899          If nvl(l_dummy.rei_information3,hr_api.g_varchar2)  <> nvl(l_rei_rec.rei_information3,hr_api.g_varchar2)   or
4900 			nvl(l_dummy.rei_information4,hr_api.g_varchar2)  <> nvl(l_rei_rec.rei_information4,hr_api.g_varchar2)   or
4901 			nvl(l_dummy.rei_information5,hr_api.g_varchar2)  <> nvl(l_rei_rec.rei_information5,hr_api.g_varchar2)   or
4902 				nvl(l_dummy.rei_information6,hr_api.g_varchar2)  <> nvl(l_rei_rec.rei_information6,hr_api.g_varchar2)   or
4903 			  nvl(l_dummy.rei_information7,hr_api.g_varchar2)  <> nvl(l_rei_rec.rei_information7,hr_api.g_varchar2)   or
4904 				nvl(l_dummy.rei_information8,hr_api.g_varchar2)  <> nvl(l_rei_rec.rei_information8,hr_api.g_varchar2)   or
4905 			nvl(l_dummy.rei_information9,hr_api.g_varchar2)  <> nvl(l_rei_rec.rei_information9,hr_api.g_varchar2)   or
4906 				nvl(l_dummy.rei_information10,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information10,hr_api.g_varchar2)  or
4907 			nvl(l_dummy.rei_information11,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information11,hr_api.g_varchar2)  or
4908 			nvl(l_dummy.rei_information12,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information12,hr_api.g_varchar2)  or
4909 			nvl(l_dummy.rei_information13,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information13,hr_api.g_varchar2)  or
4910 			nvl(l_dummy.rei_information14,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information14,hr_api.g_varchar2)  or
4911 			nvl(l_dummy.rei_information15,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information15,hr_api.g_varchar2)  or
4912 			nvl(l_dummy.rei_information16,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information16,hr_api.g_varchar2)  or
4913 				nvl(l_dummy.rei_information17,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information17,hr_api.g_varchar2)  or
4914 				nvl(l_dummy.rei_information18,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information18,hr_api.g_varchar2)  or
4915 			nvl(l_dummy.rei_information19,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information19,hr_api.g_varchar2)  or
4916 				nvl(l_dummy.rei_information20,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information20,hr_api.g_varchar2)  or
4917 			nvl(l_dummy.rei_information21,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information21,hr_api.g_varchar2)  or
4918 			nvl(l_dummy.rei_information22,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information22,hr_api.g_varchar2)  or
4919 			nvl(l_dummy.rei_information23,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information23,hr_api.g_varchar2)  or
4920 				nvl(l_dummy.rei_information24,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information24,hr_api.g_varchar2)  or
4921 			nvl(l_dummy.rei_information25,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information25,hr_api.g_varchar2)  or
4922 				nvl(l_dummy.rei_information26,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information26,hr_api.g_varchar2)  or
4923 			  nvl(l_dummy.rei_information27,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information27,hr_api.g_varchar2)  or
4924 				nvl(l_dummy.rei_information28,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information28,hr_api.g_varchar2)  or
4925 			nvl(l_dummy.rei_information29,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information29,hr_api.g_varchar2)  or
4926 				nvl(l_dummy.rei_information30,hr_api.g_varchar2) <> nvl(l_rei_rec.rei_information30,hr_api.g_varchar2) then
4927            hr_utility.set_location('operation is Update',1);
4928            p_operation_flag   := 'U';
4929            hr_utility.set_location(l_proc,25);
4930          End if;
4931        Else
4932          hr_utility.set_location(' Delete ',1);
4933           hr_utility.set_location(l_proc,30);
4934          p_operation_flag   := 'D';
4935        End if;
4936      Else
4937        If p_update_rei = 'Y' then
4938          hr_utility.set_location(l_proc,35);
4939          hr_utility.set_location(' Create ',1);
4940          p_operation_flag  := 'C';
4941        Else
4942          hr_utility.set_location(' Null ',1);
4943           hr_utility.set_location(l_proc,40);
4944          p_operation_flag  := null;
4945        End if;
4946      End if;
4947     End determine_operation;
4948 
4949 Procedure generic_populate_extra_info
4950 (p_rei_rec           in      ghr_pa_request_extra_info%rowtype,
4951  p_org_rec           in      ghr_pa_request_ei_shadow%rowtype,
4952  p_flag              in       varchar2
4953 )
4954 is
4955 
4956   l_flag      varchar2(1) := p_flag;
4957   l_rei_rec   ghr_pa_request_extra_info%rowtype := p_rei_rec;
4958   l_org_rec   ghr_pa_request_ei_shadow%rowtype;
4959   l_proc      varchar2(72) := 'generic_populate_extra_info';
4960 
4961 Begin
4962 hr_utility.set_location('Entering ' || l_proc,10);
4963 hr_utility.set_location('Flag  := ' || l_flag,1);
4964 
4965 -- l_flag :
4966 -- C    - Create
4967 -- U    - Update
4968 -- D    - Delete
4969 -- Null - do nothing
4970 
4971 If l_flag is not null then
4972    hr_utility.set_location(l_proc,15);
4973 
4974    If l_flag = 'C' then
4975       hr_utility.set_location(l_proc,20);
4976       ghr_par_extra_info_api.create_pa_request_extra_info
4977      (p_pa_request_id             =>  l_rei_rec.pa_request_id,
4978       p_information_type          =>  l_rei_rec.information_type,  -- to be replaced by the info_type returned by the get_infor._type
4979       p_rei_information_category  =>  l_rei_rec.information_type,
4980       p_rei_information1          =>  l_rei_rec.rei_information1,
4981       p_rei_information2          =>  l_rei_rec.rei_information2,
4982       p_rei_information3          =>  l_rei_rec.rei_information3,
4983       p_rei_information4          =>  l_rei_rec.rei_information4,
4984       p_rei_information5          =>  l_rei_rec.rei_information5,
4985       p_rei_information6          =>  l_rei_rec.rei_information6,
4986       p_rei_information7          =>  l_rei_rec.rei_information7,
4987       p_rei_information8          =>  l_rei_rec.rei_information8,
4988       p_rei_information9          =>  l_rei_rec.rei_information9,
4989       p_rei_information10         =>  l_rei_rec.rei_information10,
4990       p_rei_information11         =>  l_rei_rec.rei_information11,
4991       p_rei_information12         =>  l_rei_rec.rei_information12,
4992       p_rei_information13         =>  l_rei_rec.rei_information13,
4993       p_rei_information14         =>  l_rei_rec.rei_information14,
4994       p_rei_information15         =>  l_rei_rec.rei_information15,
4995       p_rei_information16         =>  l_rei_rec.rei_information16,
4996       p_rei_information17         =>  l_rei_rec.rei_information17,
4997       p_rei_information18         =>  l_rei_rec.rei_information18,
4998       p_rei_information19         =>  l_rei_rec.rei_information19,
4999       p_rei_information20         =>  l_rei_rec.rei_information20,
5000       p_rei_information21         =>  l_rei_rec.rei_information21,
5001       p_rei_information22         =>  l_rei_rec.rei_information22,
5002       p_rei_information23         =>  l_rei_rec.rei_information23,
5003       p_rei_information24         =>  l_rei_rec.rei_information24,
5004       p_rei_information25         =>  l_rei_rec.rei_information25,
5005       p_rei_information26         =>  l_rei_rec.rei_information26,
5006       p_rei_information27         =>  l_rei_rec.rei_information27,
5007       p_rei_information28         =>  l_rei_rec.rei_information28,
5008       p_rei_information29         =>  l_rei_rec.rei_information29,
5009       p_rei_information30         =>  l_rei_rec.rei_information30,
5010       P_PA_REQUEST_EXTRA_INFO_ID  =>  l_rei_rec.pa_request_extra_info_id,
5011       P_OBJECT_VERSION_NUMBER     =>  l_rei_rec.object_version_number
5012       );
5013 
5014       insert into ghr_pa_request_ei_shadow
5015       (
5016       pa_request_extra_info_id ,
5017       pa_request_id  ,
5018       information_type,
5019       rei_information1 ,
5020       rei_information2 ,
5021       rei_information3 ,
5022       rei_information4 ,
5023       rei_information5 ,
5024       rei_information6 ,
5025       rei_information7 ,
5026       rei_information8 ,
5027       rei_information9 ,
5028       rei_information10 ,
5029       rei_information11 ,
5030       rei_information12 ,
5031       rei_information13 ,
5032       rei_information14 ,
5033       rei_information15 ,
5034       rei_information16 ,
5035       rei_information17 ,
5036       rei_information18 ,
5037       rei_information19 ,
5038       rei_information20 ,
5039       rei_information21 ,
5040       rei_information22 ,
5041       rei_information23 ,
5042       rei_information24 ,
5043       rei_information25 ,
5044       rei_information26 ,
5045       rei_information27 ,
5046       rei_information28 ,
5047       rei_information29 ,
5048       rei_information30
5049       ) values
5050       (l_rei_rec.pa_request_extra_info_id,
5051       l_rei_rec.pa_request_id,
5052       l_rei_rec.information_type,
5053       l_rei_rec.rei_information1,
5054       l_rei_rec.rei_information2,
5055       l_rei_rec.rei_information3,
5056       l_rei_rec.rei_information4,
5057       l_rei_rec.rei_information5,
5058       l_rei_rec.rei_information6,
5059       l_rei_rec.rei_information7,
5060       l_rei_rec.rei_information8,
5061       l_rei_rec.rei_information9,
5062       l_rei_rec.rei_information10,
5063       l_rei_rec.rei_information11,
5064       l_rei_rec.rei_information12,
5065       l_rei_rec.rei_information13,
5066       l_rei_rec.rei_information14,
5067       l_rei_rec.rei_information15,
5068       l_rei_rec.rei_information16,
5069       l_rei_rec.rei_information17,
5070       l_rei_rec.rei_information18,
5071       l_rei_rec.rei_information19,
5072       l_rei_rec.rei_information20,
5073       l_rei_rec.rei_information21,
5074       l_rei_rec.rei_information22,
5075       l_rei_rec.rei_information23,
5076       l_rei_rec.rei_information24,
5077       l_rei_rec.rei_information25,
5078       l_rei_rec.rei_information26,
5079       l_rei_rec.rei_information27,
5080       l_rei_rec.rei_information28,
5081       l_rei_rec.rei_information29,
5082       l_rei_rec.rei_information30
5083      );
5084 
5085    Elsif l_flag = 'U' then
5086       hr_utility.set_location(l_proc,25);
5087       hr_utility.set_location('update extra info',1);
5088       ghr_par_extra_info_api.update_pa_request_extra_info
5089      (P_PA_REQUEST_EXTRA_INFO_ID  =>  l_rei_rec.pa_request_extra_info_id,
5090       P_OBJECT_VERSION_NUMBER     =>  l_rei_rec.object_version_number ,
5091       p_rei_information1          =>  l_rei_rec.rei_information1,
5092       p_rei_information2          =>  l_rei_rec.rei_information2,
5093       p_rei_information3          =>  l_rei_rec.rei_information3,
5094       p_rei_information4          =>  l_rei_rec.rei_information4,
5095       p_rei_information5          =>  l_rei_rec.rei_information5,
5096       p_rei_information6          =>  l_rei_rec.rei_information6,
5097       p_rei_information7          =>  l_rei_rec.rei_information7,
5098       p_rei_information8          =>  l_rei_rec.rei_information8,
5099       p_rei_information9          =>  l_rei_rec.rei_information9,
5100       p_rei_information10         =>  l_rei_rec.rei_information10,
5101       p_rei_information11         =>  l_rei_rec.rei_information11,
5102       p_rei_information12         =>  l_rei_rec.rei_information12,
5103       p_rei_information13         =>  l_rei_rec.rei_information13,
5104       p_rei_information14         =>  l_rei_rec.rei_information14,
5105       p_rei_information15         =>  l_rei_rec.rei_information15,
5106       p_rei_information16         =>  l_rei_rec.rei_information16,
5107       p_rei_information17         =>  l_rei_rec.rei_information17,
5108       p_rei_information18         =>  l_rei_rec.rei_information18,
5109       p_rei_information19         =>  l_rei_rec.rei_information19,
5110       p_rei_information20         =>  l_rei_rec.rei_information20,
5111       p_rei_information21         =>  l_rei_rec.rei_information21,
5112       p_rei_information22         =>  l_rei_rec.rei_information22,
5113       p_rei_information23         =>  l_rei_rec.rei_information23,
5114       p_rei_information24         =>  l_rei_rec.rei_information24,
5115       p_rei_information25         =>  l_rei_rec.rei_information25,
5116       p_rei_information26         =>  l_rei_rec.rei_information26,
5117       p_rei_information27         =>  l_rei_rec.rei_information27,
5118       p_rei_information28         =>  l_rei_rec.rei_information28,
5119       p_rei_information29         =>  l_rei_rec.rei_information29,
5120       p_rei_information30         =>  l_rei_rec.rei_information30
5121       );
5122      hr_utility.set_location('bef upd of shad ' || 'ovn ' ||  l_rei_rec.object_version_number,2);
5123 
5124      update ghr_pa_request_ei_shadow set
5125       rei_information1          =  p_org_rec.rei_information1,
5126       rei_information2          =  p_org_rec.rei_information2,
5127       rei_information3          =  p_org_rec.rei_information3,
5128       rei_information4          =  p_org_rec.rei_information4,
5129       rei_information5          =  p_org_rec.rei_information5,
5130       rei_information6          =  p_org_rec.rei_information6,
5131       rei_information7          =  p_org_rec.rei_information7,
5132       rei_information8          =  p_org_rec.rei_information8,
5133       rei_information9          =  p_org_rec.rei_information9,
5134       rei_information10         =  p_org_rec.rei_information10,
5135       rei_information11         =  p_org_rec.rei_information11,
5136       rei_information12         =  p_org_rec.rei_information12,
5137       rei_information13         =  p_org_rec.rei_information13,
5138       rei_information14         =  p_org_rec.rei_information14,
5139       rei_information15         =  p_org_rec.rei_information15,
5140       rei_information16         =  p_org_rec.rei_information16,
5141       rei_information17         =  p_org_rec.rei_information17,
5142       rei_information18         =  p_org_rec.rei_information18,
5143       rei_information19         =  p_org_rec.rei_information19,
5144       rei_information20         =  p_org_rec.rei_information20,
5145       rei_information21         =  p_org_rec.rei_information21,
5146       rei_information22         =  p_org_rec.rei_information22,
5147       rei_information23         =  p_org_rec.rei_information23,
5148       rei_information24         =  p_org_rec.rei_information24,
5149       rei_information25         =  p_org_rec.rei_information25,
5150       rei_information26         =  p_org_rec.rei_information26,
5151       rei_information27         =  p_org_rec.rei_information27,
5152       rei_information28         =  p_org_rec.rei_information28,
5153       rei_information29         =  p_org_rec.rei_information29,
5154       rei_information30         =  p_org_rec.rei_information30
5155      where pa_request_extra_info_id = l_rei_rec.pa_request_extra_info_id;
5156 
5157 
5158    Elsif l_flag = 'D' then
5159       hr_utility.set_location(l_proc,30);
5160       hr_utility.set_location('delete extra info',1);
5161 
5162        ghr_par_extra_info_api.delete_pa_request_extra_info
5163        (p_pa_request_extra_info_id    => l_rei_rec.pa_request_extra_info_id,
5164         p_object_version_number       => l_rei_rec.object_version_number
5165        );
5166         delete from ghr_pa_request_ei_shadow
5167         where pa_request_extra_info_id = l_rei_rec.pa_request_extra_info_id;
5168    End if;
5169  End if;
5170  hr_utility.set_location('Leaving ' || l_proc,40);
5171 end generic_populate_extra_info ;
5172 
5173 Procedure set_ei
5174 (p_original     in out NOCOPY   varchar2,
5175  p_as_in_core   in     varchar2,
5176  p_as_in_ddf    in out NOCOPY varchar2,
5177  p_refresh_flag in     varchar2 default 'Y')
5178 is
5179 
5180 begin
5181 
5182   If p_refresh_flag = 'Y' then
5183     hr_utility.set_location('in set ei  - Y ',5);
5184     If nvl(p_as_in_ddf,hr_api.g_varchar2) <>  nvl(p_as_in_core,hr_api.g_varchar2) and
5185        nvl(p_as_in_ddf,hr_api.g_varchar2)  =   nvl(p_original,hr_api.g_varchar2) then
5186       p_as_in_ddf := p_as_in_core;
5187     End if;
5188   Else
5189      hr_utility.set_location('in set ei  - N ',6);
5190      p_as_in_ddf := p_as_in_core;
5191   End if;
5192     p_original := p_as_in_core;
5193 End set_ei;
5194 
5195 --6850492
5196 procedure dual_extra_info_refresh(p_first_corr_pa_request_id in number,
5197                                   p_second_corr_pa_request_id in number,
5198 			          p_first_noa_code in varchar2,
5199   			          p_second_noa_code in varchar2,
5200 				  p_upd_info_type  in varchar2,
5201 				  p_dual_corr_yn in varchar)
5202 is
5203   cursor c_get_extra_info_details(p_pa_request_id in number,
5204                                   p_information_type in varchar2)
5205       is
5206       select *
5207       from   ghr_pa_request_extra_info
5208       where  pa_request_id    = p_pa_request_id
5209       and    information_type = p_information_type;
5210 
5211   cursor c_shadow_extra_info(p_pa_request_id in number,
5212                              p_information_type in varchar2)
5213       is
5214       select *
5215       from   ghr_pa_request_ei_shadow
5216       where  pa_request_id    = p_pa_request_id
5217       and    information_type = p_information_type;
5218 
5219   cursor get_ord_of_eit(p_information_type1 in varchar2,
5220                         p_information_type2 in varchar2)
5221       is
5222       select a.noa_family_code, a.information_type
5223       from GHR_PA_REQUEST_INFO_TYPES a,ghr_noa_families b, ghr_nature_of_actions c
5224       where b.nature_of_action_id= c.nature_of_action_id
5225       and a.noa_family_code= b.noa_family_code
5226       and c.code in (p_first_noa_code,p_second_noa_code)
5227       and a.information_type in (p_information_type1,p_information_type2)
5228       order by a.noa_family_code;
5229 
5230       l_rei_rec  ghr_pa_request_extra_info%rowtype;
5231       sc_rei_rec ghr_pa_request_extra_info%rowtype;
5232       fc_rei_rec ghr_pa_request_extra_info%rowtype;
5233       l_org_sc_rec  ghr_pa_request_ei_shadow%rowtype;
5234       l_org_fc_rec  ghr_pa_request_ei_shadow%rowtype;
5235       l_information_type1 ghr_pa_request_extra_info.information_type%type;
5236       l_information_type2 ghr_pa_request_extra_info.information_type%type;
5237 
5238 
5239 begin
5240   -- Handling common segments between Conversion to Appointment and Change in Work Schedule
5241   l_information_type1 := NULL;
5242   l_information_type2 := NULL;
5243   --Return to Duty and Conversion to Appointment
5244   if p_first_noa_code in ('280','292') and substr(p_second_noa_code,1,1) = '5' then
5245      if NVL(p_dual_corr_yn,'N') = 'Y' then
5246         l_information_type1 := 'GHR_US_PAR_RETURN_TO_DUTY';
5247 	l_information_type2 := 'GHR_US_PAR_CONV_APP';
5248      else
5249        if p_upd_info_type = 'GHR_US_PAR_RETURN_TO_DUTY'  then
5250 	  l_information_type1 := 'GHR_US_PAR_RETURN_TO_DUTY';
5251 	  l_information_type2 := 'GHR_US_PAR_CONV_APP';
5252        elsif p_upd_info_type = 'GHR_US_PAR_CONV_APP' then
5253 	  l_information_type1 := 'GHR_US_PAR_CONV_APP';
5254  	  l_information_type2 := 'GHR_US_PAR_RETURN_TO_DUTY';
5255        end if;
5256      end if;
5257 
5258      if l_information_type1 is not null and l_information_type2 is not null then
5259          open c_get_extra_info_details(p_pa_request_id => p_first_corr_pa_request_id,
5260                                        p_information_type => l_information_type1);
5261          fetch c_get_extra_info_details into fc_rei_rec;
5262          close c_get_extra_info_details;
5263 
5264          open c_get_extra_info_details(p_pa_request_id => p_second_corr_pa_request_id,
5265                                        p_information_type => l_information_type2);
5266          fetch c_get_extra_info_details into sc_rei_rec;
5267          if c_get_extra_info_details%found then
5268   	   open c_shadow_extra_info(p_pa_request_id => p_first_corr_pa_request_id,
5269                                     p_information_type => l_information_type1);
5270 	   fetch c_shadow_extra_info into l_org_fc_rec;
5271 	   close  c_shadow_extra_info;
5272 
5273 	   open c_shadow_extra_info(p_pa_request_id => p_second_corr_pa_request_id,
5274                                     p_information_type => l_information_type2);
5275 	   fetch c_shadow_extra_info into l_org_sc_rec;
5276 	   close  c_shadow_extra_info;
5277 
5278 	   l_rei_rec := sc_rei_rec;
5279          if l_information_type1 = 'GHR_US_PAR_RETURN_TO_DUTY' and l_information_type2 = 'GHR_US_PAR_CONV_APP' then
5280 	   -- Part time indicator
5281 	   set_dual_ei(l_org_fc_rec.rei_information7,fc_rei_rec.rei_information7,l_org_sc_rec.rei_information8,l_rei_rec.rei_information8);
5282 	   -- WGI Due Date
5283 	   set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information19,l_rei_rec.rei_information19);
5284 	   -- Creditable Military Service
5285 	   set_dual_ei(l_org_fc_rec.rei_information3,fc_rei_rec.rei_information3,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5286            -- Frozen Service
5287  	   set_dual_ei(l_org_fc_rec.rei_information5,fc_rei_rec.rei_information5,l_org_sc_rec.rei_information6,l_rei_rec.rei_information6);
5288            -- Type of Employment
5289 	   set_dual_ei(l_org_fc_rec.rei_information8,fc_rei_rec.rei_information8,l_org_sc_rec.rei_information13,l_rei_rec.rei_information13);
5290          elsif l_information_type1 = 'GHR_US_PAR_CONV_APP' and l_information_type2 = 'GHR_US_PAR_RETURN_TO_DUTY' then
5291            -- Part time indicator
5292 	   set_dual_ei(l_org_fc_rec.rei_information8,fc_rei_rec.rei_information8,l_org_sc_rec.rei_information7,l_rei_rec.rei_information7);
5293 	   -- WGI Due Date
5294 	   set_dual_ei(l_org_fc_rec.rei_information19,fc_rei_rec.rei_information19,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5295 	   -- Creditable Military Service
5296 	   set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information3,l_rei_rec.rei_information3);
5297            -- Frozen Service
5298  	   set_dual_ei(l_org_fc_rec.rei_information6,fc_rei_rec.rei_information6,l_org_sc_rec.rei_information5,l_rei_rec.rei_information5);
5299            -- Type of Employment
5300 	   set_dual_ei(l_org_fc_rec.rei_information13,fc_rei_rec.rei_information13,l_org_sc_rec.rei_information8,l_rei_rec.rei_information8);
5301           end if;
5302 
5303 	  generic_populate_extra_info
5304                     (p_rei_rec            =>  l_rei_rec,
5305                      p_org_rec            =>  l_org_sc_rec,
5306                      p_flag               =>  'U');
5307       else
5308 
5309 	l_rei_rec.pa_request_id := p_second_corr_pa_request_id;
5310 	l_rei_rec.information_type := l_information_type2;
5311 	if l_information_type1 = 'GHR_US_PAR_RETURN_TO_DUTY' and l_information_type2 = 'GHR_US_PAR_CONV_APP' then
5312   	  -- Part time indicator
5313 	  set_dual_ei(l_org_fc_rec.rei_information7,fc_rei_rec.rei_information7,l_org_sc_rec.rei_information8,l_rei_rec.rei_information8);
5314 	  -- WGI Due Date
5315 	  set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information19,l_rei_rec.rei_information19);
5316 	  -- Creditable Military Service
5317 	  set_dual_ei(l_org_fc_rec.rei_information3,fc_rei_rec.rei_information3,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5318           -- Frozen Service
5319 	  set_dual_ei(l_org_fc_rec.rei_information5,fc_rei_rec.rei_information5,l_org_sc_rec.rei_information6,l_rei_rec.rei_information6);
5320           -- Type of Employment
5321 	  set_dual_ei(l_org_fc_rec.rei_information8,fc_rei_rec.rei_information8,l_org_sc_rec.rei_information13,l_rei_rec.rei_information13);
5322 	elsif l_information_type1 = 'GHR_US_PAR_CONV_APP' and l_information_type2 = 'GHR_US_PAR_RETURN_TO_DUTY' then
5323            -- Part time indicator
5324 	   set_dual_ei(l_org_fc_rec.rei_information8,fc_rei_rec.rei_information8,l_org_sc_rec.rei_information7,l_rei_rec.rei_information7);
5325 	   -- WGI Due Date
5326 	   set_dual_ei(l_org_fc_rec.rei_information19,fc_rei_rec.rei_information19,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5327 	   -- Creditable Military Service
5328 	   set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information3,l_rei_rec.rei_information3);
5329            -- Frozen Service
5330  	   set_dual_ei(l_org_fc_rec.rei_information6,fc_rei_rec.rei_information6,l_org_sc_rec.rei_information5,l_rei_rec.rei_information5);
5331            -- Type of Employment
5332 	   set_dual_ei(l_org_fc_rec.rei_information13,fc_rei_rec.rei_information13,l_org_sc_rec.rei_information8,l_rei_rec.rei_information8);
5333         end if;
5334 	generic_populate_extra_info
5335               (p_rei_rec    =>  l_rei_rec,
5336                p_org_rec    =>  l_org_sc_rec,
5337                p_flag       =>  'C'
5338                 );
5339 
5340      end if;
5341      close c_get_extra_info_details;
5342      end if;
5343   end if;
5344 
5345   --Return to Duty and Promotion
5346   if p_first_noa_code in ('280','292') and p_second_noa_code in ('702','703','713') then
5347      if NVL(p_dual_corr_yn,'N') = 'Y' then
5348         l_information_type1 := 'GHR_US_PAR_RETURN_TO_DUTY';
5349 	l_information_type2 := 'GHR_US_PAR_SALARY_CHG';
5350      else
5351          if p_upd_info_type = 'GHR_US_PAR_RETURN_TO_DUTY'  then
5352 	    l_information_type1 := 'GHR_US_PAR_RETURN_TO_DUTY';
5353 	    l_information_type2 := 'GHR_US_PAR_SALARY_CHG';
5354 	 elsif p_upd_info_type = 'GHR_US_PAR_SALARY_CHG' then
5355 	    l_information_type1 := 'GHR_US_PAR_SALARY_CHG';
5356  	    l_information_type2 := 'GHR_US_PAR_RETURN_TO_DUTY';
5357 	 end if;
5358      end if;
5359 
5360      if l_information_type1 is not null and l_information_type2 is not null then
5361 
5362       open c_get_extra_info_details(p_pa_request_id => p_first_corr_pa_request_id,
5363                                     p_information_type => l_information_type1);
5364       fetch c_get_extra_info_details into fc_rei_rec;
5365       close c_get_extra_info_details;
5366 
5367       open c_get_extra_info_details(p_pa_request_id => p_second_corr_pa_request_id,
5368                                     p_information_type => l_information_type2);
5369       fetch c_get_extra_info_details into sc_rei_rec;
5370       if c_get_extra_info_details%found then
5371 	open c_shadow_extra_info(p_pa_request_id => p_first_corr_pa_request_id,
5372                                  p_information_type => l_information_type1);
5373 	fetch c_shadow_extra_info into l_org_fc_rec;
5374 	close  c_shadow_extra_info;
5375 
5376 	open c_shadow_extra_info(p_pa_request_id => p_second_corr_pa_request_id,
5377                                  p_information_type => l_information_type2);
5378 	fetch c_shadow_extra_info into l_org_sc_rec;
5379 	close  c_shadow_extra_info;
5380 
5381 	l_rei_rec := sc_rei_rec;
5382 
5383 	if l_information_type1 = 'GHR_US_PAR_RETURN_TO_DUTY' and l_information_type2 = 'GHR_US_PAR_SALARY_CHG' then
5384 	  -- WGI Due Date
5385 	  set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5386 	elsif l_information_type1 = 'GHR_US_PAR_SALARY_CHG' and l_information_type2 = 'GHR_US_PAR_RETURN_TO_DUTY' then
5387 	  -- WGI Due Date
5388 	  set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5389 	end if;
5390 
5391 
5392 	generic_populate_extra_info
5393                     (p_rei_rec            =>  l_rei_rec,
5394                      p_org_rec            =>  l_org_sc_rec,
5395                      p_flag               =>  'U');
5396       else
5397 	l_rei_rec.pa_request_id := p_second_corr_pa_request_id;
5398 	l_rei_rec.information_type := l_information_type2;
5399 
5400         if l_information_type1 = 'GHR_US_PAR_RETURN_TO_DUTY' and l_information_type2 = 'GHR_US_PAR_SALARY_CHG' then
5401 	  -- WGI Due Date
5402 	  set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5403 	elsif l_information_type1 = 'GHR_US_PAR_SALARY_CHG' and l_information_type2 = 'GHR_US_PAR_RETURN_TO_DUTY' then
5404 	  -- WGI Due Date
5405 	  set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5406 	end if;
5407 
5408 	generic_populate_extra_info
5409               (p_rei_rec    =>  l_rei_rec,
5410                p_org_rec    =>  l_org_sc_rec,
5411                p_flag       =>  'C'
5412                 );
5413 
5414    end if;
5415 	 close c_get_extra_info_details;
5416     end if;
5417    end if;
5418 
5419 --Return to Duty and Reassignment
5420   if p_first_noa_code in ('280','292') and p_second_noa_code in ('721') then
5421 
5422      if NVL(p_dual_corr_yn,'N') = 'Y' then
5423         l_information_type1 := 'GHR_US_PAR_RETURN_TO_DUTY';
5424 	l_information_type2 := 'GHR_US_PAR_REASSIGNMENT';
5425      else
5426          if p_upd_info_type = 'GHR_US_PAR_RETURN_TO_DUTY'  then
5427 	    l_information_type1 := 'GHR_US_PAR_RETURN_TO_DUTY';
5428 	    l_information_type2 := 'GHR_US_PAR_REASSIGNMENT';
5429 	 elsif p_upd_info_type = 'GHR_US_PAR_REASSIGNMENT' then
5430 	    l_information_type1 := 'GHR_US_PAR_REASSIGNMENT';
5431  	    l_information_type2 := 'GHR_US_PAR_RETURN_TO_DUTY';
5432 	 end if;
5433      end if;
5434 
5435     if l_information_type1 is not null and l_information_type2 is not null then
5436      open c_get_extra_info_details(p_pa_request_id => p_first_corr_pa_request_id,
5437                                    p_information_type => l_information_type1);
5438      fetch c_get_extra_info_details into fc_rei_rec;
5439      close c_get_extra_info_details;
5440 
5441      open c_get_extra_info_details(p_pa_request_id => p_second_corr_pa_request_id,
5442                                    p_information_type => l_information_type2);
5443      fetch c_get_extra_info_details into sc_rei_rec;
5444      if c_get_extra_info_details%found then
5445 	open c_shadow_extra_info(p_pa_request_id => p_first_corr_pa_request_id,
5446                                  p_information_type => l_information_type1);
5447 	fetch c_shadow_extra_info into l_org_fc_rec;
5448 	close  c_shadow_extra_info;
5449 
5450 	open c_shadow_extra_info(p_pa_request_id => p_second_corr_pa_request_id,
5451                                  p_information_type => l_information_type2);
5452 	fetch c_shadow_extra_info into l_org_sc_rec;
5453 	close  c_shadow_extra_info;
5454 
5455 	l_rei_rec := sc_rei_rec;
5456 
5457         if l_information_type1 = 'GHR_US_PAR_RETURN_TO_DUTY' and l_information_type2 = 'GHR_US_PAR_REASSIGNMENT' then
5458 	  -- Part time indicator
5459 	  set_dual_ei(l_org_fc_rec.rei_information7,fc_rei_rec.rei_information7,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5460 	elsif l_information_type1 = 'GHR_US_PAR_REASSIGNMENT' and l_information_type2 = 'GHR_US_PAR_RETURN_TO_DUTY' then
5461 	  -- Part time indicator
5462 	  set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information7,l_rei_rec.rei_information7);
5463 	end if;
5464 
5465 
5466 	generic_populate_extra_info
5467                     (p_rei_rec            =>  l_rei_rec,
5468                      p_org_rec            =>  l_org_sc_rec,
5469                      p_flag               =>  'U');
5470     else
5471 	l_rei_rec.pa_request_id := p_second_corr_pa_request_id;
5472 	l_rei_rec.information_type := l_information_type2;
5473 
5474 	if l_information_type1 = 'GHR_US_PAR_RETURN_TO_DUTY' and l_information_type2 = 'GHR_US_PAR_REASSIGNMENT' then
5475   	  -- Part time indicator
5476 	  set_dual_ei(l_org_fc_rec.rei_information7,fc_rei_rec.rei_information7,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5477 	elsif l_information_type1 = 'GHR_US_PAR_REASSIGNMENT' and l_information_type2 = 'GHR_US_PAR_RETURN_TO_DUTY' then
5478    	  -- Part time indicator
5479 	  set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information7,l_rei_rec.rei_information7);
5480 	end if;
5481 
5482 	generic_populate_extra_info
5483               (p_rei_rec    =>  l_rei_rec,
5484                p_org_rec    =>  l_org_sc_rec,
5485                p_flag       =>  'C'
5486                 );
5487 
5488    end if;
5489 	 close c_get_extra_info_details;
5490     end if;
5491    end if;
5492 
5493     --Return to Duty and Change in WorkSchedule or Change in Hours
5494   if p_first_noa_code in ('280','292') and p_second_noa_code in ('781','782') then
5495 
5496      if NVL(p_dual_corr_yn,'N') = 'Y' then
5497         l_information_type1 := 'GHR_US_PAR_RETURN_TO_DUTY';
5498 	l_information_type2 := 'GHR_US_PAR_CHG_HOURS';
5499      else
5500          if p_upd_info_type = 'GHR_US_PAR_RETURN_TO_DUTY'  then
5501 	    l_information_type1 := 'GHR_US_PAR_RETURN_TO_DUTY';
5502 	    l_information_type2 := 'GHR_US_PAR_CHG_HOURS';
5503 	 elsif p_upd_info_type = 'GHR_US_PAR_CHG_HOURS' then
5504 	    l_information_type1 := 'GHR_US_PAR_CHG_HOURS';
5505  	    l_information_type2 := 'GHR_US_PAR_RETURN_TO_DUTY';
5506 	 end if;
5507      end if;
5508 
5509     if l_information_type1 is not null and l_information_type2 is not null then
5510      open c_get_extra_info_details(p_pa_request_id => p_first_corr_pa_request_id,
5511                                    p_information_type => l_information_type1);
5512      fetch c_get_extra_info_details into fc_rei_rec;
5513      close c_get_extra_info_details;
5514 
5515      open c_get_extra_info_details(p_pa_request_id => p_second_corr_pa_request_id,
5516                                    p_information_type => l_information_type2);
5517      fetch c_get_extra_info_details into sc_rei_rec;
5518      if c_get_extra_info_details%found then
5519 	open c_shadow_extra_info(p_pa_request_id => p_first_corr_pa_request_id,
5520                                  p_information_type =>l_information_type1);
5521 	fetch c_shadow_extra_info into l_org_fc_rec;
5522 	close  c_shadow_extra_info;
5523 
5524 	open c_shadow_extra_info(p_pa_request_id => p_second_corr_pa_request_id,
5525                                  p_information_type =>l_information_type2);
5526 	fetch c_shadow_extra_info into l_org_sc_rec;
5527 	close  c_shadow_extra_info;
5528 
5529 	l_rei_rec := sc_rei_rec;
5530 
5531 	if l_information_type1 = 'GHR_US_PAR_RETURN_TO_DUTY' and l_information_type2 = 'GHR_US_PAR_CHG_HOURS' then
5532    	  -- Part time indicator
5533 	  set_dual_ei(l_org_fc_rec.rei_information7,fc_rei_rec.rei_information7,l_org_sc_rec.rei_information7,l_rei_rec.rei_information7);
5534 	  -- WGI Due Date
5535 	  set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information5,l_rei_rec.rei_information5);
5536 	elsif l_information_type1 = 'GHR_US_PAR_CHG_HOURS' and l_information_type2 = 'GHR_US_PAR_RETURN_TO_DUTY' then
5537 	  -- Part time indicator
5538 	  set_dual_ei(l_org_fc_rec.rei_information7,fc_rei_rec.rei_information7,l_org_sc_rec.rei_information7,l_rei_rec.rei_information7);
5539 	  -- WGI Due Date
5540 	  set_dual_ei(l_org_fc_rec.rei_information5,fc_rei_rec.rei_information5,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5541 	end if;
5542 
5543 	generic_populate_extra_info
5544                     (p_rei_rec            =>  l_rei_rec,
5545                      p_org_rec            =>  l_org_sc_rec,
5546                      p_flag               =>  'U');
5547     else
5548 
5549 	l_rei_rec.pa_request_id := p_second_corr_pa_request_id;
5550 	l_rei_rec.information_type := l_information_type2;
5551 
5552 	if l_information_type1 = 'GHR_US_PAR_RETURN_TO_DUTY' and l_information_type2 = 'GHR_US_PAR_CHG_HOURS' then
5553   	  -- Part time indicator
5554 	  set_dual_ei(l_org_fc_rec.rei_information7,fc_rei_rec.rei_information7,l_org_sc_rec.rei_information7,l_rei_rec.rei_information7);
5555 	  -- WGI Due Date
5556  	  set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information5,l_rei_rec.rei_information5);
5557 	elsif l_information_type1 = 'GHR_US_PAR_CHG_HOURS' and l_information_type2 = 'GHR_US_PAR_RETURN_TO_DUTY' then
5558            -- Part time indicator
5559 	  set_dual_ei(l_org_fc_rec.rei_information7,fc_rei_rec.rei_information7,l_org_sc_rec.rei_information7,l_rei_rec.rei_information7);
5560 	  -- WGI Due Date
5561  	  set_dual_ei(l_org_fc_rec.rei_information5,fc_rei_rec.rei_information5,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5562 	end if;
5563 
5564 	generic_populate_extra_info
5565               (p_rei_rec    =>  l_rei_rec,
5566                p_org_rec    =>  l_org_sc_rec,
5567                p_flag       =>  'C'
5568                 );
5569 
5570    end if;
5571 	 close c_get_extra_info_details;
5572     end if;
5573    end if;
5574 
5575  --- Conversion to Appointment and Change in WorkSchedule/Part Time Hours
5576   if substr(p_first_noa_code,1,1) = '5' and p_second_noa_code in ('781','782') then
5577 
5578      if NVL(p_dual_corr_yn,'N') = 'Y' then
5579         l_information_type1 := 'GHR_US_PAR_CONV_APP';
5580 	l_information_type2 := 'GHR_US_PAR_CHG_HOURS';
5581      else
5582          if p_upd_info_type = 'GHR_US_PAR_CONV_APP'  then
5583 	    l_information_type1 := 'GHR_US_PAR_CONV_APP';
5584 	    l_information_type2 := 'GHR_US_PAR_CHG_HOURS';
5585 	 elsif p_upd_info_type = 'GHR_US_PAR_CHG_HOURS' then
5586 	    l_information_type1 := 'GHR_US_PAR_CHG_HOURS';
5587  	    l_information_type2 := 'GHR_US_PAR_CONV_APP';
5588 	 end if;
5589      end if;
5590 
5591     if l_information_type1 is not null and l_information_type2 is not null then
5592      open c_get_extra_info_details(p_pa_request_id => p_first_corr_pa_request_id,
5593                                    p_information_type => l_information_type1);
5594      fetch c_get_extra_info_details into fc_rei_rec;
5595      close c_get_extra_info_details;
5596 
5597      open c_get_extra_info_details(p_pa_request_id => p_second_corr_pa_request_id,
5598                                    p_information_type => l_information_type2);
5599      fetch c_get_extra_info_details into sc_rei_rec;
5600      if c_get_extra_info_details%found then
5601 	open c_shadow_extra_info(p_pa_request_id => p_first_corr_pa_request_id,
5602                                  p_information_type => l_information_type1);
5603 	fetch c_shadow_extra_info into l_org_fc_rec;
5604 	close  c_shadow_extra_info;
5605 
5606 	open c_shadow_extra_info(p_pa_request_id => p_second_corr_pa_request_id,
5607                                  p_information_type => l_information_type2);
5608 	fetch c_shadow_extra_info into l_org_sc_rec;
5609 	close  c_shadow_extra_info;
5610 
5611 	l_rei_rec := sc_rei_rec;
5612 
5613         if l_information_type1 = 'GHR_US_PAR_CONV_APP' and l_information_type2 = 'GHR_US_PAR_CHG_HOURS' then
5614    	  -- Part time indicator
5615 	  set_dual_ei(l_org_fc_rec.rei_information8,fc_rei_rec.rei_information8,l_org_sc_rec.rei_information7,l_rei_rec.rei_information7);
5616 	  -- WGI Due Date
5617 	  set_dual_ei(l_org_fc_rec.rei_information19,fc_rei_rec.rei_information19,l_org_sc_rec.rei_information5,l_rei_rec.rei_information5);
5618 	elsif l_information_type1 = 'GHR_US_PAR_CHG_HOURS' and l_information_type2 = 'GHR_US_PAR_CONV_APP' then
5619           -- Part time indicator
5620 	  set_dual_ei(l_org_fc_rec.rei_information7,fc_rei_rec.rei_information7,l_org_sc_rec.rei_information8,l_rei_rec.rei_information8);
5621 	  -- WGI Due Date
5622 	  set_dual_ei(l_org_fc_rec.rei_information5,fc_rei_rec.rei_information5,l_org_sc_rec.rei_information19,l_rei_rec.rei_information19);
5623 	end if;
5624 
5625 	generic_populate_extra_info
5626                     (p_rei_rec            =>  l_rei_rec,
5627                      p_org_rec            =>  l_org_sc_rec,
5628                      p_flag               =>  'U');
5629     else
5630 	l_rei_rec.pa_request_id := p_second_corr_pa_request_id;
5631 	l_rei_rec.information_type := l_information_type2;
5632 
5633 	 if l_information_type1 = 'GHR_US_PAR_CONV_APP' and l_information_type2 = 'GHR_US_PAR_CHG_HOURS' then
5634    	  -- Part time indicator
5635 	  set_dual_ei(l_org_fc_rec.rei_information8,fc_rei_rec.rei_information8,l_org_sc_rec.rei_information7,l_rei_rec.rei_information7);
5636 	  -- WGI Due Date
5637 	  set_dual_ei(l_org_fc_rec.rei_information19,fc_rei_rec.rei_information19,l_org_sc_rec.rei_information5,l_rei_rec.rei_information5);
5638 	elsif l_information_type1 = 'GHR_US_PAR_CHG_HOURS' and l_information_type2 = 'GHR_US_PAR_CONV_APP' then
5639           -- Part time indicator
5640 	  set_dual_ei(l_org_fc_rec.rei_information7,fc_rei_rec.rei_information7,l_org_sc_rec.rei_information8,l_rei_rec.rei_information8);
5641 	  -- WGI Due Date
5642 	  set_dual_ei(l_org_fc_rec.rei_information5,fc_rei_rec.rei_information5,l_org_sc_rec.rei_information19,l_rei_rec.rei_information19);
5643 	end if;
5644 
5645 	generic_populate_extra_info
5646               (p_rei_rec    =>  l_rei_rec,
5647                p_org_rec    =>  l_org_sc_rec,
5648                p_flag       =>  'C'
5649                 );
5650 
5651    end if;
5652 	 close c_get_extra_info_details;
5653     end if;
5654    end if;
5655 
5656    --- Promotion and Change in WorkSchedule/Part Time Hours
5657   if p_first_noa_code in ('702','703','713') and p_second_noa_code in ('781','782') then
5658 
5659      if NVL(p_dual_corr_yn,'N') = 'Y' then
5660         l_information_type1 := 'GHR_US_PAR_SALARY_CHG';
5661 	l_information_type2 := 'GHR_US_PAR_CHG_HOURS';
5662      else
5663          if p_upd_info_type = 'GHR_US_PAR_SALARY_CHG'  then
5664 	    l_information_type1 := 'GHR_US_PAR_SALARY_CHG';
5665 	    l_information_type2 := 'GHR_US_PAR_CHG_HOURS';
5666 	 elsif p_upd_info_type = 'GHR_US_PAR_CHG_HOURS' then
5667 	    l_information_type1 := 'GHR_US_PAR_CHG_HOURS';
5668  	    l_information_type2 := 'GHR_US_PAR_SALARY_CHG';
5669 	 end if;
5670      end if;
5671 
5672     if l_information_type1 is not null and l_information_type2 is not null then
5673      open c_get_extra_info_details(p_pa_request_id => p_first_corr_pa_request_id,
5674                                    p_information_type => l_information_type1);
5675      fetch c_get_extra_info_details into fc_rei_rec;
5676      close c_get_extra_info_details;
5677 
5678      open c_get_extra_info_details(p_pa_request_id => p_second_corr_pa_request_id,
5679                                    p_information_type => l_information_type2);
5680      fetch c_get_extra_info_details into sc_rei_rec;
5681      if c_get_extra_info_details%found then
5682 	open c_shadow_extra_info(p_pa_request_id => p_first_corr_pa_request_id,
5683                                  p_information_type => l_information_type1);
5684 	fetch c_shadow_extra_info into l_org_fc_rec;
5685 	close  c_shadow_extra_info;
5686 
5687 	open c_shadow_extra_info(p_pa_request_id => p_second_corr_pa_request_id,
5688                                  p_information_type => l_information_type2);
5689 	fetch c_shadow_extra_info into l_org_sc_rec;
5690 	close  c_shadow_extra_info;
5691 
5692 	l_rei_rec := sc_rei_rec;
5693 
5694         if l_information_type1 = 'GHR_US_PAR_SALARY_CHG' and l_information_type2 = 'GHR_US_PAR_CHG_HOURS' then
5695   	   -- Date WGI Postpone Effective
5696 	   set_dual_ei(l_org_fc_rec.rei_information3,fc_rei_rec.rei_information3,l_org_sc_rec.rei_information6,l_rei_rec.rei_information6);
5697   	   -- WGI Due Date
5698 	   set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information5,l_rei_rec.rei_information5);
5699 	elsif  l_information_type1 = 'GHR_US_PAR_CHG_HOURS' and l_information_type2 = 'GHR_US_PAR_SALARY_CHG' then
5700            -- Date WGI Postpone Effective
5701 	   set_dual_ei(l_org_fc_rec.rei_information6,fc_rei_rec.rei_information6,l_org_sc_rec.rei_information3,l_rei_rec.rei_information3);
5702   	   -- WGI Due Date
5703 	   set_dual_ei(l_org_fc_rec.rei_information5,fc_rei_rec.rei_information5,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5704 	end if;
5705 	generic_populate_extra_info
5706                     (p_rei_rec            =>  l_rei_rec,
5707                      p_org_rec            =>  l_org_sc_rec,
5708                      p_flag               =>  'U');
5709     else
5710 	l_rei_rec.pa_request_id := p_second_corr_pa_request_id;
5711 	l_rei_rec.information_type := l_information_type2;
5712 
5713 
5714 	if l_information_type1 = 'GHR_US_PAR_SALARY_CHG' and l_information_type2 = 'GHR_US_PAR_CHG_HOURS' then
5715   	   -- Date WGI Postpone Effective
5716 	   set_dual_ei(l_org_fc_rec.rei_information3,fc_rei_rec.rei_information3,l_org_sc_rec.rei_information6,l_rei_rec.rei_information6);
5717   	   -- WGI Due Date
5718 	   set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information5,l_rei_rec.rei_information5);
5719 	elsif  l_information_type1 = 'GHR_US_PAR_CHG_HOURS' and l_information_type2 = 'GHR_US_PAR_SALARY_CHG' then
5720            -- Date WGI Postpone Effective
5721 	   set_dual_ei(l_org_fc_rec.rei_information6,fc_rei_rec.rei_information6,l_org_sc_rec.rei_information3,l_rei_rec.rei_information3);
5722   	   -- WGI Due Date
5723 	   set_dual_ei(l_org_fc_rec.rei_information5,fc_rei_rec.rei_information5,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5724 	end if;
5725 
5726 	generic_populate_extra_info
5727               (p_rei_rec    =>  l_rei_rec,
5728                p_org_rec    =>  l_org_sc_rec,
5729                p_flag       =>  'C'
5730                 );
5731 
5732    end if;
5733 	 close c_get_extra_info_details;
5734     end if;
5735    end if;
5736 
5737   --- Reassignment and Change in WorkSchedule/Part Time Hours
5738   if p_first_noa_code in ('721') and p_second_noa_code in ('781','782') then
5739 
5740      if NVL(p_dual_corr_yn,'N') = 'Y' then
5741         l_information_type1 := 'GHR_US_PAR_REASSIGNMENT';
5742 	l_information_type2 := 'GHR_US_PAR_CHG_HOURS';
5743      else
5744          if p_upd_info_type = 'GHR_US_PAR_REASSIGNMENT'  then
5745 	    l_information_type1 := 'GHR_US_PAR_REASSIGNMENT';
5746 	    l_information_type2 := 'GHR_US_PAR_CHG_HOURS';
5747 	 elsif p_upd_info_type = 'GHR_US_PAR_CHG_HOURS' then
5748 	    l_information_type1 := 'GHR_US_PAR_CHG_HOURS';
5749  	    l_information_type2 := 'GHR_US_PAR_REASSIGNMENT';
5750 	 end if;
5751      end if;
5752 
5753     if l_information_type1 is not null and l_information_type2 is not null then
5754      open c_get_extra_info_details(p_pa_request_id => p_first_corr_pa_request_id,
5755                                    p_information_type => l_information_type1);
5756      fetch c_get_extra_info_details into fc_rei_rec;
5757      close c_get_extra_info_details;
5758 
5759      open c_get_extra_info_details(p_pa_request_id => p_second_corr_pa_request_id,
5760                                    p_information_type => l_information_type2);
5761      fetch c_get_extra_info_details into sc_rei_rec;
5762      if c_get_extra_info_details%found then
5763 	open c_shadow_extra_info(p_pa_request_id => p_first_corr_pa_request_id,
5764                                  p_information_type => l_information_type1);
5765 	fetch c_shadow_extra_info into l_org_fc_rec;
5766 	close  c_shadow_extra_info;
5767 
5768 	open c_shadow_extra_info(p_pa_request_id => p_second_corr_pa_request_id,
5769                                  p_information_type => l_information_type2);
5770 	fetch c_shadow_extra_info into l_org_sc_rec;
5771 	close  c_shadow_extra_info;
5772 
5773 	l_rei_rec := sc_rei_rec;
5774 
5775        if l_information_type1 = 'GHR_US_PAR_REASSIGNMENT' and l_information_type2 = 'GHR_US_PAR_CHG_HOURS' then
5776 	  -- part time indicator
5777 	  set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information7,l_rei_rec.rei_information7);
5778        elsif l_information_type1 = 'GHR_US_PAR_CHG_HOURS' and l_information_type2 = 'GHR_US_PAR_REASSIGNMENT' then
5779 	  -- part time indicator
5780 	  set_dual_ei(l_org_fc_rec.rei_information7,fc_rei_rec.rei_information7,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5781        end if;
5782 
5783 	generic_populate_extra_info
5784                     (p_rei_rec            =>  l_rei_rec,
5785                      p_org_rec            =>  l_org_sc_rec,
5786                      p_flag               =>  'U');
5787     else
5788 	l_rei_rec.pa_request_id := p_second_corr_pa_request_id;
5789 	l_rei_rec.information_type := l_information_type2;
5790 
5791 	if l_information_type1 = 'GHR_US_PAR_REASSIGNMENT' and l_information_type2 = 'GHR_US_PAR_CHG_HOURS' then
5792 	  -- part time indicator
5793 	  set_dual_ei(l_org_fc_rec.rei_information4,fc_rei_rec.rei_information4,l_org_sc_rec.rei_information7,l_rei_rec.rei_information7);
5794         elsif l_information_type1 = 'GHR_US_PAR_CHG_HOURS' and l_information_type2 = 'GHR_US_PAR_REASSIGNMENT' then
5795 	  -- part time indicator
5796 	  set_dual_ei(l_org_fc_rec.rei_information7,fc_rei_rec.rei_information7,l_org_sc_rec.rei_information4,l_rei_rec.rei_information4);
5797         end if;
5798 
5799 	generic_populate_extra_info
5800               (p_rei_rec    =>  l_rei_rec,
5801                p_org_rec    =>  l_org_sc_rec,
5802                p_flag       =>  'C'
5803                 );
5804 
5805    end if;
5806 	 close c_get_extra_info_details;
5807     end if;
5808    end if;
5809  end dual_extra_info_refresh;
5810 
5811  Procedure set_dual_ei
5812 (p_first_original     in     varchar2,
5813  p_first_as_in_ddf    in     varchar2,
5814  p_sec_original       in     varchar2,
5815  p_sec_as_in_ddf      in out NOCOPY varchar2)
5816 is
5817 
5818 begin
5819 
5820   if nvl(p_first_as_in_ddf,'-1') <> nvl(p_first_original,'-1') and
5821      nvl(p_first_as_in_ddf,'-1') <> nvl(p_sec_as_in_ddf,'-1') then
5822      p_sec_as_in_ddf := p_first_as_in_ddf;
5823   end if;
5824 
5825   if nvl(p_first_as_in_ddf,'-1') = nvl(p_first_original,'-1') and
5826      nvl(p_sec_as_in_ddf,'-1') <> nvl(p_sec_original,'-1') then
5827      p_sec_as_in_ddf := p_sec_original;
5828   end if;
5829 End set_dual_ei;
5830 --6850492
5831 
5832 --BUG # 13889381 added this procedure to delete extra information record
5833 -- based on information type
5834 Procedure delete_extra_info_rec(p_pa_request_id in number,
5835                                 p_info_type in varchar2) is
5836 
5837  cursor c_rei_rec
5838      is
5839      select pa_request_extra_info_id, object_version_number
5840      from   ghr_pa_request_extra_info
5841      where  pa_request_id = p_pa_request_id
5842      and    information_type = p_info_type;
5843 
5844 begin
5845   for c_rec in c_rei_rec
5846   loop
5847       ghr_par_extra_info_api.delete_pa_request_extra_info
5848           (p_pa_request_extra_info_id    => c_rec.pa_request_extra_info_id,
5849            p_object_version_number       => c_rec.object_version_number
5850           );
5851       delete from ghr_pa_request_ei_shadow
5852       where pa_request_extra_info_id = c_rec.pa_request_extra_info_id;
5853 
5854   end loop;
5855 end delete_extra_info_rec;
5856 
5857 end GHR_NON_SF52_EXTRA_INFO;