DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_SF52_POS_UPDATE

Source


1 PACKAGE BODY GHR_SF52_POS_UPDATE  AS
2 /* $Header: ghpauppo.pkb 115.13 2004/01/28 21:42:08 ajose ship $ */
3 
4 g_package varchar2(32) := 'GHR_SF52_POS_UPDATE';
5 
6 
7 --
8 -- ---------------------------------------------------------------------------
9 -- |--------------------< retrieve_gov_kff_setup_info >----------------------|
10 -- ---------------------------------------------------------------------------
11 -- {Start of Comments}
12 --
13 -- Description:
14 --   Retrieve government key flexfields setup information.
15 --
16 -- Prerequisites:
17 --   Data must be existed in organization information with
18 --      ORG_INFORMATION = 'GHR_US_ORG_INFORMATION'.
19 --
20 -- In Parameters:
21 --   p_business_group_id
22 --
23 -- Out Parameters:
24 --   p_org_info_rec
25 --
26 -- Post Success:
27 --   Processing continues.
28 --
29 -- Post Failure:
30 --   An application error will be raised and processing is terminated.
31 --
32 -- Developer Implementation Notes:
33 --   Calling hr_utility procedures are commented out due to these procedures
34 --   update the database which violates the function requirement.
35 --
36 -- Access Status:
37 --   Internal Use Only.
38 --
39 -- {End of Comments}
40 -- ---------------------------------------------------------------------------
41 procedure retrieve_gov_kff_setup_info
42 	(p_business_group_id    in     per_business_groups.business_group_id%type
43 	,p_org_info_rec         out nocopy   org_info_rec_type
44 	) is
45   --
46   l_proc                varchar2(72) := g_package||'retrieve_gov_kff_setup_info';
47   l_org_info_id         hr_organization_information.org_information_id%type;
48   l_org_info_found      boolean := FALSE;
49   --
50   cursor c_organization_information (org_id number) is
51 	select oi.org_information1,
52 	       oi.org_information2,
53 	       oi.org_information3,
54 	       oi.org_information4,
55 	       oi.org_information5
56 	  from hr_organization_information oi
57 	  where oi.organization_id = org_id
58 	  and oi.org_information_context = 'GHR_US_ORG_INFORMATION';
59 --
60 begin
61   hr_utility.set_location('Entering:'||l_proc, 1);
62   p_org_info_rec.information1 := NULL;
63   p_org_info_rec.information2 := NULL;
64   p_org_info_rec.information3 := NULL;
65   p_org_info_rec.information4 := NULL;
66   p_org_info_rec.information5 := NULL;
67   --
68   for c_organization_information_rec in
69 		c_organization_information (p_business_group_id) loop
70     l_org_info_found := TRUE;
71     p_org_info_rec.information1 := c_organization_information_rec.org_information1;
72     p_org_info_rec.information2 := c_organization_information_rec.org_information2;
73     p_org_info_rec.information3 := c_organization_information_rec.org_information3;
74     p_org_info_rec.information4 := c_organization_information_rec.org_information4;
75     p_org_info_rec.information5 := c_organization_information_rec.org_information5;
76     exit;
77   end loop;
78   if not l_org_info_found then
79     -- hr_utility.set_message(8301, 'GHR_38025_API_INV_ORG');
80     -- hr_utility.raise_error;
81     null;
82   end if;
83   hr_utility.set_location(l_proc, 2);
84   --
85   if (p_org_info_rec.information1 is NULL
86       and p_org_info_rec.information2 is NULL
87       and p_org_info_rec.information3 is NULL
88       and p_org_info_rec.information4 is NULL
89       and p_org_info_rec.information5 is NULL) then
90     -- hr_utility.set_message(8301, 'GHR_38033_API_ORG_DDF_NOT_EXST');
91     -- hr_utility.raise_error;
92     null;
93   end if;
94   --
95    hr_utility.set_location(' Leaving:'||l_proc, 3);
96 --
97 exception
98   when no_data_found then
99     -- hr_utility.set_message(8301, 'GHR_38033_API_ORG_DDF_NOT_EXST');
100     -- hr_utility.raise_error;
101     null;
102 
103   WHEN others THEN
104      -- Reset IN OUT parameters and set OUT parameters
105 
106        p_org_info_rec          := NULL;
107 
108    hr_utility.set_location('Leaving  ' || l_proc,60);
109    RAISE;
110 
111 end retrieve_gov_kff_setup_info;
112 
113 procedure update_position_info
114 (p_pos_data_rec    in position_data_rec_type
115 )
116 IS
117 
118 l_proc              varchar2(25) := 'update_position_info';
119 l_datetrack_mode    VARCHAR2(20);
120 
121 procedure  update_position_kff
122 IS
123 l_proc              varchar2(25) := 'update_position_kff';
124 
125  l_position_definition_id         hr_all_positions_f.position_definition_id%TYPE;
126  l_position_name                  hr_all_positions_f.name%TYPE;
127  l_organization_id                per_organization_units.organization_id%TYPE;
128  l_business_group_id              number;
129  l_object_version_number          number;
130  l_valid_grades_changed_warning   BOOLEAN;
131  l_agency_code_info_num           number(2);
132  l_org_info_rec                   org_info_rec_type;
133  l_segment_tab 		          segment_tab_type;
134  l_effective_start_date           date;
135  l_effective_end_date             date;
136 
137 
138 cursor c_get_position_details(c_position_id IN number)
139 IS
140 
141 	SELECT name,position_definition_id,
142                organization_id,object_version_number,business_group_id
143         FROM   hr_all_positions_f  pos
144         WHERE  position_id = c_position_id -- Venkat -- Position DT
145         and    p_pos_data_rec.effective_date between
146            pos.effective_start_date and pos.effective_end_date;
147 
148 
149 cursor c_get_segments(c_position_definition_id in number)
150 IS
151 
152 	SELECT segment1,
153                segment2,
154 	       segment3,
155 	       segment4,
156 	       segment5,
157 	       segment6,
158 	       segment7,
159 	       segment8,
160 	       segment9,
161 	       segment10,
162 	       segment11,
163 	       segment12,
164 	       segment13,
165 	       segment14,
166 	       segment15,
167 	       segment16,
168 	       segment17,
169 	       segment18,
170 	       segment19,
171                segment20,
172 	       segment21,
173 	       segment22,
174 	       segment23,
175 	       segment24,
176 	       segment25,
177 	       segment26,
178 	       segment27,
179 	       segment28,
180 	       segment29,
181 	       segment30
182      FROM      per_position_definitions
183      WHERE     position_definition_id = c_position_definition_id;
184 
185 
186 BEGIN
187 hr_utility.set_location('Entering ' || l_proc ,5);
188 hr_utility.set_location('p_pos_data_rec.position_id  ' || to_char(p_pos_data_rec.position_id) ,6);
189 hr_utility.set_location('p_pos_data_rec.effective_date  ' || to_char(p_pos_data_rec.effective_date) ,7);
190 
191 for c_position_detail_rec IN c_get_position_details(p_pos_data_rec.position_id) LOOP
192 
193     l_position_definition_id := c_position_detail_rec.position_definition_id;
194     l_object_version_number  := c_position_detail_rec.object_version_number;
195     --l_position_name          := c_position_detail_rec.name;
196     l_organization_id        := c_position_detail_rec.organization_id;
197     l_business_group_id      := c_position_detail_rec.business_group_id;
198 hr_utility.set_location('l_business_group_id ' || to_char(l_business_group_id) ,10);
199 end loop;
200 
201 hr_utility.set_location('Entering ' || l_proc ,10);
202 for cursor_rec in c_get_segments(l_position_definition_id) LOOP
203 
204     l_segment_tab(1) := cursor_rec.segment1;
205     l_segment_tab(2) := cursor_rec.segment2;
206     l_segment_tab(3) := cursor_rec.segment3;
207     l_segment_tab(4) := cursor_rec.segment4;
208     l_segment_tab(5) := cursor_rec.segment5;
209     l_segment_tab(6) := cursor_rec.segment6;
210     l_segment_tab(7) := cursor_rec.segment7;
211     l_segment_tab(8) := cursor_rec.segment8;
212     l_segment_tab(9) := cursor_rec.segment9;
213     l_segment_tab(10) := cursor_rec.segment10;
214     l_segment_tab(11) := cursor_rec.segment11;
215     l_segment_tab(12) := cursor_rec.segment12;
216     l_segment_tab(13) := cursor_rec.segment13;
217     l_segment_tab(14) := cursor_rec.segment14;
218     l_segment_tab(15) := cursor_rec.segment15;
219     l_segment_tab(16) := cursor_rec.segment16;
220     l_segment_tab(17) := cursor_rec.segment17;
221     l_segment_tab(18) := cursor_rec.segment18;
222     l_segment_tab(19) := cursor_rec.segment19;
223     l_segment_tab(20) := cursor_rec.segment20;
224     l_segment_tab(21) := cursor_rec.segment21;
225     l_segment_tab(22) := cursor_rec.segment22;
226     l_segment_tab(23) := cursor_rec.segment23;
227     l_segment_tab(24) := cursor_rec.segment24;
228     l_segment_tab(25) := cursor_rec.segment25;
229     l_segment_tab(26) := cursor_rec.segment26;
230     l_segment_tab(27) := cursor_rec.segment27;
231     l_segment_tab(28) := cursor_rec.segment28;
232     l_segment_tab(29) := cursor_rec.segment29;
233     l_segment_tab(30) := cursor_rec.segment30;
234 
235 END LOOP;
236 
237 hr_utility.set_location('bg id :' || to_char(l_business_group_id) ,15);
238      retrieve_gov_kff_setup_info (p_business_group_id    => l_business_group_id
239                                   ,p_org_info_rec          => l_org_info_rec);
240 
241 hr_utility.set_location('org_info_rec :' || l_org_info_rec.information5,15);
242      l_agency_code_info_num := to_number(substr(l_org_info_rec.information5,8));
243 hr_utility.set_location('l_agency_code_info_num :' || to_char(l_agency_code_info_num),15);
244 
245 
246      l_segment_tab(l_agency_code_info_num) :=
247                             p_pos_data_rec.agency_code_subelement;
248 
249     hr_utility.set_location('after l_segment_tab ' || l_proc ,20);
250     l_datetrack_mode := pos_return_update_mode
251                  (p_position_id        => p_pos_data_rec.position_id,
252                   p_effective_date     => p_pos_data_rec.effective_date);
253      hr_utility.set_location('UPDATE_MODE Position  :   ' || l_datetrack_mode,25);
254      hr_position_api.update_position(
255  	       p_position_id              => p_pos_data_rec.position_id,
256                p_object_version_number    => l_object_version_number ,
257                p_segment1                 => l_segment_tab(1),
258                p_segment2                 => l_segment_tab(2),
259 	       p_segment3                 => l_segment_tab(3),
260 	       p_segment4                 => l_segment_tab(4),
261 	       p_segment5                 => l_segment_tab(5),
262 	       p_segment6                 => l_segment_tab(6),
263 	       p_segment7                 => l_segment_tab(7),
264 	       p_segment8                 => l_segment_tab(8),
265 	       p_segment9                 => l_segment_tab(9),
266 	       p_segment10                 => l_segment_tab(10),
267 	       p_segment11                 => l_segment_tab(11),
268 	       p_segment12                 => l_segment_tab(12),
269 	       p_segment13                 => l_segment_tab(13),
270 	       p_segment14                 => l_segment_tab(14),
271 	       p_segment15                 => l_segment_tab(15),
272 	       p_segment16                 => l_segment_tab(16),
273 	       p_segment17                 => l_segment_tab(17),
274 	       p_segment18                 => l_segment_tab(18),
275 	       p_segment19                 => l_segment_tab(19),
276 	       p_segment20                 => l_segment_tab(20),
277 	       p_segment21                 => l_segment_tab(21),
278 	       p_segment22                 => l_segment_tab(22),
279 	       p_segment23                 => l_segment_tab(23),
280 	       p_segment24                 => l_segment_tab(24),
281 	       p_segment25                 => l_segment_tab(25),
282 	       p_segment26                 => l_segment_tab(26),
283 	       p_segment27                 => l_segment_tab(27),
284 	       p_segment28                 => l_segment_tab(28),
285 	       p_segment29                 => l_segment_tab(29),
286 	       p_segment30                 => l_segment_tab(30),
287                p_position_definition_id    => l_position_definition_id,
288                p_name                      => l_position_name,
289                p_valid_grades_changed_warning => l_valid_grades_changed_warning,
290                p_effective_start_date     => l_effective_start_date,
291                p_effective_end_date       => l_effective_end_date,
292                p_effective_date           => p_pos_data_rec.effective_date,
293                p_datetrack_mode           => l_datetrack_mode);
294 
295 hr_utility.set_location('after update_position_api ' || l_proc ,25);
296 
297 end;
298 
299 procedure update_pos_organization
300 IS
301 
302 l_object_version_number  number;
303 l_position_definition_id hr_all_positions_f.position_definition_id%TYPE;
304 l_pos_name               hr_all_positions_f.name%TYPE;
305 l_valid_grade_warning    boolean;
306 l_effective_start_date   date;
307 l_effective_end_date     date;
308 l_location_id            hr_all_positions_f.location_id%TYPE;
309 
310 cursor c_get_position_details(c_position_id IN number)
311 IS
312 
313 	SELECT name,position_definition_id,
314                organization_id,object_version_number,business_group_id
315 	       ,location_id --  Bug 3219207 added by Ashley
316         FROM   hr_all_positions_f  pos
317         WHERE  position_id = c_position_id -- Venkat -- Position DT
318         and    p_pos_data_rec.effective_date between
319            pos.effective_start_date and pos.effective_end_date;
320 
321 
322 BEGIN
323 
324 
325 
326     hr_utility.set_location('update_pos_organization   ' ,25);
327 
331     l_location_id             := c_get_position_detail_rec.location_id; -- Bug 3219207
328   FOR c_get_position_detail_rec IN c_get_position_details(p_pos_data_rec.position_id) LOOP
329     l_object_version_number   := c_get_position_detail_rec.object_version_number;
330     l_position_definition_id  := c_get_position_detail_rec.position_definition_id;
332 
333 
334     l_datetrack_mode := pos_return_update_mode
335                  (p_position_id        => p_pos_data_rec.position_id,
336                   p_effective_date     => p_pos_data_rec.effective_date);
337 
338     hr_utility.set_location('UPDATE_MODE Position  :   ' || l_datetrack_mode,25);
339 
340 
341     IF p_pos_data_rec.location_id is not null THEN
342 
343        hr_position_api.update_position(
344  	       p_position_id              => p_pos_data_rec.position_id,
345                p_object_version_number    => l_object_version_number ,
346                p_location_id              => p_pos_data_rec.location_id,
347                p_position_definition_id   => l_position_definition_id,
348                p_name                     => l_pos_name,
349                p_valid_grades_changed_warning => l_valid_grade_warning,
350                p_effective_start_date     => l_effective_start_date,
351                p_effective_end_date       => l_effective_end_date,
352                p_effective_date           => p_pos_data_rec.effective_date,
353                p_datetrack_mode           => l_datetrack_mode);
354 
355       UPDATE hr_all_positions_f
356       SET organization_id = p_pos_data_rec.organization_id
357       WHERE position_id = p_pos_data_rec.position_id
358       AND   effective_start_date = l_effective_start_date;
359 
360    ELSE
361 
362 --Added this call for bug 3219207
363 
364        hr_position_api.update_position(
365  	       p_position_id              => p_pos_data_rec.position_id,
366                p_object_version_number    => l_object_version_number ,
367                p_location_id              => l_location_id,
368                p_position_definition_id   => l_position_definition_id,
369                p_name                     => l_pos_name,
370                p_valid_grades_changed_warning => l_valid_grade_warning,
371                p_effective_start_date     => l_effective_start_date,
372                p_effective_end_date       => l_effective_end_date,
373                p_effective_date           => p_pos_data_rec.effective_date,
374                p_datetrack_mode           => l_datetrack_mode
375 	                            );
376 
377       UPDATE hr_all_positions_f
378       SET organization_id = p_pos_data_rec.organization_id
379       WHERE position_id = p_pos_data_rec.position_id
380       AND   effective_start_date = l_effective_start_date;
381 
382     END IF;
383 
384   END LOOP;
385 
386 END;
387 
388 procedure update_pos_end_date
389 IS
390 
391 cursor c_get_position_details(c_position_id IN number, c_effective_date date)
392 IS
393 	SELECT  name,position_definition_id,
394                 organization_id,object_version_number,business_group_id
395         FROM    hr_all_positions_f
396         WHERE   position_id = c_position_id
397         AND     nvl(c_effective_date,sysdate)
398         between effective_start_date and effective_end_Date;
399 
400         Cursor c_position_status is
401         SELECT shared_type_id,shared_type_name  from per_shared_types
402         WHERE  system_type_cd = 'ELIMINATED';
403 
404   l_object_version_number  number;
405   l_position_definition_id hr_all_positions_f.position_definition_id%TYPE;
406   l_pos_name               hr_all_positions_f.name%TYPE;
407   l_valid_grade_warning    boolean;
408   l_location_id            hr_all_positions_f.location_id%TYPE;
409   l_effective_start_date   date;
410   l_effective_end_date     date;
411   l_shared_type_id         number;
412 
413 BEGIN
414   hr_utility.set_location('update_pos_end_date ', 25);
415  for c_get_position_details_rec in c_get_position_details (p_pos_data_rec.position_id , p_pos_data_rec.effective_date)   loop
416      for c_position_status_rec in c_position_status loop
417        l_shared_type_id :=   c_position_status_rec.shared_type_id;
418        exit;
419      end loop;
420 
421     l_datetrack_mode := pos_return_update_mode
422                  (p_position_id        => p_pos_data_rec.position_id,
423                   p_effective_date     => p_pos_data_rec.effective_date);
424     hr_utility.set_location('UPDATE_MODE Position  :   ' || l_datetrack_mode,25);
425     hr_position_api.update_position(
426  	       p_position_id              => p_pos_data_rec.position_id,
427                p_object_version_number    => c_get_position_details_rec.object_version_number,
428                p_position_definition_id   => c_get_position_details_rec.position_definition_id,
429                p_name                     => l_pos_name,
430                --p_date_end                 => p_pos_data_rec.effective_date,
431                p_availability_status_id   =>  l_shared_type_id,
432                p_valid_grades_changed_warning => l_valid_grade_warning,
433                p_effective_start_date     => l_effective_start_date,
434                p_effective_end_date       => l_effective_end_date,
435                p_effective_date           => p_pos_data_rec.effective_date,
436                p_datetrack_mode           => l_datetrack_mode);
437        hr_utility.set_location('After update of position',1);
438 
439 
440      --UPDATE hr_all_positions_f
441      --SET date_end = p_pos_data_rec.effective_end_date
442      --WHERE position_id = p_pos_data_rec.position_id
443      --AND   effective_start_date = p_pos_data_rec.effective_date;
444 
445  END LOOP;
446 
447 END;
448 
449 procedure update_pos_job_id
450 IS
451 l_effective_start_Date date;
452 l_effective_end_Date date;
453 l_pos_name               hr_all_positions_f.name%type;
454 l_position_Definition_id hr_all_positions_f.position_Definition_id%type;
455 l_object_version_number number;
456 l_valid_grade_warning boolean;
457 
458 cursor c_get_position_details(c_position_id IN number,c_effective_date date)
459 IS
460 
461 	SELECT name,position_definition_id,
462                job_id,object_version_number,business_group_id
463         FROM   hr_all_positions_f
464         WHERE  position_id = c_position_id
465         and    nvl(c_effective_date,sysdate) between
466                effective_start_date and effective_end_date;
467 
468 BEGIN
469 
470     hr_utility.set_location('update_pos_job_id   ' ,25);
471   FOR c_get_position_detail_rec IN c_get_position_details(p_pos_data_rec.position_id,p_pos_data_rec.effective_date) LOOP
472    l_object_version_number :=  c_get_position_detail_rec.object_version_number;
473    l_position_definition_id :=  c_get_position_detail_rec.position_definition_id;
474     l_datetrack_mode := pos_return_update_mode
475                  (p_position_id        => p_pos_data_rec.position_id,
476                   p_effective_date     => p_pos_data_rec.effective_date);
477     hr_utility.set_location('UPDATE_MODE Position  :   ' || l_datetrack_mode,25);
478     hr_position_api.update_position(
479  	       p_position_id              => p_pos_data_rec.position_id,
480                p_object_version_number    => l_object_version_number ,
481                p_position_definition_id   => l_position_definition_id,
482                p_name                     => l_pos_name,
483                p_valid_grades_changed_warning => l_valid_grade_warning,
484                p_effective_start_date     => l_effective_start_date,
485                p_effective_end_date       => l_effective_end_date,
486                p_effective_date           => p_pos_data_rec.effective_date,
487                p_datetrack_mode           => l_datetrack_mode);
488 
489       UPDATE hr_all_positions_f
490       SET job_id        = p_pos_data_rec.job_id
491       WHERE position_id = p_pos_data_rec.position_id
492       and effective_start_date = l_effective_start_date;
493 
494 
495  END LOOP;
496 
497 END;
498 
499 
500 BEGIN
501 
502 IF p_pos_data_rec.organization_id is NOT NULL THEN
503 
504 begin
505 
506    update_pos_organization;
507 exception
508    when others then
509       raise;
510 end;
511 
512 END IF;
513 
514 IF p_pos_data_rec.agency_code_subelement is NOT NULL
515 THEN
516 
517 begin
518     update_position_kff;
519 exception
520    when others then
521       raise;
522 end;
523 
524 END IF;
525 
526 IF p_pos_data_rec.effective_end_date is NOT NULL
527 THEN
528 
529 begin
530    update_pos_end_date;
531 exception
532    when others then
533       raise;
534 end;
535 
536 END IF;
537 
538 IF p_pos_data_rec.job_id is NOT NULL
539 THEN
540 
541 begin
542    update_pos_job_id;
543 exception
544    when others then
545       raise;
546 end;
547 
548 END IF;
549 
550 END;
551 
552 FUNCTION pos_return_update_mode
553   (p_position_id     IN     hr_all_positions_f.position_id%type,
554    p_effective_date  IN     date)
555 
556 RETURN varchar2 is
557 
558   l_proc     varchar2(72) := 'return_update_mode';
559   l_eed      date;
560   l_esd      date;
561   l_mode     varchar2(20) := 'CORRECTION';
562   l_exists  boolean := FALSE;
563 
564   cursor     c_update_mode_pos is
565     select   pos.effective_start_date ,
566              pos.effective_end_date
567     from     hr_all_positions_f pos
568     where    pos.position_id = p_position_id
569     and      p_effective_date
570     between  pos.effective_start_date
571     and      pos.effective_end_date;
572 
573   cursor     c_update_mode_pos1 is
574     select   pos.effective_start_date ,
575              pos.effective_end_date
576     from     hr_all_positions_f pos
577     where    pos.position_id = p_position_id
578     and      p_effective_date  <  pos.effective_start_date;
579 
580   Begin
581     hr_utility.set_location('Entering  ' || l_proc,5);
582       for update_mode in c_update_mode_pos loop
583         hr_utility.set_location(l_proc,10);
584         l_esd := update_mode.effective_start_date;
585         l_eed := update_mode.effective_end_date;
586       end loop;
587       If l_esd = p_effective_date then
588         hr_utility.set_location(l_proc,20);
589         l_mode := 'CORRECTION';
590       Elsif l_esd < p_effective_date and
591             to_char(l_eed,'YYYY/MM/DD') = '4712/12/31' then
592         hr_utility.set_location(l_proc,25);
593         l_mode := 'UPDATE';                           --  to end date a row and then create a new row
594       Elsif  l_esd <  p_effective_date  then
595         hr_utility.set_location(l_proc,30);
596         for update_mode1 in c_update_mode_pos1 loop
597           hr_utility.set_location(l_proc,35);
598           l_exists := true;
599           exit;
600         end loop;
601         If l_exists then
602           hr_utility.set_location(l_proc,40);
603           l_mode := 'UPDATE_CHANGE_INSERT';              -- to insert a row between 2 existing rows
604         Else
605           hr_utility.set_location(l_proc,45);
606           l_mode := 'CORRECTION';
607         End if;
608         hr_utility.set_location(l_proc,50);
609       End if;
610       hr_utility.set_location(l_proc,55);
611       hr_utility.set_location('UPDATE_MODE  :   ' || l_mode,2);
612       If l_mode is null then
613         hr_utility.set_message(8301,'GHR_GET_DATE_TRACK_FAILED');
614         hr_utility.set_message_token('TABLE_NAME','HR_ALL_POSITIONS_F');
615         hr_utility.raise_error;
616       End if;
617     return l_mode;
618     hr_utility.set_location('Leaving ' ||l_proc,60);
619 End pos_return_update_mode;
620 
621 -----
622 -- JH Added for bug 773795, Position's location is now updated with update to HR.
623 -----
624 PROCEDURE update_positions_location
625  (p_position_id        IN       hr_all_positions_f.position_id%TYPE,
626   p_location_id        IN       hr_all_positions_f.location_id%TYPE,
627   p_effective_date     IN       date) IS
628 
629  l_position_definition_id         hr_all_positions_f.position_definition_id%TYPE;
630  l_position_name                  hr_all_positions_f.name%TYPE;
631  l_object_version_number          number;
632  l_location_id                    hr_all_positions_f.location_id%TYPE;
633  l_valid_grade_warning            BOOLEAN;
634  l_effective_start_date           date;
635  l_effective_end_date             date;
636  l_datetrack_mode                 VARCHAR2(20);
637 
638 cursor c_get_position_details
639 IS
640 
641 	SELECT name, position_definition_id, location_id, object_version_number
642       FROM   hr_all_positions_f
643       WHERE  position_id = p_position_id
644       and    nvl(p_effective_date,sysdate) between
645              effective_start_date and effective_end_date;
646 
647 BEGIN
648 
649   FOR c_get_position_detail_rec IN c_get_position_details LOOP
650     l_position_name := c_get_position_detail_rec.name;
651     l_position_definition_id := c_get_position_detail_rec.position_definition_id;
652     l_location_id := c_get_position_detail_rec.location_id;
653     l_object_version_number := c_get_position_detail_rec.object_version_number;
654 
655     If nvl(l_location_id,-1) <> nvl(p_location_id,-2) Then
656 
657       l_datetrack_mode := pos_return_update_mode
658           (p_position_id        => p_position_id,
659           p_effective_date     => p_effective_date);
660 
661       hr_utility.set_location('UPDATE_MODE Position  :   ' || l_datetrack_mode,99);
662 
663       hr_utility.set_location('update_pos_location ', 99);
664 
665       hr_position_api.update_position(
666         p_position_id                  => p_position_id,
667         p_object_version_number        => l_object_version_number,
668         p_location_id                  => p_location_id,
669         p_position_definition_id       => l_position_definition_id,
670         p_name                         => l_position_name,
671         p_valid_grades_changed_warning => l_valid_grade_warning,
672         p_effective_start_date         => l_effective_start_date,
673         p_effective_end_date           => l_effective_end_date,
674         p_effective_date               => p_effective_date,
675         p_datetrack_mode               => l_datetrack_mode);
676 
677       hr_utility.set_location('After update of positions location ',99);
678 
679     End If;
680 
681   END LOOP;
682 
683 END;
684 
685 end ghr_sf52_pos_update;
686