DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_PROCESS_SF52

Source


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