DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_MX_EXTRA_ASG_RULES

Source


1 PACKAGE BODY hr_mx_extra_asg_rules AS
2 /* $Header: hrmxexas.pkb 120.4.12010000.1 2008/07/28 03:31:54 appldev ship $ */
3 
4 -- Global variables
5 --
6     g_debug    BOOLEAN;
7     g_package  VARCHAR2(33);
8 
9 --------------------------------------------------------------------------
10 --                                                                      --
11 -- Name           : get_gre_loc                                         --
12 -- Type           : Procedure                                           --
13 -- Access         : Public                                              --
14 -- Description    : Procedure to save the location and GRE for the      --
15 --                  given assignment on the specified date in global    --
16 --                  variables.                                          --
17 -- Parameters     :                                                     --
18 --             IN : p_effective_date        DATE                        --
19 --                  p_assignment_id         NUMBER                      --
20 --            OUT : N/A                                                 --
21 --         RETURN : N/A                                                 --
22 --                                                                      --
23 --------------------------------------------------------------------------
24 PROCEDURE get_gre_loc(p_effective_date IN        DATE,
25                       p_assignment_id  IN        per_assignments_f.assignment_id%TYPE
26                      ) AS
27 --
28        l_proc        VARCHAR2(100);
29        l_location_id hr_locations.location_id%TYPE;
30        l_scl_gre     hr_soft_coding_keyflex.segment1%TYPE;
31 
32      CURSOR csr_get_gre_location IS
33      SELECT paf.location_id,
34             hsck.segment1
35        FROM per_assignments_f      PAF,
36             hr_soft_coding_keyflex HSCK
37       WHERE paf.assignment_id = p_assignment_id
38         AND paf.soft_coding_keyflex_id = hsck.soft_coding_keyflex_id
39         AND trunc(p_effective_date) BETWEEN paf.effective_start_date
40                                         AND paf.effective_end_date;
41 
42 --
43 BEGIN
44 --
45      g_debug := hr_utility.debug_enabled;
46 
47      l_proc := g_package||'get_gre_loc';
48 
49      IF g_debug THEN
50         hr_utility.set_location('Entering:'|| l_proc, 10);
51      END IF;
52 
53      OPEN csr_get_gre_location;
54      FETCH csr_get_gre_location INTO l_location_id, l_scl_gre;
55      CLOSE csr_get_gre_location;
56 
57      hr_mx_assignment_api.g_old_location := l_location_id;
58      hr_mx_assignment_api.g_old_gre      := l_scl_gre;
59 
60      IF g_debug THEN
61         hr_utility.set_location('Leaving: '||l_proc, 20);
62      END IF;
63 --
64 END get_gre_loc;
65 
66 --------------------------------------------------------------------------
67 --                                                                      --
68 -- Name           : chk_loc_gre_for_leav_reason                         --
69 -- Type           : Procedure                                           --
70 -- Access         : Public                                              --
71 -- Description    : Procedure to perform the Leaving Reason validations --
72 --                  in case of update of assignment's location or GRE.  --
73 -- Parameters     :                                                     --
74 --             IN : p_effective_date        DATE                        --
75 --                       p_datetrack_update_mode VARCHAR2                    --
76 --                  p_assignment_id         NUMBER                      --
77 --                  p_location_id           NUMBER                      --
78 --                  p_scl_segment1          VARCHAR2                    --
79 --            OUT : N/A                                                 --
80 --         RETURN : N/A                                                 --
81 --                                                                      --
82 --------------------------------------------------------------------------
83 PROCEDURE chk_loc_gre_for_leav_reason(p_effective_date        IN DATE,
84                                        p_datetrack_update_mode IN VARCHAR2,
85                                       p_assignment_id         IN per_assignments_f.assignment_id%TYPE,
86                                       p_location_id           IN hr_locations.location_id%TYPE,
87                                       p_scl_segment1          IN hr_soft_coding_keyflex.segment1%TYPE
88                                      ) AS
89 --
90         l_gre_old       hr_soft_coding_keyflex.segment1%TYPE;
91         l_gre_new       hr_soft_coding_keyflex.segment1%TYPE;
92         l_location_old  hr_locations.location_id%TYPE;
93         l_scl_gre       hr_soft_coding_keyflex.segment1%TYPE;
94         l_dummy1        BOOLEAN;
95         l_dummy2        BOOLEAN;
96         l_dummy3        per_assignment_extra_info.assignment_extra_info_id%TYPE;
97         l_dummy4        NUMBER;
98         l_bg_id         per_assignments_f.business_group_id%TYPE;
99         l_proc          VARCHAR2(100);
100         l_segment1      hr_soft_coding_keyflex.segment1%TYPE;
101         l_location_id   hr_locations.location_id%TYPE;
102 
103 
104         CURSOR csr_fetch_bg IS
105         SELECT business_group_id
106           FROM per_assignments_f
107          WHERE assignment_id = p_assignment_id
108            AND rownum < 2;
109 --
110 BEGIN
111 --
112         g_debug    := hr_utility.debug_enabled;
113 
114         l_proc := g_package||'chk_loc_gre_for_leav_reason';
115 
116         IF g_debug THEN
117                 hr_utility.set_location('Entering:'|| l_proc, 10);
118         END IF;
119 
120         IF NOT hr_utility.chk_product_install('Oracle Human Resources', 'MX') THEN
121 
122                 IF g_debug THEN
123                         hr_utility.trace('Mexico legislation not installed. Not performing validation checks.');
124                 END IF;
125                 RETURN;
126         END IF;
127 
128 --------------------------------------------------------------------------
129 -- Get the OLD gre and location from the global variables that have been
130 -- set in the BP hook
131 --------------------------------------------------------------------------
132         l_location_old := hr_mx_assignment_api.g_old_location;
133         l_scl_gre      := hr_mx_assignment_api.g_old_gre;
134 
135 --------------------------------------------------------------------------
136 -- Reset the global variables for Old Location and GRE to NULL.
137 --------------------------------------------------------------------------
138         hr_mx_assignment_api.g_old_location := NULL;
139         hr_mx_assignment_api.g_old_gre      := NULL;
140 
141         OPEN csr_fetch_bg;
142         FETCH csr_fetch_bg INTO l_bg_id;
143         CLOSE csr_fetch_bg;
144 
145         IF g_debug THEN
146                 hr_utility.set_location(l_proc, 20);
147         END IF;
148 
149 ---------------------
150 -- Fetch the Old GRE.
151 ---------------------
152         l_gre_old := nvl(  to_number(l_scl_gre),
153 
154                            hr_mx_utility.get_gre_from_location(l_location_old,
155                                                        l_bg_id, -- Bug 4129001
156                                                        p_effective_date,
157                                                        l_dummy1,
158                                                        l_dummy2)
159                         );
160 
161         IF g_debug THEN
162                 hr_utility.set_location(l_proc, 30);
163         END IF;
164 
165 --------------------------------------------------------------------------
166 -- Use the old location and old SCL GRE values, if the parameters are
167 -- system defaulted. (Bug 3777663)
168 --------------------------------------------------------------------------
169         SELECT decode(p_scl_segment1, hr_api.g_varchar2, l_scl_gre, p_scl_segment1),
170                decode(p_location_id, hr_api.g_number, l_location_old, p_location_id)
171         INTO   l_segment1,
172                l_location_id
173         FROM DUAL;
174 
175         IF g_debug THEN
176                 hr_utility.set_location(l_proc, 35);
177         END IF;
178 
179 --------------------------------------------------------------------------
180 -- Determine the NEW gre for the given assignment_id.
181 --------------------------------------------------------------------------
182         l_gre_new := nvl(  to_number(l_segment1),
183 
184                            hr_mx_utility.get_gre_from_location(l_location_id,
185                                                        l_bg_id, -- Bug 4129001
186                                                        p_effective_date,
187                                                        l_dummy1,
188                                                        l_dummy2)
189                         );
190 
191         IF g_debug THEN
192                 hr_utility.set_location(l_proc, 40);
193         END IF;
194 
195 --------------------------------------------------------------------------
196 -- Check the new GRE and compare with old GRE and location to determine
197 -- if there is a change in GRE taking place with this Update operation.
198 --------------------------------------------------------------------------
199         IF l_gre_new <> l_gre_old AND
200            l_gre_new IS NOT NULL  AND
201            l_gre_old IS NOT NULL  AND
202            p_datetrack_update_mode IN ('UPDATE', 'UPDATE_CHANGE_INSERT', 'UPDATE_OVERRIDE') THEN
203 
204 --------------------------------------------------------------------------
205 -- If YES, then check the leaving reason Global Variable. If it's null,
206 -- raise an error. Else, insert an Assignment EIT record using the API.
207 --------------------------------------------------------------------------
208                 IF hr_mx_assignment_api.g_leaving_reason IS NULL THEN
209 
210 --                        hr_utility.set_message(800,'HR_MX_MISSING_LEAVING_REASON');
211 --                           hr_utility.raise_error;
212                         null;
213 
214                 ELSE
215 
216                         OPEN csr_fetch_bg;
217                         FETCH csr_fetch_bg INTO l_bg_id;
218                         CLOSE csr_fetch_bg;
219 
220                         IF g_debug THEN
221                                 hr_utility.set_location(l_proc, 50);
222                         END IF;
223 
224                         fnd_profile.put('PER_BUSINESS_GROUP_ID', l_bg_id);
225 
226                         hr_assignment_extra_info_api.create_assignment_extra_info
227                             (p_assignment_id    => p_assignment_id,
228                              p_information_type => 'MX_SS_EMP_TRANS_REASON',
229                              p_aei_information_category => 'MX_SS_EMP_TRANS_REASON',
230                              p_aei_information1 => fnd_date.date_to_canonical(trunc(p_effective_date) - 1),
231                              p_aei_information2 => l_gre_old,
232                              p_aei_information3 => hr_mx_assignment_api.g_leaving_reason,
233                              p_assignment_extra_info_id => l_dummy3,
234                              p_object_version_number => l_dummy4
235                             );
236 
237                         IF g_debug THEN
238                                 hr_utility.set_location(l_proc, 60);
239                         END IF;
240 
241                         hr_mx_assignment_api.g_leaving_reason := null;
242 
243                 END IF;
244 
245         END IF;
246 
247         IF g_debug THEN
248                 hr_utility.set_location('Leaving: '||l_proc, 70);
249         END IF;
250 
251 --
252 END chk_loc_gre_for_leav_reason;
253 
254 
255 --------------------------------------------------------------------------
256 --                                                                      --
257 -- Name           : chk_gre_for_leav_reason                             --
258 -- Type           : Procedure                                           --
259 -- Access         : Public                                              --
260 -- Description    : Procedure to perform the Leaving Reason validations --
261 --                  in case of update of assignment's GRE through SCL.  --
262 -- Parameters     :                                                     --
263 --             IN : p_effective_date        DATE                        --
264 --                       p_datetrack_update_mode VARCHAR2                    --
265 --                  p_assignment_id         NUMBER                      --
266 --                  p_segment1              VARCHAR2                    --
267 --            OUT : N/A                                                 --
268 --         RETURN : N/A                                                 --
269 --                                                                      --
270 --------------------------------------------------------------------------
271 PROCEDURE chk_gre_for_leav_reason(p_effective_date        IN DATE,
272                                   p_datetrack_update_mode IN VARCHAR2,
273                                   p_assignment_id         IN per_assignments_f.assignment_id%TYPE,
274                                   p_segment1              IN hr_soft_coding_keyflex.segment1%TYPE
275                                  ) AS
276 --
277         l_gre_old       hr_soft_coding_keyflex.segment1%TYPE;
278         l_gre_new       hr_soft_coding_keyflex.segment1%TYPE;
279         l_location_old  hr_locations.location_id%TYPE;
280         l_scl_gre       hr_soft_coding_keyflex.segment1%TYPE;
281         l_dummy1        BOOLEAN;
282         l_dummy2        BOOLEAN;
283         l_dummy3        per_assignment_extra_info.assignment_extra_info_id%TYPE;
284         l_dummy4        NUMBER;
285         l_bg_id         per_assignments_f.business_group_id%TYPE;
286         l_proc          VARCHAR2(100);
287         l_segment1      hr_soft_coding_keyflex.segment1%TYPE;
288 
289         CURSOR csr_fetch_bg IS
290         SELECT business_group_id
291           FROM per_assignments_f
292          WHERE assignment_id = p_assignment_id
293            AND rownum < 2;
294 --
295 BEGIN
296 --
297         g_debug    := hr_utility.debug_enabled;
298 
299         l_proc := g_package||'chk_gre_for_leav_reason';
300 
301         IF g_debug THEN
302                 hr_utility.set_location('Entering:'|| l_proc, 10);
303         END IF;
304 
305         IF NOT hr_utility.chk_product_install('Oracle Human Resources', 'MX') THEN
306 
307                 IF g_debug THEN
308                         hr_utility.trace('Mexico legislation not installed. Not performing validation checks.');
309                 END IF;
310                 RETURN;
311         END IF;
312 
313 --------------------------------------------------------------------------
314 -- Get the old gre and location for the given assignment_id as on the
315 -- effective_date.
316 --------------------------------------------------------------------------
317         get_gre_loc(p_effective_date,
318                     p_assignment_id
319                    );
320 
321         l_location_old := hr_mx_assignment_api.g_old_location;
322         l_scl_gre      := hr_mx_assignment_api.g_old_gre;
323 
324 --------------------------------------------------------------------------
325 -- Reset the global variables for Old Location and GRE to NULL.
326 --------------------------------------------------------------------------
327         hr_mx_assignment_api.g_old_location := NULL;
328         hr_mx_assignment_api.g_old_gre      := NULL;
329 
330         OPEN csr_fetch_bg;
331         FETCH csr_fetch_bg INTO l_bg_id;
332         CLOSE csr_fetch_bg;
333 
334         IF g_debug THEN
335                 hr_utility.set_location(l_proc, 20);
336         END IF;
337 
338         l_gre_old := nvl(  to_number(l_scl_gre),
339 
340                            hr_mx_utility.get_gre_from_location(l_location_old,
341                                                        l_bg_id, -- Bug 4129001
342                                                        p_effective_date,
343                                                        l_dummy1,
344                                                        l_dummy2)
345                         );
346 
347         IF g_debug THEN
348                 hr_utility.set_location(l_proc, 30);
349         END IF;
350 
351 --------------------------------------------------------------------------
352 --  Use the old SCL GRE value, if the value of p_segment1 is system
353 --  defaulted. (Bug 3777663)
354 --------------------------------------------------------------------------
355         SELECT decode(p_segment1, hr_api.g_varchar2, l_scl_gre, p_segment1)
356         INTO   l_segment1
357         FROM DUAL;
358 
359         IF g_debug THEN
360                 hr_utility.set_location(l_proc, 35);
361         END IF;
362 
363 --------------------------------------------------------------------------
364 -- Determine the NEW gre for the given assignment_id.
365 -- Bug 3785341 - The Old location is used to derive GRE, if the GRE passed
366 --               is null.
367 --------------------------------------------------------------------------
368         l_gre_new := nvl(  to_number(l_segment1),
369                            hr_mx_utility.get_gre_from_location(l_location_old,
370                                                        l_bg_id, -- Bug 4129001
371                                                        p_effective_date,
372                                                        l_dummy1,
373                                                        l_dummy2)
374                         );
375 
376 --------------------------------------------------------------------------
377 -- Check the new GRE and compare with old GRE and location to determine
378 -- if there is a change in GRE taking place with this Update operation.
379 --------------------------------------------------------------------------
380         IF l_gre_new <> l_gre_old AND
381            l_gre_new IS NOT NULL  AND
382            l_gre_old IS NOT NULL  AND
383            p_datetrack_update_mode IN ('UPDATE', 'UPDATE_CHANGE_INSERT', 'UPDATE_OVERRIDE') THEN
384 
385 --------------------------------------------------------------------------
386 -- If YES, then check the leaving reason Global Variable. If it's null,
387 -- raise an error. Else, insert an Assignment EIT record using the API.
388 --------------------------------------------------------------------------
389                 IF hr_mx_assignment_api.g_leaving_reason IS NULL THEN
390 
391                         IF g_debug THEN
392                                 hr_utility.set_location(l_proc, 40);
393                         END IF;
394 
395 --                        hr_utility.set_message(800,'HR_MX_MISSING_LEAVING_REASON');
396 --                        hr_utility.raise_error;
397                         null;
398 
399                 ELSE
400 
401                         IF g_debug THEN
402                                 hr_utility.set_location(l_proc, 50);
403                         END IF;
404 
405                         fnd_profile.put('PER_BUSINESS_GROUP_ID', l_bg_id);
406 
407                         hr_assignment_extra_info_api.create_assignment_extra_info
408                             (p_assignment_id    => p_assignment_id,
409                              p_information_type => 'MX_SS_EMP_TRANS_REASON',
410                              p_aei_information_category => 'MX_SS_EMP_TRANS_REASON',
411                              p_aei_information1 => fnd_date.date_to_canonical(trunc(p_effective_date) - 1),
412                              p_aei_information2 => l_gre_old,
413                              p_aei_information3 => hr_mx_assignment_api.g_leaving_reason,
414                              p_assignment_extra_info_id => l_dummy3,
415                              p_object_version_number => l_dummy4
416                             );
417 
418                         hr_mx_assignment_api.g_leaving_reason := null;
419 
420                         IF g_debug THEN
421                                 hr_utility.set_location(l_proc, 60);
422                         END IF;
423 
424                 END IF;
425 
426         END IF;
427 
428         IF g_debug THEN
429                 hr_utility.set_location('Leaving: '||l_proc, 70);
430         END IF;
431 
432 END chk_gre_for_leav_reason;
433 
434 --------------------------------------------------------------------------
435 --                                                                      --
436 -- Name           : chk_leav_reason_for_del_asg                         --
437 -- Type           : Procedure                                           --
438 -- Access         : Public                                              --
439 -- Description    : Procedure to capture the Leaving Reason in case of  --
440 --                  delete of assignment.                               --
441 -- Parameters     :                                                     --
442 --             IN : p_final_process_date    DATE                        --
443 --                  p_assignment_id         NUMBER                      --
444 --            OUT : N/A                                                 --
445 --         RETURN : N/A                                                 --
446 --                                                                      --
447 --------------------------------------------------------------------------
448 PROCEDURE chk_leav_reason_for_del_asg
449 
450          (p_final_process_date    IN DATE,
451           p_assignment_id         IN per_assignments_f.assignment_id%TYPE
452          )
453 AS
454 --
455         l_gre_old       hr_soft_coding_keyflex.segment1%TYPE;
456         l_location_old  hr_locations.location_id%TYPE;
457         l_scl_gre       hr_soft_coding_keyflex.segment1%TYPE;
458         l_dummy1        BOOLEAN;
459         l_dummy2        BOOLEAN;
460         l_dummy3        per_assignment_extra_info.assignment_extra_info_id%TYPE;
461         l_dummy4        NUMBER;
462         l_proc          VARCHAR2(100);
463 
464         l_bg_id         per_assignments_f.business_group_id%TYPE;
465 
466         CURSOR csr_fetch_bg IS
467         SELECT business_group_id
468           FROM per_assignments_f
469          WHERE assignment_id = p_assignment_id
470            AND rownum < 2;
471 --
472 BEGIN
473 --
474         g_debug    := hr_utility.debug_enabled;
475 
476         l_proc := g_package||'chk_leav_reason_for_del_asg';
477         IF g_debug THEN
478                 hr_utility.set_location('Entering:'|| l_proc, 10);
479         END IF;
480 
481         IF NOT hr_utility.chk_product_install('Oracle Human Resources', 'MX') THEN
482 
483                 IF g_debug THEN
484                         hr_utility.trace('Mexico legislation not installed. Not performing validation checks.');
485                 END IF;
486                 RETURN;
487         END IF;
488 
489 --------------------------------------------------------------------------
490 -- Get the old gre and location for the given assignment_id as on the
491 -- Final Process Date.
492 --------------------------------------------------------------------------
493         get_gre_loc(p_final_process_date,
494                     p_assignment_id
495                    );
496 
497         l_location_old := hr_mx_assignment_api.g_old_location;
498         l_scl_gre      := hr_mx_assignment_api.g_old_gre;
499 
500 --------------------------------------------------------------------------
501 -- Reset the global variables for Old Location and GRE to NULL.
502 --------------------------------------------------------------------------
503         hr_mx_assignment_api.g_old_location := NULL;
504         hr_mx_assignment_api.g_old_gre      := NULL;
505 
506 --------------------------------------------------------------------------
507 -- Fetch the BG for the assignment and set the corresponding system profile.
508 --------------------------------------------------------------------------
509         OPEN csr_fetch_bg;
510         FETCH csr_fetch_bg INTO l_bg_id;
511         CLOSE csr_fetch_bg;
512 
513         fnd_profile.put('PER_BUSINESS_GROUP_ID', l_bg_id);
514 
515 
516         IF g_debug THEN
517                 hr_utility.set_location(l_proc, 20);
518         END IF;
519 
520 --------------------------------------------------------------------------
521 -- Fetch the GRE for the assignment record being deleted.
522 --------------------------------------------------------------------------
523         l_gre_old := nvl(  to_number(l_scl_gre),
524 
525                            hr_mx_utility.get_gre_from_location(l_location_old,
526                                                        l_bg_id, -- Bug 4129001
527                                                        p_final_process_date,
528                                                        l_dummy1,
529                                                        l_dummy2)
530                         );
531 
532         IF g_debug THEN
533                 hr_utility.set_location(l_proc, 30);
534         END IF;
535 
536 --------------------------------------------------------------------------
537 -- Check the leaving reason Global Variable. If it's null,
538 -- raise an error. Else, insert an Assignment EIT record using the API.
539 --------------------------------------------------------------------------
540         IF hr_mx_assignment_api.g_leaving_reason IS NULL THEN
541 
542                 IF g_debug THEN
543                         hr_utility.set_location(l_proc, 40);
544                 END IF;
545 
546 --                hr_utility.set_message(800,'HR_MX_MISSING_LEAVING_REASON');
547 --                hr_utility.raise_error;
548                 null;
549 
550         ELSE
551 
552                 IF g_debug THEN
553                         hr_utility.set_location(l_proc, 50);
554                 END IF;
555 
556                 hr_assignment_extra_info_api.create_assignment_extra_info
557                             (p_assignment_id    => p_assignment_id,
558                              p_information_type => 'MX_SS_EMP_TRANS_REASON',
559                              p_aei_information_category => 'MX_SS_EMP_TRANS_REASON',
560                              p_aei_information1 => fnd_date.date_to_canonical(trunc(p_final_process_date)),
561                              p_aei_information2 => l_gre_old,
562                              p_aei_information3 => hr_mx_assignment_api.g_leaving_reason,
563                              p_assignment_extra_info_id => l_dummy3,
564                              p_object_version_number => l_dummy4
565                             );
566 
567                 hr_mx_assignment_api.g_leaving_reason := null;
568 
569                 IF g_debug THEN
570                         hr_utility.set_location(l_proc, 60);
571                 END IF;
572 
573         END IF;
574 
575         IF g_debug THEN
576                 hr_utility.set_location('Leaving: '||l_proc, 70);
577         END IF;
578 
579 --
580 END chk_leav_reason_for_del_asg;
581 
582 --------------------------------------------------------------------------
583 --                                                                      --
584 -- Name           : chk_leav_reason_for_del_emp                         --
585 -- Type           : Procedure                                           --
586 -- Access         : Public                                              --
587 -- Description    : Procedure to capture the Leaving Reason in case of  --
588 --                  end of Employment.                                  --
589 -- Parameters     :                                                     --
590 --             IN : p_final_process_date    DATE                        --
591 --                  p_assignment_id         NUMBER                      --
592 --            OUT : N/A                                                 --
593 --         RETURN : N/A                                                 --
594 --                                                                      --
595 --------------------------------------------------------------------------
596 PROCEDURE chk_leav_reason_for_del_emp
597 
598 (p_final_process_date    IN DATE,
599  p_period_of_service_id  IN per_periods_of_service.period_of_service_id%TYPE,
600  p_object_version_number IN NUMBER
601 ) AS
602 
603 l_dummy            NUMBER;
604 l_proc             VARCHAR2(100);
605 ld_effective_date  DATE;
606 --
607 BEGIN
608 --
609         g_debug    := hr_utility.debug_enabled;
610         l_dummy    := p_object_version_number;
611 
612         l_proc := g_package||'chk_leav_reason_for_del_emp';
613         IF g_debug THEN
614                 hr_utility.set_location('Entering:'|| l_proc, 10);
615         END IF;
616 
617         IF NOT hr_utility.chk_product_install('Oracle Human Resources', 'MX') THEN
618 
619                 IF g_debug THEN
620                         hr_utility.trace('Mexico legislation not installed. Not performing validation checks.');
621                 END IF;
622                 RETURN;
623         END IF;
624 
625 --------------------------------------------------------------------------
626 -- Check the leaving reason Global Variable. If it's null, raise an error.
627 -- Else, save it in the Period of Service DDF using the API.
628 --------------------------------------------------------------------------
629         IF hr_mx_assignment_api.g_leaving_reason IS NULL THEN
630 
631                 IF g_debug THEN
632                         hr_utility.set_location(l_proc, 20);
633                 END IF;
634 
635 --                hr_utility.set_message(800,'HR_MX_MISSING_LEAVING_REASON');
636 --                hr_utility.raise_error;
637                 null;
638 
639         ELSE
640 
641                 IF g_debug THEN
642                         hr_utility.set_location(l_proc, 30);
643                 END IF;
644 
645                 BEGIN
646 
647                   SELECT TRUNC(effective_date)
648                     INTO ld_effective_date
649                     FROM fnd_sessions
650                    WHERE session_id = userenv('sessionid');
651 
652                   EXCEPTION
653                   WHEN others THEN
654                     ld_effective_date := TRUNC(sysdate);
655 
656                 END;
657 
658                 hr_periods_of_service_api.update_pds_details
659                    (p_effective_date           => ld_effective_date
660                    ,p_final_process_date       => trunc(p_final_process_date)
661                    ,p_period_of_service_id     => p_period_of_service_id
662                    ,p_pds_information_category => 'MX'
663                    ,p_pds_information1         =>
664                                          hr_mx_assignment_api.g_leaving_reason
665                    ,p_object_version_number    => l_dummy
666                       );
667 
668                 hr_mx_assignment_api.g_leaving_reason := null;
669 
670                 IF g_debug THEN
671                         hr_utility.set_location(l_proc, 40);
672                 END IF;
673 
674         END IF;
675 
676         IF g_debug THEN
677                 hr_utility.set_location('Leaving: '||l_proc, 50);
678         END IF;
679 
680 --
681 END chk_leav_reason_for_del_emp;
682 
683 BEGIN
684 --
685     g_package  := 'hr_mx_extra_asg_rules.';
686 
687 --
688 END hr_mx_extra_asg_rules;