DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_PROCESS_SF52

Source


1 Package Body GHR_PROCESS_SF52 as
2 /* $Header: ghproc52.pkb 120.42.12020000.7 2012/11/05 09:29:35 vmididho ship $ */
3 -- |--------------------------< <Ghr_Process_SF52 >--------------------------|
4 -- Declaring package global variables
5 
6 	g_futr_proc_name	varchar2(30):='GHR_Proc_Futr_Act';
7 
8 -- Declaring local procedures and functions
9 Function  get_information_type(p_noa_id in number) return varchar2;
10 Procedure Route_Errorerd_SF52(
11 	p_sf52  in out nocopy ghr_pa_requests%rowtype,
12 	p_error	in varchar2,
13 	p_result   out nocopy varchar2);
14 
15 Procedure Single_Action_SF52(p_sf52_data  in out nocopy ghr_pa_requests%rowtype,
16 			     p_process_type in	varchar2 default 'CURRENT',
17                              p_capped_other_pay    in number default null);
18 Procedure Dual_Action_SF52(p_sf52_data in out nocopy ghr_pa_requests%rowtype,
19 			   p_process_type in varchar2 default 'CURRENT');
20 
21 procedure create_ghr_errorlog(
22       p_program_name           in     ghr_process_log.program_name%type,
23       p_log_text               in     ghr_process_log.log_text%type,
24       p_message_name           in     ghr_process_log.message_name%type,
25       p_log_date               in     ghr_process_log.log_date%type
26       );
27 
28 Procedure Update_shadow_row ( p_shadow_data in	ghr_pa_request_shadow%rowtype,
29 		              p_result	out nocopy Boolean);
30 
31 /*Procedure fetch_update_routing_details
32 (p_pa_request_id           in         ghr_pa_requests.pa_request_id%type,
33  p_object_version_number   in out     ghr_pa_requests.object_version_number%type,
34  p_position_id             in         ghr_pa_requests.to_position_id%type,
35  p_effective_date          in         ghr_pa_requests.effective_date%type,
36  p_retcode                 out        number,
37  p_route_flag              out        boolean
38 );
39 */
40 
41 --6850492
42 procedure Dual_Cancel_sf52(p_sf52_data in out nocopy ghr_pa_requests%rowtype
43                           ,p_first_noa_code  in varchar2
44                        	  ,p_second_noa_code in varchar2
45                 	  ,p_pa_request_id   in number
46                           ,p_ovn             in number
47                 	  ,p_first_noa_id    in number
48                       	  ,p_second_noa_id   in number
49                  	  ,p_row_id          in varchar2);
50 --6850492
51 
52 --- End declaration Local Procedures
53 -- declare global variables
54 --Begin Bug# 5634990
55  -- e_refresh exception is declared in package header.
56 --e_refresh EXCEPTION;
57 --End Bug# 5634990
58 -- |--------------------------< process_sf52>---------------------------------|
59 -- Description:
60 --   This procedure is the generic procedure for processing an sf52. This procedure
61 --   determines what type of sf52 is being processed and calls the appropriate
62 --   procedure to handle it.
63 --
64 -- Pre-Requisities:
65 --   	None.
66 --
67 -- In Parameters:
68 --	p_sf52_data	->	ghr_pa_requests record of the sf52.
69 --	p_process_type	->	either current action or future action.
70 --	p_validate	->	flag to indicate if this is validate only mode.
71 --      p_capped_other_pay ->   Capped Other Pay amount due to Update 34 changes
72 --
73 -- Post Success:
74 -- 	The sf52 will have been processed.
75 --
76 -- Post Failure:
77 --   Exception will have been raised with message explaining what the problem is.
78 --
79 -- Developer Implementation Notes:
80 --   None
81 --
82 -- Access Status:
83 --   Internal Development Use Only.
84 --
85 -- {End Of Comments}
86 -- ---------------------------------------------------------------------------
87 Procedure Process_SF52 (
88 	p_sf52_data	in out	nocopy ghr_pa_requests%rowtype,
89 	p_process_type	in	varchar2	default 'CURRENT',
90 	p_validate	in	Boolean 	default FALSE,
91         p_capped_other_pay in number default NULL) is
92 
93 	l_noa_code			varchar2(4);
94 	l_noa_family_code		varchar2(30);
95 	l_proc				varchar2(30):='process_sf52';
96 	l_sf52_data			ghr_pa_requests%rowtype;
97 
98 --6850492
99 l_dual_cancel         varchar2(1);
100 l_dual_first_noa_code    ghr_pa_requests.first_noa_code%type;
101 l_dual_second_noa_code   ghr_pa_requests.second_noa_code%type;
102 l_dual_pa_request_id     ghr_pa_requests.pa_request_id%type;
103 l_dual_ovn               ghr_pa_requests.object_version_number%type;
104 l_dual_first_noa_id      ghr_pa_requests.first_noa_id%type;
105 l_dual_second_noa_id      ghr_pa_requests.second_noa_id%type;
106 l_dual_row_id            varchar2(100);
107 --6850492   /*Base Action is dual action*/
108 
109   Cursor Chk_Dual_Cancel
110       is
111       select rowid,pa_request_id,first_noa_code,second_noa_code,
112 	     object_version_number,first_noa_id,second_noa_id
113       from   ghr_pa_requests
114       where  pa_request_id = p_sf52_data.altered_pa_request_id
115       and    first_noa_code not in ('001','002')
116       and    second_noa_code is not null
117       and    pa_notification_id is not null;
118       -- Bug # 8283074 removed the below validation as the
119       -- concept of breaking dual relationship is removed
120       /*and    not exists (select 1
121                          from  ghr_pa_requests
122                          where nvl(rpa_type,'-1') <> 'DUAL'
123 			 and   mass_action_id is null
124                          and   first_noa_code in ('002')
125                          and   pa_notification_id is not null
126                          start with pa_request_id = p_sf52_data.altered_pa_request_id
127                          and   altered_pa_request_id is null
128                          connect by altered_pa_request_id = prior pa_request_id);*/
129 --end of 6850492
130 Begin
131 
132         l_sf52_data   := p_sf52_data ; --NOCOPY Changes
133 
134 	hr_utility.set_location(' Entering : ' || l_proc, 10);
135 	hr_utility.set_location(' Payment Option ' || p_sf52_data.pa_incentive_payment_option, 15);
136 
137 	-- set global to disable checks that disallow changes to core data.
138 	-- This is also set back to false when exiting this procedure.
139 	ghr_api.g_api_dml	:= TRUE;
140         -- Start Bug 3256085
141         g_prd := NULL;
142         g_step_or_rate :=  NULL;
143         -- End Bug 3256085
144 	-- issue Savepoint
145 	savepoint process_SF52;
146 
147 	if p_sf52_data.first_noa_code = '001' then
148 		-- Cancellation
149 	  hr_utility.set_location('First LAC CODE is : ' ||p_sf52_data.first_action_la_code1, 11);
150           if p_sf52_data.first_action_la_code1 is null then
151             hr_utility.set_message(8301 , 'GHR_38031_FIRST_LAC_NOT_EXIST');
152             hr_utility.raise_error;
153           end if;
154           --6850492
155 	  l_dual_cancel := 'N';
156 	  for Chk_Dual_Cancel_Rec in Chk_Dual_Cancel
157 	  loop
158 	     l_dual_cancel :='Y';
159 	     l_dual_first_noa_code := Chk_Dual_Cancel_Rec.first_noa_code;
160 	     l_dual_second_noa_code := Chk_Dual_Cancel_Rec.second_noa_code;
161 	     l_dual_pa_request_id := Chk_Dual_Cancel_Rec.pa_request_id;
162 	     l_dual_ovn := Chk_Dual_Cancel_Rec.object_version_number;
163 	     l_dual_first_noa_id :=  Chk_Dual_Cancel_Rec.first_noa_id;
164 	     l_dual_second_noa_id :=  Chk_Dual_Cancel_Rec.second_noa_id;
165 	     l_dual_row_id :=  Chk_Dual_Cancel_Rec.rowid;
166 	  end loop;
167 	  If l_dual_cancel = 'N' then
168              ghr_corr_canc_sf52.cancel_routine(p_sf52_data);
169 	  elsif l_dual_cancel = 'Y' then
170 	     Dual_Cancel_sf52(p_sf52_data => p_sf52_data
171               	             ,p_first_noa_code  => l_dual_first_noa_code
172 	                     ,p_second_noa_code => l_dual_second_noa_code
173 			     ,p_pa_request_id   => l_dual_pa_request_id
174 			     ,p_ovn             => l_dual_ovn
175 			     ,p_first_noa_id    => l_dual_first_noa_id
176 			     ,p_second_noa_id   => l_dual_second_noa_id
177 			     ,p_row_id          => l_dual_row_id);
178 	  end if;
179 	  --6850492
180 
181 
182 	elsif p_sf52_data.first_noa_code = '002' then
183 		-- Correction
184 		ghr_corr_canc_sf52.correction_sf52 ( p_sf52_data        => p_sf52_data,
185 					   	     p_process_type     => p_process_type,
186                                                      p_capped_other_pay => p_capped_other_pay);
187 	elsif p_sf52_data.first_noa_code is not null and
188 		p_sf52_data.second_noa_code is not null then
189 		-- dual Action
190 		--added for 8267598
191 		ghr_process_sf52.reinit_dual_var;
192 		dual_action_sf52 ( p_sf52_data,
193 	         		           p_process_type => p_process_type);
194                 --added for 8267598
195 	         ghr_process_sf52.reinit_dual_var;
196 	elsif p_sf52_data.first_noa_code is not null and
197 		p_sf52_data.second_noa_code is null then
198 		-- Single action
199 		hr_utility.set_location('Bef call single action Payment Option ' || p_sf52_data.pa_incentive_payment_option, 20);
200 		Single_action_SF52 ( p_sf52_data => p_sf52_data,
201 					   p_process_type => p_process_type,
202                                            p_capped_other_pay => p_capped_other_pay);
203 	else
204 	      hr_utility.set_message(8301,'GHR_38222_UNKNOWN_NOA');
205 		ghr_api.g_api_dml	:= FALSE;
206 	      hr_utility.raise_error;
207 		-- raise error.
208 	end if;
209 	-- if validate only mode, then rollback.
210 	if p_validate then
211 		rollback to process_sf52;
212 	end if;
213 
214 	if p_process_type = 'CURRENT' then
215 		Route_Intervn_Future_Actions(
216 			p_person_id		=>	p_sf52_data.person_id,
217 			p_effective_date	=>	p_sf52_data.effective_date
218                   );
219 	end if;
220       If p_process_type = 'FUTURE' then
221          Route_Intervn_Act_pend_today(
222 			p_person_id		=>	p_sf52_data.person_id,
223 			p_effective_date	=>	p_sf52_data.effective_date
224                   );
225       End if;
226 
227 	ghr_history_api.reinit_g_session_var;
228 	ghr_api.g_api_dml	:= FALSE;
229 	hr_utility.set_location(' Leaving : ' || l_proc, 200);
230 
231 EXCEPTION
232   WHEN others THEN
233      -- Reset IN OUT parameters and set OUT parameters
234 
235         p_sf52_data   := l_sf52_data ;
236 
237    hr_utility.set_location('Leaving  ' || l_proc,60);
238    RAISE;
239 End;
240 
241 -- |--------------------------< single_action_sf52>---------------------------|
242 -- Description:
243 --   	This procedure handles the 'normal' case of a single,
244 --	non-correction/cancellation sf52.
245 -- Pre-Requisities:
246 --   	None.
247 -- In Parameters:
248 --	p_sf52_data		->		ghr_pa_requests record of the sf52.
249 --
250 -- Post Success:
251 -- 	The sf52 will have been processed.
252 --
253 -- Post Failure:
254 --   Exception will have been raised with message explaining what the problem is.
255 -- Developer Implementation Notes:
256 --   None
257 -- Access Status:
258 --   Internal Development Use Only.
259 -- ---------------------------------------------------------------------------
260 
261 Procedure Single_Action_SF52 ( p_sf52_data	  in out nocopy	ghr_pa_requests%rowtype,
262        			       p_process_type     in		varchar2 default 'CURRENT',
263                                p_capped_other_pay in number    default null ) is
264 
265 	l_today		date:=sysdate;
266 	l_session_var	ghr_history_api.g_session_var_type;
267 	l_result		varchar2(30);
268 	l_sf52_ei_data	ghr_pa_request_extra_info%rowtype;
269 	l_agency_ei_data	ghr_pa_request_extra_info%rowtype;
270 	l_sf52_shadow	ghr_pa_requests%rowtype;
271 	l_shadow_data	ghr_pa_request_shadow%rowtype;
272 	l_sf52_data		ghr_pa_requests%rowtype;
273 	l_proc		varchar2(30):='single_action_sf52';
274         l_capped_other_pay number;
275 
276 Begin
277         l_sf52_data   := p_sf52_data ; --NOCOPY Changes
278 	hr_utility.set_location(' Entering : ' || l_proc, 10);
279         hr_utility.set_location('Inside single action Payment Option ' || p_sf52_data.pa_incentive_payment_option, 20);
280 	-- reinitialise session variables
281 	ghr_history_api.reinit_g_session_var;
282 	-- set values of session variables
283 	l_session_var.pa_request_id 	:= p_sf52_data.pa_request_id;
284 	l_session_var.noa_id		:= p_sf52_data.first_noa_id;
285 	l_session_var.fire_trigger	:= 'Y';
286 	l_session_var.date_Effective	:= p_sf52_data.effective_date;
287 	l_session_var.person_id		:= p_sf52_data.person_id;
288 	l_session_var.program_name	:= 'sf50';
289 	l_session_var.altered_pa_request_id	:= p_sf52_data.altered_pa_request_id;
290 	l_session_var.assignment_id	:= p_sf52_data.employee_assignment_id;
291 	ghr_history_api.set_g_session_var(l_session_var);
292 
293 
294 	l_sf52_data := p_sf52_data;
295 
296 	refresh_req_shadow (
297 		p_sf52_data	    => l_sf52_data,
298 		p_shadow_data   => l_shadow_data,
299 		p_process_type  => p_process_type);
300         l_capped_other_pay := p_capped_other_pay;
301 	redo_pay_calc( p_Sf52_rec => l_sf52_data,
302                        p_capped_other_pay => l_capped_other_pay );
303 
304 	print_sf52('Before Update to HR Single Action : ' , l_sf52_data);
305 
306 	ghr_non_sf52_extra_info.populate_noa_spec_extra_info(
307 		p_pa_request_id	=>	l_sf52_data.pa_request_id,
308 		p_first_noa_id	=>	l_sf52_data.first_noa_id,
309 		p_second_noa_id	=>	l_sf52_data.second_noa_id,
310 		p_person_id		=>	l_sf52_data.person_id,
311 		p_assignment_id	=>	l_sf52_data.employee_assignment_id,
312 		p_position_id	=>	nvl(l_sf52_data.to_position_id, l_sf52_data.from_position_id),
313 		p_effective_date	=>	l_sf52_data.effective_date,
314 		p_refresh_flag	=>	'Y'
315 	);
316 
317 	ghr_non_sf52_extra_info.fetch_generic_extra_info(
318 		p_pa_request_id	=>	l_sf52_data.pa_request_id,
319 		p_person_id		=>	l_sf52_data.person_id,
320 		p_assignment_id	=>	l_sf52_data.employee_assignment_id,
321 		p_effective_date	=>	l_sf52_data.effective_date,
322 		p_refresh_flag	=>	'Y'
323 	);
324 
325 	-- get sf52 extra info.
326 	Fetch_extra_info( p_pa_request_id 	=> p_sf52_data.pa_request_id,
327 				p_noa_id   		=> p_sf52_data.first_noa_id,
328 				p_sf52_ei_data 	=> l_sf52_ei_data,
329 				p_result		=> l_result);
330 
331 	-- get agency specific sf52 extra info.
332 	Fetch_extra_info( p_pa_request_id 	=> p_sf52_data.pa_request_id,
333 				p_noa_id   		=> p_sf52_data.first_noa_id,
334 				p_agency_ei		=> TRUE,
335 				p_sf52_ei_data 	=> l_agency_ei_data,
336 				p_result		=> l_result);
337 
338 	print_sf52('SINGLE_ACTION BEFORE UPDATE : ' , l_sf52_data);
339 	-- check for future action
340 	if l_session_var.date_effective > l_today then
341 		-- issue savepoint
342 		savepoint single_Action_sf52;
343         -- Check if atleast the min. required items exist in the pa_request
344         ghr_sf52_validn_pkg.prelim_req_chk_for_update_hr
345         (p_pa_request_rec       =>  p_sf52_data
346         );
347 		hr_utility.set_location('Bef call main Payment Option ' || l_sf52_data.pa_incentive_payment_option, 20);
348 		ghr_sf52_update.main( 	p_pa_request_rec    	=> l_sf52_data,
349 				        p_pa_request_ei_rec 	=> l_sf52_ei_data,
350 				        p_generic_ei_rec        => l_agency_ei_data,
351                                         p_capped_other_pay      => l_capped_other_pay);
352 		-- rollback to savepoint
353 		rollback to single_action_sf52;
354 	else
355         -- Check if atleast the min. required items exist in the pa_request
356         ghr_sf52_validn_pkg.prelim_req_chk_for_update_hr
357         (p_pa_request_rec       =>  p_sf52_data
358         );
359 		ghr_sf52_update.main( 	p_pa_request_rec    	=> l_sf52_data,
360 					p_pa_request_ei_rec 	=> l_sf52_ei_data,
361 					p_generic_ei_rec       => l_agency_ei_data,
362                                         p_capped_other_pay      => l_capped_other_pay);
363 	hr_utility.set_location( 'Before Call to Post_sf52_process ' || l_proc , 90);
364 
365 
366 		ghr_sf52_post_update.Post_sf52_process(
367 			p_pa_request_id		=> l_sf52_data.pa_request_id,
368 			p_effective_date		=> l_session_var.date_effective,
369 			p_object_version_number	=> l_sf52_data.object_version_number,
370 			p_from_position_id	=> l_sf52_data.from_position_id,
371 			p_to_position_id		=> l_sf52_data.to_position_id,
372 			p_agency_code		=> l_sf52_data.agency_code,
373                         p_sf52_data_result      => l_sf52_data
374 		);
375 	hr_utility.set_location( 'After Call to Post_sf52_process ' || l_proc , 90);
376 
377 	end if;
378 
379 	Update_rfrs_values( p_sf52_data   => l_sf52_data,
380 				  p_shadow_data => l_shadow_data);
381 	hr_utility.set_location( 'Leaving : ' || l_proc , 100);
382 
383 EXCEPTION
384   WHEN others THEN
385      -- Reset IN OUT parameters and set OUT parameters
386 
387         p_sf52_data   := l_sf52_data ;
388 
389    hr_utility.set_location('Leaving  ' || l_proc,60);
390    RAISE;
391 
392 End Single_Action_SF52;
393 
394 -- |--------------------------< dual_action_sf52>-----------------------------|
395 -- Description:
396 --   	This procedure handles the case of a dual action.
397 -- Pre-Requisities:
398 --   	None.
399 -- In Parameters:
400 --	p_sf52_data		->		ghr_pa_requests record of the sf52.
401 -- Post Success:
402 -- 	The sf52 will have been processed.
403 -- Post Failure:
404 --   Exception will have been raised with message explaining what the problem is.
405 -- Developer Implementation Notes:
406 --   None
407 -- Access Status:
408 --   Internal Development Use Only.
409 -- ---------------------------------------------------------------------------
410 
411 Procedure Dual_Action_SF52( p_sf52_data		in out	nocopy ghr_pa_requests%rowtype,
412 			    p_process_type	in		varchar2 default 'CURRENT') is
413 
414 	l_today		date:=sysdate;
415 	l_sf52_data		ghr_pa_requests%rowtype;
416 	l_sf52_data_save  ghr_pa_requests%rowtype;
417 	l_sf52_ei_data	ghr_pa_request_extra_info%rowtype;
418 	l_agency_ei_data	ghr_pa_request_extra_info%rowtype;
419 	l_shadow_data	ghr_pa_request_shadow%rowtype;
420 	l_session_var	ghr_history_api.g_session_var_type;
421 	l_result		varchar2(30);
422 	l_proc		varchar2(30):='dual_action_sf52';
423         l_new_assignment_id per_all_assignments_f.assignment_id%type;
424         l_capped_other_pay number;
425 
426 Begin
427 
428         l_sf52_data   := p_sf52_data ; --NOCOPY Changes
429 
430 	hr_utility.set_location(' Entering : ' || l_proc, 10);
431 	-- reinitialise session variables
432 	ghr_history_api.reinit_g_session_var;
433 	-- set values of session variables
434 	l_session_var.pa_request_id 	:= p_sf52_data.pa_request_id;
435 	l_session_var.noa_id		:= p_sf52_data.first_noa_id;
436 	l_session_var.fire_trigger	:= 'Y';
437 	l_session_var.date_Effective	:= p_sf52_data.effective_date;
438 	l_session_var.person_id		:= p_sf52_data.person_id;
439 	l_session_var.program_name	:= 'sf50';
440 	l_session_var.assignment_id	:= p_sf52_data.employee_assignment_id;
441 	ghr_history_api.set_g_session_var(l_session_var);
442 	ghr_process_sf52.g_dual_action_yn := 'Y';
443 	ghr_process_sf52.g_dual_first_noac := p_sf52_data.first_noa_code;
444      	ghr_process_sf52.g_dual_second_noac := p_sf52_data.second_noa_code;
445 
446 	l_sf52_data := p_sf52_data;
447 
448 	refresh_req_shadow (
449 		p_sf52_data	    => l_sf52_data,
450 		p_shadow_data   => l_shadow_data,
451 		p_process_type  => p_process_type);
452 	redo_pay_calc( p_Sf52_rec => l_sf52_data,
453                        p_capped_other_pay => l_capped_other_pay);
454 	-- refresh SF52 DDF.
455 	ghr_non_sf52_extra_info.populate_noa_spec_extra_info(
456 		p_pa_request_id	=>	l_sf52_data.pa_request_id,
457 		p_first_noa_id	=>	l_sf52_data.first_noa_id,
458 		p_second_noa_id	=>	l_sf52_data.second_noa_id,
459 		p_person_id		=>	l_sf52_data.person_id,
460 		p_assignment_id	=>	l_sf52_data.employee_assignment_id,
461 		p_position_id	=>	nvl(l_sf52_data.to_position_id, l_sf52_data.from_position_id),
462 		p_effective_date	=>	l_sf52_data.effective_date,
463 		p_refresh_flag	=>	'Y'
464 	);
465 	ghr_non_sf52_extra_info.fetch_generic_extra_info(
466 		p_pa_request_id	=>	l_sf52_data.pa_request_id,
467 		p_person_id		=>	l_sf52_data.person_id,
468 		p_assignment_id	=>	l_sf52_data.employee_assignment_id,
469 		p_effective_date	=>	l_sf52_data.effective_date,
470 		p_refresh_flag	=>	'Y'
471 	);
472 	l_sf52_data_save := l_sf52_data;
473 
474 	--8753859  Modified to not to call assign_new_rg for return to duty as the latest position is considered
475 	-- during the processing of first action itself. For Return to Duty the changes made for the
476 	--second action of dual action will be considered in the first action itself so assign_new_rg is not call
477 	-- for return to duty.
478 
479 	if  l_sf52_data.noa_family_code <> 'RETURN_TO_DUTY' then
480    	    assign_new_rg( p_action_num => 1,
481 			   p_pa_req     => l_sf52_data);
482         else
483 	    null_2ndNoa_cols(l_sf52_data);
484         end if;
485 	if (p_sf52_data.first_noa_code = '893') then --Bug# 8926400
486 		-- In case of dual action we may want to derive from, to column values
487 		-- Will be implemented once we have the business rules requirement.
488 		--	generate_from_to_colm( l_sf52_data);
489 		derive_to_columns(p_sf52_data	=>	l_sf52_data);
490 	end if;
491 
492 	-- get sf52 extra info.
493 	Fetch_extra_info( p_pa_request_id 	=> p_sf52_data.pa_request_id,
494 				p_noa_id   		=> p_sf52_data.first_noa_id,
495 				p_sf52_ei_data 	=> l_sf52_ei_data,
496 				p_result		=> l_result);
497 	-- get agency specific sf52 extra info.
498 	Fetch_extra_info( p_pa_request_id 	=> p_sf52_data.pa_request_id,
499 				p_noa_id   		=> p_sf52_data.first_noa_id,
500 				p_agency_ei		=> TRUE,
501 				p_sf52_ei_data 	=> l_agency_ei_data,
502 				p_result		=> l_result);
503 	-- issue savepoint
504 	savepoint dual_Action_sf52;
505         -- Check if atleast the min. required items exist in the pa_request
506         ghr_sf52_validn_pkg.prelim_req_chk_for_update_hr
507         (p_pa_request_rec       =>  p_sf52_data
508         );
509 
510 	ghr_sf52_update.main(
511 				p_pa_request_rec    	=> l_sf52_data,
512 				p_pa_request_ei_rec	=> l_sf52_ei_data,
513 				p_generic_ei_rec		=> l_agency_ei_data,
514                                 p_capped_other_pay      => l_capped_other_pay);
515 
516 	hr_utility.set_location(' l_sf52_data.employee_assignment_id is : ' || l_sf52_data.employee_assignment_id, 11);
517 	-- Process 2nd NOA
518         l_new_assignment_id := l_sf52_data.employee_assignment_id;
519 	l_sf52_data := p_sf52_data;
520 -- Bug# 1234846-- Venkat --
521 -- Above statement copies employee_assignment_id  to that of first action.
522 -- Below statement corrects it
523 -- ??? We have to research on above blanket copy once fix up patch over..
524         l_sf52_data.employee_assignment_id := l_new_assignment_id;
525 
526         --6850492 added fetching of noa_family_code as family code will change for
527 	--second noa code
528 	get_Family_code(p_noa_id		=> l_sf52_data.second_noa_id,
529 		        p_noa_family_code	=> l_sf52_data.noa_family_code
530    		        );
531 
532 
533 
534 	assign_new_rg( p_action_num => 2,
535 			   p_pa_req     => l_sf52_data);
536 
537 
538 	-- refresh from values here.
539 	if (p_sf52_data.first_noa_code = '893') then--Bug# 8926400
540 		refresh_pa_request(p_person_id	=> 	l_sf52_data.person_id,
541 					 p_effective_date	=>	l_sf52_data.effective_date,
542 					 p_from_only	=>	TRUE,
543 					 p_sf52_data	=>	l_sf52_data);
544 	end if;
545 
546 	-- reinitialise session variables
547 	ghr_history_api.reinit_g_session_var;
548 	-- set values of session variables
549 	l_session_var.pa_request_id 	:= p_sf52_data.pa_request_id;
550 	l_session_var.noa_id		:= p_sf52_data.second_noa_id;
551 	l_session_var.fire_trigger	:= 'Y';
552 	l_session_var.date_Effective	:= p_sf52_data.effective_date;
553 	l_session_var.person_id		:= p_sf52_data.person_id;
554 	l_session_var.program_name	:= 'sf50';
555 	l_session_var.assignment_id	:= l_sf52_data.employee_assignment_id;
556 	ghr_history_api.set_g_session_var(l_session_var);
557 
558 	-- get sf52 extra info.
559 	Fetch_extra_info( p_pa_request_id 	=> p_sf52_data.pa_request_id,
560 			  	p_noa_id   		=> p_sf52_data.second_noa_id,
561 			  	p_sf52_ei_data 	=> l_sf52_ei_data,
562 			  	p_result		=> l_result);
563 
564 	hr_utility.set_location(l_proc, 30);
565 
566         -- Check if atleast the min. required items exist in the pa_request
567         ghr_sf52_validn_pkg.prelim_req_chk_for_update_hr
568         (p_pa_request_rec       =>  p_sf52_data
569         );
570 	ghr_sf52_update.main(
571 		p_pa_request_rec    	=> l_sf52_data,
572 		p_pa_request_ei_rec	=> l_sf52_ei_data,
573 		p_generic_ei_rec        => l_agency_ei_data,
574                 p_capped_other_pay      => l_capped_other_pay);
575 
576 	hr_utility.set_location( l_proc , 60);
577 	if l_session_var.date_effective > l_today then
578 		rollback to dual_action_sf52;
579 	else
580 		hr_utility.set_location( l_proc , 60);
581 		ghr_sf52_post_update.Post_sf52_process(
582 			p_pa_request_id		=> p_sf52_data.pa_request_id,
583 			p_effective_date		=> l_session_var.date_effective,
584 			p_object_version_number	=> p_sf52_data.object_version_number,
585 			p_from_position_id	=> p_sf52_data.from_position_id,
586 			p_to_position_id		=> p_sf52_data.to_position_id,
587 			p_agency_code		=> p_sf52_data.agency_code,
588                         p_sf52_data_result      => l_sf52_data);
589 	end if;
590 	hr_utility.set_location( l_proc, 125);
591 
592 	Update_rfrs_values( p_sf52_data   => l_sf52_data_save,
593 				  p_shadow_data => l_shadow_data);
594 
595 	hr_utility.set_location( 'Leaving : ' || l_proc , 100);
596 
597 EXCEPTION
598   WHEN others THEN
599      -- Reset IN OUT parameters and set OUT parameters
600 
601         p_sf52_data   := l_sf52_data ;
602 
603    hr_utility.set_location('Leaving  ' || l_proc,60);
604    RAISE;
605 
606 end;
607 
608 -- |--------------------------< get_information_type>-------------------------|
609 -- Description:
610 --   	This function returns the information_type given the noa_id.
611 -- Pre-Requisities:
612 --   	None.
613 -- In Parameters:
614 --	p_noa_id	->	nature of action id to retrieve
615 --				information_type for.
616 -- Post Success:
617 -- 	The inforation_type will have been returned.
618 -- Post Failure:
619 --   No failure conditions.
620 -- Developer Implementation Notes:
621 --   None
622 -- Access Status:
623 --   Internal Development Use Only.
624 -- ---------------------------------------------------------------------------
625 Function  get_information_type(p_noa_id 	in number) return varchar2
626 is
627 	l_information_type   ghr_pa_request_info_types.information_type%type;
628 	l_proc               varchar2(72) := 'get_information_type';
629 	Cursor cur_info_type IS
630 	Select pit.information_type
631 	from  ghr_pa_request_info_types  pit,
632 		ghr_noa_families           nfa,
633 		ghr_families               fam
634 	where  nfa.nature_of_action_id  = p_noa_id
635 	and    nfa.noa_family_code      = fam.noa_family_code
636 	and    fam.pa_info_type_flag    = 'Y'
637 	and    pit.noa_family_code      = fam.noa_family_code
638 	and    pit.information_type    <> 'GHR_US_PAR_GEN_AGENCY_DATA'
639 	and 	 pit.information_type	 like 'GHR_US%';
640 -- Bug No 570303 added restriction to only look at 'our' info types
641 Begin
642 	hr_utility.set_location(l_proc,10);
643 	l_information_type := null;
644 	for info_type in cur_info_type
645 	loop
646 		l_information_type :=  info_type.information_type;
647 	end loop;
648 	return l_information_type;
649 End get_information_type;
650 -- |--------------------------< fetch_extra_info>-----------------------------|
651 -- Description:
652 --   	This function fetches the sf52 extra info for a given pa_request.
653 -- Pre-Requisities:
654 --   	None.
655 -- In Parameters:
656 --	p_pa_request_id	->	pa_request_id to fetch the extra info for.
657 --	p_noa_id	->	nature of action id to fetch the extra info for.
658 --	p_agency_ei	->	boolean to indicate if this is agency specific ei.
659 --	p_sf52_ei_data	->	fetched extra info data returned here.
660 --	p_result	->	return code.
661 -- Post Success:
662 -- 	The inforation_type will have been returned.
663 -- Post Failure:
664 --   p_result will be set to 'not_found' if the extra information was not found.
665 -- Developer Implementation Notes:
666 --   None
667 -- Access Status:
668 --   Internal Development Use Only.
669 -- ---------------------------------------------------------------------------
670 Procedure Fetch_Extra_Info( 	p_pa_request_id	in	number,
671 				p_noa_id	in	number,
672 				p_agency_ei	in	boolean	default False,
673 				p_sf52_ei_data	out nocopy	ghr_pa_request_extra_info%rowtype,
674 				p_result	out nocopy	varchar2) is
675 	l_info_type 	ghr_pa_request_info_types.information_type%type;
676 	-- this cursor fetches the extra info data given the information_type and pa_request_id
677 	cursor c_req_ei ( cp_pa_request_id 	number,
678 				cp_info_type	ghr_pa_request_info_types.information_type%type) is
679 		select *
680 		from ghr_pa_request_extra_info
681 		where pa_request_id = cp_pa_request_id and
682 			information_type = cp_info_type;
683 
684 	l_proc		varchar2(30):='fetch_Extra_info';
685 Begin
686 	hr_utility.set_location('entering : ' || l_proc, 10);
687 	if NOT p_agency_ei then
688 		l_info_type := get_information_type(p_noa_id => p_noa_id);
689 	else
690 		l_info_type := 'GHR_US_PAR_GEN_AGENCY_DATA';
691 	end if;
692 
693 	if l_info_type is not null then
694 		open c_req_ei( p_pa_request_id, l_info_type);
695 		fetch c_req_ei into p_sf52_ei_data;
696 		if c_req_ei%notfound then
697 			p_result := 'not_found';
698 		end if;
699 		close c_req_ei;
700 	end if;
701 
702 	hr_utility.set_location( 'Leaving : ' || l_proc, 50);
703 
704 EXCEPTION
705   WHEN others THEN
706      -- Reset IN OUT parameters and set OUT parameters
707 
708         p_sf52_ei_data   := NULL ;
709 	p_result         := NULL ;
710 
711    hr_utility.set_location('Leaving  ' || l_proc,60);
712    RAISE;
713 End;
714 
715 -- |--------------------------< assign_new_rg>--------------------------------|
716 -- Description:
717 --   	This procedure nulls out or populates the unneeded columns in p_pa_req according to the
718 --	following two criteria:
719 --	1) If this the second or first action of a dual action.
720 --	2) Which fields are in pa_data_fields for this noa.
721 -- 	If p_action_num is 2 (We are building this from the second noa of a dual action),
722 --	then copy all second noa columns to the first noa columns and null out
723 --	the second noa columns.
724 --	Then, for each of the fields, copy them to the pa_request record we are building
725 --	according to the criteria listed in the function (Some fields are copied regardless
726 --	of noa, soem fields are noa specific, some fields are never copied and must be populated
727 --	by other means). Note that copy_to_new_rg will null out fields that are not found to
728 --	be needed for the given noa.
729 -- Pre-Requisities:
730 --   	None.
731 -- In Parameters:
732 --	p_action_num	->	number that indicates if this is the first or second action.
733 --	p_pa_req	->	pa_request record is passed here. It is also returned here after
734 --				it has been modified.
735 -- Post Success:
736 -- 	All the fields in p_pa_req will have been populated or nulled as needed for the given NOA.
737 -- Post Failure:
738 --   No Failure conditions.
739 -- Developer Implementation Notes:
740 --   A lot of thought was given to which fields should be copied, which should be always copied, which
741 --	should only be copied if they are in proc_methods, etc. This comment needs to be revisited to reflect
742 --	the reasons behind this.
743 -- Access Status:
744 --   Internal Development Use Only.
745 -- ---------------------------------------------------------------------------
746 PROCEDURE assign_new_rg (
747 	p_action_num       in  number,
748 	p_pa_req 	   in out nocopy ghr_pa_requests%rowtype) IS
749 
750    TYPE fields_type	is	record
751 	(form_field_name		ghr_pa_data_fields.form_field_name%TYPE,
752 	 process_method_code	ghr_noa_fam_proc_methods.process_method_code%TYPE
753 	);
754 	CURSOR get_root_pa_hist_id(	cp_pa_request_id	in	number,
755 						cp_noa_id		in	number) IS
756 		SELECT 	min(pa_history_id)
757 		FROM		ghr_pa_history ghrpah_1
758 		WHERE 	ghrpah_1.pa_request_id =
759 				(SELECT 	min(pa_request_id)
760 				FROM 		ghr_pa_requests
761 				CONNECT BY 	pa_request_id 	= prior altered_pa_request_id
762 				START WITH 	pa_request_id 	= cp_pa_request_id)
763 		AND		ghrpah_1.nature_of_action_id = cp_noa_id;
764 
765 	CURSOR get_dual_family(	p_first_noa_id	in	ghr_dual_actions.first_noa_id%type,
766 					p_second_noa_id	in	ghr_dual_actions.second_noa_id%type) IS
767 		SELECT 	noa_family_code
768 		FROM		ghr_dual_actions
769 		WHERE 	first_noa_id = p_first_noa_id
770 			AND   second_noa_id = p_second_noa_id;
771 	CURSOR get_dual_action(	p_noa_family_code	in	ghr_dual_actions.noa_family_code%type,
772 					p_form_field_name	in	ghr_dual_actions.noa_family_code%type) IS
773 		SELECT	*
774 		FROM		ghr_dual_proc_methods
775 		WHERE		LOWER(noa_family_code) = LOWER(p_noa_family_code)
776 			AND	LOWER(form_field_name) = LOWER(p_form_field_name);
777    TYPE fld_names_typ   is TABLE of fields_type
778 			INDEX BY BINARY_INTEGER;
779    l_fld_names_tab1	fld_names_typ;
780    l_fld_names_tab2	fld_names_typ;
781    l_pa_req		ghr_pa_requests%rowtype;
782    l_column_count		number := 0;
783    l_column_count1	number := 0;
784    l_column_count2	number := 0;
785    l_refresh_called	boolean:= false;
786    l_non_from_called	boolean:= false;
787    l_non_from_pa_req	ghr_pa_requests%rowtype;
788    l_correction			boolean:= null;
789    l_pa_req_ref		ghr_pa_requests%rowtype;
790    l_pa_req_ref2		ghr_pa_requests%rowtype;
791    l_noa_family_code		ghr_dual_actions.noa_family_code%type := null;
792    tmp_varchar		varchar2(150);
793 
794    l_proc	varchar2(30):='assign_new_rg';
795 
796    PROCEDURE initialize_fld_names_table (	p_noa_id 	in		number,
797 						p_fld_names_tab	in out nocopy fld_names_typ) IS
798    -- initializes the local pl/sql table with the field names from ghr_pa_data_fields table.
799 	-- this cursor fetches the form_field_names for the noa_id specified.
800 	CURSOR cur_flds(p_noa_id number) IS
801 		SELECT	fld.form_field_name,
802 				met.process_method_code
803 		FROM
804 			ghr_families			ghrf,
805 			ghr_noa_fam_proc_methods	met,
806 			ghr_pa_data_fields		fld,
807 			ghr_noa_families			fam
808 		WHERE
809 			    fam.noa_family_code		= met.noa_family_code
810 			AND ghrf.noa_family_code	= met.noa_family_code
811 			AND ghrf.update_hr_flag		= 'Y'
812 			AND met.process_method_code in ('AP', 'APUE', 'UE')
813 			AND met.pa_data_field_id	= fld.pa_data_field_id
814 			AND fam.nature_of_action_id	= p_noa_id;
815 	l_proc	varchar2(30):='initialize_fld_names_table';
816 	l_fld_names_tab	 fld_names_typ;
817    BEGIN
818         l_fld_names_tab := p_fld_names_tab;
819 	l_column_count := 0;
820 	hr_utility.set_location('Entering:'|| l_proc, 5);
821 	-- populate the local table with the form_field_names for this noa.
822       FOR curflds_rec in cur_flds(p_noa_id) LOOP
823           l_column_count := l_column_count + 1;
824           p_fld_names_tab(l_column_count) := curflds_rec;
825       END LOOP;
826 	hr_utility.set_location('Leaving:'|| l_proc, 10);
827    EXCEPTION
828      WHEN OTHERS THEN
829      -- NOCOPY CHANGES
830         p_fld_names_tab := l_fld_names_tab;
831    END initialize_fld_names_table;
832 
833 FUNCTION to_from_info(p_field_name	IN varchar2) return varchar2 IS
834 	l_proc	varchar2(30):='to_from_info';
835 	ret_value	varchar2(1) := 'N';
836 BEGIN
837 	if (LOWER(SUBSTR(p_field_name, 0, 5)) = 'from_') then
838 		ret_value := 'F';
839 	elsif (LOWER(SUBSTR(p_field_name, 0, 3)) = 'to_') then
840 		ret_value := 'T';
841 	end if;
842 	return ret_value;
843 END;
844 
845 FUNCTION	get_field_info(	p_field_name	IN VARCHAR2,
846 					p_sf52_data		IN ghr_pa_requests%rowtype) RETURN varchar2 IS
847 	l_proc	varchar2(30):='get_field_info';
848 	l_ret_value	varchar2(2000);
849 BEGIN
850 	hr_utility.set_location('Entering: ' ||l_proc, 10);
851 	if (lower(p_field_name) = 'pa_request_id') then
852 		l_ret_value := p_sf52_data.pa_request_id;
853 
854 	elsif (lower(p_field_name) = 'pa_notification_id') then
855 		l_ret_value := p_sf52_data.pa_notification_id;
856 
857 	elsif (lower(p_field_name) = 'noa_family_code') then
858 		l_ret_value := p_sf52_data.noa_family_code;
859 
860 	elsif (lower(p_field_name) = 'routing_group_id') then
861 		l_ret_value := p_sf52_data.routing_group_id;
862 
863 	elsif (lower(p_field_name) = 'academic_discipline') then
864 		l_ret_value := p_sf52_data.academic_discipline;
865 
866 	elsif (lower(p_field_name) = 'additional_info_person_id') then
867 		l_ret_value := p_sf52_data.additional_info_person_id;
868 
869 	elsif (lower(p_field_name) = 'additional_info_tel_number') then
870 		l_ret_value := p_sf52_data.additional_info_tel_number;
871 
872 	elsif ((lower(p_field_name) = 'agency_code') or (lower(p_field_name) = 'to_agency_code')) then
873 		l_ret_value := p_sf52_data.agency_code;
874 
875 	elsif (lower(p_field_name) = 'altered_pa_request_id') then
876 		l_ret_value := p_sf52_data.altered_pa_request_id;
877 
878 	elsif (lower(p_field_name) = 'annuitant_indicator') then
879 		l_ret_value := p_sf52_data.annuitant_indicator;
880 
881 	elsif (lower(p_field_name) = 'annuitant_indicator_desc') then
882 		l_ret_value := p_sf52_data.annuitant_indicator_desc;
883 
884 	elsif (lower(p_field_name) = 'appropriation_code1') then
885 		l_ret_value := p_sf52_data.appropriation_code1;
886 
887 	elsif (lower(p_field_name) = 'appropriation_code2') then
888 		l_ret_value := p_sf52_data.appropriation_code2;
889 
890 	elsif (lower(p_field_name) = 'approval_date') then
891 		l_ret_value := to_char(p_sf52_data.approval_date,'DDMMYYYY');
892 
893 	elsif (lower(p_field_name) = 'approving_official_work_title') then
894 		l_ret_value := p_sf52_data.approving_official_work_title;
895 
896 	elsif (lower(p_field_name) = 'authorized_by_person_id') then
897 		l_ret_value := p_sf52_data.authorized_by_person_id;
898 
899 	elsif (lower(p_field_name) = 'authorized_by_title') then
900 		l_ret_value := p_sf52_data.authorized_by_title;
901 
902 	elsif (lower(p_field_name) = 'award_amount') then
903 		l_ret_value := p_sf52_data.award_amount;
904 
905 	elsif (lower(p_field_name) = 'award_uom') then
906 		l_ret_value := p_sf52_data.award_uom;
907 
908 	elsif (lower(p_field_name) = 'bargaining_unit_status') then
909 		l_ret_value := p_sf52_data.bargaining_unit_status;
910 
911 	elsif (lower(p_field_name) = 'citizenship') then
912 		l_ret_value := p_sf52_data.citizenship;
913 
914 	elsif (lower(p_field_name) = 'concurrence_date') then
915 		l_ret_value := to_char(p_sf52_data.concurrence_date,'DDMMYYYY');
916 
917 	elsif (lower(p_field_name) = 'custom_pay_calc_flag') then
918 		l_ret_value := p_sf52_data.custom_pay_calc_flag;
919 
920 	elsif (lower(p_field_name) = 'duty_station_code') then
921 		l_ret_value := p_sf52_data.duty_station_code;
922 
923 	elsif (lower(p_field_name) = 'duty_station_desc') then
924 		l_ret_value := p_sf52_data.duty_station_desc;
925 
926 	elsif (lower(p_field_name) = 'duty_station_id') then
927 		l_ret_value := to_char(p_sf52_data.duty_station_id);
928 
929 	elsif (lower(p_field_name) = 'duty_station_location_id') then
930 		l_ret_value := to_char(p_sf52_data.duty_station_location_id);
931 
932 	elsif (lower(p_field_name) = 'education_level') then
933 		l_ret_value := p_sf52_data.education_level;
934 
935 	elsif (lower(p_field_name) = 'effective_date') then
936 		l_ret_value := to_char(p_sf52_data.effective_date,'DDMMYYYY');
937 
938 	elsif (lower(p_field_name) = 'employee_assignment_id') then
939 		l_ret_value := p_sf52_data.employee_assignment_id;
940 
941 	elsif (lower(p_field_name) = 'employee_date_of_birth') then
942 		-- must specify conversion in order to avoid Y2000 problems
943 		l_ret_value := to_char(p_sf52_data.employee_date_of_birth,'DDMMYYYY');
944 
945 	elsif (lower(p_field_name) = 'employee_dept_or_agency') then
946 		l_ret_value := p_sf52_data.employee_dept_or_agency;
947 
948 	elsif (lower(p_field_name) = 'employee_first_name') then
949 		l_ret_value := p_sf52_data.employee_first_name;
950 
951 	elsif (lower(p_field_name) = 'employee_last_name') then
952 		l_ret_value := p_sf52_data.employee_last_name;
953 
954 	elsif (lower(p_field_name) = 'employee_middle_names') then
955 		l_ret_value := p_sf52_data.employee_middle_names;
956 
957 	elsif (lower(p_field_name) = 'employee_national_identifier') then
958 		l_ret_value := p_sf52_data.employee_national_identifier;
959 
960 	elsif (lower(p_field_name) = 'fegli') then
961 		l_ret_value := p_sf52_data.fegli;
962 
963 	elsif (lower(p_field_name) = 'fegli_desc') then
964 		l_ret_value := p_sf52_data.fegli_desc;
965 
966 	elsif (lower(p_field_name) = 'first_action_la_code1') then
967 		l_ret_value := p_sf52_data.first_action_la_code1;
968 
969 	elsif (lower(p_field_name) = 'first_action_la_code2') then
970 		l_ret_value := p_sf52_data.first_action_la_code2;
971 
972 	elsif (lower(p_field_name) = 'first_action_la_desc1') then
973 		l_ret_value := p_sf52_data.first_action_la_desc1;
974 
975 	elsif (lower(p_field_name) = 'first_action_la_desc2') then
976 		l_ret_value := p_sf52_data.first_action_la_desc2;
977 
978 	elsif (lower(p_field_name) = 'first_noa_cancel_or_correct') then
979 		l_ret_value := p_sf52_data.first_noa_cancel_or_correct;
980 
981 	elsif (lower(p_field_name) = 'first_noa_code') then
982 		l_ret_value := p_sf52_data.first_noa_code;
983 
984 	elsif (lower(p_field_name) = 'first_noa_desc') then
985 		l_ret_value := p_sf52_data.first_noa_desc;
986 
987 	elsif (lower(p_field_name) = 'first_noa_id') then
988 		l_ret_value := p_sf52_data.first_noa_id;
989 
990 	elsif (lower(p_field_name) = 'first_noa_pa_request_id') then
991 		l_ret_value := p_sf52_data.first_noa_pa_request_id;
992 
993 	elsif (lower(p_field_name) = 'flsa_category') then
994 		l_ret_value := p_sf52_data.flsa_category;
995 
996 	elsif (lower(p_field_name) = 'forwarding_address_line1') then
997 		l_ret_value := p_sf52_data.forwarding_address_line1;
998 
999 	elsif (lower(p_field_name) = 'forwarding_address_line2') then
1000 		l_ret_value := p_sf52_data.forwarding_address_line2;
1001 
1002 	elsif (lower(p_field_name) = 'forwarding_address_line3') then
1003 		l_ret_value := p_sf52_data.forwarding_address_line3;
1004 
1005 	elsif (lower(p_field_name) = 'forwarding_country') then
1006 		l_ret_value := p_sf52_data.forwarding_country;
1007 
1008 	elsif (lower(p_field_name) = 'forwarding_country_short_name') then
1009 		l_ret_value := p_sf52_data.forwarding_country_short_name;
1010 
1011 	elsif (lower(p_field_name) = 'forwarding_postal_code') then
1012 		l_ret_value := p_sf52_data.forwarding_postal_code;
1013 
1014 	elsif (lower(p_field_name) = 'forwarding_region_2') then
1015 		l_ret_value := p_sf52_data.forwarding_region_2;
1016 
1017 	elsif (lower(p_field_name) = 'forwarding_town_or_city') then
1018 		l_ret_value := p_sf52_data.forwarding_town_or_city;
1019 
1020 	elsif (lower(p_field_name) = 'from_adj_basic_pay') then
1021 		l_ret_value := p_sf52_data.from_adj_basic_pay;
1022 
1023 	elsif (lower(p_field_name) = 'from_agency_code') then
1024 		l_ret_value := p_sf52_data.from_agency_code;
1025 
1026 	elsif (lower(p_field_name) = 'from_agency_desc') then
1027 		l_ret_value := p_sf52_data.from_agency_desc;
1028 
1029 	elsif (lower(p_field_name) = 'from_ap_premium_pay_indicator') then
1030 		if (not l_non_from_called) then
1031 			refresh_pa_request(
1032 						p_person_id		=>	p_sf52_data.person_id,
1033 						p_effective_date	=>	p_sf52_data.effective_date,
1034 						p_derive_to_cols	=>	TRUE,
1035 						p_sf52_data		=>	l_non_from_pa_req);
1036 		end if;
1037 		l_ret_value := l_non_from_pa_req.to_ap_premium_pay_indicator;
1038 
1039 	elsif (lower(p_field_name) = 'from_auo_premium_pay_indicator') then
1040 		if (not l_non_from_called) then
1041 			refresh_pa_request(
1042 						p_person_id		=>	p_sf52_data.person_id,
1043 						p_effective_date	=>	p_sf52_data.effective_date,
1044 						p_derive_to_cols	=>	TRUE,
1045 						p_sf52_data		=>	l_non_from_pa_req);
1046 		end if;
1047 		l_ret_value := l_non_from_pa_req.to_auo_premium_pay_indicator;
1048 
1049 	elsif (lower(p_field_name) = 'from_au_overtime') then
1050 		if (not l_non_from_called) then
1051 			refresh_pa_request(
1052 						p_person_id		=>	p_sf52_data.person_id,
1053 						p_effective_date	=>	p_sf52_data.effective_date,
1054 						p_derive_to_cols	=>	TRUE,
1055 						p_sf52_data		=>	l_non_from_pa_req);
1056 		end if;
1057 		l_ret_value := l_non_from_pa_req.to_au_overtime;
1058 
1059 	elsif (lower(p_field_name) = 'from_availability_pay') then
1060 		if (not l_non_from_called) then
1061 			refresh_pa_request(
1062 						p_person_id		=>	p_sf52_data.person_id,
1063 						p_effective_date	=>	p_sf52_data.effective_date,
1064 						p_derive_to_cols	=>	TRUE,
1065 						p_sf52_data		=>	l_non_from_pa_req);
1066 		end if;
1067 		l_ret_value := l_non_from_pa_req.to_availability_pay;
1068 
1069 	elsif (lower(p_field_name) = 'from_retention_allowance') then
1070 		if (not l_non_from_called) then
1071 			refresh_pa_request(
1072 						p_person_id		=>	p_sf52_data.person_id,
1073 						p_effective_date	=>	p_sf52_data.effective_date,
1074 						p_derive_to_cols	=>	TRUE,
1075 						p_sf52_data		=>	l_non_from_pa_req);
1076 		end if;
1077 		l_ret_value := l_non_from_pa_req.to_retention_allowance;
1078 
1079 	elsif (lower(p_field_name) = 'from_retention_allow_percentage') then
1080 		if (not l_non_from_called) then
1081 			refresh_pa_request(
1082 						p_person_id		=>	p_sf52_data.person_id,
1083 						p_effective_date	=>	p_sf52_data.effective_date,
1084 						p_derive_to_cols	=>	TRUE,
1085 						p_sf52_data		=>	l_non_from_pa_req);
1086 		end if;
1087 		l_ret_value := l_non_from_pa_req.to_retention_allow_percentage;
1088 
1089 	elsif (lower(p_field_name) = 'from_staffing_differential') then
1090 		if (not l_non_from_called) then
1091 			refresh_pa_request(
1092 						p_person_id		=>	p_sf52_data.person_id,
1093 						p_effective_date	=>	p_sf52_data.effective_date,
1094 						p_derive_to_cols	=>	TRUE,
1095 						p_sf52_data		=>	l_non_from_pa_req);
1096 		end if;
1097 		l_ret_value := l_non_from_pa_req.to_staffing_differential;
1098 
1099 	elsif (lower(p_field_name) = 'from_staffing_diff_percentage') then
1100 		if (not l_non_from_called) then
1101 			refresh_pa_request(
1102 						p_person_id		=>	p_sf52_data.person_id,
1103 						p_effective_date	=>	p_sf52_data.effective_date,
1104 						p_derive_to_cols	=>	TRUE,
1105 						p_sf52_data		=>	l_non_from_pa_req);
1106 		end if;
1107 		l_ret_value := l_non_from_pa_req.to_staffing_diff_percentage;
1108 
1109 	elsif (lower(p_field_name) = 'from_supervisory_differential') then
1110 		if (not l_non_from_called) then
1111 			refresh_pa_request(
1112 						p_person_id		=>	p_sf52_data.person_id,
1113 						p_effective_date	=>	p_sf52_data.effective_date,
1114 						p_derive_to_cols	=>	TRUE,
1115 						p_sf52_data		=>	l_non_from_pa_req);
1116 		end if;
1117 		l_ret_value := l_non_from_pa_req.to_supervisory_differential;
1118 
1119 	elsif (lower(p_field_name) = 'from_supervisory_diff_percentage') then
1120 		if (not l_non_from_called) then
1121 			refresh_pa_request(
1122 						p_person_id		=>	p_sf52_data.person_id,
1123 						p_effective_date	=>	p_sf52_data.effective_date,
1124 						p_derive_to_cols	=>	TRUE,
1125 						p_sf52_data		=>	l_non_from_pa_req);
1126 		end if;
1127 		l_ret_value := l_non_from_pa_req.to_supervisory_diff_percentage;
1128 
1129 	elsif (lower(p_field_name) = 'from_organization_id') then
1130 		if (not l_non_from_called) then
1131 			refresh_pa_request(
1132 						p_person_id		=>	p_sf52_data.person_id,
1133 						p_effective_date	=>	p_sf52_data.effective_date,
1134 						p_derive_to_cols	=>	TRUE,
1135 						p_sf52_data		=>	l_non_from_pa_req);
1136 		end if;
1137 		l_ret_value := l_non_from_pa_req.to_organization_id;
1138 
1139 	elsif (lower(p_field_name) = 'from_job_id') then
1140 		if (not l_non_from_called) then
1141 			refresh_pa_request(
1142 						p_person_id		=>	p_sf52_data.person_id,
1143 						p_effective_date	=>	p_sf52_data.effective_date,
1144 						p_derive_to_cols	=>	TRUE,
1145 						p_sf52_data		=>	l_non_from_pa_req);
1146 		end if;
1147 		l_ret_value := l_non_from_pa_req.to_job_id;
1148 
1149 	elsif (lower(p_field_name) = 'from_grade_id') then
1150 		if (not l_non_from_called) then
1151 			refresh_pa_request(
1152 						p_person_id		=>	p_sf52_data.person_id,
1153 						p_effective_date	=>	p_sf52_data.effective_date,
1154 						p_derive_to_cols	=>	TRUE,
1155 						p_sf52_data		=>	l_non_from_pa_req);
1156 		end if;
1157 		l_ret_value := l_non_from_pa_req.to_grade_id;
1158 
1159 	elsif (lower(p_field_name) = 'from_basic_pay') then
1160 		l_ret_value := p_sf52_data.from_basic_pay;
1161 
1162 	elsif (lower(p_field_name) = 'from_grade_or_level') then
1163 		l_ret_value := p_sf52_data.from_grade_or_level;
1164 
1165 	elsif (lower(p_field_name) = 'from_locality_adj') then
1166 		l_ret_value := p_sf52_data.from_locality_adj;
1167 
1168 	elsif (lower(p_field_name) = 'from_occ_code') then
1169 		l_ret_value := p_sf52_data.from_occ_code;
1170 
1171 	elsif (lower(p_field_name) = 'from_office_symbol') then
1172 		l_ret_value := p_sf52_data.from_office_symbol;
1173 
1174 	elsif (lower(p_field_name) = 'from_other_pay_amount') then
1175 		l_ret_value := p_sf52_data.from_other_pay_amount;
1176 
1177 	elsif (lower(p_field_name) = 'from_pay_basis') then
1178 		l_ret_value := p_sf52_data.from_pay_basis;
1179 
1180 	elsif (lower(p_field_name) = 'from_pay_plan') then
1181 		l_ret_value := p_sf52_data.from_pay_plan;
1182 
1183 	elsif (lower(p_field_name) = 'from_position_id') then
1184 		l_ret_value := p_sf52_data.from_position_id;
1185 
1186 	elsif (lower(p_field_name) = 'from_position_org_line1') then
1187 		l_ret_value := p_sf52_data.from_position_org_line1;
1188 
1189 	elsif (lower(p_field_name) = 'from_position_org_line2') then
1190 		l_ret_value := p_sf52_data.from_position_org_line2;
1191 
1192 	elsif (lower(p_field_name) = 'from_position_org_line3') then
1193 		l_ret_value := p_sf52_data.from_position_org_line3;
1194 
1195 	elsif (lower(p_field_name) = 'from_position_org_line4') then
1196 		l_ret_value := p_sf52_data.from_position_org_line4;
1197 
1198 	elsif (lower(p_field_name) = 'from_position_org_line5') then
1199 		l_ret_value := p_sf52_data.from_position_org_line5;
1200 
1201 	elsif (lower(p_field_name) = 'from_position_org_line6') then
1202 		l_ret_value := p_sf52_data.from_position_org_line6;
1203 
1204 	elsif (lower(p_field_name) = 'from_position_number') then
1205 		l_ret_value := p_sf52_data.from_position_number;
1206 
1207 	elsif (lower(p_field_name) = 'from_position_seq_no') then
1208 		l_ret_value := p_sf52_data.from_position_seq_no;
1209 
1210 	elsif (lower(p_field_name) = 'from_position_title') then
1211 		l_ret_value := p_sf52_data.from_position_title;
1212 
1213 	elsif (lower(p_field_name) = 'from_step_or_rate') then
1214 		l_ret_value := p_sf52_data.from_step_or_rate;
1215 
1216 	elsif (lower(p_field_name) = 'from_total_salary') then
1217 		l_ret_value := p_sf52_data.from_total_salary;
1218 
1219 	elsif (lower(p_field_name) = 'functional_class') then
1220 		l_ret_value := p_sf52_data.functional_class;
1221 
1222 	elsif (lower(p_field_name) = 'part_time_hours') then
1223 		l_ret_value := p_sf52_data.part_time_hours;
1224 
1225 	elsif (lower(p_field_name) = 'pay_rate_determinant') then
1226 		l_ret_value := p_sf52_data.pay_rate_determinant;
1227 
1228 	elsif (lower(p_field_name) = 'personnel_office_id') then
1229 		l_ret_value := p_sf52_data.personnel_office_id;
1230 
1231 	elsif (lower(p_field_name) = 'person_id') then
1232 		l_ret_value := p_sf52_data.person_id;
1233 
1234 	elsif (lower(p_field_name) = 'position_occupied') then
1235 		l_ret_value := p_sf52_data.position_occupied;
1236 
1237 	elsif (lower(p_field_name) = 'proposed_effective_asap_flag') then
1238 		l_ret_value := p_sf52_data.proposed_effective_asap_flag;
1239 
1240 	elsif (lower(p_field_name) = 'proposed_effective_date') then
1241 		l_ret_value := to_char(p_sf52_data.proposed_effective_date,'DDMMYYYY');
1242 
1243 	elsif (lower(p_field_name) = 'requested_by_person_id') then
1244 		l_ret_value := p_sf52_data.requested_by_person_id;
1245 
1246 	elsif (lower(p_field_name) = 'requested_by_title') then
1247 		l_ret_value := p_sf52_data.requested_by_title;
1248 
1249 	elsif (lower(p_field_name) = 'requested_date') then
1250 		l_ret_value := to_char(p_sf52_data.requested_date,'DDMMYYYY');
1251 
1252 	elsif (lower(p_field_name) = 'requesting_office_remarks_desc') then
1253 		l_ret_value := p_sf52_data.requesting_office_remarks_desc;
1254 
1255 	elsif (lower(p_field_name) = 'requesting_office_remarks_flag') then
1256 		l_ret_value := p_sf52_data.requesting_office_remarks_flag;
1257 
1258 	elsif (lower(p_field_name) = 'request_number') then
1259 		l_ret_value := p_sf52_data.request_number;
1260 
1261 	elsif (lower(p_field_name) = 'resign_and_retire_reason_desc') then
1262 		l_ret_value := p_sf52_data.resign_and_retire_reason_desc;
1263 
1264 	elsif (lower(p_field_name) = 'retirement_plan') then
1265 		l_ret_value := p_sf52_data.retirement_plan;
1266 
1267 	elsif (lower(p_field_name) = 'retirement_plan_desc') then
1268 		l_ret_value := p_sf52_data.retirement_plan_desc;
1269 
1270 	elsif (lower(p_field_name) = 'second_action_la_code1') then
1271 		l_ret_value := p_sf52_data.second_action_la_code1;
1272 
1273 	elsif (lower(p_field_name) = 'second_action_la_code2') then
1274 		l_ret_value := p_sf52_data.second_action_la_code2;
1275 
1276 	elsif (lower(p_field_name) = 'second_action_la_desc1') then
1277 		l_ret_value := p_sf52_data.second_action_la_desc1;
1278 
1279 	elsif (lower(p_field_name) = 'second_action_la_desc2') then
1280 		l_ret_value := p_sf52_data.second_action_la_desc2;
1281 
1282 	elsif (lower(p_field_name) = 'second_noa_cancel_or_correct') then
1283 		l_ret_value := p_sf52_data.second_noa_cancel_or_correct;
1284 
1285 	elsif (lower(p_field_name) = 'second_noa_code') then
1286 		l_ret_value := p_sf52_data.second_noa_code;
1287 
1288 	elsif (lower(p_field_name) = 'second_noa_desc') then
1289 		l_ret_value := p_sf52_data.second_noa_desc;
1290 
1291 	elsif (lower(p_field_name) = 'second_noa_id') then
1292 		l_ret_value := p_sf52_data.second_noa_id;
1293 
1294 	elsif (lower(p_field_name) = 'second_noa_pa_request_id') then
1295 		l_ret_value := p_sf52_data.second_noa_pa_request_id;
1296 
1297 	elsif (lower(p_field_name) = 'service_comp_date') then
1298 		-- must specify conversion in order to avoid Y2000 problems
1299 		--l_ret_value := fnd_date.date_to_canonical(p_sf52_data.service_comp_date);
1300                 -- Venkat,Bug 1809513,7/5/01 -- We do not need any date_to_canonical conversion here
1301                 -- because  we are not dealing with DDF/element related date here
1302                 --
1303 		l_ret_value := to_char(p_sf52_data.service_comp_date,'DDMMYYYY');
1304 
1305 	elsif (lower(p_field_name) = 'supervisory_status') then
1306 		l_ret_value := p_sf52_data.supervisory_status;
1307 
1308 	elsif (lower(p_field_name) = 'tenure') then
1309 		l_ret_value := p_sf52_data.tenure;
1310 
1311 	elsif (lower(p_field_name) = 'to_adj_basic_pay') then
1312 		l_ret_value := p_sf52_data.to_adj_basic_pay;
1313 
1314 	elsif (lower(p_field_name) = 'to_ap_premium_pay_indicator') then
1315 		l_ret_value := p_sf52_data.to_ap_premium_pay_indicator;
1316 
1317 	elsif (lower(p_field_name) = 'to_auo_premium_pay_indicator') then
1318 		l_ret_value := p_sf52_data.to_auo_premium_pay_indicator;
1319 
1320 	elsif (lower(p_field_name) = 'to_au_overtime') then
1321 		l_ret_value := p_sf52_data.to_au_overtime;
1322 
1323 	elsif (lower(p_field_name) = 'to_availability_pay') then
1324 		l_ret_value := p_sf52_data.to_availability_pay;
1325 
1326 	elsif (lower(p_field_name) = 'to_basic_pay') then
1327 		l_ret_value := p_sf52_data.to_basic_pay;
1328 
1329 	elsif (lower(p_field_name) = 'to_grade_id') then
1330 		l_ret_value := p_sf52_data.to_grade_id;
1331 
1332 	elsif (lower(p_field_name) = 'to_grade_or_level') then
1333 		l_ret_value := p_sf52_data.to_grade_or_level;
1334 
1335 	elsif (lower(p_field_name) = 'to_job_id') then
1336 		l_ret_value := p_sf52_data.to_job_id;
1337 
1338 	elsif (lower(p_field_name) = 'to_locality_adj') then
1339 		l_ret_value := p_sf52_data.to_locality_adj;
1340 
1341 	elsif (lower(p_field_name) = 'to_occ_code') then
1342 		l_ret_value := p_sf52_data.to_occ_code;
1343 
1344 	elsif (lower(p_field_name) = 'to_office_symbol') then
1345 		l_ret_value := p_sf52_data.to_office_symbol;
1346 
1347 	elsif (lower(p_field_name) = 'to_organization_id') then
1348 		l_ret_value := p_sf52_data.to_organization_id;
1349 
1350 	elsif (lower(p_field_name) = 'to_other_pay_amount') then
1351 		l_ret_value := p_sf52_data.to_other_pay_amount;
1352 
1353 	elsif (lower(p_field_name) = 'to_pay_basis') then
1354 		l_ret_value := p_sf52_data.to_pay_basis;
1355 
1356 	elsif (lower(p_field_name) = 'to_pay_plan') then
1357 		l_ret_value := p_sf52_data.to_pay_plan;
1358 
1359 	elsif (lower(p_field_name) = 'to_position_id') then
1360 		l_ret_value := p_sf52_data.to_position_id;
1361 
1362 	elsif (lower(p_field_name) = 'to_position_org_line1') then
1363 		l_ret_value := p_sf52_data.to_position_org_line1;
1364 
1365 	elsif (lower(p_field_name) = 'to_position_org_line2') then
1366 		l_ret_value := p_sf52_data.to_position_org_line2;
1367 
1368 	elsif (lower(p_field_name) = 'to_position_org_line3') then
1369 		l_ret_value := p_sf52_data.to_position_org_line3;
1370 
1371 	elsif (lower(p_field_name) = 'to_position_org_line4') then
1372 		l_ret_value := p_sf52_data.to_position_org_line4;
1373 
1374 	elsif (lower(p_field_name) = 'to_position_org_line5') then
1375 		l_ret_value := p_sf52_data.to_position_org_line5;
1376 
1377 	elsif (lower(p_field_name) = 'to_position_org_line6') then
1378 		l_ret_value := p_sf52_data.to_position_org_line6;
1379 
1380 	elsif (lower(p_field_name) = 'to_position_number') then
1381 		l_ret_value := p_sf52_data.to_position_number;
1382 
1383 	elsif (lower(p_field_name) = 'to_position_seq_no') then
1384 		l_ret_value := p_sf52_data.to_position_seq_no;
1385 
1386 	elsif (lower(p_field_name) = 'to_position_title') then
1387 		l_ret_value := p_sf52_data.to_position_title;
1388 
1389 	elsif (lower(p_field_name) = 'to_retention_allowance') then
1390 		l_ret_value := p_sf52_data.to_retention_allowance;
1391 
1392 	elsif (lower(p_field_name) = 'to_retention_allow_percentage') then
1393 		l_ret_value := p_sf52_data.to_retention_allow_percentage;
1394 
1395 	elsif (lower(p_field_name) = 'to_staffing_differential') then
1396 		l_ret_value := p_sf52_data.to_staffing_differential;
1397 
1398 	elsif (lower(p_field_name) = 'to_staffing_diff_percentage') then
1399 		l_ret_value := p_sf52_data.to_staffing_diff_percentage;
1400 
1401 	elsif (lower(p_field_name) = 'to_step_or_rate') then
1402 		l_ret_value := p_sf52_data.to_step_or_rate;
1403 
1404 	elsif (lower(p_field_name) = 'to_supervisory_differential') then
1405 		l_ret_value := p_sf52_data.to_supervisory_differential;
1406 
1407 	elsif (lower(p_field_name) = 'to_supervisory_diff_percentage') then
1408 		l_ret_value := p_sf52_data.to_supervisory_diff_percentage;
1409 
1410 	elsif (lower(p_field_name) = 'to_total_salary') then
1411 		l_ret_value := p_sf52_data.to_total_salary;
1412 
1413 	elsif (lower(p_field_name) = 'veterans_preference') then
1414 		l_ret_value := p_sf52_data.veterans_preference;
1415 
1416 	elsif (lower(p_field_name) = 'veterans_pref_for_rif') then
1417 		l_ret_value := p_sf52_data.veterans_pref_for_rif;
1418 
1419 	elsif (lower(p_field_name) = 'veterans_status') then
1420 		l_ret_value := p_sf52_data.veterans_status;
1421 
1422 	elsif (lower(p_field_name) = 'work_schedule') then
1423 		l_ret_value := p_sf52_data.work_schedule;
1424 
1425 	elsif (lower(p_field_name) = 'work_schedule_desc') then
1426 		l_ret_value := p_sf52_data.work_schedule_desc;
1427 
1428 	elsif (lower(p_field_name) = 'year_degree_attained') then
1429 		l_ret_value := p_sf52_data.year_degree_attained;
1430 
1431 	elsif (lower(p_field_name) = 'first_noa_information1') then
1432 		l_ret_value := p_sf52_data.first_noa_information1;
1433 
1434 	elsif (lower(p_field_name) = 'first_noa_information2') then
1435 		l_ret_value := p_sf52_data.first_noa_information2;
1436 
1437 	elsif (lower(p_field_name) = 'first_noa_information3') then
1438 		l_ret_value := p_sf52_data.first_noa_information3;
1439 
1440 	elsif (lower(p_field_name) = 'first_noa_information4') then
1441 		l_ret_value := p_sf52_data.first_noa_information4;
1442 
1443 	elsif (lower(p_field_name) = 'first_noa_information5') then
1444 		l_ret_value := p_sf52_data.first_noa_information5;
1445 
1446 	elsif (lower(p_field_name) = 'second_lac1_information1') then
1447 		l_ret_value := p_sf52_data.second_lac1_information1;
1448 
1449 	elsif (lower(p_field_name) = 'second_lac1_information2') then
1450 		l_ret_value := p_sf52_data.second_lac1_information2;
1451 
1452 	elsif (lower(p_field_name) = 'second_lac1_information3') then
1453 		l_ret_value := p_sf52_data.second_lac1_information3;
1454 
1455 	elsif (lower(p_field_name) = 'second_lac1_information4') then
1456 		l_ret_value := p_sf52_data.second_lac1_information4;
1457 
1458 	elsif (lower(p_field_name) = 'second_lac1_information5') then
1459 		l_ret_value := p_sf52_data.second_lac1_information5;
1460 
1461 	elsif (lower(p_field_name) = 'second_lac2_information1') then
1462 		l_ret_value := p_sf52_data.second_lac2_information1;
1463 
1464 	elsif (lower(p_field_name) = 'second_lac2_information2') then
1465 		l_ret_value := p_sf52_data.second_lac2_information2;
1466 
1467 	elsif (lower(p_field_name) = 'second_lac2_information3') then
1468 		l_ret_value := p_sf52_data.second_lac2_information3;
1469 
1470 	elsif (lower(p_field_name) = 'second_lac2_information4') then
1471 		l_ret_value := p_sf52_data.second_lac2_information4;
1472 
1473 	elsif (lower(p_field_name) = 'second_lac2_information5') then
1474 		l_ret_value := p_sf52_data.second_lac2_information5;
1475 
1476 	elsif (lower(p_field_name) = 'second_noa_information1') then
1477 		l_ret_value := p_sf52_data.second_noa_information1;
1478 
1479 	elsif (lower(p_field_name) = 'second_noa_information2') then
1480 		l_ret_value := p_sf52_data.second_noa_information2;
1481 
1482 	elsif (lower(p_field_name) = 'second_noa_information3') then
1483 		l_ret_value := p_sf52_data.second_noa_information3;
1484 
1485 	elsif (lower(p_field_name) = 'second_noa_information4') then
1486 		l_ret_value := p_sf52_data.second_noa_information4;
1487 
1488 	elsif (lower(p_field_name) = 'second_noa_information5') then
1489 		l_ret_value := p_sf52_data.second_noa_information5;
1490 
1491 	elsif (lower(p_field_name) = 'first_lac1_information1') then
1492 		l_ret_value := p_sf52_data.first_lac1_information1;
1493 
1494 	elsif (lower(p_field_name) = 'first_lac1_information2') then
1495 		l_ret_value := p_sf52_data.first_lac1_information2;
1496 
1497 	elsif (lower(p_field_name) = 'first_lac1_information3') then
1498 		l_ret_value := p_sf52_data.first_lac1_information3;
1499 
1500 	elsif (lower(p_field_name) = 'first_lac1_information4') then
1501 		l_ret_value := p_sf52_data.first_lac1_information4;
1502 
1503 	elsif (lower(p_field_name) = 'first_lac1_information5') then
1504 		l_ret_value := p_sf52_data.first_lac1_information5;
1505 
1506 	elsif (lower(p_field_name) = 'first_lac2_information1') then
1507 		l_ret_value := p_sf52_data.first_lac2_information1;
1508 
1509 	elsif (lower(p_field_name) = 'first_lac2_information2') then
1510 		l_ret_value := p_sf52_data.first_lac2_information2;
1511 
1512 	elsif (lower(p_field_name) = 'first_lac2_information3') then
1513 		l_ret_value := p_sf52_data.first_lac2_information3;
1514 
1515 	elsif (lower(p_field_name) = 'first_lac2_information4') then
1516 		l_ret_value := p_sf52_data.first_lac2_information4;
1517 
1518 	elsif (lower(p_field_name) = 'first_lac2_information5') then
1519 		l_ret_value := p_sf52_data.first_lac2_information5;
1520 
1521 	elsif (lower(p_field_name) = 'attribute_category') then
1522 		l_ret_value := p_sf52_data.attribute_category;
1523 
1524 	elsif (lower(p_field_name) = 'attribute1') then
1525 		l_ret_value := p_sf52_data.attribute1;
1526 
1527 	elsif (lower(p_field_name) = 'attribute2') then
1528 		l_ret_value := p_sf52_data.attribute2;
1529 
1530 	elsif (lower(p_field_name) = 'attribute3') then
1531 		l_ret_value := p_sf52_data.attribute3;
1532 
1533 	elsif (lower(p_field_name) = 'attribute4') then
1534 		l_ret_value := p_sf52_data.attribute4;
1535 
1536 	elsif (lower(p_field_name) = 'attribute5') then
1537 		l_ret_value := p_sf52_data.attribute5;
1538 
1539 	elsif (lower(p_field_name) = 'attribute6') then
1540 		l_ret_value := p_sf52_data.attribute6;
1541 
1542 	elsif (lower(p_field_name) = 'attribute7') then
1543 		l_ret_value := p_sf52_data.attribute7;
1544 
1545 	elsif (lower(p_field_name) = 'attribute8') then
1546 		l_ret_value := p_sf52_data.attribute8;
1547 
1548 	elsif (lower(p_field_name) = 'attribute9') then
1549 		l_ret_value := p_sf52_data.attribute9;
1550 
1551 	elsif (lower(p_field_name) = 'attribute10') then
1552 		l_ret_value := p_sf52_data.attribute10;
1553 
1554 	elsif (lower(p_field_name) = 'attribute11') then
1555 		l_ret_value := p_sf52_data.attribute11;
1556 
1557 	elsif (lower(p_field_name) = 'attribute12') then
1558 		l_ret_value := p_sf52_data.attribute12;
1559 
1560 	elsif (lower(p_field_name) = 'attribute13') then
1561 		l_ret_value := p_sf52_data.attribute13;
1562 
1563 	elsif (lower(p_field_name) = 'attribute14') then
1564 		l_ret_value := p_sf52_data.attribute14;
1565 
1566 	elsif (lower(p_field_name) = 'attribute15') then
1567 		l_ret_value := p_sf52_data.attribute15;
1568 
1569 	elsif (lower(p_field_name) = 'attribute16') then
1570 		l_ret_value := p_sf52_data.attribute16;
1571 
1572 	elsif (lower(p_field_name) = 'attribute17') then
1573 		l_ret_value := p_sf52_data.attribute17;
1574 
1575 	elsif (lower(p_field_name) = 'attribute18') then
1576 		l_ret_value := p_sf52_data.attribute18;
1577 
1578 	elsif (lower(p_field_name) = 'attribute19') then
1579 		l_ret_value := p_sf52_data.attribute19;
1580 
1581 	elsif (lower(p_field_name) = 'attribute20') then
1582 		l_ret_value := p_sf52_data.attribute20;
1583       end if;
1584 	hr_utility.set_location('Leaving: ' ||l_proc, 20);
1585 	return l_ret_value;
1586 END;
1587 
1588    Procedure copy_to_new_rg_shared(
1589 				p_action_num	IN NUMBER,
1590 				p_field_name	IN VARCHAR2,
1591 				p_from_field	IN VARCHAR2,
1592 				p_to_field	IN OUT NOCOPY VARCHAR2,
1593 				p_fld_nm_copy_from IN VARCHAR2 default null) IS
1594 
1595 	l_found1		boolean:=false;
1596 	l_found2		boolean:=false;
1597 	l_count1		number :=0;
1598 	l_count2		number :=0;
1599 	l_from_to		varchar2(1) ;
1600 	l_field_name	varchar2(150);
1601 	l_to_field_name	varchar2(150);
1602 	l_dual_actions	ghr_dual_proc_methods%rowtype;
1603 	l_session_var	ghr_history_api.g_session_var_type;
1604 	l_pa_history_id	ghr_pa_history.pa_history_id%type;
1605 	l_to_field		varchar2(2000);
1606 	l_proc		varchar2(30):='copy_to_new_rg_shared';
1607 
1608    Begin
1609 
1610         l_to_field := p_to_field; --NOCOPY Changes
1611 
1612  	hr_utility.set_location('Entering:'|| l_proc, 5);
1613 	-- initialize l_fld_names_tab1 with proc_methods for first noa.
1614       FOR l_count IN 1..l_column_count1 LOOP
1615           if p_field_name = l_fld_names_tab1(l_count).form_field_name then
1616 		l_count1 := l_count;
1617 		l_found1 := TRUE;
1618 	      exit;
1619           end if;
1620       END LOOP;
1621 	-- initialize l_fld_names_tab2 with proc_methods for second noa.
1622       FOR l_count IN 1..l_column_count2 LOOP
1623           if p_field_name = l_fld_names_tab2(l_count).form_field_name then
1624 		l_count2 := l_count;
1625 		l_found2 := TRUE;
1626 	      exit;
1627           end if;
1628       END LOOP;
1629 
1630 	if (p_action_num = 1) then
1631 		if (not l_found1) then
1632 			-- field is 'NE' for this action. Null it out.
1633 			p_to_field := null;
1634 		elsif (not l_found2) then
1635 			-- field is 'NE' for second action. But not 'NE' for first action. So, pass it along as is.
1636 			null;
1637 		elsif ((l_fld_names_tab1(l_count1).process_method_code = 'UE' or
1638 			l_fld_names_tab1(l_count1).process_method_code = 'APUE')  and
1639 			(l_fld_names_tab2(l_count2).process_method_code = 'UE' or
1640 			l_fld_names_tab2(l_count2).process_method_code = 'APUE')) then
1641 			-- this covers the case where the user can enter data for both actions.
1642 			-- i.e. - APUE/UE first action with a APUE/UE second action.
1643 			if (p_pa_req.first_noa_code = '893') then--Bug# 8926400
1644 				-- this is a WGI first action, and requires special handling of UE/APUE-UE/APUE cases.
1645 				if (LOWER(SUBSTR(p_field_name,0,3)) = 'to_') then
1646 					-- this is to information for the first action, do nothing with this field as it is
1647 					-- derived by calling procedure. (i.e. - it doesn't matter if we pass it along as is
1648 					-- bacause calling procedure is going to overwrite this information anyway.
1649 					null;
1650 				else
1651 					-- this is non-to information, go ahead and refresh it for the first action.
1652 					-- according to the requirement, the only fields touched by a WGI first action
1653 					-- are to fields. To fields are derived by calling procedure. All other fields
1654 					-- are refreshed from db here.
1655 					if (not l_refresh_called) then
1656 						-- call refresh with to_position = from-position, since to_position never changes
1657 						-- for a WGI first action (any position change will go to the second action).
1658 						l_pa_req_ref.from_position_id       := p_pa_req.from_position_id;
1659 						l_pa_req_ref.to_position_id         := p_pa_req.from_position_id;
1660 						l_pa_req_ref.effective_date         := p_pa_req.effective_date;
1661 						l_pa_req_ref.employee_assignment_id := p_pa_req.employee_assignment_id;
1662 						--6850492
1663 				                l_pa_req_ref.pa_request_id := p_pa_req.pa_request_id;
1664                     				--6850492
1665 
1666 						refresh_pa_request(p_person_id	       => p_pa_req.person_id,
1667 									 p_effective_date	       => p_pa_req.effective_date,
1668 									 p_sf52_data	       => l_pa_req_ref);
1669 
1670 						l_refresh_called := TRUE;
1671 					end if;
1672 					p_to_field := get_field_info(	p_field_name 	=> NVL(p_fld_nm_copy_from,p_field_name),
1673 										p_sf52_data		=> l_pa_req_ref);
1674 				end if;
1675 			else
1676 				-- non-WGI first action.
1677 				-- here's the handling for the new table:
1678 				if (l_noa_family_code is null) then
1679 					open get_dual_family(	p_first_noa_id 	=>	p_pa_req.first_noa_id,
1680 									p_second_noa_id	=>	p_pa_req.second_noa_id);
1681 					fetch get_dual_family into l_noa_family_code;
1682 					close get_dual_family;
1683 				end if;
1684 				if (LOWER(SUBSTR(p_field_name,0,3)) = 'to_') then
1685 					open get_dual_action(	p_noa_family_code	=>	l_noa_family_code,
1686 									p_form_field_name	=>	'TO_INFO');
1687 					fetch get_dual_action into l_dual_actions;
1688 					if (LOWER(l_dual_actions.first_noa_proc_method) = 'uf') then
1689 						-- copy corresponding 'from' value into 'to' value
1690 						-- Right now, all the calls wil have null in p_fld_nm_copy_from
1691 						-- or if p_field_name is 'TO_...' and p_fld_nm_copy_from has a value
1692 						-- then it will also be 'TO_....'
1693 						l_field_name := nvl(p_fld_nm_copy_from, p_field_name);
1694 						l_to_field_name := REPLACE(l_field_name, 'TO_','FROM_');
1695 						p_to_field := get_field_info(	p_field_name	=>	l_to_field_name,
1696 											p_sf52_data		=>	p_pa_req);
1697 					elsif (LOWER(l_dual_actions.first_noa_proc_method) = 'ue') then
1698 						NULL;
1699 					else
1700 						close get_dual_action;
1701 						hr_utility.set_message(8301, 'GHR_38414_UNSUPPORTED_ACT_TYP');
1702 						hr_utility.set_message_token('ACTION_TYPE', l_dual_actions.first_noa_proc_method);
1703 						hr_utility.raise_error;
1704 					end if;
1705 					close get_dual_action;
1706 				else
1707 					open get_dual_action(	p_noa_family_code	=>	l_noa_family_code,
1708 									p_form_field_name	=>	p_field_name);
1709 					fetch get_dual_action into l_dual_actions;
1710 					if (LOWER(l_dual_actions.first_noa_proc_method) = 'rp') then
1711 						if (not l_refresh_called) then
1712 
1713 							l_pa_req_ref.from_position_id       := l_pa_req.from_position_id;
1714 							-- if this is a return_to_duty first action, then set to_position = from_position
1715 							-- for refresh call. return_to_duty first actions always put to_position info
1716 							-- with the 2nd action.
1717 							/*if (p_pa_req.noa_family_code = 'RETURN_TO_DUTY') then
1718 								l_pa_req_ref.to_position_id         := l_pa_req.from_position_id;
1719 							else*/
1720 								l_pa_req_ref.to_position_id         := l_pa_req.to_position_id;
1721 							--end if;
1722 
1723 							l_pa_req_ref.effective_date         := p_pa_req.effective_date;
1724 							l_pa_req_ref.employee_assignment_id := p_pa_req.employee_assignment_id;
1725 							-- 8288066 Modified to assign step or rate as step or rate is getting
1726 							-- assigned with the from value
1727 							if p_pa_req.noa_family_code = 'RETURN_TO_DUTY' then
1728                         				    l_pa_req_ref.to_step_or_rate := p_pa_req.to_step_or_rate;
1729 			                         	end if;
1730 
1731 							refresh_pa_request(p_person_id	       => p_pa_req.person_id,
1732 										 p_effective_date	       => p_pa_req.effective_date,
1733 										 p_sf52_data	       => l_pa_req_ref);
1734 							l_refresh_called := TRUE;
1735 						end if;
1736 						p_to_field := get_field_info(	p_field_name 	=> nvl(p_fld_nm_copy_from,p_field_name),
1737 											p_sf52_data		=> l_pa_req_ref);
1738 					elsif (LOWER(l_dual_actions.first_noa_proc_method) = 'ue') then
1739 						-- do nothing, pass it along as is.
1740 						null;
1741 					else
1742 						-- unsupported type. Throw error.
1743 						close get_dual_action;
1744 						hr_utility.set_message(8301, 'GHR_38498_UNSUPPORTED_ACT_TYP');
1745 						hr_utility.set_message_token('ACTION_TYPE', l_dual_actions.first_noa_proc_method);
1746 						hr_utility.raise_error;
1747 					end if;
1748 					close get_dual_action;
1749 				end if;
1750 			end if;
1751 		elsif (l_fld_names_tab1(l_count1).process_method_code = 'AP' and
1752 			l_fld_names_tab2(l_count2).process_method_code = 'AP') or
1753 			((l_fld_names_tab1(l_count1).process_method_code = 'APUE' or
1754 			(l_fld_names_tab1(l_count1).process_method_code = 'UE') and
1755 			l_fld_names_tab2(l_count2).process_method_code = 'AP')) then
1756 			-- Either it is 'AP' for both actions, pass the value along as is. Or
1757 			-- first action is 'APUE'/'AP' and second action is 'AP', so pass the value
1758 			-- along as is.
1759 			null;
1760 		elsif (l_fld_names_tab1(l_count1).process_method_code = 'AP' and
1761 			(l_fld_names_tab2(l_count2).process_method_code = 'APUE' or
1762 				l_fld_names_tab2(l_count2).process_method_code = 'UE')) then
1763 			-- first action is 'AP', second action is 'APUE'/'UE'. So, repopulate the field from the database,
1764 			-- as there may be changes to it that have to do with the second action, and not the first.
1765 			if (not l_refresh_called) then
1766 				l_pa_req_ref.from_position_id       := l_pa_req.from_position_id;
1767 				-- if this is a return_to_duty first action, then set to_position = from_position
1768 				-- for refresh call. return_to_duty first actions always put to_position info
1769 				-- with the 2nd action.
1770 				hr_utility.set_location('noa_family_code: ' || l_noa_family_code, 99999);
1771 				/*if (p_pa_req.noa_family_code = 'RETURN_TO_DUTY') then
1772 					l_pa_req_ref.to_position_id         := l_pa_req.from_position_id;
1773 					--This has been added to fetch PRD from the Parent Action
1774 					--While processing for Return to Duty
1775 					l_pa_req_ref.pa_request_id          := l_pa_req.pa_request_id;
1776 				else */
1777 					l_pa_req_ref.to_position_id         := l_pa_req.to_position_id;
1778 				--end if;
1779 				-- 8288066 Modified to assign step or rate as step or rate is getting
1780 							-- assigned with the from value
1781 				if p_pa_req.noa_family_code = 'RETURN_TO_DUTY' then
1782 				    l_pa_req_ref.to_step_or_rate := p_pa_req.to_step_or_rate;
1783 				end if;
1784 
1785 				l_pa_req_ref.effective_date         := p_pa_req.effective_date;
1786 				l_pa_req_ref.employee_assignment_id := p_pa_req.employee_assignment_id;
1787 
1788 				refresh_pa_request(p_person_id	       => p_pa_req.person_id,
1789 							 p_effective_date	       => p_pa_req.effective_date,
1790 							 p_sf52_data	       => l_pa_req_ref);
1791 				l_refresh_called := TRUE;
1792 			end if;
1793 			p_to_field := get_field_info(	p_field_name 	=> nvl(p_fld_nm_copy_from,p_field_name),
1794 								p_sf52_data		=> l_pa_req_ref);
1795 		else
1796 			-- Any other Proc_Method like NE/NE or NE/AP etc. need not be catered to.
1797 			null;
1798 		end if;
1799 	elsif (p_action_num = 2) then
1800 		if (not l_found2) then
1801 			-- field is 'NE' for this action. Null it out.
1802 			p_to_field := null;
1803 		elsif (not l_found1) then
1804 			-- field is 'NE' for first action. But not 'NE' for second action. So, pass it along as is.
1805 			null;
1806 		elsif ((l_fld_names_tab1(l_count1).process_method_code = 'UE' or
1807 			l_fld_names_tab1(l_count1).process_method_code = 'APUE')  and
1808 			(l_fld_names_tab2(l_count2).process_method_code = 'UE' or
1809 			l_fld_names_tab2(l_count2).process_method_code = 'APUE')) then
1810 			-- this covers the case where the user can enter data for both actions.
1811 			-- i.e. - APUE/UE first action with a APUE/UE second action.
1812 			if (p_pa_req.first_noa_code = '893') then--Bug# 8926400
1813 				-- this is a WGI first action, and requires special handling of UE/APUE-UE/APUE cases.
1814 				-- when processing the second action of a dual action with WGI as the first action,
1815 				-- we will always pass the field along as is. The reasons for this are as follows:
1816 				-- 1) If the form field is a to field, then it is automatically associated with the second action.
1817 				-- 2) Non-to field information, is also passed along as is. The requirement specifies that
1818 				--    all information on the form is associated with the second action. The only exception to this
1819 				--	is from information, which is refreshed from the database by the calling procedure whenever
1820 				--	there is a WGI first action.
1821 				null;
1822 			else
1823 				-- non-WGI first action
1824 				-- Here's the functionality to access the new table:
1825 				if (l_noa_family_code is null) then
1826 					open get_dual_family(	p_first_noa_id 	=>	p_pa_req.first_noa_id,
1827 									p_second_noa_id	=>	p_pa_req.second_noa_id);
1828 					fetch get_dual_family into l_noa_family_code;
1829 					close get_dual_family;
1830 				end if;
1831 				if (LOWER(SUBSTR(p_field_name,0,3)) = 'to_') then
1832 					open get_dual_action(	p_noa_family_code	=>	l_noa_family_code,
1833 									p_form_field_name	=>	'TO_INFO');
1834 					fetch get_dual_action into l_dual_actions;
1835 					if (LOWER(l_dual_actions.second_noa_proc_method) = 'ue') then
1836 						-- do nothing, pass it along as is.
1837 						null;
1838 					else
1839 						close get_dual_action;
1840 						hr_utility.set_message(8301, 'GHR_38418_UNSUPPORTED_ACT_TYP');
1841 						hr_utility.set_message_token('ACTION_TYPE', l_dual_actions.second_noa_proc_method);
1842 						hr_utility.raise_error;
1843 					end if;
1844 					close get_dual_action;
1845 				else
1846 					open get_dual_action(	p_noa_family_code	=>	l_noa_family_code,
1847 									p_form_field_name	=>	p_field_name);
1848 					fetch get_dual_action into l_dual_actions;
1849 					if (LOWER(l_dual_actions.second_noa_proc_method) = 'ue' ) then
1850 						-- do nothing, pass it along as is.
1851 						null;
1852 					else
1853 						-- unsupported type. Throw error.
1854 						close get_dual_action;
1855 						hr_utility.set_message(8301, 'GHR_38418_UNSUPPORTED_ACT_TYP');
1856 						hr_utility.set_message_token('ACTION_TYPE', l_dual_actions.second_noa_proc_method);
1857 						hr_utility.raise_error;
1858 					end if;
1859 					close get_dual_action;
1860 				end if;
1861 			end if;
1862 		elsif ((l_fld_names_tab1(l_count1).process_method_code = 'UE' or
1863 			l_fld_names_tab1(l_count1).process_method_code = 'APUE' or
1864 			l_fld_names_tab1(l_count1).process_method_code = 'AP' ) and
1865 			 (l_fld_names_tab2(l_count2).process_method_code = 'AP')) then
1866 			if ((LOWER(SUBSTR(p_field_name, 0, 5))) = 'from_') then
1867 				-- if this is a separation/separation incentive dual
1868 				-- action, then take the from info from the first action as
1869 				-- the from info for the second action. This is necessary because
1870 				-- the separation first action has no to info.
1871 				if (	(p_pa_req.first_noa_code in ('302','303','304','312','317') and --Bug# 8926400
1872 					p_pa_req.second_noa_code = '825') or p_pa_req.first_noa_code
1873 					in ('280','292','893')) then
1874 					null;
1875 				else
1876 					if (l_correction is null) then
1877 						--determine if this is a correction of the 2nd action and act accordingly. i.e. -
1878 						-- only refresh if this is a correction.
1879 					--	ghr_history_api.get_g_session_var(l_session_var);
1880 						open get_root_pa_hist_id(cp_pa_request_id	=>	p_pa_req.pa_request_id,
1881 										cp_noa_id		=>	p_pa_req.second_noa_id);
1882 						fetch get_root_pa_hist_id into l_pa_history_id;
1883 						close get_root_pa_hist_id;
1884 
1885 						-- if this cursor returned a null, then this means that this if the first time this
1886 						-- dual action is being processed. i.e. - this is not a correction of the dual action.
1887 						if l_pa_history_id is not null and p_pa_req.first_noa_code in ('002') then
1888 							-- successfully found the root. Call refresh with this pa_history_id.
1889 							l_correction := true;
1890 							ghr_history_api.get_g_session_var(l_session_var);
1891 							l_session_var.pa_history_id := l_pa_history_id;
1892 							ghr_history_api.set_g_session_var(l_session_var);
1893 							-- note that the following references to l_pa_req an p_pa_req are referencing definitions
1894 							-- in assign_new_rg.
1895 							l_pa_req_ref2.from_position_id       := l_pa_req.from_position_id;
1896 							l_pa_req_ref2.to_position_id         := l_pa_req.to_position_id;
1897 							l_pa_req_ref2.effective_date         := p_pa_req.effective_date;
1898 							l_pa_req_ref2.employee_assignment_id := p_pa_req.employee_assignment_id;
1899 
1900 
1901 							refresh_pa_request(p_person_id	       => p_pa_req.person_id,
1902 										 p_effective_date	       => p_pa_req.effective_date,
1903 										 p_sf52_data	       => l_pa_req_ref2);
1904 
1905 							l_session_var.pa_history_id := null;
1906 							ghr_history_api.set_g_session_var(l_session_var);
1907 						else
1908 							l_correction := false;
1909 						end if;
1910 					end if;
1911 
1912 					if (l_correction = true) then
1913 						l_to_field := get_field_info(	p_field_name 	=> nvl(p_fld_nm_copy_from,p_field_name),
1914 											p_sf52_data		=> l_pa_req_ref2);
1915 						-- only assign to p_to_field if it is not null. If it is null, then refresh didn't populate
1916 						-- it, so we need to retain the original value.
1917 						if (l_to_field is not null) then
1918 							p_to_field := l_to_field;
1919 						end if;
1920 					else
1921 						-- this branch covers the following case:
1922 						-- We are processing the second action. The first action is 'APUE'/'UE' and
1923 						-- the second action is 'AP'. This field is a from information field.
1924 						-- in this case, we want to copy the from info from the corresponding to info.
1925 
1926 						l_field_name := nvl(p_fld_nm_copy_from, p_field_name);
1927 						l_to_field_name := REPLACE(l_field_name, 'FROM','TO');
1928 						p_to_field := get_field_info(	p_field_name	=>	l_to_field_name,
1929 										p_sf52_data		=>	p_pa_req);
1930 
1931 					end if;
1932 				end if;
1933 			else
1934 				-- if this is 'AP'/'AP' and is not from info, simply pass the value along as is.
1935 				if ((l_fld_names_tab1(l_count1).process_method_code = 'AP') and
1936 			 		(l_fld_names_tab2(l_count2).process_method_code = 'AP')) then
1937 					null;
1938 				else
1939 					if (l_correction is null) then
1940 						--determine if this is a correction of the 2nd action and act accordingly. i.e. -
1941 						-- only refresh if this is a correction.
1942 					--	ghr_history_api.get_g_session_var(l_session_var);
1943 						open get_root_pa_hist_id(cp_pa_request_id	=>	p_pa_req.pa_request_id,
1944 										cp_noa_id		=>	p_pa_req.second_noa_id);
1945 						fetch get_root_pa_hist_id into l_pa_history_id;
1946 						close get_root_pa_hist_id;
1947 						-- if this cursor returned a null, then this means that this if the first time this
1948 						-- dual action is being processed. i.e. - this is not a correction of the dual action.
1949 						if l_pa_history_id is not null then
1950 							-- successfully found the root. Call refresh with this pa_history_id.
1951 							l_correction := true;
1952 							ghr_history_api.get_g_session_var(l_session_var);
1953 							l_session_var.pa_history_id := l_pa_history_id;
1954 							ghr_history_api.set_g_session_var(l_session_var);
1955 							-- note that the following references to l_pa_req an p_pa_req are referencing definitions
1956 							-- in assign_new_rg.
1957 							l_pa_req_ref2.from_position_id       := l_pa_req.from_position_id;
1958 							l_pa_req_ref2.to_position_id         := l_pa_req.to_position_id;
1959 							l_pa_req_ref2.effective_date         := p_pa_req.effective_date;
1960 							l_pa_req_ref2.employee_assignment_id := p_pa_req.employee_assignment_id;
1961 
1962 							refresh_pa_request(p_person_id	       => p_pa_req.person_id,
1963 										 p_effective_date	       => p_pa_req.effective_date,
1964 										 p_sf52_data	       => l_pa_req_ref2);
1965 							l_session_var.pa_history_id := null;
1966 							ghr_history_api.set_g_session_var(l_session_var);
1967 						else
1968 							l_correction := false;
1969 						end if;
1970 					end if;
1971 
1972 					if (l_correction = true) then
1973 						hr_utility.set_location('l_refresh_called_2' || l_proc,9165);
1974 						l_to_field := get_field_info(	p_field_name 	=> nvl(p_fld_nm_copy_from,p_field_name),
1975 											p_sf52_data		=> l_pa_req_ref2);
1976 						-- only assign to p_to_field if it is not null. If it is null, then refresh didn't populate
1977 						-- it, so we need to retain the original value.
1978 						if (l_to_field is not null) then
1979 							p_to_field := l_to_field;
1980 						end if;
1981 					end if;
1982 				end if;
1983 			end if;
1984 		elsif (l_fld_names_tab1(l_count1).process_method_code = 'AP' and
1985 			l_fld_names_tab2(l_count2).process_method_code = 'AP') or
1986 		 	((l_fld_names_tab1(l_count1).process_method_code = 'AP' and
1987 			(l_fld_names_tab2(l_count2).process_method_code = 'APUE' or
1988 				l_fld_names_tab2(l_count2).process_method_code = 'UE'))) then
1989 			-- This branch covers the following cases:
1990 			-- 1) It is 'AP' for both actions, pass the value along as is.
1991 			-- 2) First action is 'APUE'/'AP' and second action is 'AP', so pass the value
1992 			-- 	along as is.
1993 			-- 3) First action is 'AP', second action is 'APUE'/'UE'. So, pass the value along as is.
1994 			null;
1995 		else
1996 			-- Any other Proc_Method like NE/NE or NE/AP etc. need not be catered to.
1997 			null;
1998 		end if;
1999 	end if;
2000 
2001 	hr_utility.set_location(' Return Value :' || p_to_field || '+++', 199);
2002 	hr_utility.set_location('Leaving:'|| l_proc, 200);
2003 
2004 EXCEPTION
2005   WHEN others THEN
2006      -- Reset IN OUT parameters and set OUT parameters
2007 
2008       p_to_field := l_to_field;
2009 
2010    hr_utility.set_location('Leaving  ' || l_proc,55);
2011    RAISE;
2012 
2013 END copy_to_new_rg_shared;
2014 
2015    Procedure copy_to_new_rg(
2016 				p_action_num	IN NUMBER,
2017 				p_field_name	IN VARCHAR2,
2018 				p_from_field	IN DATE,
2019 				p_to_field	IN OUT NOCOPY DATE,
2020 				p_fld_nm_copy_from IN VARCHAR2 default null) IS
2021 	l_proc	varchar2(30):= 'copy_to_new_rg(date)';
2022 	l_from_char varchar2(100);
2023 	l_to_char	varchar2(100);
2024 	l_to_field   Date;
2025 
2026 BEGIN
2027 	l_to_field := p_to_field; --NOCOPY Changes
2028 
2029 	hr_utility.set_location('Entering: ' || l_proc, 5);
2030 	l_from_char := to_char(p_from_field,'DDMMYYYY');
2031 	l_to_char := to_char(p_to_field,'DDMMYYYY');
2032 	copy_to_new_rg_shared(	p_action_num		=> p_action_num,
2033 				p_field_name		=> p_field_name,
2034 				p_from_field		=> l_from_char,
2035 				p_to_field		=> l_to_char,
2036 				p_fld_nm_copy_from	=> p_fld_nm_copy_from);
2037 
2038 	p_to_field	:= to_date(l_to_char,'DDMMYYYY');
2039 	hr_utility.set_location('Leaving: ' || l_proc, 35);
2040 
2041 
2042 EXCEPTION
2043   WHEN others THEN
2044      -- Reset IN OUT parameters and set OUT parameters
2045 
2046       p_to_field := l_to_field;
2047 
2048    hr_utility.set_location('Leaving  ' || l_proc,50);
2049    RAISE;
2050 
2051 END;
2052 
2053    Procedure copy_to_new_rg(
2054 				p_action_num	IN NUMBER,
2055 				p_field_name	IN VARCHAR2,
2056 				p_from_field	IN VARCHAR2,
2057 				p_to_field	IN OUT NOCOPY VARCHAR2,
2058 				p_fld_nm_copy_from IN VARCHAR2 default null) IS
2059 
2060 	l_proc	varchar2(30):= 'copy_to_new_rg(char)';
2061 	l_to_field	VARCHAR2(2000);
2062 BEGIN
2063 	l_to_field := p_to_field; --NOCOPY Changes
2064 	hr_utility.set_location('Entering: ' || l_proc, 5);
2065 	copy_to_new_rg_shared(	p_action_num		=> p_action_num,
2066 				p_field_name		=> p_field_name,
2067 				p_from_field		=> p_from_field,
2068 				p_to_field		=> p_to_field,
2069 				p_fld_nm_copy_from	=> p_fld_nm_copy_from);
2070 
2071 	hr_utility.set_location('Leaving: ' || l_proc, 10);
2072 
2073 EXCEPTION
2074   WHEN others THEN
2075      -- Reset IN OUT parameters and set OUT parameters
2076 
2077       p_to_field := l_to_field;
2078 
2079    hr_utility.set_location('Leaving  ' || l_proc,55);
2080    RAISE;
2081 
2082 END;
2083 
2084    Procedure copy_to_new_rg(
2085 				p_action_num	IN NUMBER,
2086 				p_field_name	IN VARCHAR2,
2087 				p_from_field	IN NUMBER,
2088 				p_to_field	IN OUT NOCOPY NUMBER,
2089 				p_fld_nm_copy_from IN VARCHAR2 default null) IS
2090 	l_proc	varchar2(30):= 'copy_to_new_rg(number)';
2091 	l_from_char varchar2(100);
2092 	l_to_char	varchar2(100);
2093 	l_to_field	NUMBER;
2094 BEGIN
2095         l_to_field := p_to_field; --NOCOPY Changes
2096 	hr_utility.set_location('Entering: ' || l_proc, 5);
2097 	l_from_char := to_char(p_from_field);
2098 	l_to_char := to_char(p_to_field);
2099 	copy_to_new_rg_shared(	p_action_num		=> p_action_num,
2100 					p_field_name		=> p_field_name,
2101 					p_from_field		=> l_from_char,
2102 					p_to_field			=> l_to_char,
2103 					p_fld_nm_copy_from	=> p_fld_nm_copy_from);
2104 	p_to_field	:= to_number(l_to_char);
2105 
2106 	hr_utility.set_location('Leaving: ' || l_proc, 35);
2107 
2108 EXCEPTION
2109   WHEN others THEN
2110      -- Reset IN OUT parameters and set OUT parameters
2111 
2112       p_to_field := l_to_field;
2113 
2114    hr_utility.set_location('Leaving  ' || l_proc,56);
2115    RAISE;
2116 END;
2117 
2118 
2119 BEGIN
2120 	l_pa_req :=p_pa_req ; ---NOCOPY Changes
2121 
2122  	hr_utility.set_location('Entering:'|| l_proc, 5);
2123 	hr_utility.set_location(' no. of rows in table rg ' || to_char(l_column_count), 11);
2124 	-- get list of all columns needed for the noa we are correcting.
2125    	initialize_fld_names_table(	p_noa_id  		=> p_pa_req.first_noa_id,
2126 						p_fld_names_tab	=> l_fld_names_tab1);
2127 	l_column_count1	:= l_column_count;
2128    	initialize_fld_names_table(	p_noa_id  		=> p_pa_req.second_noa_id,
2129 						p_fld_names_tab	=> l_fld_names_tab2);
2130 	l_column_count2	:= l_column_count;
2131 
2132 	l_pa_req := p_pa_req;
2133 	-- for all columns, set to null if not needed for the noa we are processing
2134 
2135 -- Lines whih are commented meanss that this column value must be passed irrespective
2136 -- of if it has been defined in proc_methods or not.
2137 -- LINES WITH --? must be revisited. Not sure if we should be ignoring them or what.
2138 -- LINES WITH --* means that column does not have any value. If this sf52 has not been processed
2139 -- LINES WITH --** means that this column must be fetched by this processs before sending it to
2140 -- update to database.
2141 --	be sure to process all from fields first. assign_new_rg depends on these being done before all
2142 --	other columns.
2143 
2144 	copy_to_new_rg(p_action_num,'FROM_BASIC_PAY',p_pa_req.from_basic_pay,l_pa_req.from_basic_pay);
2145 	copy_to_new_rg(p_action_num,'FROM_GRADE_OR_LEVEL',p_pa_req.from_grade_or_level,l_pa_req.from_grade_or_level);
2146 	copy_to_new_rg(p_action_num,'FROM_LOCALITY_ADJ',p_pa_req.from_locality_adj,l_pa_req.from_locality_adj);
2147 	copy_to_new_rg(p_action_num,'FROM_OCC_CODE',p_pa_req.from_occ_code,l_pa_req.from_occ_code);
2148 --*	copy_to_new_rg(p_action_num,'FROM_OFFICE_SYMBOL',p_pa_req.from_office_symbol,l_pa_req.from_office_symbol);
2149 
2150 	copy_to_new_rg(p_action_num,'FROM_OTHER_PAY_AMOUNT',p_pa_req.from_other_pay_amount,l_pa_req.from_other_pay_amount);
2151 
2152 	copy_to_new_rg(p_action_num,'FROM_PAY_BASIS_DESC',p_pa_req.from_pay_basis,l_pa_req.from_pay_basis, 'FROM_PAY_BASIS');
2153 
2154 	copy_to_new_rg(p_action_num,'FROM_PAY_PLAN',p_pa_req.from_pay_plan,l_pa_req.from_pay_plan);
2155 
2156 	copy_to_new_rg(p_action_num,'FROM_POSITION_TITLE',p_pa_req.from_position_title,l_pa_req.from_position_title);
2157 	copy_to_new_rg(p_action_num,'FROM_POSITION_TITLE',p_pa_req.from_position_id,l_pa_req.from_position_id,'FROM_POSITION_ID');
2158 
2159 	copy_to_new_rg(p_action_num,'FROM_POSITION_ORG_LINE1',p_pa_req.from_position_org_line1,l_pa_req.from_position_org_line1);
2160 	copy_to_new_rg(p_action_num,'FROM_POSITION_ORG_LINE2',p_pa_req.from_position_org_line2,l_pa_req.from_position_org_line2);
2161 	copy_to_new_rg(p_action_num,'FROM_POSITION_ORG_LINE3',p_pa_req.from_position_org_line3,l_pa_req.from_position_org_line3);
2162 	copy_to_new_rg(p_action_num,'FROM_POSITION_ORG_LINE4',p_pa_req.from_position_org_line4,l_pa_req.from_position_org_line4);
2163 	copy_to_new_rg(p_action_num,'FROM_POSITION_ORG_LINE5',p_pa_req.from_position_org_line5,l_pa_req.from_position_org_line5);
2164 	copy_to_new_rg(p_action_num,'FROM_POSITION_ORG_LINE6',p_pa_req.from_position_org_line6,l_pa_req.from_position_org_line6);
2165 --	copy_to_new_rg(p_action_num,'FROM_POSITION_LOC3',p_pa_req.from_position_loc3,l_pa_req.from_position_loc3);
2166 
2167 	copy_to_new_rg(p_action_num,'FROM_POSITION_NUMBER',p_pa_req.from_position_number,l_pa_req.from_position_number);
2168 	copy_to_new_rg(p_action_num,'FROM_POSITION_SEQ_NO',p_pa_req.from_position_seq_no,l_pa_req.from_position_seq_no);
2169 	copy_to_new_rg(p_action_num,'FROM_STEP_OR_RATE',p_pa_req.from_step_or_rate,l_pa_req.from_step_or_rate);
2170 	copy_to_new_rg(p_action_num,'FROM_TOTAL_SALARY',p_pa_req.from_total_salary,l_pa_req.from_total_salary);
2171 	copy_to_new_rg(p_action_num,'FROM_ADJ_BASIC_PAY',p_pa_req.from_adj_basic_pay,l_pa_req.from_adj_basic_pay);
2172 --*	copy_to_new_rg(p_action_num,'FROM_AGENCY_CODE',p_pa_req.from_agency_code,l_pa_req.from_agency_code);
2173 --*	copy_to_new_rg(p_action_num,'FROM_AGENCY_DESC',p_pa_req.from_agency_desc,l_pa_req.from_agency_desc);
2174 
2175 
2176 --	copy_to_new_rg(p_action_num,'PA_REQUEST_ID',p_pa_req.pa_request_id,l_pa_req.pa_request_id);
2177 --*	copy_to_new_rg(p_action_num,'PA_NOTIFICATION_ID',p_pa_req.pa_notification_id,l_pa_req.pa_notification_id);
2178 --**	copy_to_new_rg(p_action_num,'NOA_FAMILY_CODE',p_pa_req.noa_family_code,l_pa_req.noa_family_code);
2179 --	copy_to_new_rg(p_action_num,'ROUTING_GROUP_ID',p_pa_req.routing_group_id,l_pa_req.routing_group_id);
2180 --	copy_to_new_rg(p_action_num,'PROPOSED_EFFECTIVE_ASAP_FLAG',p_pa_req.proposed_effective_asap_flag,l_pa_req.proposed_effective_asap_flag);
2181 	copy_to_new_rg(p_action_num,'ACADEMIC_DISCIPLINE',p_pa_req.academic_discipline,l_pa_req.academic_discipline);
2182 --	copy_to_new_rg(p_action_num,'ADDITIONAL_INFO_PERSON_ID',p_pa_req.additional_info_person_id,l_pa_req.additional_info_person_id);
2183 --	copy_to_new_rg(p_action_num,'ADDITIONAL_INFO_TEL_NUMBER',p_pa_req.additional_info_tel_number,l_pa_req.additional_info_tel_number);
2184 --*	copy_to_new_rg(p_action_num,'AGENCY_CODE',p_pa_req.agency_code,l_pa_req.agency_code);
2185 --	copy_to_new_rg(p_action_num,'ALTERED_PA_REQUEST_ID',p_pa_req.altered_pa_request_id,l_pa_req.altered_pa_request_id);
2186 	copy_to_new_rg(p_action_num,'ANNUITANT_INDICATOR',p_pa_req.annuitant_indicator,l_pa_req.annuitant_indicator);
2187 	copy_to_new_rg(p_action_num,'ANNUITANT_INDICATOR_DESC',p_pa_req.annuitant_indicator_desc,l_pa_req.annuitant_indicator_desc);
2188 	copy_to_new_rg(p_action_num,'APPROPRIATION_CODE1',p_pa_req.appropriation_code1,l_pa_req.appropriation_code1);
2189 	copy_to_new_rg(p_action_num,'APPROPRIATION_CODE2',p_pa_req.appropriation_code2,l_pa_req.appropriation_code2);
2190 --*	copy_to_new_rg(p_action_num,'APPROVAL_DATE',p_pa_req.approval_date,l_pa_req.approval_date);
2191 --*	copy_to_new_rg(p_action_num,'APPROVING_OFFICIAL_WORK_TITLE',p_pa_req.approving_official_work_title,l_pa_req.approving_official_work_title);
2192 
2193 --	copy_to_new_rg(p_action_num,'AUTHORIZED_BY_PERSON_ID',p_pa_req.authorized_by_person_id,l_pa_req.authorized_by_person_id);
2194 --	copy_to_new_rg(p_action_num,'AUTHORIZED_BY_TITLE',p_pa_req.authorized_by_title,l_pa_req.authorized_by_title);
2195 	copy_to_new_rg(p_action_num,'AWARD_AMOUNT',p_pa_req.award_amount,l_pa_req.award_amount);
2196 	copy_to_new_rg(p_action_num,'AWARD_UOM',p_pa_req.award_uom,l_pa_req.award_uom);
2197 	copy_to_new_rg(p_action_num,'BARGAINING_UNIT_STATUS',p_pa_req.bargaining_unit_status,l_pa_req.bargaining_unit_status);
2198 	copy_to_new_rg(p_action_num,'CITIZENSHIP',p_pa_req.citizenship,l_pa_req.citizenship);
2199 --	copy_to_new_rg(p_action_num,'CONCURRENCE_DATE',p_pa_req.concurrence_date,l_pa_req.concurrence_date);
2200 	copy_to_new_rg(p_action_num,'DUTY_STATION_CODE',p_pa_req.duty_station_code,l_pa_req.duty_station_code);
2201 	copy_to_new_rg(p_action_num,'DUTY_STATION_DESC',p_pa_req.duty_station_desc,l_pa_req.duty_station_desc);
2202 	-- Copied on the basis of DUTY_STATION_DESC
2203 	copy_to_new_rg(p_action_num,'DUTY_STATION_DESC',p_pa_req.duty_station_id,l_pa_req.duty_station_id,'DUTY_STATION_ID');
2204 	copy_to_new_rg(p_action_num,'DUTY_STATION_DESC',p_pa_req.duty_station_location_id,l_pa_req.duty_station_location_id,'DUTY_STATION_LOCATION_ID');
2205 	copy_to_new_rg(p_action_num,'EDUCATION_LEVEL',p_pa_req.education_level,l_pa_req.education_level);
2206 
2207 --	copy_to_new_rg(p_action_num,'EFFECTIVE_DATE',p_pa_req.effective_date,l_pa_req.effective_date);
2208 --	copy_to_new_rg(p_action_num,'EMPLOYEE_ASSIGNMENT_ID',p_pa_req.employee_assignment_id,l_pa_req.employee_assignment_id)
2209 
2210 	copy_to_new_rg(p_action_num,'EMPLOYEE_DATE_OF_BIRTH',p_pa_req.employee_date_of_birth,l_pa_req.employee_date_of_birth);
2211 --*	copy_to_new_rg(p_action_num,'EMPLOYEE_DEPT_OR_AGENCY',p_pa_req.employee_dept_or_agency,l_pa_req.employee_dept_or_agency);
2212 	copy_to_new_rg(p_action_num,'EMPLOYEE_FIRST_NAME',p_pa_req.employee_first_name,l_pa_req.employee_first_name);
2213 --	copy_to_new_rg(p_action_num,'EMPLOYEE_LAST_NAME',p_pa_req.employee_last_name,l_pa_req.employee_last_name);
2214 	copy_to_new_rg(p_action_num,'EMPLOYEE_MIDDLE_NAMES',p_pa_req.employee_middle_names,l_pa_req.employee_middle_names);
2215 --	copy_to_new_rg(p_action_num,'EMPLOYEE_NATIONAL_IDENTIFIER',p_pa_req.employee_national_identifier,l_pa_req.employee_national_identifier);
2216 	copy_to_new_rg(p_action_num,'FEGLI',p_pa_req.fegli,l_pa_req.fegli);
2217 	copy_to_new_rg(p_action_num,'FEGLI_DESC',p_pa_req.fegli_desc,l_pa_req.fegli_desc);
2218 	copy_to_new_rg(p_action_num,'FLSA_CATEGORY',p_pa_req.flsa_category,l_pa_req.flsa_category);
2219 -- Can modify the code to copy all the address lines if address_line1 is copied
2220 	copy_to_new_rg(p_action_num,'FORWARDING_ADDRESS_LINE1',p_pa_req.forwarding_address_line1,l_pa_req.forwarding_address_line1);
2221 	copy_to_new_rg(p_action_num,'FORWARDING_ADDRESS_LINE2',p_pa_req.forwarding_address_line2,l_pa_req.forwarding_address_line2);
2222 	copy_to_new_rg(p_action_num,'FORWARDING_ADDRESS_LINE3',p_pa_req.forwarding_address_line3,l_pa_req.forwarding_address_line3);
2223 
2224 	copy_to_new_rg(p_action_num,'FORWARDING_COUNTRY_SHORT_NAME',p_pa_req.forwarding_country,l_pa_req.forwarding_country,'FORWARDING_COUNTRY');
2225 	copy_to_new_rg(p_action_num,'FORWARDING_COUNTRY_SHORT_NAME',p_pa_req.forwarding_country_short_name,l_pa_req.forwarding_country_short_name);
2226 	copy_to_new_rg(p_action_num,'FORWARDING_POSTAL_CODE',p_pa_req.forwarding_postal_code,l_pa_req.forwarding_postal_code);
2227 	copy_to_new_rg(p_action_num,'FORWARDING_REGION_2',p_pa_req.forwarding_region_2,l_pa_req.forwarding_region_2);
2228 	copy_to_new_rg(p_action_num,'FORWARDING_TOWN_OR_CITY',p_pa_req.forwarding_town_or_city,l_pa_req.forwarding_town_or_city);
2229 
2230 	copy_to_new_rg(p_action_num,'FUNCTIONAL_CLASS',p_pa_req.functional_class,l_pa_req.functional_class);
2231 --	copy_to_new_rg(p_action_num,'NOTEPAD',p_pa_req.notepad,l_pa_req.notepad);
2232 	copy_to_new_rg(p_action_num,'PART_TIME_HOURS',p_pa_req.part_time_hours,l_pa_req.part_time_hours);
2233 	copy_to_new_rg(p_action_num,'PAY_RATE_DETERMINANT',p_pa_req.pay_rate_determinant,l_pa_req.pay_rate_determinant);
2234 --*	copy_to_new_rg(p_action_num,'PERSONNEL_OFFICE_ID',p_pa_req.personnel_office_id,l_pa_req.personnel_office_id);
2235 --	copy_to_new_rg(p_action_num,'PERSON_ID',p_pa_req.person_id,l_pa_req.person_id);
2236 	copy_to_new_rg(p_action_num,'POSITION_OCCUPIED',p_pa_req.position_occupied,l_pa_req.position_occupied);
2237 --	copy_to_new_rg(p_action_num,'PROPOSED_EFFECTIVE_DATE',p_pa_req.proposed_effective_date,l_pa_req.proposed_effective_date);
2238 
2239 --	copy_to_new_rg(p_action_num,'REQUESTED_BY_PERSON_ID',p_pa_req.requested_by_person_id,l_pa_req.requested_by_person_id);
2240 
2241 --	copy_to_new_rg(p_action_num,'REQUESTED_BY_TITLE',p_pa_req.requested_by_title,l_pa_req.requested_by_title);
2242 
2243 --	copy_to_new_rg(p_action_num,'REQUESTED_DATE',p_pa_req.requested_date,l_pa_req.requested_date);
2244 
2245 --	copy_to_new_rg(p_action_num,'REQUESTING_OFFICE_REMARKS_DESC',p_pa_req.requesting_office_remarks_desc,l_pa_req.requesting_office_remarks_desc);
2246 
2247 	copy_to_new_rg(p_action_num,'REQUESTING_OFFICE_REMARKS_FLAG',p_pa_req.requesting_office_remarks_flag,l_pa_req.requesting_office_remarks_flag);
2248 --	copy_to_new_rg(p_action_num,'REQUEST_NUMBER',p_pa_req.request_number,l_pa_req.request_number);
2249 
2250 	copy_to_new_rg(p_action_num,'RESIGN_AND_RETIRE_REASON_DESC',p_pa_req.resign_and_retire_reason_desc,l_pa_req.resign_and_retire_reason_desc);
2251 	copy_to_new_rg(p_action_num,'RETIREMENT_PLAN',p_pa_req.retirement_plan,l_pa_req.retirement_plan);
2252 
2253 	copy_to_new_rg(p_action_num,'RETIREMENT_PLAN_DESC',p_pa_req.retirement_plan_desc,l_pa_req.retirement_plan_desc);
2254 
2255 	copy_to_new_rg(p_action_num,'SERVICE_COMP_DATE',p_pa_req.service_comp_date,l_pa_req.service_comp_date);
2256 
2257 	copy_to_new_rg(p_action_num,'SUPERVISORY_STATUS',p_pa_req.supervisory_status,l_pa_req.supervisory_status);
2258 
2259 	copy_to_new_rg(p_action_num,'TENURE',p_pa_req.tenure,l_pa_req.tenure);
2260 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_adj_basic_pay,l_pa_req.to_adj_basic_pay, 'TO_ADJ_BASIC_PAY');
2261 
2262 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_basic_pay,l_pa_req.to_basic_pay,'TO_BASIC_PAY');
2263 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_locality_adj,l_pa_req.to_locality_adj,'TO_LOCALITY_ADJ');
2264 
2265 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_occ_code,l_pa_req.to_occ_code,'TO_OCC_CODE');
2266 --*	copy_to_new_rg(p_action_num,'TO_OFFICE_SYMBOL',p_pa_req.to_office_symbol,l_pa_req.to_office_symbol);
2267 
2268 --	copy_to_new_rg(p_action_num,'TO_ORGANIZATION_NAME',p_pa_req.to_organization_id,l_pa_req.to_organization_id);
2269 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_position_org_line1,l_pa_req.to_position_org_line1,'TO_POSITION_ORG_LINE1');
2270 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_position_org_line2,l_pa_req.to_position_org_line2,'TO_POSITION_ORG_LINE2');
2271 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_position_org_line3,l_pa_req.to_position_org_line3,'TO_POSITION_ORG_LINE3');
2272 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_position_org_line4,l_pa_req.to_position_org_line4,'TO_POSITION_ORG_LINE4');
2273 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_position_org_line5,l_pa_req.to_position_org_line5,'TO_POSITION_ORG_LINE5');
2274 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_position_org_line6,l_pa_req.to_position_org_line6,'TO_POSITION_ORG_LINE6');
2275 
2276 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_pay_basis,l_pa_req.to_pay_basis, 'TO_PAY_BASIS');
2277 
2278 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_pay_plan,l_pa_req.to_pay_plan,'TO_PAY_PLAN');
2279 	/* if TO_POSITION_TITLE exists, then the following fields should be copied */
2280 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_position_title,l_pa_req.to_position_title);
2281 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_position_id,l_pa_req.to_position_id,'TO_POSITION_ID');
2282 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_grade_id,l_pa_req.to_grade_id,'TO_GRADE_ID');
2283 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_job_id,l_pa_req.to_job_id,'TO_JOB_ID');
2284 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_organization_id,l_pa_req.to_organization_id,'TO_ORGANIZATION_ID');
2285 --	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_location_id,l_pa_req.to_location_id,'TO_LOCATION_ID');
2286 	/* end of fields dependent on TO_POSITION_TITLE */
2287 
2288 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_grade_or_level,l_pa_req.to_grade_or_level,'TO_GRADE_OR_LEVEL');
2289 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_position_number,l_pa_req.to_position_number,'TO_POSITION_NUMBER');
2290 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_position_seq_no,l_pa_req.to_position_seq_no,'TO_POSITION_SEQ_NO');
2291 	copy_to_new_rg(p_action_num,'TO_STEP_OR_RATE',p_pa_req.to_step_or_rate,l_pa_req.to_step_or_rate);
2292 	copy_to_new_rg(p_action_num,'TO_POSITION_TITLE',p_pa_req.to_total_salary,l_pa_req.to_total_salary,'TO_TOTAL_SALARY');
2293 
2294 	copy_to_new_rg(p_action_num,'VETERANS_PREFERENCE',p_pa_req.veterans_preference,l_pa_req.veterans_preference);
2295 
2296 	copy_to_new_rg(p_action_num,'VETERANS_PREF_FOR_RIF_DESC',p_pa_req.veterans_pref_for_rif,l_pa_req.veterans_pref_for_rif,'VETERANS_PREF_FOR_RIF');
2297 	copy_to_new_rg(p_action_num,'VETERANS_STATUS',p_pa_req.veterans_status,l_pa_req.veterans_status);
2298 	copy_to_new_rg(p_action_num,'WORK_SCHEDULE',p_pa_req.work_schedule,l_pa_req.work_schedule);
2299  	copy_to_new_rg(p_action_num,'WORK_SCHEDULE_DESC',p_pa_req.work_schedule_desc,l_pa_req.work_schedule_desc);
2300 	copy_to_new_rg(p_action_num,'YEAR_DEGREE_ATTAINED',p_pa_req.year_degree_attained,l_pa_req.year_degree_attained);
2301 /*	All of the follwing will be passed irrespective of NOA.
2302 
2303 	copy_to_new_rg(p_action_num,'ATTRIBUTE_CATEGORY',p_pa_req.attribute_category,l_pa_req.attribute_category);
2304 	copy_to_new_rg(p_action_num,'ATTRIBUTE1',p_pa_req.attribute1,l_pa_req.attribute1);
2305 	copy_to_new_rg(p_action_num,'ATTRIBUTE2',p_pa_req.attribute2,l_pa_req.attribute2);
2306 	copy_to_new_rg(p_action_num,'ATTRIBUTE3',p_pa_req.attribute3,l_pa_req.attribute3);
2307 	copy_to_new_rg(p_action_num,'ATTRIBUTE4',p_pa_req.attribute4,l_pa_req.attribute4);
2308 	copy_to_new_rg(p_action_num,'ATTRIBUTE5',p_pa_req.attribute5,l_pa_req.attribute5);
2309 	copy_to_new_rg(p_action_num,'ATTRIBUTE6',p_pa_req.attribute6,l_pa_req.attribute6);
2310 	copy_to_new_rg(p_action_num,'ATTRIBUTE7',p_pa_req.attribute7,l_pa_req.attribute7);
2311 	copy_to_new_rg(p_action_num,'ATTRIBUTE8',p_pa_req.attribute8,l_pa_req.attribute8);
2312 	copy_to_new_rg(p_action_num,'ATTRIBUTE9',p_pa_req.attribute9,l_pa_req.attribute9);
2313 	copy_to_new_rg(p_action_num,'ATTRIBUTE10',p_pa_req.attribute10,l_pa_req.attribute10);
2314 	copy_to_new_rg(p_action_num,'ATTRIBUTE11',p_pa_req.attribute11,l_pa_req.attribute11);
2315 	copy_to_new_rg(p_action_num,'ATTRIBUTE12',p_pa_req.attribute12,l_pa_req.attribute12);
2316 	copy_to_new_rg(p_action_num,'ATTRIBUTE13',p_pa_req.attribute13,l_pa_req.attribute13);
2317 	copy_to_new_rg(p_action_num,'ATTRIBUTE14',p_pa_req.attribute14,l_pa_req.attribute14);
2318 	copy_to_new_rg(p_action_num,'ATTRIBUTE15',p_pa_req.attribute15,l_pa_req.attribute15);
2319 	copy_to_new_rg(p_action_num,'ATTRIBUTE16',p_pa_req.attribute16,l_pa_req.attribute16);
2320 	copy_to_new_rg(p_action_num,'ATTRIBUTE17',p_pa_req.attribute17,l_pa_req.attribute17);
2321 	copy_to_new_rg(p_action_num,'ATTRIBUTE18',p_pa_req.attribute18,l_pa_req.attribute18);
2322 	copy_to_new_rg(p_action_num,'ATTRIBUTE19',p_pa_req.attribute19,l_pa_req.attribute19);
2323 	copy_to_new_rg(p_action_num,'ATTRIBUTE20',p_pa_req.attribute20,l_pa_req.attribute20);
2324 */
2325 	-- all the following fields should be based on to_other_pay_amount field.
2326 	copy_to_new_rg(p_action_num,'TO_OTHER_PAY_AMOUNT',p_pa_req.to_other_pay_amount,l_pa_req.to_other_pay_amount);
2327 	copy_to_new_rg(p_action_num,'TO_OTHER_PAY_AMOUNT',p_pa_req.to_au_overtime,l_pa_req.to_au_overtime,'TO_AU_OVERTIME');
2328 	copy_to_new_rg(p_action_num,'TO_OTHER_PAY_AMOUNT',p_pa_req.to_auo_premium_pay_indicator,l_pa_req.to_auo_premium_pay_indicator,'TO_AUO_PREMIUM_PAY_INDICATOR');
2329 	copy_to_new_rg(p_action_num,'TO_OTHER_PAY_AMOUNT',p_pa_req.to_availability_pay,l_pa_req.to_availability_pay,'TO_AVAILABILITY_PAY');
2330 	copy_to_new_rg(p_action_num,'TO_OTHER_PAY_AMOUNT',p_pa_req.to_ap_premium_pay_indicator,l_pa_req.to_ap_premium_pay_indicator,'TO_AP_PREMIUM_PAY_INDICATOR');
2331 	copy_to_new_rg(p_action_num,'TO_OTHER_PAY_AMOUNT',p_pa_req.to_retention_allowance,l_pa_req.to_retention_allowance,'TO_RETENTION_ALLOWANCE');
2332 	copy_to_new_rg(p_action_num,'TO_OTHER_PAY_AMOUNT',p_pa_req.to_retention_allow_percentage,l_pa_req.to_retention_allow_percentage,'TO_RETENTION_ALLOW_PERCENTAGE');
2333 	copy_to_new_rg(p_action_num,'TO_OTHER_PAY_AMOUNT',p_pa_req.to_supervisory_differential,l_pa_req.to_supervisory_differential,'TO_SUPERVISORY_DIFFERENTIAL');
2334 	copy_to_new_rg(p_action_num,'TO_OTHER_PAY_AMOUNT',p_pa_req.to_supervisory_diff_percentage,l_pa_req.to_supervisory_diff_percentage,'TO_SUPERVISORY_DIFF_PERCENTAGE');
2335 	copy_to_new_rg(p_action_num,'TO_OTHER_PAY_AMOUNT',p_pa_req.to_staffing_differential,l_pa_req.to_staffing_differential,'TO_STAFFING_DIFFERENTIAL');
2336 	copy_to_new_rg(p_action_num,'TO_OTHER_PAY_AMOUNT',p_pa_req.to_staffing_diff_percentage,l_pa_req.to_staffing_diff_PERCENTAGE,'TO_STAFFING_DIFF_PERCENTAGE');
2337 
2338 
2339 --	copy_to_new_rg(p_action_num,'CUSTOM_PAY_CALC_FLAG',p_pa_req.custom_pay_calc_flag,l_pa_req.custom_pay_calc_flag);
2340 	if (p_action_num = 2) then
2341 		hr_utility.set_location('Correcting second action'|| l_proc, 10);
2342 		-- if we are correcting the second action of a dual action, then copy all second noa columns into
2343 		-- corresponding first noa columns
2344 		copy_2ndNoa_to_1stNoa(l_pa_req);
2345 	end if;
2346 	-- null out second noa columns
2347 	null_2ndNoa_cols(l_pa_req);
2348 	p_pa_req := l_pa_req;
2349 
2350 	hr_utility.set_location('Leaving:'|| l_proc, 15);
2351 
2352 EXCEPTION
2353   WHEN others THEN
2354      -- Reset IN OUT parameters and set OUT parameters
2355 
2356       p_pa_req := l_pa_req;
2357 
2358    hr_utility.set_location('Leaving  ' || l_proc,60);
2359    RAISE;
2360 
2361 END assign_new_rg;
2362 
2363 -- ---------------------------------------------------------------------------
2364 -- |--------------------------< copy_2ndNoa_to_1stNoa>------------------------|
2365 -- ---------------------------------------------------------------------------
2366 -- {Start Of Comments}
2367 --
2368 -- Description:
2369 --	Copies second noa columns to first noa columns. This is needed to facilitate
2370 --	the design of always processing both actions of a dual action as if
2371 --	each is the first action (i.e. - we pass it to update to database as if
2372 --	it is the first action, regardless of whether or not it is the first or second
2373 --	action).
2374 --
2375 -- Pre-Requisities:
2376 --   	None.
2377 --
2378 -- In Parameters:
2379 --	p_pa_req		->		pa_request record is passed here. It is also returned here after
2380 --						it has been modified.
2381 --
2382 -- Post Success:
2383 -- 	All the second noa columns will have been copied to the corresponding first noa columns.
2384 --
2385 -- Post Failure:
2386 --   No Failure conditions.
2387 --
2388 -- Developer Implementation Notes:
2389 --	None.
2390 --
2391 -- Access Status:
2392 --   Internal Development Use Only.
2393 --
2394 -- {End Of Comments}
2395 -- ---------------------------------------------------------------------------
2396 
2397 PROCEDURE copy_2ndNoa_to_1stNoa (p_pa_req		in out 	nocopy ghr_pa_requests%rowtype) IS
2398 	l_proc	varchar2(30):='copy_2ndNoa_to_1stNoa';
2399 	l_pa_req	ghr_pa_requests%rowtype;
2400 
2401 BEGIN
2402 	l_pa_req :=p_pa_req ; ---NOCOPY Changes
2403 
2404 	hr_utility.set_location('Entering:'|| l_proc, 5);
2405 	p_pa_req.first_action_la_code1 	:= p_pa_req.second_action_la_code1;
2406 	p_pa_req.first_action_la_code2	:= p_pa_req.second_action_la_code2;
2407 	p_pa_req.first_action_la_desc1	:= p_pa_req.second_action_la_desc1;
2408 	p_pa_req.first_action_la_desc2	:= p_pa_req.second_action_la_desc2;
2409 	p_pa_req.first_noa_cancel_or_correct:= p_pa_req.second_noa_cancel_or_correct;
2410 	p_pa_req.first_noa_code			:= p_pa_req.second_noa_code;
2411 	p_pa_req.first_noa_desc			:= p_pa_req.second_noa_desc;
2412 	p_pa_req.first_noa_id			:= p_pa_req.second_noa_id;
2413 	p_pa_req.first_noa_pa_request_id	:= p_pa_req.second_noa_pa_request_id;
2414 	p_pa_req.first_noa_information1	:= p_pa_req.second_noa_information1;
2415 	p_pa_req.first_noa_information2	:= p_pa_req.second_noa_information2;
2416 	p_pa_req.first_noa_information3	:= p_pa_req.second_noa_information3;
2417 	p_pa_req.first_noa_information4	:= p_pa_req.second_noa_information4;
2418 	p_pa_req.first_noa_information5	:= p_pa_req.second_noa_information5;
2419 	p_pa_req.first_lac1_information1	:= p_pa_req.second_lac1_information1;
2420 	p_pa_req.first_lac1_information2	:= p_pa_req.second_lac1_information2;
2421 	p_pa_req.first_lac1_information3	:= p_pa_req.second_lac1_information3;
2422 	p_pa_req.first_lac1_information4	:= p_pa_req.second_lac1_information4;
2423 	p_pa_req.first_lac1_information5	:= p_pa_req.second_lac1_information5;
2424 	p_pa_req.first_lac2_information1	:= p_pa_req.second_lac2_information1;
2425 	p_pa_req.first_lac2_information2	:= p_pa_req.second_lac2_information2;
2426 	p_pa_req.first_lac2_information3	:= p_pa_req.second_lac2_information3;
2427 	p_pa_req.first_lac2_information4	:= p_pa_req.second_lac2_information4;
2428 	p_pa_req.first_lac2_information5	:= p_pa_req.second_lac2_information5;
2429 	hr_utility.set_location('Leaving:'|| l_proc, 10);
2430 
2431 EXCEPTION
2432   WHEN others THEN
2433      -- Reset IN OUT parameters and set OUT parameters
2434 
2435       p_pa_req := l_pa_req;
2436 
2437    hr_utility.set_location('Leaving  ' || l_proc,65);
2438    RAISE;
2439 END copy_2ndNoa_to_1stNoa;
2440 
2441 -- ---------------------------------------------------------------------------
2442 -- |--------------------------< null_2ndNoa_cols>-----------------------------|
2443 -- ---------------------------------------------------------------------------
2444 -- {Start Of Comments}
2445 --
2446 -- Description:
2447 --	Nulls out second noa columns.
2448 --
2449 -- Pre-Requisities:
2450 --   	None.
2451 --
2452 -- In Parameters:
2453 --	p_pa_req		->		pa_request record is passed here. It is also returned here after
2454 --						it has been modified.
2455 --
2456 -- Post Success:
2457 -- 	All the second noa columns will have been nulled.
2458 --
2459 -- Post Failure:
2460 --   No Failure conditions.
2461 --
2462 -- Developer Implementation Notes:
2463 --	None.
2464 --
2465 -- Access Status:
2466 --   Internal Development Use Only.
2467 --
2468 -- {End Of Comments}
2469 -- ---------------------------------------------------------------------------
2470 
2471 PROCEDURE	null_2ndNoa_cols(p_pa_req	in out	nocopy ghr_pa_requests%rowtype) IS
2472 	l_proc	varchar2(30):='null_2ndNoa_cols';
2473 	l_pa_req	ghr_pa_requests%rowtype;
2474 
2475 BEGIN
2476 	l_pa_req :=p_pa_req ; ---NOCOPY Changes
2477 
2478 	hr_utility.set_location('Entering:'|| l_proc, 5);
2479 	-- set all second noa columns to null.
2480 	p_pa_req.second_action_la_code1		:= null;
2481  	p_pa_req.second_action_la_code2		:= null;
2482 	p_pa_req.second_action_la_desc1		:= null;
2483 	p_pa_req.second_action_la_desc2		:= null;
2484 	p_pa_req.second_noa_cancel_or_correct	:= null;
2485 	p_pa_req.second_noa_code			:= null;
2486 	p_pa_req.second_noa_desc			:= null;
2487 	p_pa_req.second_noa_id				:= null;
2488 	p_pa_req.second_noa_pa_request_id		:= null;
2489 	p_pa_req.second_noa_information1		:= null;
2490 	p_pa_req.second_noa_information2		:= null;
2491 	p_pa_req.second_noa_information3		:= null;
2492 	p_pa_req.second_noa_information4		:= null;
2493 	p_pa_req.second_noa_information5		:= null;
2494 	p_pa_req.second_lac1_information1		:= null;
2495 	p_pa_req.second_lac1_information2		:= null;
2496 	p_pa_req.second_lac1_information3		:= null;
2497 	p_pa_req.second_lac1_information4		:= null;
2498 	p_pa_req.second_lac1_information5		:= null;
2499 	p_pa_req.second_lac2_information1		:= null;
2500 	p_pa_req.second_lac2_information2		:= null;
2501 	p_pa_req.second_lac2_information3		:= null;
2502 	p_pa_req.second_lac2_information4		:= null;
2503 	p_pa_req.second_lac2_information5		:= null;
2504 	hr_utility.set_location('Leaving:'|| l_proc, 10);
2505 
2506 EXCEPTION
2507   WHEN others THEN
2508      -- Reset IN OUT parameters and set OUT parameters
2509 
2510       p_pa_req := l_pa_req;
2511 
2512    hr_utility.set_location('Leaving  ' || l_proc,70);
2513    RAISE;
2514 
2515 END null_2ndNoa_cols;
2516 
2517 -- ---------------------------------------------------------------------------
2518 -- |--------------------------< get_family_code>------------------------------|
2519 -- ---------------------------------------------------------------------------
2520 -- {Start Of Comments}
2521 --
2522 -- Description:
2523 --	gets the noa_family_code for the noa_id passed.
2524 --
2525 -- Pre-Requisities:
2526 --   	None.
2527 --
2528 -- In Parameters:
2529 --	p_noa_id		->		noa_id to get noa_family_code for.
2530 --	p_noa_family_code	->		noa_family_code returned here.
2531 --
2532 -- Post Success:
2533 -- 	the noa_family_code will have been populated into p_noa_family_code.
2534 --
2535 -- Post Failure:
2536 --   No Failure conditions.
2537 --
2538 -- Developer Implementation Notes:
2539 --	None.
2540 --
2541 -- Access Status:
2542 --   Internal Development Use Only.
2543 --
2544 -- {End Of Comments}
2545 -- ---------------------------------------------------------------------------
2546 Procedure get_Family_code (
2547 		p_noa_id		in 	number,
2548 		p_noa_family_code	out	nocopy varchar2
2549 		) is
2550 
2551 	cursor c_fam (c_noa_id number) is
2552 	select
2553 		fams.noa_family_code
2554 	from  ghr_noa_families noafam,
2555 		ghr_families     fams
2556 	where noafam.nature_of_action_id = c_noa_id               and
2557 		noafam.enabled_flag        = 'Y'                    and
2558 		fams.noa_family_code 	   = noafam.noa_family_code and
2559 		fams.enabled_flag          = 'Y'                    and
2560 		fams.update_hr_flag = 'Y';
2561 
2562 	l_proc	varchar2(30):='get_family_code';
2563 Begin
2564 
2565 	hr_utility.set_location( 'entering : ' || l_proc, 10);
2566 	open c_fam (p_noa_id);
2567 	fetch c_fam into p_noa_family_code;
2568 	close c_fam;
2569 	hr_utility.set_location( 'leaving : ' || l_proc, 20);
2570 
2571 EXCEPTION
2572   WHEN others THEN
2573      -- Reset IN OUT parameters and set OUT parameters
2574 
2575       p_noa_family_code := NULL;
2576 
2577    hr_utility.set_location('Leaving  ' || l_proc,75);
2578    RAISE;
2579 
2580 End;
2581 
2582 -- ---------------------------------------------------------------------------
2583 -- |--------------------------< proc_futr_act>--------------------------------|
2584 -- ---------------------------------------------------------------------------
2585 -- {Start Of Comments}
2586 --
2587 -- Description:
2588 --	gets the noa_family_code for the noa_id passed.
2589 --
2590 -- Pre-Requisities:
2591 --   	None.
2592 --
2593 -- In Parameters:
2594 --	errbuf		->		noa_id to get noa_family_code for.
2595 --	p_noa_family_code	->		noa_family_code returned here.
2596 --
2597 -- Post Success:
2598 -- 	the noa_family_code will have been populated into p_noa_family_code.
2599 --
2600 -- Post Failure:
2601 --   No Failure conditions.
2602 --
2603 -- Developer Implementation Notes:
2604 --	None.
2605 --
2606 -- Access Status:
2607 --   Internal Development Use Only.
2608 --
2609 -- {End Of Comments}
2610 --
2611 -- Added a new parameter POI as of 17-FEB-03.
2612 -- ---------------------------------------------------------------------------
2613 
2614 Procedure Proc_Futr_Act(
2615        errbuf         out  nocopy   varchar2,
2616        retcode        out  nocopy   number,
2617        p_poi          in ghr_pois.personnel_office_id%type) is
2618 
2619    l_log_text	varchar2(2000);
2620    l_error	varchar2(512); --512
2621    l_req	varchar2(10);
2622    l_sf52_rec	ghr_pa_requests%rowtype;
2623    l_result	varchar2(30);
2624 
2625    l_retcode		Number;
2626    l_calculated		Boolean;
2627    l_error_message	Varchar2(2000);
2628    l_proc		varchar2(30):='Proc_Futr_Act';
2629    l_route_flag         boolean := TRUE;
2630    l_person_id          Number;
2631    l_effective_date     Date;
2632    l_pa_request_id      Number;
2633    l_new_line           varchar2(1) := substr('',1,1);
2634 
2635 
2636 
2637 
2638 ----If p_poi is passed then use the following modified SQL.
2639 
2640        cursor  c_par_pend_per_poi is
2641        select  person_id,effective_date
2642        from    ghr_pa_requests a, ghr_pa_routing_history b
2643        where   effective_date <= sysdate
2644        and     pa_notification_id is null
2645        and     approval_date is not null
2646        and     a.pa_request_id = b.pa_request_id
2647        and     p_poi   =
2648                (select POEI_INFORMATION3 from per_position_extra_info
2649                 where information_type = 'GHR_US_POS_GRP1'
2650                 and   position_id = nvl(a.to_position_id,a.from_position_id))
2651        and     action_taken    = 'FUTURE_ACTION'
2652          and     exists
2653                 (select 1
2654                  from per_people_f per
2655                  where per.person_id = a.person_id
2656                  and a.effective_date between
2657                  per.effective_start_date and per.effective_end_date )
2658       and     b.pa_routing_history_id = (select max(pa_routing_history_id)
2659                                           from ghr_pa_routing_history
2660                                           where pa_request_id = a.pa_request_id)
2661        group by person_id,effective_date
2662        order by 2,1;
2663 
2664 
2665 ----If p_poi is null then use the following original SQL.
2666 
2667        cursor  c_par_pend_per is
2668 ---------Added as part of fix for the bug 2180343
2669        select  person_id,effective_date
2670        from    ghr_pa_requests a, ghr_pa_routing_history b
2671        where   effective_date <= sysdate
2672        and     pa_notification_id is null
2673        and     approval_date is not null
2674        and     a.pa_request_id = b.pa_request_id
2675        and     action_taken    = 'FUTURE_ACTION'
2676          and     exists
2677                 (select 1
2678                  from per_people_f per
2679                  where per.person_id = a.person_id
2680                  and a.effective_date between
2681                  per.effective_start_date and per.effective_end_date )
2682       and     b.pa_routing_history_id = (select max(pa_routing_history_id)
2683                                           from ghr_pa_routing_history
2684                                           where pa_request_id = a.pa_request_id)
2685        group by person_id,effective_date
2686        order by 2,1;
2687 
2688 /*********** Commented out as part of fix 2180343  ***** AVR
2689        select  distinct person_id,effective_date
2690        from ghr_pa_requests a
2691        where effective_date <=  sysdate and
2692                 pa_notification_id is null and
2693                 approval_date is not null and
2694                 exists  (select 'exists'
2695                          from ghr_pa_routing_history
2696                          where pa_routing_history_id = (select max(pa_routing_history_id)
2697                                                         from ghr_pa_routing_history
2698                                                         where pa_request_id = a.pa_request_id)
2699                                                         and action_taken in ('FUTURE_ACTION'))
2700         order by 2,1;
2701 
2702 	cursor	c_get_par_id is
2703 	select  pa_request_id ,noa.order_of_processing
2704 	from   ghr_pa_requests a, ghr_nature_of_actions noa
2705 	where  person_id      =  l_person_id
2706       and    effective_date =  l_effective_date
2707       and    pa_notification_id is null
2708       and    approval_date is not null
2709       and    noa.code  = a.first_noa_code
2710       and    exists	(select 'exists'
2711 				from ghr_pa_routing_history
2712 				where pa_routing_history_id = (select max(pa_routing_history_id)
2713 									from ghr_pa_routing_history
2714 									where pa_request_id = a.pa_request_id)
2715 					and action_taken in ('FUTURE_ACTION'))
2716 	order by 2 asc;
2717 
2718 
2719       Cursor  get_req is
2720         select * from ghr_pa_requests
2721         where  pa_request_id = l_pa_request_id;
2722 ***********/
2723 
2724 
2725       Cursor cur_sessionid is
2726         select userenv('sessionid') sesid  from dual;
2727 
2728       l_sid           number;
2729 ----
2730 ---- Inserted a new procedure sub_proc_futr_sf52.
2731 ----
2732 
2733 ---Local Procedure.
2734  PROCEDURE  sub_proc_futr_sf52 is
2735    cursor   c_get_par_id is
2736    select  pa_request_id ,noa.order_of_processing
2737    from   ghr_pa_requests a, ghr_nature_of_actions noa
2738    where  person_id      =  l_person_id
2739    and    effective_date =  l_effective_date
2740    and    pa_notification_id is null
2741    and    approval_date is not null
2742    and    noa.code  = a.first_noa_code
2743    and    exists  (select 'exists'
2744           from ghr_pa_routing_history
2745           where pa_routing_history_id = (select max(pa_routing_history_id)
2746                                          from ghr_pa_routing_history
2747                                          where pa_request_id = a.pa_request_id)
2748    and action_taken in ('FUTURE_ACTION'))
2749    order by 2 asc;
2750 
2751 
2752    Cursor  get_req is
2753    select * from ghr_pa_requests
2754    where  pa_request_id = l_pa_request_id;
2755 
2756    l_rec             get_req%rowtype;
2757 
2758  -- Start of Bug 3602261
2759 
2760    l_object_version_number      ghr_pa_requests.object_version_number%type;
2761 
2762    Cursor c_ovn (p_pa_request_id ghr_pa_requests.pa_request_id%type)  is        -- 3769917
2763      select par.object_version_number
2764      from   ghr_pa_requests par
2765      where  par.pa_request_id = p_pa_request_id;           -- 3769917
2766 
2767 -- End of Bug 3602261
2768 --Bug # 9329643
2769 l_employee_number  per_people_f.employee_number%type;
2770 
2771 
2772  BEGIN
2773         for get_par_id in c_get_par_id loop
2774           l_pa_request_id  :=  get_par_id.pa_request_id ;
2775           hr_utility.set_location('par id ' || l_pa_request_id,3);
2776 
2777         for get_request in get_req loop
2778             hr_utility.set_location('par_id ' || l_pa_request_id,2);
2779           l_rec :=  get_request;
2780             hr_utility.set_location('l_rec ' || l_rec.first_noa_code,3);
2781 
2782 		    l_sf52_rec := l_rec;
2783 		    --Bug # 9329643
2784 		l_employee_number := ghr_pa_requests_pkg2.get_employee_number
2785 		                            (p_person_id => l_sf52_rec.person_id,
2786 					     p_effective_date => l_sf52_rec.effective_date);
2787 
2788 		Begin
2789 			--  Bug 2639698 Sundar Enhancement - If To Pay is less than From Pay, no need to process. Just route it to inbox.
2790 
2791 			IF ( UPPER(SUBSTR(l_sf52_rec.request_number,1,3)) = 'MSL' AND l_sf52_rec.first_noa_code = '894')
2792 				AND (l_sf52_rec.to_basic_pay < l_sf52_rec.from_basic_pay) THEN
2793 				--Bug # 9329643 Modified SSN to Emp No
2794 				l_log_text := 'Request Number : ' || l_sf52_rec.request_number || l_new_line ||
2795 						'PA_REQUEST_ID : ' || to_char(l_sf52_rec.pa_request_id) || l_new_line ||
2796 						'Employee Name : ' || l_sf52_rec.employee_last_name || ' ,'
2797 									  || l_sf52_rec.employee_first_name || l_new_line ||
2798 						'Emp No        : ' || l_employee_number || l_new_line ||
2799 						'First NOA Code: ' || l_sf52_rec.first_noa_code || l_new_line ||
2800 						'Second NOA Code: ' || l_sf52_rec.second_noa_code || l_new_line ||
2801 						'Error: The From Side Basic Pay exceeds the To Side Basic Pay. ' ||  l_new_line ||
2802 						'Cause: The Personnel Action attempted to update the employee''s salary with a ' || l_new_line ||
2803 						'decreased amount of Basic Pay. ' || l_new_line ||
2804 						'Action: Please review the personnel action to verify the Grade and Step, Pay Table amounts,' || l_new_line ||
2805 						'and Pay Rate Determinant code for this employee.' ;    -- Bug 3320086 Changed error message.
2806 
2807 				hr_utility.set_location(l_log_text,1511);
2808 				create_ghr_errorlog(
2809 					p_program_name	=> g_futr_proc_name,
2810 					p_log_text		=> l_log_text,
2811 					p_message_name	=> 'SF52 Routed to Inbox',
2812 					p_log_date		=> sysdate
2813 					);
2814 				Route_Errorerd_SF52(
2815 	               p_sf52   => l_sf52_rec,
2816 		           p_error  => l_log_text,
2817 			       p_result => l_result
2818 				 );
2819 				 l_retcode := 5; /* Error - but route to inbox */
2820 			-- Bug 2639698
2821 			ELSE
2822 				savepoint future_Action;
2823 				Process_SF52(
2824 					p_sf52_data		=> l_sf52_rec,
2825 					p_process_type	=> 'FUTURE');
2826 
2827 --  Start of Bug 3602261
2828                                 ghr_sf52_post_update.get_notification_details
2829 				  (p_pa_request_id                  =>  l_sf52_rec.pa_request_id,
2830 				   p_effective_date                 =>  l_sf52_rec.effective_date,
2831 				   p_from_position_id               =>  l_sf52_rec.from_position_id,
2832 				   p_to_position_id                 =>  l_sf52_rec.to_position_id,
2833 				   p_agency_code                    =>  l_sf52_rec.agency_code,
2834 				   p_from_agency_code               =>  l_sf52_rec.from_agency_code,
2835 				   p_from_agency_desc               =>  l_sf52_rec.from_agency_desc,
2836 				   p_from_office_symbol             =>  l_sf52_rec.from_office_symbol,
2837 				   p_personnel_office_id            =>  l_sf52_rec.personnel_office_id,
2838 				   p_employee_dept_or_agency        =>  l_sf52_rec.employee_dept_or_agency,
2839 				   p_to_office_symbol               =>  l_sf52_rec.to_office_symbol
2840 				   );
2841 				 FOR ovn_rec IN c_ovn (l_sf52_rec.pa_request_id) LOOP
2842 				     l_object_version_number := ovn_rec.object_version_number;
2843 				 END LOOP;
2844 				 ghr_par_upd.upd
2845 				   (p_pa_request_id                  =>  l_sf52_rec.pa_request_id,
2846 				    p_object_version_number          =>  l_object_version_number,
2847 				    p_from_position_id               =>  l_sf52_rec.from_position_id,
2848 				    p_to_position_id                 =>  l_sf52_rec.to_position_id,
2849 				    p_agency_code                    =>  l_sf52_rec.agency_code,
2850 				    p_from_agency_code               =>  l_sf52_rec.from_agency_code,
2851 				    p_from_agency_desc               =>  l_sf52_rec.from_agency_desc,
2852 				    p_from_office_symbol             =>  l_sf52_rec.from_office_symbol,
2853 				    p_personnel_office_id            =>  l_sf52_rec.personnel_office_id,
2854 				    p_employee_dept_or_agency        =>  l_sf52_rec.employee_dept_or_agency,
2855 				    p_to_office_symbol               =>  l_sf52_rec.to_office_symbol
2856 				   );
2857 -- End of Bug 3602261
2858 			       --Bug # 9329643 Modified SSN to Emp No
2859 				l_log_text := 'Request Number : ' || l_sf52_rec.request_number || l_new_line ||
2860 						'PA_REQUEST_ID : ' || to_char(l_sf52_rec.pa_request_id) || l_new_line ||
2861 						'Employee Name : ' || l_sf52_rec.employee_last_name || ' ,'
2862 									  || l_sf52_rec.employee_first_name || l_new_line ||
2863 						'Emp No        : ' || l_employee_number || l_new_line ||
2864 						'First NOA Code: ' || l_sf52_rec.first_noa_code || l_new_line ||
2865 						'Second NOA Code: ' || l_sf52_rec.second_noa_code || l_new_line ||
2866 						'Processed Successfully';
2867 
2868 				create_ghr_errorlog(
2869 					p_program_name	=> g_futr_proc_name,
2870 					p_log_text		=> l_log_text,
2871 					p_message_name	=> 'SF52 Processed Successfully',
2872 					p_log_date		=> sysdate
2873 					);
2874 			 END IF;
2875 			 commit;
2876 		Exception
2877 		when e_refresh then
2878 			begin
2879 				rollback to future_Action;
2880      	      	      l_route_flag := TRUE;
2881 				if nvl(l_retcode, 0) <> 2 then
2882 					l_retcode := 1; /* warning */
2883 				end if;
2884 				-- Enter a record in process log
2885 				l_log_text := substr(
2886 						'Request Number : ' || l_sf52_rec.request_number || l_new_line ||
2887 						'PA_REQUEST_ID : ' || to_char(l_sf52_rec.pa_request_id) || l_new_line ||
2888 						'Employee Name : ' || l_sf52_rec.employee_last_name || ' ,' ||
2889                                                                             l_sf52_rec.employee_first_name || l_new_line ||
2890 						'Emp  No       : ' || l_employee_number || l_new_line  ||
2891 						'First NOA Code: ' || l_sf52_rec.first_noa_code || l_new_line ||
2892 						'Second NOA Code: ' || l_sf52_rec.second_noa_code || l_new_line ||
2893 						'Action: RPA related information has changed. Retrieve the RPA from the groupbox to review the refreshed information, make necessary changes, and update HR',1,2000);
2894 				create_ghr_errorlog(
2895 					p_program_name	=> g_futr_proc_name,
2896 					p_log_text		=> l_log_text,
2897 					p_message_name	=> 'Future SF52 Routed to Inbox',--Bug#5634990
2898 					p_log_date		=> sysdate
2899 			        );
2900             l_error_message := substr(sqlerrm(sqlcode), 1, 512);
2901             Route_Errorerd_SF52(
2902                p_sf52   => l_sf52_rec,
2903                p_error  => substr(l_error_message,1 ,512),
2904                p_result => l_result
2905              );
2906 				commit;
2907 			end;
2908 		when others then
2909 			Begin
2910 				if sqlcode = -6508 then
2911 					-- Program Unit not found
2912 					-- This usually happens and the only solution know so far is
2913 					-- to re-start the conc. manager. So all the SF52's are routed unnecessarily
2914 					l_retcode := 2; /* Error*/
2915 					errbuf := ' Program raised Error - Program Unit not Found. Details in Process Log.';
2916 					l_log_text := substr('Initiate Process Future Dated SF52 Due For Processing Terminated due to following error :  ' || Sqlerrm(sqlcode), 1, 2000);
2917 
2918 					rollback to future_Action;
2919 					create_ghr_errorlog(
2920 						p_program_name	=> g_futr_proc_name,
2921 						p_log_text		=> l_log_text,
2922 						p_message_name	=> 'Process Terminated',
2923 						p_log_date		=> sysdate
2924 					);
2925 					commit;
2926 					return;
2927 				end if;
2928 
2929 				rollback to future_Action;
2930             	      l_route_flag := TRUE;
2931 				if nvl(l_retcode, 0) <> 2 then
2932 					l_retcode := 1; /* warning */
2933 				end if;
2934 
2935 				hr_utility.set_location( l_proc || ' ' || substr(sqlerrm,1,20), 40);
2936 				-- Enter a record in process log
2937 				--Bug # 9329643 Modified SSN to Emp No
2938 				l_log_text := substr(
2939 						'Request Number : ' || l_sf52_rec.request_number || l_new_line ||
2940 						'PA_REQUEST_ID : ' || to_char(l_sf52_rec.pa_request_id) || l_new_line ||
2941 						'Employee Name : ' || l_sf52_rec.employee_last_name || ' ,' ||
2942                                         l_sf52_rec.employee_first_name || l_new_line ||
2943 						'Emp No        : ' || l_employee_number || l_new_line ||
2944 						'First NOA Code: ' || l_sf52_rec.first_noa_code || l_new_line ||
2945 						'Second NOA Code: ' || l_sf52_rec.second_noa_code || l_new_line ||
2946 						'Error : ' || sqlerrm(sqlcode) , 1, 2000);
2947 				create_ghr_errorlog(
2948 					p_program_name	=> g_futr_proc_name,
2949 					p_log_text		=> l_log_text,
2950 					p_message_name	=> 'SF52 Errored Out',
2951 					p_log_date		=> sysdate
2952 			        );
2953 
2954 				commit;
2955 			Exception
2956 			When Others then
2957 				hr_utility.set_location(' Error While creating Procees Log' || l_proc, 200);
2958 				-- Error
2959 				l_retcode := 2;
2960 				errbuf  := 'Process was errored out while creating Error Log. Error: ' || substr(sqlerrm(sqlcode), 1, 50);
2961 				return;
2962 			End;
2963                 l_error_message := substr(sqlerrm(sqlcode), 1, 512);
2964                 Route_Errorerd_SF52(
2965                   p_sf52   => l_sf52_rec,
2966                   p_error  => substr(l_error_message,1 ,512),
2967                   p_result => l_result
2968                   );
2969                 if l_result = '2' then
2970                   l_retcode := 2;
2971                 end if;
2972                 commit;
2973               End; --Bug 1266718
2974 	    End loop;
2975           exit;
2976         End loop;
2977  END sub_proc_futr_sf52;
2978 ----
2979 ---- End of  new procedure sub_proc_futr_sf52.
2980 ----
2981 
2982 Begin
2983 
2984    for s_id in cur_sessionid
2985    loop
2986      l_sid  := s_id.sesid;
2987    exit;
2988    end loop;
2989 
2990   begin
2991       update fnd_sessions set SESSION_ID = l_sid
2992       where  SESSION_ID = l_sid;
2993       if sql%notfound then
2994          INSERT INTO fnd_sessions
2995             (SESSION_ID,EFFECTIVE_DATE)
2996          VALUES
2997             (l_sid,sysdate);
2998       end if;
2999   end;
3000 
3001 	hr_utility.set_location(' Entering : ' || l_proc, 10);
3002 	-- Get concurent Request_id
3003 	g_futr_proc_name	:='GHR_Proc_Futr_Act';
3004 	l_req	:= Fnd_profile.value('CONC_REQUEST_ID');
3005 
3006 	if l_req is not null then
3007 		g_futr_proc_name := g_futr_proc_name || '_' || l_req;
3008 	else
3009 		-- if it fails for any reason. concat date time with program name
3010 		g_futr_proc_name := g_futr_proc_name || '_' || to_char(sysdate, 'ddmmyyhhmiss');
3011 	end if;
3012 
3013 ----New Logic for a Passed POI parameter.
3014 
3015     IF p_poi is not null then
3016       for par_pend_for_per_poi in c_par_pend_per_poi loop
3017         l_person_id       :=  par_pend_for_per_poi.person_id;
3018         l_effective_date  :=  par_pend_for_per_poi.effective_date;
3019         hr_utility.set_location( 'Person id ' || l_person_id,1);
3020         hr_utility.set_location(' Eff. Date ' || l_effective_date,2);
3021         sub_proc_futr_sf52;
3022       end loop;
3023     ELSE
3024       for par_pend_for_per in c_par_pend_per loop
3025         l_person_id       :=  par_pend_for_per.person_id;
3026         l_effective_date  :=  par_pend_for_per.effective_date;
3027         hr_utility.set_location( 'Person id ' || l_person_id,1);
3028         hr_utility.set_location(' Eff. Date ' || l_effective_date,2);
3029         sub_proc_futr_sf52;
3030       end loop;
3031     END IF;
3032      if l_retcode = 2 then
3033 		retcode := 2;
3034             hr_utility.set_location('Ret code ' || to_char(l_retcode),1);
3035  		errbuf  := 'There were errors in SF52''s which could NOT be routed to approver''s Inbox. Detail in GHR_PROCESS_LOG';
3036     -- Bug 2639698 Sundar
3037 	elsif l_retcode = 5 then
3038 		retcode := 2;
3039             hr_utility.set_location('Ret code ' || to_char(l_retcode),1);
3040  		errbuf  := 'There were errors in SF52''s which were routed to approver''s Inbox. Detail in GHR_PROCESS_LOG';
3041     -- End Bug 2639698 Sundar
3042      elsif l_retcode is not NULL then
3043 		-- Warning
3044 		retcode := 1;
3045 		errbuf  := 'There were errors in SF52''s which were routed to approver''s Inbox. Detail in GHR_PROCESS_LOG' ;
3046      elsif l_retcode is null then
3047 		retcode := 0;
3048      end if;
3049      hr_utility.set_location( 'Leaving : ' || l_proc, 20);
3050      hr_utility.set_location('Ret code ' || to_char(l_retcode), 21);
3051 Exception
3052 when others then
3053 	hr_utility.set_location(l_proc, 60);
3054 	-- Error
3055 	retcode := 2;
3056 	errbuf  := 'Process Terminated due to Unhandled Errors.' || l_new_line
3057              || 'Error : ' || substr(sqlerrm(sqlcode), 1, 20);
3058 End Proc_Futr_Act;
3059 
3060 --
3061 --
3062 Procedure Route_Errorerd_SF52(
3063 				p_sf52   in out nocopy ghr_pa_requests%rowtype,
3064 				p_error	 in varchar2,
3065 				p_result out nocopy varchar2) is
3066 
3067 	l_u_prh_object_version_number		number;
3068 	l_i_pa_routing_history_id	     	number;
3069 	l_i_prh_object_version_number		number;
3070 
3071 	l_log_text				varchar2(2000);
3072 --	l_prog_name				varchar2(30):='GHR Process Future SF52';
3073 	l_proc					varchar2(30):='Route_Errerd_SF52';
3074         l_new_line				varchar2(1) := substr('',1,1);
3075 	l_sf52					ghr_pa_requests%rowtype ;
3076 	--Bug # 9329643
3077 	l_employee_number                       per_people_f.employee_number%type;
3078 
3079 Begin
3080 	l_sf52 :=p_sf52; --NOCOPY Changes
3081 	hr_utility.set_location( 'Entering : ' || l_proc, 10);
3082 	savepoint route_errored_sf52;
3083 /*
3084 	l_log_text := 'Request Number : ' || p_sf52.request_number || l_new_line ||
3085 			  'PA_REQUEST_ID : ' || to_char(p_sf52.pa_request_id) ||
3086                     ' has errors.' || l_new_line ||
3087                     'Error :         ' || p_error || l_new_line  ||
3088                     'Errored while resetting approval date ';
3089 */
3090 	hr_utility.set_location( l_proc, 20);
3091 
3092 	--Bug # 9329643
3093 	l_employee_number := ghr_pa_requests_pkg2.get_employee_number
3094 	                            (p_person_id => l_sf52.person_id,
3095 				     p_effective_date => l_sf52.effective_date);
3096 	l_log_text := 'Request Number : ' || p_sf52.request_number || l_new_line ||
3097 			  'PA_REQUEST_ID : ' || to_char(p_sf52.pa_request_id) ||
3098                     ' has errors.' || l_new_line ||
3099                     'Error :         ' || p_error || l_new_line ||
3100                     'Errored while routing it to the approver''s Inbox ';
3101 
3102 	ghr_api.call_workflow(
3103 		p_pa_request_id	=>	p_sf52.pa_request_id,
3104 		p_action_taken	=>	'CONTINUE',
3105 		p_error		=>	p_error);
3106 	hr_utility.set_location( 'Leaving : ' || l_proc, 20);
3107 Exception
3108 when others then
3109 	hr_utility.set_location(l_proc || ' workflow errored out', 30);
3110 	rollback to route_errored_sf52;
3111 	p_result := '0';
3112 	--Bug # 9329643 Modified SSN to Emp No
3113 	l_log_text := substr(
3114 			'Request Number : ' || p_sf52.request_number || l_new_line ||
3115 			'PA_REQUEST_ID : ' || to_char(p_sf52.pa_request_id) || l_new_line ||
3116 			'Employee Name : ' || p_SF52.employee_last_name || ' ,' || p_sf52.employee_first_name || l_new_line ||
3117 			'Emp No        : ' || l_employee_number || l_new_line ||
3118 			'First NOA Code: ' || p_sf52.first_noa_code || l_new_line ||
3119 			'Second NOA Code: ' || p_sf52.second_noa_code || l_new_line ||
3120 			'Errored while routing it to the approver''s Inbox '  || l_new_line ||
3121 			'Error : ' || sqlerrm(sqlcode), 1, 2000);
3122 	create_ghr_errorlog(
3123 		p_program_name	=> g_futr_proc_name,
3124 		p_log_text		=> l_log_text,
3125 		p_message_name	=> 'Routing Error',
3126 		p_log_date		=> sysdate
3127 	);
3128 	hr_utility.set_location(l_proc , 40);
3129 	p_result := '2';
3130 	p_sf52 := l_sf52; --Added for nocopy changes
3131 
3132 End Route_Errorerd_SF52;
3133 
3134 /*--Added by Rohini
3135 
3136 Procedure fetch_update_routing_details
3137 (p_pa_request_id           in         ghr_pa_requests.pa_request_id%type,
3138  p_object_version_number   in out     ghr_pa_requests.object_version_number%type,
3139  p_position_id             in         ghr_pa_requests.to_position_id%type,
3140  p_effective_date          in         ghr_pa_requests.effective_date%type,
3141  p_retcode                 out     nocopy   number,
3142  p_route_flag              out     nocopy   boolean
3143  )
3144 
3145  is
3146 
3147  l_groupbox_id                ghr_groupboxes.groupbox_id%type;
3148  l_routing_group_id           ghr_pa_requests.routing_group_id%type;
3149  l_proc     			varchar2(72)  :=  ' ghr_process_sf52.' || 'update_routing_details';
3150  l_pa_routing_history_id      ghr_pa_routing_history.pa_routing_history_id%type;
3151  l_pa_object_version_number   ghr_pa_routing_history.object_version_number%type;
3152  l_user_name           varchar2(30);
3153  l_log_text            varchar2(2000);
3154 
3155 
3156 
3157 
3158  Cursor c_rout_history is
3159    select pa_routing_history_id,
3160           object_version_number,
3161           user_name,
3162           groupbox_id
3163    from   ghr_pa_routing_history
3164    where  pa_request_id = p_pa_request_id
3165    order  by 1 desc;
3166 
3167 
3168 Procedure get_personnel_off_groupbox
3169 (p_position_id         in       per_positions.position_id%type,
3170  p_effective_date      in       date default trunc(sysdate),
3171  p_groupbox_id         out      ghr_groupboxes.groupbox_id%type,
3172  p_routing_group_id    out      ghr_routing_groups.routing_group_id%type,
3173  p_retcode             out      number
3174 )
3175 is
3176 
3177   l_proc            	varchar2(72) :=  'fetch_update_rout_details '  || 'get_personnel_off_groupbox';
3178   l_pos_ei_data     	per_position_extra_info%type;
3179   l_groupbox_name   	ghr_groupboxes.name%type;
3180   l_groupbox_id     	ghr_groupboxes.groupbox_id%type;
3181   l_routing_group_id 	ghr_routing_groups.routing_group_id%type;
3182   l_personnel_office_id ghr_pa_requests.personnel_office_id%type;
3183   l_log_text            varchar2(2000);
3184 
3185   Cursor  c_gpboxname is
3186     select  substr(hl.description,1,30) description
3187     from    hr_lookups hl
3188     where   hl.application_id      = 800
3189     and     hl.lookup_type         = 'GHR_US_PERSONNEL_OFFICE_ID'
3190     and     hl.lookup_code         = l_personnel_office_id
3191     and     hl.enabled_flag        = 'Y'
3192     and     nvl(p_effective_date,trunc(sysdate))
3193     between nvl(hl.start_date_active,nvl(p_effective_date,trunc(sysdate)))
3194     and     nvl(hl.end_date_active,nvl(p_effective_date,trunc(sysdate)));
3195 
3196   Cursor c_gbx is
3197     select  gbx.groupbox_id gpid, gbx.routing_group_id rgpid
3198            --gbx.name, rgp.name
3199     from    ghr_groupboxes gbx,
3200             ghr_routing_groups rgp
3201     where   gbx.name = l_groupbox_name
3202     and     gbx.routing_group_id = rgp.routing_group_id;
3203 
3204 
3205 
3206 begin
3207   savepoint get_personnel_off_groupbox;
3208   hr_utility.set_location('Entering   ' || l_proc,5);
3209   p_retcode      :=  null;
3210 
3211  -- Find the groupbox of the personnelist, update ghr_pa_routing_history and then call work_flow
3212 
3213   If p_position_id is not null then
3214 
3215     l_log_text := 'Error while getting the groupbox of the personnel';
3216 
3217    -- get the personnel offfice id
3218     ghr_history_fetch.fetch_positionei
3219     (p_position_id                 =>   p_position_id    	               ,
3220      p_information_type            =>   'GHR_US_POS_GRP1'		         ,
3221      p_date_effective              =>   trunc(nvl(p_effective_date,sysdate)),
3222      p_pos_ei_data                 =>   l_pos_ei_data
3223     );
3224 
3225     l_personnel_office_id          :=  l_pos_ei_data.poei_information3;
3226     l_pos_ei_data                  :=  null;
3227 
3228      -- get groupbox name
3229     for gpboxname in c_gpboxname loop
3230       l_groupbox_name             :=   gpboxname.description;
3231     end loop;
3232 
3233 
3234   --
3235   -- validate groupbox  (name exists in wf_roles ) -- Should I do this or will workflow take care of it
3236   -- fetch groupbox_id as well as other routing group details
3237 
3238     if l_groupbox_name is not null then
3239       for rout_det in c_gbx loop
3240         l_groupbox_id             :=  rout_det.gpid;
3241         l_routing_group_id        :=  rout_det.rgpid;
3242 
3243       end loop;
3244     end if;
3245   end if;
3246   p_groupbox_id       :=  l_groupbox_id;
3247   p_routing_group_id  := l_routing_group_id;
3248 
3249 Exception
3250   when others then
3251     rollback to get_personnel_off_groupbox;
3252     hr_utility.set_location(l_proc,50);
3253 
3254     p_retcode          :=  2;
3255     create_ghr_errorlog
3256     (p_program_name		=> g_futr_proc_name,
3257      p_log_text		=> l_log_text,
3258      p_message_name	=> NULL,
3259      p_log_date		=> sysdate
3260     );
3261     commit;
3262 end get_personnel_off_groupbox;
3263 
3264 begin
3265 
3266   hr_utility.set_location('Entering   '  || l_proc ,5);
3267   savepoint fetch_update_routing_details;
3268 
3269   l_user_name   :=  null;
3270   l_groupbox_id :=  null;
3271   p_retcode     :=  null;
3272   p_route_flag  :=  FALSE;
3273 
3274   For rout_hist in c_rout_history loop
3275     l_user_name                 :=   rout_hist.user_name;
3276     l_groupbox_id               :=   rout_hist.groupbox_id;
3277     l_pa_routing_history_id     :=   rout_hist.pa_routing_history_id;
3278     l_pa_object_version_number  :=   rout_hist.object_version_number;
3279     exit;
3280   End loop;
3281 
3282   If l_user_name is null and l_groupbox_id is null then
3283     get_personnel_off_groupbox
3284     (p_position_id          =>   p_position_id,
3285      p_effective_date       =>   p_effective_date  ,
3286      p_groupbox_id          =>   l_groupbox_id,
3287      p_routing_group_id     =>   l_routing_group_id,
3288      p_retcode              =>   p_retcode
3289     );
3290 
3291     If l_groupbox_id is null then
3292       p_route_flag := FALSE;
3293       rollback to fetch_update_routing_details;
3294       l_log_text := 'No groupbox associated with this personnel office';
3295       create_ghr_errorlog
3296       (p_program_name	=> g_futr_proc_name,
3297        p_log_text		=> l_log_text,
3298        p_message_name	=> NULL,
3299        p_log_date		=> sysdate
3300       );
3301       commit;
3302     Else
3303       p_route_flag  := TRUE;
3304       l_log_text := 'Error while updating routing_group_id to ghr_pa_requests table';
3305       ghr_par_upd.upd
3306       (p_pa_request_id           =>    p_pa_request_id,
3307        p_object_version_number   =>    p_object_version_number,
3308        p_routing_group_id        =>    l_routing_group_id
3309       );
3310       hr_utility.set_location(l_proc ,10);
3311 
3312 
3313       l_log_text := 'Error while updating groupbox to ghr_pa_routing_history table';
3314       for rout_hist in c_rout_history loop
3315         hr_utility.set_location(l_proc ,15);
3316         l_pa_routing_history_id         :=   rout_hist.pa_routing_history_id;
3317         l_pa_object_version_number      :=   rout_hist.object_version_number;
3318       end loop;
3319 
3320       hr_utility.set_location(l_proc ,20);
3321       ghr_prh_upd.upd
3322       (p_pa_routing_history_id         =>   l_pa_routing_history_id,
3323        p_object_version_number         =>   l_pa_object_version_number,
3324        p_groupbox_id                   =>   l_groupbox_id
3325        );
3326        hr_utility.set_location('Leaving  '|| l_proc ,30);
3327     End if;
3328   Else
3329     p_route_flag := TRUE;
3330   End if;
3331 
3332  Exception
3333    when others then
3334     rollback to fetch_update_routing_details;
3335     create_ghr_errorlog
3336     (p_program_name		=> g_futr_proc_name,
3337      p_log_text		=> l_log_text,
3338      p_message_name	=> NULL,
3339      p_log_date		=> sysdate
3340     );
3341     p_retcode  := 2;
3342     commit;
3343  end fetch_update_routing_details;
3344 
3345 -- Rohini
3346 */
3347 
3348 -- Route Future Action
3349 
3350 Procedure Route_Intervn_Future_Actions( p_person_id		in	number,
3351 					p_effective_date	in	date
3352                                         ) is
3353 
3354 	cursor get_req (
3355 			cp_person_id		number,
3356 			cp_date_Effective	date
3357                        ) is
3358 
3359 	select *
3360 	from ghr_pa_requests a
3361 	where person_id 	   =  cp_person_id	and
3362 		effective_date > cp_date_effective      and
3363                 pa_notification_id is null 		and
3364 		approval_date is not null		and
3365 		exists 	(select 'exists'
3366 				from ghr_pa_routing_history
3367 				where pa_routing_history_id = (select max(pa_routing_history_id)
3368 									from ghr_pa_routing_history
3369 									where pa_request_id = a.pa_request_id)
3370 					and action_taken in ('FUTURE_ACTION')) ;
3371 	l_error	varchar2(512):='Routed because of intervening RPA approval';
3372 	l_rec		get_req%rowtype;
3373 	l_proc	varchar2(30):='Route_Intervn_Future_Actions';
3374 
3375 Begin
3376 	hr_utility.set_location(' Entering : ' || l_proc, 10);
3377 	open get_req (p_person_id, p_effective_date);
3378 	While TRUE
3379 	loop
3380 		fetch get_req into l_rec;
3381 		exit when get_req%notfound;
3382 		Begin
3383 			savepoint future_Action;
3384 
3385 			ghr_api.call_workflow(	p_pa_request_id	=>	l_rec.pa_request_id,
3386 						p_action_taken	=>	'CONTINUE',
3387 						p_error		=>	l_error);
3388 		Exception
3389 		when others then
3390 			l_error := Sqlerrm(sqlcode);
3391 			rollback to future_Action;
3392 			Raise;
3393 		End;
3394 		hr_utility.set_location(' Entering : ' || l_proc, 100);
3395 	End loop;
3396 	hr_utility.set_location( 'Leaving : ' || l_proc, 20);
3397 End Route_Intervn_Future_Actions;
3398 
3399 
3400 
3401 Procedure Route_Intervn_act_pend_today( p_person_id		in	number,
3402 					p_effective_date	in	date
3403                                         ) is
3404 
3405 	cursor get_req (
3406 			cp_person_id		number,
3407 			cp_date_Effective	date
3408                     ) is
3409 	select *
3410 	from ghr_pa_requests a
3411 	where person_id 	=  cp_person_id 	and
3412 		effective_date = cp_date_effective      and
3413             pa_notification_id is null 		        and
3414 		approval_date is not null		and
3415 		exists 	(select 'exists'
3416 				from ghr_pa_routing_history
3417 				where pa_routing_history_id = (select max(pa_routing_history_id)
3418 									from ghr_pa_routing_history
3419 									where pa_request_id = a.pa_request_id)
3420 					and action_taken in ('FUTURE_ACTION')) ;
3421 	l_error	varchar2(512):='Routed because of intervening RPA approval';
3422 	l_rec		get_req%rowtype;
3423 	l_proc	varchar2(30):='Route_Intervn_pend_Actions';
3424 
3425 Begin
3426 	hr_utility.set_location(' Entering : ' || l_proc, 10);
3427 	open get_req (p_person_id, p_effective_date);
3428 	While TRUE
3429 	loop
3430 		fetch get_req into l_rec;
3431 		exit when get_req%notfound;
3432 		Begin
3433 			savepoint route_pending_Actions;
3434 
3435 			ghr_api.call_workflow(	p_pa_request_id	=>	l_rec.pa_request_id,
3436 						p_action_taken	=>	'CONTINUE',
3437 						p_error		=>	l_error);
3438 		Exception
3439 		when others then
3440 			l_error := Sqlerrm(sqlcode);
3441 			rollback to route_pending_Actions;
3442 			Raise;
3443 		End;
3444 		hr_utility.set_location(' Entering : ' || l_proc, 100);
3445 	End loop;
3446 	hr_utility.set_location( 'Leaving : ' || l_proc, 20);
3447 End Route_Intervn_act_pend_today;
3448 
3449 
3450 
3451 procedure create_ghr_errorlog(
3452         p_program_name           in     ghr_process_log.program_name%type,
3453         p_log_text               in     ghr_process_log.log_text%type,
3454         p_message_name           in     ghr_process_log.message_name%type,
3455         p_log_date               in     ghr_process_log.log_date%type
3456         ) is
3457 
3458 	l_proc		varchar2(30):='create_ghr_errorlog';
3459 Begin
3460 	hr_utility.set_location( 'Entering : ' || l_proc, 10);
3461      insert into ghr_process_log
3462 	(process_log_id
3463       ,program_name
3464       ,log_text
3465       ,message_name
3466       ,log_date
3467       )
3468      values
3469 	(ghr_process_log_s.nextval
3470       ,p_program_name
3471       ,p_log_text
3472       ,p_message_name
3473       ,p_log_date
3474      );
3475 	hr_utility.set_location( 'Leaving : ' || l_proc, 20);
3476 
3477 End create_ghr_errorlog;
3478 
3479 -- ---------------------------------------------------------------------------
3480 -- |--------------------------< refresh_pa_request>---------------------------|
3481 -- ---------------------------------------------------------------------------
3482 -- {Start Of Comments}
3483 --
3484 -- Description:
3485 --	Refreshes all data having to do with a given pa_request.
3486 --
3487 -- Pre-Requisities:
3488 --   	None.
3489 --
3490 -- In Parameters:
3491 --	p_person_id		->		person_id to get pa_request info for.
3492 --	p_effective_date	->		date to refresh from.
3493 --	p_sf52_data		->		Retrieved values returned here.
3494 --	p_from_only		->		input flag to indicate if only from info is needed.
3495 --	p_
3496 --
3497 -- Post Success:
3498 -- 	the requested information will have been returned.
3499 --
3500 -- Post Failure:
3501 --   No Failure conditions.
3502 --
3503 -- Developer Implementation Notes:
3504 --	None.
3505 --
3506 -- Access Status:
3507 --   Internal Development Use Only.
3508 --
3509 -- {End Of Comments}
3510 -- ---------------------------------------------------------------------------
3511 
3512 PROCEDURE refresh_pa_request(
3513 		p_person_id			in	per_people_f.person_id%type,
3514 		p_effective_date		in	date,
3515 		p_from_only			in	boolean	default	FALSE,
3516 		p_derive_to_cols		in	boolean	default	FALSE,
3517 		p_sf52_data			in out 	nocopy ghr_pa_requests%rowtype) IS
3518 
3519 	l_agency_code			ghr_pa_requests.agency_code%type;
3520 	l_assignment_id       		NUMBER(9);
3521 	l_duty_station_id		NUMBER(9);
3522 	l_duty_station_desc		ghr_pa_requests.duty_station_desc%type;
3523 	l_duty_station_code		ghr_pa_requests.duty_station_code%type;
3524 	l_national_identifier		ghr_pa_requests.employee_national_identifier%type;
3525 	l_date_of_birth			ghr_pa_requests.employee_date_of_birth%type;
3526 	l_employee_last_name		ghr_pa_requests.employee_last_name%type;
3527 	l_employee_first_name		ghr_pa_requests.employee_first_name%type;
3528 	l_employee_middle_names		ghr_pa_requests.employee_middle_names%type;
3529 	l_personnel_office_id		ghr_pa_requests.personnel_office_id%type;
3530 	l_office_symbol			ghr_pa_requests.from_office_symbol%type;
3531 	l_position_id         		hr_all_positions_f.position_id%type;
3532 	l_from_position_id              hr_all_positions_f.position_id%type;
3533 	l_from_position_title           hr_all_positions_f.name%type;
3534 	l_location_id         		NUMBER(15);
3535 	l_position_title      		VARCHAR2(150);
3536 	l_position_number     		VARCHAR2(150);
3537 	l_position_seq_no     		NUMBER(15);
3538 	l_pay_plan            		VARCHAR2(150);
3539 	l_job_id              		NUMBER(15);
3540 	l_occ_code            		VARCHAR2(150);
3541 	l_grade_id            		NUMBER(15);
3542 	l_grade_or_level      		VARCHAR2(150);
3543 	l_step_or_rate        		VARCHAR2(150);
3544 	--6850492
3545         l_step_or_rate1        		VARCHAR2(150);
3546 	l_total_salary        		NUMBER;
3547 	l_pay_basis           		VARCHAR2(150);
3548 	-- FWFA Changes Bug#4444609
3549 	l_pay_table_identifier          NUMBER;
3550 	-- FWFA Changes
3551 	l_basic_pay           		NUMBER;
3552 	l_locality_adj        		NUMBER;
3553 	l_adj_basic_pay       		NUMBER;
3554 	l_other_pay           		NUMBER;
3555 	l_capped_other_pay              NUMBER;
3556 	l_au_overtime			NUMBER;
3557 	l_auo_premium_pay_indicator 	VARCHAR2(30);
3558 	l_availability_pay          	NUMBER;
3559 	l_ap_premium_pay_indicator  	VARCHAR2(30);
3560 	l_retention_allowance       	NUMBER;
3561 	l_supervisory_differential  	NUMBER;
3562 	l_staffing_differential     	NUMBER;
3563 	l_organization_id     		NUMBER(15);
3564 	l_position_org_line1  		VARCHAR2(150);
3565 	l_position_org_line2  		VARCHAR2(150);
3566 	l_position_org_line3  		VARCHAR2(150);
3567 	l_position_org_line4  		VARCHAR2(150);
3568 	l_position_org_line5  		VARCHAR2(150);
3569 	l_position_org_line6  		VARCHAR2(150);
3570 	l_dummy_varchar       		VARCHAR2(150);
3571 	l_citizenship           	VARCHAR2(150);
3572 	l_veterans_preference  		VARCHAR2(150);
3573 	l_veterans_pref_for_rif 	VARCHAR2(150);
3574 	l_veterans_status       	VARCHAR2(150);
3575 	l_service_comp_date     	VARCHAR2(150);
3576 	l_education_level      		VARCHAR2(60);
3577 	l_year_degree_attained 		VARCHAR2(60);
3578 	l_academic_discipline  		VARCHAR2(60);
3579         l_forwarding_address_line1      per_addresses.address_line1%type;
3580         l_forwarding_address_line2      per_addresses.address_line2%type;
3581         l_forwarding_address_line3      per_addresses.address_line3%type;
3582         l_forwarding_town_or_city       per_addresses.town_or_city%type;
3583         l_forwarding_region_2           per_addresses.region_2%type;
3584         l_forwarding_postal_code        per_addresses.postal_code%type;
3585         l_forwarding_country            per_addresses.country%type;
3586 	l_forwarding_country_short_na   fnd_territories_tl.territory_short_name%type;
3587 
3588 	l_tenure                 	VARCHAR2(150);
3589 	l_annuitant_indicator    	VARCHAR2(150);
3590 	l_pay_rate_determinant   	VARCHAR2(150);
3591 	l_fegli                  	VARCHAR2(150);
3592 	l_retirement_plan        	VARCHAR2(150);
3593 	l_multiple_error_flag    	BOOLEAN;
3594 	l_flsa_category          	VARCHAR2(150);
3595 	l_bargaining_unit_status 	VARCHAR2(150);
3596 	l_work_schedule          	VARCHAR2(150);
3597 	l_functional_class       	VARCHAR2(150);
3598 	l_supervisory_status     	VARCHAR2(150);
3599 	l_position_occupied      	VARCHAR2(150);
3600 	l_appropriation_code1    	VARCHAR2(150);
3601 	l_appropriation_code2    	VARCHAR2(150);
3602 	l_part_time_hours        	NUMBER(5,2);
3603 	l_business_group_id		NUMBER(9);
3604 	l_proc				VARCHAR2(30):= 'refresh_pa_request';
3605 --	p_from_location_id		hr_locations.location_id%type;
3606 	l_alt_pa_req_id			NUMBER;
3607 	l_people_data			per_all_people_f%rowtype;
3608 	l_result_code			varchar2(30);
3609         l_retention_allow_percentage    ghr_pa_requests.to_retention_allow_percentage%type;
3610         l_supervisory_diff_percentage   ghr_pa_requests.to_supervisory_diff_percentage%type;
3611         l_staffing_diff_percentage      ghr_pa_requests.to_staffing_diff_percentage%type;
3612 	l_session_var	            ghr_history_api.g_session_var_type;
3613 	l_noa_family_code			ghr_pa_requests.noa_family_code%type;
3614 	l_first_noa_id			ghr_pa_requests.first_noa_id%type;
3615 	l_first_noa_code			ghr_pa_requests.first_noa_code%type;
3616 	l_second_noa_id			ghr_pa_requests.second_noa_id%type;
3617 	l_second_noa_code			ghr_pa_requests.second_noa_code%type;
3618         l_per_type                      per_person_types.system_person_type%type := hr_api.g_varchar2;
3619         l_prd                          varchar2(30);
3620 	l_prd1                         varchar2(30);
3621         l_person_id                    ghr_pa_requests.person_id%type;
3622         l_temp_to_position_id          ghr_pa_requests.to_position_id%type;
3623         l_pm                          varchar2(50);
3624 
3625         l_pos_ei_grade_data           per_position_extra_info%rowtype;
3626 	l_sf52_data		      ghr_pa_requests%rowtype;
3627 
3628 
3629 
3630 CURSOR cur_per IS
3631   SELECT 	per.national_identifier
3632         	,per.date_of_birth
3633 		,per.first_name
3634 		,per.last_name
3635 		,per.middle_names
3636   FROM   per_people_f per
3637   WHERE  per.person_id = p_person_id
3638   AND    NVL(p_effective_date,TRUNC(sysdate))  between per.effective_start_date and per.effective_end_date;
3639 
3640 Cursor get_pos_bg ( c_position_id in number) IS
3641 	select
3642 		business_group_id
3643 	from hr_all_positions_f pos  -- Venkat -- Position DT
3644 	where pos.position_id = c_position_id
3645          and p_effective_date between pos.effective_start_date
3646                 and pos.effective_end_date;
3647 -- FWFA Changes Commented the input_pay_rate_determinant.
3648 -- FWFA Changes Bug#4444609 Added input_pay_rate_determinant field in the cursor
3649 -- 6850492 Added NVL While refreshing the column for Dual Action,p_sf52_data.pa_request_id is null consider session variable
3650 Cursor get_noa_info IS
3651 	select
3652 		noa_family_code, first_noa_code, first_noa_id,
3653         second_noa_code, second_noa_id
3654 	, pay_rate_determinant
3655         /* input_pay_rate_determinant*/
3656 	from ghr_pa_requests
3657 	where pa_request_id = nvl(p_sf52_data.pa_request_id,l_session_var.pa_request_id);
3658 -- FWFA Changes
3659 -- Bug # 1239688 --
3660 cursor get_person_type is
3661           select ppt.system_person_type
3662           from   per_people_f ppf,
3663                  per_person_types ppt
3664           where   ppf.person_id = p_person_id
3665           and     p_effective_date
3666           between ppf.effective_start_date
3667           and     ppf.effective_end_date
3668           and     ppt.person_type_id = ppf.person_type_id;
3669 
3670 -- JH Get To Position Title PM for Noa Code being updated.
3671 Cursor get_to_posn_title_pm(p_noa_id in number) is
3672          select  fpm.process_method_code
3673          from    ghr_noa_families         nof
3674                  ,ghr_families             fam
3675                  ,ghr_noa_fam_proc_methods fpm
3676                  ,ghr_pa_data_fields       pdf
3677          where   nof.nature_of_action_id = p_noa_id
3678          and     nof.noa_family_code     = fam.noa_family_code
3679          and     nof.enabled_flag = 'Y'
3680          and     p_effective_date between nvl(nof.start_date_active,p_effective_date) and nvl(nof.end_date_active,p_effective_date)
3681          and     fam.proc_method_flag = 'Y'
3682          and     fam.enabled_flag = 'Y'
3683          and     p_effective_date between nvl(fam.start_date_active,p_effective_date) and nvl(fam.end_date_active,p_effective_date)
3684          and     fam.noa_family_code = fpm.noa_family_code
3685          and     fpm.pa_data_field_id = pdf.pa_data_field_id
3686          and     fpm.enabled_flag = 'Y'
3687          and     p_effective_date between nvl(fpm.start_date_active,p_effective_date) and nvl(fpm.end_date_active,p_effective_date)
3688          and     pdf.form_field_name = 'TO_POSITION_TITLE'
3689          and     pdf.enabled_flag = 'Y'
3690          and     p_effective_date between nvl(pdf.date_from,p_effective_date) and nvl(pdf.date_to,p_effective_date);
3691 	-- Bug 2112935
3692    l_orig_pa_request_id	  ghr_pa_requests.pa_request_id%type;
3693    l_orig_pa_notification_id ghr_pa_requests.pa_notification_id%type;
3694    l_orig_person_id ghr_pa_requests.person_id%type;
3695    l_orig_effective_date ghr_pa_requests.effective_date%type;
3696    l_effective_date   ghr_pa_requests.effective_date%type;
3697    l_retro_first_noa   ghr_nature_of_actions.code%type;
3698    l_retro_second_noa   ghr_nature_of_actions.code%type;
3699    l_retro_pa_request_id   ghr_pa_requests.pa_request_id%type;
3700    l_orig_first_noa   ghr_pa_requests.first_noa_code%type;
3701    l_orig_second_noa  ghr_pa_requests.second_noa_code%type;
3702 
3703 CURSOR c_orig_rec(c_pa_request_id ghr_pa_requests.pa_request_id%type) IS
3704    SELECT *
3705    FROM ghr_pa_requests par
3706    WHERE par.pa_request_id =
3707 							(SELECT min(par1.pa_request_id)
3708 								FROM ghr_pa_requests par1
3709 									start with pa_request_id = c_pa_request_id
3710 									connect by  pa_request_id = prior altered_pa_request_id);
3711 
3712 -- 8303159 Dual Actions
3713 cursor get_740_prd
3714     is
3715     select pay_rate_determinant
3716     from   ghr_pa_requests
3717     where  pa_request_id = (select max(pa_request_id)
3718                             from   ghr_pa_requests
3719                             where  pa_notification_id is not null
3720 			    and (first_noa_code = '740' or second_noa_code = '740')
3721                             start with pa_request_id = (select mass_action_id
3722                                                         from   ghr_pa_requests
3723                                                         where  pa_request_id = l_session_var.pa_request_id)
3724                             connect by  pa_request_id = prior altered_pa_request_id);
3725 
3726 cursor chk_sec_corr
3727     is
3728     select 1
3729     from   ghr_pa_requests
3730     where  pa_request_id =  (SELECT min(par1.pa_request_id)
3731  			     FROM ghr_pa_requests par1
3732 			     start with pa_request_id = l_session_var.altered_pa_request_id
3733 			     connect by  pa_request_id = prior altered_pa_request_id)
3734     and    second_noa_id  =l_session_var.noa_id_correct;
3735 -- 8303159 Dual Actions
3736 
3737 --Begin Bug# 14047036, 13587903
3738 Cursor get_prd_pm(p_noa_id in number) is
3739          select  fpm.process_method_code
3740          from    ghr_noa_families         nof
3741                  ,ghr_families             fam
3742                  ,ghr_noa_fam_proc_methods fpm
3743                  ,ghr_pa_data_fields       pdf
3744          where   nof.nature_of_action_id = p_noa_id
3745          and     nof.noa_family_code     = fam.noa_family_code
3746          and     nof.enabled_flag = 'Y'
3747          and     p_effective_date between nvl(nof.start_date_active,p_effective_date) and nvl(nof.end_date_active,p_effective_date)
3748          and     fam.proc_method_flag = 'Y'
3749          and     fam.enabled_flag = 'Y'
3750          and     p_effective_date between nvl(fam.start_date_active,p_effective_date) and nvl(fam.end_date_active,p_effective_date)
3751          and     fam.noa_family_code = fpm.noa_family_code
3752          and     fpm.pa_data_field_id = pdf.pa_data_field_id
3753          and     fpm.enabled_flag = 'Y'
3754          and     p_effective_date between nvl(fpm.start_date_active,p_effective_date) and nvl(fpm.end_date_active,p_effective_date)
3755          and     pdf.form_field_name = 'PAY_RATE_DETERMINANT'
3756          and     pdf.enabled_flag = 'Y'
3757          and     p_effective_date between nvl(pdf.date_from,p_effective_date) and nvl(pdf.date_to,p_effective_date);
3758  l_prd_pm  varchar2(50);
3759 --End Bug# 14047036, 13587903
3760 
3761 -- Procedure to get step or rate
3762 PROCEDURE get_asg_step_or_rate(p_position_id IN ghr_pa_requests.to_position_id%type,
3763 								p_effective_date IN ghr_pa_requests.effective_date%type,
3764 								p_step_or_rate OUT NOCOPY ghr_pa_requests.to_step_or_rate%type,
3765 								p_prd OUT NOCOPY ghr_pa_requests.pay_rate_determinant%type ) IS
3766 
3767 CURSOR cur_ass_id(c_position_id ghr_pa_requests.to_position_id%type, c_effective_date IN ghr_pa_requests.effective_date%type) IS
3768   SELECT assignment_id, person_id
3769   FROM  per_all_assignments_f
3770   WHERE position_id = c_position_id
3771   AND   assignment_type <> 'B'
3772   AND   primary_flag = 'Y'
3773   AND   c_effective_date
3774         between effective_start_date and effective_end_date;
3775 
3776 l_assignment_id per_all_assignments_f.assignment_id%type;
3777 l_asgei_data    per_assignment_extra_info%rowtype;
3778 l_session ghr_history_api.g_session_var_type;
3779 
3780 
3781 BEGIN
3782 	-- Get the Assignment ID from the position ID.
3783 	FOR cur_ass_id_rec  IN cur_ass_id(p_position_id,p_effective_date)  LOOP
3784 		l_assignment_id     := cur_ass_id_rec.assignment_id;
3785 	    l_person_id         := cur_ass_id_rec.person_id;
3786 		EXIT;
3787 	END LOOP;
3788 	-- From history fetch the Assignment Information Details for the effective date
3789 	hr_utility.set_location('Eff. date in get_asg_step_or_rate ' || p_effective_date,25);
3790 	IF l_assignment_id IS NOT NULL THEN
3791 		ghr_history_fetch.fetch_asgei (
3792 			p_assignment_id     => l_assignment_id,
3793 			p_information_type  => 'GHR_US_ASG_SF52',
3794 			p_date_effective    => p_effective_date,
3795 			p_asg_ei_data       => l_asgei_data) ;
3796 		IF (l_asgei_data.assignment_extra_info_id IS NOT NULL) THEN
3797 			p_step_or_rate := l_asgei_data.aei_information3;
3798 
3799 		ELSE
3800 				ghr_history_api.get_g_session_var(l_session);
3801 			   Ghr_History_Fetch.Fetch_ASGEI_prior_root_sf50
3802 			   (
3803 				p_assignment_id         => l_assignment_id,
3804 				p_information_type      => 'GHR_US_ASG_SF52',
3805 				p_date_effective        => p_effective_date,
3806 				p_altered_pa_request_id => l_session.altered_pa_request_id,
3807 				p_noa_id_corrected      => l_session.noa_id_correct,
3808 				p_get_ovn_flag          => 'Y',
3809 				p_asgei_data            => l_asgei_data
3810 			   );
3811 				p_step_or_rate := l_asgei_data.aei_information3;
3812 		END IF;
3813 		IF l_asgei_data.aei_information6 = '5' then
3814 				p_prd  := '6';
3815 		ELSIF l_asgei_data.aei_information6 = '7' then
3816 			    p_prd  := '0';
3817 		ELSE
3818 			      p_prd  := l_asgei_data.aei_information6;
3819 				  hr_utility.set_location('Sun p_pay_rate_determinant' || p_prd,250);
3820 	    END IF;
3821 	END IF;
3822 
3823 END get_asg_step_or_rate;
3824 
3825 begin
3826 
3827       l_sf52_data := p_sf52_data ; --NOCOPY Changes
3828 
3829       hr_utility.set_location('Entering: ' || l_proc, 10);
3830       hr_utility.set_location('pay  Rate in the  beginning of Ref '|| p_sf52_data.pay_rate_determinant,11);
3831       hr_utility.set_location('To Pay Basis '|| p_sf52_data.to_pay_basis,11);
3832       hr_utility.set_location('Noa Family Code '|| p_sf52_data.noa_family_code,11);
3833 
3834 	ghr_history_api.get_g_session_var( l_session_var);
3835 	for c_rec in get_noa_info LOOP
3836 		l_first_noa_id 	:= c_rec.first_noa_id;
3837 		l_first_noa_code 	:= c_rec.first_noa_code;
3838 		l_noa_family_code := c_rec.noa_family_code;
3839         l_second_noa_id         := c_rec.second_noa_id;
3840         l_second_noa_code       := c_rec.second_noa_code;
3841         -- Reverted FWFA Changes Bug#4444609 Consider input PRD if not null
3842         l_prd             := c_rec.pay_rate_determinant;
3843         -- FWFA Changes
3844   end LOOP;
3845 -- Bug 2568188
3846 -- Fetch the process method for Position Title
3847       IF l_noa_family_code = 'CORRECT' THEN
3848         FOR pm_rec in get_to_posn_title_pm(l_second_noa_id) LOOP
3849           l_pm := pm_rec.process_method_code;
3850         END Loop;
3851       ELSE
3852         FOR pm_rec in get_to_posn_title_pm(l_first_noa_id) LOOP
3853           l_pm := pm_rec.process_method_code;
3854         END Loop;
3855       END IF;
3856 
3857 
3858 	l_from_position_id := p_sf52_data.from_position_id;
3859 	l_from_position_title := p_sf52_data.from_position_title;
3860 
3861 	l_assignment_id := p_sf52_data.employee_assignment_id;
3862         If l_noa_family_code <> 'APP' THEN
3863 	    GHR_API.sf52_from_data_elements(
3864 		     p_person_id         => p_person_id
3865             ,p_assignment_id     => l_assignment_id
3866             ,p_effective_date    => nvl(p_effective_date, trunc(sysdate))
3867             ,p_altered_pa_request_id => l_session_var.altered_pa_request_id
3868             ,p_noa_id_corrected  => l_session_var.noa_id_correct
3869 		    ,p_pa_history_id     => l_session_var.pa_history_id
3870             ,p_position_id       => l_position_id
3871             ,p_position_title    => l_position_title
3872             ,p_position_number   => l_position_number
3873             ,p_position_seq_no   => l_position_seq_no
3874             ,p_pay_plan          => l_pay_plan
3875             ,p_job_id            => l_job_id
3876             ,p_occ_code          => l_occ_code
3877             ,p_grade_id          => l_grade_id
3878             ,p_grade_or_level    => l_grade_or_level
3879             ,p_step_or_rate      => l_step_or_rate
3880             ,p_total_salary      => l_total_salary
3881             ,p_pay_basis         => l_pay_basis
3882 	    -- FWFA Changes Bug#4444609
3883 	       ,p_pay_table_identifier => l_pay_table_identifier
3884 	    -- FWFA Changes
3885             ,p_basic_pay         => l_basic_pay
3886             ,p_locality_adj      => l_locality_adj
3887             ,p_adj_basic_pay     => l_adj_basic_pay
3888             ,p_other_pay         => l_other_pay
3889             ,p_au_overtime                 => l_au_overtime
3890             ,p_auo_premium_pay_indicator   => l_auo_premium_pay_indicator
3891             ,p_availability_pay            => l_availability_pay
3892             ,p_ap_premium_pay_indicator    => l_ap_premium_pay_indicator
3893             ,p_retention_allowance         => l_retention_allowance
3894             ,p_retention_allow_percentage  => l_retention_allow_percentage
3895             ,p_supervisory_differential    => l_supervisory_differential
3896             ,p_supervisory_diff_percentage => l_supervisory_diff_percentage
3897             ,p_staffing_differential       => l_staffing_differential
3898             ,p_staffing_diff_percentage  => l_staffing_diff_percentage
3899             ,p_organization_id           => l_organization_id
3900             ,p_position_org_line1        => l_position_org_line1
3901             ,p_position_org_line2        => l_position_org_line2
3902             ,p_position_org_line3        => l_position_org_line3
3903             ,p_position_org_line4        => l_position_org_line4
3904             ,p_position_org_line5        => l_position_org_line5
3905             ,p_position_org_line6        => l_position_org_line6
3906             ,p_duty_station_location_id  => l_location_id
3907             ,p_pay_rate_determinant      => l_dummy_varchar
3908             ,p_work_schedule             => l_dummy_varchar
3909 
3910 	);
3911 
3912         l_capped_other_pay := ghr_pa_requests_pkg2.get_cop(l_assignment_id,
3913                                                           nvl(p_effective_date, trunc(sysdate)));
3914 
3915 	if (p_derive_to_cols) then
3916 		p_sf52_data.to_organization_id		:= 	l_organization_id;
3917 		p_sf52_data.to_grade_id				:= 	l_grade_id;
3918 		p_sf52_data.to_job_id				:=	l_job_id;
3919 		p_sf52_data.to_ap_premium_pay_indicator	:= 	l_ap_premium_pay_indicator;
3920 		p_sf52_data.to_auo_premium_pay_indicator	:= 	l_auo_premium_pay_indicator;
3921 		p_sf52_data.to_au_overtime			:= 	l_au_overtime;
3922 		p_sf52_data.to_availability_pay		:= 	l_availability_pay;
3923 		p_sf52_data.to_supervisory_differential	:= 	l_supervisory_differential;
3924 		p_sf52_data.to_supervisory_diff_percentage	:= 	l_supervisory_diff_percentage;
3925 		p_sf52_data.to_staffing_differential	:= 	l_staffing_differential;
3926 		p_sf52_data.to_staffing_diff_percentage:= 	l_staffing_diff_percentage;
3927 		p_sf52_data.to_retention_allowance		:= 	l_retention_allowance;
3928 		p_sf52_data.to_retention_allow_percentage		:= 	l_retention_allow_percentage;
3929 		return;
3930 	end if;
3931 --      p_from_location_id     		     := l_location_id;
3932       p_sf52_data.duty_station_location_id    := l_location_id;
3933       p_sf52_data.from_position_title    := l_position_title;
3934       p_sf52_data.from_position_number   := l_position_number;
3935       p_sf52_data.from_position_id   	:= l_position_id;
3936       p_sf52_data.from_position_seq_no   := l_position_seq_no;
3937       p_sf52_data.from_pay_plan          := l_pay_plan;
3938       p_sf52_data.employee_assignment_id := l_assignment_id;
3939       p_sf52_data.from_occ_code          := l_occ_code;
3940       p_sf52_data.from_grade_or_level    := l_grade_or_level;
3941       p_sf52_data.from_step_or_rate      := l_step_or_rate;
3942       p_sf52_data.from_total_salary      := l_total_salary;
3943       p_sf52_data.from_pay_basis         := l_pay_basis;
3944       -- FWFA Changes Bug#4444609
3945       p_sf52_data.from_pay_table_identifier := l_pay_table_identifier;
3946       -- FWFA Changes
3947       p_sf52_data.from_basic_pay         := l_basic_pay;
3948       p_sf52_data.from_locality_adj      := l_locality_adj;
3949       p_sf52_data.from_adj_basic_pay     := l_adj_basic_pay;
3950       p_sf52_data.from_other_pay_amount  := nvl(l_capped_other_pay,l_other_pay);
3951 -- Following commented items are not pa_request fields.
3952 --      p_sf52_data.from_job_id            := l_job_id;
3953 --      p_sf52_data.from_grade_id          := l_grade_id;
3954 --      p_sf52_data.from_au_overtime               := l_au_overtime;
3955 --      p_sf52_data.from_auo_premium_pay_indicator := l_auo_premium_pay_indicator;
3956 --      p_sf52_data.from_availability_pay          := l_availability_pay;
3957 --      p_sf52_data.from_ap_premium_pay_indicator  := l_ap_premium_pay_indicator;
3958 --      p_sf52_data.from_retention_allowance       := l_retention_allowance;
3959 --      p_sf52_data.from_retention_allow_percentage := l_retention_allow_percentage;
3960 --      p_sf52_data.from_supervisory_differential  := l_supervisory_differential;
3961 --      p_sf52_data.from_supervisory_diff_percentage  := l_supervisory_diff_percentage;
3962 --      p_sf52_data.from_staffing_differential     := l_staffing_differential;
3963 --      p_sf52_data.from_staffing_diff_percentage     := l_staffing_diff_percentage;
3964 --      p_sf52_data.from_organization_id    := l_organization_id;
3965      END IF;
3966       if (l_noa_family_code = 'APP') then
3967 		p_sf52_data.from_position_org_line1 := ghr_pa_requests_pkg2.get_agency_code_from(
3968 									p_pa_request_id	=>	p_sf52_data.pa_request_id,
3969 									p_noa_id		=>    l_first_noa_id);
3970 	else
3971       	p_sf52_data.from_position_org_line1 := l_position_org_line1;
3972 	end if;
3973       p_sf52_data.from_position_org_line2 := l_position_org_line2;
3974       p_sf52_data.from_position_org_line3 := l_position_org_line3;
3975       p_sf52_data.from_position_org_line4 := l_position_org_line4;
3976       p_sf52_data.from_position_org_line5 := l_position_org_line5;
3977       p_sf52_data.from_position_org_line6 := l_position_org_line6;
3978 
3979 
3980 	l_agency_code := ghr_api.get_position_agency_code(
3981 				p_person_id		=>	p_person_id,
3982 				p_assignment_id	=>	l_assignment_id,
3983 				p_effective_date	=>	p_effective_date);
3984 	p_sf52_data.from_agency_desc := ghr_pa_requests_pkg.get_lookup_meaning(800
3985                                              ,'GHR_US_AGENCY_CODE'
3986                                              ,l_agency_code);
3987 	p_sf52_data.agency_code			:= l_agency_code;
3988 	-- ????? is this the right from agency code?
3989 	p_sf52_data.from_agency_code		:= l_agency_code;
3990 	p_sf52_data.from_office_symbol	:=	l_office_symbol;
3991 
3992 	if p_from_only then
3993 		return;
3994 	end if;
3995 	if (l_first_noa_code = '352') then
3996 		p_sf52_data.to_position_org_line1 :=
3997                    ghr_pa_requests_pkg2.get_agency_code_to(
3998 			p_pa_request_id	=> p_sf52_data.pa_request_id,
3999 			p_noa_id	=> l_first_noa_id);
4000         -- Added by ENUNEZ (23-FEB-2000 bug# 756335)
4001         elsif (l_first_noa_code = '002' and l_second_noa_code = '352') then
4002 		p_sf52_data.to_position_org_line1 :=
4003                    ghr_pa_requests_pkg2.get_agency_code_to(
4004 			p_pa_request_id	=> p_sf52_data.pa_request_id,
4005 			p_noa_id	=> l_second_noa_id);
4006 	end if;
4007 
4008 	if (p_from_only = FALSE) then
4009 
4010 		-- Following other_pay related fields are copied into to_.. fields
4011 		-- because pay_calc is not performed for other_pay family. So by using from
4012 		-- values we can place refreshed values into to_other...fields.
4013                 -- Venkat 04/04/00
4014                 -- Bug # 1239688
4015                 -- Initialization of all the varibles related to Other Pay in the case of Conversion of Ex Employee
4016                 FOR per_type  in get_person_type  LOOP
4017                   l_per_type := per_type.system_person_type;
4018                 END LOOP;
4019                 IF l_noa_family_code = 'CONV_APP' and nvl(l_per_type,hr_api.g_varchar2) = 'EX_EMP' then
4020 		  p_sf52_data.to_retention_allowance		:= NULL;
4021 		  p_sf52_data.to_retention_allow_percentage	:= NULL;
4022 		  p_sf52_data.to_staffing_differential	:= NULL;
4023 		  p_sf52_data.to_staffing_diff_percentage	:= NULL;
4024 		  p_sf52_data.to_supervisory_differential	:= NULL;
4025 		  p_sf52_data.to_supervisory_diff_percentage:= NULL;
4026 		  p_sf52_data.to_ap_premium_pay_indicator   := NULL;
4027 		  p_sf52_data.to_auo_premium_pay_indicator  := NULL;
4028 		  p_sf52_data.to_au_overtime                :=NULL;
4029 		  p_sf52_data.to_availability_pay           := NULL;
4030 		  p_sf52_data.to_other_pay_amount           := NULL;
4031                 ELSE
4032 		  p_sf52_data.to_retention_allowance		:= l_retention_allowance;
4033 		  p_sf52_data.to_retention_allow_percentage	:= l_retention_allow_percentage;
4034 		  p_sf52_data.to_staffing_differential	:= l_staffing_differential;
4035 		  p_sf52_data.to_staffing_diff_percentage	:= l_staffing_diff_percentage;
4036 
4037 		  ----------------------- modified as part of bug #2347244
4038 		   IF (p_sf52_data.first_noa_code  not in ('892','893')) then
4039                      p_sf52_data.to_supervisory_differential	:= l_supervisory_differential;
4040 		  END IF;
4041 
4042 		   p_sf52_data.to_supervisory_diff_percentage:= l_supervisory_diff_percentage;
4043 		  p_sf52_data.to_ap_premium_pay_indicator   := l_ap_premium_pay_indicator;
4044 		  p_sf52_data.to_auo_premium_pay_indicator  := l_auo_premium_pay_indicator;
4045 		  p_sf52_data.to_au_overtime                := l_au_overtime;
4046 		  p_sf52_data.to_availability_pay           := l_availability_pay ;
4047 		  p_sf52_data.to_other_pay_amount           := l_other_pay;
4048                 END IF;
4049 	        hr_utility.set_location('l_from_position_id is  ' ||l_from_position_id, 11);
4050 	        hr_utility.set_location('from_position_id is  ' ||p_sf52_data.from_position_id, 12);
4051 	        hr_utility.set_location('to_position_id is  ' ||p_sf52_data.to_position_id, 13);
4052 	        hr_utility.set_location('to_basic_pay is  ' ||p_sf52_data.to_basic_pay, 14);
4053 		if (nvl(l_from_position_id, -1) <> nvl(p_sf52_data.from_position_id, -1) and
4054                     nvl(l_from_position_id, -1)  = nvl(p_sf52_data.to_position_id, -2))  then
4055 		-- ie from and to position were same and
4056                 -- from position has been changed because of refresh.
4057 
4058                 -- Reverting changes made in Bug # 757932
4059 		-- if nvl(l_from_position_id, -1) = nvl(p_sf52_data.to_position_id, -2)   then
4060 		-- from and to position were same.
4061 
4062 	        hr_utility.set_location('Case 1 ', 15);
4063 
4064 			p_sf52_data.to_adj_basic_pay              := l_adj_basic_pay;
4065 			p_sf52_data.to_basic_pay                  := l_basic_pay;
4066 			p_sf52_data.to_grade_id                   := l_grade_id;
4067 			p_sf52_data.to_grade_or_level             := l_grade_or_level;
4068 			p_sf52_data.to_job_id                     := l_job_id;
4069 			p_sf52_data.to_locality_adj               := l_locality_adj;
4070 			p_sf52_data.to_occ_code                   := l_occ_code;
4071 			p_sf52_data.to_office_symbol              := l_office_symbol;
4072 			p_sf52_data.to_organization_id            := l_organization_id;
4073 			p_sf52_data.to_pay_basis                  := l_pay_basis;
4074 			p_sf52_data.to_pay_plan                   := l_pay_plan;
4075 			if (l_first_noa_code = '352') then
4076                 	  p_sf52_data.to_position_org_line1 :=
4077                              ghr_pa_requests_pkg2.get_agency_code_to(
4078                		       p_pa_request_id => p_sf52_data.pa_request_id,
4079                 	       p_noa_id	=> l_first_noa_id);
4080                         -- Added by ENUNEZ (23-FEB-2000 bug# 756335)
4081                         elsif (l_first_noa_code = '002' and l_second_noa_code = '352') then
4082                 	  p_sf52_data.to_position_org_line1 :=
4083                              ghr_pa_requests_pkg2.get_agency_code_to(
4084                		       p_pa_request_id => p_sf52_data.pa_request_id,
4085                 	       p_noa_id	=> l_second_noa_id);
4086 			else
4087 				p_sf52_data.to_position_org_line1         := l_position_org_line1;
4088 			end if;
4089 			p_sf52_data.to_position_org_line2      := l_position_org_line2;
4090 			p_sf52_data.to_position_org_line3      := l_position_org_line3;
4091 			p_sf52_data.to_position_org_line4      := l_position_org_line4;
4092 			p_sf52_data.to_position_org_line5      := l_position_org_line5;
4093 			p_sf52_data.to_position_org_line6      := l_position_org_line6;
4094 			p_sf52_data.to_position_number         := l_position_number;
4095 			p_sf52_data.to_position_seq_no	       := l_position_seq_no;
4096 			p_sf52_data.to_position_title	       := l_position_title;
4097 			p_sf52_data.to_step_or_rate	       := l_step_or_rate;
4098 			p_sf52_data.to_total_salary	       := l_total_salary;
4099                         IF l_pm in ('AP') then
4100                           p_sf52_data.to_position_id           := l_from_position_id;
4101                           p_sf52_data.to_position_title        := l_from_position_title;
4102                         ELSE
4103                           p_sf52_data.to_position_id           := p_sf52_data.from_position_id;
4104                           p_sf52_data.to_position_title        := p_sf52_data.from_position_title
4105 ;
4106                         END IF;
4107                 -- Start Bug 1310894
4108 		elsif nvl(l_from_position_id, -1) = nvl(p_sf52_data.to_position_id, -2)
4109                       and l_noa_family_code = 'OTHER_PAY'   then
4110 	        hr_utility.set_location('Case 2 ', 15);
4111 			-- Other Pay action and From and To Position were same.
4112 			p_sf52_data.to_adj_basic_pay            := l_adj_basic_pay;
4113 			p_sf52_data.to_basic_pay                := l_basic_pay;
4114 			p_sf52_data.to_grade_id                 := l_grade_id;
4115 			p_sf52_data.to_grade_or_level           := l_grade_or_level;
4116 			p_sf52_data.to_job_id                   := l_job_id;
4117 			p_sf52_data.to_locality_adj             := l_locality_adj;
4118 			p_sf52_data.to_occ_code                 := l_occ_code;
4119 			p_sf52_data.to_office_symbol            := l_office_symbol;
4120 			p_sf52_data.to_organization_id          := l_organization_id;
4121 			p_sf52_data.to_pay_basis                := l_pay_basis;
4122 			p_sf52_data.to_pay_plan                 := l_pay_plan;
4123 			p_sf52_data.to_position_org_line1       := l_position_org_line1;
4124 			p_sf52_data.to_position_org_line2       := l_position_org_line2;
4125 			p_sf52_data.to_position_org_line3       := l_position_org_line3;
4126 			p_sf52_data.to_position_org_line4       := l_position_org_line4;
4127 			p_sf52_data.to_position_org_line5       := l_position_org_line5;
4128 			p_sf52_data.to_position_org_line6       := l_position_org_line6;
4129 			p_sf52_data.to_position_number          := l_position_number;
4130 			p_sf52_data.to_position_seq_no		:= l_position_seq_no;
4131 			p_sf52_data.to_position_title		:= l_position_title;
4132 			p_sf52_data.to_step_or_rate		:= l_step_or_rate;
4133 			--p_sf52_data.to_total_salary		:= l_total_salary;
4134 			p_sf52_data.to_position_id 		:= p_sf52_data.from_position_id;
4135 			p_sf52_data.to_position_title		:= p_sf52_data.from_position_title;
4136                 -- End Bug 1310894
4137 		elsif p_sf52_data.to_position_id is not NULL then
4138 			-- User has entered to_position
4139                 	hr_utility.set_location('Case 3 ', 15);
4140 			l_position_id := p_sf52_data.to_position_id;
4141 
4142 			-- get to_position columns
4143 				-- Bug 2112935 Sundar
4144 				-- For Retro 866 and 740, need to pass initial PRD as null.
4145 				-- Call determine_ia to Find out Retro NOAs.
4146 				hr_utility.set_location('l_session_var.altered_pa_request_id ' || l_session_var.altered_pa_request_id ,15);
4147 
4148 					FOR l_orig_rec IN c_orig_rec(l_session_var.altered_pa_request_id) LOOP
4149 					   l_orig_pa_request_id := l_orig_rec.pa_request_id;
4150 					   l_orig_pa_notification_id := l_orig_rec.pa_notification_id;
4151 					   l_orig_person_id := l_orig_rec.person_id;
4152 					   l_orig_effective_date := l_orig_rec.effective_date;
4153 					   --Bug # 8303159 added for dual actions
4154 					   l_orig_first_noa := l_orig_rec.first_noa_code;
4155 					   l_orig_second_noa := l_orig_rec.second_noa_code;
4156 					END LOOP;
4157 	      			    --BUG #7216635 added the parameter p_noa_id_correct
4158 					GHR_APPROVED_PA_REQUESTS.determine_ia(
4159 								 p_pa_request_id => l_orig_pa_request_id,
4160 								 p_pa_notification_id => l_orig_pa_notification_id,
4161 								 p_person_id      => l_orig_person_id,
4162 								 p_effective_date => nvl(l_orig_effective_date, trunc(sysdate)),
4163 								 p_noa_id_correct => l_session_var.noa_id_correct,
4164 								 p_retro_eff_date => l_effective_date,
4165 								 p_retro_pa_request_id => l_retro_pa_request_id,
4166 								 p_retro_first_noa => l_retro_first_noa,
4167 								 p_retro_second_noa => l_retro_second_noa);
4168 					hr_utility.set_location('Retro 1st NOA ' || l_retro_first_noa ,15);
4169 					hr_utility.set_location('Retro 2nd NOA ' || l_retro_second_noa ,15);
4170 
4171                                         -- 8303159 For dual actions with 740 combination if first noa code is 740 need to
4172 					-- consider it is as retro NOA
4173 				       IF l_session_var.altered_pa_request_id is not null and l_orig_second_noa is not null
4174 					   and l_orig_first_noa = '740' then
4175 					  for rec_chk_corr in chk_sec_corr
4176 					  loop
4177 					   l_retro_first_noa := '740';
4178 					   for rec_prd in get_740_prd
4179 					   loop
4180 					      p_sf52_data.pay_rate_determinant := rec_prd.pay_rate_determinant;
4181 					   end loop;
4182 					  end loop;
4183 					END IF;
4184 
4185 
4186 					IF ((l_retro_first_noa = '866' OR l_retro_second_noa = '866') OR
4187 						(l_retro_first_noa = '740' OR l_retro_second_noa = '740')) THEN
4188 							NULL;
4189 					ELSE
4190 					         hr_utility.set_location('FWFA prd :'||l_prd,80);
4191 						hr_utility.set_location('FWFA refresh prd :'||p_sf52_data.pay_rate_determinant,90);
4192 						--Begin Bug# 14047036, 13587903
4193 						IF l_noa_family_code = 'CORRECT' THEN
4194 							FOR l_get_prd_pm IN get_prd_pm(l_second_noa_id) LOOP
4195 							  l_prd_pm := l_get_prd_pm.process_method_code;
4196 							END LOOP;
4197 						 ELSIF l_second_noa_id IS NULL THEN
4198 						    FOR l_get_prd_pm IN get_prd_pm(l_first_noa_id) LOOP
4199 							  l_prd_pm := l_get_prd_pm.process_method_code;
4200 							END LOOP;
4201 						 END IF;
4202 						 hr_utility.set_location('PRD Process Method :'|| l_prd_pm,92);
4203 						--End Bug# 14047036, 13587903
4204 						--Bug# 13587903 added RPA prd not null condition to get the PRD from assginment
4205 						 IF l_prd IS NOT NULL AND l_prd_pm NOT IN ('AP') AND --Bug# 13587903
4206 							l_prd <>  nvl(p_sf52_data.pay_rate_determinant,hr_api.g_varchar2) then
4207 							p_sf52_data.pay_rate_determinant := l_prd;
4208 						 END IF;
4209 						 hr_utility.set_location('p_sf52_data.to_position_id'||p_sf52_data.to_position_id,10);
4210         					 hr_utility.set_location('p_sf52_data.from_position_id'||p_sf52_data.from_position_id,11);
4211   					         --6850492
4212    					           get_asg_step_or_rate(p_sf52_data.to_position_id,p_sf52_data.effective_date,l_step_or_rate1,l_prd1);
4213 					         --6850492
4214 					         hr_utility.set_location('l_prd1'||l_prd1,10);
4215      					         hr_utility.set_location('l_step_or_rate1'||l_step_or_rate1,12);
4216 
4217 					        -- Added to compare step or rate with '00' for dual actions
4218 					         IF l_step_or_rate1 IS NOT NULL AND
4219 						    l_step_or_rate1 <>  nvl(p_sf52_data.to_step_or_rate,hr_api.g_varchar2) AND
4220 						    p_sf52_data.to_step_or_rate <> '00' then
4221 						   p_sf52_data.to_step_or_rate := l_step_or_rate1;
4222         				         END IF;
4223 
4224 						--For Dual combination with Return to Duty PRD need to be considered prior to root sf50
4225 						 IF (p_sf52_data.pay_rate_determinant IS NULL)  THEN
4226 				                    p_sf52_data.pay_rate_determinant := l_prd1;
4227 		                  		 END IF;
4228 					         -- end if
4229 
4230 					         --6850492
4231 					END IF;
4232              hr_utility.set_location('bef  call to to_data PRD ' || p_sf52_data.pay_rate_determinant ,15);
4233              hr_utility.set_location('bef  call to to_data pay BAsis ' || p_sf52_data.to_pay_basis ,15);
4234 			ghr_pa_requests_pkg.get_sf52_to_data_elements
4235                       (p_position_id               => p_sf52_data.to_position_id
4236                       ,p_effective_date            => p_sf52_data.effective_date
4237                       ,p_prd                       => p_sf52_data.pay_rate_determinant
4238                       ,p_grade_id                  => l_grade_id
4239                       ,p_job_id                    => l_job_id
4240                       ,p_location_id               => l_location_id
4241                       ,p_organization_id           => l_organization_id
4242                       ,p_pay_plan                  => l_pay_plan
4243                       ,p_occ_code                  => l_occ_code
4244                       ,p_grade_or_level            => l_grade_or_level
4245                       ,p_pay_basis                 => l_pay_basis
4246                       ,p_position_org_line1        => l_position_org_line1
4247                       ,p_position_org_line2        => l_position_org_line2
4248                       ,p_position_org_line3        => l_position_org_line3
4249                       ,p_position_org_line4        => l_position_org_line4
4250                       ,p_position_org_line5        => l_position_org_line5
4251                       ,p_position_org_line6        => l_position_org_line6
4252                       ,p_duty_station_id           => l_duty_station_id
4253                       );
4254              hr_utility.set_location('After  call to to_data PRD ' || p_sf52_data.pay_rate_determinant ,15);
4255 
4256 
4257                        --Added 855 for bug 3617311
4258 		       --6850492 added 713 to compare for dual actions as 713 can be performed as a second action
4259 		       --Bug# 7690029 added NVL to l_second_noa_code
4260                       IF ( l_first_noa_code <> '713' and  NVL(l_second_noa_code,'$$$') <> '713'  AND l_first_noa_code <> '855'
4261 		          AND NVL(l_second_noa_code,'$$$') <> '855' ) THEN
4262 			p_sf52_data.to_grade_id                   := l_grade_id;
4263 			p_sf52_data.to_grade_or_level             := l_grade_or_level;
4264 			p_sf52_data.to_pay_plan                   := l_pay_plan;
4265                       END IF;
4266 			p_sf52_data.to_job_id                    	:= l_job_id;
4267 			p_sf52_data.to_occ_code                   := l_occ_code;
4268 			p_sf52_data.to_organization_id            := l_organization_id;
4269 --			p_sf52_data.to_other_pay_amount           := l_other_pay;
4270 			p_sf52_data.to_pay_basis                  := l_pay_basis;
4271 			-- vsm : commented following stmt. May have an impact. Need to test refresh
4272 			-- dkk : put following statement back in. See BUG # 741064.
4273 			IF ((l_retro_first_noa = '866' OR l_retro_second_noa = '866') OR
4274 						(l_retro_first_noa = '740' OR l_retro_second_noa = '740')) THEN
4275 
4276 			       --6973711
4277 			       IF l_session_var.noa_id_correct is not null and l_noa_family_code = 'RETURN_TO_DUTY' then
4278  			          IF (p_sf52_data.pay_rate_determinant IS NULL) THEN
4279     				    p_sf52_data.pay_rate_determinant := l_prd;
4280 				  END IF;
4281 			       END IF;
4282 			       --6973711
4283 				-- Get PRD, Step or rate from Asg DDF.
4284 				get_asg_step_or_rate(p_sf52_data.to_position_id,p_sf52_data.effective_date,l_step_or_rate,l_prd);
4285 				IF (p_sf52_data.to_step_or_rate IS NULL) THEN
4286 					p_sf52_data.to_step_or_rate	:= l_step_or_rate;
4287 				END IF;
4288 				IF (p_sf52_data.pay_rate_determinant IS NULL) THEN
4289 					p_sf52_data.pay_rate_determinant := l_prd;
4290 				END IF;
4291 			ELSE
4292 			-- Bug 2112935
4293 				IF (p_sf52_data.to_step_or_rate IS NULL) THEN
4294   			            p_sf52_data.to_step_or_rate			:= l_step_or_rate;
4295   			        END IF;
4296 			END IF;
4297 
4298               hr_utility.set_location('aft  call to to_data pay BAsis ' || p_sf52_data.to_pay_basis ,16);
4299               if nvl(p_sf52_data.pay_rate_determinant,hr_api.g_varchar2) in  ('A','B','E','F','U','V') then
4300 
4301 ----Temp Promo Changes by AVR 03-JUN-2000--Start---
4302 
4303                  if nvl(p_sf52_data.pay_rate_determinant,hr_api.g_varchar2) in  ('A','B','E','F') AND
4304                     ghr_pa_requests_pkg.temp_step_true(p_sf52_data.pa_request_id) THEN
4305                          ghr_history_fetch.fetch_positionei(
4306                               p_position_id      => p_sf52_data.to_position_id,
4307                               p_information_type => 'GHR_US_POS_VALID_GRADE',
4308                               p_date_effective   => p_sf52_data.effective_date,
4309                               p_pos_ei_data      => l_pos_ei_grade_data);
4310 
4311                     p_sf52_data.to_pay_basis := l_pos_ei_grade_data.poei_information6;
4312                  else
4313 ----Temp Promo Changes by AVR 03-JUN-2000--End---
4314 
4315                      p_sf52_data.to_pay_basis  := ghr_pa_requests_pkg.get_upd34_pay_basis
4316                             (p_person_id  =>  p_person_id,
4317                             p_position_id =>  p_sf52_data.to_position_id,
4318                             p_prd         =>  p_sf52_data.pay_rate_determinant,
4319                             p_pa_request_id =>  p_sf52_data.pa_request_id,
4320                             p_effective_date =>  p_sf52_data.effective_date);
4321                  end if;
4322               hr_utility.set_location('aft  call to upda 34 pay BAsis ' || p_sf52_data.to_pay_basis ,1);
4323               end  if;
4324               hr_utility.set_location('aft  call to upda 34 pay BAsis outside if '
4325                                                                  || p_sf52_data.to_pay_basis ,1);
4326 
4327 			if (l_first_noa_code = '352') then
4328                 	  p_sf52_data.to_position_org_line1 :=
4329                              ghr_pa_requests_pkg2.get_agency_code_to(
4330                 	       p_pa_request_id	=> p_sf52_data.pa_request_id,
4331                 	       p_noa_id	=> l_first_noa_id);
4332                         -- Added by ENUNEZ (23-FEB-2000 bug# 756335)
4333                         elsif (l_first_noa_code = '002' and l_second_noa_code = '352') then
4334                 	  p_sf52_data.to_position_org_line1 :=
4335                              ghr_pa_requests_pkg2.get_agency_code_to(
4336                 	       p_pa_request_id	=> p_sf52_data.pa_request_id,
4337                 	       p_noa_id	=> l_second_noa_id);
4338 			else
4339 				p_sf52_data.to_position_org_line1         := l_position_org_line1;
4340 			end if;
4341 			p_sf52_data.to_position_org_line1         := l_position_org_line1;
4342 			p_sf52_data.to_position_org_line2         := l_position_org_line2;
4343 			p_sf52_data.to_position_org_line3         := l_position_org_line3;
4344 			p_sf52_data.to_position_org_line4         := l_position_org_line4;
4345 			p_sf52_data.to_position_org_line5         := l_position_org_line5;
4346 			p_sf52_data.to_position_org_line6         := l_position_org_line6;
4347 /*
4348 			p_sf52_data.to_position_number            := l_position_number;
4349 			p_sf52_data.to_position_seq_no		:= l_position_seq_no;
4350 			p_sf52_data.to_position_title			:= l_position_title;
4351 			p_sf52_data.to_retention_allowance		:= l_retention_allowance;
4352 			p_sf52_data.to_retention_allow_percentage	:= l_retention_allow_percentage;
4353 			p_sf52_data.to_staffing_differential	:= l_staffing_differential;
4354 			p_sf52_data.to_staffing_diff_percentage	:= l_staffing_diff_percentage;
4355 			p_sf52_data.to_supervisory_differential	:= l_supervisory_differential;
4356 			p_sf52_data.to_supervisory_diff_percentage:= l_supervisory_diff_percentage;
4357 */
4358 			open get_pos_bg ( P_sf52_data.to_position_id);
4359 			fetch get_pos_bg into l_business_group_id;
4360 			if get_pos_bg%notfound then
4361 				close get_pos_bg;
4362 				hr_utility.set_location ( l_proc || 'get_pos_bg not found ', 100);
4363 			      hr_utility.set_message(8301 , 'GHR_38415_BUSN_GRP_NOT_FOUND');
4364 			      hr_utility.raise_error;
4365 			else
4366 				close get_pos_bg;
4367 			end if;
4368 
4369 			p_sf52_data.to_position_number := ghr_api.get_position_desc_no_pos
4370 				(p_position_id         => p_sf52_data.to_position_id
4371 				,p_business_group_id   => l_business_group_id
4372                                 ,p_effective_date      => p_effective_date);
4373 
4374 			p_sf52_data.to_position_seq_no := ghr_api.get_position_sequence_no_pos
4375 				(p_position_id       => p_sf52_data.to_position_id
4376 				,p_business_group_id => l_business_group_id
4377                                 ,p_effective_date      => p_effective_date);
4378 
4379 			p_sf52_data.to_position_title := ghr_api.get_position_title_pos
4380 				(p_position_id       => p_sf52_data.to_position_id
4381 				,p_business_group_id => l_business_group_id
4382                                 ,p_effective_date      => p_effective_date);
4383 
4384 -- JH DS starts populated from ASG.  Populate using To Position if To Posn PM is UE, or APUE and
4385 -- to_posn <> from posn.
4386 --
4387                   hr_utility.set_location('To Posn ID ' || p_sf52_data.to_position_id ,20);
4388                   IF p_sf52_data.to_position_id IS NOT NULL THEN
4389 /* l_pm value determined above
4390 	              FOR pm_rec in get_to_posn_title_pm LOOP
4391                       l_pm := pm_rec.process_method_code;
4392                     END Loop;
4393 */
4394                     hr_utility.set_location('To Posn PM ' || l_pm ,20);
4395                     IF l_pm = 'UE' THEN
4396 			    p_sf52_data.duty_station_location_id	:= l_location_id;
4397 			    p_sf52_data.duty_station_id           := l_duty_station_id;
4398                     ELSIF l_pm = 'APUE' and nvl(p_sf52_data.to_position_id,hr_api.g_number)
4399                       <> nvl(p_sf52_data.from_position_id,hr_api.g_number) THEN
4400 			    p_sf52_data.duty_station_location_id	:= l_location_id;
4401 			    p_sf52_data.duty_station_id           := l_duty_station_id;
4402                     END IF;
4403 			END IF;
4404 
4405 		end if;
4406 	end if;
4407 	-- If the refresh is for realignment then refresh position org. lines using the procedure
4408 	-- ghr_pa_requests_pkg.get_rei_org_lines
4409 	if p_sf52_data.first_noa_code = '790' or
4410 	   p_sf52_data.second_noa_code = '790' then
4411 		hr_utility.set_location('Realignment NOA: ' || l_proc, 410);
4412 		ghr_pa_requests_pkg.get_rei_org_lines(
4413 			P_PA_REQUEST_ID		=>	p_sf52_data.pa_request_id,
4414 			P_ORGANIZATION_ID		=>	l_organization_id,
4415 			P_POSITION_ORG_LINE1	=>	l_position_org_line1,
4416 			P_POSITION_ORG_LINE2	=>	l_position_org_line2,
4417 			P_POSITION_ORG_LINE3	=>	l_position_org_line3,
4418 			P_POSITION_ORG_LINE4	=>	l_position_org_line4,
4419 			P_POSITION_ORG_LINE5	=>	l_position_org_line5,
4420 			P_POSITION_ORG_LINE6	=>	l_position_org_line6
4421 		);
4422 		if l_organization_id is not NULL then
4423 			hr_utility.set_location('Realignment NOA Refreshed: ' || l_proc, 420);
4424 		      p_sf52_data.to_position_org_line1 := l_position_org_line1;
4425 		      p_sf52_data.to_position_org_line2 := l_position_org_line2;
4426 		      p_sf52_data.to_position_org_line3 := l_position_org_line3;
4427 		      p_sf52_data.to_position_org_line4 := l_position_org_line4;
4428 		      p_sf52_data.to_position_org_line5 := l_position_org_line5;
4429 		      p_sf52_data.to_position_org_line6 := l_position_org_line6;
4430 		else
4431 			hr_utility.set_location('Realignment NOA NOT Refreshed:  ' || l_proc, 430);
4432 		end if;
4433 	end if;
4434 
4435 	ghr_pa_requests_pkg.get_SF52_loc_ddf_details
4436      	               (p_location_id      => p_sf52_data.duty_station_location_id
4437            	         ,p_duty_station_id  => l_duty_station_id);
4438 
4439 	p_sf52_data.duty_station_id			:= l_duty_station_id;
4440 
4441        ghr_pa_requests_pkg.get_duty_station_details
4442       	        (p_duty_station_id	=> l_duty_station_id
4443 			  ,p_effective_date	=> p_sf52_data.effective_date
4444             	  ,p_duty_station_code	=> l_duty_station_code
4445 	              ,p_duty_station_desc	=> l_duty_station_desc);
4446 --    p_sf52_data.duty_station_location_id    := l_location_id;
4447 --	p_sf52_data.duty_station_id		:=	l_duty_station_id;
4448 	p_sf52_data.duty_station_code		:=	l_duty_station_code;
4449 	p_sf52_data.duty_station_desc		:=	l_duty_station_desc;
4450 
4451 	ghr_pa_requests_pkg.get_SF52_pos_ddf_details
4452 	     	            (p_position_id            => l_position_id
4453             	      ,p_date_effective         => p_effective_date
4454 	                  ,p_flsa_category          => l_flsa_category
4455       	            ,p_bargaining_unit_status => l_bargaining_unit_status
4456             	      ,p_work_schedule          => l_work_schedule
4457                   	,p_functional_class       => l_functional_class
4458 	                  ,p_supervisory_status     => l_supervisory_status
4459       	            ,p_position_occupied      => l_position_occupied
4460             	    	,p_appropriation_code1    => l_appropriation_code1
4461           	      	,p_appropriation_code2    => l_appropriation_code2
4462 			   	,p_personnel_office_id    => l_personnel_office_id
4463 			   	,p_office_symbol	     	  => l_office_symbol
4464       	     	      ,p_part_time_hours        => l_part_time_hours);
4465 
4466 	        hr_utility.set_location('l_work_schedule is  ' || l_work_schedule, 11);
4467 	if (not p_from_only) then
4468 	        hr_utility.set_location('l_work_schedule is  ' || l_work_schedule, 12);
4469 			p_sf52_data.flsa_category	 	:=	l_flsa_category  ;
4470 			p_sf52_data.bargaining_unit_status	:=	l_bargaining_unit_status;
4471 			p_sf52_data.work_schedule		:=	l_work_schedule;
4472 			p_sf52_data.functional_class	 	:=	l_functional_class  ;
4473 			p_sf52_data.supervisory_status 	:=	l_supervisory_status ;
4474 			p_sf52_data.position_occupied		:=	l_position_occupied;
4475 			p_sf52_data.appropriation_code1	:=	l_appropriation_code1;
4476 			p_sf52_data.appropriation_code2	:=	l_appropriation_code2;
4477 			p_sf52_data.personnel_office_id	:=	l_personnel_office_id;
4478 			p_sf52_data.part_time_hours		:=	l_part_time_hours;
4479 
4480 			p_sf52_data.work_schedule_desc := ghr_pa_requests_pkg.get_lookup_meaning(800
4481 	      	                                       ,'GHR_US_WORK_SCHEDULE'
4482 		                                             ,l_work_schedule);
4483 	end if;
4484 	        hr_utility.set_location('l_work_schedule_desc is  ' || p_sf52_data.work_schedule_desc, 13);
4485 	if (p_from_only = FALSE) then
4486 		ghr_history_fetch.fetch_people(
4487 			p_person_id				=> p_person_id,
4488 			p_date_effective			=> p_effective_date,
4489 			p_altered_pa_request_id		=> l_session_var.altered_pa_request_id,
4490 			p_noa_id_corrected		=> l_session_var.noa_id_correct,
4491 			p_pa_history_id			=> l_session_var.pa_history_id,
4492 			p_people_data			=> l_people_data,
4493 			p_result_code			=> l_result_code
4494 		);
4495 		if (l_result_code is not null) then
4496 			hr_utility.set_location(l_proc || 'non-null result_code', 910);
4497 		end if;
4498 
4499 		p_sf52_data.employee_national_identifier	:=	l_people_data.national_identifier;
4500 		p_sf52_data.employee_date_of_birth	:=	l_people_data.date_of_birth;
4501 		p_sf52_data.employee_first_name	:=	l_people_data.first_name;
4502 		p_sf52_data.employee_last_name	:=	l_people_data.last_name;
4503 		p_sf52_data.employee_middle_names	:=	l_people_data.middle_names;
4504 
4505 /*
4506 	  	FOR cur_per_rec IN cur_per LOOP
4507     			l_national_identifier := cur_per_rec.national_identifier;
4508     			l_date_of_birth       := cur_per_rec.date_of_birth;
4509 			l_employee_first_name := cur_per_rec.first_name;
4510 			l_employee_last_name  := cur_per_rec.last_name;
4511 			l_employee_middle_names:= cur_per_rec.middle_names;
4512 	  	END LOOP;
4513 		p_sf52_data.employee_national_identifier	:=	l_national_identifier;
4514 		p_sf52_data.employee_date_of_birth	:=	l_date_of_birth;
4515 		p_sf52_data.employee_first_name	:=	l_employee_first_name;
4516 		p_sf52_data.employee_last_name	:=	l_employee_last_name;
4517 		p_sf52_data.employee_middle_names	:=	l_employee_middle_names;
4518 */
4519 	    	ghr_pa_requests_pkg.get_SF52_person_ddf_details
4520      	                (p_person_id             => p_person_id
4521      	                ,p_date_effective        => p_effective_date
4522      	                ,p_citizenship           => l_citizenship
4523      	                ,p_veterans_preference   => l_veterans_preference
4524      	                ,p_veterans_pref_for_rif => l_veterans_pref_for_rif
4525      	                ,p_veterans_status       => l_veterans_status
4526      	                ,p_scd_leave             => l_service_comp_date);
4527 
4528 		p_sf52_data.citizenship			:=	l_citizenship;
4529 		p_sf52_data.veterans_preference	        :=	l_veterans_preference;
4530 		p_sf52_data.veterans_pref_for_rif	:=	l_veterans_pref_for_rif;
4531 		p_sf52_data.veterans_status		:=	l_veterans_status;
4532 		p_sf52_data.service_comp_date		:=	fnd_date.canonical_to_date(l_service_comp_date);
4533 --, 'YYYY/MM/DD HH24:MI:SS');
4534 
4535 		ghr_api.return_education_details(
4536 			p_person_id            => p_person_id
4537                  ,p_effective_date       => p_effective_date
4538                  ,p_education_level      => l_education_level
4539                  ,p_academic_discipline  => l_academic_discipline
4540                  ,p_year_degree_attained => l_year_degree_attained);
4541 		p_sf52_data.education_level		:=	l_education_level;
4542 		p_sf52_data.academic_discipline	:=	l_academic_discipline;
4543 		p_sf52_data.year_degree_attained	:=	l_year_degree_attained;
4544 
4545 	      ghr_pa_requests_pkg.get_address_details
4546                        (p_person_id            => p_person_id
4547                        ,p_effective_date       => p_effective_date
4548                        ,p_address_line1        => l_forwarding_address_line1
4549                        ,p_address_line2        => l_forwarding_address_line2
4550                        ,p_address_line3        => l_forwarding_address_line3
4551                        ,p_town_or_city         => l_forwarding_town_or_city
4552                        ,p_region_2             => l_forwarding_region_2
4553                        ,p_postal_code          => l_forwarding_postal_code
4554                        ,p_country              => l_forwarding_country
4555                        ,p_territory_short_name => l_forwarding_country_short_na);
4556 
4557 		p_sf52_data.forwarding_address_line1:=	l_forwarding_address_line1;
4558 		p_sf52_data.forwarding_address_line2:=	l_forwarding_address_line2;
4559 		p_sf52_data.forwarding_address_line3:=	l_forwarding_address_line3;
4560 		p_sf52_data.forwarding_town_or_city	:=	l_forwarding_town_or_city;
4561 		p_sf52_data.forwarding_region_2	:=	l_forwarding_region_2;
4562 		p_sf52_data.forwarding_postal_code 	:=	l_forwarding_postal_code ;
4563 		p_sf52_data.forwarding_country	:=	l_forwarding_country;
4564 		p_sf52_data.forwarding_country_short_name	:=	l_forwarding_country_short_na;
4565 
4566 -- JH altered to return WS/PTH directly to p_sf52_data.
4567 	   	ghr_pa_requests_pkg.get_SF52_asg_ddf_details
4568 	                     (p_assignment_id         => l_assignment_id
4569 	                     ,p_date_effective        => p_effective_date
4570 	                     ,p_tenure                => l_tenure
4571 	                     ,p_annuitant_indicator   => l_annuitant_indicator
4572 	                     ,p_pay_rate_determinant  => l_pay_rate_determinant
4573                            ,p_work_schedule         => p_sf52_data.work_schedule
4574                            ,p_part_time_hours       => p_sf52_data.part_time_hours);
4575 
4576 		p_sf52_data.tenure		 	:=	l_tenure ;
4577 		p_sf52_data.annuitant_indicator	:=	l_annuitant_indicator;
4578 ------Bug 3038095
4579                 IF p_sf52_data.first_noa_code = '866'
4580                    AND l_session_var.noa_id_correct is not NULL THEN
4581                    Null;
4582                 ELSE
4583                   -- FWFA Changes Bug#4444609 Modified the prd as In_prd.
4584 		          p_sf52_data.input_pay_rate_determinant	:=	l_pay_rate_determinant;
4585                 END IF;
4586 ------Bug 3038095 End
4587 
4588 -- JH Asg WS/PTH is populated by default, then overwritten by To Position WS/PTH
4589 -- If the To Position Process Method is UE, or APUE and To Posn <> From Posn.
4590             IF p_sf52_data.to_position_id IS NOT NULL THEN
4591 /* l_pm value determined above
4592 	        FOR pm_rec in get_to_posn_title_pm LOOP
4593                 l_pm := pm_rec.process_method_code;
4594               END Loop;
4595 */
4596               IF l_pm = 'UE' THEN
4597                 p_sf52_data.work_schedule           :=    l_work_schedule;
4598                 p_sf52_data.part_time_hours         :=    l_part_time_hours;
4599               ELSIF l_pm = 'APUE' AND nvl(p_sf52_data.to_position_id,hr_api.g_number)
4600                 <> nvl(p_sf52_data.from_position_id,hr_api.g_number) THEN
4601                 p_sf52_data.work_schedule           :=    l_work_schedule;
4602                 p_sf52_data.part_time_hours         :=    l_part_time_hours;
4603               END IF;
4604             END IF;
4605 -- JH
4606 
4607 	    	ghr_api.retrieve_element_entry_value
4608 	                     (p_element_name        => 'FEGLI'
4609 	                     ,p_input_value_name    => 'FEGLI'
4610 	                     ,p_assignment_id       => l_assignment_id
4611 	                     ,p_effective_date      => p_effective_date
4612 	                     ,p_value               => l_fegli
4613 	                     ,p_multiple_error_flag => l_multiple_error_flag);
4614 
4615 		/*
4616 		if (l_multiple_error_flag) then
4617 	    		hr_utility.set_message(8301 , 'GHR_99999_MULT_ERR_FLAG');
4618 			hr_utility.raise_error;
4619 		end if;
4620 		*/
4621 
4622 		p_sf52_data.fegli		 	:=	l_fegli ;
4623 		p_sf52_data.fegli_desc := ghr_pa_requests_pkg.get_lookup_meaning(800
4624  	                                            ,'GHR_US_FEGLI'
4625 	                                             ,l_fegli);
4626 
4627 	    	ghr_api.retrieve_element_entry_value
4628 	                     (p_element_name        => 'Retirement Plan'
4629 	                     ,p_input_value_name    => 'Plan'
4630 	                     ,p_assignment_id       => l_assignment_id
4631 	     	               ,p_effective_date      => p_effective_date
4632 	     	               ,p_value               => l_retirement_plan
4633 		               ,p_multiple_error_flag => l_multiple_error_flag);
4634 		/*
4635 		if (l_multiple_error_flag) then
4636     			hr_utility.set_message(8301 , 'GHR_99999_MULT_ERR_FLAG2');
4637 			hr_utility.raise_error;
4638 		end if;
4639 		*/
4640 
4641 		p_sf52_data.retirement_plan		 	:=	l_retirement_plan ;
4642 		p_sf52_data.retirement_plan_desc := ghr_pa_requests_pkg.get_lookup_meaning(800
4643      	                                        ,'GHR_US_RETIREMENT_PLAN'
4644 	                                             ,l_retirement_plan);
4645 
4646 	end if;
4647 
4648 --- Code for converting the pay values per Retain Grade Pay Basis
4649 --  if employee is on retain grade
4650   hr_utility.set_location('PRD is '|| p_sf52_data.pay_rate_determinant,1 );
4651   hr_utility.set_location('Eff Date is '|| p_sf52_data.effective_date,1 );
4652   hr_utility.set_location('PER ID '|| p_person_id,1 );
4653   hr_utility.set_location('POS ID '|| p_sf52_data.to_position_id,1 );
4654   hr_utility.set_location('from_basic_pay is '|| p_sf52_data.from_basic_pay,1 );
4655   hr_utility.set_location('from_locality_adj is '|| p_sf52_data.from_locality_adj,1 );
4656   hr_utility.set_location('from_adj_basic_pay is '|| p_sf52_data.from_adj_basic_pay,1 );
4657   hr_utility.set_location('from_total_salary is '|| p_sf52_data.from_total_salary,1 );
4658 IF p_sf52_data.pay_rate_determinant IN ('A','B','E','F','U','V') THEN
4659   IF l_from_position_id = p_sf52_data.to_position_id  and
4660      l_session_var.noa_id_correct is not NULL and
4661      l_pm = 'AP' THEN
4662 ----Temp Promo Changes by AVR 03-JUN-2000--Start---
4663 
4664                  if p_sf52_data.pay_rate_determinant in  ('A','B','E','F') AND
4665                     ghr_pa_requests_pkg.temp_step_true(p_sf52_data.pa_request_id) THEN
4666                          ghr_history_fetch.fetch_positionei(
4667                               p_position_id      => p_sf52_data.to_position_id,
4668                               p_information_type => 'GHR_US_POS_VALID_GRADE',
4669                               p_date_effective   => p_sf52_data.effective_date,
4670                               p_pos_ei_data      => l_pos_ei_grade_data);
4671 
4672                     p_sf52_data.to_pay_basis := l_pos_ei_grade_data.poei_information6;
4673                  else
4674 ----Temp Promo Changes by AVR 03-JUN-2000--End---
4675 
4676      p_sf52_data.to_pay_basis      :=
4677                    ghr_pa_requests_pkg.get_upd34_pay_basis
4678                      (p_person_id      => p_person_id
4679                      ,p_position_id    => p_sf52_data.to_position_id
4680                      ,p_prd            => p_sf52_data.pay_rate_determinant
4681                      ,p_pa_request_id  =>  p_sf52_data.pa_request_id
4682                      ,p_effective_date => nvl(p_sf52_data.effective_date,trunc(sysdate)));
4683                  end if;
4684     IF NOT ghr_pa_requests_pkg.temp_step_true(p_sf52_data.pa_request_id) THEN
4685     IF p_sf52_data.from_pay_basis <> p_sf52_data.to_pay_basis THEN
4686       p_sf52_data.to_basic_pay    := ghr_pay_calc.convert_amount(p_sf52_data.from_basic_pay
4687                                        ,p_sf52_data.from_pay_basis
4688                                        ,p_sf52_data.to_pay_basis);
4689       p_sf52_data.to_locality_adj := ghr_pay_calc.convert_amount(p_sf52_data.from_locality_adj
4690                                        ,p_sf52_data.from_pay_basis
4691                                        ,p_sf52_data.to_pay_basis);
4692       p_sf52_data.to_adj_basic_pay := ghr_pay_calc.convert_amount(p_sf52_data.from_adj_basic_pay
4693                                        ,p_sf52_data.from_pay_basis
4694                                        ,p_sf52_data.to_pay_basis);
4695       p_sf52_data.to_total_salary := ghr_pay_calc.convert_amount(p_sf52_data.from_total_salary
4696                                        ,p_sf52_data.from_pay_basis
4697                                        ,p_sf52_data.to_pay_basis);
4698     END IF;
4699     END IF;
4700   END IF;
4701 END IF;
4702 	-- display all values retrieved
4703 	print_sf52('Retrieved by refresh: ', p_sf52_data);
4704 
4705 	hr_utility.set_location('Leaving: ' || l_proc, 100);
4706 
4707 EXCEPTION
4708   WHEN others THEN
4709      -- Reset IN OUT parameters and set OUT parameters
4710 
4711       p_sf52_data := l_sf52_data ;
4712 
4713    hr_utility.set_location('Leaving  ' || l_proc,80);
4714    RAISE;
4715 
4716 end refresh_pa_request;
4717 
4718 -- ---------------------------------------------------------------------------
4719 -- |--------------------------< get_par_ap_apue_fields>-----------------------|
4720 -- ---------------------------------------------------------------------------
4721 -- {Start Of Comments}
4722 --
4723 -- Description:
4724 --   	This procedure copies the AP/APUE fields from p_pa_req_in to p_pa_req_out
4725 --
4726 -- Pre-Requisities:
4727 --   	None.
4728 --
4729 -- In Parameters:
4730 --	p_pa_req_in		->	pa_request record is passed here. This should contain
4731 --					values for all fields that need to be considered for
4732 --					copying into p_pa_req_out.
4733 --	p_pa_req_out	->	This will contain all the AP/APUE fields contained in
4734 --					p_pa_req_in.
4735 --
4736 -- Post Success:
4737 -- 	All the fields in p_pa_req_out will have been populated according to process methods.
4738 --
4739 -- Post Failure:
4740 --   No Failure conditions.
4741 --
4742 -- Developer Implementation Notes:
4743 --	None.
4744 --
4745 -- Access Status:
4746 --   Internal Development Use Only.
4747 --
4748 -- {End Of Comments}
4749 -- ---------------------------------------------------------------------------
4750 
4751 PROCEDURE get_par_ap_apue_fields (p_pa_req_in		in ghr_pa_requests%rowtype,
4752 				  p_first_noa_id	in ghr_pa_requests.first_noa_id%type,
4753 				  p_second_noa_id	in ghr_pa_requests.second_noa_id%type,
4754 				  p_pa_req_out		out nocopy ghr_pa_requests%rowtype) IS
4755 
4756    TYPE fields_type	is	record
4757 	(form_field_name		ghr_pa_data_fields.form_field_name%TYPE	);
4758 
4759    TYPE fld_names_typ   is TABLE of fields_type
4760 			INDEX BY BINARY_INTEGER;
4761    l_fld_names_tab	fld_names_typ;
4762    l_pa_req		ghr_pa_requests%rowtype;
4763    l_column_count	number := 0;
4764    l_proc	varchar2(30):='get_par_ap_apue_fields';
4765 
4766 --
4767    PROCEDURE initialize_fld_names_table (p_1st_noa_id  		in	number,
4768 					p_2nd_noa_id		in	number default null,
4769 					p_fld_names_tab		in out 	nocopy  fld_names_typ) IS
4770    --
4771    -- initializes the local pl/sql table with the field names from ghr_pa_data_fields table.
4772    --
4773 --
4774 	-- this cursor fetches the form_field_names for the 1st_noa_id and 2nd_noa_id specified.
4775 	CURSOR cur_flds2(	p_1st_noa_id number,
4776 				p_2nd_noa_id number) IS
4777 		SELECT	fld.form_field_name
4778 		FROM
4779 			ghr_families			ghrf,
4780 			ghr_noa_fam_proc_methods	met,
4781 			ghr_pa_data_fields		fld,
4782 			ghr_noa_families			fam
4783 		WHERE
4784 			    fam.noa_family_code		= met.noa_family_code
4785 			AND ghrf.noa_family_code	= met.noa_family_code
4786 			AND ghrf.update_hr_flag		= 'Y'
4787 			AND met.process_method_code in ('AP', 'APUE')
4788 			AND met.pa_data_field_id	= fld.pa_data_field_id
4789 			AND fam.nature_of_action_id	= p_1st_noa_id
4790 		UNION
4791 			SELECT	fld2.form_field_name
4792 			FROM
4793 				ghr_families			ghrf2,
4794 				ghr_noa_fam_proc_methods	met2,
4795 				ghr_pa_data_fields		fld2,
4796 				ghr_noa_families			fam2
4797 			WHERE
4798 				    fam2.noa_family_code	= met2.noa_family_code
4799 				AND ghrf2.noa_family_code	= met2.noa_family_code
4800 				AND ghrf2.update_hr_flag	= 'Y'
4801 				AND met2.process_method_code in ('AP', 'APUE')
4802 				AND met2.pa_data_field_id	= fld2.pa_data_field_id
4803 				AND fam2.nature_of_action_id	= p_2nd_noa_id;
4804 
4805 	CURSOR cur_flds1(	p_1st_noa_id number) IS
4806 		SELECT	fld.form_field_name
4807 		FROM
4808 			ghr_families			ghrf,
4809 			ghr_noa_fam_proc_methods	met,
4810 			ghr_pa_data_fields		fld,
4811 			ghr_noa_families			fam
4812 		WHERE
4813 			    fam.noa_family_code		= met.noa_family_code
4814 			AND ghrf.noa_family_code	= met.noa_family_code
4815 			AND ghrf.update_hr_flag		= 'Y'
4816 			AND met.process_method_code in ('AP', 'APUE')
4817 			AND met.pa_data_field_id	= fld.pa_data_field_id
4818 			AND fam.nature_of_action_id	= p_1st_noa_id;
4819 
4820 	CURSOR cur_pos_title1(	p_1st_noa_id number) IS
4821 		SELECT	fld.form_field_name
4822 		FROM
4823 			ghr_families			ghrf,
4824 			ghr_noa_fam_proc_methods	met,
4825 			ghr_pa_data_fields		fld,
4826 			ghr_noa_families			fam
4827 		WHERE
4828 			    fam.noa_family_code		= met.noa_family_code
4829 			AND ghrf.noa_family_code	= met.noa_family_code
4830 			AND ghrf.update_hr_flag		= 'Y'
4831 			AND met.pa_data_field_id	= fld.pa_data_field_id
4832 			AND met.process_method_code 	= 'UE'
4833 			AND fld.form_field_name		= 'TO_POSITION_TITLE'
4834 			AND fam.nature_of_action_id	= p_1st_noa_id;
4835 
4836 	CURSOR cur_pos_title2(	p_1st_noa_id number, p_2nd_noa_id number ) IS
4837 		SELECT	fld.form_field_name
4838 		FROM
4839 			ghr_families			ghrf,
4840 			ghr_noa_fam_proc_methods	met,
4841 			ghr_pa_data_fields		fld,
4842 			ghr_noa_families			fam
4843 		WHERE
4844 			    fam.noa_family_code		= met.noa_family_code
4845 			AND ghrf.noa_family_code	= met.noa_family_code
4846 			AND ghrf.update_hr_flag		= 'Y'
4847 			AND met.pa_data_field_id	= fld.pa_data_field_id
4848 			AND met.process_method_code 	= 'UE'
4849 			AND fld.form_field_name		= 'TO_POSITION_TITLE'
4850 			AND (fam.nature_of_action_id	= p_1st_noa_id
4851 				OR fam.nature_of_action_id	= p_2nd_noa_id);
4852 
4853 	l_proc	varchar2(30):='initialize_fld_names_table';
4854 	l_fld_names_tab   fld_names_typ;
4855 
4856    BEGIN
4857          l_fld_names_tab := p_fld_names_tab; --NOCOPY Changes
4858 	hr_utility.set_location('Entering:'|| l_proc, 5);
4859 
4860 	-- populate the local table with the form_field_names for this noa.
4861 	if (p_2nd_noa_id is not null) then
4862 	    hr_utility.set_location( l_proc || 'dual action', 7);
4863 	      FOR curflds_rec in cur_flds2(p_1st_noa_id, p_2nd_noa_id) LOOP
4864 	          l_column_count := l_column_count + 1;
4865 	          p_fld_names_tab(l_column_count) := curflds_rec;
4866 	      END LOOP;
4867 		FOR cur_postitle_rec in cur_pos_title2(p_1st_noa_id,p_2nd_noa_id) LOOP
4868 			l_column_count := l_column_count +1;
4869 			p_fld_names_tab(l_column_count) := cur_postitle_rec;
4870 		end LOOP;
4871 	else
4872 	    hr_utility.set_location( l_proc || 'single action', 9);
4873 	      FOR curflds_rec in cur_flds1(p_1st_noa_id) LOOP
4874 	          l_column_count := l_column_count + 1;
4875 	          p_fld_names_tab(l_column_count) := curflds_rec;
4876 	      END LOOP;
4877 		FOR cur_postitle_rec in cur_pos_title1(p_1st_noa_id) LOOP
4878 			l_column_count := l_column_count +1;
4879 			p_fld_names_tab(l_column_count) := cur_postitle_rec;
4880 		end LOOP;
4881 	end if;
4882 	hr_utility.set_location('Leaving:'|| l_proc, 10);
4883 
4884     EXCEPTION
4885       WHEN others THEN
4886      -- Reset IN OUT parameters and set OUT parameters
4887 
4888          p_fld_names_tab  :=l_fld_names_tab;
4889 
4890       hr_utility.set_location('Leaving  ' || l_proc,60);
4891      RAISE;
4892    END initialize_fld_names_table;
4893 
4894 --
4895    PROCEDURE copy_to_new_rg	(p_field_name	IN VARCHAR2,
4896 				 p_from_field	IN VARCHAR2,
4897 				 p_to_field	IN OUT NOCOPY VARCHAR2) IS
4898    --
4899    -- copies the passed rg value to the new rg only if the field name is present
4900    -- in the temp table
4901    --
4902 	l_proc	varchar2(30):='copy_to_new_rg';
4903 	l_found	boolean:=false;
4904 	l_to_field VARCHAR2(2000);
4905 
4906    BEGIN
4907 	l_to_field := p_to_field; --NOCOPY Changes
4908  	hr_utility.set_location('Entering:'|| l_proc, 5);
4909       FOR l_count IN 1..l_column_count LOOP
4910           if p_field_name = l_fld_names_tab(l_count).form_field_name then
4911 				l_found := TRUE;
4912 				p_to_field := p_from_field; -- Sundar 2112935 Copying source to the target.
4913 	      exit;
4914           end if;
4915       END LOOP;
4916 	if not l_found then
4917 		p_to_field := null;
4918 	end if;
4919 
4920  	hr_utility.set_location('Leaving:'|| l_proc, 10);
4921 
4922    EXCEPTION
4923      WHEN others THEN
4924      -- Reset IN OUT parameters and set OUT parameters
4925 
4926          p_to_field  :=l_to_field;
4927 
4928       hr_utility.set_location('Leaving  ' || l_proc,60);
4929      RAISE;
4930    END copy_to_new_rg;
4931 
4932 BEGIN
4933  	hr_utility.set_location('Entering:'|| l_proc, 5);
4934 	hr_utility.set_location(' no. of rows in table rg ' || to_char(l_column_count), 11);
4935 	-- get list of all columns needed for the noa we are correcting.
4936    	initialize_fld_names_table(	p_1st_noa_id  		=> p_first_noa_id,
4937 					p_2nd_noa_id  		=> p_second_noa_id,
4938 					p_fld_names_tab		=> l_fld_names_tab);
4939 
4940 	l_pa_req := p_pa_req_in;
4941 	-- for all columns, set to null if not needed for the noa we are processing
4942 
4943 -- Lines whih are commented meanss that this column value must be passed irrespective
4944 -- of if it has been defined in proc_methods or not.
4945 -- LINES WITH --* means that this value was not fetched by refresh_pa_request
4946 -- LINES WITH --** means that this column was fetched by refresh_pa_request and it is not a form
4947 -- LINES WITH --? must be revisited. Not sure what to do with these.
4948 -- field but it should always be copied.
4949 --*	copy_to_new_rg('PA_REQUEST_ID',p_pa_req_in.pa_request_id,l_pa_req.pa_request_id);
4950 --*	copy_to_new_rg('PA_NOTIFICATION_ID',p_pa_req_in.pa_notification_id,l_pa_req.pa_notification_id);
4951 --*	copy_to_new_rg('NOA_FAMILY_CODE',p_pa_req_in.noa_family_code,l_pa_req.noa_family_code);
4952 --*	copy_to_new_rg('ROUTING_GROUP_ID',p_pa_req_in.routing_group_id,l_pa_req.routing_group_id);
4953 --*	copy_to_new_rg('PROPOSED_EFFECTIVE_ASAP_FLAG',p_pa_req_in.proposed_effective_asap_flag,l_pa_req.proposed_effective_asap_flag);
4954 	copy_to_new_rg('ACADEMIC_DISCIPLINE',p_pa_req_in.academic_discipline,l_pa_req.academic_discipline);
4955 --*	copy_to_new_rg('ADDITIONAL_INFO_PERSON_ID',p_pa_req_in.additional_info_person_id,l_pa_req.additional_info_person_id);
4956 --*	copy_to_new_rg('ADDITIONAL_INFO_TEL_NUMBER',p_pa_req_in.additional_info_tel_number,l_pa_req.additional_info_tel_number);
4957 	copy_to_new_rg('AGENCY_CODE',p_pa_req_in.agency_code,l_pa_req.agency_code);
4958 --*	copy_to_new_rg('ALTERED_PA_REQUEST_ID',p_pa_req_in.altered_pa_request_id,l_pa_req.altered_pa_request_id);
4959 	copy_to_new_rg('ANNUITANT_INDICATOR',p_pa_req_in.annuitant_indicator,l_pa_req.annuitant_indicator);
4960 	copy_to_new_rg('ANNUITANT_INDICATOR_DESC',p_pa_req_in.annuitant_indicator_desc,l_pa_req.annuitant_indicator_desc);
4961 	copy_to_new_rg('APPROPRIATION_CODE1',p_pa_req_in.appropriation_code1,l_pa_req.appropriation_code1);
4962 	copy_to_new_rg('APPROPRIATION_CODE2',p_pa_req_in.appropriation_code2,l_pa_req.appropriation_code2);
4963 --*	copy_to_new_rg('APPROVAL_DATE',p_pa_req_in.approval_date,l_pa_req.approval_date);
4964 --*	copy_to_new_rg('APPROVING_OFFICIAL_WORK_TITLE',p_pa_req_in.approving_official_work_title,l_pa_req.approving_official_work_title);
4965 
4966 --*	copy_to_new_rg('AUTHORIZED_BY_PERSON_ID',p_pa_req_in.authorized_by_person_id,l_pa_req.authorized_by_person_id);
4967 --*	copy_to_new_rg('AUTHORIZED_BY_TITLE',p_pa_req_in.authorized_by_title,l_pa_req.authorized_by_title);
4968 	copy_to_new_rg('AWARD_AMOUNT',p_pa_req_in.award_amount,l_pa_req.award_amount);
4969 	copy_to_new_rg('AWARD_UOM',p_pa_req_in.award_uom,l_pa_req.award_uom);
4970 	copy_to_new_rg('BARGAINING_UNIT_STATUS',p_pa_req_in.bargaining_unit_status,l_pa_req.bargaining_unit_status);
4971 	copy_to_new_rg('CITIZENSHIP',p_pa_req_in.citizenship,l_pa_req.citizenship);
4972 --	copy_to_new_rg('CONCURRENCE_DATE',p_pa_req_in.concurrence_date,l_pa_req.concurrence_date);
4973 	copy_to_new_rg('DUTY_STATION_CODE',p_pa_req_in.duty_station_code,l_pa_req.duty_station_code);
4974 	copy_to_new_rg('DUTY_STATION_DESC',p_pa_req_in.duty_station_desc,l_pa_req.duty_station_desc);
4975 	-- Copied on the basis of DUTY_STATION_DESC
4976 	copy_to_new_rg('DUTY_STATION_DESC',p_pa_req_in.duty_station_id,l_pa_req.duty_station_id);
4977 	copy_to_new_rg('DUTY_STATION_DESC',p_pa_req_in.duty_station_location_id,l_pa_req.duty_station_location_id);
4978 	copy_to_new_rg('EDUCATION_LEVEL',p_pa_req_in.education_level,l_pa_req.education_level);
4979 --*	copy_to_new_rg('EFFECTIVE_DATE',p_pa_req_in.effective_date,l_pa_req.effective_date);
4980 --**	copy_to_new_rg('EMPLOYEE_ASSIGNMENT_ID',p_pa_req_in.employee_assignment_id,l_pa_req.employee_assignment_id);
4981 --	copy_to_new_rg('EMPLOYEE_DATE_OF_BIRTH',p_pa_req_in.employee_date_of_birth,l_pa_req.employee_date_of_birth);
4982 --*	copy_to_new_rg('EMPLOYEE_DEPT_OR_AGENCY',p_pa_req_in.employee_dept_or_agency,l_pa_req.employee_dept_or_agency);
4983 --	copy_to_new_rg('EMPLOYEE_FIRST_NAME',p_pa_req_in.employee_first_name,l_pa_req.employee_first_name);
4984 --	copy_to_new_rg('EMPLOYEE_LAST_NAME',p_pa_req_in.employee_last_name,l_pa_req.employee_last_name);
4985 --	copy_to_new_rg('EMPLOYEE_MIDDLE_NAMES',p_pa_req_in.employee_middle_names,l_pa_req.employee_middle_names);
4986 --	copy_to_new_rg('EMPLOYEE_NATIONAL_IDENTIFIER',p_pa_req_in.employee_national_identifier,l_pa_req.employee_national_identifier);
4987 	copy_to_new_rg('FEGLI',p_pa_req_in.fegli,l_pa_req.fegli);
4988 	copy_to_new_rg('FEGLI_DESC',p_pa_req_in.fegli_desc,l_pa_req.fegli_desc);
4989 	copy_to_new_rg('FLSA_CATEGORY',p_pa_req_in.flsa_category,l_pa_req.flsa_category);
4990 -- Can modify the code to copy all the address lines if address_line1 is copied
4991 	copy_to_new_rg('FORWARDING_ADDRESS_LINE1',p_pa_req_in.forwarding_address_line1,l_pa_req.forwarding_address_line1);
4992 	copy_to_new_rg('FORWARDING_ADDRESS_LINE2',p_pa_req_in.forwarding_address_line2,l_pa_req.forwarding_address_line2);
4993 	copy_to_new_rg('FORWARDING_ADDRESS_LINE3',p_pa_req_in.forwarding_address_line3,l_pa_req.forwarding_address_line3);
4994 
4995 	copy_to_new_rg('FORWARDING_COUNTRY_SHORT_NAME',p_pa_req_in.forwarding_country,l_pa_req.forwarding_country);
4996 	copy_to_new_rg('FORWARDING_COUNTRY_SHORT_NAME',p_pa_req_in.forwarding_country_short_name,l_pa_req.forwarding_country_short_name);
4997 	copy_to_new_rg('FORWARDING_POSTAL_CODE',p_pa_req_in.forwarding_postal_code,l_pa_req.forwarding_postal_code);
4998 	copy_to_new_rg('FORWARDING_REGION_2',p_pa_req_in.forwarding_region_2,l_pa_req.forwarding_region_2);
4999 	copy_to_new_rg('FORWARDING_TOWN_OR_CITY',p_pa_req_in.forwarding_town_or_city,l_pa_req.forwarding_town_or_city);
5000 	copy_to_new_rg('FROM_ADJ_BASIC_PAY',p_pa_req_in.from_adj_basic_pay,l_pa_req.from_adj_basic_pay);
5001 	copy_to_new_rg('FROM_AGENCY_CODE',p_pa_req_in.from_agency_code,l_pa_req.from_agency_code);
5002 	copy_to_new_rg('FROM_AGENCY_DESC',p_pa_req_in.from_agency_desc,l_pa_req.from_agency_desc);
5003 
5004 	copy_to_new_rg('FROM_BASIC_PAY',p_pa_req_in.from_basic_pay,l_pa_req.from_basic_pay);
5005 	copy_to_new_rg('FROM_GRADE_OR_LEVEL',p_pa_req_in.from_grade_or_level,l_pa_req.from_grade_or_level);
5006 	copy_to_new_rg('FROM_LOCALITY_ADJ',p_pa_req_in.from_locality_adj,l_pa_req.from_locality_adj);
5007 	copy_to_new_rg('FROM_OCC_CODE',p_pa_req_in.from_occ_code,l_pa_req.from_occ_code);
5008 	copy_to_new_rg('FROM_OFFICE_SYMBOL',p_pa_req_in.from_office_symbol,l_pa_req.from_office_symbol);
5009 	copy_to_new_rg('FROM_OTHER_PAY_AMOUNT',p_pa_req_in.from_other_pay_amount,l_pa_req.from_other_pay_amount);
5010 	copy_to_new_rg('FROM_PAY_BASIS_DESC',p_pa_req_in.from_pay_basis,l_pa_req.from_pay_basis);
5011 	copy_to_new_rg('FROM_PAY_PLAN',p_pa_req_in.from_pay_plan,l_pa_req.from_pay_plan);
5012 
5013 	copy_to_new_rg('FROM_POSITION_TITLE',p_pa_req_in.from_position_title,l_pa_req.from_position_title);
5014 	copy_to_new_rg('FROM_POSITION_TITLE',p_pa_req_in.from_position_id,l_pa_req.from_position_id);
5015 
5016 	copy_to_new_rg('FROM_POSITION_ORG_LINE1',p_pa_req_in.from_position_org_line1,l_pa_req.from_position_org_line1);
5017 	copy_to_new_rg('FROM_POSITION_ORG_LINE2',p_pa_req_in.from_position_org_line2,l_pa_req.from_position_org_line2);
5018 	copy_to_new_rg('FROM_POSITION_ORG_LINE3',p_pa_req_in.from_position_org_line3,l_pa_req.from_position_org_line3);
5019 	copy_to_new_rg('FROM_POSITION_ORG_LINE4',p_pa_req_in.from_position_org_line4,l_pa_req.from_position_org_line4);
5020 	copy_to_new_rg('FROM_POSITION_ORG_LINE5',p_pa_req_in.from_position_org_line5,l_pa_req.from_position_org_line5);
5021 	copy_to_new_rg('FROM_POSITION_ORG_LINE6',p_pa_req_in.from_position_org_line6,l_pa_req.from_position_org_line6);
5022 
5023 	copy_to_new_rg('FROM_POSITION_NUMBER',p_pa_req_in.from_position_number,l_pa_req.from_position_number);
5024 	copy_to_new_rg('FROM_POSITION_SEQ_NO',p_pa_req_in.from_position_seq_no,l_pa_req.from_position_seq_no);
5025 	copy_to_new_rg('FROM_STEP_OR_RATE',p_pa_req_in.from_step_or_rate,l_pa_req.from_step_or_rate);
5026 	copy_to_new_rg('FROM_TOTAL_SALARY',p_pa_req_in.from_total_salary,l_pa_req.from_total_salary);
5027 	copy_to_new_rg('FUNCTIONAL_CLASS',p_pa_req_in.functional_class,l_pa_req.functional_class);
5028 --*	copy_to_new_rg('NOTEPAD',p_pa_req_in.notepad,l_pa_req.notepad);
5029 	copy_to_new_rg('PART_TIME_HOURS',p_pa_req_in.part_time_hours,l_pa_req.part_time_hours);
5030     copy_to_new_rg('PAY_RATE_DETERMINANT',p_pa_req_in.pay_rate_determinant,l_pa_req.pay_rate_determinant);
5031 --*	copy_to_new_rg('PERSONNEL_OFFICE_ID',p_pa_req_in.personnel_office_id,l_pa_req.personnel_office_id);
5032 --	copy_to_new_rg('PERSON_ID',p_pa_req_in.person_id,l_pa_req.person_id);
5033 	copy_to_new_rg('POSITION_OCCUPIED',p_pa_req_in.position_occupied,l_pa_req.position_occupied);
5034 	copy_to_new_rg('PROPOSED_EFFECTIVE_DATE',p_pa_req_in.proposed_effective_date,l_pa_req.proposed_effective_date);
5035 
5036 --*	copy_to_new_rg('REQUESTED_BY_PERSON_ID',p_pa_req_in.requested_by_person_id,l_pa_req.requested_by_person_id);
5037 --*	copy_to_new_rg('REQUESTED_BY_TITLE',p_pa_req_in.requested_by_title,l_pa_req.requested_by_title);
5038 --*	copy_to_new_rg('REQUESTED_DATE',p_pa_req_in.requested_date,l_pa_req.requested_date);
5039 --*	copy_to_new_rg('REQUESTING_OFFICE_REMARKS_DESC',p_pa_req_in.requesting_office_remarks_desc,l_pa_req.requesting_office_remarks_desc);
5040 --*	copy_to_new_rg('REQUESTING_OFFICE_REMARKS_FLAG',p_pa_req_in.requesting_office_remarks_flag,l_pa_req.requesting_office_remarks_flag);
5041 --*	copy_to_new_rg('REQUEST_NUMBER',p_pa_req_in.request_number,l_pa_req.request_number);
5042 	copy_to_new_rg('RESIGN_AND_RETIRE_REASON_DESC',p_pa_req_in.resign_and_retire_reason_desc,l_pa_req.resign_and_retire_reason_desc);
5043 	copy_to_new_rg('RETIREMENT_PLAN',p_pa_req_in.retirement_plan,l_pa_req.retirement_plan);
5044 	copy_to_new_rg('RETIREMENT_PLAN_DESC',p_pa_req_in.retirement_plan_desc,l_pa_req.retirement_plan_desc);
5045 	copy_to_new_rg('SERVICE_COMP_DATE',p_pa_req_in.service_comp_date,l_pa_req.service_comp_date);
5046 	copy_to_new_rg('SUPERVISORY_STATUS',p_pa_req_in.supervisory_status,l_pa_req.supervisory_status);
5047 	copy_to_new_rg('TENURE',p_pa_req_in.tenure,l_pa_req.tenure);
5048 	copy_to_new_rg('TO_ADJ_BASIC_PAY',p_pa_req_in.to_adj_basic_pay,l_pa_req.to_adj_basic_pay);
5049 	copy_to_new_rg('TO_BASIC_PAY',p_pa_req_in.to_basic_pay,l_pa_req.to_basic_pay);
5050 	copy_to_new_rg('TO_LOCALITY_ADJ',p_pa_req_in.to_locality_adj,l_pa_req.to_locality_adj);
5051 
5052 	copy_to_new_rg('TO_OCC_CODE',p_pa_req_in.to_occ_code,l_pa_req.to_occ_code);
5053 	copy_to_new_rg('TO_OFFICE_SYMBOL',p_pa_req_in.to_office_symbol,l_pa_req.to_office_symbol);
5054 
5055 --	copy_to_new_rg('TO_ORGANIZATION_NAME',p_pa_req_in.to_organization_id,l_pa_req.to_organization_id);
5056 --	copy_to_new_rg('TO_POSITION_ORG_LINE1',p_pa_req_in.to_position_org_line1,l_pa_req.to_position_org_line1);
5057 --	copy_to_new_rg('TO_POSITION_ORG_LINE2',p_pa_req_in.to_position_org_line2,l_pa_req.to_position_org_line2);
5058 --	copy_to_new_rg('To_POSITION_ORG_LINE3',p_pa_req_in.to_position_org_line3,l_pa_req.to_position_org_line3);
5059 --	copy_to_new_rg('To_POSITION_ORG_LINE4',p_pa_req_in.to_position_org_line4,l_pa_req.to_position_org_line4);
5060 --	copy_to_new_rg('To_POSITION_ORG_LINE5',p_pa_req_in.to_position_org_line5,l_pa_req.to_position_org_line5);
5061 --	copy_to_new_rg('To_POSITION_ORG_LINE6',p_pa_req_in.to_position_org_line6,l_pa_req.to_position_org_line6);
5062 
5063 	copy_to_new_rg('TO_PAY_BASIS_DESC',p_pa_req_in.to_pay_basis,l_pa_req.to_pay_basis);
5064 
5065 	copy_to_new_rg('TO_PAY_PLAN',p_pa_req_in.to_pay_plan,l_pa_req.to_pay_plan);
5066 	/* if TO_POSITION_TITLE exists, then the following fields should be copied */
5067 	copy_to_new_rg('TO_POSITION_TITLE',p_pa_req_in.to_position_title,l_pa_req.to_position_title);
5068 	--
5069 	-- Position_id is already been taken care of in refresh_pa_req.
5070 	-- It must not be nullified even if it is 'UE'
5071 	-- copy_to_new_rg('TO_POSITION_TITLE',p_pa_req_in.to_position_id,l_pa_req.to_position_id);
5072 	copy_to_new_rg('TO_POSITION_TITLE',p_pa_req_in.to_grade_id,l_pa_req.to_grade_id);
5073 	copy_to_new_rg('TO_POSITION_TITLE',p_pa_req_in.to_job_id,l_pa_req.to_job_id);
5074 	copy_to_new_rg('TO_POSITION_TITLE',p_pa_req_in.to_organization_id,l_pa_req.to_organization_id);
5075 
5076 	/* end of fields dependent on TO_POSITION_TITLE */
5077 
5078 	copy_to_new_rg('TO_GRADE_OR_LEVEL',p_pa_req_in.to_grade_or_level,l_pa_req.to_grade_or_level);
5079 	copy_to_new_rg('TO_POSITION_NUMBER',p_pa_req_in.to_position_number,l_pa_req.to_position_number);
5080 	copy_to_new_rg('TO_POSITION_SEQ_NO',p_pa_req_in.to_position_seq_no,l_pa_req.to_position_seq_no);
5081 	copy_to_new_rg('TO_STEP_OR_RATE',p_pa_req_in.to_step_or_rate,l_pa_req.to_step_or_rate);
5082 	copy_to_new_rg('TO_TOTAL_SALARY',p_pa_req_in.to_total_salary,l_pa_req.to_total_salary);
5083 	copy_to_new_rg('VETERANS_PREFERENCE',p_pa_req_in.veterans_preference,l_pa_req.veterans_preference);
5084 
5085 	copy_to_new_rg('VETERANS_PREF_FOR_RIF_DESC',p_pa_req_in.veterans_pref_for_rif,l_pa_req.veterans_pref_for_rif);
5086 	copy_to_new_rg('VETERANS_STATUS',p_pa_req_in.veterans_status,l_pa_req.veterans_status);
5087 	copy_to_new_rg('WORK_SCHEDULE',p_pa_req_in.work_schedule,l_pa_req.work_schedule);
5088  	copy_to_new_rg('WORK_SCHEDULE_DESC',p_pa_req_in.work_schedule_desc,l_pa_req.work_schedule_desc);
5089 	copy_to_new_rg('YEAR_DEGREE_ATTAINED',p_pa_req_in.year_degree_attained,l_pa_req.year_degree_attained);
5090 
5091 /*	All of the follwing will be passed irrespective of NOA.
5092 
5093 	copy_to_new_rg('ATTRIBUTE_CATEGORY',p_pa_req_in.attribute_category,l_pa_req.attribute_category);
5094 	copy_to_new_rg('ATTRIBUTE1',p_pa_req_in.attribute1,l_pa_req.attribute1);
5095 	copy_to_new_rg('ATTRIBUTE2',p_pa_req_in.attribute2,l_pa_req.attribute2);
5096 	copy_to_new_rg('ATTRIBUTE3',p_pa_req_in.attribute3,l_pa_req.attribute3);
5097 	copy_to_new_rg('ATTRIBUTE4',p_pa_req_in.attribute4,l_pa_req.attribute4);
5098 	copy_to_new_rg('ATTRIBUTE5',p_pa_req_in.attribute5,l_pa_req.attribute5);
5099 	copy_to_new_rg('ATTRIBUTE6',p_pa_req_in.attribute6,l_pa_req.attribute6);
5100 	copy_to_new_rg('ATTRIBUTE7',p_pa_req_in.attribute7,l_pa_req.attribute7);
5101 	copy_to_new_rg('ATTRIBUTE8',p_pa_req_in.attribute8,l_pa_req.attribute8);
5102 	copy_to_new_rg('ATTRIBUTE9',p_pa_req_in.attribute9,l_pa_req.attribute9);
5103 	copy_to_new_rg('ATTRIBUTE10',p_pa_req_in.attribute10,l_pa_req.attribute10);
5104 	copy_to_new_rg('ATTRIBUTE11',p_pa_req_in.attribute11,l_pa_req.attribute11);
5105 	copy_to_new_rg('ATTRIBUTE12',p_pa_req_in.attribute12,l_pa_req.attribute12);
5106 	copy_to_new_rg('ATTRIBUTE13',p_pa_req_in.attribute13,l_pa_req.attribute13);
5107 	copy_to_new_rg('ATTRIBUTE14',p_pa_req_in.attribute14,l_pa_req.attribute14);
5108 	copy_to_new_rg('ATTRIBUTE15',p_pa_req_in.attribute15,l_pa_req.attribute15);
5109 	copy_to_new_rg('ATTRIBUTE16',p_pa_req_in.attribute16,l_pa_req.attribute16);
5110 	copy_to_new_rg('ATTRIBUTE17',p_pa_req_in.attribute17,l_pa_req.attribute17);
5111 	copy_to_new_rg('ATTRIBUTE18',p_pa_req_in.attribute18,l_pa_req.attribute18);
5112 	copy_to_new_rg('ATTRIBUTE19',p_pa_req_in.attribute19,l_pa_req.attribute19);
5113 	copy_to_new_rg('ATTRIBUTE20',p_pa_req_in.attribute20,l_pa_req.attribute20);
5114 */
5115 	-- all the following fields should be based on to_other_pay_amount
5116 	copy_to_new_rg('TO_OTHER_PAY_AMOUNT',p_pa_req_in.to_other_pay_amount,l_pa_req.to_other_pay_amount);
5117 	copy_to_new_rg('TO_OTHER_PAY_AMOUNT',p_pa_req_in.to_au_overtime,l_pa_req.to_au_overtime);
5118 	copy_to_new_rg('TO_OTHER_PAY_AMOUNT',p_pa_req_in.to_auo_premium_pay_indicator,l_pa_req.to_auo_premium_pay_indicator);
5119 	copy_to_new_rg('TO_OTHER_PAY_AMOUNT',p_pa_req_in.to_availability_pay,l_pa_req.to_availability_pay);
5120 	copy_to_new_rg('TO_OTHER_PAY_AMOUNT',p_pa_req_in.to_ap_premium_pay_indicator,l_pa_req.to_ap_premium_pay_indicator);
5121 	copy_to_new_rg('TO_OTHER_PAY_AMOUNT',p_pa_req_in.to_retention_allowance,l_pa_req.to_retention_allowance);
5122 	copy_to_new_rg('TO_OTHER_PAY_AMOUNT',p_pa_req_in.to_retention_allow_percentage,l_pa_req.to_retention_allow_percentage);
5123 	copy_to_new_rg('TO_OTHER_PAY_AMOUNT',p_pa_req_in.to_supervisory_differential,l_pa_req.to_supervisory_differential);
5124 	copy_to_new_rg('TO_OTHER_PAY_AMOUNT',p_pa_req_in.to_supervisory_diff_percentage,l_pa_req.to_supervisory_diff_percentage);
5125 	copy_to_new_rg('TO_OTHER_PAY_AMOUNT',p_pa_req_in.to_staffing_differential,l_pa_req.to_staffing_differential);
5126 	copy_to_new_rg('TO_OTHER_PAY_AMOUNT',p_pa_req_in.to_staffing_diff_percentage,l_pa_req.to_staffing_diff_percentage);
5127 
5128 
5129 --	copy_to_new_rg('CUSTOM_PAY_CALC_FLAG',p_pa_req_in.custom_pay_calc_flag,l_pa_req.custom_pay_calc_flag);
5130 	p_pa_req_out := l_pa_req;
5131 
5132 	hr_utility.set_location('Leaving:'|| l_proc, 15);
5133 
5134 EXCEPTION
5135   WHEN others THEN
5136      -- Reset IN OUT parameters and set OUT parameters
5137 
5138        p_pa_req_out  :=NULL;
5139 
5140    hr_utility.set_location('Leaving  ' || l_proc,60);
5141    RAISE;
5142 
5143 END get_par_ap_apue_fields;
5144 
5145 
5146 -- ---------------------------------------------------------------------------
5147 -- |--------------------------< derive_to_columns>----------------------------|
5148 -- ---------------------------------------------------------------------------
5149 -- {Start Of Comments}
5150 --
5151 -- Description:
5152 --   	This procedure derives the to column values for the given ghr_pa_request
5153 --	record. This is meant to be called for the first action in a dual action where
5154 --	the first action is a WGI.
5155 --
5156 -- Pre-Requisities:
5157 --   	None.
5158 --
5159 -- In Parameters:
5160 --	p_sf52_data		in out	ghr_pa_request record to be populated with derived
5161 --						to column values. Also contains input information for
5162 --						the pa_request record.
5163 --
5164 -- Post Success:
5165 -- 	The to values will have been derived from the from values in p_sf52_data. The results
5166 --	will have been put into the corresponding to value columns in p_sf52_data.
5167 --
5168 -- Post Failure:
5169 --   Exception will have been raised with error message explaining the problem.
5170 --
5171 -- Developer Implementation Notes:
5172 --   None
5173 --
5174 -- Access Status:
5175 --   Internal Development Use Only.
5176 --
5177 -- {End Of Comments}
5178 -- ---------------------------------------------------------------------------
5179 
5180 PROCEDURE derive_to_columns(p_sf52_data	in out	nocopy ghr_pa_requests%rowtype) IS
5181 
5182 	l_proc	varchar2(30):='derive_to_columns';
5183 	l_basic_pay        NUMBER;
5184 	l_locality_adj     NUMBER;
5185 	l_adj_basic_pay    NUMBER;
5186 	l_total_salary     NUMBER;
5187 	l_other_pay_amount NUMBER;
5188 	l_au_overtime      NUMBER;
5189 	l_availability_pay NUMBER;
5190 	l_out_step_or_rate VARCHAR2(30);
5191 	l_message_set      BOOLEAN;
5192 	l_calculated       BOOLEAN;
5193 	l_sf52_data	  ghr_pa_requests%rowtype;
5194 	l_message          VARCHAR2(2000);
5195 	l_out_pay_rate_determinant	NUMBER;
5196         l_out_to_grade_id   NUMBER;
5197         l_out_to_pay_plan   VARCHAR2(2);
5198         l_out_to_grade_or_level VARCHAR2(30);
5199 	l_pt_eff_start_date DATE;
5200 
5201         l_open_pay_fields  BOOLEAN;
5202         l_open_basicpay_field  BOOLEAN;
5203 	--Bug5132113
5204 	l_open_localityadj_field BOOLEAN;
5205         --Bug5132113
5206         l_open_range_out_basic_pay NUMBER;
5207 	l_open_out_locality_adj    NUMBER;
5208 
5209 	-- FWFA Changes
5210 	l_calc_pay_table_id NUMBER;
5211 	l_pay_table_id      NUMBER;
5212 	-- FWFA Changes
5213 
5214 	l_to_ret_allowance NUMBER;
5215     l_ret_allow_perc_out NUMBER;
5216 BEGIN
5217         l_sf52_data :=p_sf52_data ; --NOCOPY Changes
5218 
5219 	hr_utility.set_location('Entering:'|| l_proc, 5);
5220 	p_sf52_data.to_adj_basic_pay	:= p_sf52_data.from_adj_basic_pay;
5221 	p_sf52_data.agency_code			:= p_sf52_data.from_agency_code;
5222 
5223     l_open_range_out_basic_pay      := p_sf52_data.to_basic_pay;
5224     l_open_out_locality_adj         := p_sf52_data.to_locality_adj;
5225 
5226 	p_sf52_data.to_basic_pay		:= p_sf52_data.from_basic_pay;
5227 	p_sf52_data.to_grade_or_level	:= p_sf52_data.from_grade_or_level;
5228 	p_sf52_data.to_locality_adj		:= p_sf52_data.from_locality_adj;
5229 	p_sf52_data.to_occ_code			:= p_sf52_data.from_occ_code;
5230 	p_sf52_data.to_office_symbol	:= p_sf52_data.from_office_symbol;
5231 	p_sf52_data.to_other_pay_amount	:= p_sf52_data.from_other_pay_amount;
5232 	p_sf52_data.to_pay_basis		:= p_sf52_data.from_pay_basis;
5233 	p_sf52_data.to_pay_plan			:= p_sf52_data.from_pay_plan;
5234 	p_sf52_data.to_position_id		:= p_sf52_data.from_position_id;
5235 	p_sf52_data.to_position_org_line1	:= p_sf52_data.from_position_org_line1;
5236 	p_sf52_data.to_position_org_line2	:= p_sf52_data.from_position_org_line2;
5237 	p_sf52_data.to_position_org_line3	:= p_sf52_data.from_position_org_line3;
5238 	p_sf52_data.to_position_org_line4	:= p_sf52_data.from_position_org_line4;
5239 	p_sf52_data.to_position_org_line5	:= p_sf52_data.from_position_org_line5;
5240 	p_sf52_data.to_position_org_line6	:= p_sf52_data.from_position_org_line6;
5241 	p_sf52_data.to_position_number	:= p_sf52_data.from_position_number;
5242 	p_sf52_data.to_position_seq_no	:= p_sf52_data.from_position_seq_no;
5243 	p_sf52_data.to_position_title		:= p_sf52_data.from_position_title;
5244 	p_sf52_data.to_step_or_rate		:= p_sf52_data.from_step_or_rate;
5245 	p_sf52_data.to_total_salary		:= p_sf52_data.from_total_salary;
5246 	p_sf52_data.to_office_symbol		:= p_sf52_data.from_office_symbol;
5247 	p_sf52_data.to_other_pay_amount	:= p_sf52_data.from_other_pay_amount;
5248 	p_sf52_data.to_pay_basis		:= p_sf52_data.from_pay_basis;
5249 
5250 	refresh_pa_request(
5251 				p_person_id		=>	p_sf52_data.person_id,
5252 				p_effective_date 	=>	p_sf52_data.effective_date,
5253 				p_derive_to_cols	=>	TRUE,
5254 				p_sf52_data		=>	l_sf52_data);
5255 
5256 	p_sf52_data.to_organization_id		:= l_sf52_data.to_organization_id;
5257 	p_sf52_data.to_job_id				:= l_sf52_data.to_job_id;
5258 	p_sf52_data.to_grade_id				:= l_sf52_data.to_grade_id;
5259 	p_sf52_data.to_supervisory_differential	:= l_sf52_data.to_supervisory_differential;
5260 	p_sf52_data.to_supervisory_diff_percentage:= l_sf52_data.to_supervisory_diff_percentage;
5261 	p_sf52_data.to_staffing_differential	:= l_sf52_data.to_staffing_differential;
5262 	p_sf52_data.to_staffing_diff_percentage	:= l_sf52_data.to_staffing_diff_percentage;
5263 	p_sf52_data.to_au_overtime			:= l_sf52_data.to_au_overtime;
5264 	p_sf52_data.to_availability_pay		:= l_sf52_data.to_availability_pay;
5265 	p_sf52_data.to_ap_premium_pay_indicator	:= l_sf52_data.to_ap_premium_pay_indicator;
5266 	p_sf52_data.to_auo_premium_pay_indicator	:= l_sf52_data.to_auo_premium_pay_indicator;
5267 	p_sf52_data.to_retention_allowance		:= l_sf52_data.to_retention_allowance;
5268 	p_sf52_data.to_retention_allow_percentage	:= l_sf52_data.to_retention_allow_percentage;
5269 	hr_utility.set_location(l_proc ||' to_organization_id: ' || p_sf52_data.to_organization_id, 12);
5270 	hr_utility.set_location(l_proc ||' to_job_id: ' || p_sf52_data.to_job_id, 13);
5271 	hr_utility.set_location(l_proc ||' to_grade_id: ' || p_sf52_data.to_grade_id, 14);
5272 	hr_utility.set_location(l_proc ||' to_supervisory_differential: ' || p_sf52_data.to_supervisory_differential, 15);
5273 	hr_utility.set_location(l_proc ||' to_staffing_differential: ' || p_sf52_data.to_staffing_differential, 16);
5274 	hr_utility.set_location(l_proc ||' to_au_overtime: ' || p_sf52_data.to_au_overtime, 17);
5275 	hr_utility.set_location(l_proc ||' to_availability_pay: ' || p_sf52_data.to_availability_pay, 18);
5276 	hr_utility.set_location(l_proc ||' to_ap_premium_pay_indicator: ' || p_sf52_data.to_ap_premium_pay_indicator, 19);
5277 	hr_utility.set_location(l_proc ||' to_auo_premium_pay_indicator: ' || p_sf52_data.to_auo_premium_pay_indicator, 21);
5278 	hr_utility.set_location(l_proc ||' to_retention_allowance: ' || p_sf52_data.to_retention_allowance, 22);
5279 
5280 		ghr_pay_calc.main_pay_calc    (
5281             p_person_id        => p_sf52_data.person_id
5282            ,p_position_id      => p_sf52_data.to_position_id
5283            ,p_noa_family_code  => p_sf52_data.noa_family_code
5284            ,p_noa_code         => p_sf52_data.first_noa_code
5285            ,p_second_noa_code  => null
5286            ,p_first_action_la_code1 => p_sf52_data.first_action_la_code1
5287            ,p_effective_date   => p_sf52_data.effective_date
5288 	       -- FWFA Changes Bug#4444609 Modified the passed PRD parameter with input_pay_rate_determinant.
5289            ,p_pay_rate_determinant => NVL(p_sf52_data.input_pay_rate_determinant,NVL(p_sf52_data.pay_rate_determinant,'0'))
5290 	       -- FWFA Changes
5291 	       ,p_pay_plan         => p_sf52_data.to_pay_plan
5292            ,p_grade_or_level   => p_sf52_data.to_grade_or_level
5293            ,p_step_or_rate     => p_sf52_data.to_step_or_rate
5294            ,p_pay_basis        => p_sf52_data.to_pay_basis
5295            ,p_user_table_id    => null
5296            ,p_duty_station_id  => p_sf52_data.duty_station_id
5297            ,p_auo_premium_pay_indicator => p_sf52_data.to_auo_premium_pay_indicator
5298            ,p_ap_premium_pay_indicator  => p_sf52_data.to_ap_premium_pay_indicator
5299            ,p_retention_allowance       => p_sf52_data.to_retention_allowance
5300            ,p_to_ret_allow_percentage   => p_sf52_data.to_retention_allow_percentage
5301            ,p_supervisory_differential  => p_sf52_data.to_supervisory_differential
5302            ,p_staffing_differential     => p_sf52_data.to_staffing_differential
5303            ,p_current_basic_pay         => p_sf52_data.from_basic_pay
5304            ,p_current_adj_basic_pay     => p_sf52_data.from_adj_basic_pay
5305            ,p_current_step_or_rate      => p_sf52_data.from_step_or_rate
5306            ,p_pa_request_id    => p_sf52_data.pa_request_id
5307            ,p_open_range_out_basic_pay  => l_open_range_out_basic_pay
5308 	   ,p_open_out_locality_adj     => l_open_out_locality_adj
5309            ,p_basic_pay        => l_basic_pay
5310            ,p_locality_adj     => l_locality_adj
5311            ,p_adj_basic_pay    => l_adj_basic_pay
5312            ,p_total_salary     => l_total_salary
5313            ,p_other_pay_amount => l_other_pay_amount
5314            ,p_to_retention_allowance => l_to_ret_allowance
5315            ,p_ret_allow_perc_out => l_ret_allow_perc_out
5316            ,p_au_overtime      => l_au_overtime
5317            ,p_availability_pay => l_availability_pay
5318             -- FWFA Changes
5319             ,p_calc_pay_table_id => l_calc_pay_table_id
5320             ,p_pay_table_id	  => l_pay_table_id
5321             -- FWFA Changes
5322            ,p_out_step_or_rate => l_out_step_or_rate
5323            ,p_out_pay_rate_determinant => l_out_pay_rate_determinant
5324            ,p_out_to_grade_id          => l_out_to_grade_id
5325            ,p_out_to_pay_plan          => l_out_to_pay_plan
5326            ,p_out_to_grade_or_level    => l_out_to_grade_or_level
5327            ,p_pt_eff_start_date        => l_pt_eff_start_date
5328            ,p_open_basicpay_field  => l_open_basicpay_field
5329            ,p_open_pay_fields  => l_open_pay_fields
5330            ,p_message_set      => l_message_set
5331            ,p_calculated       => l_calculated
5332 	   ,p_open_localityadj_field => l_open_localityadj_field
5333           );
5334 
5335 		-- Check if we had any warning messages
5336 		-- Calculation not done.
5337 		IF l_message_set THEN
5338 			hr_utility.set_location( l_proc, 80);
5339 			hr_utility.set_message( 8301, 'GHR_38416_PC_FAILED');
5340 			hr_utility.raise_error;
5341 		END IF;
5342 
5343 		IF l_calculated THEN
5344 			hr_utility.set_location( l_proc, 50);
5345 			-- FWFA Changes Bug#4444609
5346 			p_sf52_data.pay_rate_determinant := NVL(l_out_pay_rate_determinant,p_sf52_data.input_pay_rate_determinant);
5347 			p_sf52_data.to_pay_table_identifier := l_calc_pay_table_id;
5348 			-- FWFA Changes
5349 			p_sf52_data.to_basic_pay     := l_basic_pay;
5350 			p_sf52_data.to_locality_adj  := l_locality_adj;
5351 			p_sf52_data.to_adj_basic_pay := l_adj_basic_pay;
5352 			p_sf52_data.to_total_salary  := l_total_salary;
5353 
5354 			-- don't bother with other pay stuff since this never gets used for dual actions where
5355 			-- WGI is the first action (that is the only time this procedure will have been called).
5356 			/*
5357 			-- Be careful with setting 'other' pay if it is 'NE'
5358 			IF get_other_pay_amount_pm <> 'NE' THEN
5359 				-- Populate these values if required
5360 				hr_utility.set_location( l_proc, 60);
5361 				p_sf52_data.to_other_pay_amount := l_other_pay_amount;
5362 				p_sf52_data.to_au_overtime  := l_au_overtime;
5363 				p_sf52_data.to_au_overtime  := l_au_overtime;
5364 			END IF;
5365 			*/
5366 			IF l_out_step_or_rate IS NOT NULL THEN
5367 				hr_utility.set_location( l_proc, 70);
5368 				p_sf52_data.to_step_or_rate := l_out_step_or_rate;
5369 			END IF;
5370 			-- should this check be here?? This is not the same as the future action case
5371 			-- where the pay calc is being run for the second time.
5372 /*
5373 			IF p_sf52_data.duty_station_id IS NULL      or
5374                      p_sf52_data.pay_rate_determinant IS NULL then
5375 				-- GHR_99999_MANDT_COLM_NULL
5376 				-- this must never be the case as this SF52 must have been
5377 				-- validated at the time future action was saved.
5378 				-- raise error
5379 				hr_utility.set_location( l_proc, 80);
5380 				hr_utility.set_message( 8301, 'GHR_99999_MANDT_COLM_NULL');
5381 				hr_utility.raise_error;
5382 				null;
5383 			END IF;
5384 */
5385 		ELSE
5386 			-- GHR_99999_PC_FAILED
5387 			-- ie  Pay calc failed
5388 			-- raise error. As values can not be entered interactively
5389 			hr_utility.set_location( l_proc, 100);
5390 			hr_utility.set_message( 8301, 'GHR_38416_PC_FAILED');
5391 			hr_utility.raise_error;
5392 			null;
5393 		END IF;
5394 
5395 EXCEPTION
5396   WHEN others THEN
5397      -- Reset IN OUT parameters and set OUT parameters
5398 
5399         p_sf52_data := l_sf52_data ;
5400 
5401    hr_utility.set_location('Leaving  ' || l_proc,60);
5402    RAISE;
5403 
5404 end derive_to_columns;
5405 
5406 -- This procedure can be used for refresh before update to database and for correction.
5407 --
5408 Procedure refresh_req_shadow (
5409 	p_sf52_data	    in out nocopy ghr_pa_requests%rowtype,
5410 	p_shadow_data       out nocopy ghr_pa_request_shadow%rowtype,
5411 	p_process_type	in	varchar2 default 'CURRENT'
5412 	) is
5413 
5414 	l_sf52_shadow	      ghr_pa_requests%rowtype;
5415 	l_shadow_data		ghr_pa_request_shadow%rowtype;
5416 	l_sf52_refresh_data	ghr_pa_requests%rowtype;
5417 	l_changed			boolean := FALSE;
5418 	l_proc			varchar2(30):='refresh_req_shadow';
5419         l_bef_basic_pay        number;
5420         l_retention_allowance   number;
5421         l_ret_calc_perc         number;
5422         l_supervisory_differential number;
5423         l_staffing_differential number;
5424         l_multi_error_flag    boolean;
5425         l_capped_other_pay  number;
5426 	l_sf52_data   ghr_pa_requests%rowtype;
5427 
5428 	cursor c_sf52_shadow (c_pa_request_id in number) is
5429 	select *
5430 	from ghr_pa_request_shadow
5431 	where pa_request_id = c_pa_request_id ;
5432 
5433 	-- Sundar 2112935 Added the variables below for Output
5434 	l_sf52_out_shadow ghr_pa_requests%rowtype;
5435 	l_sf52_refresh_out_data	ghr_pa_requests%rowtype;
5436 Begin
5437         l_sf52_data := p_sf52_data ;--NOCOPY Changes
5438 
5439 	print_sf52('Initial Data: ', p_sf52_data);
5440 
5441 	-- fetch Shadow sf52 of original/root SF52;
5442 	hr_utility.set_location('Entering ' || l_proc, 100);
5443 	open c_sf52_shadow (p_sf52_data.pa_request_id);
5444 	fetch c_sf52_shadow into l_shadow_data;
5445 	if c_sf52_shadow%notfound then
5446 		hr_utility.set_location(' Error, Shadow not found ' || l_proc, 101);
5447 		close c_sf52_shadow;
5448 	      hr_utility.set_message(8301,'GHR_38417_SHADOW_SF52_NOTFOUND');
5449 	      hr_utility.raise_error;
5450 	else
5451 		close c_sf52_shadow ;
5452 	end if;
5453 	-- convert shadow rg to SF52 format
5454 	hr_utility.set_location('Call Convert_shadoe_to_sf52 ' || l_proc, 110);
5455 	ghr_history_conv_rg.convert_shadow_to_sf52 (
5456 		p_shadow	 => l_shadow_data,
5457 		p_sf52	 => l_sf52_shadow);
5458 
5459 	print_sf52('shadow record before get_par: ', l_sf52_shadow);
5460 	get_par_ap_apue_fields(	p_pa_req_in		=>	l_sf52_shadow,
5461 					p_first_noa_id	=>	p_sf52_data.first_noa_id,
5462 					p_second_noa_id	=>	p_sf52_data.second_noa_id,
5463 					p_pa_req_out	=>	l_sf52_out_shadow); -- Sundar 2112935
5464 	l_sf52_shadow := l_sf52_out_shadow;
5465 	-- Sundar 2112935. Seperate variable added for out parameter above as
5466     -- it was not retrieving the value properly if original is passed.
5467 
5468 	l_sf52_refresh_data.pa_request_id		:= p_sf52_data.pa_request_id;
5469 	l_sf52_refresh_data.from_position_id	:= p_sf52_data.from_position_id;
5470 	l_sf52_refresh_data.from_position_title	:= p_sf52_data.from_position_title;
5471 	l_sf52_refresh_data.to_position_id		:= p_sf52_data.to_position_id;
5472 	l_sf52_refresh_data.effective_date		:= p_sf52_data.effective_date;
5473 	l_sf52_refresh_data.employee_assignment_id := p_sf52_data.employee_assignment_id;
5474 	l_sf52_refresh_data.first_noa_code		:= p_sf52_data.first_noa_code;
5475 	l_sf52_refresh_data.second_noa_code		:= p_sf52_data.second_noa_code;
5476     --6850492 added 713 to compare for dual actions as 713 can be performed as a second action
5477     IF p_sf52_data.first_noa_code = '713' or p_sf52_data.second_noa_code = '713' THEN
5478 	  l_sf52_refresh_data.to_grade_id		:= p_sf52_data.to_grade_id;
5479 	  l_sf52_refresh_data.to_grade_or_level		:= p_sf52_data.to_grade_or_level;
5480 	  l_sf52_refresh_data.to_pay_plan		:= p_sf52_data.to_pay_plan;
5481     END IF;
5482 
5483 -- vsm
5484 	hr_utility.set_location(l_proc, 120);
5485         -- Start Bug 1310894
5486     l_bef_basic_pay := p_sf52_data.from_basic_pay;
5487 	hr_utility.set_location('l_bef_basic_pay is '||l_bef_basic_pay, 135);
5488         -- End Bug 1310894
5489 
5490 	refresh_pa_request
5491 		(p_person_id	       => p_sf52_data.person_id,
5492 		 p_effective_date	       => p_sf52_data.effective_date,
5493 		 p_sf52_data	       => l_sf52_refresh_data);
5494 	hr_utility.set_location(l_proc, 130);
5495 	print_sf52('refresh record before get_par: ', l_sf52_refresh_data);
5496 
5497 	-- Call procedure to nullify NE/UE columns.
5498 	get_par_ap_apue_fields(	p_pa_req_in		=>	l_sf52_refresh_data,
5499 					p_first_noa_id	=>	p_sf52_data.first_noa_id,
5500 					p_second_noa_id	=>	p_sf52_data.second_noa_id,
5501 					p_pa_req_out	=>	l_sf52_refresh_out_data);
5502     l_sf52_refresh_data := l_sf52_refresh_out_data;
5503 	-- Sundar 2112935. Seperate variable added for out parameter above as
5504     -- it was not retrieving the value properly if original is passed.
5505 
5506 	print_sf52('refresh record after get_par: ', l_sf52_refresh_data);
5507 
5508 	-- Cascade AP and APUE fields not changed by the user.
5509 	-- l_sf52_refresh will have the result which should be processed
5510 	print_sf52('sf52 record before cascade: ', p_sf52_data);
5511 	print_sf52('shadow record before cascade: ', l_sf52_shadow);
5512 	print_sf52('refresh record before cascade: ', l_sf52_refresh_data);
5513 
5514 	ghr_history_cascade.cascade_pa_req(
5515 		p_rfrsh_rec	      => l_sf52_refresh_data,
5516 		p_shadow_rec      => l_sf52_shadow,
5517 		p_sf52_rec		=> p_sf52_data,
5518 		p_changed		=> l_changed);
5519 	if (l_changed) then
5520 		hr_utility.set_location('REFRESH CHANGED SF52.' , 11999);
5521 	end if;
5522 	if (l_changed and p_process_type = 'FUTURE') then
5523 		raise e_refresh;
5524 	end if;
5525     -- Bug#4709111 Reverted the fix done for 4680047. Commented the following code.
5526     -- Bug#4680047
5527 /*    IF p_sf52_data.input_pay_rate_determinant <> l_sf52_refresh_data.pay_rate_determinant THEN
5528        hr_utility.set_location('FWFA RPA Input PRD: '||p_sf52_data.input_pay_rate_determinant,12000);
5529        hr_utility.set_location('FWFA Refresh  PRD: '||l_sf52_refresh_data.pay_rate_determinant,13000);
5530        p_sf52_data.input_pay_rate_determinant := l_sf52_refresh_data.pay_rate_determinant;
5531        p_sf52_data.pay_rate_determinant := l_sf52_refresh_data.pay_rate_determinant;
5532     END IF; */
5533 	print_sf52('sf52 record after cascade: ', p_sf52_data);
5534 	print_sf52('shadow record after cascade: ', l_sf52_shadow);
5535 	print_sf52('refresh record after cascade: ', l_sf52_refresh_data);
5536 	hr_utility.set_location(l_proc, 150);
5537         -- Bug 3704438 - PTH Issue - Start
5538         IF p_sf52_data.work_schedule in ('F', 'G', 'B', 'I', 'J')
5539          and p_sf52_data.part_time_hours is not null then
5540           p_sf52_data.part_time_hours  := null;
5541         END IF;
5542         -- Bug 3704438 - PTH Issue - End
5543           --Calculating Other Pay Components
5544            --Get the retention allowance on that date
5545           ghr_api.retrieve_element_entry_value (p_element_name    => 'Retention Allowance'
5546                                ,p_input_value_name      => 'Amount'
5547                                ,p_assignment_id         => p_sf52_data.employee_assignment_id
5548                                ,p_effective_date        => p_sf52_data.effective_date
5549                                ,p_value                 => l_retention_allowance
5550                                ,p_multiple_error_flag   => l_multi_error_flag);
5551           hr_utility.set_location('Retention Allowance on Eff Date'||l_retention_allowance, 164);
5552           ghr_api.retrieve_element_entry_value (p_element_name    => 'Supervisory Differential'
5553                                ,p_input_value_name      => 'Amount'
5554                                ,p_assignment_id         => p_sf52_data.employee_assignment_id
5555                                ,p_effective_date        => p_sf52_data.effective_date
5556                                ,p_value                 => l_supervisory_differential
5557                                ,p_multiple_error_flag   => l_multi_error_flag);
5558           hr_utility.set_location('Supervisory Differential on Eff Date'||l_supervisory_differential, 165);
5559           ghr_api.retrieve_element_entry_value (p_element_name    => 'Staffing Differential'
5560                                ,p_input_value_name      => 'Amount'
5561                                ,p_assignment_id         => p_sf52_data.employee_assignment_id
5562                                ,p_effective_date        => p_sf52_data.effective_date
5563                                ,p_value                 => l_staffing_differential
5564                                ,p_multiple_error_flag   => l_multi_error_flag);
5565           hr_utility.set_location('Staffing Differential on Eff Date'||l_staffing_differential, 166);
5566 
5567           -- Start Bug 2633367
5568           IF p_sf52_data.first_noa_code in ('810') THEN
5569 	    hr_utility.set_location('l_bef_basic_pay is '||l_bef_basic_pay, 160);
5570 	    hr_utility.set_location('to_basic_pay is '||p_sf52_data.to_basic_pay, 161);
5571 	    hr_utility.set_location('from_basic_pay is '||p_sf52_data.from_basic_pay, 162);
5572             IF nvl(p_sf52_data.from_basic_pay,0) <> nvl(l_bef_basic_pay,0) then
5573               IF p_sf52_data.to_retention_allow_percentage is not null then
5574 
5575    -- Changed For FWS
5576                   IF p_sf52_data.to_pay_basis = 'PH' THEN
5577    		     p_sf52_data.to_retention_allowance :=
5578                             TRUNC(p_sf52_data.to_basic_pay * p_sf52_data.to_retention_allow_percentage/100,2);
5579                   ELSE
5580 		       p_sf52_data.to_retention_allowance :=
5581         		       TRUNC(p_sf52_data.to_basic_pay * p_sf52_data.to_retention_allow_percentage/100,0);
5582                   END IF;
5583                    l_sf52_shadow.to_retention_allowance := p_sf52_data.to_retention_allowance;
5584               END IF;
5585               IF p_sf52_data.to_supervisory_diff_percentage is not null then
5586 	            p_sf52_data.to_supervisory_differential :=
5587 		            ROUND(ghr_pay_calc.convert_amount(p_sf52_data.to_basic_pay,
5588 			                                      p_sf52_data.to_pay_basis,'PA')
5589                                                                * p_sf52_data.to_supervisory_diff_percentage/100,0);
5590 		   l_sf52_shadow.to_supervisory_differential := p_sf52_data.to_supervisory_differential;
5591               END IF;
5592             END IF;
5593           ELSE
5594             IF l_retention_allowance is NULL then
5595               p_sf52_data.to_retention_allowance          :=  NULL;
5596               p_sf52_data.to_retention_allow_percentage   :=  NULL;
5597               l_sf52_shadow.to_retention_allowance        :=  NULL;
5598               l_sf52_shadow.to_retention_allow_percentage :=  NULL;
5599             END IF;
5600             IF l_supervisory_differential is NULL then
5601               p_sf52_data.to_supervisory_differential     :=  NULL;
5602               l_sf52_shadow.to_supervisory_differential   :=  NULL;
5603               p_sf52_data.to_supervisory_diff_percentage  :=  NULL;
5604               l_sf52_shadow.to_supervisory_diff_percentage  :=  NULL;
5605             END IF;
5606             IF l_staffing_differential is NULL then
5607               p_sf52_data.to_staffing_differential      := NULL;
5608               l_sf52_shadow.to_staffing_differential    := NULL;
5609               p_sf52_data.to_staffing_diff_percentage   := NULL;
5610               l_sf52_shadow.to_staffing_diff_percentage := NULL;
5611             END IF;
5612           END IF;
5613           p_sf52_data.to_other_pay_amount := nvl(p_sf52_data.to_au_overtime,0) +
5614                                                nvl(p_sf52_data.to_availability_pay,0) +
5615                                                nvl(p_sf52_data.to_retention_allowance,0) +
5616                                                nvl(p_sf52_data.to_supervisory_differential,0) +
5617                                                nvl(p_sf52_data.to_staffing_differential,0);
5618           hr_utility.set_location('Recalculated Other Pay is '||p_sf52_data.to_other_pay_amount, 166);
5619           if p_sf52_data.to_other_pay_amount = 0 then
5620                 p_sf52_data.to_other_pay_amount := null;
5621           end if;
5622           -- End Bug 2633367
5623 
5624         -- Start Bug 1457792
5625 /* Commenting this portion of code because recalculation of
5626 retention allowance included in ghr_pay_calc.main_pay_calc
5627         if nvl(p_sf52_data.from_basic_pay,0) <> nvl(p_sf52_data.to_basic_pay,0) and
5628           p_sf52_data.first_noa_code not in ('810','818','819') then
5629 	  hr_utility.set_location('Change in Basic Pay and Non Other Pay Action', 163);
5630           --Get the retention allowance and supervisory differential on that date
5631           ghr_api.retrieve_element_entry_value (p_element_name    => 'Retention Allowance'
5632                                ,p_input_value_name      => 'Amount'
5633                                ,p_assignment_id         => p_sf52_data.employee_assignment_id
5634                                ,p_effective_date        => p_sf52_data.effective_date
5635                                ,p_value                 => l_retention_allowance
5636                                ,p_multiple_error_flag   => l_multi_error_flag);
5637 	  hr_utility.set_location('Retention Allowance on Eff Date'||l_retention_allowance, 164);
5638           ghr_api.retrieve_element_entry_value (p_element_name    => 'Supervisory Differential'
5639                                ,p_input_value_name      => 'Amount'
5640                                ,p_assignment_id         => p_sf52_data.employee_assignment_id
5641                                ,p_effective_date        => p_sf52_data.effective_date
5642                                ,p_value                 => l_supervisory_differential
5643                                ,p_multiple_error_flag   => l_multi_error_flag);
5644 	  hr_utility.set_location('Supervisory Differential on Eff Date'||l_supervisory_differential, 165);
5645           if l_retention_allowance is null  then
5646             p_sf52_data.to_retention_allowance := null;
5647             p_sf52_data.to_other_pay_amount := nvl(p_sf52_data.to_au_overtime,0) +
5648                                                nvl(p_sf52_data.to_availability_pay,0) +
5649                                                nvl(p_sf52_data.to_retention_allowance,0) +
5650                                                nvl(p_sf52_data.to_supervisory_differential,0) +
5651                                                nvl(p_sf52_data.to_staffing_differential,0);
5652 	    hr_utility.set_location('Recalculated Other Pay is '||p_sf52_data.to_other_pay_amount, 166);
5653           end if;
5654           if l_supervisory_differential is null  then
5655             p_sf52_data.to_supervisory_differential := null;
5656             p_sf52_data.to_other_pay_amount := nvl(p_sf52_data.to_au_overtime,0) +
5657                                                nvl(p_sf52_data.to_availability_pay,0) +
5658                                                nvl(p_sf52_data.to_retention_allowance,0) +
5659                                                nvl(p_sf52_data.to_supervisory_differential,0) +
5660                                                nvl(p_sf52_data.to_staffing_differential,0);
5661             hr_utility.set_location('Recalculated Other Pay is '||p_sf52_data.to_other_pay_amount, 167);
5662           end if;
5663           if p_sf52_data.to_other_pay_amount = 0 then
5664             p_sf52_data.to_other_pay_amount := null;
5665           end if;
5666         end if;
5667 */
5668         -- End Bug 1457792
5669 	-- Redo Pay Calc
5670 	-- Bug#3228557 Don't process redo_pay_calc for NPA Report
5671 
5672 	IF NVL(p_process_type,hr_api.g_varchar2) <> 'NPA' THEN
5673 	   redo_Pay_calc ( p_sf52_rec => p_sf52_data,
5674                         p_capped_other_pay => l_capped_other_pay);
5675 	END IF;
5676 
5677 	hr_utility.set_location(l_proc, 170);
5678 	ghr_history_conv_rg.convert_sf52_to_shadow (
5679 		p_shadow	 => p_shadow_data,
5680 		p_sf52	 => l_sf52_shadow);
5681 
5682 	hr_utility.set_location('Leaving : ' || l_proc, 180);
5683 
5684 EXCEPTION
5685   WHEN others THEN
5686      -- Reset IN OUT parameters and set OUT parameters
5687 
5688         p_sf52_data := l_sf52_data ;
5689 	p_shadow_data :=NULL ;
5690 
5691    hr_utility.set_location('Leaving  ' || l_proc,160);
5692    RAISE;
5693 
5694 End refresh_req_shadow ;
5695 
5696 
5697 Procedure Redo_Pay_calc ( p_sf52_rec	in out	nocopy ghr_pa_requests%rowtype,
5698                           p_capped_other_pay in out nocopy number ) is
5699 
5700 	l_pay_calc_in_rec	ghr_pay_calc.pay_calc_in_rec_type;
5701 	l_pay_calc_out_rec	ghr_pay_calc.pay_calc_out_rec_type;
5702 	l_message_set		BOOLEAN;
5703 	l_calculated		BOOLEAN;
5704 	l_proc			varchar2(30):='Redo Pay Calc';
5705         l_open_pay_fields_caps  BOOLEAN;
5706         l_message_set_caps      BOOLEAN;
5707         l_entitled_other_pay    number;
5708         l_total_pc              number;
5709 
5710         l_adj_basic_message     BOOLEAN;
5711         l_pay_cap_message       BOOLEAN;
5712         l_temp_retention_allowance NUMBER;
5713 	l_session_var	ghr_history_api.g_session_var_type;
5714         l_multi_error_flag    boolean;
5715 	l_sf52_rec    ghr_pa_requests%rowtype;
5716 	l_capped_other_pay   Number;
5717 
5718 	--Pradeep for Bug 3306515
5719 	l_temp_ret_allo_percentage NUMBER;
5720 
5721 	--BUG # 14032192
5722 	lo_total_salary NUMBER;
5723 	lo_entitled_other_pay NUMBER;
5724 
5725 Begin
5726 	l_capped_other_pay := p_capped_other_pay; --NOCOPY Changes
5727 	l_sf52_rec         := p_sf52_rec ;
5728 
5729 	hr_utility.set_location( 'Entering : ' || l_proc,10);
5730 
5731 	print_sf52('Before redo_pay : ' , p_sf52_rec);
5732 
5733 	 If nvl(p_sf52_rec.noa_family_code,hr_api.g_varchar2)
5734 	   in ('APP', 'CHG_DUTY_STATION', 'CONV_APP', 'POS_CHG',
5735  	       'REASSIGNMENT') or
5736 		(nvl(p_sf52_rec.noa_family_code,hr_api.g_varchar2) like 'GHR_SAL%')
5737 	 then
5738 	     -- and (p_sf52_rec.first_noa_code <> '899') and
5739              -- not (p_sf52_rec.first_noa_code = '002' and
5740              --	p_sf52_rec.second_noa_code = '899')
5741             hr_utility.set_location('Valid Family ' || l_proc, 11);
5742             If nvl(p_sf52_rec.custom_pay_calc_flag,hr_api.g_varchar2) <> 'Y' then
5743                 hr_utility.set_location('Custom Pay Calc is NOT Y ' || l_proc, 12);
5744         	hr_utility.set_location('Input PRD : '||p_sf52_rec.input_pay_rate_determinant, 14);
5745         	hr_utility.set_location('PRD : '||p_sf52_rec.pay_rate_determinant, 14);
5746 		l_pay_calc_in_rec.pa_request_id                 :=  p_sf52_rec.pa_request_id;
5747 		l_pay_calc_in_rec.person_id           	      :=  p_sf52_rec.person_id;
5748 		l_pay_calc_in_rec.position_id          		:=  p_sf52_rec.to_position_id;
5749 		l_pay_calc_in_rec.noa_family_code      		:=  p_sf52_rec.noa_family_code;
5750 		l_pay_calc_in_rec.noa_code                      :=  p_sf52_rec.first_noa_code;
5751 		l_pay_calc_in_rec.second_noa_code      		:=  p_sf52_rec.second_noa_code;
5752 		l_pay_calc_in_rec.first_action_la_code1         :=  p_sf52_rec.first_action_la_code1;
5753 		l_pay_calc_in_rec.effective_date       		:=  p_sf52_rec.effective_date;
5754         -- FWFA Changes Bug#4444609 Modified the passed parameter as input_pay_rate_determinant.
5755 		l_pay_calc_in_rec.pay_rate_determinant 		:=  NVL(p_sf52_rec.input_pay_rate_determinant,
5756                                                             p_sf52_rec.pay_rate_determinant);
5757         -- FWFA Changes
5758 		l_pay_calc_in_rec.pay_plan             		:=  p_sf52_rec.to_pay_plan;
5759 		l_pay_calc_in_rec.grade_or_level       		:=  p_sf52_rec.to_grade_or_level;
5760 		l_pay_calc_in_rec.step_or_rate         		:=  p_sf52_rec.to_step_or_rate;
5761 		l_pay_calc_in_rec.pay_basis           	 	:=  p_sf52_rec.to_pay_basis;
5762 
5763 		-- Bug # 12647449 Modified for Pay table Identifier
5764 		-- Bug # 13587695 Modified to pass pay table identifier for corrections
5765                 IF  l_sf52_rec.first_noa_code = '002' THEN
5766                     l_pay_calc_in_rec.user_table_id             :=  p_sf52_rec.to_pay_table_identifier;
5767                 ELSE
5768   	   	    l_pay_calc_in_rec.user_table_id    		:=  NULL;
5769                 END IF;
5770 
5771 		l_pay_calc_in_rec.duty_station_id      	   	:=  p_sf52_rec.duty_station_id;
5772 		l_pay_calc_in_rec.auo_premium_pay_indicator 	:=  p_sf52_rec.to_auo_premium_pay_indicator;
5773 		l_pay_calc_in_rec.ap_premium_pay_indicator      :=  p_sf52_rec.to_ap_premium_pay_indicator;
5774 
5775 		--Open Pay Range Basic Pay assigning to in basic.
5776 			if ghr_pay_calc.get_open_pay_range ( p_sf52_rec.to_position_id
5777 								  , p_sf52_rec.person_id
5778 								  , p_sf52_rec.pay_rate_determinant
5779 								  , p_sf52_rec.pa_request_id
5780 								  , NVL(p_sf52_rec.effective_date,TRUNC(sysdate)) ) then
5781 			   if p_sf52_rec.to_basic_pay is not null then
5782 				  l_pay_calc_in_rec.open_range_out_basic_pay := p_sf52_rec.to_basic_pay;
5783 			   end if;
5784 			end if;
5785 		--Open Pay Range Code end.
5786 
5787 		--Bug#5132113
5788 		  l_pay_calc_in_rec.open_out_locality_adj := p_sf52_rec.to_locality_adj;
5789 		--Bug#5132113
5790 
5791 		-- Changes for RA re-calc using ghr_pay_calc
5792 		-- Bug 2633367
5793 		-- Here the sql_main_pay_calc wants the retention allowance in the DB
5794 		-- Since redo_pay_calc will be called number of times during the Update HR
5795 		-- and we can not use the p_sf52_rec.retention_allowance  as this value
5796 		-- might be a re-computed value in the earlier call to sql_main_pay_calc
5797 		--  That's why we are fetching the retention_allowance from DB
5798                 IF p_sf52_rec.employee_assignment_id is not null and
5799                    p_sf52_rec.effective_date is not null
5800 				   THEN
5801 						-- Bug 4689374 - If FWFA then, dont take from element entry.
5802 						IF p_sf52_rec.noa_family_code like 'GHR_SAL%' AND
5803 							p_sf52_rec.pay_rate_determinant IN ('3','4','J','K','U','V') AND
5804 							p_sf52_rec.effective_date >= to_date('01/05/2005','dd/mm/yyyy') THEN
5805 								l_pay_calc_in_rec.retention_allowance :=  p_sf52_rec.to_retention_allowance;
5806 								hr_utility.set_location('setting retention - fwfa ' || p_sf52_rec.to_retention_allowance,120);
5807 						ELSE
5808 							ghr_api.retrieve_element_entry_value
5809 								   (p_element_name          => 'Retention Allowance'
5810 								   ,p_input_value_name      => 'Amount'
5811 								   ,p_assignment_id         => p_sf52_rec.employee_assignment_id
5812 								   ,p_effective_date        => p_sf52_rec.effective_date
5813 								   ,p_value                 => l_pay_calc_in_rec.retention_allowance
5814 								   ,p_multiple_error_flag   => l_multi_error_flag);
5815 						END IF;-- IF p_sf52_rec.noa_family_code like 'GHR_S
5816 						-- End Bug 4689374
5817                 ELSE
5818 	                l_pay_calc_in_rec.retention_allowance           :=  p_sf52_rec.to_retention_allowance;
5819                 END IF;
5820                 --  Start 2588150
5821                 l_pay_calc_in_rec.to_ret_allow_percentage       :=  p_sf52_rec.to_retention_allow_percentage;
5822                 --  End 2588150
5823 				l_pay_calc_in_rec.supervisory_differential   	:=  p_sf52_rec.to_supervisory_differential;
5824 				l_pay_calc_in_rec.staffing_differential  	:=  p_sf52_rec.to_staffing_differential;
5825 				l_pay_calc_in_rec.current_basic_pay  		:=  p_sf52_rec.from_basic_pay;
5826 				l_pay_calc_in_rec.current_adj_basic_pay   	:=  p_sf52_rec.from_adj_basic_pay;
5827 				l_pay_calc_in_rec.current_step_or_rate          :=  p_sf52_rec.from_step_or_rate;
5828 
5829 						hr_utility.set_location('Before Main Pay Calc  ' || l_proc, 13);
5830         			hr_utility.set_location('Pay Calc In PRD : '||l_pay_calc_in_rec.pay_rate_determinant, 14);
5831 
5832 
5833 				ghr_pay_calc.sql_main_pay_calc
5834 				( p_pay_calc_data        =>  l_pay_calc_in_rec,
5835 				  p_pay_calc_out_data	 =>  l_pay_calc_out_rec,
5836 				  p_message_set          =>  l_message_set,
5837 				  p_calculated           =>  l_calculated
5838 				 );
5839 
5840                 hr_utility.set_location('After Main Pay Calc  ' || l_proc, 13);
5841                 if l_calculated then
5842                    hr_utility.set_location('l_Calculated is TRUE  ' || l_proc, 13);
5843                 else
5844                    hr_utility.set_location('l_Calculated is FASLE  ' || l_proc, 13);
5845                 end if;
5846          If not nvl(l_pay_calc_out_rec.open_pay_fields, FALSE) then
5847               hr_utility.set_location('pay fields not open',1);
5848 
5849               If l_calculated  then
5850                   -- assign
5851                 hr_utility.set_location( ' Not Custom Pay Calc : ' || l_proc,12);
5852 
5853                 p_sf52_rec.custom_pay_calc_flag         := 'N';
5854                 -- FWFA Changes Bug#4444609
5855                 p_sf52_rec.from_pay_table_identifier    := l_pay_calc_out_rec.pay_table_id;
5856                 p_sf52_rec.to_pay_table_identifier	:= l_pay_calc_out_rec.calculation_pay_table_id;
5857                 -- FWFA Changes
5858                 p_sf52_rec.to_basic_pay                 := l_pay_calc_out_rec.basic_pay;
5859                 p_sf52_rec.to_locality_adj              := l_pay_calc_out_rec.locality_adj;
5860                 p_sf52_rec.to_adj_basic_pay             := l_pay_calc_out_rec.adj_basic_pay;
5861                 p_sf52_rec.to_total_salary              := l_pay_calc_out_rec.total_salary;
5862                 p_sf52_rec.to_retention_allowance       := l_pay_calc_out_rec.retention_allowance;
5863                 p_sf52_rec.to_other_pay_amount          := l_pay_calc_out_rec.other_pay_amount;
5864                 p_sf52_rec.to_au_overtime               := l_pay_calc_out_rec.au_overtime;
5865                 p_sf52_rec.to_availability_pay          := l_pay_calc_out_rec.availability_pay;
5866                 -- Start Processing for bug 2684176
5867                 IF p_sf52_rec.first_noa_code = '894' THEN
5868                     g_prd := l_pay_calc_out_rec.out_pay_rate_determinant;
5869                     g_step_or_rate := l_pay_calc_out_rec.out_step_or_rate;
5870                     IF g_prd is NOT NULL THEN
5871                        IF l_pay_calc_out_rec.out_step_or_rate IS NOT NULL THEN
5872                           IF nvl(g_prd,'0') not in ('A','B','E','F','U','V') THEN
5873 			    hr_utility.set_location('Inside G_prd condition',10);
5874                             p_sf52_rec.to_step_or_rate  :=
5875                                 NVL(l_pay_calc_out_rec.out_step_or_rate, p_sf52_rec.to_step_or_rate);
5876 ----Bug 2914406 fix start
5877                             p_sf52_rec.pay_rate_determinant :=
5878                                   NVL(l_pay_calc_out_rec.out_pay_rate_determinant, p_sf52_rec.pay_rate_determinant);
5879 ----Bug 2914406 fix End
5880                           END IF;
5881 		               ELSE
5882               			    hr_utility.set_location('Inside G_prd condition and g_step null',10);
5883                            p_sf52_rec.pay_rate_determinant :=
5884                                   NVL(l_pay_calc_out_rec.out_pay_rate_determinant, p_sf52_rec.pay_rate_determinant);
5885                        END IF;
5886                    ELSE
5887   		        hr_utility.set_location('Inside G_prd NULL condition',10);
5888                         -- FWFA Changes Bug#4444609 Modified the value of PRD.
5889                         p_sf52_rec.pay_rate_determinant :=
5890                                       NVL(p_sf52_rec.input_pay_rate_determinant, p_sf52_rec.pay_rate_determinant);
5891                         -- FWFA Changes
5892                         p_sf52_rec.to_step_or_rate  :=
5893                                       NVL(l_pay_calc_out_rec.out_step_or_rate, p_sf52_rec.to_step_or_rate);
5894                    END IF;
5895                 ELSE
5896                   -- FWFA Changes Bug#4444609 Modified the value of PRD
5897 		  hr_utility.set_location('inside NON 894 Actions ',20);
5898                   p_sf52_rec.pay_rate_determinant :=
5899                                 NVL(l_pay_calc_out_rec.out_pay_rate_determinant,
5900                                     NVL(p_sf52_rec.input_pay_rate_determinant,p_sf52_rec.pay_rate_determinant)
5901                                     );
5902                   -- FWFA Changes
5903                   p_sf52_rec.to_step_or_rate  :=
5904                                 NVL(l_pay_calc_out_rec.out_step_or_rate, p_sf52_rec.to_step_or_rate);
5905                 END IF;
5906                             -- End Processing for bug 2684176
5907               End if;
5908          Elsif l_pay_calc_out_rec.open_pay_fields then
5909                   hr_utility.set_location('open pay fields',1);
5910   	            hr_utility.set_location( 'Error - Pay Calc failed ' || l_proc, 90);
5911 	            hr_utility.set_message(8301,'GHR_38401_OPEN_PAY');
5912                   hr_utility.raise_error;
5913 			--     error; -- send back to user
5914 
5915          End if;
5916       End if;
5917 	 Elsif nvl(p_sf52_rec.noa_family_code,hr_api.g_varchar2) = 'OTHER_PAY'
5918 		then
5919 	    -- and  (p_sf52_rec.first_noa_code <> '899') and not (p_sf52_rec.first_noa_code = '002' and
5920              --	p_sf52_rec.second_noa_code = '899')
5921 		hr_utility.set_location( 'Other Pay Calculation ' || l_proc, 95);
5922 		-- fOR OTHER PAY family calculate other_pay_amount and total_pay_amount
5923 		p_sf52_rec.to_other_pay_amount :=	nvl(p_sf52_rec.to_au_overtime             , 0) +
5924 								nvl(p_sf52_rec.to_availability_pay        , 0) +
5925 								nvl(p_sf52_rec.to_retention_allowance     , 0) +
5926 								nvl(p_sf52_rec.to_supervisory_differential, 0) +
5927 								nvl(p_sf52_rec.to_staffing_differential   , 0);
5928                 -- FWS Changes
5929 		p_sf52_rec.to_total_salary := p_sf52_rec.to_adj_basic_pay +
5930                                               NVL(p_sf52_rec.to_other_pay_amount,0);
5931 
5932 	End if;
5933 	-- VSM temp call
5934         -- Begin Update 34 - Validation Logic
5935 	  hr_utility.set_location( 'Before calling do_pay_caps_main noa_family_code is ' ||p_sf52_rec.noa_family_code, 95);
5936           ghr_history_api.get_g_session_var( l_session_var);
5937           -- Bug#4486823 RRR Changes. Added GHR_INCENTIVE Family also.
5938 	  IF not (p_sf52_rec.noa_family_code in
5939                      ('POS_REVIEW',
5940                       'RECRUIT_FILL',
5941                       'NON_PAY_DUTY_STATUS',
5942                       'POS_ESTABLISH',
5943                       'AWARD',
5944 		      'GHR_INCENTIVE',
5945                       'SEPARATION',
5946                       'POS_ABOLISH')
5947 /*BUG 7186053 Commented the below line as it is not required. Code in the if clause should not run for
5948 all the NOA Families mentioned in the condition. */
5949                  -- AND  l_session_var.noa_id_correct is not NULL) THEN
5950 			) THEN
5951 	  hr_utility.set_location( 'Before calling do_pay_caps_main ' ||p_capped_other_pay , 95);
5952 	  hr_utility.set_location( 'p_sf52_rec.to_total_salary is ' || p_sf52_rec.to_total_salary, 95);
5953 
5954           --BUG # 14032192 passing total salary as addition of adjusted basic pay and other pay
5955 	  lo_total_salary  := p_sf52_rec.to_total_salary;
5956           if nvl(p_sf52_rec.noa_family_code,hr_api.g_varchar2) <> 'OTHER_PAY' THEN
5957              if p_sf52_rec.to_other_pay_amount is not null then
5958                 lo_entitled_other_pay := nvl(p_sf52_rec.to_au_overtime             , 0) +
5959                         		 nvl(p_sf52_rec.to_availability_pay        , 0) +
5960                           		 nvl(p_sf52_rec.to_retention_allowance     , 0) +
5961                           		 nvl(p_sf52_rec.to_supervisory_differential, 0) +
5962                               		 nvl(p_sf52_rec.to_staffing_differential   , 0);
5963 
5964                 lo_total_salary  := p_sf52_rec.to_adj_basic_pay +
5965                                      nvl(lo_entitled_other_pay,0);
5966              end if;
5967           end if;
5968 
5969         IF p_capped_other_pay <> hr_api.g_number OR
5970            p_capped_other_pay is NULL THEN
5971 	  hr_utility.set_location( 'p_sf52_rec.to_total_salary is ' || p_sf52_rec.to_total_salary, 95);
5972 
5973           ghr_pay_caps.do_pay_caps_main (
5974            p_pa_request_id        =>    p_sf52_rec.pa_request_id,
5975            p_effective_date       =>    NVL(p_sf52_rec.effective_date,TRUNC(sysdate)) ,
5976 	   p_duty_station_id      =>    p_sf52_rec.duty_station_id, --bug# 13414643,13403289
5977            p_pay_rate_determinant =>    p_sf52_rec.pay_rate_determinant ,
5978            p_pay_plan             =>    p_sf52_rec.to_pay_plan ,
5979            p_to_position_id       =>    p_sf52_rec.to_position_id ,
5980            p_pay_basis            =>    p_sf52_rec.to_pay_basis ,
5981            p_person_id            =>    p_sf52_rec.person_id ,
5982            p_noa_code             =>    p_sf52_rec.first_noa_code ,
5983            p_basic_pay            =>    p_sf52_rec.to_basic_pay ,
5984            p_locality_adj         =>    p_sf52_rec.to_locality_adj ,
5985            p_adj_basic_pay        =>    p_sf52_rec.to_adj_basic_pay
5986            ,p_total_salary         =>    lo_total_salary
5987            ,p_other_pay_amount     =>    p_sf52_rec.to_other_pay_amount
5988            ,p_capped_other_pay     =>    p_capped_other_pay
5989            ,p_retention_allowance  =>    p_sf52_rec.to_retention_allowance
5990            ,p_retention_allow_percentage  =>    p_sf52_rec.to_retention_allow_percentage
5991            ,p_supervisory_allowance =>   p_sf52_rec.to_supervisory_differential
5992            ,p_staffing_differential =>   p_sf52_rec.to_staffing_differential
5993            ,p_au_overtime          =>    p_sf52_rec.to_au_overtime
5994            ,p_availability_pay     =>    p_sf52_rec.to_availability_pay
5995                    ,p_adj_basic_message    =>    l_adj_basic_message
5996                    ,p_pay_cap_message      =>    l_pay_cap_message
5997                    ,p_pay_cap_adj          =>    l_temp_retention_allowance
5998            ,p_open_pay_fields      =>    l_open_pay_fields_caps
5999            ,p_message_set          =>    l_message_set_caps
6000            ,p_total_pay_check      =>    g_total_pay_check);
6001 
6002 
6003 	   p_sf52_rec.to_total_salary  := lo_total_salary;
6004 
6005            p_sf52_rec.to_other_pay_amount := nvl(p_capped_other_pay,p_sf52_rec.to_other_pay_amount);
6006 
6007            l_temp_ret_allo_percentage := trunc((l_temp_retention_allowance/p_sf52_rec.to_basic_pay)*100,2);
6008 
6009            if l_pay_cap_message then
6010 				hr_utility.raise_error;
6011 				-- This would show the error message with tokens passed with
6012 				-- the values from the sub-program called above - do_pay_caps_main.
6013 				-- So no need to explicitly again initiate the error message
6014 				-- and set of the tokens seperately. Earlier 38893 message was called here.
6015 				-- 4085704
6016 			end if;
6017 
6018        END IF;
6019        END IF;
6020 
6021 
6022         -- End Update 34 - Validation Logic
6023 	print_sf52('After redo_pay : ' , p_sf52_rec);
6024 
6025 	hr_utility.set_location( 'Leaving :  ' || l_proc,100);
6026 
6027 EXCEPTION
6028   WHEN others THEN
6029      -- Reset IN OUT parameters and set OUT parameters
6030 
6031         p_capped_other_pay := l_capped_other_pay;
6032 	p_sf52_rec         := l_sf52_rec ;
6033 
6034    hr_utility.set_location('Leaving  ' || l_proc,101);
6035    RAISE;
6036 
6037 End redo_pay_calc;
6038 
6039 
6040 Procedure Update_rfrs_values( p_sf52_data   in out nocopy ghr_pa_requests%rowtype,
6041 			                  p_shadow_data in     ghr_pa_request_shadow%rowtype) is
6042 	cursor get_par_ovn is
6043 	select
6044 		object_version_number
6045 	from ghr_pa_requests
6046 	where pa_request_id = p_Sf52_data.pa_request_id;
6047 
6048         cursor get_person_type is
6049           select ppt.system_person_type
6050           from   per_people_f ppf,
6051                  per_person_types ppt
6052           where   ppf.person_id = p_sf52_data.person_id
6053           and     p_sf52_data.effective_date
6054           between ppf.effective_start_date
6055           and     ppf.effective_end_date
6056           and     ppt.person_type_id = ppf.person_type_id;
6057 
6058 
6059 	l_result	Boolean;
6060 	l_ovn		ghr_pa_requests.object_version_number%type;
6061         l_per_type      per_person_types.system_person_type%type;
6062 	l_sf52_data     ghr_pa_requests%rowtype;
6063 
6064 
6065 Begin
6066 
6067         l_sf52_data := p_sf52_data ; --NOCOPY Changes
6068 
6069 	open get_par_ovn;
6070 	fetch get_par_ovn into l_ovn;
6071 	close get_par_ovn;
6072 
6073 -- Update SF52
6074 -- If future Action and rehire of an ex_employee, then
6075 -- no assignment will exist for the person, as we have rolled back the changes
6076 -- that would have generated an assignment_id. Hence it is required to make sure
6077 -- that the assignment_id on the SF52 does not get refreshed with any new value.
6078 
6079       If trunc(p_sf52_data.effective_date) >  trunc(sysdate) then
6080         for per_type  in get_person_type  loop
6081           l_per_type := per_type.system_person_type;
6082         end loop;
6083         If nvl(l_per_type,hr_api.g_varchar2) = 'EX_EMP' then
6084             p_sf52_data.employee_assignment_id := Null;
6085         End if;
6086       End if;
6087 
6088 -- Note : Ver 10.53 fix
6089 --  Commented out all the columns that are specific to notification
6090 -- Bug 1304629 uncommented p_agency_code, p_employee_dept_or_agency
6091 	ghr_par_upd.upd
6092 		(p_pa_request_id                 =>  p_sf52_data.pa_request_id
6093 		,p_academic_discipline           =>  p_sf52_data.academic_discipline
6094 		,p_agency_code                   =>  p_sf52_data.agency_code
6095 		,p_annuitant_indicator           =>  p_sf52_data.annuitant_indicator
6096 		,p_annuitant_indicator_desc      =>  p_sf52_data.annuitant_indicator_desc
6097 		,p_appropriation_code1           =>  p_sf52_data.appropriation_code1
6098 		,p_appropriation_code2           =>  p_sf52_data.appropriation_code2
6099 		,p_award_amount                  =>  p_sf52_data.award_amount
6100 		,p_award_uom                     =>  p_sf52_data.award_uom
6101 		,p_bargaining_unit_status        =>  p_sf52_data.bargaining_unit_status
6102 		,p_citizenship                   =>  p_sf52_data.citizenship
6103 		,p_custom_pay_calc_flag          =>  p_sf52_data.custom_pay_calc_flag
6104 		,p_duty_station_code             =>  p_sf52_data.duty_station_code
6105 		,p_duty_station_desc             =>  p_sf52_data.duty_station_desc
6106 		,p_duty_station_id               =>  p_sf52_data.duty_station_id
6107 		,p_duty_station_location_id      =>  p_sf52_data.duty_station_location_id
6108 		,p_education_level               =>  p_sf52_data.education_level
6109 		,p_employee_assignment_id        =>  p_sf52_data.employee_assignment_id
6110 		,p_employee_date_of_birth        =>  p_sf52_data.employee_date_of_birth
6111 		,p_employee_dept_or_agency       =>  p_sf52_data.employee_dept_or_agency
6112 		,p_employee_first_name           =>  p_sf52_data.employee_first_name
6113 		,p_employee_last_name            =>  p_sf52_data.employee_last_name
6114 		,p_employee_middle_names         =>  p_sf52_data.employee_middle_names
6115 		,p_employee_national_identifier  =>  p_sf52_data.employee_national_identifier
6116 		,p_fegli                         =>  p_sf52_data.fegli
6117 		,p_fegli_desc                    =>  p_sf52_data.fegli_desc
6118 		,p_flsa_category                 =>  p_sf52_data.flsa_category
6119 		,p_forwarding_address_line1      =>  p_sf52_data.forwarding_address_line1
6120 		,p_forwarding_address_line2      =>  p_sf52_data.forwarding_address_line2
6121 		,p_forwarding_address_line3      =>  p_sf52_data.forwarding_address_line3
6122 		,p_forwarding_country            =>  p_sf52_data.forwarding_country
6123 		,p_forwarding_country_short_nam  =>  p_sf52_data.forwarding_country_short_name
6124 		,p_forwarding_postal_code        =>  p_sf52_data.forwarding_postal_code
6125 		,p_forwarding_region_2           =>  p_sf52_data.forwarding_region_2
6126 		,p_forwarding_town_or_city       =>  p_sf52_data.forwarding_town_or_city
6127 		,p_from_adj_basic_pay            =>  p_sf52_data.from_adj_basic_pay
6128 --		,p_from_agency_code              =>  p_sf52_data.from_agency_code
6129 --		,p_from_agency_desc              =>  p_sf52_data.from_agency_desc
6130 		,p_from_basic_pay                =>  p_sf52_data.from_basic_pay
6131 		,p_from_grade_or_level           =>  p_sf52_data.from_grade_or_level
6132 		,p_from_locality_adj             =>  p_sf52_data.from_locality_adj
6133 		,p_from_occ_code                 =>  p_sf52_data.from_occ_code
6134 --		,p_from_office_symbol            =>  p_sf52_data.from_office_symbol
6135 		,p_from_other_pay_amount         =>  p_sf52_data.from_other_pay_amount
6136 		,p_from_pay_basis                =>  p_sf52_data.from_pay_basis
6137 		,p_from_pay_plan                 =>  p_sf52_data.from_pay_plan
6138         -- FWFA Changes Bug#4444609
6139         ,p_input_pay_rate_determinant    =>  p_sf52_data.input_pay_rate_determinant
6140         ,p_from_pay_table_identifier     =>  p_sf52_data.from_pay_table_identifier
6141         -- FWFA Changes
6142 		,p_from_position_id              =>  p_sf52_data.from_position_id
6143 		,p_from_position_org_line1       =>  p_sf52_data.from_position_org_line1
6144 		,p_from_position_org_line2       =>  p_sf52_data.from_position_org_line2
6145 		,p_from_position_org_line3       =>  p_sf52_data.from_position_org_line3
6146 		,p_from_position_org_line4       =>  p_sf52_data.from_position_org_line4
6147 		,p_from_position_org_line5       =>  p_sf52_data.from_position_org_line5
6148 		,p_from_position_org_line6       =>  p_sf52_data.from_position_org_line6
6149 		,p_from_position_number          =>  p_sf52_data.from_position_number
6150 		,p_from_position_seq_no          =>  p_sf52_data.from_position_seq_no
6151 		,p_from_position_title           =>  p_sf52_data.from_position_title
6152 		,p_from_step_or_rate             =>  p_sf52_data.from_step_or_rate
6153 		,p_from_total_salary             =>  p_sf52_data.from_total_salary
6154 		,p_functional_class              =>  p_sf52_data.functional_class
6155 		,p_notepad                       =>  p_sf52_data.notepad
6156 		,p_part_time_hours               =>  p_sf52_data.part_time_hours
6157 		,p_pay_rate_determinant          =>  p_sf52_data.pay_rate_determinant
6158 --		,p_personnel_office_id           =>  p_sf52_data.personnel_office_id
6159 		,p_person_id                     =>  p_sf52_data.person_id
6160 		,p_position_occupied             =>  p_sf52_data.position_occupied
6161 		,p_requesting_office_remarks_de  =>  p_sf52_data.requesting_office_remarks_desc
6162 		,p_requesting_office_remarks_fl  =>  p_sf52_data.requesting_office_remarks_flag
6163 		,p_resign_and_retire_reason_des  =>  p_sf52_data.resign_and_retire_reason_desc
6164 		,p_retirement_plan               =>  p_sf52_data.retirement_plan
6165 		,p_retirement_plan_desc          =>  p_sf52_data.retirement_plan_desc
6166 		,p_service_comp_date             =>  p_sf52_data.service_comp_date
6167 		,p_supervisory_status            =>  p_sf52_data.supervisory_status
6168 		,p_tenure                        =>  p_sf52_data.tenure
6169 		,p_to_adj_basic_pay              =>  p_sf52_data.to_adj_basic_pay
6170 		,p_to_basic_pay                  =>  p_sf52_data.to_basic_pay
6171 		,p_to_grade_id                   =>  p_sf52_data.to_grade_id
6172 		,p_to_grade_or_level             =>  p_sf52_data.to_grade_or_level
6173 		,p_to_job_id                     =>  p_sf52_data.to_job_id
6174 		,p_to_locality_adj               =>  p_sf52_data.to_locality_adj
6175 		,p_to_occ_code                   =>  p_sf52_data.to_occ_code
6176 	--	,p_to_office_symbol              =>  p_sf52_data.to_office_symbol
6177 	        ,p_to_organization_id            =>  p_sf52_data.to_organization_id
6178 		,p_to_other_pay_amount           =>  p_sf52_data.to_other_pay_amount
6179 		,p_to_au_overtime                =>  p_sf52_data.to_au_overtime
6180 		,p_to_auo_premium_pay_indicator  =>  p_sf52_data.to_auo_premium_pay_indicator
6181 		,p_to_availability_pay           =>  p_sf52_data.to_availability_pay
6182 		,p_to_ap_premium_pay_indicator   =>  p_sf52_data.to_ap_premium_pay_indicator
6183 		,p_to_retention_allowance        =>  p_sf52_data.to_retention_allowance
6184 		,p_to_retention_allow_percentag =>  p_sf52_data.to_retention_allow_percentage
6185 		,p_to_supervisory_differential   =>  p_sf52_data.to_supervisory_differential
6186 		,p_to_supervisory_diff_percenta=>  p_sf52_data.to_supervisory_diff_percentage
6187 		,p_to_staffing_differential      =>  p_sf52_data.to_staffing_differential
6188 		,p_to_staffing_diff_percentage   =>  p_sf52_data.to_staffing_diff_percentage
6189 		,p_to_pay_basis                  =>  p_sf52_data.to_pay_basis
6190 		,p_to_pay_plan                   =>  p_sf52_data.to_pay_plan
6191         -- FWFA Changes Bug#4444609
6192         ,p_to_pay_table_identifier       =>  p_sf52_data.to_pay_table_identifier
6193         -- FWFA Changes
6194 		,p_to_position_id                =>  p_sf52_data.to_position_id
6195 		,p_to_position_org_line1         =>  p_sf52_data.to_position_org_line1
6196 		,p_to_position_org_line2         =>  p_sf52_data.to_position_org_line2
6197 		,p_to_position_org_line3         =>  p_sf52_data.to_position_org_line3
6198 		,p_to_position_org_line4         =>  p_sf52_data.to_position_org_line4
6199 		,p_to_position_org_line5         =>  p_sf52_data.to_position_org_line5
6200 		,p_to_position_org_line6         =>  p_sf52_data.to_position_org_line6
6201 		,p_to_position_number            =>  p_sf52_data.to_position_number
6202 		,p_to_position_seq_no            =>  p_sf52_data.to_position_seq_no
6203 		,p_to_position_title             =>  p_sf52_data.to_position_title
6204 		,p_to_step_or_rate               =>  p_sf52_data.to_step_or_rate
6205 		,p_to_total_salary               =>  p_sf52_data.to_total_salary
6206 		,p_veterans_preference           =>  p_sf52_data.veterans_preference
6207 		,p_veterans_pref_for_rif         =>  p_sf52_data.veterans_pref_for_rif
6208 		,p_veterans_status               =>  p_sf52_data.veterans_status
6209 		,p_work_schedule                 =>  p_sf52_data.work_schedule
6210 		,p_work_schedule_desc            =>  p_sf52_data.work_schedule_desc
6211 		,p_year_degree_attained          =>  p_sf52_data.year_degree_attained
6212 		,p_attribute_category            =>  p_sf52_data.attribute_category
6213 		,p_attribute1                    =>  p_sf52_data.attribute1
6214 		,p_attribute2                    =>  p_sf52_data.attribute2
6215 		,p_attribute3                    =>  p_sf52_data.attribute3
6216 		,p_attribute4                    =>  p_sf52_data.attribute4
6217 		,p_attribute5                    =>  p_sf52_data.attribute5
6218 		,p_attribute6                    =>  p_sf52_data.attribute6
6219 		,p_attribute7                    =>  p_sf52_data.attribute7
6220 		,p_attribute8                    =>  p_sf52_data.attribute8
6221 		,p_attribute9                    =>  p_sf52_data.attribute9
6222 		,p_attribute10                   =>  p_sf52_data.attribute10
6223 		,p_attribute11                   =>  p_sf52_data.attribute11
6224 		,p_attribute12                   =>  p_sf52_data.attribute12
6225 		,p_attribute13                   =>  p_sf52_data.attribute13
6226 		,p_attribute14                   =>  p_sf52_data.attribute14
6227 		,p_attribute15                   =>  p_sf52_data.attribute15
6228 		,p_attribute16                   =>  p_sf52_data.attribute16
6229 		,p_attribute17                   =>  p_sf52_data.attribute17
6230 		,p_attribute18                   =>  p_sf52_data.attribute18
6231 		,p_attribute19                   =>  p_sf52_data.attribute19
6232 		,p_attribute20                   =>  p_sf52_data.attribute20
6233 		,p_object_version_number         =>  l_ovn);
6234 
6235 		p_sf52_data.object_version_number := l_ovn;
6236 
6237 -- Following commented columns need not be refreshed as theses are entered by the user or are generated
6238 -- at the time notification is created.
6239 -- p_pa_notification_id            =>  p_sf52_data.pa_notification_id
6240 -- p_noa_family_code               =>  p_sf52_data.noa_family_code
6241 -- p_routing_group_id              =>  p_sf52_data.routing_grou  =>  p_sf52_data.id
6242 -- p_proposed_effective_asap_flag  =>  p_sf52_data.proposed_effective_asap_sf52_
6243 -- p_additional_info_person_id     =>  p_sf52_data.additional_info_person_id
6244 -- p_additional_info_tel_number    =>  p_sf52_data.additional_info_tel_number
6245 -- p_altered_pa_request_id         =>  p_sf52_data.altered_pa_request_id
6246 -- p_approval_date                 =>  p_sf52_data.approval_date
6247 -- p_approving_official_work_titl  =>  p_sf52_data.approving_official_work_title
6248 -- p_authorized_by_person_id       =>  p_sf52_data.authorized_by_person_id
6249 -- p_authorized_by_title           =>  p_sf52_data.authorized_by_title
6250 -- p_concurrence_date              =>  p_sf52_data.concurrence_date
6251 -- p_effective_date                =>  p_sf52_data.effective_date
6252 -- p_first_action_la_code1         =>  p_sf52_data.first_action_la_code1
6253 -- p_first_action_la_code2         =>  p_sf52_data.first_action_la_code2
6254 -- p_first_action_la_desc1         =>  p_sf52_data.first_action_la_desc1
6255 -- p_first_action_la_desc2         =>  p_sf52_data.first_action_la_desc2
6256 -- p_first_noa_cancel_or_correct   =>  p_sf52_data.first_noa_cancel_or_correct
6257 -- p_first_noa_code                =>  p_sf52_data.first_noa_code
6258 -- p_first_noa_desc                =>  p_sf52_data.first_noa_desc
6259 -- p_first_noa_id                  =>  p_sf52_data.first_noa_id
6260 -- p_first_noa_pa_request_id       =>  p_sf52_data.first_noa_pa_request_id
6261 -- p_proposed_effective_date       =>  p_sf52_data.proposed_effective_date
6262 -- p_requested_by_person_id        =>  p_sf52_data.requested_by_person_id
6263 -- p_requested_by_title            =>  p_sf52_data.requested_by_title
6264 -- p_requested_date                =>  p_sf52_data.requested_date
6265 -- p_request_number                =>  p_sf52_data.request_number
6266 -- p_second_action_la_code1        =>  p_sf52_data.second_action_la_code1
6267 -- p_second_action_la_code2        =>  p_sf52_data.second_action_la_code2
6268 -- p_second_action_la_desc1        =>  p_sf52_data.second_action_la_desc1
6269 -- p_second_action_la_desc2        =>  p_sf52_data.second_action_la_desc2
6270 -- p_second_noa_cancel_or_correct  =>  p_sf52_data.second_noa_cancel_or_correct
6271 -- p_second_noa_code               =>  p_sf52_data.second_noa_code
6272 -- p_second_noa_desc               =>  p_sf52_data.second_noa_desc
6273 -- p_second_noa_id                 =>  p_sf52_data.second_noa_id
6274 -- p_second_noa_pa_request_id      =>  p_sf52_data.second_noa_pa_request_id
6275 -- p_first_noa_information1        =>  p_sf52_data.first_noa_information1
6276 -- p_first_noa_information2        =>  p_sf52_data.first_noa_information2
6277 -- p_first_noa_information3        =>  p_sf52_data.first_noa_information3
6278 -- p_first_noa_information4        =>  p_sf52_data.first_noa_information4
6279 -- p_first_noa_information5        =>  p_sf52_data.first_noa_information5
6280 -- p_second_lac1_information1      =>  p_sf52_data.second_lac1_information1
6281 -- p_second_lac1_information2      =>  p_sf52_data.second_lac1_information2
6282 -- p_second_lac1_information3      =>  p_sf52_data.second_lac1_information3
6283 -- p_second_lac1_information4      =>  p_sf52_data.second_lac1_information4
6284 -- p_second_lac1_information5      =>  p_sf52_data.second_lac1_information5
6285 -- p_second_lac2_information1      =>  p_sf52_data.second_lac2_information1
6286 -- p_second_lac2_information2      =>  p_sf52_data.second_lac2_information2
6287 -- p_second_lac2_information3      =>  p_sf52_data.second_lac2_information3
6288 -- p_second_lac2_information4      =>  p_sf52_data.second_lac2_information4
6289 -- p_second_lac2_information5      =>  p_sf52_data.second_lac2_information5
6290 -- p_second_noa_information1       =>  p_sf52_data.second_noa_information1
6291 -- p_second_noa_information2       =>  p_sf52_data.second_noa_information2
6292 -- p_second_noa_information3       =>  p_sf52_data.second_noa_information3
6293 -- p_second_noa_information4       =>  p_sf52_data.second_noa_information4
6294 -- p_second_noa_information5       =>  p_sf52_data.second_noa_information5
6295 -- p_first_lac1_information1       =>  p_sf52_data.first_lac1_information1
6296 -- p_first_lac1_information2       =>  p_sf52_data.first_lac1_information2
6297 -- p_first_lac1_information3       =>  p_sf52_data.first_lac1_information3
6298 -- p_first_lac1_information4       =>  p_sf52_data.first_lac1_information4
6299 -- p_first_lac1_information5       =>  p_sf52_data.first_lac1_information5
6300 -- p_first_lac2_information1       =>  p_sf52_data.first_lac2_information1
6301 -- p_first_lac2_information2       =>  p_sf52_data.first_lac2_information2
6302 -- p_first_lac2_information3       =>  p_sf52_data.first_lac2_information3
6303 -- p_first_lac2_information4       =>  p_sf52_data.first_lac2_information4
6304 -- p_first_lac2_information5       =>  p_sf52_data.first_lac2_information5
6305 
6306 	update_shadow_row ( p_shadow_data => p_shadow_data,
6307 				  p_result      => l_result);
6308 	if NOT l_result then
6309 		NULL;
6310 		-- raise error;
6311 	end if;
6312 EXCEPTION
6313   WHEN others THEN
6314      -- Reset IN OUT parameters and set OUT parameters
6315 
6316         p_sf52_data := l_sf52_data ;
6317 
6318    hr_utility.set_location('Leaving Update_rfrs_values ' ,160);
6319    RAISE;
6320 
6321 End Update_rfrs_values;
6322 
6323 Procedure create_shadow_row ( p_shadow_data	in	ghr_pa_request_shadow%rowtype) is
6324 Begin
6325 	Insert into ghr_pa_request_shadow
6326 	(pa_request_id
6327 	,academic_discipline
6328 	,annuitant_indicator
6329 	,appropriation_code1
6330 	,appropriation_code2
6331 	,bargaining_unit_status
6332 	,citizenship
6333 	,duty_station_id
6334 	,duty_station_location_id
6335 	,education_level
6336 	,fegli
6337 	,flsa_category
6338 	,forwarding_address_line1
6339 	,forwarding_address_line2
6340 	,forwarding_address_line3
6341 	,forwarding_country_short_name
6342 	,forwarding_postal_code
6343 	,forwarding_region_2
6344 	,forwarding_town_or_city
6345 	,functional_class
6346 	,part_time_hours
6347 	,pay_rate_determinant
6348 	,position_occupied
6349 	,retirement_plan
6350 	,service_comp_date
6351 	,supervisory_status
6352 	,tenure
6353 	,to_ap_premium_pay_indicator
6354 	,to_auo_premium_pay_indicator
6355 	,to_occ_code
6356 	,to_position_id
6357 	,to_retention_allowance
6358 	,to_retention_allow_percentage
6359 	,to_staffing_differential
6360 	,to_staffing_diff_percentage
6361 	,to_step_or_rate
6362 	,to_supervisory_differential
6363 	,to_supervisory_diff_percentage
6364 	,veterans_preference
6365 	,veterans_pref_for_rif
6366 	,veterans_status
6367 	,work_schedule
6368 	,year_degree_attained          )
6369 	values
6370 	(p_shadow_data.pa_request_id
6371 	,p_shadow_data.academic_discipline
6372 	,p_shadow_data.annuitant_indicator
6373 	,p_shadow_data.appropriation_code1
6374 	,p_shadow_data.appropriation_code2
6375 	,p_shadow_data.bargaining_unit_status
6376 	,p_shadow_data.citizenship
6377 	,p_shadow_data.duty_station_id
6378 	,p_shadow_data.duty_station_location_id
6379 	,p_shadow_data.education_level
6380 	,p_shadow_data.fegli
6381 	,p_shadow_data.flsa_category
6382 	,p_shadow_data.forwarding_address_line1
6383 	,p_shadow_data.forwarding_address_line2
6384 	,p_shadow_data.forwarding_address_line3
6385 	,p_shadow_data.forwarding_country_short_name
6386 	,p_shadow_data.forwarding_postal_code
6387 	,p_shadow_data.forwarding_region_2
6388 	,p_shadow_data.forwarding_town_or_city
6389 	,p_shadow_data.functional_class
6390 	,p_shadow_data.part_time_hours
6391 	,p_shadow_data.pay_rate_determinant
6392 	,p_shadow_data.position_occupied
6393 	,p_shadow_data.retirement_plan
6394 	,p_shadow_data.service_comp_date
6395 	,p_shadow_data.supervisory_status
6396 	,p_shadow_data.tenure
6397 	,p_shadow_data.to_ap_premium_pay_indicator
6398 	,p_shadow_data.to_auo_premium_pay_indicator
6399 	,p_shadow_data.to_occ_code
6400 	,p_shadow_data.to_position_id
6401 	,p_shadow_data.to_retention_allowance
6402 	,p_shadow_data.to_retention_allow_percentage
6403 	,p_shadow_data.to_staffing_differential
6404 	,p_shadow_data.to_staffing_diff_percentage
6405 	,p_shadow_data.to_step_or_rate
6406 	,p_shadow_data.to_supervisory_differential
6407 	,p_shadow_data.to_supervisory_diff_percentage
6408 	,p_shadow_data.veterans_preference
6409 	,p_shadow_data.veterans_pref_for_rif
6410 	,p_shadow_data.veterans_status
6411 	,p_shadow_data.work_schedule
6412 	,p_shadow_data.year_degree_attained
6413 	);
6414 end create_shadow_row;
6415 
6416 Procedure create_shadow_row ( p_sf52_data	in	ghr_pa_requests%rowtype) is
6417 Begin
6418 	Insert into ghr_pa_request_shadow
6419 	(pa_request_id
6420 	,academic_discipline
6421 	,annuitant_indicator
6422 	,appropriation_code1
6423 	,appropriation_code2
6424 	,bargaining_unit_status
6425 	,citizenship
6426 	,duty_station_id
6427 	,duty_station_location_id
6428 	,education_level
6429 	,fegli
6430 	,flsa_category
6431 	,forwarding_address_line1
6432 	,forwarding_address_line2
6433 	,forwarding_address_line3
6434 	,forwarding_country_short_name
6435 	,forwarding_postal_code
6436 	,forwarding_region_2
6437 	,forwarding_town_or_city
6438 	,functional_class
6439 	,part_time_hours
6440 	,pay_rate_determinant
6441 	,position_occupied
6442 	,retirement_plan
6443 	,service_comp_date
6444 	,supervisory_status
6445 	,tenure
6446 	,to_ap_premium_pay_indicator
6447 	,to_auo_premium_pay_indicator
6448 	,to_occ_code
6449 	,to_position_id
6450 	,to_retention_allowance
6451 	,to_retention_allow_percentage
6452 	,to_staffing_differential
6453 	,to_staffing_diff_percentage
6454 	,to_step_or_rate
6455 	,to_supervisory_differential
6456 	,to_supervisory_diff_percentage
6457 	,veterans_preference
6458 	,veterans_pref_for_rif
6459 	,veterans_status
6460 	,work_schedule
6461 	,year_degree_attained          )
6462 	values
6463 	(p_sf52_data.pa_request_id
6464 	,p_sf52_data.academic_discipline
6465 	,p_sf52_data.annuitant_indicator
6466 	,p_sf52_data.appropriation_code1
6467 	,p_sf52_data.appropriation_code2
6468 	,p_sf52_data.bargaining_unit_status
6469 	,p_sf52_data.citizenship
6470 	,p_sf52_data.duty_station_id
6471 	,p_sf52_data.duty_station_location_id
6472 	,p_sf52_data.education_level
6473 	,p_sf52_data.fegli
6474 	,p_sf52_data.flsa_category
6475 	,p_sf52_data.forwarding_address_line1
6476 	,p_sf52_data.forwarding_address_line2
6477 	,p_sf52_data.forwarding_address_line3
6478 	,p_sf52_data.forwarding_country_short_name
6479 	,p_sf52_data.forwarding_postal_code
6480 	,p_sf52_data.forwarding_region_2
6481 	,p_sf52_data.forwarding_town_or_city
6482 	,p_sf52_data.functional_class
6483 	,p_sf52_data.part_time_hours
6484 	,p_sf52_data.pay_rate_determinant
6485 	,p_sf52_data.position_occupied
6486 	,p_sf52_data.retirement_plan
6487 	,p_sf52_data.service_comp_date
6488 	,p_sf52_data.supervisory_status
6489 	,p_sf52_data.tenure
6490 	,p_sf52_data.to_ap_premium_pay_indicator
6491 	,p_sf52_data.to_auo_premium_pay_indicator
6492 	,p_sf52_data.to_occ_code
6493 	,p_sf52_data.to_position_id
6494 	,p_sf52_data.to_retention_allowance
6495 	,p_sf52_data.to_retention_allow_percentage
6496 	,p_sf52_data.to_staffing_differential
6497 	,p_sf52_data.to_staffing_diff_percentage
6498 	,p_sf52_data.to_step_or_rate
6499 	,p_sf52_data.to_supervisory_differential
6500 	,p_sf52_data.to_supervisory_diff_percentage
6501 	,p_sf52_data.veterans_preference
6502 	,p_sf52_data.veterans_pref_for_rif
6503 	,p_sf52_data.veterans_status
6504 	,p_sf52_data.work_schedule
6505 	,p_sf52_data.year_degree_attained
6506 	);
6507 end create_shadow_row;
6508 
6509 Procedure Update_shadow_row ( p_shadow_data	 in	ghr_pa_request_shadow%rowtype,
6510 			      p_result		out nocopy	Boolean) is
6511 Begin
6512 	Update ghr_pa_request_shadow
6513 	Set
6514 	 pa_request_id                 	= p_shadow_data.pa_request_id
6515 	,academic_discipline           	= p_shadow_data.academic_discipline
6516 	,annuitant_indicator           	= p_shadow_data.annuitant_indicator
6517 	,appropriation_code1           	= p_shadow_data.appropriation_code1
6518 	,appropriation_code2           	= p_shadow_data.appropriation_code2
6519 	,bargaining_unit_status        	= p_shadow_data.bargaining_unit_status
6520 	,citizenship                   	= p_shadow_data.citizenship
6521 	,duty_station_id               	= p_shadow_data.duty_station_id
6522 	,duty_station_location_id      	= p_shadow_data.duty_station_location_id
6523 	,education_level               	= p_shadow_data.education_level
6524 	,fegli                         	= p_shadow_data.fegli
6525 	,flsa_category                 	= p_shadow_data.flsa_category
6526 	,forwarding_address_line1      	= p_shadow_data.forwarding_address_line1
6527 	,forwarding_address_line2      	= p_shadow_data.forwarding_address_line2
6528 	,forwarding_address_line3      	= p_shadow_data.forwarding_address_line3
6529 	,forwarding_country_short_name 	= p_shadow_data.forwarding_country_short_name
6530 	,forwarding_postal_code        	= p_shadow_data.forwarding_postal_code
6531 	,forwarding_region_2           	= p_shadow_data.forwarding_region_2
6532 	,forwarding_town_or_city       	= p_shadow_data.forwarding_town_or_city
6533 	,functional_class              	= p_shadow_data.functional_class
6534 	,part_time_hours               	= p_shadow_data.part_time_hours
6535 	,pay_rate_determinant          	= p_shadow_data.pay_rate_determinant
6536 	,position_occupied             	= p_shadow_data.position_occupied
6537 	,retirement_plan               	= p_shadow_data.retirement_plan
6538 	,service_comp_date             	= p_shadow_data.service_comp_date
6539 	,supervisory_status            	= p_shadow_data.supervisory_status
6540 	,tenure                        	= p_shadow_data.tenure
6541 	,to_ap_premium_pay_indicator   	= p_shadow_data.to_ap_premium_pay_indicator
6542 	,to_auo_premium_pay_indicator  	= p_shadow_data.to_auo_premium_pay_indicator
6543 	,to_occ_code                   	= p_shadow_data.to_occ_code
6544 	,to_position_id                	= p_shadow_data.to_position_id
6545 	,to_retention_allowance        	= p_shadow_data.to_retention_allowance
6546 	,to_retention_allow_percentage    	= p_shadow_data.to_retention_allow_percentage
6547 	,to_staffing_differential      	= p_shadow_data.to_staffing_differential
6548 	,to_staffing_diff_percentage      	= p_shadow_data.to_staffing_diff_percentage
6549 	,to_step_or_rate               	= p_shadow_data.to_step_or_rate
6550 	,to_supervisory_differential   	= p_shadow_data.to_supervisory_differential
6551 	,to_supervisory_diff_percentage   	= p_shadow_data.to_supervisory_diff_percentage
6552 	,veterans_preference           	= p_shadow_data.veterans_preference
6553 	,veterans_pref_for_rif         	= p_shadow_data.veterans_pref_for_rif
6554 	,veterans_status               	= p_shadow_data.veterans_status
6555 	,work_schedule                 	= p_shadow_data.work_schedule
6556 	,year_degree_attained          	= p_shadow_data.year_degree_attained
6557 where pa_request_id = p_shadow_data.pa_request_id;
6558 
6559 if sql%notfound then
6560 		p_result := FALSE;
6561 else
6562 	p_result := TRUE;
6563 end if;
6564 
6565 EXCEPTION
6566   WHEN others THEN
6567      -- Reset IN OUT parameters and set OUT parameters
6568 
6569        p_result := NULL;
6570 
6571    hr_utility.set_location('Leaving Update_Shadow_row ' ,100);
6572    RAISE;
6573 
6574 end update_shadow_row;
6575 
6576 procedure print_sf52(p_proc VARCHAR2, p_pa_request_rec GHR_PA_REQUESTS%ROWTYPE)
6577 IS
6578 BEGIN
6579    hr_utility.set_location ('-----------------------------------------------', 10);
6580    hr_utility.set_location (p_proc, 20);
6581    hr_utility.set_location ('-----------------------------------------------', 30);
6582    hr_utility.set_location(p_proc||'.pa_request_id '||p_pa_request_rec.pa_request_id
6583                , 40);
6584    hr_utility.set_location(p_proc||'.pa_notification_id '||p_pa_request_rec.pa_notification_id
6585                , 50);
6586    hr_utility.set_location(p_proc||'.noa_family_code '||p_pa_request_rec.noa_family_code
6587                , 60);
6588    hr_utility.set_location(p_proc||'.routing_group_id '||p_pa_request_rec.routing_group_id
6589                , 70);
6590    hr_utility.set_location(p_proc||'.academic_discipline '||p_pa_request_rec.academic_discipline
6591                , 90);
6592    hr_utility.set_location(p_proc||'.additional_info_person_id '||p_pa_request_rec.additional_info_person_id
6593                , 100);
6594    hr_utility.set_location(p_proc||'.additional_info_tel_number '||SUBSTR(p_pa_request_rec.additional_info_tel_number,1,40)
6595                , 110);
6596    hr_utility.set_location(p_proc||'.agency_code '||p_pa_request_rec.agency_code
6597                , 120);
6598    hr_utility.set_location(p_proc||'.altered_pa_request_id '||p_pa_request_rec.altered_pa_request_id
6599                , 130);
6600    hr_utility.set_location(p_proc||'.annuitant_indicator '||p_pa_request_rec.annuitant_indicator
6601                , 140);
6602    hr_utility.set_location(p_proc||'.annuitant_indicator_desc '||substr(p_pa_request_rec.annuitant_indicator_desc,1,40)
6603                , 150);
6604    hr_utility.set_location(p_proc||'.appropriation_code1 '||p_pa_request_rec.appropriation_code1
6605                , 160);
6606    hr_utility.set_location(p_proc||'.appropriation_code2 '||p_pa_request_rec.appropriation_code2
6607                , 170);
6608    hr_utility.set_location(p_proc||'.approval_date '||p_pa_request_rec.approval_date
6609                , 180);
6610    hr_utility.set_location(p_proc||'.approving_official_work_title '||substr(p_pa_request_rec.approving_official_work_title,1,40)
6611                , 190);
6612    hr_utility.set_location(p_proc||'.authorized_by_person_id '||p_pa_request_rec.authorized_by_person_id
6613                , 200);
6614    hr_utility.set_location(p_proc||'.authorized_by_title '||substr(p_pa_request_rec.authorized_by_title,1,40)
6615                , 210);
6616    hr_utility.set_location(p_proc||'.award_amount '||p_pa_request_rec.award_amount
6617                , 220);
6618    hr_utility.set_location(p_proc||'.award_uom '||p_pa_request_rec.award_uom
6619                , 230);
6620    hr_utility.set_location(p_proc||'.bargaining_unit_status '||p_pa_request_rec.bargaining_unit_status
6621                , 240);
6622    hr_utility.set_location(p_proc||'.citizenship '||p_pa_request_rec.citizenship
6623                , 250);
6624    hr_utility.set_location(p_proc||'.concurrence_date '||p_pa_request_rec.concurrence_date
6625                , 260);
6626    hr_utility.set_location(p_proc||'.custom_pay_calc_flag '||p_pa_request_rec.custom_pay_calc_flag
6627                , 270);
6628    hr_utility.set_location(p_proc||'.duty_station_code '||p_pa_request_rec.duty_station_code
6629                , 280);
6630    hr_utility.set_location(p_proc||'.duty_station_desc '||substr(p_pa_request_rec.duty_station_desc,1,40)
6631                , 290);
6632    hr_utility.set_location(p_proc||'.duty_station_id '||p_pa_request_rec.duty_station_id
6633                , 300);
6634    hr_utility.set_location(p_proc||'.duty_station_location_id '||p_pa_request_rec.duty_station_location_id
6635                , 310);
6636    hr_utility.set_location(p_proc||'.education_level '||p_pa_request_rec.education_level
6637                , 320);
6638    hr_utility.set_location(p_proc||'.effective_date '||p_pa_request_rec.effective_date
6639                , 330);
6640    hr_utility.set_location(p_proc||'.employee_assignment_id '||p_pa_request_rec.employee_assignment_id
6641                , 340);
6642    hr_utility.set_location(p_proc||'.employee_date_of_birth '||p_pa_request_rec.employee_date_of_birth
6643                , 350);
6644    hr_utility.set_location(p_proc||'.employee_dept_or_agency '||substr(p_pa_request_rec.employee_dept_or_agency,1,40)
6645                , 360);
6646    hr_utility.set_location(p_proc||'.employee_first_name '||substr(p_pa_request_rec.employee_first_name,1,40)
6647                , 370);
6648    hr_utility.set_location(p_proc||'.employee_last_name '||substr(p_pa_request_rec.employee_last_name,1,40)
6649                , 380);
6650    hr_utility.set_location(p_proc||'.employee_middle_names '||substr(p_pa_request_rec.employee_middle_names,1,40)
6651                , 390);
6652    hr_utility.set_location(p_proc||'.employee_national_identifier '||p_pa_request_rec.employee_national_identifier
6653                , 400);
6654    hr_utility.set_location(p_proc||'.fegli '||p_pa_request_rec.fegli
6655                , 410);
6656    hr_utility.set_location(p_proc||'.fegli_desc '||substr(p_pa_request_rec.fegli_desc,1,40)
6657                , 420);
6658    hr_utility.set_location(p_proc||'.first_action_la_code1 '||p_pa_request_rec.first_action_la_code1
6659                , 430);
6660    hr_utility.set_location(p_proc||'.first_action_la_code2 '||p_pa_request_rec.first_action_la_code2
6661                , 440);
6662    hr_utility.set_location(p_proc||'.first_action_la_desc1 '||substr(p_pa_request_rec.first_action_la_desc1,1,40)
6663                , 450);
6664    hr_utility.set_location(p_proc||'.first_action_la_desc2 '||substr(p_pa_request_rec.first_action_la_desc2,1,40)
6665                , 460);
6666    hr_utility.set_location(p_proc||'.first_noa_cancel_or_correct '||p_pa_request_rec.first_noa_cancel_or_correct
6667                , 470);
6668    hr_utility.set_location(p_proc||'.first_noa_code '||p_pa_request_rec.first_noa_code
6669                , 480);
6670    hr_utility.set_location(p_proc||'.first_noa_desc '||substr(p_pa_request_rec.first_noa_desc,1,40)
6671                , 490);
6672    hr_utility.set_location(p_proc||'.first_noa_id '||p_pa_request_rec.first_noa_id
6673                , 500);
6674    hr_utility.set_location(p_proc||'.first_noa_pa_request_id '||p_pa_request_rec.first_noa_pa_request_id
6675                , 510);
6676    hr_utility.set_location(p_proc||'.flsa_category '||p_pa_request_rec.flsa_category
6677                , 520);
6678    hr_utility.set_location(p_proc||'.forwarding_address_line1 '||substr(p_pa_request_rec.forwarding_address_line1,1,40)
6679                , 530);
6680    hr_utility.set_location(p_proc||'.forwarding_address_line2 '||substr(p_pa_request_rec.forwarding_address_line2,1,40)
6681                , 540);
6682    hr_utility.set_location(p_proc||'.forwarding_address_line3 '||substr(p_pa_request_rec.forwarding_address_line3,1,40)
6683                , 550);
6684    hr_utility.set_location(p_proc||'.forwarding_country '||substr(p_pa_request_rec.forwarding_country,1,40)
6685                , 560);
6686    hr_utility.set_location(p_proc||'.forwarding_country_short_name '||substr(p_pa_request_rec.forwarding_country_short_name,1,40)
6687                , 570);
6688    hr_utility.set_location(p_proc||'.forwarding_postal_code '||p_pa_request_rec.forwarding_postal_code
6689                , 580);
6690    hr_utility.set_location(p_proc||'.forwarding_region_2 '||substr(p_pa_request_rec.forwarding_region_2,1,40)
6691                , 590);
6692    hr_utility.set_location(p_proc||'.forwarding_town_or_city '||p_pa_request_rec.forwarding_town_or_city
6693                , 600);
6694    hr_utility.set_location(p_proc||'.from_adj_basic_pay '||p_pa_request_rec.from_adj_basic_pay
6695                , 610);
6696    hr_utility.set_location(p_proc||'.from_agency_code '||p_pa_request_rec.from_agency_code
6697                , 610);
6698    hr_utility.set_location(p_proc||'.from_agency_desc '||substr(p_pa_request_rec.from_agency_desc,1,40)
6699                , 610);
6700    hr_utility.set_location(p_proc||'.from_basic_pay '||p_pa_request_rec.from_basic_pay
6701                , 610);
6702    hr_utility.set_location(p_proc||'.from_grade_or_level '||p_pa_request_rec.from_grade_or_level
6703                , 610);
6704    hr_utility.set_location(p_proc||'.from_locality_adj '||p_pa_request_rec.from_locality_adj
6705                , 610);
6706    hr_utility.set_location(p_proc||'.from_occ_code '||substr(p_pa_request_rec.from_occ_code,1,40)
6707                , 610);
6708    hr_utility.set_location(p_proc||'.from_office_symbol '||p_pa_request_rec.from_office_symbol
6709                , 610);
6710    hr_utility.set_location(p_proc||'.from_other_pay_amount '||p_pa_request_rec.from_other_pay_amount
6711                , 610);
6712    hr_utility.set_location(p_proc||'.from_pay_basis '||p_pa_request_rec.from_pay_basis
6713                , 710);
6714    hr_utility.set_location(p_proc||'.from_pay_plan '||p_pa_request_rec.from_pay_plan
6715                , 710);
6716    --hr_utility.set_location(p_proc||'.from_pay_table_id '||to_char(p_pa_request_rec.from_pay_table_identifier)
6717                --, 710);
6718    hr_utility.set_location(p_proc||'.from_position_id '||p_pa_request_rec.from_position_id
6719                , 710);
6720    hr_utility.set_location(p_proc||'.from_position_org_line1 '||p_pa_request_rec.from_position_org_line1
6721                , 710);
6722    hr_utility.set_location(p_proc||'.from_position_org_line2 '||p_pa_request_rec.from_position_org_line2
6723                , 710);
6724    hr_utility.set_location(p_proc||'.from_position_org_line3 '||p_pa_request_rec.from_position_org_line3
6725                , 710);
6726    hr_utility.set_location(p_proc||'.from_position_org_line4 '||p_pa_request_rec.from_position_org_line4
6727                , 710);
6728    hr_utility.set_location(p_proc||'.from_position_org_line5 '||p_pa_request_rec.from_position_org_line5
6729                , 710);
6730    hr_utility.set_location(p_proc||'.from_position_org_line6 '||p_pa_request_rec.from_position_org_line6
6731                , 710);
6732    hr_utility.set_location(p_proc||'.from_position_number '||p_pa_request_rec.from_position_number
6733                , 710);
6734    hr_utility.set_location(p_proc||'.from_position_seq_no '||p_pa_request_rec.from_position_seq_no
6735                , 710);
6736    hr_utility.set_location(p_proc||'.from_position_title '||substr(p_pa_request_rec.from_position_title,1,40)
6737                , 810);
6738    hr_utility.set_location(p_proc||'.from_step_or_rate '||p_pa_request_rec.from_step_or_rate
6739                , 810);
6740    hr_utility.set_location(p_proc||'.from_total_salary '||p_pa_request_rec.from_total_salary
6741                , 810);
6742    hr_utility.set_location(p_proc||'.functional_class '||p_pa_request_rec.functional_class
6743                , 810);
6744    hr_utility.set_location(p_proc||'.notepad '||SUBSTR(p_pa_request_rec.notepad,1,40)
6745                , 810); -- Bug 3659193 Added Substr for Notepad.
6746    hr_utility.set_location(p_proc||'.part_time_hours '||p_pa_request_rec.part_time_hours
6747                , 810);
6748    hr_utility.set_location(p_proc||'.input_pay_rate_determinant '||p_pa_request_rec.input_pay_rate_determinant
6749                , 810);
6750    hr_utility.set_location(p_proc||'.pay_rate_determinant '||p_pa_request_rec.pay_rate_determinant
6751                , 810);
6752    hr_utility.set_location(p_proc||'.personnel_office_id '||p_pa_request_rec.personnel_office_id
6753                , 810);
6754    hr_utility.set_location(p_proc||'.person_id '||p_pa_request_rec.person_id
6755                , 810);
6756    hr_utility.set_location(p_proc||'.position_occupied '||p_pa_request_rec.position_occupied
6757                , 810);
6758    hr_utility.set_location(p_proc||'.proposed_effective_asap_flag '||p_pa_request_rec.proposed_effective_asap_flag
6759                , 810);
6760    hr_utility.set_location(p_proc||'.proposed_effective_date '||p_pa_request_rec.proposed_effective_date
6761                , 810);
6762    hr_utility.set_location(p_proc||'.requested_by_person_id '||p_pa_request_rec.requested_by_person_id
6763                , 910);
6764    hr_utility.set_location(p_proc||'.requested_by_title '||substr(p_pa_request_rec.requested_by_title,1,40)
6765                , 910);
6766    hr_utility.set_location(p_proc||'.requested_date '||p_pa_request_rec.requested_date
6767                , 910);
6768    hr_utility.set_location(p_proc||'.requesting_office_remarks_desc '||substr(p_pa_request_rec.requesting_office_remarks_desc,1,40)
6769                , 910); -- Bug 3381432 added 'substr'
6770    hr_utility.set_location(p_proc||'.requesting_office_remarks_flag '||p_pa_request_rec.requesting_office_remarks_flag
6771                , 910);
6772    hr_utility.set_location(p_proc||'.request_number '||p_pa_request_rec.request_number
6773                , 910);
6774    hr_utility.set_location(p_proc||'.resign_and_retire_reason_desc '||substr(p_pa_request_rec.resign_and_retire_reason_desc,1,40)
6775                , 910); -- Bug 3381432 added 'substr'
6776    hr_utility.set_location(p_proc||'.retirement_plan '||p_pa_request_rec.retirement_plan
6777                , 910);
6778    hr_utility.set_location(p_proc||'.retirement_plan_desc '||substr(p_pa_request_rec.retirement_plan_desc,1,40)
6779                , 910); -- Bug 3381432 added 'substr'
6780    hr_utility.set_location(p_proc||'.second_action_la_code1 '||p_pa_request_rec.second_action_la_code1
6781                , 910);
6782    hr_utility.set_location(p_proc||'.second_action_la_code2 '||p_pa_request_rec.second_action_la_code2
6783                , 910);
6784    hr_utility.set_location(p_proc||'.second_action_la_desc1 '||substr(p_pa_request_rec.second_action_la_desc1,1,40)
6785                , 1010);
6786    hr_utility.set_location(p_proc||'.second_action_la_desc2 '||substr(p_pa_request_rec.second_action_la_desc2,1,40)
6787                , 1010);
6788    hr_utility.set_location(p_proc||'.second_noa_cancel_or_correct '||p_pa_request_rec.second_noa_cancel_or_correct
6789                , 1010);
6790    hr_utility.set_location(p_proc||'.second_noa_code '||p_pa_request_rec.second_noa_code
6791                , 1010);
6792    hr_utility.set_location(p_proc||'.second_noa_desc '||substr(p_pa_request_rec.second_noa_desc,1,40)
6793                , 1010);
6794    hr_utility.set_location(p_proc||'.second_noa_id '||p_pa_request_rec.second_noa_id
6795                , 1010);
6796    hr_utility.set_location(p_proc||'.second_noa_pa_request_id '||p_pa_request_rec.second_noa_pa_request_id
6797                , 1010);
6798    hr_utility.set_location(p_proc||'.service_comp_date '||p_pa_request_rec.service_comp_date
6799                , 1010);
6800    hr_utility.set_location(p_proc||'.supervisory_status '||p_pa_request_rec.supervisory_status
6801                , 1010);
6802    hr_utility.set_location(p_proc||'.tenure '||p_pa_request_rec.tenure
6803                , 1010);
6804    hr_utility.set_location(p_proc||'.to_adj_basic_pay '||p_pa_request_rec.to_adj_basic_pay
6805                , 1010);
6806    hr_utility.set_location(p_proc||'.to_ap_premium_pay_indicator '||p_pa_request_rec.to_ap_premium_pay_indicator
6807                , 1010);
6808    hr_utility.set_location(p_proc||'.to_auo_premium_pay_indicator '||p_pa_request_rec.to_auo_premium_pay_indicator
6809                , 1010);
6810    hr_utility.set_location(p_proc||'.to_au_overtime '||p_pa_request_rec.to_au_overtime
6811                , 1010);
6812    hr_utility.set_location(p_proc||'.to_availability_pay '||p_pa_request_rec.to_availability_pay
6813                , 1010);
6814    hr_utility.set_location(p_proc||'.to_basic_pay '||p_pa_request_rec.to_basic_pay
6815                , 1010);
6816    hr_utility.set_location(p_proc||'.to_grade_id '||p_pa_request_rec.to_grade_id
6817                , 1010);
6818    hr_utility.set_location(p_proc||'.to_grade_or_level '||p_pa_request_rec.to_grade_or_level
6819                , 1010);
6820    hr_utility.set_location(p_proc||'.to_job_id '||p_pa_request_rec.to_job_id
6821                , 1010);
6822    hr_utility.set_location(p_proc||'.to_locality_adj '||p_pa_request_rec.to_locality_adj
6823                , 1010);
6824    hr_utility.set_location(p_proc||'.to_occ_code '||substr(p_pa_request_rec.to_occ_code,1,40)
6825                , 1010);
6826    hr_utility.set_location(p_proc||'.to_office_symbol '||p_pa_request_rec.to_office_symbol
6827                , 1010);
6828    hr_utility.set_location(p_proc||'.to_organization_id '||p_pa_request_rec.to_organization_id
6829                , 1010);
6830    hr_utility.set_location(p_proc||'.to_other_pay_amount '||p_pa_request_rec.to_other_pay_amount
6831                , 1010);
6832    hr_utility.set_location(p_proc||'.to_pay_basis '||p_pa_request_rec.to_pay_basis
6833                , 1010);
6834    hr_utility.set_location(p_proc||'.to_pay_plan '||p_pa_request_rec.to_pay_plan
6835                , 1010);
6836    --hr_utility.set_location(p_proc||'.to_prd '||p_pa_request_rec.to_pay_rate_determinant
6837                --, 1010);
6838    --hr_utility.set_location(p_proc||'.to_pay_table_id '||to_char(p_pa_request_rec.to_pay_table_identifier)
6839                --, 1010);
6840    hr_utility.set_location(p_proc||'.to_position_id '||p_pa_request_rec.to_position_id
6841                , 1010);
6842    hr_utility.set_location(p_proc||'.to_position_org_line1 '||p_pa_request_rec.to_position_org_line1
6843                , 1010);
6844    hr_utility.set_location(p_proc||'.to_position_org_line2 '||p_pa_request_rec.to_position_org_line2
6845                , 1010);
6846    hr_utility.set_location(p_proc||'.to_position_org_line3 '||p_pa_request_rec.to_position_org_line3
6847                , 1010);
6848    hr_utility.set_location(p_proc||'.to_position_org_line4 '||p_pa_request_rec.to_position_org_line4
6849                , 1010);
6850    hr_utility.set_location(p_proc||'.to_position_org_line5 '||p_pa_request_rec.to_position_org_line5
6851                , 1010);
6852    hr_utility.set_location(p_proc||'.to_position_org_line6 '||p_pa_request_rec.to_position_org_line6
6853                , 1010);
6854    hr_utility.set_location(p_proc||'.to_position_number '||p_pa_request_rec.to_position_number
6855                , 1010);
6856    hr_utility.set_location(p_proc||'.to_position_seq_no '||p_pa_request_rec.to_position_seq_no
6857                , 1010);
6858    hr_utility.set_location(p_proc||'.to_position_title '||substr(p_pa_request_rec.to_position_title,1,40)
6859                , 1010);
6860    hr_utility.set_location(p_proc||'.to_retention_allowance '||p_pa_request_rec.to_retention_allowance
6861                , 1010);
6862    hr_utility.set_location(p_proc||'.to_retention_allow_percentage '||p_pa_request_rec.to_retention_allow_percentage
6863                , 1010);
6864    hr_utility.set_location(p_proc||'.to_staffing_differential '||p_pa_request_rec.to_staffing_differential
6865                , 1010);
6866    hr_utility.set_location(p_proc||'.to_staffing_diff_percentage '||p_pa_request_rec.to_staffing_diff_percentage
6867                , 1010);
6868    hr_utility.set_location(p_proc||'.to_step_or_rate '||p_pa_request_rec.to_step_or_rate
6869                , 1010);
6870    hr_utility.set_location(p_proc||'.to_supervisory_differential '||p_pa_request_rec.to_supervisory_differential
6871                , 1010);
6872    hr_utility.set_location(p_proc||'.to_supervisory_diff_percentage '||p_pa_request_rec.to_supervisory_diff_percentage
6873                , 1010);
6874    hr_utility.set_location(p_proc||'.to_total_salary '||p_pa_request_rec.to_total_salary
6875                , 1010);
6876    hr_utility.set_location(p_proc||'.veterans_preference '||p_pa_request_rec.veterans_preference
6877                , 1010);
6878    hr_utility.set_location(p_proc||'.veterans_pref_for_rif '||p_pa_request_rec.veterans_pref_for_rif
6879                , 1010);
6880    hr_utility.set_location(p_proc||'.veterans_status '||p_pa_request_rec.veterans_status
6881                , 1010);
6882    hr_utility.set_location(p_proc||'.work_schedule '||p_pa_request_rec.work_schedule
6883                , 1010);
6884    hr_utility.set_location(p_proc||'.work_schedule_desc '||substr(p_pa_request_rec.work_schedule_desc,1,40)
6885                , 1010);
6886    hr_utility.set_location(p_proc||'.year_degree_attained '||p_pa_request_rec.year_degree_attained
6887                , 1010);
6888    hr_utility.set_location(p_proc||'.from_pay_table_identifier '||p_pa_request_rec.from_pay_table_identifier
6889                , 1010);
6890    hr_utility.set_location(p_proc||'.to_pay_table_identifier '||p_pa_request_rec.to_pay_table_identifier
6891                , 1010);
6892   hr_utility.set_location(p_proc||'.payment option:  '||p_pa_request_rec.pa_incentive_payment_option
6893                , 1010);
6894    hr_utility.set_location(p_proc||'.award salary '||p_pa_request_rec.award_salary
6895                , 1010);
6896 
6897 END print_sf52;
6898 
6899 --6850492
6900 procedure Dual_Cancel_sf52(p_sf52_data in out nocopy ghr_pa_requests%rowtype
6901                           ,p_first_noa_code  in varchar2
6902      	                  ,p_second_noa_code in varchar2
6903                  	  ,p_pa_request_id   in number
6904                           ,p_ovn             in number
6905                 	  ,p_first_noa_id    in number
6906                       	  ,p_second_noa_id   in number
6907                  	  ,p_row_id          in varchar2) is
6908 
6909 l_which_noa           varchar2(1);
6910 l_dual_noa_id         ghr_pa_requests.first_noa_id%type;
6911 l_pa_request_id       ghr_pa_requests.pa_request_id%type;
6912 l_sf52_dual_sec_rec   ghr_pa_requests%rowtype;
6913 l_sf52_dual_first_rec ghr_pa_requests%rowtype;
6914 l_ovn                 ghr_pa_requests.object_version_number%type;
6915 l_pa_remark_id        ghr_pa_remarks.pa_remark_id%type;
6916 l_object_version_number  ghr_pa_remarks.object_version_number%type;
6917 --8737212
6918 l_u_pa_routing_history_id     ghr_pa_routing_history.pa_routing_history_id%TYPE;
6919 l_u_prh_object_version_number ghr_pa_routing_history.object_version_number%TYPE;
6920 
6921 cursor c_dual_cancel
6922      is
6923      select *
6924      from   ghr_pa_requests
6925      where  pa_request_id = l_pa_request_id;
6926 
6927 
6928 cursor c_dual_first
6929      is
6930      select *
6931      from   ghr_pa_requests
6932      where  pa_request_id = p_sf52_data.pa_request_id;
6933 
6934 cursor get_ovn(p_pa_request_id in number)
6935     is
6936     select object_version_number
6937     from   ghr_pa_requests
6938     where  pa_request_id = p_pa_request_id;
6939 --8272695
6940 cursor c_get_remarks
6941     is
6942     select parem.remark_id,
6943     	   parem.description,
6944 	   parem.remark_code_information1,
6945 	   parem.remark_code_information2,
6946 	   parem.remark_code_information3,
6947 	   parem.remark_code_information4,
6948 	   parem.remark_code_information5
6949     from ghr_pa_remarks parem, ghr_remarks rem
6950     where parem.pa_request_id = p_sf52_data.pa_request_id
6951     and   parem.remark_id  = rem.remark_id
6952     and   substr(rem.code,1,1) = 'C';
6953 -- 8272695
6954 
6955 --8737212
6956 cursor 	C_routing_history_id
6957     is
6958     SELECT   prh.pa_routing_history_id,
6959              prh.object_version_number
6960     FROM     ghr_pa_routing_history prh
6961     WHERE    prh.pa_request_id = l_sf52_dual_sec_rec.pa_request_id
6962     ORDER by prh.pa_routing_history_id desc;
6963 
6964 cursor c_first_routing_det
6965     is
6966     select *
6967     from   ghr_pa_routing_history prh
6968     where  prh.pa_request_id = p_sf52_data.pa_request_id
6969     and    ACTION_TAKEN = 'UPDATE_HR'
6970     and    APPROVAL_STATUS = 'APPROVE';
6971 --8737212
6972 
6973 
6974 BEGIN
6975     if p_sf52_data.second_noa_code =  p_first_noa_code then
6976       l_which_noa := 2;
6977       l_dual_noa_id :=  p_second_noa_id;
6978    elsif p_sf52_data.second_noa_code =  p_second_noa_code then
6979       l_which_noa := 1;
6980       l_dual_noa_id :=  p_first_noa_id;
6981    end if;
6982       l_ovn := p_ovn;
6983      hr_utility.set_location('l_ovn'||l_ovn,1);
6984       l_pa_request_id := ghr_approved_pa_requests.ghr_cancel_sf52(
6985                                     p_pa_request_id              => p_pa_request_id
6986                                   , p_par_object_version_number  => l_ovn
6987                                   , p_noa_id                     => l_dual_noa_id
6988                                   , p_which_noa                  => l_which_noa
6989                                   , p_row_id                     => p_row_id
6990                                   , p_username                   => fnd_profile.value('USERNAME')
6991                                   , p_which_action               => 'ORIGINAL'
6992                                   , p_cancel_legal_authority     => null
6993                                    );
6994 
6995       if c_dual_cancel%isopen then
6996         close c_dual_cancel;
6997      end if;
6998 
6999      open c_dual_cancel;
7000      fetch c_dual_cancel into l_sf52_dual_sec_rec;
7001      close c_dual_cancel;
7002 
7003      -- population of remarks 8272695
7004     for rec_remarks in c_get_remarks
7005     loop
7006 
7007        ghr_pa_remarks_api.create_pa_remarks
7008                        (p_validate                 => false
7009                        ,p_pa_request_id            => l_pa_request_id
7010                        ,p_remark_id                => rec_remarks.remark_id
7011                        ,p_description              => rec_remarks.description
7012                        ,p_remark_code_information1 => rec_remarks.remark_code_information1
7013                        ,p_remark_code_information2 => rec_remarks.remark_code_information2
7014                        ,p_remark_code_information3 => rec_remarks.remark_code_information3
7015                        ,p_remark_code_information4 => rec_remarks.remark_code_information4
7016                        ,p_remark_code_information5 => rec_remarks.remark_code_information5
7017                        ,p_pa_remark_id             => l_pa_remark_id
7018                        ,p_object_version_number    => l_object_version_number
7019                       );
7020     end loop;
7021   --8272695
7022 --lac codes
7023     l_sf52_dual_sec_rec.first_action_la_code1 :=  p_sf52_data.first_action_la_code1;
7024     l_sf52_dual_sec_rec.first_action_la_code2 :=  p_sf52_data.first_action_la_code2;
7025     l_sf52_dual_sec_rec.first_action_la_desc1 :=  p_sf52_data.first_action_la_desc1;
7026     l_sf52_dual_sec_rec.first_action_la_desc2 :=  p_sf52_data.first_action_la_desc2;
7027 
7028      -- 8737212 Updating Routing History
7029      for cur_routing_history_id in C_routing_history_id loop
7030        l_u_pa_routing_history_id     :=  cur_routing_history_id.pa_routing_history_id;
7031        l_u_prh_object_version_number :=  cur_routing_history_id.object_version_number;
7032        exit;
7033      end loop;
7034 
7035      for rec_hist_det in c_first_routing_det
7036      loop
7037        ghr_prh_upd.upd
7038        (
7039      p_pa_routing_history_id      => l_u_pa_routing_history_id,
7040      p_attachment_modified_flag   => nvl(rec_hist_det.attachment_modified_flag,'N'),
7041      p_initiator_flag             => nvl(rec_hist_det.initiator_flag,'N'),
7042      p_approver_flag              => nvl(rec_hist_det.approver_flag,'N'),
7043      p_reviewer_flag              => nvl(rec_hist_det.reviewer_flag,'N'),
7044      p_requester_flag             => nvl(rec_hist_det.requester_flag,'N'),
7045      p_authorizer_flag            => nvl(rec_hist_det.authorizer_flag,'N'),
7046      p_personnelist_flag          => nvl(rec_hist_det.personnelist_flag,'N'),
7047      p_approved_flag              => nvl(rec_hist_det.approved_flag,'N'),
7048      p_user_name                  => rec_hist_det.user_name,
7049      p_user_name_employee_id      => rec_hist_det.user_name_employee_id,
7050      p_user_name_emp_first_name   => rec_hist_det.user_name_emp_first_name,
7051      p_user_name_emp_last_name    => rec_hist_det.user_name_emp_last_name,
7052      p_user_name_emp_middle_names => rec_hist_det.user_name_emp_middle_names,
7053      p_notepad                    => rec_hist_det.notepad,
7054      p_action_taken               => rec_hist_det.action_taken,
7055      p_noa_family_code            => l_sf52_dual_sec_rec.noa_family_code,
7056      p_nature_of_action_id        => l_sf52_dual_sec_rec.first_noa_id,
7057      p_second_nature_of_action_id => l_sf52_dual_sec_rec.second_noa_id,
7058      p_approval_status            => rec_hist_det.approval_status,
7059      p_object_version_number      => l_u_prh_object_version_number
7060 --     p_validate                 => p_validate
7061      );
7062      exit;
7063      end loop;
7064     -- 8737212 Updating Routing History
7065 
7066 
7067     if  p_sf52_data.second_noa_code =  p_second_noa_code then
7068     hr_utility.set_location('before first process',1000);
7069          ghr_corr_canc_sf52.cancel_routine(p_sf52_data);
7070 	     hr_utility.set_location('before sec process'||l_sf52_dual_sec_rec.first_noa_id,1001);
7071    	     hr_utility.set_location('before sec process'||l_sf52_dual_sec_rec.second_noa_id,1002);
7072          ghr_corr_canc_sf52.cancel_routine(l_sf52_dual_sec_rec);
7073     elsif p_sf52_data.second_noa_code  =  p_first_noa_code then
7074          ghr_corr_canc_sf52.cancel_routine(l_sf52_dual_sec_rec);
7075          ghr_corr_canc_sf52.cancel_routine(p_sf52_data);
7076     end if;
7077 
7078       if c_dual_first%isopen then
7079         close c_dual_first;
7080      end if;
7081 
7082      open c_dual_first;
7083      fetch c_dual_first into l_sf52_dual_first_rec;
7084      close c_dual_first;
7085 
7086      ghr_history_api.reinit_g_session_var;
7087 
7088        hr_utility.set_location('l_sf52_dual_sec_rec.from_position_id'||l_sf52_dual_sec_rec.from_position_id,10);
7089         hr_utility.set_location('l_sf52_dual_sec_rec.to_position_id'||l_sf52_dual_sec_rec.to_position_id,11);
7090      ghr_sf52_post_update.get_notification_details
7091   (p_pa_request_id                  =>  l_sf52_dual_sec_rec.pa_request_id,
7092    p_effective_date                 =>  l_sf52_dual_sec_rec.effective_date,
7093 --   p_object_version_number          =>  p_imm_pa_request_rec.object_version_number,
7094    p_from_position_id               =>  l_sf52_dual_sec_rec.from_position_id,
7095    p_to_position_id                 =>  l_sf52_dual_sec_rec.to_position_id,
7096    p_agency_code                    =>  l_sf52_dual_sec_rec.agency_code,
7097    p_from_agency_code               =>  l_sf52_dual_sec_rec.from_agency_code,
7098    p_from_agency_desc               =>  l_sf52_dual_sec_rec.from_agency_desc,
7099    p_from_office_symbol             =>  l_sf52_dual_sec_rec.from_office_symbol,
7100    p_personnel_office_id            =>  l_sf52_dual_sec_rec.personnel_office_id,
7101    p_employee_dept_or_agency        =>  l_sf52_dual_sec_rec.employee_dept_or_agency,
7102    p_to_office_symbol               =>  l_sf52_dual_sec_rec.to_office_symbol
7103    );
7104 
7105     for c_get_ovn in get_ovn(p_pa_request_id =>  l_sf52_dual_sec_rec.pa_request_id)
7106     loop
7107        l_sf52_dual_sec_rec.object_version_number :=  c_get_ovn.object_version_number;
7108     end loop;
7109 
7110     ghr_par_upd.upd(p_pa_request_id                   => l_sf52_dual_sec_rec.pa_request_id
7111 	    	    ,p_object_version_number          => l_sf52_dual_sec_rec.object_version_number
7112 		    ,p_from_position_id               => l_sf52_dual_sec_rec.from_position_id
7113                     ,p_to_position_id                 => l_sf52_dual_sec_rec.to_position_id
7114                     ,p_agency_code                    => l_sf52_dual_sec_rec.agency_code
7115                     ,p_from_agency_code               => l_sf52_dual_sec_rec.from_agency_code
7116                     ,p_from_agency_desc               => l_sf52_dual_sec_rec.from_agency_desc
7117                     ,p_from_office_symbol             => l_sf52_dual_sec_rec.from_office_symbol
7118                     ,p_personnel_office_id            => l_sf52_dual_sec_rec.personnel_office_id
7119                     ,p_employee_dept_or_agency        => l_sf52_dual_sec_rec.employee_dept_or_agency
7120                     ,p_to_office_symbol               => l_sf52_dual_sec_rec.to_office_symbol
7121 		    ,p_first_action_la_code1          => l_sf52_dual_sec_rec.first_action_la_code1
7122       		    ,p_first_action_la_desc1          => l_sf52_dual_sec_rec.first_action_la_desc1
7123 		    ,p_first_action_la_code2          => l_sf52_dual_sec_rec.first_action_la_code2
7124                     ,p_first_action_la_desc2          => l_sf52_dual_sec_rec.first_action_la_desc2
7125 		    ,p_approval_date                  => l_sf52_dual_first_rec.approval_date
7126 		    ,p_approving_official_work_titl   => l_sf52_dual_first_rec.approving_official_work_title
7127 		    ,p_approving_official_full_name   => l_sf52_dual_first_rec.approving_official_full_name
7128 		    ,p_sf50_approval_date             => l_sf52_dual_first_rec.sf50_approval_date
7129 		    ,p_sf50_approving_ofcl_full_nam   => l_sf52_dual_first_rec.sf50_approving_ofcl_full_name
7130 		    ,p_sf50_approving_ofcl_work_tit   => l_sf52_dual_first_rec.sf50_approving_ofcl_work_title
7131                   );
7132    /*For dual cancellation also Maintaining RPA_TYPE and Mass action id rpa_type will be DUAL and mass action id will
7133      be referring other dual cancellation record*/
7134    GHR_APPROVED_PA_REQUESTS.Update_Dual_Id(p_parent_pa_request_id  => p_pa_request_id,
7135                               p_first_dual_action_id  => p_sf52_data.pa_request_id,
7136 		    	      p_second_dual_action_id => l_pa_request_id);
7137 
7138 
7139 END Dual_Cancel_sf52;
7140 --6850492
7141 
7142 --8267598
7143 procedure reinit_dual_var is
7144 begin
7145   g_dual_prior_ws := null;
7146   --8264475
7147   g_dual_first_noac := null;
7148   g_dual_second_noac := null;
7149   g_dual_action_yn := 'N';
7150   g_dual_prior_prd := NULL; --8268353
7151   --8264475
7152 
7153 end;
7154 --8267598
7155 
7156 end GHR_PROCESS_SF52;
7157