DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_EXT_CHLG

Source


1 package body ben_ext_chlg as
2 /* $Header: benxchlg.pkb 120.18 2011/02/09 07:09:06 vkodedal noship $ */
3 --------------------------------------------------------------------------------
4 /*
5 +==============================================================================+
6 |			Copyright (c) 1997 Oracle Corporation		       |
7 |			   Redwood Shores, California, USA		       |
8 |			        All rights reserved.			       |
9 +==============================================================================+
10 --
11 Name
12         Benefit Extract Change Log
13 Purpose
14         This package is used to log changes for benefit extract
15 History
16         Date             Who        Version    What?
17         10/28/98         Pdas       115.0      Created.
18         11/04/98         Pdas       115.1      Added change_exists_in_mem
19                                                procedure
20         12/18/98         Pdas       115.2      Modified log_per_chg
21                                                procedure
22         12/18/98         Pdas       115.3      Modified log_per_chg to include
23                                                session date
24         12/21/98         Pdas       115.4      Added History Info.
25         12/29/98         Pdas       115.5      Added prmtr_03..prmtr_07.
26         02/24/99         mhoyes     115.6      Modified log_add_chg passed in
27                                                old business_group_id  to
28                                                ben_ext_chg_evt_api.create_ext_chg_evt
29                                                rather than the new value
30         03/08/99         tmathers   115.7      Changed MON-YYYY to /MM/YYYY.
31         09 Mar 99        G Perry    115.8      IS to AS.
32         23 Mar 99        thayden    115.9      Added procedure log_benefit_chg.
33         12 May 99        isen       115.10     Added new change events
34         26 May 99        thayden    115.11     Remove 'bobby' etc.
35         16 Jun 99        isen       115.12     Added new change events
36         24 Jun 99        isen       115.13     Added new change events, period of service etc.
37         13 Jul 99        isen       115.14     Removed change of primary address logging for
38                                                insert of new primary address record - bug 2485
39         15 Jul 99        isen       115.15     Fixed bug arising out of above change
40         20 Jul 99        isen       115.16     Added log_abs_chg for absence change events
41         09 Aug 99        isen       115.17     Added new and old values
42         29 Sep 99        isen       115.18     Added new change events
43         05 Oct 99        thayden    115.19     Added Reinstate Benefit.
44         12 Oct 99        thayden    115.20     Fixed person type usages bug.
45         19 Oct 99        thayden    115.21     Fixed application bug.
46         09 Nov 99        thayden    115.22     Fix BC date format bug. 1050311
47         25 Jan 99        thayden    115.23     New arguments for TBBC and TBAC.
48         26 Jan 99        thayden    115.24     Added log_dependent_chg.
49         28 Jan 99        thayden    115.25     Old New values for COPR
50         30 Jan 99        thayden    115.26     Added element entries.
51         15 Mar 00        shdas      115.27     fixed bug 1187479. changed log_benefit_chg.
52         15 Mar 00        thayden    115.28     COUN old and new values.
53         20 Mar 00        shdas      115.29     CCFN,CCPA,CCMA,CCGE,CCDB,
54                                                added log_cont_chg
55         07 Nov 00        tilak      115.30     COCN- update primary country is added
56         01 Dec 00        rchase     115.31     Bug 1518466. Make sure the payroll is
57                                                a change and not an add.
58         09 Jan 00        tmathers   115.32     Bug 1530471. Added nvl
59                                                around p_new_rec.date_start.
60                                                in log_cont_chg.
61         24 jul 01        tilak      115.31     email can be more than 200 char ,change logh support
62                                                200 only   so the value is substr to 200
63         26 jul o1        tilak      115.32     COPOS cahnge of periods of service added
64         27 oct 01        tjesumic   115.33     l_full_name lenght was 50 , changed to full name type
65                                                bug : 2070576 fixed
66         06 feb 02        tjesdumic  115.36     delete EE entry fixed by changing UPDATE to DELETE
67         11 mar 02        tjesumic   115.37     UTF8 changes , variable size set dynomically
68         14 Mar 02        rpillay    115.38     UTF Changes Bug 2254683
69         23 May 02        tjesumic   115.39     change log for per_information1, per_informatiuon10
70                                                uses_tobacco_flag added
71         30 may 02        tjesumic   115.40     log_per_pay procedured added for base salary change
72                                                log_school_chg procedure added
73                                                log_prem_mo_chg proecude added
74                                                Address are substring to 600  fro bug 2383576
75        31 may 02         tjesumic   115.41     Curosr c_old_sal cahnged ,date param added
76 
77        13-Aug 02         glingapp   115.42     Bug 1554477 Modified code to trigger extract change event when
78         				       home phone, fax, work phone, mobile is entered deleted or updated,
79         				       date_to for phones is entered, when working hours of assignment is
80                                                 updated
81        15-Jul-03         tjesumic   115.43    for COTR the effective date is passed instead of sysdate to
82                                               change event effective date
83        18-Jul-03         tjesumic   115.44    for COTR the actual termn date is passed instead of sysdate
84                                               Since the changes effected from termination date, termn date
85                                               became effective date for the changes
86        09-Jan-04         rpgupta   115.45     Bug 3361237 Do not pass date to find business group.
87                                               A person can only have one business group. Hence its ok
88                                               if we get from the first record returned
89        10-Jan-03         tjesumic  115.46     coen added for employee number
90        09-Jan-04         rpgupta   115.47     Make change eff dt for delete phones as
91                                               greatest(nvl(dt_to, dt_from), sysdate)
92        26-Jan-04         vjhanak   115.48     Changes made to track the creation of secondary
93                                               employeee assignment for NL.
94        24-Feb-05         vborkar   115.49     In calls to ben_ext_chg_evt_api.create_ext_chg_evt,
95                                               whenever person's full name was getting truncated
96 					                          to 200 characters, increased it to 240 characters.
97        24-mar-05         tjesumic  115.50     position added in log
98        11-Aug-05         rgajula   115.51     Bug 4539732  Changed the date type of l_chg_eff_dt to
99                                               date table type in procedure log_pos_chg.
100        30-Aug-05         tjesumic  115.52     log_per_chg overload procedure created,
101                                               that will be called from SSHR api
102        26-Sep-05         tjesumic  115.53     ethnick orign lookup values stored for old value and new values
103                                               insted of the codes
104        14-Oct-05         vjhanak   115.54     Changes made to track the change to ASG Softcoded KFF id
105        28-Oct-05         rgajula   115.55     Bug 4699556 Made changes in the log_add_chg where previously when APA
106                                               and AMA both were triggered at the same time only APA was logged .
107                                               Chaged the code so as to log the events independent of each other.
108        31-Oct-05         rbingi    115.55     4705814, passing person_type ( Initially passed NULLs )
109                                               to Old, New Values for 'A%PTU' change event
110        27-Dec-05         rtagarra  115.57     Function "HR_GENERAL.DECODE_LOOKUP" has been called for
111                                               bug#4699913 so that meaning ll be
112 					      populated instead of lookup code for Assignment Category.
113        01-Sep-06         tjesumic  115.59     new change event added to log changes of contact of any person type
114                                               CCNFN,CCNDB,CCNDD,CCNSS,CCNGE,CCNRE,CCNPC,CCNPA,CCNMA
115        14-Sep-06         tjesumic  115.60     log_per_pay_chg's  cursor c_person is opend withing the changes
116        14-Nov-06         tjesumic   115.62   per_pay_proposal trigger moved to api (pepyprhi.pkb 115.60)
117                                              the global record changed to have all the column of the table
118                                              for future requirements.
119                                              Rqd: pepyprhi.pkb,115.60 benxchglg.pkb 115.28,benxbstg.sql 115.3
120        14-Nov-06         tjesumic  115.63    approved status for old record is fixed
121        09-Jan-07         tjesumic  115.64    the lookup code COPMPRM changed to CCOPMPRM
122        09-Jan-07         tjesumic  115.65    the lookup code COPMPRM changed to CCOPMPRM
123        08-Jul-08         pvelugul  115.66    Modified for 6517369.
124        24-Nov-09         vkodedal  115.67    Overloaded log_asg_chg, called from core HR bug#9092938
125        09-Feb-11         vkodedal  115.68    commented second cwh logging bug#11711776
126 */
127 --
128 
129 function change_exists_in_db
130          (p_person_id     in    number
131          ,p_chg_evt_cd    in    varchar2
132          ,p_chg_eff_dt    in    date
133          ) return boolean is
134 --
135   cursor get_change is
136   SELECT null
137   FROM   ben_ext_chg_evt_log a
138   WHERE  a.person_id = p_person_id
139   AND    a.chg_evt_cd = p_chg_evt_cd
140   AND    trunc(a.chg_eff_dt) = trunc(p_chg_eff_dt);
141 --
142   l_proc          varchar2(80) := 'ben_ext_chlg.change_exists_in_db';
143   l_dummy         varchar2(30);
144   l_return        boolean;
145 --
146 begin
147 --
148   hr_utility.set_location('Entering:'|| l_proc, 10);
149 --
150   open get_change;
151   fetch get_change into l_dummy;
152 --
153   if get_change%found then
154     l_return := TRUE;
155   else
156     l_return := FALSE;
157   end if;
158 --
159   close get_change;
160 --
161   return (l_return);
162 --
163   hr_utility.set_location('Exiting:'|| l_proc, 99);
164 --
165 end change_exists_in_db;
166 --
167 --
168 function change_exists_in_mem
169          (p_chg_evt_tab   in    g_char_tab_type
170          ,p_chg_eff_tab   in    g_date_tab_type
171          ,p_chg_evt_cd    in    varchar2
172          ,p_chg_eff_dt    in    date
173          ) return boolean is
174 --
175   l_proc          varchar2(80) := 'ben_ext_chlg.change_exists_in_mem';
176   l_counter       number := 0;
177   l_return        boolean := FALSE;
178 --
179 begin
180 --
181   hr_utility.set_location('Entering:'|| l_proc, 10);
182 --
183   for l_counter in 1..p_chg_evt_tab.count loop
184     if p_chg_evt_tab(l_counter) = p_chg_evt_cd
185        and p_chg_eff_tab(l_counter) = p_chg_eff_dt then
186       l_return := TRUE;
187       exit;
188     end if;
189   end loop;
190 --
191   return (l_return);
192 --
193   hr_utility.set_location('Exiting:'|| l_proc, 99);
194 --
195 end change_exists_in_mem;
196 --
197 ------------------------------------------------------------------------
198 function change_event_is_enabled
199          (p_chg_evt_cd     in    varchar2
200          ,p_effective_date in    date
201          ) return boolean is
202 --
203   cursor c_lookup_is_enabled is
204   SELECT null
205   FROM   hr_lookups h
206   WHERE  h.lookup_type = 'BEN_EXT_CHG_EVT'
207   AND    h.lookup_code = p_chg_evt_cd
208   AND    h.enabled_flag = 'Y'
209   AND    p_effective_date between nvl(start_date_active,p_effective_date)
210           and nvl(end_date_active,p_effective_date);
211 --
212   l_proc          varchar2(80) := 'ben_ext_chlg.change_event_is_enabled';
213   l_dummy         varchar2(30);
214   l_return        boolean;
215 --
216 begin
217 --
218   hr_utility.set_location('Entering:'|| l_proc, 10);
219 --
220   open c_lookup_is_enabled;
221   fetch c_lookup_is_enabled into l_dummy;
222 --
223   if c_lookup_is_enabled%found then
224     l_return := TRUE;
225   else
226     l_return := FALSE;
227   end if;
228 --
229   close c_lookup_is_enabled;
230 --
231   return (l_return);
232 --
233   hr_utility.set_location('Exiting:'|| l_proc, 99);
234 --
235 end change_event_is_enabled;
236 --
237 
238 
239 
240 --- this is a overlaod procedure to call from SSHR4
241  procedure log_per_chg
242   (p_event        in   varchar2
243   ,p_old_rec      in   per_per_shd.g_rec_type
244   ,p_new_rec      in   per_per_shd.g_rec_type
245 --  ,p_mode         in   varchar2
246   )is
247 
248   l_old_rec           ben_ext_chlg.g_per_rec_type;
249   l_new_rec           ben_ext_chlg.g_per_rec_type;
250   l_event             varchar2(10) ;
251 --
252   l_proc               varchar2(100) := 'ben_ext_chlg.log_per_chg';
253 begin
254 
255   hr_utility.set_location('Entering:'|| l_proc, 05);
256 
257 
258   l_old_rec.national_identifier := p_old_rec.national_identifier;
259   l_old_rec.full_name := p_old_rec.full_name;
260   l_old_rec.last_name := p_old_rec.last_name;
261   l_old_rec.first_name := p_old_rec.first_name;
262   l_old_rec.middle_names := p_old_rec.middle_names;
263   l_old_rec.title := p_old_rec.title;
264   l_old_rec.pre_name_adjunct := p_old_rec.pre_name_adjunct;
265   l_old_rec.suffix := p_old_rec.suffix;
266   l_old_rec.known_as := p_old_rec.known_as;
267   l_old_rec.previous_last_name := p_old_rec.previous_last_name;
268   l_old_rec.date_of_birth := p_old_rec.date_of_birth;
269   l_old_rec.sex := p_old_rec.sex;
270   l_old_rec.marital_status := p_old_rec.marital_status;
271   l_old_rec.person_id := p_old_rec.person_id;
272   l_old_rec.person_type_id := p_old_rec.person_type_id;
273   l_old_rec.business_group_id := p_old_rec.business_group_id;
274   l_old_rec.registered_disabled_flag := p_old_rec.registered_disabled_flag;
275   l_old_rec.benefit_group_id := p_old_rec.benefit_group_id;
276   l_old_rec.student_status := p_old_rec.student_status;
277   l_old_rec.date_of_death := p_old_rec.date_of_death;
278   l_old_rec.date_employee_data_verified := p_old_rec.date_employee_data_verified;
279   l_old_rec.effective_start_date :=p_old_rec.effective_start_date;
280   l_old_rec.effective_end_date :=p_old_rec.effective_end_date;
281   l_old_rec.attribute1 :=p_old_rec.attribute1;
282   l_old_rec.attribute2 :=p_old_rec.attribute2;
283   l_old_rec.attribute3 :=p_old_rec.attribute3;
284   l_old_rec.attribute4 :=p_old_rec.attribute4;
285   l_old_rec.attribute5 :=p_old_rec.attribute5;
286   l_old_rec.attribute6 :=p_old_rec.attribute6;
287   l_old_rec.attribute7 :=p_old_rec.attribute7;
288   l_old_rec.attribute8 :=p_old_rec.attribute8;
289   l_old_rec.attribute9 :=p_old_rec.attribute9;
290   l_old_rec.attribute10 :=p_old_rec.attribute10;
291   l_old_rec.email_address :=p_old_rec.email_address;
292   l_old_rec.per_information1 :=p_old_rec.per_information1;
293   l_old_rec.per_information2 :=p_old_rec.per_information2;
294   l_old_rec.per_information3 :=p_old_rec.per_information3;
295   l_old_rec.per_information4 :=p_old_rec.per_information4;
296   l_old_rec.attribute5 :=p_old_rec.attribute5;
297   l_old_rec.attribute6 :=p_old_rec.attribute6;
298   l_old_rec.attribute7 :=p_old_rec.attribute7;
299   l_old_rec.attribute8 :=p_old_rec.attribute8;
300   l_old_rec.attribute9 :=p_old_rec.attribute9;
301   l_old_rec.attribute10 :=p_old_rec.attribute10;
302   l_old_rec.email_address :=p_old_rec.email_address;
303   l_old_rec.per_information1 :=p_old_rec.per_information1;
304   l_old_rec.per_information2 :=p_old_rec.per_information2;
305   l_old_rec.per_information3 :=p_old_rec.per_information3;
306   l_old_rec.per_information4 :=p_old_rec.per_information4;
307   l_old_rec.per_information5 :=p_old_rec.per_information5;
308   l_old_rec.per_information6 :=p_old_rec.per_information6;
309   l_old_rec.per_information7 :=p_old_rec.per_information7;
310   l_old_rec.per_information8 :=p_old_rec.per_information8;
311   l_old_rec.per_information9 :=p_old_rec.per_information9;
312   l_old_rec.per_information10 :=p_old_rec.per_information10;
313   l_old_rec.per_information11 :=p_old_rec.per_information11;
314   l_old_rec.per_information12 :=p_old_rec.per_information12;
315   l_old_rec.per_information13 :=p_old_rec.per_information13;
316   l_old_rec.per_information14 :=p_old_rec.per_information14;
317   l_old_rec.per_information15 :=p_old_rec.per_information15;
318   l_old_rec.per_information16 :=p_old_rec.per_information16;
319   l_old_rec.per_information17 :=p_old_rec.per_information17;
320   l_old_rec.per_information18 :=p_old_rec.per_information18;
321   l_old_rec.per_information19 :=p_old_rec.per_information19;
322   l_old_rec.per_information20 :=p_old_rec.per_information20;
323   l_old_rec.per_information21 :=p_old_rec.per_information21;
324   l_old_rec.per_information22 :=p_old_rec.per_information22;
325   l_old_rec.per_information23 :=p_old_rec.per_information23;
326   l_old_rec.per_information24 :=p_old_rec.per_information24;
327   l_old_rec.per_information25 :=p_old_rec.per_information25;
328   l_old_rec.per_information26 :=p_old_rec.per_information26;
329   l_old_rec.per_information27 :=p_old_rec.per_information27;
330   l_old_rec.per_information28 :=p_old_rec.per_information28;
331   l_old_rec.per_information29 :=p_old_rec.per_information29;
332   l_old_rec.per_information30 :=p_old_rec.per_information30;
333   l_old_rec.correspondence_language :=p_old_rec.correspondence_language;
334   l_old_rec.uses_tobacco_flag :=p_old_rec.uses_tobacco_flag;
335   l_old_rec.employee_number   :=p_old_rec.employee_number;
336 --
337   l_new_rec.national_identifier := p_new_rec.national_identifier;
338   l_new_rec.full_name := p_new_rec.full_name;
339   l_new_rec.last_name := p_new_rec.last_name;
340   l_new_rec.first_name := p_new_rec.first_name;
341   l_new_rec.middle_names := p_new_rec.middle_names;
342   l_new_rec.title := p_new_rec.title;
343   l_new_rec.pre_name_adjunct := p_new_rec.pre_name_adjunct;
344   l_new_rec.suffix := p_new_rec.suffix;
345   l_new_rec.known_as := p_new_rec.known_as;
346   l_new_rec.previous_last_name := p_new_rec.previous_last_name;
347   l_new_rec.date_of_birth := p_new_rec.date_of_birth;
348   l_new_rec.sex := p_new_rec.sex;
349   l_new_rec.marital_status := p_new_rec.marital_status;
350   l_new_rec.person_id := p_new_rec.person_id;
351   l_new_rec.person_type_id := p_new_rec.person_type_id;
352   l_new_rec.business_group_id := p_new_rec.business_group_id;
353   l_new_rec.registered_disabled_flag := p_new_rec.registered_disabled_flag;
354   l_new_rec.benefit_group_id := p_new_rec.benefit_group_id;
355   l_new_rec.student_status := p_new_rec.student_status;
356   l_new_rec.date_of_death := p_new_rec.date_of_death;
357   l_new_rec.date_employee_data_verified := p_new_rec.date_employee_data_verified;
358   l_new_rec.effective_start_date :=p_new_rec.effective_start_date;
359   l_new_rec.effective_end_date :=p_new_rec.effective_end_date;
360   l_new_rec.attribute1 :=p_new_rec.attribute1;
361   l_new_rec.attribute2 :=p_new_rec.attribute2;
362   l_new_rec.attribute3 :=p_new_rec.attribute3;
363   l_new_rec.attribute4 :=p_new_rec.attribute4;
364   l_new_rec.attribute5 :=p_new_rec.attribute5;
365   l_new_rec.attribute6 :=p_new_rec.attribute6;
366   l_new_rec.attribute7 :=p_new_rec.attribute7;
367   l_new_rec.attribute8 :=p_new_rec.attribute8;
368   l_new_rec.attribute9 :=p_new_rec.attribute9;
369   l_new_rec.attribute10 :=p_new_rec.attribute10;
370   l_new_rec.email_address :=p_new_rec.email_address;
371   l_new_rec.per_information1 :=p_new_rec.per_information1;
372   l_new_rec.per_information2 :=p_new_rec.per_information2;
373   l_new_rec.per_information3 :=p_new_rec.per_information3;
374   l_new_rec.per_information4 :=p_new_rec.per_information4;
375   l_new_rec.per_information5 :=p_new_rec.per_information5;
376   l_new_rec.per_information6 :=p_new_rec.per_information6;
377   l_new_rec.per_information7 :=p_new_rec.per_information7;
378   l_new_rec.per_information8 :=p_new_rec.per_information8;
379   l_new_rec.per_information9 :=p_new_rec.per_information9;
380   l_new_rec.per_information10 :=p_new_rec.per_information10;
381   l_new_rec.per_information11 :=p_new_rec.per_information11;
382   l_new_rec.per_information12 :=p_new_rec.per_information12;
383   l_new_rec.per_information13 :=p_new_rec.per_information13;
384   l_new_rec.per_information14 :=p_new_rec.per_information14;
385   l_new_rec.per_information15 :=p_new_rec.per_information15;
386   l_new_rec.per_information16 :=p_new_rec.per_information16;
387   l_new_rec.per_information17 :=p_new_rec.per_information17;
388   l_new_rec.per_information18 :=p_new_rec.per_information18;
389   l_new_rec.per_information19 :=p_new_rec.per_information19;
390   l_new_rec.per_information20 :=p_new_rec.per_information20;
391   l_new_rec.per_information21 :=p_new_rec.per_information21;
392   l_new_rec.per_information22 :=p_new_rec.per_information22;
393   l_new_rec.per_information23 :=p_new_rec.per_information23;
394   l_new_rec.per_information24 :=p_new_rec.per_information24;
395   l_new_rec.per_information25 :=p_new_rec.per_information25;
396   l_new_rec.per_information26 :=p_new_rec.per_information26;
397   l_new_rec.per_information27 :=p_new_rec.per_information27;
398   l_new_rec.per_information28 :=p_new_rec.per_information28;
399   l_new_rec.per_information29 :=p_new_rec.per_information29;
400   l_new_rec.per_information30 :=p_new_rec.per_information30;
401   l_new_rec.correspondence_language :=p_new_rec.correspondence_language;
402   l_new_rec.uses_tobacco_flag :=p_new_rec.uses_tobacco_flag;
403   l_new_rec.employee_number   :=p_new_rec.employee_number;
404 
405   if p_new_rec.effective_start_date = p_old_rec.effective_start_date then
406     l_new_rec.update_mode := 'CORRECTION';
407     l_old_rec.update_mode := 'CORRECTION';
408   else
409     l_new_rec.update_mode := 'UPDATE';
410     l_old_rec.update_mode := 'UPDATE';
411   end if;
412 
413   l_event  := nvl(p_event ,'UPDATE') ;
414 
415   log_per_chg
416   (p_event   => p_event
417   ,p_old_rec => l_old_rec
418   ,p_new_rec => l_new_rec
419   );
420   hr_utility.set_location('Exiting:'|| l_proc, 99);
421 end ;
422 
423 ------------------------------------------------------------------------------------------
424 procedure log_per_chg
425           (p_event     in  varchar2
426           ,p_old_rec   in  g_per_rec_type
427           ,p_new_rec   in  g_per_rec_type
428           ) is
429 --
430   l_chg_evt_tab           g_char_tab_type;
431   l_cont_chg_evt_tab      g_char_tab_type;
432   l_prmtr_01_tab          g_char_tab_type;
433   l_prmtr_02_tab          g_char_tab_type;
434   l_prmtr_03_tab          g_char_tab_type;
435   l_prmtr_04_tab          g_char_tab_type;
436   l_prmtr_05_tab          g_char_tab_type;
437   l_prmtr_06_tab          g_char_tab_type;
438   l_prmtr_07_tab          g_char_tab_type;
439   l_old_val1              g_old_val;
440   l_old_val2              g_old_val;
441   l_old_val3              g_old_val;
442   l_old_val4              g_old_val;
443   l_old_val5              g_old_val;
444   l_old_val6              g_old_val;
445   l_new_val1              g_new_val;
446   l_new_val2              g_new_val;
447   l_new_val3              g_new_val;
448   l_new_val4              g_new_val;
449   l_new_val5              g_new_val;
450   l_new_val6              g_new_val;
451   l_tab_counter           binary_integer := 0;
452   l_ini_tab_counter       binary_integer ;
453   l_chg_eff_dt            date;
454   l_count                 number;
455   l_ext_chg_evt_log_id    number;
456   l_object_version_number number;
457 --
458   cursor c_lookup_value
459     (p_lookup_type hr_lookups.lookup_type%type
460     ,p_lookup_code hr_lookups.lookup_code%type
461     )
462   is
463   select meaning
464   from hr_lookups hl
465   where hl.lookup_type = p_lookup_type
466   and hl.lookup_code = p_lookup_code;
467 
468   cursor c_benefits_group(p_benfts_grp_id ben_benfts_grp.benfts_grp_id%type)
469   is
470   select name
471   from ben_benfts_grp bbg
472   where bbg.benfts_grp_id = p_benfts_grp_id;
473 --
474   cursor c_relationship(p_person_id number) is
475   SELECT pcr.contact_relationship_id,pcr.person_id
476   FROM   per_contact_relationships pcr,
477          hr_lookups hl
478   WHERE  pcr.contact_person_id = p_person_id
479   AND    pcr.contact_type = hl.lookup_code
480   AND    hl.lookup_type = 'CONTACT';
481   --
482   cursor c_person_type(p_person_type_id number) is
483   select ppt.system_person_type
484   from   per_person_types ppt
485   where  ppt.person_type_id = p_person_type_id;
486 
487   -- Get all the contact relationship person
488   cursor c_con_relationship(p_person_id number , p_date date ) is
489   SELECT pcr.contact_relationship_id, pcr.person_id,pcr.contact_type
490   FROM   per_contact_relationships pcr
491   WHERE  pcr.contact_person_id = p_person_id
492   AND    pcr.personal_flag = 'Y'
493   and    p_date between  pcr.date_start and nvl(pcr.date_end, p_date)
494    ;
495 
496 
497 
498 
499   l_old_marital_status        hr_lookups.meaning%type ;
500   l_new_marital_status        hr_lookups.meaning%type ;
501   l_old_sex                   hr_lookups.meaning%type ;
502   l_new_sex                   hr_lookups.meaning%type ;
503   l_old_disability_status     hr_lookups.meaning%type ;
504   l_new_disability_status     hr_lookups.meaning%type ;
505   l_old_benefits_group        ben_benfts_grp.name%type;
506   l_new_benefits_group        ben_benfts_grp.name%type;
507   l_old_student_status        hr_lookups.meaning%type ;
508   l_new_student_status        hr_lookups.meaning%type ;
509   l_old_ethnic_group          hr_lookups.meaning%type ;
510   l_new_ethnic_group          hr_lookups.meaning%type ;
511   l_relationship              per_all_people_f.person_id%type;
512   l_contact                   per_contact_relationships.contact_relationship_id%type;
513   l_person_type               per_person_types.system_person_type%type ;
514 --
515   l_proc               varchar2(100) := 'ben_ext_chlg.log_per_chg';
516 --
517 begin
518 --
519   hr_utility.set_location('Entering:'|| l_proc, 10);
520 --
521   if p_event = 'UPDATE' then
522 --
523     if nvl(p_old_rec.national_identifier, '000-00-0000')
524         <> nvl(p_new_rec.national_identifier, '000-00-0000') then
525       l_tab_counter := l_tab_counter + 1;
526       l_chg_evt_tab(l_tab_counter) := 'COSS';
527       l_prmtr_01_tab(l_tab_counter) := null;
528       l_prmtr_02_tab(l_tab_counter) := null;
529       l_prmtr_03_tab(l_tab_counter) := null;
530       l_prmtr_04_tab(l_tab_counter) := null;
531       l_prmtr_05_tab(l_tab_counter) := null;
532       l_prmtr_06_tab(l_tab_counter) := null;
533       l_prmtr_07_tab(l_tab_counter) := null;
534       l_old_val1(l_tab_counter) := p_old_rec.national_identifier;
535       l_new_val1(l_tab_counter) := p_new_rec.national_identifier;
536       l_old_val2(l_tab_counter) := null;
537       l_old_val3(l_tab_counter) := null;
538       l_old_val4(l_tab_counter) := null;
539       l_old_val5(l_tab_counter) := null;
540       l_old_val6(l_tab_counter) := null;
541       l_new_val2(l_tab_counter) := null;
542       l_new_val3(l_tab_counter) := null;
543       l_new_val4(l_tab_counter) := null;
544       l_new_val5(l_tab_counter) := null;
545       l_new_val6(l_tab_counter) := null;
546     end if;
547     if nvl(p_old_rec.full_name, '$$$$$&&&')
548         <> nvl(p_new_rec.full_name, '$$$$$&&&') then
549       l_tab_counter := l_tab_counter + 1;
550       l_chg_evt_tab(l_tab_counter) := 'COUN';
551       l_prmtr_01_tab(l_tab_counter) := null;
552       l_prmtr_02_tab(l_tab_counter) := null;
553       l_prmtr_03_tab(l_tab_counter) := null;
554       l_prmtr_04_tab(l_tab_counter) := null;
555       l_prmtr_05_tab(l_tab_counter) := null;
556       l_prmtr_06_tab(l_tab_counter) := null;
557       l_prmtr_07_tab(l_tab_counter) := null;
558       l_old_val1(l_tab_counter) := substr(p_old_rec.full_name,1,240);
559       l_old_val2(l_tab_counter) := p_old_rec.title;
560       l_old_val3(l_tab_counter) := p_old_rec.first_name;
561       l_old_val4(l_tab_counter) := p_old_rec.middle_names;
562       l_old_val5(l_tab_counter) := p_old_rec.last_name;
563       l_old_val6(l_tab_counter) := p_old_rec.suffix;
564       l_new_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
565       l_new_val2(l_tab_counter) := p_new_rec.title;
566       l_new_val3(l_tab_counter) := p_new_rec.first_name;
567       l_new_val4(l_tab_counter) := p_new_rec.middle_names;
568       l_new_val5(l_tab_counter) := p_new_rec.last_name;
569       l_new_val6(l_tab_counter) := p_new_rec.suffix;
570     end if;
571     if nvl(p_old_rec.first_name, '$$$$$&&&')
572         <> nvl(p_new_rec.first_name, '$$$$$&&&') then
573       l_tab_counter := l_tab_counter + 1;
574       l_chg_evt_tab(l_tab_counter) := 'COFN';
575       l_prmtr_01_tab(l_tab_counter) := null;
576       l_prmtr_02_tab(l_tab_counter) := null;
577       l_prmtr_03_tab(l_tab_counter) := null;
578       l_prmtr_04_tab(l_tab_counter) := null;
579       l_prmtr_05_tab(l_tab_counter) := null;
580       l_prmtr_06_tab(l_tab_counter) := null;
581       l_prmtr_07_tab(l_tab_counter) := null;
582       l_old_val1(l_tab_counter) := p_old_rec.first_name;
583       l_new_val1(l_tab_counter) := p_new_rec.first_name;
584       l_old_val2(l_tab_counter) := null;
585       l_old_val3(l_tab_counter) := null;
586       l_old_val4(l_tab_counter) := null;
587       l_old_val5(l_tab_counter) := null;
588       l_old_val6(l_tab_counter) := null;
589       l_new_val2(l_tab_counter) := null;
590       l_new_val3(l_tab_counter) := null;
591       l_new_val4(l_tab_counter) := null;
592       l_new_val5(l_tab_counter) := null;
593       l_new_val6(l_tab_counter) := null;
594     end if;
595     if nvl(p_old_rec.last_name, '$$$$$&&&')
596         <> nvl(p_new_rec.last_name, '$$$$$&&&') then
597       l_tab_counter := l_tab_counter + 1;
598       l_chg_evt_tab(l_tab_counter) := 'COLN';
599       l_prmtr_01_tab(l_tab_counter) := null;
600       l_prmtr_02_tab(l_tab_counter) := null;
601       l_prmtr_03_tab(l_tab_counter) := null;
602       l_prmtr_04_tab(l_tab_counter) := null;
603       l_prmtr_05_tab(l_tab_counter) := null;
604       l_prmtr_06_tab(l_tab_counter) := null;
605       l_prmtr_07_tab(l_tab_counter) := null;
606       l_old_val1(l_tab_counter) := p_old_rec.last_name;
607       l_new_val1(l_tab_counter) := p_new_rec.last_name;
608       l_old_val2(l_tab_counter) := null;
609       l_old_val3(l_tab_counter) := null;
610       l_old_val4(l_tab_counter) := null;
611       l_old_val5(l_tab_counter) := null;
612       l_old_val6(l_tab_counter) := null;
613       l_new_val2(l_tab_counter) := null;
614       l_new_val3(l_tab_counter) := null;
615       l_new_val4(l_tab_counter) := null;
616       l_new_val5(l_tab_counter) := null;
617       l_new_val6(l_tab_counter) := null;
618     end if;
619     if nvl(p_old_rec.middle_names, '$$$$$&&&')
620         <> nvl(p_new_rec.middle_names, '$$$$$&&&') then
621       l_tab_counter := l_tab_counter + 1;
622       l_chg_evt_tab(l_tab_counter) := 'COMN';
623       l_prmtr_01_tab(l_tab_counter) := null;
624       l_prmtr_02_tab(l_tab_counter) := null;
625       l_prmtr_03_tab(l_tab_counter) := null;
626       l_prmtr_04_tab(l_tab_counter) := null;
627       l_prmtr_05_tab(l_tab_counter) := null;
628       l_prmtr_06_tab(l_tab_counter) := null;
629       l_prmtr_07_tab(l_tab_counter) := null;
630       l_old_val1(l_tab_counter) := p_old_rec.middle_names;
631       l_new_val1(l_tab_counter) := p_new_rec.middle_names;
632       l_old_val2(l_tab_counter) := null;
633       l_old_val3(l_tab_counter) := null;
634       l_old_val4(l_tab_counter) := null;
635       l_old_val5(l_tab_counter) := null;
636       l_old_val6(l_tab_counter) := null;
637       l_new_val2(l_tab_counter) := null;
638       l_new_val3(l_tab_counter) := null;
639       l_new_val4(l_tab_counter) := null;
640       l_new_val5(l_tab_counter) := null;
641       l_new_val6(l_tab_counter) := null;
642     end if;
643     if nvl(p_old_rec.title, '$$$$$&&&')
644         <> nvl(p_new_rec.title, '$$$$$&&&') then
645       l_tab_counter := l_tab_counter + 1;
646       l_chg_evt_tab(l_tab_counter) := 'CONT';
647       l_prmtr_01_tab(l_tab_counter) := null;
648       l_prmtr_02_tab(l_tab_counter) := null;
649       l_prmtr_03_tab(l_tab_counter) := null;
650       l_prmtr_04_tab(l_tab_counter) := null;
651       l_prmtr_05_tab(l_tab_counter) := null;
652       l_prmtr_06_tab(l_tab_counter) := null;
653       l_prmtr_07_tab(l_tab_counter) := null;
654       l_old_val1(l_tab_counter) := p_old_rec.title;
655       l_new_val1(l_tab_counter) := p_new_rec.title;
656       l_old_val2(l_tab_counter) := null;
657       l_old_val3(l_tab_counter) := null;
658       l_old_val4(l_tab_counter) := null;
659       l_old_val5(l_tab_counter) := null;
660       l_old_val6(l_tab_counter) := null;
661       l_new_val2(l_tab_counter) := null;
662       l_new_val3(l_tab_counter) := null;
663       l_new_val4(l_tab_counter) := null;
664       l_new_val5(l_tab_counter) := null;
665       l_new_val6(l_tab_counter) := null;
666     end if;
667     if nvl(p_old_rec.suffix, '$$$$$&&&')
668         <> nvl(p_new_rec.suffix, '$$$$$&&&') then
669       l_tab_counter := l_tab_counter + 1;
670       l_chg_evt_tab(l_tab_counter) := 'CONS';
671       l_prmtr_01_tab(l_tab_counter) := null;
672       l_prmtr_02_tab(l_tab_counter) := null;
673       l_prmtr_03_tab(l_tab_counter) := null;
674       l_prmtr_04_tab(l_tab_counter) := null;
675       l_prmtr_05_tab(l_tab_counter) := null;
676       l_prmtr_06_tab(l_tab_counter) := null;
677       l_prmtr_07_tab(l_tab_counter) := null;
678       l_old_val1(l_tab_counter) := p_old_rec.suffix;
679       l_new_val1(l_tab_counter) := p_new_rec.suffix;
680       l_old_val2(l_tab_counter) := null;
681       l_old_val3(l_tab_counter) := null;
682       l_old_val4(l_tab_counter) := null;
683       l_old_val5(l_tab_counter) := null;
684       l_old_val6(l_tab_counter) := null;
685       l_new_val2(l_tab_counter) := null;
686       l_new_val3(l_tab_counter) := null;
687       l_new_val4(l_tab_counter) := null;
688       l_new_val5(l_tab_counter) := null;
689       l_new_val6(l_tab_counter) := null;
690     end if;
691     if nvl(p_old_rec.pre_name_adjunct, '$$$$$&&&')
692         <> nvl(p_new_rec.pre_name_adjunct, '$$$$$&&&') then
693       l_tab_counter := l_tab_counter + 1;
694       l_chg_evt_tab(l_tab_counter) := 'CONA';
695       l_prmtr_01_tab(l_tab_counter) := null;
696       l_prmtr_02_tab(l_tab_counter) := null;
697       l_prmtr_03_tab(l_tab_counter) := null;
698       l_prmtr_04_tab(l_tab_counter) := null;
699       l_prmtr_05_tab(l_tab_counter) := null;
700       l_prmtr_06_tab(l_tab_counter) := null;
701       l_prmtr_07_tab(l_tab_counter) := null;
702       l_old_val1(l_tab_counter) := p_old_rec.pre_name_adjunct;
703       l_new_val1(l_tab_counter) := p_new_rec.pre_name_adjunct;
704       l_old_val2(l_tab_counter) := null;
705       l_old_val3(l_tab_counter) := null;
706       l_old_val4(l_tab_counter) := null;
707       l_old_val5(l_tab_counter) := null;
708       l_old_val6(l_tab_counter) := null;
709       l_new_val2(l_tab_counter) := null;
710       l_new_val3(l_tab_counter) := null;
711       l_new_val4(l_tab_counter) := null;
712       l_new_val5(l_tab_counter) := null;
713       l_new_val6(l_tab_counter) := null;
714     end if;
715     if nvl(p_old_rec.known_as, '$$$$$&&&')
716         <> nvl(p_new_rec.known_as, '$$$$$&&&') then
717       l_tab_counter := l_tab_counter + 1;
718       l_chg_evt_tab(l_tab_counter) := 'COKA';
719       l_prmtr_01_tab(l_tab_counter) := null;
720       l_prmtr_02_tab(l_tab_counter) := null;
721       l_prmtr_03_tab(l_tab_counter) := null;
722       l_prmtr_04_tab(l_tab_counter) := null;
723       l_prmtr_05_tab(l_tab_counter) := null;
724       l_prmtr_06_tab(l_tab_counter) := null;
725       l_prmtr_07_tab(l_tab_counter) := null;
726       l_old_val1(l_tab_counter) := p_old_rec.known_as;
727       l_new_val1(l_tab_counter) := p_new_rec.known_as;
728       l_old_val2(l_tab_counter) := null;
729       l_old_val3(l_tab_counter) := null;
730       l_old_val4(l_tab_counter) := null;
731       l_old_val5(l_tab_counter) := null;
732       l_old_val6(l_tab_counter) := null;
733       l_new_val2(l_tab_counter) := null;
734       l_new_val3(l_tab_counter) := null;
735       l_new_val4(l_tab_counter) := null;
736       l_new_val5(l_tab_counter) := null;
737       l_new_val6(l_tab_counter) := null;
738     end if;
739     if nvl(p_old_rec.previous_last_name, '$$$$$&&&')
740         <> nvl(p_new_rec.previous_last_name, '$$$$$&&&') then
741       l_tab_counter := l_tab_counter + 1;
742       l_chg_evt_tab(l_tab_counter) := 'COPL';
743       l_prmtr_01_tab(l_tab_counter) := null;
744       l_prmtr_02_tab(l_tab_counter) := null;
745       l_prmtr_03_tab(l_tab_counter) := null;
746       l_prmtr_04_tab(l_tab_counter) := null;
747       l_prmtr_05_tab(l_tab_counter) := null;
748       l_prmtr_06_tab(l_tab_counter) := null;
749       l_prmtr_07_tab(l_tab_counter) := null;
750       l_old_val1(l_tab_counter) := p_old_rec.previous_last_name;
751       l_new_val1(l_tab_counter) := p_new_rec.previous_last_name;
752       l_old_val2(l_tab_counter) := null;
753       l_old_val3(l_tab_counter) := null;
754       l_old_val4(l_tab_counter) := null;
755       l_old_val5(l_tab_counter) := null;
756       l_old_val6(l_tab_counter) := null;
757       l_new_val2(l_tab_counter) := null;
758       l_new_val3(l_tab_counter) := null;
759       l_new_val4(l_tab_counter) := null;
760       l_new_val5(l_tab_counter) := null;
761       l_new_val6(l_tab_counter) := null;
762     end if;
763     if nvl(p_old_rec.date_of_birth, to_date('01/01/0001', 'dd/mm/yyyy'))
764         <> nvl(p_new_rec.date_of_birth, to_date('01/01/0001', 'dd/mm/yyyy')) then
765       l_tab_counter := l_tab_counter + 1;
766       l_chg_evt_tab(l_tab_counter) := 'CODB';
767       l_prmtr_01_tab(l_tab_counter) := null;
768       l_prmtr_02_tab(l_tab_counter) := null;
769       l_prmtr_03_tab(l_tab_counter) := null;
770       l_prmtr_04_tab(l_tab_counter) := null;
771       l_prmtr_05_tab(l_tab_counter) := null;
772       l_prmtr_06_tab(l_tab_counter) := null;
773       l_prmtr_07_tab(l_tab_counter) := null;
774       l_old_val1(l_tab_counter) := to_char(p_old_rec.date_of_birth, 'mm/dd/yyyy');
775       l_new_val1(l_tab_counter) := to_char(p_new_rec.date_of_birth, 'mm/dd/yyyy');
776       l_old_val2(l_tab_counter) := null;
777       l_old_val3(l_tab_counter) := null;
778       l_old_val4(l_tab_counter) := null;
779       l_old_val5(l_tab_counter) := null;
780       l_old_val6(l_tab_counter) := null;
781       l_new_val2(l_tab_counter) := null;
782       l_new_val3(l_tab_counter) := null;
783       l_new_val4(l_tab_counter) := null;
784       l_new_val5(l_tab_counter) := null;
785       l_new_val6(l_tab_counter) := null;
786     end if;
787     if nvl(p_old_rec.date_of_death, to_date('01/01/0001', 'dd/mm/yyyy'))
788         <> nvl(p_new_rec.date_of_death, to_date('01/01/0001', 'dd/mm/yyyy')) then
789       l_tab_counter := l_tab_counter + 1;
790       l_chg_evt_tab(l_tab_counter) := 'CODD';
791       l_prmtr_01_tab(l_tab_counter) := null;
792       l_prmtr_02_tab(l_tab_counter) := null;
793       l_prmtr_03_tab(l_tab_counter) := null;
794       l_prmtr_04_tab(l_tab_counter) := null;
795       l_prmtr_05_tab(l_tab_counter) := null;
796       l_prmtr_06_tab(l_tab_counter) := null;
797       l_prmtr_07_tab(l_tab_counter) := null;
798       l_old_val1(l_tab_counter) := to_char(p_old_rec.date_of_death, 'mm/dd/yyyy');
799       l_new_val1(l_tab_counter) := to_char(p_new_rec.date_of_death, 'mm/dd/yyyy');
800       l_old_val2(l_tab_counter) := null;
801       l_old_val3(l_tab_counter) := null;
802       l_old_val4(l_tab_counter) := null;
803       l_old_val5(l_tab_counter) := null;
804       l_old_val6(l_tab_counter) := null;
805       l_new_val2(l_tab_counter) := null;
806       l_new_val3(l_tab_counter) := null;
807       l_new_val4(l_tab_counter) := null;
808       l_new_val5(l_tab_counter) := null;
809       l_new_val6(l_tab_counter) := null;
810     end if;
811     if (nvl(p_old_rec.date_employee_data_verified, to_date('01/01/0001', 'dd/mm/yyyy'))
812         <> nvl(p_new_rec.date_employee_data_verified, to_date('01/01/0001', 'dd/mm/yyyy')) or
813         (p_old_rec.date_employee_data_verified is null and
814          p_new_rec.date_employee_data_verified is not null) or
815         (p_old_rec.date_employee_data_verified is not null and
816          p_new_rec.date_employee_data_verified is null))  then
817       l_tab_counter := l_tab_counter + 1;
818       l_chg_evt_tab(l_tab_counter) := 'COPV';
819       l_prmtr_01_tab(l_tab_counter) := null;
820       l_prmtr_02_tab(l_tab_counter) := null;
821       l_prmtr_03_tab(l_tab_counter) := null;
822       l_prmtr_04_tab(l_tab_counter) := null;
823       l_prmtr_05_tab(l_tab_counter) := null;
824       l_prmtr_06_tab(l_tab_counter) := null;
825       l_prmtr_07_tab(l_tab_counter) := null;
826       l_old_val1(l_tab_counter) := to_char(p_old_rec.date_employee_data_verified, 'mm/dd/yyyy');
827       l_new_val1(l_tab_counter) := to_char(p_new_rec.date_employee_data_verified, 'mm/dd/yyyy');
828       l_old_val2(l_tab_counter) := null;
829       l_old_val3(l_tab_counter) := null;
830       l_old_val4(l_tab_counter) := null;
831       l_old_val5(l_tab_counter) := null;
832       l_old_val6(l_tab_counter) := null;
833       l_new_val2(l_tab_counter) := null;
834       l_new_val3(l_tab_counter) := null;
835       l_new_val4(l_tab_counter) := null;
836       l_new_val5(l_tab_counter) := null;
837       l_new_val6(l_tab_counter) := null;
838     end if;
839     if nvl(p_old_rec.marital_status, '$')
840         <> nvl(p_new_rec.marital_status, '$') then
841       -- read marital status from lookup table
842       open c_lookup_value('MAR_STATUS', p_old_rec.marital_status);
843       fetch c_lookup_value into l_old_marital_status;
844       close c_lookup_value;
845       open c_lookup_value('MAR_STATUS', p_new_rec.marital_status);
846       fetch c_lookup_value into l_new_marital_status;
847       close c_lookup_value;
848 
849       l_tab_counter := l_tab_counter + 1;
850       l_chg_evt_tab(l_tab_counter) := 'COM';
851       l_prmtr_01_tab(l_tab_counter) := null;
852       l_prmtr_02_tab(l_tab_counter) := null;
853       l_prmtr_03_tab(l_tab_counter) := null;
854       l_prmtr_04_tab(l_tab_counter) := null;
855       l_prmtr_05_tab(l_tab_counter) := null;
856       l_prmtr_06_tab(l_tab_counter) := null;
857       l_prmtr_07_tab(l_tab_counter) := null;
858       l_old_val1(l_tab_counter) := l_old_marital_status;
859       l_new_val1(l_tab_counter) := l_new_marital_status;
860       l_old_val2(l_tab_counter) := null;
861       l_old_val3(l_tab_counter) := null;
862       l_old_val4(l_tab_counter) := null;
863       l_old_val5(l_tab_counter) := null;
864       l_old_val6(l_tab_counter) := null;
865       l_new_val2(l_tab_counter) := null;
866       l_new_val3(l_tab_counter) := null;
867       l_new_val4(l_tab_counter) := null;
868       l_new_val5(l_tab_counter) := null;
869       l_new_val6(l_tab_counter) := null;
870     end if;
871     if nvl(p_old_rec.sex, '$')
872         <> nvl(p_new_rec.sex, '$') then
873       -- read gender from lookup table
874       open c_lookup_value('SEX', p_old_rec.sex);
875       fetch c_lookup_value into l_old_sex;
876       close c_lookup_value;
877       open c_lookup_value('SEX', p_new_rec.sex);
878       fetch c_lookup_value into l_new_sex;
879       close c_lookup_value;
880 
881       l_tab_counter := l_tab_counter + 1;
882       l_chg_evt_tab(l_tab_counter) := 'COG';
883       l_prmtr_01_tab(l_tab_counter) := null;
884       l_prmtr_02_tab(l_tab_counter) := null;
885       l_prmtr_03_tab(l_tab_counter) := null;
886       l_prmtr_04_tab(l_tab_counter) := null;
887       l_prmtr_05_tab(l_tab_counter) := null;
888       l_prmtr_06_tab(l_tab_counter) := null;
889       l_prmtr_07_tab(l_tab_counter) := null;
890       l_old_val1(l_tab_counter) := l_old_sex;
891       l_new_val1(l_tab_counter) := l_new_sex;
892       l_old_val2(l_tab_counter) := null;
893       l_old_val3(l_tab_counter) := null;
894       l_old_val4(l_tab_counter) := null;
895       l_old_val5(l_tab_counter) := null;
896       l_old_val6(l_tab_counter) := null;
897       l_new_val2(l_tab_counter) := null;
898       l_new_val3(l_tab_counter) := null;
899       l_new_val4(l_tab_counter) := null;
900       l_new_val5(l_tab_counter) := null;
901       l_new_val6(l_tab_counter) := null;
902     end if;
903     if nvl(p_old_rec.registered_disabled_flag, '$')
904         <> nvl(p_new_rec.registered_disabled_flag, '$') then
905       -- read disability status from lookup table
906       open c_lookup_value('REGISTERED_DISABLED', p_old_rec.registered_disabled_flag);
907       fetch c_lookup_value into l_old_disability_status;
908       close c_lookup_value;
909       open c_lookup_value('REGISTERED_DISABLED', p_new_rec.registered_disabled_flag);
910       fetch c_lookup_value into l_new_disability_status;
911       close c_lookup_value;
912 
913       l_tab_counter := l_tab_counter + 1;
914       l_chg_evt_tab(l_tab_counter) := 'CODS';
915       l_prmtr_01_tab(l_tab_counter) := null;
916       l_prmtr_02_tab(l_tab_counter) := null;
917       l_prmtr_03_tab(l_tab_counter) := null;
918       l_prmtr_04_tab(l_tab_counter) := null;
919       l_prmtr_05_tab(l_tab_counter) := null;
920       l_prmtr_06_tab(l_tab_counter) := null;
921       l_prmtr_07_tab(l_tab_counter) := null;
922       l_old_val1(l_tab_counter) := l_old_disability_status;
923       l_new_val1(l_tab_counter) := l_new_disability_status;
924       l_old_val2(l_tab_counter) := null;
925       l_old_val3(l_tab_counter) := null;
926       l_old_val4(l_tab_counter) := null;
927       l_old_val5(l_tab_counter) := null;
928       l_old_val6(l_tab_counter) := null;
929       l_new_val2(l_tab_counter) := null;
930       l_new_val3(l_tab_counter) := null;
931       l_new_val4(l_tab_counter) := null;
932       l_new_val5(l_tab_counter) := null;
933       l_new_val6(l_tab_counter) := null;
934     end if;
935     if nvl(p_old_rec.benefit_group_id, 1)
936         <> nvl(p_new_rec.benefit_group_id, 1) then
937       -- read old and new benefits group values
938       open c_benefits_group(p_old_rec.benefit_group_id);
939       fetch c_benefits_group into l_old_benefits_group;
940       close c_benefits_group;
941       open c_benefits_group(p_new_rec.benefit_group_id);
942       fetch c_benefits_group into l_new_benefits_group;
943       close c_benefits_group;
944 
945       l_tab_counter := l_tab_counter + 1;
946       l_chg_evt_tab(l_tab_counter) := 'COBG';
947       l_prmtr_01_tab(l_tab_counter) := p_old_rec.benefit_group_id;
948       l_prmtr_02_tab(l_tab_counter) := p_new_rec.benefit_group_id;
949       l_prmtr_03_tab(l_tab_counter) := null;
950       l_prmtr_04_tab(l_tab_counter) := null;
951       l_prmtr_05_tab(l_tab_counter) := null;
952       l_prmtr_06_tab(l_tab_counter) := null;
953       l_prmtr_07_tab(l_tab_counter) := null;
954       l_old_val1(l_tab_counter) := l_old_benefits_group;
955       l_new_val1(l_tab_counter) := l_new_benefits_group;
956       l_old_val2(l_tab_counter) := null;
957       l_old_val3(l_tab_counter) := null;
958       l_old_val4(l_tab_counter) := null;
959       l_old_val5(l_tab_counter) := null;
960       l_old_val6(l_tab_counter) := null;
961       l_new_val2(l_tab_counter) := null;
962       l_new_val3(l_tab_counter) := null;
963       l_new_val4(l_tab_counter) := null;
964       l_new_val5(l_tab_counter) := null;
965       l_new_val6(l_tab_counter) := null;
966     end if;
967     if nvl(p_old_rec.student_status, '$')
968         <> nvl(p_new_rec.student_status, '$') then
969       -- read student status from lookup table
970       open c_lookup_value('STUDENT_STATUS', p_old_rec.student_status);
971       fetch c_lookup_value into l_old_student_status;
972       close c_lookup_value;
973       open c_lookup_value('STUDENT_STATUS', p_new_rec.student_status);
974       fetch c_lookup_value into l_new_student_status;
975       close c_lookup_value;
976 
977       l_tab_counter := l_tab_counter + 1;
978       l_chg_evt_tab(l_tab_counter) := 'COST';
979       l_prmtr_01_tab(l_tab_counter) := null;
980       l_prmtr_02_tab(l_tab_counter) := null;
981       l_prmtr_03_tab(l_tab_counter) := null;
982       l_prmtr_04_tab(l_tab_counter) := null;
983       l_prmtr_05_tab(l_tab_counter) := null;
984       l_prmtr_06_tab(l_tab_counter) := null;
985       l_prmtr_07_tab(l_tab_counter) := null;
986       l_old_val1(l_tab_counter) := l_old_student_status;
987       l_new_val1(l_tab_counter) := l_new_student_status;
988       l_old_val2(l_tab_counter) := null;
989       l_old_val3(l_tab_counter) := null;
990       l_old_val4(l_tab_counter) := null;
991       l_old_val5(l_tab_counter) := null;
992       l_old_val6(l_tab_counter) := null;
993       l_new_val2(l_tab_counter) := null;
994       l_new_val3(l_tab_counter) := null;
995       l_new_val4(l_tab_counter) := null;
996       l_new_val5(l_tab_counter) := null;
997       l_new_val6(l_tab_counter) := null;
998     end if;
999     if nvl(p_old_rec.attribute1, '$')
1000         <> nvl(p_new_rec.attribute1, '$') then
1001       l_tab_counter := l_tab_counter + 1;
1002       l_chg_evt_tab(l_tab_counter) := 'COPF01';
1003       l_prmtr_01_tab(l_tab_counter) := null;
1004       l_prmtr_02_tab(l_tab_counter) := null;
1005       l_prmtr_03_tab(l_tab_counter) := null;
1006       l_prmtr_04_tab(l_tab_counter) := null;
1007       l_prmtr_05_tab(l_tab_counter) := null;
1008       l_prmtr_06_tab(l_tab_counter) := null;
1009       l_prmtr_07_tab(l_tab_counter) := null;
1010       l_old_val1(l_tab_counter) := p_old_rec.attribute1;
1011       l_new_val1(l_tab_counter) := p_new_rec.attribute1;
1012       l_old_val2(l_tab_counter) := null;
1013       l_old_val3(l_tab_counter) := null;
1014       l_old_val4(l_tab_counter) := null;
1015       l_old_val5(l_tab_counter) := null;
1016       l_old_val6(l_tab_counter) := null;
1017       l_new_val2(l_tab_counter) := null;
1018       l_new_val3(l_tab_counter) := null;
1019       l_new_val4(l_tab_counter) := null;
1020       l_new_val5(l_tab_counter) := null;
1021       l_new_val6(l_tab_counter) := null;
1022     end if;
1023     if nvl(p_old_rec.attribute2, '$')
1024         <> nvl(p_new_rec.attribute2, '$') then
1025       l_tab_counter := l_tab_counter + 1;
1026       l_chg_evt_tab(l_tab_counter) := 'COPF02';
1027       l_prmtr_01_tab(l_tab_counter) := null;
1028       l_prmtr_02_tab(l_tab_counter) := null;
1029       l_prmtr_03_tab(l_tab_counter) := null;
1030       l_prmtr_04_tab(l_tab_counter) := null;
1031       l_prmtr_05_tab(l_tab_counter) := null;
1032       l_prmtr_06_tab(l_tab_counter) := null;
1033       l_prmtr_07_tab(l_tab_counter) := null;
1034       l_old_val1(l_tab_counter) := p_old_rec.attribute2;
1035       l_new_val1(l_tab_counter) := p_new_rec.attribute2;
1036       l_old_val2(l_tab_counter) := null;
1037       l_old_val3(l_tab_counter) := null;
1038       l_old_val4(l_tab_counter) := null;
1039       l_old_val5(l_tab_counter) := null;
1040       l_old_val6(l_tab_counter) := null;
1041       l_new_val2(l_tab_counter) := null;
1042       l_new_val3(l_tab_counter) := null;
1043       l_new_val4(l_tab_counter) := null;
1044       l_new_val5(l_tab_counter) := null;
1045       l_new_val6(l_tab_counter) := null;
1046     end if;
1047     if nvl(p_old_rec.attribute3, '$')
1048         <> nvl(p_new_rec.attribute3, '$') then
1049       l_tab_counter := l_tab_counter + 1;
1050       l_chg_evt_tab(l_tab_counter) := 'COPF03';
1051       l_prmtr_01_tab(l_tab_counter) := null;
1052       l_prmtr_02_tab(l_tab_counter) := null;
1053       l_prmtr_03_tab(l_tab_counter) := null;
1054       l_prmtr_04_tab(l_tab_counter) := null;
1055       l_prmtr_05_tab(l_tab_counter) := null;
1056       l_prmtr_06_tab(l_tab_counter) := null;
1057       l_prmtr_07_tab(l_tab_counter) := null;
1058       l_old_val1(l_tab_counter) := p_old_rec.attribute3;
1059       l_new_val1(l_tab_counter) := p_new_rec.attribute3;
1060       l_old_val2(l_tab_counter) := null;
1061       l_old_val3(l_tab_counter) := null;
1062       l_old_val4(l_tab_counter) := null;
1063       l_old_val5(l_tab_counter) := null;
1064       l_old_val6(l_tab_counter) := null;
1065       l_new_val2(l_tab_counter) := null;
1066       l_new_val3(l_tab_counter) := null;
1067       l_new_val4(l_tab_counter) := null;
1068       l_new_val5(l_tab_counter) := null;
1069       l_new_val6(l_tab_counter) := null;
1070     end if;
1071     if nvl(p_old_rec.attribute4, '$')
1072         <> nvl(p_new_rec.attribute4, '$') then
1073       l_tab_counter := l_tab_counter + 1;
1074       l_chg_evt_tab(l_tab_counter) := 'COPF04';
1075       l_prmtr_01_tab(l_tab_counter) := null;
1076       l_prmtr_02_tab(l_tab_counter) := null;
1077       l_prmtr_03_tab(l_tab_counter) := null;
1078       l_prmtr_04_tab(l_tab_counter) := null;
1079       l_prmtr_05_tab(l_tab_counter) := null;
1080       l_prmtr_06_tab(l_tab_counter) := null;
1081       l_prmtr_07_tab(l_tab_counter) := null;
1082       l_old_val1(l_tab_counter) := p_old_rec.attribute4;
1083       l_new_val1(l_tab_counter) := p_new_rec.attribute4;
1084       l_old_val2(l_tab_counter) := null;
1085       l_old_val3(l_tab_counter) := null;
1086       l_old_val4(l_tab_counter) := null;
1087       l_old_val5(l_tab_counter) := null;
1088       l_old_val6(l_tab_counter) := null;
1089       l_new_val2(l_tab_counter) := null;
1090       l_new_val3(l_tab_counter) := null;
1091       l_new_val4(l_tab_counter) := null;
1092       l_new_val5(l_tab_counter) := null;
1093       l_new_val6(l_tab_counter) := null;
1094     end if;
1095     if nvl(p_old_rec.attribute5, '$')
1096         <> nvl(p_new_rec.attribute5, '$') then
1097       l_tab_counter := l_tab_counter + 1;
1098       l_chg_evt_tab(l_tab_counter) := 'COPF05';
1099       l_prmtr_01_tab(l_tab_counter) := null;
1100       l_prmtr_02_tab(l_tab_counter) := null;
1101       l_prmtr_03_tab(l_tab_counter) := null;
1102       l_prmtr_04_tab(l_tab_counter) := null;
1103       l_prmtr_05_tab(l_tab_counter) := null;
1104       l_prmtr_06_tab(l_tab_counter) := null;
1105       l_prmtr_07_tab(l_tab_counter) := null;
1106       l_old_val1(l_tab_counter) := p_old_rec.attribute5;
1107       l_new_val1(l_tab_counter) := p_new_rec.attribute5;
1108       l_old_val2(l_tab_counter) := null;
1109       l_old_val3(l_tab_counter) := null;
1110       l_old_val4(l_tab_counter) := null;
1111       l_old_val5(l_tab_counter) := null;
1112       l_old_val6(l_tab_counter) := null;
1113       l_new_val2(l_tab_counter) := null;
1114       l_new_val3(l_tab_counter) := null;
1115       l_new_val4(l_tab_counter) := null;
1116       l_new_val5(l_tab_counter) := null;
1117       l_new_val6(l_tab_counter) := null;
1118     end if;
1119     if nvl(p_old_rec.attribute6, '$')
1120         <> nvl(p_new_rec.attribute6, '$') then
1121       l_tab_counter := l_tab_counter + 1;
1122       l_chg_evt_tab(l_tab_counter) := 'COPF06';
1123       l_prmtr_01_tab(l_tab_counter) := null;
1124       l_prmtr_02_tab(l_tab_counter) := null;
1125       l_prmtr_03_tab(l_tab_counter) := null;
1126       l_prmtr_04_tab(l_tab_counter) := null;
1127       l_prmtr_05_tab(l_tab_counter) := null;
1128       l_prmtr_06_tab(l_tab_counter) := null;
1129       l_prmtr_07_tab(l_tab_counter) := null;
1130       l_old_val1(l_tab_counter) := p_old_rec.attribute6;
1131       l_new_val1(l_tab_counter) := p_new_rec.attribute6;
1132       l_old_val2(l_tab_counter) := null;
1133       l_old_val3(l_tab_counter) := null;
1134       l_old_val4(l_tab_counter) := null;
1135       l_old_val5(l_tab_counter) := null;
1136       l_old_val6(l_tab_counter) := null;
1137       l_new_val2(l_tab_counter) := null;
1138       l_new_val3(l_tab_counter) := null;
1139       l_new_val4(l_tab_counter) := null;
1140       l_new_val5(l_tab_counter) := null;
1141       l_new_val6(l_tab_counter) := null;
1142     end if;
1143     if nvl(p_old_rec.attribute7, '$')
1144         <> nvl(p_new_rec.attribute7, '$') then
1145       l_tab_counter := l_tab_counter + 1;
1146       l_chg_evt_tab(l_tab_counter) := 'COPF07';
1147       l_prmtr_01_tab(l_tab_counter) := null;
1148       l_prmtr_02_tab(l_tab_counter) := null;
1149       l_prmtr_03_tab(l_tab_counter) := null;
1150       l_prmtr_04_tab(l_tab_counter) := null;
1151       l_prmtr_05_tab(l_tab_counter) := null;
1152       l_prmtr_06_tab(l_tab_counter) := null;
1153       l_prmtr_07_tab(l_tab_counter) := null;
1154       l_old_val1(l_tab_counter) := p_old_rec.attribute7;
1155       l_new_val1(l_tab_counter) := p_new_rec.attribute7;
1156       l_old_val2(l_tab_counter) := null;
1157       l_old_val3(l_tab_counter) := null;
1158       l_old_val4(l_tab_counter) := null;
1159       l_old_val5(l_tab_counter) := null;
1160       l_old_val6(l_tab_counter) := null;
1161       l_new_val2(l_tab_counter) := null;
1162       l_new_val3(l_tab_counter) := null;
1163       l_new_val4(l_tab_counter) := null;
1164       l_new_val5(l_tab_counter) := null;
1165       l_new_val6(l_tab_counter) := null;
1166     end if;
1167     if nvl(p_old_rec.attribute8, '$')
1168         <> nvl(p_new_rec.attribute8, '$') then
1169       l_tab_counter := l_tab_counter + 1;
1170       l_chg_evt_tab(l_tab_counter) := 'COPF08';
1171       l_prmtr_01_tab(l_tab_counter) := null;
1172       l_prmtr_02_tab(l_tab_counter) := null;
1173       l_prmtr_03_tab(l_tab_counter) := null;
1174       l_prmtr_04_tab(l_tab_counter) := null;
1175       l_prmtr_05_tab(l_tab_counter) := null;
1176       l_prmtr_06_tab(l_tab_counter) := null;
1177       l_prmtr_07_tab(l_tab_counter) := null;
1178       l_old_val1(l_tab_counter) := p_old_rec.attribute8;
1179       l_new_val1(l_tab_counter) := p_new_rec.attribute8;
1180       l_old_val2(l_tab_counter) := null;
1181       l_old_val3(l_tab_counter) := null;
1182       l_old_val4(l_tab_counter) := null;
1183       l_old_val5(l_tab_counter) := null;
1184       l_old_val6(l_tab_counter) := null;
1185       l_new_val2(l_tab_counter) := null;
1186       l_new_val3(l_tab_counter) := null;
1187       l_new_val4(l_tab_counter) := null;
1188       l_new_val5(l_tab_counter) := null;
1189       l_new_val6(l_tab_counter) := null;
1190     end if;
1191     if nvl(p_old_rec.attribute9, '$')
1192         <> nvl(p_new_rec.attribute9, '$') then
1193       l_tab_counter := l_tab_counter + 1;
1194       l_chg_evt_tab(l_tab_counter) := 'COPF09';
1195       l_prmtr_01_tab(l_tab_counter) := null;
1196       l_prmtr_02_tab(l_tab_counter) := null;
1197       l_prmtr_03_tab(l_tab_counter) := null;
1198       l_prmtr_04_tab(l_tab_counter) := null;
1199       l_prmtr_05_tab(l_tab_counter) := null;
1200       l_prmtr_06_tab(l_tab_counter) := null;
1201       l_prmtr_07_tab(l_tab_counter) := null;
1202       l_old_val1(l_tab_counter) := p_old_rec.attribute9;
1203       l_new_val1(l_tab_counter) := p_new_rec.attribute9;
1204       l_old_val2(l_tab_counter) := null;
1205       l_old_val3(l_tab_counter) := null;
1206       l_old_val4(l_tab_counter) := null;
1207       l_old_val5(l_tab_counter) := null;
1208       l_old_val6(l_tab_counter) := null;
1209       l_new_val2(l_tab_counter) := null;
1210       l_new_val3(l_tab_counter) := null;
1211       l_new_val4(l_tab_counter) := null;
1212       l_new_val5(l_tab_counter) := null;
1213       l_new_val6(l_tab_counter) := null;
1214     end if;
1215     if nvl(p_old_rec.attribute10, '$')
1216         <> nvl(p_new_rec.attribute10, '$') then
1217       l_tab_counter := l_tab_counter + 1;
1218       l_chg_evt_tab(l_tab_counter) := 'COPF10';
1219       l_prmtr_01_tab(l_tab_counter) := null;
1220       l_prmtr_02_tab(l_tab_counter) := null;
1221       l_prmtr_03_tab(l_tab_counter) := null;
1222       l_prmtr_04_tab(l_tab_counter) := null;
1223       l_prmtr_05_tab(l_tab_counter) := null;
1224       l_prmtr_06_tab(l_tab_counter) := null;
1225       l_prmtr_07_tab(l_tab_counter) := null;
1226       l_old_val1(l_tab_counter) := p_old_rec.attribute10;
1227       l_new_val1(l_tab_counter) := p_new_rec.attribute10;
1228       l_old_val2(l_tab_counter) := null;
1229       l_old_val3(l_tab_counter) := null;
1230       l_old_val4(l_tab_counter) := null;
1231       l_old_val5(l_tab_counter) := null;
1232       l_old_val6(l_tab_counter) := null;
1233       l_new_val2(l_tab_counter) := null;
1234       l_new_val3(l_tab_counter) := null;
1235       l_new_val4(l_tab_counter) := null;
1236       l_new_val5(l_tab_counter) := null;
1237       l_new_val6(l_tab_counter) := null;
1238     end if;
1239     if nvl(p_old_rec.email_address, '$')
1240         <> nvl(p_new_rec.email_address, '$') then
1241       l_tab_counter := l_tab_counter + 1;
1242       l_chg_evt_tab(l_tab_counter) := 'COEA';
1243       l_prmtr_01_tab(l_tab_counter) := null;
1244       l_prmtr_02_tab(l_tab_counter) := null;
1245       l_prmtr_03_tab(l_tab_counter) := null;
1246       l_prmtr_04_tab(l_tab_counter) := null;
1247       l_prmtr_05_tab(l_tab_counter) := null;
1248       l_prmtr_06_tab(l_tab_counter) := null;
1249       l_prmtr_07_tab(l_tab_counter) := null;
1250       l_old_val1(l_tab_counter) := substr(p_old_rec.email_address,1,240);
1251       l_new_val1(l_tab_counter) := substr(p_new_rec.email_address,1,240);
1252       l_old_val2(l_tab_counter) := null;
1253       l_old_val3(l_tab_counter) := null;
1254       l_old_val4(l_tab_counter) := null;
1255       l_old_val5(l_tab_counter) := null;
1256       l_old_val6(l_tab_counter) := null;
1257       l_new_val2(l_tab_counter) := null;
1258       l_new_val3(l_tab_counter) := null;
1259       l_new_val4(l_tab_counter) := null;
1260       l_new_val5(l_tab_counter) := null;
1261       l_new_val6(l_tab_counter) := null;
1262     end if;
1263     if nvl(p_old_rec.per_information10, '$')
1264         <> nvl(p_new_rec.per_information10, '$') then
1265       l_tab_counter := l_tab_counter + 1;
1266       l_chg_evt_tab(l_tab_counter) := 'CCOPMD';
1267       l_prmtr_01_tab(l_tab_counter) := null;
1268       l_prmtr_02_tab(l_tab_counter) := null;
1269       l_prmtr_03_tab(l_tab_counter) := null;
1270       l_prmtr_04_tab(l_tab_counter) := null;
1271       l_prmtr_05_tab(l_tab_counter) := null;
1272       l_prmtr_06_tab(l_tab_counter) := null;
1273       l_prmtr_07_tab(l_tab_counter) := null;
1274       l_old_val1(l_tab_counter) := p_old_rec.per_information10;
1275       l_new_val1(l_tab_counter) := p_new_rec.per_information10;
1276       l_old_val2(l_tab_counter) := null;
1277       l_old_val3(l_tab_counter) := null;
1278       l_old_val4(l_tab_counter) := null;
1279       l_old_val5(l_tab_counter) := null;
1280       l_old_val6(l_tab_counter) := null;
1281       l_new_val2(l_tab_counter) := null;
1282       l_new_val3(l_tab_counter) := null;
1283       l_new_val4(l_tab_counter) := null;
1284       l_new_val5(l_tab_counter) := null;
1285       l_new_val6(l_tab_counter) := null;
1286     end if;
1287     if nvl(p_old_rec.per_information1, '$')
1288         <> nvl(p_new_rec.per_information1, '$') then
1289 
1290        -- read ethnic group from lookup table
1291       open c_lookup_value('US_ETHNIC_GROUP', p_old_rec.per_information1);
1292       fetch c_lookup_value into l_old_ethnic_group;
1293       close c_lookup_value;
1294       open c_lookup_value('US_ETHNIC_GROUP', p_new_rec.per_information1);
1295       fetch c_lookup_value into l_new_ethnic_group;
1296       close c_lookup_value;
1297       ---
1298 
1299       l_tab_counter := l_tab_counter + 1;
1300       l_chg_evt_tab(l_tab_counter) := 'CETHORG';
1301       l_prmtr_01_tab(l_tab_counter) := null;
1302       l_prmtr_02_tab(l_tab_counter) := null;
1303       l_prmtr_03_tab(l_tab_counter) := null;
1304       l_prmtr_04_tab(l_tab_counter) := null;
1305       l_prmtr_05_tab(l_tab_counter) := null;
1306       l_prmtr_06_tab(l_tab_counter) := null;
1307       l_prmtr_07_tab(l_tab_counter) := null;
1308       l_old_val1(l_tab_counter) := l_old_ethnic_group;
1309       l_new_val1(l_tab_counter) := l_new_ethnic_group;
1310       l_old_val2(l_tab_counter) := null;
1311       l_old_val3(l_tab_counter) := null;
1312       l_old_val4(l_tab_counter) := null;
1313       l_old_val5(l_tab_counter) := null;
1314       l_old_val6(l_tab_counter) := null;
1315       l_new_val2(l_tab_counter) := null;
1316       l_new_val3(l_tab_counter) := null;
1317       l_new_val4(l_tab_counter) := null;
1318       l_new_val5(l_tab_counter) := null;
1319       l_new_val6(l_tab_counter) := null;
1320     end if;
1321     if nvl(p_old_rec.correspondence_language, '$')
1322         <> nvl(p_new_rec.correspondence_language, '$') then
1323       l_tab_counter := l_tab_counter + 1;
1324       l_chg_evt_tab(l_tab_counter) := 'CLANG';
1325       l_prmtr_01_tab(l_tab_counter) := null;
1326       l_prmtr_02_tab(l_tab_counter) := null;
1327       l_prmtr_03_tab(l_tab_counter) := null;
1328       l_prmtr_04_tab(l_tab_counter) := null;
1329       l_prmtr_05_tab(l_tab_counter) := null;
1330       l_prmtr_06_tab(l_tab_counter) := null;
1331       l_prmtr_07_tab(l_tab_counter) := null;
1332       l_old_val1(l_tab_counter) := p_old_rec.correspondence_language;
1333       l_new_val1(l_tab_counter) := p_new_rec.correspondence_language;
1334       l_old_val2(l_tab_counter) := null;
1335       l_old_val3(l_tab_counter) := null;
1336       l_old_val4(l_tab_counter) := null;
1337       l_old_val5(l_tab_counter) := null;
1338       l_old_val6(l_tab_counter) := null;
1339       l_new_val2(l_tab_counter) := null;
1340       l_new_val3(l_tab_counter) := null;
1341       l_new_val4(l_tab_counter) := null;
1342       l_new_val5(l_tab_counter) := null;
1343       l_new_val6(l_tab_counter) := null;
1344     end if;
1345 
1346     if nvl(p_old_rec.uses_tobacco_flag, '$')
1347         <> nvl(p_new_rec.uses_tobacco_flag, '$') then
1348       l_tab_counter := l_tab_counter + 1;
1349       l_chg_evt_tab(l_tab_counter) := 'CTOBAC';
1350       l_prmtr_01_tab(l_tab_counter) := null;
1351       l_prmtr_02_tab(l_tab_counter) := null;
1352       l_prmtr_03_tab(l_tab_counter) := null;
1353       l_prmtr_04_tab(l_tab_counter) := null;
1354       l_prmtr_05_tab(l_tab_counter) := null;
1355       l_prmtr_06_tab(l_tab_counter) := null;
1356       l_prmtr_07_tab(l_tab_counter) := null;
1357       l_old_val1(l_tab_counter) := p_old_rec.uses_tobacco_flag;
1358       l_new_val1(l_tab_counter) := p_new_rec.uses_tobacco_flag;
1359       l_old_val2(l_tab_counter) := null;
1360       l_old_val3(l_tab_counter) := null;
1361       l_old_val4(l_tab_counter) := null;
1362       l_old_val5(l_tab_counter) := null;
1363       l_old_val6(l_tab_counter) := null;
1364       l_new_val2(l_tab_counter) := null;
1365       l_new_val3(l_tab_counter) := null;
1366       l_new_val4(l_tab_counter) := null;
1367       l_new_val5(l_tab_counter) := null;
1368       l_new_val6(l_tab_counter) := null;
1369     end if;
1370 
1371 
1372 
1373     if nvl(p_old_rec.employee_number, '$')
1374         <> nvl(p_new_rec.employee_number, '$') then
1375       l_tab_counter := l_tab_counter + 1;
1376       l_chg_evt_tab(l_tab_counter) := 'COEN';
1377       l_prmtr_01_tab(l_tab_counter) := null;
1378       l_prmtr_02_tab(l_tab_counter) := null;
1379       l_prmtr_03_tab(l_tab_counter) := null;
1380       l_prmtr_04_tab(l_tab_counter) := null;
1381       l_prmtr_05_tab(l_tab_counter) := null;
1382       l_prmtr_06_tab(l_tab_counter) := null;
1383       l_prmtr_07_tab(l_tab_counter) := null;
1384       l_old_val1(l_tab_counter) := p_old_rec.employee_number;
1385       l_new_val1(l_tab_counter) := p_new_rec.employee_number;
1386       l_old_val2(l_tab_counter) := null;
1387       l_old_val3(l_tab_counter) := null;
1388       l_old_val4(l_tab_counter) := null;
1389       l_old_val5(l_tab_counter) := null;
1390       l_old_val6(l_tab_counter) := null;
1391       l_new_val2(l_tab_counter) := null;
1392       l_new_val3(l_tab_counter) := null;
1393       l_new_val4(l_tab_counter) := null;
1394       l_new_val5(l_tab_counter) := null;
1395       l_new_val6(l_tab_counter) := null;
1396     end if;
1397 
1398   end if;
1399   for l_count in 1..l_chg_evt_tab.count loop
1400    if change_event_is_enabled(l_chg_evt_tab(l_count),p_new_rec.effective_start_date) then
1401     ben_ext_chg_evt_api.create_ext_chg_evt
1402     (p_validate                    => FALSE
1403     ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
1404     ,p_chg_evt_cd                  => l_chg_evt_tab(l_count)
1405     ,p_chg_eff_dt                  => p_new_rec.effective_start_date
1406     ,p_prmtr_01                    => l_prmtr_01_tab(l_count)
1407     ,p_prmtr_02                    => l_prmtr_02_tab(l_count)
1408     ,p_prmtr_03                    => l_prmtr_03_tab(l_count)
1409     ,p_prmtr_04                    => l_prmtr_04_tab(l_count)
1410     ,p_prmtr_05                    => l_prmtr_05_tab(l_count)
1411     ,p_prmtr_06                    => l_prmtr_06_tab(l_count)
1412     ,p_prmtr_07                    => l_prmtr_07_tab(l_count)
1413     ,p_prmtr_10                    => p_new_rec.update_mode
1414     ,p_person_id                   => p_new_rec.person_id
1415     ,p_business_group_id           => p_new_rec.business_group_id
1416     ,p_object_version_number       => l_object_version_number
1417     ,p_effective_date              => p_new_rec.effective_start_date
1418     ,p_old_val1                    => l_old_val1(l_count)
1419     ,p_old_val2                    => l_old_val2(l_count)
1420     ,p_old_val3                    => l_old_val3(l_count)
1421     ,p_old_val4                    => l_old_val4(l_count)
1422     ,p_old_val5                    => l_old_val5(l_count)
1423     ,p_old_val6                    => l_old_val6(l_count)
1424     ,p_new_val1                    => l_new_val1(l_count)
1425     ,p_new_val2                    => l_new_val2(l_count)
1426     ,p_new_val3                    => l_new_val3(l_count)
1427     ,p_new_val4                    => l_new_val4(l_count)
1428     ,p_new_val5                    => l_new_val5(l_count)
1429     ,p_new_val6                    => l_new_val6(l_count)
1430     );
1431    end if;
1432   end loop;
1433   --
1434   --for contact data change
1435   -- For contact there will be two type og log will  be created
1436   -- only when the person type is contact - this is old one and maintained for backwdrd compatibility
1437   -- aonther one for all the contact person regardless of person type - this is new one
1438 
1439   open c_relationship(p_new_rec.person_id);
1440   fetch c_relationship into l_contact,l_relationship;
1441   if c_relationship%notfound then
1442     close c_relationship;
1443   elsif c_relationship%found then
1444       close c_relationship;
1445       open c_person_type(p_new_rec.person_type_id);
1446       fetch c_person_type into l_person_type;
1447       if c_person_type%notfound then
1448         close c_person_type;
1449       else
1450         if l_person_type = 'OTHER' then
1451            close c_person_type;
1452            l_ini_tab_counter := l_tab_counter;
1453           if nvl(p_old_rec.full_name, '$$$$$&&&')
1454              <> nvl(p_new_rec.full_name, '$$$$$&&&') then
1455              l_tab_counter := l_tab_counter + 1;
1456              l_cont_chg_evt_tab(l_tab_counter) := 'CCFN';
1457              l_prmtr_01_tab(l_tab_counter) := null;
1458              l_prmtr_02_tab(l_tab_counter) := null;
1459              l_prmtr_03_tab(l_tab_counter) := null;
1460              l_prmtr_04_tab(l_tab_counter) := null;
1461              l_prmtr_05_tab(l_tab_counter) := null;
1462              l_prmtr_06_tab(l_tab_counter) := null;
1463              l_prmtr_07_tab(l_tab_counter) := null;
1464              l_old_val1(l_tab_counter) := substr(p_old_rec.full_name,1,240);
1465              l_old_val2(l_tab_counter) := p_old_rec.title;
1466              l_old_val3(l_tab_counter) := p_old_rec.first_name;
1467              l_old_val4(l_tab_counter) := p_old_rec.middle_names;
1468              l_old_val5(l_tab_counter) := p_old_rec.last_name;
1469              l_old_val6(l_tab_counter) := p_old_rec.suffix;
1470              l_new_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1471              l_new_val2(l_tab_counter) := p_new_rec.title;
1472              l_new_val3(l_tab_counter) := p_new_rec.first_name;
1473              l_new_val4(l_tab_counter) := p_new_rec.middle_names;
1474              l_new_val5(l_tab_counter) := p_new_rec.last_name;
1475              l_new_val6(l_tab_counter) := p_new_rec.suffix;
1476           end if;
1477           if nvl(p_old_rec.date_of_birth, to_date('01/01/0001', 'dd/mm/yyyy'))
1478              <> nvl(p_new_rec.date_of_birth, to_date('01/01/0001', 'dd/mm/yyyy')) then
1479              l_tab_counter := l_tab_counter + 1;
1480              l_cont_chg_evt_tab(l_tab_counter) := 'CCDB';
1481              l_prmtr_01_tab(l_tab_counter) := null;
1482              l_prmtr_02_tab(l_tab_counter) := null;
1483              l_prmtr_03_tab(l_tab_counter) := null;
1484              l_prmtr_04_tab(l_tab_counter) := null;
1485              l_prmtr_05_tab(l_tab_counter) := null;
1486              l_prmtr_06_tab(l_tab_counter) := null;
1487              l_prmtr_07_tab(l_tab_counter) := null;
1488              l_old_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1489              l_new_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1490              l_old_val2(l_tab_counter) := to_char(p_old_rec.date_of_birth, 'mm/dd/yyyy');
1491              l_new_val2(l_tab_counter) := to_char(p_new_rec.date_of_birth, 'mm/dd/yyyy');
1492              l_old_val3(l_tab_counter) := null;
1493              l_old_val4(l_tab_counter) := null;
1494              l_old_val5(l_tab_counter) := null;
1495              l_old_val6(l_tab_counter) := null;
1496              l_new_val3(l_tab_counter) := null;
1497              l_new_val4(l_tab_counter) := null;
1498              l_new_val5(l_tab_counter) := null;
1499              l_new_val6(l_tab_counter) := null;
1500           end if;
1501           if nvl(p_old_rec.date_of_death, to_date('01/01/0001', 'dd/mm/yyyy'))
1502              <> nvl(p_new_rec.date_of_death, to_date('01/01/0001', 'dd/mm/yyyy')) then
1503              l_tab_counter := l_tab_counter + 1;
1504              l_cont_chg_evt_tab(l_tab_counter) := 'CCDD';
1505              l_prmtr_01_tab(l_tab_counter) := null;
1506              l_prmtr_02_tab(l_tab_counter) := null;
1507              l_prmtr_03_tab(l_tab_counter) := null;
1508              l_prmtr_04_tab(l_tab_counter) := null;
1509              l_prmtr_05_tab(l_tab_counter) := null;
1510              l_prmtr_06_tab(l_tab_counter) := null;
1511              l_prmtr_07_tab(l_tab_counter) := null;
1512              l_old_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1513              l_new_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1514              l_old_val2(l_tab_counter) := to_char(p_old_rec.date_of_death, 'mm/dd/yyyy');
1515              l_new_val2(l_tab_counter) := to_char(p_new_rec.date_of_death, 'mm/dd/yyyy');
1516              l_old_val3(l_tab_counter) := null;
1517              l_old_val4(l_tab_counter) := null;
1518              l_old_val5(l_tab_counter) := null;
1519              l_old_val6(l_tab_counter) := null;
1520              l_new_val3(l_tab_counter) := null;
1521              l_new_val4(l_tab_counter) := null;
1522              l_new_val5(l_tab_counter) := null;
1523              l_new_val6(l_tab_counter) := null;
1524           end if;
1525           if nvl(p_old_rec.national_identifier, '000-00-0000')
1526              <> nvl(p_new_rec.national_identifier, '000-00-0000') then
1527              l_tab_counter := l_tab_counter + 1;
1528              l_cont_chg_evt_tab(l_tab_counter) := 'CCSS';
1529              l_prmtr_01_tab(l_tab_counter) := null;
1530              l_prmtr_02_tab(l_tab_counter) := null;
1531              l_prmtr_03_tab(l_tab_counter) := null;
1532              l_prmtr_04_tab(l_tab_counter) := null;
1533              l_prmtr_05_tab(l_tab_counter) := null;
1534              l_prmtr_06_tab(l_tab_counter) := null;
1535              l_prmtr_07_tab(l_tab_counter) := null;
1536              l_old_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1537              l_new_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1538              l_old_val2(l_tab_counter) := p_old_rec.national_identifier;
1539              l_new_val2(l_tab_counter) := p_new_rec.national_identifier;
1540              l_old_val3(l_tab_counter) := null;
1541              l_old_val4(l_tab_counter) := null;
1542              l_old_val5(l_tab_counter) := null;
1543              l_old_val6(l_tab_counter) := null;
1544              l_new_val3(l_tab_counter) := null;
1545              l_new_val4(l_tab_counter) := null;
1546              l_new_val5(l_tab_counter) := null;
1547              l_new_val6(l_tab_counter) := null;
1548           end if;
1549           if nvl(p_old_rec.sex, '$')
1550              <> nvl(p_new_rec.sex, '$') then
1551              -- read gender from lookup table
1552              open c_lookup_value('SEX', p_old_rec.sex);
1553              fetch c_lookup_value into l_old_sex;
1554              close c_lookup_value;
1555              open c_lookup_value('SEX', p_new_rec.sex);
1556              fetch c_lookup_value into l_new_sex;
1557              close c_lookup_value;
1558 
1559              l_tab_counter := l_tab_counter + 1;
1560              l_cont_chg_evt_tab(l_tab_counter) := 'CCGE';
1561              l_prmtr_01_tab(l_tab_counter) := null;
1562              l_prmtr_02_tab(l_tab_counter) := null;
1563              l_prmtr_03_tab(l_tab_counter) := null;
1564              l_prmtr_04_tab(l_tab_counter) := null;
1565              l_prmtr_05_tab(l_tab_counter) := null;
1566              l_prmtr_06_tab(l_tab_counter) := null;
1567              l_prmtr_07_tab(l_tab_counter) := null;
1568              l_old_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1569              l_new_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1570              l_old_val2(l_tab_counter) := l_old_sex;
1571              l_new_val2(l_tab_counter) := l_new_sex;
1572              l_old_val3(l_tab_counter) := null;
1573              l_old_val4(l_tab_counter) := null;
1574              l_old_val5(l_tab_counter) := null;
1575              l_old_val6(l_tab_counter) := null;
1576              l_new_val3(l_tab_counter) := null;
1577              l_new_val4(l_tab_counter) := null;
1578              l_new_val5(l_tab_counter) := null;
1579              l_new_val6(l_tab_counter) := null;
1580           end if;
1581           for l_count in l_ini_tab_counter+1..l_ini_tab_counter+l_cont_chg_evt_tab.count loop
1582               if change_event_is_enabled(l_cont_chg_evt_tab(l_count),p_new_rec.effective_start_date)
1583                  then
1584 
1585                  ben_ext_chg_evt_api.create_ext_chg_evt
1586                  (p_validate                    => FALSE
1587                  ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
1588                  ,p_chg_evt_cd                  => l_cont_chg_evt_tab(l_count)
1589                  ,p_chg_eff_dt                  => p_new_rec.effective_start_date
1590                  ,p_prmtr_01                    => to_char(l_contact)
1591                  ,p_prmtr_02                    => l_prmtr_02_tab(l_count)
1592                  ,p_prmtr_03                    => l_prmtr_03_tab(l_count)
1593                  ,p_prmtr_04                    => l_prmtr_04_tab(l_count)
1594                  ,p_prmtr_05                    => l_prmtr_05_tab(l_count)
1595                  ,p_prmtr_06                    => to_char(p_new_rec.person_id)
1596                  ,p_prmtr_07                    => l_prmtr_07_tab(l_count)
1597                  ,p_prmtr_10                    => p_new_rec.update_mode
1598                  ,p_person_id                   => l_relationship
1599                  ,p_business_group_id           => p_new_rec.business_group_id
1600                  ,p_object_version_number       => l_object_version_number
1601                  ,p_effective_date              => p_new_rec.effective_start_date
1602                  ,p_old_val1                    => l_old_val1(l_count)
1603                  ,p_old_val2                    => l_old_val2(l_count)
1604                  ,p_old_val3                    => l_old_val3(l_count)
1605                  ,p_old_val4                    => l_old_val4(l_count)
1606                  ,p_old_val5                    => l_old_val5(l_count)
1607                  ,p_old_val6                    => l_old_val6(l_count)
1608                  ,p_new_val1                    => l_new_val1(l_count)
1609                  ,p_new_val2                    => l_new_val2(l_count)
1610                  ,p_new_val3                    => l_new_val3(l_count)
1611                  ,p_new_val4                    => l_new_val4(l_count)
1612                  ,p_new_val5                    => l_new_val5(l_count)
1613                  ,p_new_val6                    => l_new_val6(l_count)
1614                  );
1615               end if;
1616           end loop;
1617        end if;
1618        ------
1619 
1620     end if;
1621 
1622     -- the counter logic changed here, cause the person id may change for every row
1623 
1624     open c_con_relationship(p_new_rec.person_id , p_new_rec.effective_start_date );
1625     Loop
1626        fetch c_con_relationship into l_contact,l_relationship , l_person_type ;
1627        Exit When  c_con_relationship%notfound ;
1628        hr_utility.set_location ( 'Contact person ' || l_relationship , 11 ) ;
1629        hr_utility.set_location ( 'relation type ' || l_person_type , 11 ) ;
1630        l_ini_tab_counter :=  1 ;
1631        l_tab_counter     :=  0 ;
1632        l_cont_chg_evt_tab.delete   ;
1633 
1634        if nvl(p_old_rec.full_name, '$$$$$&&&')
1635           <> nvl(p_new_rec.full_name, '$$$$$&&&') then
1636           l_tab_counter := l_tab_counter + 1;
1637           l_cont_chg_evt_tab(l_tab_counter) := 'CCNFN';
1638           l_prmtr_01_tab(l_tab_counter) := l_contact;
1639           l_prmtr_02_tab(l_tab_counter) := l_person_type;
1640           l_prmtr_03_tab(l_tab_counter) := null;
1641           l_prmtr_04_tab(l_tab_counter) := null;
1642           l_prmtr_05_tab(l_tab_counter) := null;
1643           l_prmtr_06_tab(l_tab_counter) := null;
1644           l_prmtr_07_tab(l_tab_counter) := null;
1645           l_old_val1(l_tab_counter) := substr(p_old_rec.full_name,1,240);
1646           l_old_val2(l_tab_counter) := p_old_rec.title;
1647           l_old_val3(l_tab_counter) := p_old_rec.first_name;
1648           l_old_val4(l_tab_counter) := p_old_rec.middle_names;
1649           l_old_val5(l_tab_counter) := p_old_rec.last_name;
1650           l_old_val6(l_tab_counter) := p_old_rec.suffix;
1651           l_new_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1652           l_new_val2(l_tab_counter) := p_new_rec.title;
1653           l_new_val3(l_tab_counter) := p_new_rec.first_name;
1654           l_new_val4(l_tab_counter) := p_new_rec.middle_names;
1655           l_new_val5(l_tab_counter) := p_new_rec.last_name;
1656           l_new_val6(l_tab_counter) := p_new_rec.suffix;
1657        end if;
1658        if nvl(p_old_rec.date_of_birth, to_date('01/01/0001', 'dd/mm/yyyy'))
1659           <> nvl(p_new_rec.date_of_birth, to_date('01/01/0001', 'dd/mm/yyyy')) then
1660           l_tab_counter := l_tab_counter + 1;
1661           l_cont_chg_evt_tab(l_tab_counter) := 'CCNDB';
1662           l_prmtr_01_tab(l_tab_counter) := l_contact;
1663           l_prmtr_02_tab(l_tab_counter) := l_person_type;
1664           l_prmtr_03_tab(l_tab_counter) := null;
1665           l_prmtr_04_tab(l_tab_counter) := null;
1666           l_prmtr_05_tab(l_tab_counter) := null;
1667           l_prmtr_06_tab(l_tab_counter) := null;
1668           l_prmtr_07_tab(l_tab_counter) := null;
1669           l_old_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1670           l_new_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1671           l_old_val2(l_tab_counter) := to_char(p_old_rec.date_of_birth, 'mm/dd/yyyy');
1672           l_new_val2(l_tab_counter) := to_char(p_new_rec.date_of_birth, 'mm/dd/yyyy');
1673           l_old_val3(l_tab_counter) := null;
1674           l_old_val4(l_tab_counter) := null;
1675           l_old_val5(l_tab_counter) := null;
1676           l_old_val6(l_tab_counter) := null;
1677           l_new_val3(l_tab_counter) := null;
1678           l_new_val4(l_tab_counter) := null;
1679           l_new_val5(l_tab_counter) := null;
1680           l_new_val6(l_tab_counter) := null;
1681        end if;
1682        if nvl(p_old_rec.date_of_death, to_date('01/01/0001', 'dd/mm/yyyy'))
1683           <> nvl(p_new_rec.date_of_death, to_date('01/01/0001', 'dd/mm/yyyy')) then
1684           l_tab_counter := l_tab_counter + 1;
1685           l_cont_chg_evt_tab(l_tab_counter) := 'CCNDD';
1686           l_prmtr_01_tab(l_tab_counter) := l_contact;
1687           l_prmtr_02_tab(l_tab_counter) := l_person_type;
1688           l_prmtr_03_tab(l_tab_counter) := null;
1689           l_prmtr_04_tab(l_tab_counter) := null;
1690           l_prmtr_05_tab(l_tab_counter) := null;
1691           l_prmtr_06_tab(l_tab_counter) := null;
1692           l_prmtr_07_tab(l_tab_counter) := null;
1693           l_old_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1694           l_new_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1695           l_old_val2(l_tab_counter) := to_char(p_old_rec.date_of_death, 'mm/dd/yyyy');
1696           l_new_val2(l_tab_counter) := to_char(p_new_rec.date_of_death, 'mm/dd/yyyy');
1697           l_old_val3(l_tab_counter) := null;
1698           l_old_val4(l_tab_counter) := null;
1699           l_old_val5(l_tab_counter) := null;
1700           l_old_val6(l_tab_counter) := null;
1701           l_new_val3(l_tab_counter) := null;
1702           l_new_val4(l_tab_counter) := null;
1703           l_new_val5(l_tab_counter) := null;
1704           l_new_val6(l_tab_counter) := null;
1705        end if;
1706        if nvl(p_old_rec.national_identifier, '000-00-0000')
1707           <> nvl(p_new_rec.national_identifier, '000-00-0000') then
1708           l_tab_counter := l_tab_counter + 1;
1709           l_cont_chg_evt_tab(l_tab_counter) := 'CCNSS';
1710           l_prmtr_01_tab(l_tab_counter) := l_contact;
1711           l_prmtr_02_tab(l_tab_counter) := l_person_type;
1712           l_prmtr_03_tab(l_tab_counter) := null;
1713           l_prmtr_04_tab(l_tab_counter) := null;
1714           l_prmtr_05_tab(l_tab_counter) := null;
1715           l_prmtr_06_tab(l_tab_counter) := null;
1716           l_prmtr_07_tab(l_tab_counter) := null;
1717           l_old_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1718           l_new_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1719           l_old_val2(l_tab_counter) := p_old_rec.national_identifier;
1720           l_new_val2(l_tab_counter) := p_new_rec.national_identifier;
1721           l_old_val3(l_tab_counter) := null;
1722           l_old_val4(l_tab_counter) := null;
1723           l_old_val5(l_tab_counter) := null;
1724           l_old_val6(l_tab_counter) := null;
1725           l_new_val3(l_tab_counter) := null;
1726           l_new_val4(l_tab_counter) := null;
1727           l_new_val5(l_tab_counter) := null;
1728           l_new_val6(l_tab_counter) := null;
1729        end if;
1730        if nvl(p_old_rec.sex, '$')
1731           <> nvl(p_new_rec.sex, '$') then
1732           -- read gender from lookup table
1733           open c_lookup_value('SEX', p_old_rec.sex);
1734           fetch c_lookup_value into l_old_sex;
1735           close c_lookup_value;
1736           open c_lookup_value('SEX', p_new_rec.sex);
1737           fetch c_lookup_value into l_new_sex;
1738           close c_lookup_value;
1739 
1740           l_tab_counter := l_tab_counter + 1;
1741           l_cont_chg_evt_tab(l_tab_counter) := 'CCNGE';
1742           l_prmtr_01_tab(l_tab_counter) := l_contact;
1743           l_prmtr_02_tab(l_tab_counter) := l_person_type;
1744           l_prmtr_03_tab(l_tab_counter) := null;
1745           l_prmtr_04_tab(l_tab_counter) := null;
1746           l_prmtr_05_tab(l_tab_counter) := null;
1747           l_prmtr_06_tab(l_tab_counter) := null;
1748           l_prmtr_07_tab(l_tab_counter) := null;
1749           l_old_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1750           l_new_val1(l_tab_counter) := substr(p_new_rec.full_name,1,240);
1751           l_old_val2(l_tab_counter) := l_old_sex;
1752           l_new_val2(l_tab_counter) := l_new_sex;
1753           l_old_val3(l_tab_counter) := null;
1754           l_old_val4(l_tab_counter) := null;
1755           l_old_val5(l_tab_counter) := null;
1756           l_old_val6(l_tab_counter) := null;
1757           l_new_val3(l_tab_counter) := null;
1758           l_new_val4(l_tab_counter) := null;
1759           l_new_val5(l_tab_counter) := null;
1760           l_new_val6(l_tab_counter) := null;
1761        end if;
1762        -- insert the row for every relation , the person id may change for every row
1763        for l_count in 1  .. l_tab_counter  loop
1764 
1765            hr_utility.set_location ( ' change event  ' || l_cont_chg_evt_tab(l_count)  , 11 ) ;
1766            if change_event_is_enabled(l_cont_chg_evt_tab(l_count),p_new_rec.effective_start_date)
1767               then
1768 
1769               ben_ext_chg_evt_api.create_ext_chg_evt
1770                  (p_validate                    => FALSE
1771                  ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
1772                  ,p_chg_evt_cd                  => l_cont_chg_evt_tab(l_count)
1773                  ,p_chg_eff_dt                  => p_new_rec.effective_start_date
1774                  ,p_prmtr_01                    => l_prmtr_01_tab(l_count)
1775                  ,p_prmtr_02                    => l_prmtr_02_tab(l_count)
1776                  ,p_prmtr_03                    => l_prmtr_03_tab(l_count)
1777                  ,p_prmtr_04                    => l_prmtr_04_tab(l_count)
1778                  ,p_prmtr_05                    => l_prmtr_05_tab(l_count)
1779                  ,p_prmtr_06                    => to_char(p_new_rec.person_id)
1780                  ,p_prmtr_07                    => l_prmtr_07_tab(l_count)
1781                  ,p_prmtr_10                    => p_new_rec.update_mode
1782                  ,p_person_id                   => l_relationship
1783                  ,p_business_group_id           => p_new_rec.business_group_id
1784                  ,p_object_version_number       => l_object_version_number
1785                  ,p_effective_date              => p_new_rec.effective_start_date
1786                  ,p_old_val1                    => l_old_val1(l_count)
1787                  ,p_old_val2                    => l_old_val2(l_count)
1788                  ,p_old_val3                    => l_old_val3(l_count)
1789                  ,p_old_val4                    => l_old_val4(l_count)
1790                  ,p_old_val5                    => l_old_val5(l_count)
1791                  ,p_old_val6                    => l_old_val6(l_count)
1792                  ,p_new_val1                    => l_new_val1(l_count)
1793                  ,p_new_val2                    => l_new_val2(l_count)
1794                  ,p_new_val3                    => l_new_val3(l_count)
1795                  ,p_new_val4                    => l_new_val4(l_count)
1796                  ,p_new_val5                    => l_new_val5(l_count)
1797                  ,p_new_val6                    => l_new_val6(l_count)
1798                  );
1799            end if;
1800        end loop;
1801 
1802     End Loop ;
1803     close c_con_relationship ;
1804     ----
1805  end if;
1806 --
1807   hr_utility.set_location('Exiting:'|| l_proc, 99);
1808 --
1809 end log_per_chg;
1810 --
1811 procedure log_cont_chg
1812           (
1813            p_old_rec   in  g_cont_rec_type
1814           ,p_new_rec   in  g_cont_rec_type
1815           ) is
1816    --
1817   l_proc               varchar2(100) := 'ben_ext_chlg.log_cont_chg';
1818   l_tab_counter        binary_integer := 0;
1819   l_old_contact_type                   varchar2(100) ;
1820   l_new_contact_type                   varchar2(100) ;
1821   l_person_type                        per_person_types.system_person_type%type;
1822   l_full_name                          per_all_people_f.full_name%type ;
1823   l_chg_evt_tab           g_char_tab_type;
1824   l_chg_eff_tab           g_date_tab_type;
1825   l_prmtr_01_tab          g_char_tab_type;
1826   l_prmtr_02_tab          g_char_tab_type;
1827   l_prmtr_03_tab          g_char_tab_type;
1828   l_prmtr_04_tab          g_char_tab_type;
1829   l_prmtr_05_tab          g_char_tab_type;
1830   l_prmtr_06_tab          g_char_tab_type;
1831   l_prmtr_07_tab          g_char_tab_type;
1832   l_old_val1              g_old_val;
1833   l_old_val2              g_old_val;
1834   l_old_val3              g_old_val;
1835   l_old_val4              g_old_val;
1836   l_old_val5              g_old_val;
1837   l_old_val6              g_old_val;
1838   l_new_val1              g_new_val;
1839   l_new_val2              g_new_val;
1840   l_new_val3              g_new_val;
1841   l_new_val4              g_new_val;
1842   l_new_val5              g_new_val;
1843   l_new_val6              g_new_val;
1844   l_chg_eff_dt            date;
1845   l_count                 number;
1846   l_ext_chg_evt_log_id    number;
1847   l_object_version_number number;
1848   --
1849   cursor c_person_type(p_person_id number) is
1850   select ppt.system_person_type,ppf.full_name
1851   from   per_person_types ppt,per_all_people_f ppf
1852   where  ppf.person_type_id = ppt.person_type_id
1853   and    ppf.person_id = p_person_id;
1854   --
1855   cursor c_lookup_value
1856     (p_lookup_code hr_lookups.lookup_code%type
1857     )
1858   is
1859   select meaning
1860   from hr_lookups hl
1861   where hl.lookup_type = 'CONTACT'
1862   and hl.lookup_code = p_lookup_code;
1863 begin
1864 --
1865   hr_utility.set_location('Entering:'|| l_proc, 10);
1866 --
1867   open c_person_type(p_new_rec.contact_person_id);
1868   fetch c_person_type into l_person_type,l_full_name;
1869   if c_person_type%notfound then
1870      close c_person_type;
1871   else
1872 
1873      close c_person_type;
1874      open c_lookup_value( p_old_rec.contact_type);
1875      fetch c_lookup_value into l_old_contact_type;
1876      close c_lookup_value;
1877      hr_utility.set_location ( 'old contact  ' || l_old_contact_type,99) ;
1878      open c_lookup_value( p_new_rec.contact_type);
1879      fetch c_lookup_value into l_new_contact_type;
1880      close c_lookup_value;
1881      hr_utility.set_location ( 'new contact  ' || l_new_contact_type,99) ;
1882 
1883      if l_person_type = 'OTHER' then
1884         l_tab_counter := l_tab_counter + 1;
1885 
1886         hr_utility.set_location ( 'change evnt ' ,99) ;
1887         --
1888         -- Handle web case where date_start is null
1889         --
1890         l_chg_evt_tab(l_tab_counter) := 'CCRE';
1891         l_chg_eff_tab(l_tab_counter) := nvl(p_new_rec.date_start,sysdate);
1892         l_prmtr_01_tab(l_tab_counter) := null;
1893         l_prmtr_02_tab(l_tab_counter) := null;
1894         l_prmtr_03_tab(l_tab_counter) := null;
1895         l_prmtr_04_tab(l_tab_counter) := null;
1896         l_prmtr_05_tab(l_tab_counter) := null;
1897         l_prmtr_06_tab(l_tab_counter) := null;
1898         l_prmtr_07_tab(l_tab_counter) := null;
1899         l_old_val1(l_tab_counter) := substr(l_full_name,1,240);
1900         l_new_val1(l_tab_counter) := substr(l_full_name,1,240);
1901         l_old_val2(l_tab_counter) := l_old_contact_type;
1902         l_new_val2(l_tab_counter) := l_new_contact_type;
1903         l_old_val3(l_tab_counter) := null;
1904         l_old_val4(l_tab_counter) := null;
1905         l_old_val5(l_tab_counter) := null;
1906         l_old_val6(l_tab_counter) := null;
1907         l_new_val3(l_tab_counter) := null;
1908         l_new_val4(l_tab_counter) := null;
1909         l_new_val5(l_tab_counter) := null;
1910         l_new_val6(l_tab_counter) := null;
1911      end if ;
1912      --- for every person contact changes
1913      l_tab_counter := l_tab_counter + 1;
1914 
1915      hr_utility.set_location ( 'change evnt ' ,99) ;
1916      --
1917      -- Handle web case where date_start is null
1918      --
1919      l_chg_evt_tab(l_tab_counter) := 'CCNRE';
1920      l_chg_eff_tab(l_tab_counter) := nvl(p_new_rec.date_start,sysdate);
1921      l_prmtr_01_tab(l_tab_counter) := null;
1922      l_prmtr_02_tab(l_tab_counter) := null;
1923      l_prmtr_03_tab(l_tab_counter) := null;
1924      l_prmtr_04_tab(l_tab_counter) := null;
1925      l_prmtr_05_tab(l_tab_counter) := null;
1926      l_prmtr_06_tab(l_tab_counter) := null;
1927      l_prmtr_07_tab(l_tab_counter) := null;
1928      l_old_val1(l_tab_counter) := substr(l_full_name,1,240);
1929      l_new_val1(l_tab_counter) := substr(l_full_name,1,240);
1930      l_old_val2(l_tab_counter) := l_old_contact_type;
1931      l_new_val2(l_tab_counter) := l_new_contact_type;
1932      l_old_val3(l_tab_counter) := null;
1933      l_old_val4(l_tab_counter) := null;
1934      l_old_val5(l_tab_counter) := null;
1935      l_old_val6(l_tab_counter) := null;
1936      l_new_val3(l_tab_counter) := null;
1937      l_new_val4(l_tab_counter) := null;
1938      l_new_val5(l_tab_counter) := null;
1939      l_new_val6(l_tab_counter) := null;
1940 
1941   end if;
1942   for l_count in 1..l_chg_evt_tab.count loop
1943     if change_event_is_enabled(l_chg_evt_tab(l_count),trunc(sysdate)) then
1944        hr_utility.set_location ( 'calling api ' ,99) ;
1945        ben_ext_chg_evt_api.create_ext_chg_evt
1946         (p_validate                    => FALSE
1947         ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
1948         ,p_chg_evt_cd                  => l_chg_evt_tab(l_count)
1949         ,p_chg_eff_dt                  => l_chg_eff_tab(l_count)
1950         ,p_prmtr_01                    => l_prmtr_01_tab(l_count)
1951         ,p_prmtr_02                    => l_prmtr_02_tab(l_count)
1952         ,p_prmtr_03                    => l_prmtr_03_tab(l_count)
1953         ,p_prmtr_04                    => l_prmtr_04_tab(l_count)
1954         ,p_prmtr_05                    => l_prmtr_05_tab(l_count)
1955         ,p_prmtr_06                    => l_prmtr_06_tab(l_count)
1956         ,p_prmtr_07                    => l_prmtr_07_tab(l_count)
1957         ,p_person_id                   => p_new_rec.person_id
1958         ,p_business_group_id           => p_new_rec.business_group_id
1959         ,p_object_version_number       => l_object_version_number
1960         ,p_effective_date              => trunc(sysdate)
1961         ,p_old_val1                    => l_old_val1(l_count)
1962         ,p_old_val2                    => l_old_val2(l_count)
1963         ,p_old_val3                    => l_old_val3(l_count)
1964         ,p_old_val4                    => l_old_val4(l_count)
1965         ,p_old_val5                    => l_old_val5(l_count)
1966         ,p_old_val6                    => l_old_val6(l_count)
1967         ,p_new_val1                    => l_new_val1(l_count)
1968         ,p_new_val2                    => l_new_val2(l_count)
1969         ,p_new_val3                    => l_new_val3(l_count)
1970         ,p_new_val4                    => l_new_val4(l_count)
1971         ,p_new_val5                    => l_new_val5(l_count)
1972         ,p_new_val6                    => l_new_val6(l_count)
1973         );
1974     end if;
1975  end loop;
1976 --
1977  hr_utility.set_location('Exiting:'|| l_proc, 99);
1978 --
1979 end log_cont_chg;
1980 --
1981 procedure log_add_chg
1982           (p_event       in  varchar2
1983           ,p_old_rec   in  g_add_rec_type
1984           ,p_new_rec   in  g_add_rec_type
1985           ) is
1986    --
1987    l_proc               varchar2(100) := 'ben_ext_chlg.log_add_chg';
1988    --
1989   l_chg_evt_tab           g_char_tab_type;
1990   l_chg_eff_tab           g_date_tab_type;
1991   l_prmtr_01_tab          g_char_tab_type;
1992   l_prmtr_02_tab          g_char_tab_type;
1993   l_prmtr_03_tab          g_char_tab_type;
1994   l_prmtr_04_tab          g_char_tab_type;
1995   l_prmtr_05_tab          g_char_tab_type;
1996   l_prmtr_06_tab          g_char_tab_type;
1997   l_prmtr_07_tab          g_char_tab_type;
1998   l_old_val1              g_old_val;
1999   l_old_val2              g_old_val;
2000   l_old_val3              g_old_val;
2001   l_old_val4              g_old_val;
2002   l_old_val5              g_old_val;
2003   l_old_val6              g_old_val;
2004   l_new_val1              g_new_val;
2005   l_new_val2              g_new_val;
2006   l_new_val3              g_new_val;
2007   l_new_val4              g_new_val;
2008   l_new_val5              g_new_val;
2009   l_new_val6              g_new_val;
2010   l_tab_counter           binary_integer := 0;
2011   l_ini_tab_counter       binary_integer ;
2012   l_chg_eff_dt            date;
2013   l_chg_occured           boolean := FALSE;
2014   l_chg_mail_add          boolean := FALSE;
2015   l_count                 number;
2016   l_ext_chg_evt_log_id    number;
2017   l_object_version_number number;
2018   l_person_id             number;
2019   l_business_group_id     number;
2020   l_relationship          per_all_people_f.person_id%type;
2021   l_name                  per_all_people_f.full_name%type;
2022   l_contact               per_contact_relationships.contact_relationship_id%type;
2023   --
2024   cursor c_relationship(p_person_id number) is
2025   SELECT pcr.contact_relationship_id,pcr.person_id,ppf.full_name
2026   FROM   per_contact_relationships pcr,
2027          per_all_people_f ppf,
2028          per_person_types ppt,
2029          hr_lookups hl
2030   WHERE  pcr.contact_person_id = p_person_id
2031   AND    ppf.person_id = p_person_id
2032   AND    ppf.person_type_id = ppt.person_type_id
2033   AND    ppt.system_person_type = 'OTHER'
2034   AND    pcr.contact_type = hl.lookup_code
2035   AND    hl.lookup_type = 'CONTACT';
2036 
2037   cursor c_con_relationship(p_person_id number,p_effective_date date) is
2038   SELECT pcr.contact_relationship_id,pcr.person_id,ppf.full_name
2039   FROM   per_contact_relationships pcr,
2040          per_all_people_f ppf,
2041          hr_lookups hl
2042   WHERE  pcr.contact_person_id = p_person_id
2043   AND    ppf.person_id = p_person_id
2044   AND    pcr.contact_type = hl.lookup_code
2045   AND    hl.lookup_type = 'CONTACT'
2046   AND    pcr.personal_flag = 'Y'
2047   and    p_effective_date between  pcr.date_start and nvl(pcr.date_end, p_effective_date)
2048 
2049   ;
2050 --
2051 begin
2052 --
2053   hr_utility.set_location('Entering:'|| l_proc, 10);
2054 --
2055   if p_event = 'INSERT' then
2056     l_person_id         := p_new_rec.person_id;
2057     l_business_group_id := p_new_rec.business_group_id;
2058     --
2059     if p_new_rec.primary_flag = 'Y' then
2060        -- if this is the first primary address then 'APA' (add primary address)
2061        -- if it is not the first primary address then 'COPR'
2062        --(change of primary address)
2063        if g_prev_upd_adr_person_id  = p_new_rec.person_id and
2064           g_prev_upd_adr_primary_flag = p_new_rec.primary_flag and
2065           g_prev_upd_adr_to_date = (p_new_rec.date_from-1) then
2066 
2067          l_chg_eff_dt := p_new_rec.date_from;
2068          l_tab_counter := l_tab_counter + 1;
2069          l_chg_evt_tab(l_tab_counter) := 'COPR';
2070          l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2071          l_prmtr_01_tab(l_tab_counter) := p_new_rec.address_id;
2072          l_prmtr_02_tab(l_tab_counter) := g_prev_upd_adr_address_id;
2073          l_prmtr_03_tab(l_tab_counter) := null;
2074          l_prmtr_04_tab(l_tab_counter) := null;
2075          l_prmtr_05_tab(l_tab_counter) := null;
2076          l_prmtr_06_tab(l_tab_counter) := null;
2077          l_prmtr_07_tab(l_tab_counter) := null;
2078          l_old_val1(l_tab_counter)     :=rtrim(substrb(g_prev_upd_adr_address_line1||' '||
2079                                       g_prev_upd_adr_address_line2||' '||
2080                                       g_prev_upd_adr_address_line3,1,600));
2081          l_old_val2(l_tab_counter) := g_prev_upd_adr_town_or_city;
2082          l_old_val3(l_tab_counter) := g_prev_upd_adr_region_2;
2083          l_old_val4(l_tab_counter) := g_prev_upd_adr_postal_code;
2084          l_old_val5(l_tab_counter) := g_prev_upd_adr_region_3;
2085          l_old_val6(l_tab_counter) := g_prev_upd_adr_region_1;
2086          l_new_val1(l_tab_counter) := rtrim(substrb(p_new_rec.address_line1||' '||
2087                                       p_new_rec.address_line2||' '||
2088                                       p_new_rec.address_line3,1,600));
2089          l_new_val2(l_tab_counter) := p_new_rec.town_or_city;
2090          l_new_val3(l_tab_counter) := p_new_rec.region_2;
2091          l_new_val4(l_tab_counter) := p_new_rec.postal_code;
2092          l_new_val5(l_tab_counter) := p_new_rec.region_3;
2093          l_new_val6(l_tab_counter) := p_new_rec.region_1;
2094        else
2095          l_chg_eff_dt := p_new_rec.date_from;
2096          l_tab_counter := l_tab_counter + 1;
2097          l_chg_evt_tab(l_tab_counter) := 'APA';
2098          l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2099          l_prmtr_01_tab(l_tab_counter) := p_new_rec.address_id;
2100          l_prmtr_02_tab(l_tab_counter) := null;
2101          l_prmtr_03_tab(l_tab_counter) := null;
2102          l_prmtr_04_tab(l_tab_counter) := null;
2103          l_prmtr_05_tab(l_tab_counter) := null;
2104          l_prmtr_06_tab(l_tab_counter) := null;
2105          l_prmtr_07_tab(l_tab_counter) := null;
2106          l_old_val1(l_tab_counter) := null;
2107          l_old_val2(l_tab_counter) := null;
2108          l_old_val3(l_tab_counter) := null;
2109          l_old_val4(l_tab_counter) := null;
2110          l_old_val5(l_tab_counter) := null;
2111          l_old_val6(l_tab_counter) := null;
2112          l_new_val1(l_tab_counter) := rtrim(substrb( p_new_rec.address_line1||' '||
2113                                       p_new_rec.address_line2||' '||
2114                                       p_new_rec.address_line3 , 1,600));
2115          l_new_val2(l_tab_counter) := p_new_rec.town_or_city;
2116          l_new_val3(l_tab_counter) := p_new_rec.region_2;
2117          l_new_val4(l_tab_counter) := p_new_rec.postal_code;
2118          l_new_val5(l_tab_counter) := p_new_rec.region_3;
2119          l_new_val6(l_tab_counter) := p_new_rec.region_1;
2120        end if;
2121     --
2122     --record change event(update contact's primary address) for participant.
2123     --- create only for the person, his person type is contact
2124     open c_relationship(p_new_rec.person_id);
2125     fetch c_relationship into l_contact,l_relationship,l_name;
2126     if c_relationship%notfound then
2127     close c_relationship;
2128     elsif c_relationship%found then
2129       close c_relationship;
2130       if g_prev_upd_adr_person_id  = p_new_rec.person_id and
2131           g_prev_upd_adr_primary_flag = p_new_rec.primary_flag and
2132           g_prev_upd_adr_to_date = (p_new_rec.date_from-1) then
2133          l_chg_eff_dt := p_new_rec.date_from;
2134          l_tab_counter := l_tab_counter + 1;
2135          l_chg_evt_tab(l_tab_counter) := 'CCPA';
2136          l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2137          l_prmtr_01_tab(l_tab_counter) := to_char(l_contact);
2138          l_prmtr_02_tab(l_tab_counter) := p_new_rec.address_id;
2139          l_prmtr_03_tab(l_tab_counter) := g_prev_upd_adr_address_id;
2140          l_prmtr_04_tab(l_tab_counter) := null;
2141          l_prmtr_05_tab(l_tab_counter) := null;
2142          l_prmtr_06_tab(l_tab_counter) := null;
2143          l_prmtr_07_tab(l_tab_counter) := null;
2144          l_old_val1(l_tab_counter) := rtrim(substrb(l_name,1,240));
2145          l_new_val1(l_tab_counter) := rtrim(substrb(l_name,1,240));
2146          l_old_val2(l_tab_counter) := rtrim(substrb( g_prev_upd_adr_address_line1||' '||
2147                                       g_prev_upd_adr_address_line2||' '||
2148                                       g_prev_upd_adr_address_line3,1,600));
2149          l_old_val3(l_tab_counter) := g_prev_upd_adr_town_or_city;
2150          l_old_val4(l_tab_counter) := g_prev_upd_adr_region_2;
2151          l_old_val5(l_tab_counter) := g_prev_upd_adr_postal_code;
2152          l_old_val6(l_tab_counter) := g_prev_upd_adr_region_3;
2153          l_new_val2(l_tab_counter) := rtrim(substrb( p_new_rec.address_line1||' '||
2154                                       p_new_rec.address_line2||' '||
2155                                       p_new_rec.address_line3,1,600));
2156          l_new_val3(l_tab_counter) := p_new_rec.town_or_city;
2157          l_new_val4(l_tab_counter) := p_new_rec.region_2;
2158          l_new_val5(l_tab_counter) := p_new_rec.postal_code;
2159          l_new_val6(l_tab_counter) := p_new_rec.region_3;
2160        end if;
2161      end if;
2162 
2163      --- create log for all the person from relationship
2164     open c_con_relationship(p_new_rec.person_id,l_chg_eff_dt);
2165     Loop
2166        fetch c_con_relationship into l_contact,l_relationship,l_name;
2167        Exit when c_con_relationship%notfound ;
2168        if g_prev_upd_adr_person_id  = p_new_rec.person_id and
2169           g_prev_upd_adr_primary_flag = p_new_rec.primary_flag and
2170           g_prev_upd_adr_to_date = (p_new_rec.date_from-1) then
2171           l_chg_eff_dt := p_new_rec.date_from;
2172           l_tab_counter := l_tab_counter + 1;
2173           l_chg_evt_tab(l_tab_counter) := 'CCNPA';
2174           l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2175           l_prmtr_01_tab(l_tab_counter) := to_char(l_contact);
2176           l_prmtr_02_tab(l_tab_counter) := p_new_rec.address_id;
2177           l_prmtr_03_tab(l_tab_counter) := g_prev_upd_adr_address_id;
2178           l_prmtr_04_tab(l_tab_counter) := null;
2179           l_prmtr_05_tab(l_tab_counter) := null;
2180           l_prmtr_06_tab(l_tab_counter) := null;
2181           l_prmtr_07_tab(l_tab_counter) := l_relationship;
2182           l_old_val1(l_tab_counter) := rtrim(substrb(l_name,1,240));
2183           l_new_val1(l_tab_counter) := rtrim(substrb(l_name,1,240));
2184           l_old_val2(l_tab_counter) := rtrim(substrb( g_prev_upd_adr_address_line1||' '||
2185                                        g_prev_upd_adr_address_line2||' '||
2186                                        g_prev_upd_adr_address_line3,1,600));
2187           l_old_val3(l_tab_counter) := g_prev_upd_adr_town_or_city;
2188           l_old_val4(l_tab_counter) := g_prev_upd_adr_region_2;
2189           l_old_val5(l_tab_counter) := g_prev_upd_adr_postal_code;
2190           l_old_val6(l_tab_counter) := g_prev_upd_adr_region_3;
2191           l_new_val2(l_tab_counter) := rtrim(substrb( p_new_rec.address_line1||' '||
2192                                        p_new_rec.address_line2||' '||
2193                                        p_new_rec.address_line3,1,600));
2194           l_new_val3(l_tab_counter) := p_new_rec.town_or_city;
2195           l_new_val4(l_tab_counter) := p_new_rec.region_2;
2196           l_new_val5(l_tab_counter) := p_new_rec.postal_code;
2197           l_new_val6(l_tab_counter) := p_new_rec.region_3;
2198        end if ;
2199           --- change of mailing address
2200        if (p_new_rec.address_type <> nvl(p_old_rec.address_type,'$$')
2201           and p_new_rec.address_type = 'M' ) OR
2202           (p_old_rec.address_type = 'M' and p_new_rec.date_to is null
2203           and p_old_rec.date_to is not null )  then
2204 
2205              l_chg_eff_dt := p_new_rec.date_from;
2206              l_tab_counter := l_tab_counter + 1;
2207              l_chg_evt_tab(l_tab_counter) := 'CCNMA';
2208              l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2209              l_prmtr_01_tab(l_tab_counter) := to_char(l_contact);
2210              l_prmtr_02_tab(l_tab_counter) := p_new_rec.address_id;
2211              l_prmtr_03_tab(l_tab_counter) := null;
2212              l_prmtr_04_tab(l_tab_counter) := null;
2213              l_prmtr_05_tab(l_tab_counter) := null;
2214              l_prmtr_06_tab(l_tab_counter) := null;
2215              l_prmtr_07_tab(l_tab_counter) := l_relationship;
2216              l_old_val1(l_tab_counter) := substr(l_name,1,240);
2217              l_new_val1(l_tab_counter) := substr(l_name,1,240);
2218              l_old_val2(l_tab_counter) := rtrim(substrb( p_old_rec.address_line1||' '||
2219                                           p_old_rec.address_line2||' '||
2220                                           p_old_rec.address_line3,1,600));
2221              l_old_val3(l_tab_counter) := p_old_rec.town_or_city;
2222              l_old_val4(l_tab_counter) := p_old_rec.region_2;
2223              l_old_val5(l_tab_counter) := p_old_rec.postal_code;
2224              l_old_val6(l_tab_counter) := p_old_rec.region_3;
2225              l_new_val2(l_tab_counter) := rtrim(substrb( p_new_rec.address_line1||' '||
2226                                           p_new_rec.address_line2||' '||
2227                                           p_new_rec.address_line3,1,600));
2228              l_new_val3(l_tab_counter) := p_new_rec.town_or_city;
2229              l_new_val4(l_tab_counter) := p_new_rec.region_2;
2230              l_new_val5(l_tab_counter) := p_new_rec.postal_code;
2231              l_new_val6(l_tab_counter) := p_new_rec.region_3;
2232 
2233         end if ;
2234 
2235      End Loop  ;
2236      close c_con_relationship;
2237 
2238 
2239 --Bug 4699556 removed the elseif for AMA and added the below statement
2240 -- so that if both APA and AMA are triggered at the same time both get logged.
2241    end if;
2242 --End Bug 4699556
2243     -- record change events for creation of mailing address
2244 
2245     if p_new_rec.address_type = 'M' then
2246         l_chg_eff_dt := p_new_rec.date_from;
2247         l_tab_counter := l_tab_counter + 1;
2248         l_chg_evt_tab(l_tab_counter) := 'AMA';
2249         l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2250         l_prmtr_01_tab(l_tab_counter) := p_new_rec.address_id;
2251         l_prmtr_02_tab(l_tab_counter) := null;
2252         l_prmtr_03_tab(l_tab_counter) := null;
2253         l_prmtr_04_tab(l_tab_counter) := null;
2254         l_prmtr_05_tab(l_tab_counter) := null;
2255         l_prmtr_06_tab(l_tab_counter) := null;
2256         l_prmtr_07_tab(l_tab_counter) := null;
2257         l_old_val1(l_tab_counter) := null;
2258         l_old_val2(l_tab_counter) := null;
2259         l_old_val3(l_tab_counter) := null;
2260         l_old_val4(l_tab_counter) := null;
2261         l_old_val5(l_tab_counter) := null;
2262         l_old_val6(l_tab_counter) := null;
2263         l_new_val1(l_tab_counter) :=  rtrim(substrb( p_new_rec.address_line1||' '||
2264                                      p_new_rec.address_line2||' '||
2265                                      p_new_rec.address_line3,1,600));
2266         l_new_val2(l_tab_counter) := p_new_rec.town_or_city;
2267         l_new_val3(l_tab_counter) := p_new_rec.region_2;
2268         l_new_val4(l_tab_counter) := p_new_rec.postal_code;
2269         l_new_val5(l_tab_counter) := p_new_rec.region_3;
2270         l_new_val6(l_tab_counter) := p_new_rec.region_1;
2271     --record change event(update contact's mailing address) for participant.
2272     open c_relationship(p_new_rec.person_id);
2273     fetch c_relationship into l_contact,l_relationship,l_name;
2274     if c_relationship%notfound then
2275       close c_relationship;
2276     elsif c_relationship%found then
2277       close c_relationship;
2278         l_chg_eff_dt := p_new_rec.date_from;
2279         l_tab_counter := l_tab_counter + 1;
2280         l_chg_evt_tab(l_tab_counter) := 'CCMA';
2281         l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2282         l_prmtr_01_tab(l_tab_counter) := to_char(l_contact);
2283         l_prmtr_02_tab(l_tab_counter) := p_new_rec.address_id;
2284         l_prmtr_03_tab(l_tab_counter) := null;
2285         l_prmtr_04_tab(l_tab_counter) := null;
2286         l_prmtr_05_tab(l_tab_counter) := null;
2287         l_prmtr_06_tab(l_tab_counter) := null;
2288         l_prmtr_07_tab(l_tab_counter) := l_relationship;
2289         l_old_val1(l_tab_counter) := substr(l_name,1,240);
2290         l_new_val1(l_tab_counter) := substr(l_name,1,240);
2291         l_old_val2(l_tab_counter) := null;
2292         l_old_val3(l_tab_counter) := null;
2293         l_old_val4(l_tab_counter) := null;
2294         l_old_val5(l_tab_counter) := null;
2295         l_old_val6(l_tab_counter) := null;
2296         l_new_val2(l_tab_counter) := rtrim(substrb( p_new_rec.address_line1||' '||
2297                                      p_new_rec.address_line2||' '||
2298                                      p_new_rec.address_line3,1,600));
2299         l_new_val3(l_tab_counter) := p_new_rec.town_or_city;
2300         l_new_val4(l_tab_counter) := p_new_rec.region_2;
2301         l_new_val5(l_tab_counter) := p_new_rec.postal_code;
2302         l_new_val6(l_tab_counter) := p_new_rec.region_3;
2303     end if;
2304   end if;
2305     --
2306     --
2307   elsif p_event = 'DELETE' then
2308     l_person_id := p_old_rec.person_id;
2309     l_business_group_id := p_old_rec.business_group_id;
2310     --
2311     -- record change events for deletion of mailing address
2312     if p_old_rec.address_type = 'M' and p_old_rec.primary_flag = 'N'
2313         and p_old_rec.date_to is null then
2314         l_chg_eff_dt:= trunc(sysdate);
2315         l_tab_counter := l_tab_counter + 1;
2316         l_chg_evt_tab(l_tab_counter) := 'DMA';
2317         l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2318         l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2319         l_prmtr_02_tab(l_tab_counter) := null;
2320         l_prmtr_03_tab(l_tab_counter) := null;
2321         l_prmtr_04_tab(l_tab_counter) := null;
2322         l_prmtr_05_tab(l_tab_counter) := null;
2323         l_prmtr_06_tab(l_tab_counter) := null;
2324         l_prmtr_07_tab(l_tab_counter) := null;
2325         l_old_val1(l_tab_counter) :=  rtrim(substrb( p_old_rec.address_line1||' '||
2326                                      p_old_rec.address_line2||' '||
2327                                      p_old_rec.address_line3,1,600));
2328         l_old_val2(l_tab_counter) := p_old_rec.town_or_city;
2329         l_old_val3(l_tab_counter) := p_old_rec.region_2;
2330         l_old_val4(l_tab_counter) := p_old_rec.postal_code;
2331         l_old_val5(l_tab_counter) := p_old_rec.region_3;
2332         l_old_val6(l_tab_counter) := p_old_rec.region_1;
2333         l_new_val1(l_tab_counter) := null;
2334         l_new_val2(l_tab_counter) := null;
2335         l_new_val3(l_tab_counter) := null;
2336         l_new_val4(l_tab_counter) := null;
2337         l_new_val5(l_tab_counter) := null;
2338         l_new_val6(l_tab_counter) := null;
2339     end if;
2340     --
2341 --
2342   elsif p_event = 'UPDATE' then
2343   -- cache this data for later use.
2344   hr_utility.set_location(' in address changes ' , 673);
2345   g_prev_upd_adr_person_id       :=    p_new_rec.person_id;
2346   g_prev_upd_adr_primary_flag    :=    p_new_rec.primary_flag;
2347   g_prev_upd_adr_to_date         :=    p_new_rec.date_to;
2348   g_prev_upd_adr_address_line1   :=    p_new_rec.address_line1;
2349   g_prev_upd_adr_address_line2   :=    p_new_rec.address_line2;
2350   g_prev_upd_adr_address_line3   :=    p_new_rec.address_line3;
2351   g_prev_upd_adr_country         :=    p_new_rec.country;
2352   g_prev_upd_adr_postal_code     :=    p_new_rec.postal_code;
2353   g_prev_upd_adr_region_1        :=    p_new_rec.region_1;
2354   g_prev_upd_adr_region_2        :=    p_new_rec.region_2;
2355   g_prev_upd_adr_region_3        :=    p_new_rec.region_3;
2356   g_prev_upd_adr_town_or_city    :=    p_new_rec.town_or_city;
2357   g_prev_upd_adr_address_id      :=    p_new_rec.address_id;
2358   --
2359 
2360   l_person_id := p_new_rec.person_id;
2361   l_business_group_id := p_new_rec.business_group_id;
2362     --
2363     if p_old_rec.primary_flag = p_new_rec.primary_flag
2364        and p_new_rec.primary_flag = 'Y' and p_old_rec.date_to is null then
2365 
2366       l_chg_eff_dt := p_new_rec.date_from;
2367       if nvl(p_old_rec.address_line1, 'address_line1')
2368          <> nvl(p_new_rec.address_line1, 'address_line1')
2369          or
2370          nvl(p_old_rec.address_line2, 'address_line2')
2371          <> nvl(p_new_rec.address_line2, 'address_line2')
2372          or
2373          nvl(p_old_rec.address_line3, 'address_line3')
2374          <> nvl(p_new_rec.address_line3, 'address_line3')
2375          then
2376           l_chg_occured := TRUE;
2377           l_tab_counter := l_tab_counter + 1;
2378           l_chg_evt_tab(l_tab_counter) := 'CORS';
2379           l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2380           l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2381           l_prmtr_02_tab(l_tab_counter) := null;
2382           l_prmtr_03_tab(l_tab_counter) := null;
2383           l_prmtr_04_tab(l_tab_counter) := null;
2384           l_prmtr_05_tab(l_tab_counter) := null;
2385           l_prmtr_06_tab(l_tab_counter) := null;
2386           l_prmtr_07_tab(l_tab_counter) := null;
2387           l_old_val1(l_tab_counter) := rtrim(substrb( p_old_rec.address_line1||' '||
2388                                        p_old_rec.address_line2||' '||
2389                                        p_old_rec.address_line3,1,600));
2390           l_old_val2(l_tab_counter) := null;
2391           l_old_val3(l_tab_counter) := null;
2392           l_old_val4(l_tab_counter) := null;
2393           l_old_val5(l_tab_counter) := null;
2394           l_old_val6(l_tab_counter) := null;
2395           l_new_val1(l_tab_counter) :=  rtrim(substrb( p_new_rec.address_line1||' '||
2396                                        p_new_rec.address_line2||' '||
2397                                        p_new_rec.address_line3,1,600));
2398           l_new_val2(l_tab_counter) := null;
2399           l_new_val3(l_tab_counter) := null;
2400           l_new_val4(l_tab_counter) := null;
2401           l_new_val5(l_tab_counter) := null;
2402           l_new_val6(l_tab_counter) := null;
2403       end if;
2404       if upper(nvl(p_old_rec.postal_code, 'postal_code'))
2405          <> upper(nvl(p_new_rec.postal_code, 'postal_code')) then
2406           l_chg_occured := TRUE;
2407           l_tab_counter := l_tab_counter + 1;
2408           l_chg_evt_tab(l_tab_counter) := 'CORP';
2409           l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2410           l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2411           l_prmtr_02_tab(l_tab_counter) := null;
2412           l_prmtr_03_tab(l_tab_counter) := null;
2413           l_prmtr_04_tab(l_tab_counter) := null;
2414           l_prmtr_05_tab(l_tab_counter) := null;
2415           l_prmtr_06_tab(l_tab_counter) := null;
2416           l_prmtr_07_tab(l_tab_counter) := null;
2417           l_old_val1(l_tab_counter) := p_old_rec.postal_code;
2418           l_old_val2(l_tab_counter) := null;
2419           l_old_val3(l_tab_counter) := null;
2420           l_old_val4(l_tab_counter) := null;
2421           l_old_val5(l_tab_counter) := null;
2422           l_old_val6(l_tab_counter) := null;
2423           l_new_val1(l_tab_counter) := p_new_rec.postal_code;
2424           l_new_val2(l_tab_counter) := null;
2425           l_new_val3(l_tab_counter) := null;
2426           l_new_val4(l_tab_counter) := null;
2427           l_new_val5(l_tab_counter) := null;
2428           l_new_val6(l_tab_counter) := null;
2429       end if;
2430       if upper(nvl(p_old_rec.region_1, 'region_1'))
2431          <> upper(nvl(p_new_rec.region_1, 'region_1')) then
2432           l_chg_occured := TRUE;
2433           l_tab_counter := l_tab_counter + 1;
2434           l_chg_evt_tab(l_tab_counter) := 'COPE';
2435           l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2436           l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2437           l_prmtr_02_tab(l_tab_counter) := null;
2438           l_prmtr_03_tab(l_tab_counter) := null;
2439           l_prmtr_04_tab(l_tab_counter) := null;
2440           l_prmtr_05_tab(l_tab_counter) := null;
2441           l_prmtr_06_tab(l_tab_counter) := null;
2442           l_prmtr_07_tab(l_tab_counter) := null;
2443           l_old_val1(l_tab_counter) := p_old_rec.region_1;
2444           l_old_val2(l_tab_counter) := null;
2445           l_old_val3(l_tab_counter) := null;
2446           l_old_val4(l_tab_counter) := null;
2447           l_old_val5(l_tab_counter) := null;
2448           l_old_val6(l_tab_counter) := null;
2449           l_new_val1(l_tab_counter) := p_new_rec.region_1;
2450           l_new_val2(l_tab_counter) := null;
2451           l_new_val3(l_tab_counter) := null;
2452           l_new_val4(l_tab_counter) := null;
2453           l_new_val5(l_tab_counter) := null;
2454           l_new_val6(l_tab_counter) := null;
2455       end if;
2456       if upper(nvl(p_old_rec.region_2, 'region_2'))
2457          <> upper(nvl(p_new_rec.region_2, 'region_2')) then
2458           l_chg_occured := TRUE;
2459           l_tab_counter := l_tab_counter + 1;
2460           l_chg_evt_tab(l_tab_counter) := 'COPS';
2461           l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2462           l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2463           l_prmtr_02_tab(l_tab_counter) := null;
2464           l_prmtr_03_tab(l_tab_counter) := null;
2465           l_prmtr_04_tab(l_tab_counter) := null;
2466           l_prmtr_05_tab(l_tab_counter) := null;
2467           l_prmtr_06_tab(l_tab_counter) := null;
2468           l_prmtr_07_tab(l_tab_counter) := null;
2469           l_old_val1(l_tab_counter) := p_old_rec.region_2;
2470           l_old_val2(l_tab_counter) := null;
2471           l_old_val3(l_tab_counter) := null;
2472           l_old_val4(l_tab_counter) := null;
2473           l_old_val5(l_tab_counter) := null;
2474           l_old_val6(l_tab_counter) := null;
2475           l_new_val1(l_tab_counter) := p_new_rec.region_2;
2476           l_new_val2(l_tab_counter) := null;
2477           l_new_val3(l_tab_counter) := null;
2478           l_new_val4(l_tab_counter) := null;
2479           l_new_val5(l_tab_counter) := null;
2480           l_new_val6(l_tab_counter) := null;
2481       end if;
2482       if upper(nvl(p_old_rec.region_3, 'region_3'))
2483          <> upper(nvl(p_new_rec.region_3, 'region_3')) then
2484           l_chg_occured := TRUE;
2485           l_tab_counter := l_tab_counter + 1;
2486           l_chg_evt_tab(l_tab_counter) := 'COPC';
2487           l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2488           l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2489           l_prmtr_02_tab(l_tab_counter) := null;
2490           l_prmtr_03_tab(l_tab_counter) := null;
2491           l_prmtr_04_tab(l_tab_counter) := null;
2492           l_prmtr_05_tab(l_tab_counter) := null;
2493           l_prmtr_06_tab(l_tab_counter) := null;
2494           l_prmtr_07_tab(l_tab_counter) := null;
2495           l_old_val1(l_tab_counter) := p_old_rec.region_3;
2496           l_old_val2(l_tab_counter) := null;
2497           l_old_val3(l_tab_counter) := null;
2498           l_old_val4(l_tab_counter) := null;
2499           l_old_val5(l_tab_counter) := null;
2500           l_old_val6(l_tab_counter) := null;
2501           l_new_val1(l_tab_counter) := p_new_rec.region_3;
2502           l_new_val2(l_tab_counter) := null;
2503           l_new_val3(l_tab_counter) := null;
2504           l_new_val4(l_tab_counter) := null;
2505           l_new_val5(l_tab_counter) := null;
2506           l_new_val6(l_tab_counter) := null;
2507       end if;
2508       if upper(nvl(p_old_rec.town_or_city, 'town_or_city'))
2509          <> upper(nvl(p_new_rec.town_or_city, 'town_or_city')) then
2510           l_chg_occured := TRUE;
2511           l_tab_counter := l_tab_counter + 1;
2512           l_chg_evt_tab(l_tab_counter) := 'CORC';
2513           l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2514           l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2515           l_prmtr_02_tab(l_tab_counter) := null;
2516           l_prmtr_03_tab(l_tab_counter) := null;
2517           l_prmtr_04_tab(l_tab_counter) := null;
2518           l_prmtr_05_tab(l_tab_counter) := null;
2519           l_prmtr_06_tab(l_tab_counter) := null;
2520           l_prmtr_07_tab(l_tab_counter) := null;
2521           l_old_val1(l_tab_counter) := p_old_rec.town_or_city;
2522           l_old_val2(l_tab_counter) := null;
2523           l_old_val3(l_tab_counter) := null;
2524           l_old_val4(l_tab_counter) := null;
2525           l_old_val5(l_tab_counter) := null;
2526           l_old_val6(l_tab_counter) := null;
2527           l_new_val1(l_tab_counter) := p_new_rec.town_or_city;
2528           l_new_val2(l_tab_counter) := null;
2529           l_new_val3(l_tab_counter) := null;
2530           l_new_val4(l_tab_counter) := null;
2531           l_new_val5(l_tab_counter) := null;
2532           l_new_val6(l_tab_counter) := null;
2533       end if;
2534 
2535       if upper(nvl(p_old_rec.country, 'country'))
2536          <> upper(nvl(p_new_rec.country, 'country')) then
2537           l_chg_occured := TRUE;
2538           l_tab_counter := l_tab_counter + 1;
2539           l_chg_evt_tab(l_tab_counter) := 'COCN';
2540           l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2541           l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2542           l_prmtr_02_tab(l_tab_counter) := null;
2543           l_prmtr_03_tab(l_tab_counter) := null;
2544           l_prmtr_04_tab(l_tab_counter) := null;
2545           l_prmtr_05_tab(l_tab_counter) := null;
2546           l_prmtr_06_tab(l_tab_counter) := null;
2547           l_prmtr_07_tab(l_tab_counter) := null;
2548           l_old_val1(l_tab_counter) := p_old_rec.country;
2549           l_old_val2(l_tab_counter) := null;
2550           l_old_val3(l_tab_counter) := null;
2551           l_old_val4(l_tab_counter) := null;
2552           l_old_val5(l_tab_counter) := null;
2553           l_old_val6(l_tab_counter) := null;
2554           l_new_val1(l_tab_counter) := p_new_rec.country;
2555           l_new_val2(l_tab_counter) := null;
2556           l_new_val3(l_tab_counter) := null;
2557           l_new_val4(l_tab_counter) := null;
2558           l_new_val5(l_tab_counter) := null;
2559           l_new_val6(l_tab_counter) := null;
2560       end if;
2561      if l_chg_occured then
2562         l_tab_counter := l_tab_counter + 1;
2563         l_chg_evt_tab(l_tab_counter) := 'COPR';
2564         l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2565         l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2566         l_prmtr_02_tab(l_tab_counter) := null;
2567         l_prmtr_03_tab(l_tab_counter) := null;
2568         l_prmtr_04_tab(l_tab_counter) := null;
2569         l_prmtr_05_tab(l_tab_counter) := null;
2570         l_prmtr_06_tab(l_tab_counter) := null;
2571         l_prmtr_07_tab(l_tab_counter) := null;
2572         l_old_val1(l_tab_counter) := rtrim(substrb( p_old_rec.address_line1||' '||
2573                                      p_old_rec.address_line2||' '||
2574                                      p_old_rec.address_line3,1,600));
2575         l_old_val2(l_tab_counter) := p_old_rec.town_or_city;
2576         l_old_val3(l_tab_counter) := p_old_rec.region_2;
2577         l_old_val4(l_tab_counter) := p_old_rec.postal_code;
2578         l_old_val5(l_tab_counter) := p_old_rec.region_3;
2579         l_old_val6(l_tab_counter) := p_old_rec.region_1;
2580         l_new_val1(l_tab_counter) := rtrim(substrb( p_new_rec.address_line1||' '||
2581                                      p_new_rec.address_line2||' '||
2582                                      p_new_rec.address_line3,1,600));
2583         l_new_val2(l_tab_counter) := p_new_rec.town_or_city;
2584         l_new_val3(l_tab_counter) := p_new_rec.region_2;
2585         l_new_val4(l_tab_counter) := p_new_rec.postal_code;
2586         l_new_val5(l_tab_counter) := p_new_rec.region_3;
2587         l_new_val6(l_tab_counter) := p_new_rec.region_1;
2588       end if;
2589          --for contact data change
2590       if ((l_chg_occured)
2591       or (nvl(p_old_rec.date_from,
2592          to_date('01/01/0001', 'DD/MM/YYYY'))
2593          <> nvl(p_new_rec.date_from,
2594          to_date('01/01/0001', 'DD/MM/YYYY')))) then
2595 
2596          open c_relationship(p_new_rec.person_id);
2597          fetch c_relationship into l_contact,l_relationship,l_name;
2598          if c_relationship%notfound then
2599            close c_relationship;
2600          elsif c_relationship%found then
2601            close c_relationship;
2602          l_tab_counter := l_tab_counter + 1;
2603          l_chg_evt_tab(l_tab_counter) := 'CCPA';
2604          l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2605          l_prmtr_01_tab(l_tab_counter) := to_char(l_contact);
2606          l_prmtr_02_tab(l_tab_counter) := p_new_rec.address_id;
2607          l_prmtr_03_tab(l_tab_counter) := null;
2608          l_prmtr_04_tab(l_tab_counter) := null;
2609          l_prmtr_05_tab(l_tab_counter) := null;
2610          l_prmtr_06_tab(l_tab_counter) := null;
2611          l_prmtr_07_tab(l_tab_counter) := l_relationship;
2612          l_old_val1(l_tab_counter) := substr(l_name,1,240);
2613          l_new_val1(l_tab_counter) := substr(l_name,1,240);
2614          l_old_val2(l_tab_counter) :=  rtrim(substrb(p_old_rec.address_line1||' '||
2615                                      p_old_rec.address_line2||' '||
2616                                      p_old_rec.address_line3,1,600));
2617          l_old_val3(l_tab_counter) := p_old_rec.town_or_city;
2618          l_old_val4(l_tab_counter) := p_old_rec.region_2;
2619          l_old_val5(l_tab_counter) := p_old_rec.postal_code;
2620          l_old_val6(l_tab_counter) := p_old_rec.region_3;
2621          l_new_val2(l_tab_counter) := rtrim(substrb( p_new_rec.address_line1||' '||
2622                                       p_new_rec.address_line2||' '||
2623                                       p_new_rec.address_line3,1,600));
2624          l_new_val3(l_tab_counter) := p_new_rec.town_or_city;
2625          l_new_val4(l_tab_counter) := p_new_rec.region_2;
2626          l_new_val5(l_tab_counter) := p_new_rec.postal_code;
2627          l_new_val6(l_tab_counter) := p_new_rec.region_3;
2628          end if;
2629       end if;
2630       if nvl(p_old_rec.date_from,
2631          to_date('01/01/0001', 'DD/MM/YYYY'))
2632          <> nvl(p_new_rec.date_from,
2633          to_date('01/01/0001', 'DD/MM/YYYY')) then
2634           l_tab_counter := l_tab_counter + 1;
2635           l_chg_evt_tab(l_tab_counter) := 'COPR';
2636           l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2637           l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2638           l_prmtr_02_tab(l_tab_counter) := null;
2639           l_prmtr_03_tab(l_tab_counter) := null;
2640           l_prmtr_04_tab(l_tab_counter) := null;
2641           l_prmtr_05_tab(l_tab_counter) := null;
2642           l_prmtr_06_tab(l_tab_counter) := null;
2643           l_prmtr_07_tab(l_tab_counter) := null;
2644         l_old_val1(l_tab_counter) := rtrim(substrb( p_old_rec.address_line1||' '||
2645                                      p_old_rec.address_line2||' '||
2646                                      p_old_rec.address_line3,1,600));
2647         l_old_val2(l_tab_counter) := p_old_rec.town_or_city;
2648         l_old_val3(l_tab_counter) := p_old_rec.region_2;
2649         l_old_val4(l_tab_counter) := p_old_rec.postal_code;
2650         l_old_val5(l_tab_counter) := p_old_rec.region_3;
2651         l_old_val6(l_tab_counter) := p_old_rec.region_1;
2652         l_new_val1(l_tab_counter) :=  rtrim(substrb( p_new_rec.address_line1||' '||
2653                                      p_new_rec.address_line2||' '||
2654                                      p_new_rec.address_line3,1,600));
2655         l_new_val2(l_tab_counter) := p_new_rec.town_or_city;
2656         l_new_val3(l_tab_counter) := p_new_rec.region_2;
2657         l_new_val4(l_tab_counter) := p_new_rec.postal_code;
2658         l_new_val5(l_tab_counter) := p_new_rec.region_3;
2659         l_new_val6(l_tab_counter) := p_new_rec.region_1;
2660       end if;
2661 
2662 
2663     end if;
2664 --
2665     -- also log change events for mailing address
2666     if p_new_rec.address_type <> nvl(p_old_rec.address_type,'$$')
2667           and p_new_rec.address_type = 'M' then
2668         l_chg_eff_dt := p_new_rec.date_from;
2669         l_tab_counter := l_tab_counter + 1;
2670         l_chg_evt_tab(l_tab_counter) := 'AMA';
2671         l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2672         l_prmtr_01_tab(l_tab_counter) := p_new_rec.address_id;
2673         l_prmtr_02_tab(l_tab_counter) := null;
2674         l_prmtr_03_tab(l_tab_counter) := null;
2675         l_prmtr_04_tab(l_tab_counter) := null;
2676         l_prmtr_05_tab(l_tab_counter) := null;
2677         l_prmtr_06_tab(l_tab_counter) := null;
2678         l_prmtr_07_tab(l_tab_counter) := null;
2679         l_old_val1(l_tab_counter) := null;
2680         l_old_val2(l_tab_counter) := null;
2681         l_old_val3(l_tab_counter) := null;
2682         l_old_val4(l_tab_counter) := null;
2683         l_old_val5(l_tab_counter) := null;
2684         l_old_val6(l_tab_counter) := null;
2685         l_new_val1(l_tab_counter) :=  rtrim(substrb( p_new_rec.address_line1||' '||
2686                                      p_new_rec.address_line2||' '||
2687                                      p_new_rec.address_line3,1,600));
2688         l_new_val2(l_tab_counter) := p_new_rec.town_or_city;
2689         l_new_val3(l_tab_counter) := p_new_rec.region_2;
2690         l_new_val4(l_tab_counter) := p_new_rec.postal_code;
2691         l_new_val5(l_tab_counter) := p_new_rec.region_3;
2692         l_new_val6(l_tab_counter) := p_new_rec.region_1;
2693     end if;
2694 
2695     if p_old_rec.address_type = 'M'
2696           and p_new_rec.date_to is null
2697           and p_old_rec.date_to is not null then
2698         l_chg_eff_dt := p_new_rec.date_from;
2699         l_tab_counter := l_tab_counter + 1;
2700         l_chg_evt_tab(l_tab_counter) := 'AMA';
2701         l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2702         l_prmtr_01_tab(l_tab_counter) := p_new_rec.address_id;
2703         l_prmtr_02_tab(l_tab_counter) := null;
2704         l_prmtr_03_tab(l_tab_counter) := null;
2705         l_prmtr_04_tab(l_tab_counter) := null;
2706         l_prmtr_05_tab(l_tab_counter) := null;
2707         l_prmtr_06_tab(l_tab_counter) := null;
2708         l_prmtr_07_tab(l_tab_counter) := null;
2709         l_old_val1(l_tab_counter) := null;
2710         l_old_val2(l_tab_counter) := null;
2711         l_old_val3(l_tab_counter) := null;
2712         l_old_val4(l_tab_counter) := null;
2713         l_old_val5(l_tab_counter) := null;
2714         l_old_val6(l_tab_counter) := null;
2715         l_new_val1(l_tab_counter) :=  rtrim(substrb( p_new_rec.address_line1||' '||
2716                                      p_new_rec.address_line2||' '||
2717                                      p_new_rec.address_line3,1,600));
2718         l_new_val2(l_tab_counter) := p_new_rec.town_or_city;
2719         l_new_val3(l_tab_counter) := p_new_rec.region_2;
2720         l_new_val4(l_tab_counter) := p_new_rec.postal_code;
2721         l_new_val5(l_tab_counter) := p_new_rec.region_3;
2722         l_new_val6(l_tab_counter) := p_new_rec.region_1;
2723     end if;
2724 
2725     if nvl(p_new_rec.address_type,'$$') <> p_old_rec.address_type
2726           and p_old_rec.address_type = 'M' then
2727       l_chg_eff_dt := trunc(sysdate);
2728         l_tab_counter := l_tab_counter + 1;
2729         l_chg_evt_tab(l_tab_counter) := 'DMA';
2730         l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2731         l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2732         l_prmtr_02_tab(l_tab_counter) := null;
2733         l_prmtr_03_tab(l_tab_counter) := null;
2734         l_prmtr_04_tab(l_tab_counter) := null;
2735         l_prmtr_05_tab(l_tab_counter) := null;
2736         l_prmtr_06_tab(l_tab_counter) := null;
2737         l_prmtr_07_tab(l_tab_counter) := null;
2738         l_old_val1(l_tab_counter) :=  rtrim(substrb( p_old_rec.address_line1||' '||
2739                                      p_old_rec.address_line2||' '||
2740                                      p_old_rec.address_line3,1,600));
2741         l_old_val2(l_tab_counter) := p_old_rec.town_or_city;
2742         l_old_val3(l_tab_counter) := p_old_rec.region_2;
2743         l_old_val4(l_tab_counter) := p_old_rec.postal_code;
2744         l_old_val5(l_tab_counter) := p_old_rec.region_3;
2745         l_old_val6(l_tab_counter) := p_old_rec.region_1;
2746         l_new_val1(l_tab_counter) := null;
2747         l_new_val2(l_tab_counter) := null;
2748         l_new_val3(l_tab_counter) := null;
2749         l_new_val4(l_tab_counter) := null;
2750         l_new_val5(l_tab_counter) := null;
2751         l_new_val6(l_tab_counter) := null;
2752     end if;
2753 
2754     if p_old_rec.address_type = 'M'
2755           and p_new_rec.date_to is not null
2756           and p_old_rec.date_to is null then
2757       l_chg_eff_dt := p_new_rec.date_to;
2758         l_tab_counter := l_tab_counter + 1;
2759         l_chg_evt_tab(l_tab_counter) := 'DMA';
2760         l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2761         l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2762         l_prmtr_02_tab(l_tab_counter) := null;
2763         l_prmtr_03_tab(l_tab_counter) := null;
2764         l_prmtr_04_tab(l_tab_counter) := null;
2765         l_prmtr_05_tab(l_tab_counter) := null;
2766         l_prmtr_06_tab(l_tab_counter) := null;
2767         l_prmtr_07_tab(l_tab_counter) := null;
2768         l_old_val1(l_tab_counter) :=  rtrim(substrb( p_old_rec.address_line1||' '||
2769                                      p_old_rec.address_line2||' '||
2770                                      p_old_rec.address_line3,1,600));
2771         l_old_val2(l_tab_counter) := p_old_rec.town_or_city;
2772         l_old_val3(l_tab_counter) := p_old_rec.region_2;
2773         l_old_val4(l_tab_counter) := p_old_rec.postal_code;
2774         l_old_val5(l_tab_counter) := p_old_rec.region_3;
2775         l_old_val6(l_tab_counter) := p_old_rec.region_1;
2776         l_new_val1(l_tab_counter) := null;
2777         l_new_val2(l_tab_counter) := null;
2778         l_new_val3(l_tab_counter) := null;
2779         l_new_val4(l_tab_counter) := null;
2780         l_new_val5(l_tab_counter) := null;
2781         l_new_val6(l_tab_counter) := null;
2782     end if;
2783     --
2784     if p_old_rec.address_type = p_new_rec.address_type
2785        and p_new_rec.address_type = 'M' then
2786       if nvl(p_new_rec.date_from,
2787          to_date('01/01/0001', 'DD/MM/YYYY'))
2788          < trunc(sysdate) then
2789         if nvl(p_new_rec.date_to,
2790            to_date('31/12/4712', 'DD/MM/YYYY'))
2791            < trunc(sysdate) then
2792           l_chg_eff_dt := p_new_rec.date_to;
2793         else
2794           l_chg_eff_dt := trunc(sysdate);
2795         end if;
2796       else
2797         l_chg_eff_dt := p_new_rec.date_from;
2798       end if;
2799       if upper(nvl(p_old_rec.town_or_city, 'town_or_city'))
2800          <> upper(nvl(p_new_rec.town_or_city, 'town_or_city')) then
2801           l_chg_occured := TRUE;
2802           l_tab_counter := l_tab_counter + 1;
2803           l_chg_evt_tab(l_tab_counter) := 'COMC';
2804           l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2805           l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2806           l_prmtr_02_tab(l_tab_counter) := null;
2807           l_prmtr_03_tab(l_tab_counter) := null;
2808           l_prmtr_04_tab(l_tab_counter) := null;
2809           l_prmtr_05_tab(l_tab_counter) := null;
2810           l_prmtr_06_tab(l_tab_counter) := null;
2811           l_prmtr_07_tab(l_tab_counter) := null;
2812           l_old_val1(l_tab_counter) := p_old_rec.town_or_city;
2813           l_old_val2(l_tab_counter) := null;
2814           l_old_val3(l_tab_counter) := null;
2815           l_old_val4(l_tab_counter) := null;
2816           l_old_val5(l_tab_counter) := null;
2817           l_old_val6(l_tab_counter) := null;
2818           l_new_val1(l_tab_counter) := p_new_rec.town_or_city;
2819           l_new_val2(l_tab_counter) := null;
2820           l_new_val3(l_tab_counter) := null;
2821           l_new_val4(l_tab_counter) := null;
2822           l_new_val5(l_tab_counter) := null;
2823           l_new_val6(l_tab_counter) := null;
2824       end if;
2825       if upper(nvl(p_old_rec.postal_code, 'postal_code'))
2826          <> upper(nvl(p_new_rec.postal_code, 'postal_code')) then
2827           l_chg_occured := TRUE;
2828           l_tab_counter := l_tab_counter + 1;
2829           l_chg_evt_tab(l_tab_counter) := 'COMP';
2830           l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2831           l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2832           l_prmtr_02_tab(l_tab_counter) := null;
2833           l_prmtr_03_tab(l_tab_counter) := null;
2834           l_prmtr_04_tab(l_tab_counter) := null;
2835           l_prmtr_05_tab(l_tab_counter) := null;
2836           l_prmtr_06_tab(l_tab_counter) := null;
2837           l_prmtr_07_tab(l_tab_counter) := null;
2838           l_old_val1(l_tab_counter) := p_old_rec.postal_code;
2839           l_old_val2(l_tab_counter) := null;
2840           l_old_val3(l_tab_counter) := null;
2841           l_old_val4(l_tab_counter) := null;
2842           l_old_val5(l_tab_counter) := null;
2843           l_old_val6(l_tab_counter) := null;
2844           l_new_val1(l_tab_counter) := p_new_rec.postal_code;
2845           l_new_val2(l_tab_counter) := null;
2846           l_new_val3(l_tab_counter) := null;
2847           l_new_val4(l_tab_counter) := null;
2848           l_new_val5(l_tab_counter) := null;
2849           l_new_val6(l_tab_counter) := null;
2850       end if;
2851       if nvl(p_old_rec.address_line1, 'address_line1')
2852          <> nvl(p_new_rec.address_line1, 'address_line1')
2853          or
2854          nvl(p_old_rec.address_line2, 'address_line2')
2855          <> nvl(p_new_rec.address_line2, 'address_line2')
2856          or
2857          nvl(p_old_rec.address_line3, 'address_line3')
2858          <> nvl(p_new_rec.address_line3, 'address_line3')
2859           then
2860           l_chg_occured := TRUE;
2861           l_tab_counter := l_tab_counter + 1;
2862           l_chg_evt_tab(l_tab_counter) := 'COMS';
2863           l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2864           l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2865           l_prmtr_02_tab(l_tab_counter) := null;
2866           l_prmtr_03_tab(l_tab_counter) := null;
2867           l_prmtr_04_tab(l_tab_counter) := null;
2868           l_prmtr_05_tab(l_tab_counter) := null;
2869           l_prmtr_06_tab(l_tab_counter) := null;
2870           l_prmtr_07_tab(l_tab_counter) := null;
2871           l_old_val1(l_tab_counter) :=  rtrim(substrb( p_old_rec.address_line1||' '||
2872                                        p_old_rec.address_line2||' '||
2873                                        p_old_rec.address_line3,1,600));
2874           l_old_val2(l_tab_counter) := null;
2875           l_old_val3(l_tab_counter) := null;
2876           l_old_val4(l_tab_counter) := null;
2877           l_old_val5(l_tab_counter) := null;
2878           l_old_val6(l_tab_counter) := null;
2879           l_new_val1(l_tab_counter) := rtrim(substrb( p_new_rec.address_line1||' '||
2880                                        p_new_rec.address_line2||' '||
2881                                        p_new_rec.address_line3,1,600));
2882           l_new_val2(l_tab_counter) := null;
2883           l_new_val3(l_tab_counter) := null;
2884           l_new_val4(l_tab_counter) := null;
2885           l_new_val5(l_tab_counter) := null;
2886           l_new_val6(l_tab_counter) := null;
2887       end if;
2888       if upper(nvl(p_old_rec.region_1, 'region_1'))
2889          <> upper(nvl(p_new_rec.region_1, 'region_1')) then
2890           l_chg_occured := TRUE;
2891           l_tab_counter := l_tab_counter + 1;
2892           l_chg_evt_tab(l_tab_counter) := 'COMR';
2893           l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2894           l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2895           l_prmtr_02_tab(l_tab_counter) := null;
2896           l_prmtr_03_tab(l_tab_counter) := null;
2897           l_prmtr_04_tab(l_tab_counter) := null;
2898           l_prmtr_05_tab(l_tab_counter) := null;
2899           l_prmtr_06_tab(l_tab_counter) := null;
2900           l_prmtr_07_tab(l_tab_counter) := null;
2901           l_old_val1(l_tab_counter) := p_old_rec.region_1;
2902           l_old_val2(l_tab_counter) := null;
2903           l_old_val3(l_tab_counter) := null;
2904           l_old_val4(l_tab_counter) := null;
2905           l_old_val5(l_tab_counter) := null;
2906           l_old_val6(l_tab_counter) := null;
2907           l_new_val1(l_tab_counter) := p_new_rec.region_1;
2908           l_new_val2(l_tab_counter) := null;
2909           l_new_val3(l_tab_counter) := null;
2910           l_new_val4(l_tab_counter) := null;
2911           l_new_val5(l_tab_counter) := null;
2912           l_new_val6(l_tab_counter) := null;
2913       end if;
2914       if upper(nvl(p_old_rec.region_2, 'region_2'))
2915          <> upper(nvl(p_new_rec.region_2, 'region_2')) then
2916           l_chg_occured := TRUE;
2917           l_tab_counter := l_tab_counter + 1;
2918           l_chg_evt_tab(l_tab_counter) := 'COMT';
2919           l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2920           l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2921           l_prmtr_02_tab(l_tab_counter) := null;
2922           l_prmtr_03_tab(l_tab_counter) := null;
2923           l_prmtr_04_tab(l_tab_counter) := null;
2924           l_prmtr_05_tab(l_tab_counter) := null;
2925           l_prmtr_06_tab(l_tab_counter) := null;
2926           l_prmtr_07_tab(l_tab_counter) := null;
2927           l_old_val1(l_tab_counter) := p_old_rec.region_2;
2928           l_old_val2(l_tab_counter) := null;
2929           l_old_val3(l_tab_counter) := null;
2930           l_old_val4(l_tab_counter) := null;
2931           l_old_val5(l_tab_counter) := null;
2932           l_old_val6(l_tab_counter) := null;
2933           l_new_val1(l_tab_counter) := p_new_rec.region_2;
2934           l_new_val2(l_tab_counter) := null;
2935           l_new_val3(l_tab_counter) := null;
2936           l_new_val4(l_tab_counter) := null;
2937           l_new_val5(l_tab_counter) := null;
2938           l_new_val6(l_tab_counter) := null;
2939       end if;
2940       if upper(nvl(p_old_rec.region_3, 'region_3'))
2941          <> upper(nvl(p_new_rec.region_3, 'region_3')) then
2942           l_chg_occured := TRUE;
2943           l_tab_counter := l_tab_counter + 1;
2944           l_chg_evt_tab(l_tab_counter) := 'COMO';
2945           l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2946           l_prmtr_01_tab(l_tab_counter) := p_old_rec.address_id;
2947           l_prmtr_02_tab(l_tab_counter) := null;
2948           l_prmtr_03_tab(l_tab_counter) := null;
2949           l_prmtr_04_tab(l_tab_counter) := null;
2950           l_prmtr_05_tab(l_tab_counter) := null;
2951           l_prmtr_06_tab(l_tab_counter) := null;
2952           l_prmtr_07_tab(l_tab_counter) := null;
2953           l_old_val1(l_tab_counter) := p_old_rec.region_3;
2954           l_old_val2(l_tab_counter) := null;
2955           l_old_val3(l_tab_counter) := null;
2956           l_old_val4(l_tab_counter) := null;
2957           l_old_val5(l_tab_counter) := null;
2958           l_old_val6(l_tab_counter) := null;
2959           l_new_val1(l_tab_counter) := p_new_rec.region_3;
2960           l_new_val2(l_tab_counter) := null;
2961           l_new_val3(l_tab_counter) := null;
2962           l_new_val4(l_tab_counter) := null;
2963           l_new_val5(l_tab_counter) := null;
2964           l_new_val6(l_tab_counter) := null;
2965       end if;
2966     --
2967     -- for contact change of mailing address
2968       if p_new_rec.address_type <> nvl(p_old_rec.address_type,'$$')
2969           and p_new_rec.address_type = 'M' then
2970         l_chg_mail_add := true;
2971       elsif p_old_rec.address_type = 'M'
2972           and p_new_rec.date_to is null
2973           and p_old_rec.date_to is not null then
2974         l_chg_mail_add := true;
2975       end if;
2976       if l_chg_occured or l_chg_mail_add then
2977       --fnd_message.set_name('BEN','ddddsss'||to_char(l_relationship));
2978       --fnd_message.raise_error;
2979          open c_relationship(p_new_rec.person_id);
2980          fetch c_relationship into l_contact,l_relationship,l_name;
2981          if c_relationship%notfound then
2982            close c_relationship;
2983          elsif c_relationship%found then
2984            close c_relationship;
2985          l_tab_counter := l_tab_counter + 1;
2986          l_chg_evt_tab(l_tab_counter) := 'CCMA';
2987          l_chg_eff_tab(l_tab_counter) := l_chg_eff_dt;
2988          l_prmtr_01_tab(l_tab_counter) := to_char(l_contact);
2989          l_prmtr_02_tab(l_tab_counter) := p_new_rec.address_id;
2990          l_prmtr_03_tab(l_tab_counter) := null;
2991          l_prmtr_04_tab(l_tab_counter) := null;
2992          l_prmtr_05_tab(l_tab_counter) := null;
2993          l_prmtr_06_tab(l_tab_counter) := null;
2994          l_prmtr_07_tab(l_tab_counter) := l_relationship;
2995          l_old_val1(l_tab_counter) := substr(l_name,1,240);
2996          l_new_val1(l_tab_counter) := substr(l_name,1,240);
2997          l_old_val2(l_tab_counter) := rtrim(substrb( p_old_rec.address_line1||' '||
2998                                      p_old_rec.address_line2||' '||
2999                                      p_old_rec.address_line3,1,600));
3000          l_old_val3(l_tab_counter) := p_old_rec.town_or_city;
3001          l_old_val4(l_tab_counter) := p_old_rec.region_2;
3002          l_old_val5(l_tab_counter) := p_old_rec.postal_code;
3003          l_old_val6(l_tab_counter) := p_old_rec.region_3;
3004          l_new_val2(l_tab_counter) :=  rtrim(substrb( p_new_rec.address_line1||' '||
3005                                       p_new_rec.address_line2||' '||
3006                                       p_new_rec.address_line3,1,600));
3007          l_new_val3(l_tab_counter) := p_new_rec.town_or_city;
3008          l_new_val4(l_tab_counter) := p_new_rec.region_2;
3009          l_new_val5(l_tab_counter) := p_new_rec.postal_code;
3010          l_new_val6(l_tab_counter) := p_new_rec.region_3;
3011          end if;
3012       end if;
3013     end if;
3014   end if;
3015 --
3016   hr_utility.set_location('Continuing:'|| l_proc, 20);
3017   hr_utility.set_location('BGP ID:'||p_new_rec.business_group_id||' '||l_proc, 30);
3018   for l_count in 1..l_chg_evt_tab.count loop
3019    if change_event_is_enabled(l_chg_evt_tab(l_count),trunc(sysdate)) then
3020       if l_chg_evt_tab(l_count) in ('CCPA','CCMA','CCNPA','CCNMA') then
3021         l_person_id := nvl(l_prmtr_07_tab(l_count),l_relationship);
3022       end if;
3023       ben_ext_chg_evt_api.create_ext_chg_evt
3024         (p_validate                    => FALSE
3025         ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
3026         ,p_chg_evt_cd                  => l_chg_evt_tab(l_count)
3027         ,p_chg_eff_dt                  => l_chg_eff_tab(l_count)
3028         ,p_person_id                   => l_person_id
3029         --
3030         -- <BUG_FIX> Passed in old rec rather than new rec on delete
3031         --           no new rec will exist
3032         --
3033         ,p_prmtr_01                    => l_prmtr_01_tab(l_count)
3034         ,p_prmtr_02                    => l_prmtr_02_tab(l_count)
3035         ,p_prmtr_03                    => l_prmtr_03_tab(l_count)
3036         ,p_prmtr_04                    => l_prmtr_04_tab(l_count)
3037         ,p_prmtr_05                    => l_prmtr_05_tab(l_count)
3038         ,p_prmtr_06                    => l_prmtr_06_tab(l_count)
3039         ,p_prmtr_07                    => l_prmtr_07_tab(l_count)
3040         ,p_business_group_id           => l_business_group_id
3041         ,p_object_version_number       => l_object_version_number
3042         ,p_effective_date              => trunc(sysdate)
3043         ,p_old_val1                    => l_old_val1(l_count)
3044         ,p_old_val2                    => l_old_val2(l_count)
3045         ,p_old_val3                    => l_old_val3(l_count)
3046         ,p_old_val4                    => l_old_val4(l_count)
3047         ,p_old_val5                    => l_old_val5(l_count)
3048         ,p_old_val6                    => l_old_val6(l_count)
3049         ,p_new_val1                    => l_new_val1(l_count)
3050         ,p_new_val2                    => l_new_val2(l_count)
3051         ,p_new_val3                    => l_new_val3(l_count)
3052         ,p_new_val4                    => l_new_val4(l_count)
3053         ,p_new_val5                    => l_new_val5(l_count)
3054         ,p_new_val6                    => l_new_val6(l_count)
3055         );
3056    end if;
3057   end loop;
3058 --
3059   hr_utility.set_location('Exiting:'|| l_proc, 99);
3060 --
3061 end log_add_chg;
3062 
3063 ----- this is a overlaod procedure to call from core HR
3064 procedure log_asg_chg
3065   (p_event        in   varchar2
3066   ,p_old_rec      in   per_asg_shd.g_rec_type
3067   ,p_new_rec      in   per_asg_shd.g_rec_type
3068   ) is
3069 
3070   l_old_rec           ben_ext_chlg.g_asg_rec_type;
3071   l_new_rec           ben_ext_chlg.g_asg_rec_type;
3072   l_event             varchar2(10) ;
3073 --
3074   l_proc               varchar2(100) := 'ben_ext_chlg.log_asg_chg';
3075 begin
3076 
3077   hr_utility.set_location('Entering:'|| l_proc, 05);
3078   -------------
3079   l_old_rec.assignment_id  := p_old_rec.assignment_id;
3080   l_old_rec.assignment_status_type_id  := p_old_rec.assignment_status_type_id;
3081   l_old_rec.hourly_salaried_code  := p_old_rec.hourly_salaried_code;
3082   l_old_rec.normal_hours := p_old_rec.normal_hours;
3083   l_old_rec.location_id := p_old_rec.location_id;
3084   l_old_rec.position_id := p_old_rec.position_id;
3085   l_old_rec.employment_category := p_old_rec.employment_category;
3086   l_old_rec.person_id := p_old_rec.person_id;
3087   l_old_rec.assignment_type := p_old_rec.assignment_type;
3088   l_old_rec.business_group_id := p_old_rec.business_group_id;
3089   l_old_rec.effective_start_date :=p_old_rec.effective_start_date;
3090   l_old_rec.effective_end_date :=p_old_rec.effective_end_date;
3091   l_old_rec.ass_attribute1 :=p_old_rec.ass_attribute1;
3092   l_old_rec.ass_attribute2 :=p_old_rec.ass_attribute2;
3093   l_old_rec.ass_attribute3 :=p_old_rec.ass_attribute3;
3094   l_old_rec.ass_attribute4 :=p_old_rec.ass_attribute4;
3095   l_old_rec.ass_attribute5 :=p_old_rec.ass_attribute5;
3096   l_old_rec.ass_attribute6 :=p_old_rec.ass_attribute6;
3097   l_old_rec.ass_attribute7 :=p_old_rec.ass_attribute7;
3098   l_old_rec.ass_attribute8 :=p_old_rec.ass_attribute8;
3099   l_old_rec.ass_attribute9 :=p_old_rec.ass_attribute9;
3100   l_old_rec.ass_attribute10 :=p_old_rec.ass_attribute10;
3101   l_old_rec.payroll_id :=p_old_rec.payroll_id;
3102   l_old_rec.grade_id :=p_old_rec.grade_id;
3103   l_old_rec.primary_flag := p_old_rec.primary_flag;
3104   l_old_rec.soft_coding_keyflex_id := p_old_rec.soft_coding_keyflex_id;
3105 
3106 -----------------------------new record---------------------
3107   l_new_rec.assignment_id  := p_new_rec.assignment_id ;
3108   l_new_rec.assignment_status_type_id  := p_new_rec.assignment_status_type_id ;
3109   l_new_rec.hourly_salaried_code  := p_new_rec.hourly_salaried_code;
3110   l_new_rec.normal_hours := p_new_rec.normal_hours;
3111   l_new_rec.location_id := p_new_rec.location_id;
3112   l_new_rec.position_id := p_new_rec.position_id;
3113   l_new_rec.employment_category := p_new_rec.employment_category;
3114   l_new_rec.person_id := p_new_rec.person_id;
3115   l_new_rec.assignment_type := p_new_rec.assignment_type;
3116   l_new_rec.business_group_id := p_new_rec.business_group_id;
3117   l_new_rec.effective_start_date :=p_new_rec.effective_start_date;
3118   l_new_rec.effective_end_date :=p_new_rec.effective_end_date;
3119   l_new_rec.ass_attribute1 :=p_new_rec.ass_attribute1;
3120   l_new_rec.ass_attribute2 :=p_new_rec.ass_attribute2;
3121   l_new_rec.ass_attribute3 :=p_new_rec.ass_attribute3;
3122   l_new_rec.ass_attribute4 :=p_new_rec.ass_attribute4;
3123   l_new_rec.ass_attribute5 :=p_new_rec.ass_attribute5;
3124   l_new_rec.ass_attribute6 :=p_new_rec.ass_attribute6;
3125   l_new_rec.ass_attribute7 :=p_new_rec.ass_attribute7;
3126   l_new_rec.ass_attribute8 :=p_new_rec.ass_attribute8;
3127   l_new_rec.ass_attribute9 :=p_new_rec.ass_attribute9;
3128   l_new_rec.ass_attribute10 :=p_new_rec.ass_attribute10;
3129   l_new_rec.payroll_id :=p_new_rec.payroll_id;
3130   l_new_rec.grade_id :=p_new_rec.grade_id;
3131   l_new_rec.primary_flag := p_new_rec.primary_flag;
3132   l_new_rec.soft_coding_keyflex_id := p_new_rec.soft_coding_keyflex_id;
3133   ---------------------
3134 
3135   if p_new_rec.effective_start_date = p_old_rec.effective_start_date then
3136     l_new_rec.update_mode := 'CORRECTION';
3137     l_old_rec.update_mode := 'CORRECTION';
3138   else
3139     l_new_rec.update_mode := 'UPDATE';
3140     l_old_rec.update_mode := 'UPDATE';
3141   end if;
3142 
3143   l_event  := nvl(p_event ,'UPDATE') ;
3144   ---------------
3145   log_asg_chg
3146   (p_event   => p_event
3147   ,p_old_rec => l_old_rec
3148   ,p_new_rec => l_new_rec
3149   );
3150   ---------------
3151 
3152   hr_utility.set_location('Exiting:'|| l_proc, 99);
3153 
3154 end ;
3155 --
3156 procedure log_asg_chg
3157           (p_event     in  varchar2
3158           ,p_old_rec   in  g_asg_rec_type
3159           ,p_new_rec   in  g_asg_rec_type
3160           ) is
3161 --
3162   l_chg_evt_tab           g_char_tab_type;
3163   l_prmtr_01_tab          g_char_tab_type;
3164   l_prmtr_02_tab          g_char_tab_type;
3165   l_prmtr_03_tab          g_char_tab_type;
3166   l_prmtr_04_tab          g_char_tab_type;
3167   l_prmtr_05_tab          g_char_tab_type;
3168   l_prmtr_06_tab          g_char_tab_type;
3169   l_prmtr_07_tab          g_char_tab_type;
3170   l_new_val1              g_new_val;
3171   l_new_val2              g_new_val;
3172   l_new_val3              g_new_val;
3173   l_new_val4              g_new_val;
3174   l_new_val5              g_new_val;
3175   l_new_val6              g_new_val;
3176   l_old_val1              g_old_val;
3177   l_old_val2              g_old_val;
3178   l_old_val3              g_old_val;
3179   l_old_val4              g_old_val;
3180   l_old_val5              g_old_val;
3181   l_old_val6              g_old_val;
3182   l_tab_counter           binary_integer := 0;
3183   l_chg_eff_dt            date;
3184   l_count                 number;
3185   l_ext_chg_evt_log_id    number;
3186   l_object_version_number number;
3187 --
3188 
3189 
3190   cursor c_position(p_position_id number ,
3191                     p_effective_date date )
3192   is
3193   select name
3194   from HR_ALL_POSITIONS_F   pos
3195   where pos.position_id = p_position_id
3196    and  p_effective_date between nvl(pos.effective_start_date, sysdate)
3197                        and nvl(pos.effective_end_date, sysdate)
3198   ;
3199 
3200 
3201   cursor c_location(p_location_id hr_locations_all.location_id%type)
3202   is
3203   select location_code
3204   from hr_locations_all hl
3205   where hl.location_id = p_location_id;
3206 
3207   cursor c_assignment_status
3208     (p_assignment_status_type_id per_assignment_status_types.assignment_status_type_id%type)
3209   is
3210   select ast.user_status
3211   from per_assignment_status_types ast
3212   where ast.assignment_status_type_id = p_assignment_status_type_id;
3213 
3214   cursor c_payroll_name
3215     (p_payroll_id     pay_all_payrolls_f.payroll_id%type
3216     ,p_effective_date date)
3217   is
3218   select ppf.payroll_name
3219   from pay_all_payrolls_f ppf
3220   where payroll_id = p_payroll_id
3221   and p_effective_date between nvl(ppf.effective_start_date, sysdate)
3222                        and nvl(ppf.effective_end_date, sysdate);
3223 
3224   cursor c_grade_name
3225     (p_grade_id number ,p_effective_date date) is
3226     select g.name
3227     from per_grades g
3228     where g.grade_id = p_grade_id
3229       and g.date_from <= p_effective_date
3230       and ((g.date_to is null) or (g.date_to >= p_effective_date )) ;
3231 --
3232 
3233   l_old_position           HR_ALL_POSITIONS_F.name%type;
3234   l_new_position           HR_ALL_POSITIONS_F.name%type;
3235   l_old_location          hr_locations_all.location_code%type; -- UTF Change Bug 2254683
3236   l_new_location          hr_locations_all.location_code%type; -- UTF Change Bug 2254683
3237   l_old_assignment_status per_assignment_status_types.user_status%type; -- UTF Change Bug 2254683
3238   l_new_assignment_status per_assignment_status_types.user_status%type; -- UTF Change Bug 2254683
3239   l_old_payroll_name      pay_all_payrolls_f.payroll_name%type; --UTF Change Bug 2254683
3240   l_new_payroll_name      pay_all_payrolls_f.payroll_name%type; --UTF Change Bug 2254683
3241   l_old_grade_name        per_grades.name%type;
3242   l_new_grade_name        per_grades.name%type;
3243 --
3244   l_proc          varchar2(80) := 'ben_ext_chlg.log_asg_chg';
3245 --
3246 begin
3247 --
3248   hr_utility.set_location('Entering:'|| l_proc, 10);
3249 --
3250   if p_event = 'UPDATE' then
3251 --
3252     if nvl(p_old_rec.assignment_status_type_id, 1)
3253         <> nvl(p_new_rec.assignment_status_type_id, 1) then
3254 
3255       -- read old and new assignment status
3256       open c_assignment_status(p_old_rec.assignment_status_type_id);
3257       fetch c_assignment_status into l_old_assignment_status;
3258       close c_assignment_status;
3259       open c_assignment_status(p_new_rec.assignment_status_type_id);
3260       fetch c_assignment_status into l_new_assignment_status;
3261       close c_assignment_status;
3262 
3263       l_tab_counter := l_tab_counter + 1;
3264       l_chg_evt_tab(l_tab_counter) := 'COAS';
3265       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3266       l_prmtr_02_tab(l_tab_counter) := null;
3267       l_prmtr_03_tab(l_tab_counter) := null;
3268       l_prmtr_04_tab(l_tab_counter) := null;
3269       l_prmtr_05_tab(l_tab_counter) := null;
3270       l_prmtr_06_tab(l_tab_counter) := null;
3271       l_prmtr_07_tab(l_tab_counter) := null;
3272       l_old_val1(l_tab_counter)     := l_old_assignment_status;
3273       l_new_val1(l_tab_counter)     := l_new_assignment_status;
3274     end if;
3275     if nvl(p_old_rec.hourly_salaried_code, '$')
3276         <> nvl(p_new_rec.hourly_salaried_code, '$') then
3277       l_tab_counter := l_tab_counter + 1;
3278       l_chg_evt_tab(l_tab_counter) := 'COHS';
3279       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3280       l_prmtr_02_tab(l_tab_counter) := null;
3281       l_prmtr_03_tab(l_tab_counter) := null;
3282       l_prmtr_04_tab(l_tab_counter) := null;
3283       l_prmtr_05_tab(l_tab_counter) := null;
3284       l_prmtr_06_tab(l_tab_counter) := null;
3285       l_prmtr_07_tab(l_tab_counter) := null;
3286       l_old_val1(l_tab_counter)     := p_old_rec.hourly_salaried_code;
3287       l_new_val1(l_tab_counter)     := p_new_rec.hourly_salaried_code;
3288     end if;
3289     if nvl(p_old_rec.location_id, 1)
3290         <> nvl(p_new_rec.location_id, 1) then
3291       -- read old and new locations
3292       open c_location(p_old_rec.location_id);
3293       fetch c_location into l_old_location;
3294       close c_location;
3295       open c_location(p_new_rec.location_id);
3296       fetch c_location into l_new_location;
3297       close c_location;
3298       l_tab_counter := l_tab_counter + 1;
3299       l_chg_evt_tab(l_tab_counter) := 'COAL';
3300       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3301       l_prmtr_02_tab(l_tab_counter) := null;
3302       l_prmtr_03_tab(l_tab_counter) := null;
3303       l_prmtr_04_tab(l_tab_counter) := null;
3304       l_prmtr_05_tab(l_tab_counter) := null;
3305       l_prmtr_06_tab(l_tab_counter) := null;
3306       l_prmtr_07_tab(l_tab_counter) := null;
3307       l_old_val1(l_tab_counter)     := l_old_location;
3308       l_new_val1(l_tab_counter)     := l_new_location;
3309     end if;
3310 
3311     if nvl(p_old_rec.position_id, 1)
3312         <> nvl(p_new_rec.position_id, 1) then
3313       -- read old and new position
3314       open c_position(p_old_rec.position_id , p_new_rec.effective_start_date  );
3315       fetch c_position into l_old_position;
3316       close c_position;
3317       open c_position(p_new_rec.position_id , p_new_rec.effective_start_date );
3318       fetch c_position into l_new_position;
3319       close c_position;
3320       l_tab_counter := l_tab_counter + 1;
3321       l_chg_evt_tab(l_tab_counter) := 'COAPOS';
3322       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3323       l_prmtr_02_tab(l_tab_counter) := null;
3324       l_prmtr_03_tab(l_tab_counter) := null;
3325       l_prmtr_04_tab(l_tab_counter) := null;
3326       l_prmtr_05_tab(l_tab_counter) := null;
3327       l_prmtr_06_tab(l_tab_counter) := null;
3328       l_prmtr_07_tab(l_tab_counter) := null;
3329       l_old_val1(l_tab_counter)     := l_old_position;
3330       l_new_val1(l_tab_counter)     := l_new_position;
3331     end if;
3332 
3333     if nvl(p_old_rec.employment_category, '$')
3334         <> nvl(p_new_rec.employment_category, '$') then
3335       l_tab_counter := l_tab_counter + 1;
3336       l_chg_evt_tab(l_tab_counter) := 'COEC';
3337       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3338       l_prmtr_02_tab(l_tab_counter) := null;
3339       l_prmtr_03_tab(l_tab_counter) := null;
3340       l_prmtr_04_tab(l_tab_counter) := null;
3341       l_prmtr_05_tab(l_tab_counter) := null;
3342       l_prmtr_06_tab(l_tab_counter) := null;
3343       l_prmtr_07_tab(l_tab_counter) := null;
3344       l_old_val1(l_tab_counter)     := HR_GENERAL.DECODE_LOOKUP('EMP_CAT',p_old_rec.employment_category); --bug#4699913
3345       l_new_val1(l_tab_counter)     := HR_GENERAL.DECODE_LOOKUP('EMP_CAT',p_new_rec.employment_category); --bug#4699913;
3346     end if;
3347     if nvl(p_old_rec.assignment_type, '$') <> 'B' and p_new_rec.assignment_type = 'B' then
3348       l_tab_counter := l_tab_counter + 1;
3349       l_chg_evt_tab(l_tab_counter) := 'ABA';
3350       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3351       l_prmtr_02_tab(l_tab_counter) := null;
3352       l_prmtr_03_tab(l_tab_counter) := null;
3353       l_prmtr_04_tab(l_tab_counter) := null;
3354       l_prmtr_05_tab(l_tab_counter) := null;
3355       l_prmtr_06_tab(l_tab_counter) := null;
3356       l_prmtr_07_tab(l_tab_counter) := null;
3357       l_old_val1(l_tab_counter)     := null;
3358       l_new_val1(l_tab_counter)     := null;
3359     end if;
3360     if nvl(p_old_rec.ass_attribute1, '$')
3361         <> nvl(p_new_rec.ass_attribute1, '$') then
3362       l_tab_counter := l_tab_counter + 1;
3363       l_chg_evt_tab(l_tab_counter) := 'COAF01';
3364       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3365       l_prmtr_02_tab(l_tab_counter) := null;
3366       l_prmtr_03_tab(l_tab_counter) := null;
3367       l_prmtr_04_tab(l_tab_counter) := null;
3368       l_prmtr_05_tab(l_tab_counter) := null;
3369       l_prmtr_06_tab(l_tab_counter) := null;
3370       l_prmtr_07_tab(l_tab_counter) := null;
3371       l_old_val1(l_tab_counter)     := p_old_rec.ass_attribute1;
3372       l_new_val1(l_tab_counter)     := p_new_rec.ass_attribute1;
3373     end if;
3374     if nvl(p_old_rec.ass_attribute2, '$')
3375         <> nvl(p_new_rec.ass_attribute2, '$') then
3376       l_tab_counter := l_tab_counter + 1;
3377       l_chg_evt_tab(l_tab_counter) := 'COAF02';
3378       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3379       l_prmtr_02_tab(l_tab_counter) := null;
3380       l_prmtr_03_tab(l_tab_counter) := null;
3381       l_prmtr_04_tab(l_tab_counter) := null;
3382       l_prmtr_05_tab(l_tab_counter) := null;
3383       l_prmtr_06_tab(l_tab_counter) := null;
3384       l_prmtr_07_tab(l_tab_counter) := null;
3385       l_old_val1(l_tab_counter)     := p_old_rec.ass_attribute2;
3386       l_new_val1(l_tab_counter)     := p_new_rec.ass_attribute2;
3387     end if;
3388     if nvl(p_old_rec.ass_attribute3, '$')
3389         <> nvl(p_new_rec.ass_attribute3, '$') then
3390       l_tab_counter := l_tab_counter + 1;
3391       l_chg_evt_tab(l_tab_counter) := 'COAF03';
3392       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3393       l_prmtr_02_tab(l_tab_counter) := null;
3394       l_prmtr_03_tab(l_tab_counter) := null;
3395       l_prmtr_04_tab(l_tab_counter) := null;
3396       l_prmtr_05_tab(l_tab_counter) := null;
3397       l_prmtr_06_tab(l_tab_counter) := null;
3398       l_prmtr_07_tab(l_tab_counter) := null;
3399       l_old_val1(l_tab_counter)     := p_old_rec.ass_attribute3;
3400       l_new_val1(l_tab_counter)     := p_new_rec.ass_attribute3;
3401     end if;
3402     if nvl(p_old_rec.ass_attribute4, '$')
3403         <> nvl(p_new_rec.ass_attribute4, '$') then
3404       l_tab_counter := l_tab_counter + 1;
3405       l_chg_evt_tab(l_tab_counter) := 'COAF04';
3406       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3407       l_prmtr_02_tab(l_tab_counter) := null;
3408       l_prmtr_03_tab(l_tab_counter) := null;
3409       l_prmtr_04_tab(l_tab_counter) := null;
3410       l_prmtr_05_tab(l_tab_counter) := null;
3411       l_prmtr_06_tab(l_tab_counter) := null;
3412       l_prmtr_07_tab(l_tab_counter) := null;
3413       l_old_val1(l_tab_counter)     := p_old_rec.ass_attribute4;
3414       l_new_val1(l_tab_counter)     := p_new_rec.ass_attribute4;
3415     end if;
3416     if nvl(p_old_rec.ass_attribute5, '$')
3417         <> nvl(p_new_rec.ass_attribute5, '$') then
3418       l_tab_counter := l_tab_counter + 1;
3419       l_chg_evt_tab(l_tab_counter) := 'COAF05';
3420       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3421       l_prmtr_02_tab(l_tab_counter) := null;
3422       l_prmtr_03_tab(l_tab_counter) := null;
3423       l_prmtr_04_tab(l_tab_counter) := null;
3424       l_prmtr_05_tab(l_tab_counter) := null;
3425       l_prmtr_06_tab(l_tab_counter) := null;
3426       l_prmtr_07_tab(l_tab_counter) := null;
3427       l_old_val1(l_tab_counter)     := p_old_rec.ass_attribute5;
3428       l_new_val1(l_tab_counter)     := p_new_rec.ass_attribute5;
3429     end if;
3430     if nvl(p_old_rec.ass_attribute6, '$')
3431         <> nvl(p_new_rec.ass_attribute6, '$') then
3432       l_tab_counter := l_tab_counter + 1;
3433       l_chg_evt_tab(l_tab_counter) := 'COAF06';
3434       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3435       l_prmtr_02_tab(l_tab_counter) := null;
3436       l_prmtr_03_tab(l_tab_counter) := null;
3437       l_prmtr_04_tab(l_tab_counter) := null;
3438       l_prmtr_05_tab(l_tab_counter) := null;
3439       l_prmtr_06_tab(l_tab_counter) := null;
3440       l_prmtr_07_tab(l_tab_counter) := null;
3441       l_old_val1(l_tab_counter)     := p_old_rec.ass_attribute6;
3442       l_new_val1(l_tab_counter)     := p_new_rec.ass_attribute6;
3443     end if;
3444     if nvl(p_old_rec.ass_attribute7, '$')
3445         <> nvl(p_new_rec.ass_attribute7, '$') then
3446       l_tab_counter := l_tab_counter + 1;
3447       l_chg_evt_tab(l_tab_counter) := 'COAF07';
3448       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3449       l_prmtr_02_tab(l_tab_counter) := null;
3450       l_prmtr_03_tab(l_tab_counter) := null;
3451       l_prmtr_04_tab(l_tab_counter) := null;
3452       l_prmtr_05_tab(l_tab_counter) := null;
3453       l_prmtr_06_tab(l_tab_counter) := null;
3454       l_prmtr_07_tab(l_tab_counter) := null;
3455       l_old_val1(l_tab_counter)     := p_old_rec.ass_attribute7;
3456       l_new_val1(l_tab_counter)     := p_new_rec.ass_attribute7;
3457     end if;
3458     if nvl(p_old_rec.ass_attribute8, '$')
3459         <> nvl(p_new_rec.ass_attribute8, '$') then
3460       l_tab_counter := l_tab_counter + 1;
3461       l_chg_evt_tab(l_tab_counter) := 'COAF08';
3462       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3463       l_prmtr_02_tab(l_tab_counter) := null;
3464       l_prmtr_03_tab(l_tab_counter) := null;
3465       l_prmtr_04_tab(l_tab_counter) := null;
3466       l_prmtr_05_tab(l_tab_counter) := null;
3467       l_prmtr_06_tab(l_tab_counter) := null;
3468       l_prmtr_07_tab(l_tab_counter) := null;
3469       l_old_val1(l_tab_counter)     := p_old_rec.ass_attribute8;
3470       l_new_val1(l_tab_counter)     := p_new_rec.ass_attribute8;
3471     end if;
3472     if nvl(p_old_rec.ass_attribute9, '$')
3473         <> nvl(p_new_rec.ass_attribute9, '$') then
3474       l_tab_counter := l_tab_counter + 1;
3475       l_chg_evt_tab(l_tab_counter) := 'COAF09';
3476       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3477       l_prmtr_02_tab(l_tab_counter) := null;
3478       l_prmtr_03_tab(l_tab_counter) := null;
3479       l_prmtr_04_tab(l_tab_counter) := null;
3480       l_prmtr_05_tab(l_tab_counter) := null;
3481       l_prmtr_06_tab(l_tab_counter) := null;
3482       l_prmtr_07_tab(l_tab_counter) := null;
3483       l_old_val1(l_tab_counter)     := p_old_rec.ass_attribute9;
3484       l_new_val1(l_tab_counter)     := p_new_rec.ass_attribute9;
3485     end if;
3486     if nvl(p_old_rec.ass_attribute10, '$')
3487         <> nvl(p_new_rec.ass_attribute10, '$') then
3488       l_tab_counter := l_tab_counter + 1;
3489       l_chg_evt_tab(l_tab_counter) := 'COAF10';
3490       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3491       l_prmtr_02_tab(l_tab_counter) := null;
3492       l_prmtr_03_tab(l_tab_counter) := null;
3493       l_prmtr_04_tab(l_tab_counter) := null;
3494       l_prmtr_05_tab(l_tab_counter) := null;
3495       l_prmtr_06_tab(l_tab_counter) := null;
3496       l_prmtr_07_tab(l_tab_counter) := null;
3497       l_old_val1(l_tab_counter)     := p_old_rec.ass_attribute10;
3498       l_new_val1(l_tab_counter)     := p_new_rec.ass_attribute10;
3499     end if;
3500     if (nvl(p_old_rec.payroll_id, -1)
3501         <> nvl(p_new_rec.payroll_id, -1))
3502         --RCHASE make sure the payroll is a change and not an add
3503         and (p_old_rec.payroll_id is not null) then
3504       open c_payroll_name(p_old_rec.payroll_id, p_new_rec.effective_start_date);
3505       fetch c_payroll_name into l_old_payroll_name;
3506       close c_payroll_name;
3507       open c_payroll_name(p_new_rec.payroll_id, p_new_rec.effective_start_date);
3508       fetch c_payroll_name into l_new_payroll_name;
3509       close c_payroll_name;
3510       l_tab_counter := l_tab_counter + 1;
3511       l_chg_evt_tab(l_tab_counter) := 'COPP';
3512       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3513       l_prmtr_02_tab(l_tab_counter) := p_old_rec.payroll_id;
3514       l_prmtr_03_tab(l_tab_counter) := p_new_rec.payroll_id;
3515       l_prmtr_04_tab(l_tab_counter) := null;
3516       l_prmtr_05_tab(l_tab_counter) := null;
3517       l_prmtr_06_tab(l_tab_counter) := null;
3518       l_prmtr_07_tab(l_tab_counter) := null;
3519       l_old_val1(l_tab_counter)     := l_old_payroll_name;
3520       l_new_val1(l_tab_counter)     := l_new_payroll_name;
3521     end if;
3522     if (nvl(p_old_rec.grade_id, -1)
3523         <> nvl(p_new_rec.grade_id, -1))  then
3524       open c_grade_name(p_old_rec.grade_id, p_new_rec.effective_start_date);
3525       fetch c_grade_name into l_old_grade_name;
3526       close c_grade_name;
3527       open c_grade_name(p_new_rec.grade_id, p_new_rec.effective_start_date);
3528       fetch c_grade_name into l_new_grade_name;
3529       close c_grade_name;
3530       l_tab_counter := l_tab_counter + 1;
3531       l_chg_evt_tab(l_tab_counter) := 'CGRDID';
3532       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3533       l_prmtr_02_tab(l_tab_counter) := p_old_rec.grade_id;
3534       l_prmtr_03_tab(l_tab_counter) := p_new_rec.grade_id;
3535       l_prmtr_04_tab(l_tab_counter) := null;
3536       l_prmtr_05_tab(l_tab_counter) := null;
3537       l_prmtr_06_tab(l_tab_counter) := null;
3538       l_prmtr_07_tab(l_tab_counter) := null;
3539       l_old_val1(l_tab_counter)     := l_old_grade_name;
3540       l_new_val1(l_tab_counter)     := l_new_grade_name;
3541     end if;
3542 
3543 --Start Bug 1554477
3544     if nvl(p_old_rec.normal_hours, '0')
3545         <> nvl(p_new_rec.normal_hours, '0') then
3546       l_tab_counter := l_tab_counter + 1;
3547       l_chg_evt_tab(l_tab_counter) := 'CWH';
3548       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3549       l_prmtr_02_tab(l_tab_counter) := null;
3550       l_prmtr_03_tab(l_tab_counter) := null;
3551       l_prmtr_04_tab(l_tab_counter) := null;
3552       l_prmtr_05_tab(l_tab_counter) := null;
3553       l_prmtr_06_tab(l_tab_counter) := null;
3554       l_prmtr_07_tab(l_tab_counter) := null;
3555       l_old_val1(l_tab_counter)     := p_old_rec.normal_hours;
3556       l_new_val1(l_tab_counter)     := p_new_rec.normal_hours;
3557     end if;
3558   --End Bug 1554477
3559   --
3560   -- vjhanak
3561   if nvl(p_old_rec.soft_coding_keyflex_id, '0')
3562         <> nvl(p_new_rec.soft_coding_keyflex_id, '0') then
3563       l_tab_counter := l_tab_counter + 1;
3564       l_chg_evt_tab(l_tab_counter) := 'COSCKFF';
3565       l_prmtr_01_tab(l_tab_counter) := p_old_rec.assignment_id;
3566       l_prmtr_02_tab(l_tab_counter) := fnd_date.date_to_canonical(TRUNC(p_old_rec.effective_start_date));
3567       l_prmtr_03_tab(l_tab_counter) := fnd_date.date_to_canonical(TRUNC(p_old_rec.effective_end_date));
3568       l_prmtr_04_tab(l_tab_counter) := fnd_date.date_to_canonical(TRUNC(p_new_rec.effective_start_date));
3569       l_prmtr_05_tab(l_tab_counter) := fnd_date.date_to_canonical(TRUNC(p_new_rec.effective_end_date));
3570       l_prmtr_06_tab(l_tab_counter) := null;
3571       l_prmtr_07_tab(l_tab_counter) := null;
3572       l_old_val1(l_tab_counter)     := p_old_rec.soft_coding_keyflex_id;
3573       l_new_val1(l_tab_counter)     := p_new_rec.soft_coding_keyflex_id;
3574     end if;
3575   -- vjhanak
3576 
3577   elsif p_event = 'INSERT' then
3578     if p_new_rec.assignment_type = 'B' then
3579       --l_person_id          := p_new_rec.person_id;
3580       --l_business_group_id  := p_new_rec.business_group_id;
3581       l_tab_counter := l_tab_counter + 1;
3582       l_chg_evt_tab(l_tab_counter) := 'ABA';
3583       l_prmtr_01_tab(l_tab_counter) := p_new_rec.assignment_id;
3584       l_prmtr_02_tab(l_tab_counter) := null;
3585       l_prmtr_03_tab(l_tab_counter) := null;
3586       l_prmtr_04_tab(l_tab_counter) := null;
3587       l_prmtr_05_tab(l_tab_counter) := null;
3588       l_prmtr_06_tab(l_tab_counter) := null;
3589       l_prmtr_07_tab(l_tab_counter) := null;
3590       l_old_val1(l_tab_counter)     := null;
3591       l_new_val1(l_tab_counter)     := null;
3592     end if;
3593 
3594     -- rpinjala
3595     IF p_new_rec.assignment_type   = 'E' AND
3596        nvl(p_new_rec.primary_flag,'N') = 'N'    THEN
3597       l_tab_counter := l_tab_counter + 1;
3598       l_chg_evt_tab(l_tab_counter) := 'ASEA';
3599       l_prmtr_01_tab(l_tab_counter) := p_new_rec.assignment_id;
3600       l_prmtr_02_tab(l_tab_counter) := null;
3601       l_prmtr_03_tab(l_tab_counter) := null;
3602       l_prmtr_04_tab(l_tab_counter) := null;
3603       l_prmtr_05_tab(l_tab_counter) := null;
3604       l_prmtr_06_tab(l_tab_counter) := null;
3605       l_prmtr_07_tab(l_tab_counter) := null;
3606       l_old_val1(l_tab_counter)     := null;
3607       l_new_val1(l_tab_counter)     := p_new_rec.effective_start_date;
3608     END IF;
3609     -- rpinjala
3610 
3611     --Start Bug 1554477
3612 /*
3613     if p_new_rec.normal_hours is not null then
3614       l_tab_counter := l_tab_counter + 1;
3615       l_chg_evt_tab(l_tab_counter) := 'CWH';
3616       l_prmtr_01_tab(l_tab_counter) := p_new_rec.assignment_id;
3617       l_prmtr_02_tab(l_tab_counter) := null;
3618       l_prmtr_03_tab(l_tab_counter) := null;
3619       l_prmtr_04_tab(l_tab_counter) := null;
3620       l_prmtr_05_tab(l_tab_counter) := null;
3621       l_prmtr_06_tab(l_tab_counter) := null;
3622       l_prmtr_07_tab(l_tab_counter) := null;
3623       l_old_val1(l_tab_counter)     := null;
3624       l_new_val1(l_tab_counter)     := p_new_rec.normal_hours;
3625     end if;
3626 */
3627   --End Bug 1554477
3628   --
3629   end if;
3630 --
3631   for l_count in 1..l_chg_evt_tab.count loop
3632    if change_event_is_enabled(l_chg_evt_tab(l_count),p_new_rec.effective_start_date) then
3633     ben_ext_chg_evt_api.create_ext_chg_evt
3634     (p_validate                    => FALSE
3635     ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
3636     ,p_chg_evt_cd                  => l_chg_evt_tab(l_count)
3637     ,p_chg_eff_dt                  => p_new_rec.effective_start_date
3638     ,p_prmtr_01                    => l_prmtr_01_tab(l_count)
3639     ,p_prmtr_02                    => l_prmtr_02_tab(l_count)
3640     ,p_prmtr_03                    => l_prmtr_03_tab(l_count)
3641     ,p_prmtr_04                    => l_prmtr_04_tab(l_count)
3642     ,p_prmtr_05                    => l_prmtr_05_tab(l_count)
3643     ,p_prmtr_06                    => l_prmtr_06_tab(l_count)
3644     ,p_prmtr_07                    => l_prmtr_07_tab(l_count)
3645     ,p_prmtr_10                    => p_new_rec.update_mode
3646     ,p_person_id                   => p_new_rec.person_id
3647     ,p_business_group_id           => p_new_rec.business_group_id
3648     ,p_object_version_number       => l_object_version_number
3649     ,p_effective_date              => p_new_rec.effective_start_date
3650     ,p_new_val1                    => l_new_val1(l_count)
3651     ,p_old_val1                    => l_old_val1(l_count)
3652     );
3653    end if;
3654   end loop;
3655 --
3656   hr_utility.set_location('Exiting:'|| l_proc, 99);
3657 --
3658 end log_asg_chg;
3659 --
3660 procedure log_abs_chg
3661           (p_event     in  varchar2
3662           ,p_old_rec   in  g_abs_rec_type
3663           ,p_new_rec   in  g_abs_rec_type
3664           ) is
3665 --
3666   l_chg_evt_tab           g_char_tab_type;
3667   l_prmtr_01_tab          g_char_tab_type;
3668   l_prmtr_02_tab          g_char_tab_type;
3669   l_prmtr_03_tab          g_char_tab_type;
3670   l_prmtr_04_tab          g_char_tab_type;
3671   l_prmtr_05_tab          g_char_tab_type;
3672   l_prmtr_06_tab          g_char_tab_type;
3673   l_prmtr_07_tab          g_char_tab_type;
3674   l_new_val1              g_new_val;
3675   l_new_val2              g_new_val;
3676   l_new_val3              g_new_val;
3677   l_new_val4              g_new_val;
3678   l_new_val5              g_new_val;
3679   l_new_val6              g_new_val;
3680   l_old_val1              g_old_val;
3681   l_old_val2              g_old_val;
3682   l_old_val3              g_old_val;
3683   l_old_val4              g_old_val;
3684   l_old_val5              g_old_val;
3685   l_old_val6              g_old_val;
3686   l_tab_counter           binary_integer := 0;
3687   l_chg_eff_dt            date;
3688   l_person_id             number;
3689   l_business_group_id     number;
3690   l_count                 number;
3691   l_ext_chg_evt_log_id    number;
3692   l_object_version_number number;
3693 --
3694   l_old_absence_type          varchar2(100);
3695   l_new_absence_type          varchar2(100);
3696   l_old_absence_reason        varchar2(100);
3697   l_new_absence_reason        varchar2(100);
3698 --
3699   l_proc          varchar2(80) := 'ben_ext_chlg.log_abs_chg';
3700 --
3701 -- cursor definitions
3702 --
3703   cursor c_absence_type(p_absence_attendance_type_id number)
3704   is
3705   select aat.name
3706   from per_absence_attendance_types aat
3707   where aat.absence_attendance_type_id = p_absence_attendance_type_id;
3708 
3709   cursor c_absence_reason(p_abs_attendance_reason_id  number)
3710   is
3711   select aar.name
3712   from per_abs_attendance_reasons aar
3713   where aar.abs_attendance_reason_id = p_abs_attendance_reason_id;
3714 --
3715 begin
3716 --
3717   hr_utility.set_location('Entering:'|| l_proc, 10);
3718 --
3719   if p_event = 'UPDATE' then
3720 --
3721     l_business_group_id := p_new_rec.business_group_id;
3722     l_person_id := p_new_rec.person_id;
3723     if nvl(p_old_rec.abs_attendance_reason_id, 1)
3724         <> nvl(p_new_rec.abs_attendance_reason_id, 1) then
3725 
3726       -- get old and new absence reason
3727       open c_absence_reason(p_old_rec.abs_attendance_reason_id);
3728       fetch c_absence_reason into l_old_absence_reason;
3729       close c_absence_reason;
3730       open c_absence_reason(p_new_rec.abs_attendance_reason_id);
3731       fetch c_absence_reason into l_new_absence_reason;
3732       close c_absence_reason;
3733 
3734       l_chg_eff_dt := trunc(sysdate);
3735       l_tab_counter := l_tab_counter + 1;
3736       l_chg_evt_tab(l_tab_counter) := 'COAR';
3737       l_prmtr_01_tab(l_tab_counter) := p_old_rec.absence_attendance_id;
3738       l_prmtr_02_tab(l_tab_counter) := null;
3739       l_prmtr_03_tab(l_tab_counter) := null;
3740       l_prmtr_04_tab(l_tab_counter) := null;
3741       l_prmtr_05_tab(l_tab_counter) := null;
3742       l_prmtr_06_tab(l_tab_counter) := null;
3743       l_prmtr_07_tab(l_tab_counter) := null;
3744       l_old_val1(l_tab_counter)     := l_old_absence_reason;
3745       l_old_val2(l_tab_counter)     := null;
3746       l_old_val3(l_tab_counter)     := null;
3747       l_old_val4(l_tab_counter)     := null;
3748       l_new_val1(l_tab_counter)     := l_new_absence_reason;
3749       l_new_val2(l_tab_counter)     := null;
3750       l_new_val3(l_tab_counter)     := null;
3751       l_new_val4(l_tab_counter)     := null;
3752     end if;
3753     if nvl(p_old_rec.date_start, to_date('01/01/0001', 'dd/mm/yyyy'))
3754         <> nvl(p_new_rec.date_start, to_date('01/01/0001', 'dd/mm/yyyy')) then
3755       l_chg_eff_dt := trunc(sysdate);
3756       l_tab_counter := l_tab_counter + 1;
3757       l_chg_evt_tab(l_tab_counter) := 'COAAS';
3758       l_prmtr_01_tab(l_tab_counter) := p_old_rec.absence_attendance_id;
3759       l_prmtr_02_tab(l_tab_counter) := null;
3760       l_prmtr_03_tab(l_tab_counter) := null;
3761       l_prmtr_04_tab(l_tab_counter) := null;
3762       l_prmtr_05_tab(l_tab_counter) := null;
3763       l_prmtr_06_tab(l_tab_counter) := null;
3764       l_prmtr_07_tab(l_tab_counter) := null;
3765       l_old_val1(l_tab_counter)     := to_char(p_old_rec.date_start, 'mm/dd/yyyy');
3766       l_old_val2(l_tab_counter)     := null;
3767       l_old_val3(l_tab_counter)     := null;
3768       l_old_val4(l_tab_counter)     := null;
3769       l_new_val1(l_tab_counter)     := to_char(p_new_rec.date_start, 'mm/dd/yyyy');
3770       l_new_val2(l_tab_counter)     := null;
3771       l_new_val3(l_tab_counter)     := null;
3772       l_new_val4(l_tab_counter)     := null;
3773     end if;
3774     if nvl(p_old_rec.date_end, to_date('01/01/0001', 'dd/mm/yyyy'))
3775         <> nvl(p_new_rec.date_end, to_date('01/01/0001', 'dd/mm/yyyy')) then
3776       l_chg_eff_dt := trunc(sysdate);
3777       l_tab_counter := l_tab_counter + 1;
3778       l_chg_evt_tab(l_tab_counter) := 'COAAE';
3779       l_prmtr_01_tab(l_tab_counter) := p_old_rec.absence_attendance_id;
3780       l_prmtr_02_tab(l_tab_counter) := null;
3781       l_prmtr_03_tab(l_tab_counter) := null;
3782       l_prmtr_04_tab(l_tab_counter) := null;
3783       l_prmtr_05_tab(l_tab_counter) := null;
3784       l_prmtr_06_tab(l_tab_counter) := null;
3785       l_prmtr_07_tab(l_tab_counter) := null;
3786       l_old_val1(l_tab_counter)     := to_char(p_old_rec.date_end, 'mm/dd/yyyy');
3787       l_old_val2(l_tab_counter)     := null;
3788       l_old_val3(l_tab_counter)     := null;
3789       l_old_val4(l_tab_counter)     := null;
3790       l_new_val1(l_tab_counter)     := to_char(p_new_rec.date_end, 'mm/dd/yyyy');
3791       l_new_val2(l_tab_counter)     := null;
3792       l_new_val3(l_tab_counter)     := null;
3793       l_new_val4(l_tab_counter)     := null;
3794     end if;
3795   --
3796   elsif p_event = 'INSERT' then
3797   --
3798     open c_absence_type(p_new_rec.absence_attendance_type_id);
3799     fetch c_absence_type into l_new_absence_type;
3800     close c_absence_type;
3801     open c_absence_reason(p_new_rec.abs_attendance_reason_id);
3802     fetch c_absence_reason into l_new_absence_reason;
3803     close c_absence_reason;
3804     --
3805     l_business_group_id := p_new_rec.business_group_id;
3806     l_person_id := p_new_rec.person_id;
3807     l_chg_eff_dt := trunc(nvl(nvl(p_new_rec.date_start,p_new_rec.date_projected_start), sysdate));
3808     l_tab_counter := l_tab_counter + 1;
3809     l_chg_evt_tab(l_tab_counter) := 'AA';
3810     l_prmtr_01_tab(l_tab_counter) := p_new_rec.absence_attendance_id;
3811     l_prmtr_02_tab(l_tab_counter) := null;
3812     l_prmtr_03_tab(l_tab_counter) := null;
3813     l_prmtr_04_tab(l_tab_counter) := null;
3814     l_prmtr_05_tab(l_tab_counter) := null;
3815     l_prmtr_06_tab(l_tab_counter) := null;
3816     l_prmtr_07_tab(l_tab_counter) := null;
3817     l_old_val1(l_tab_counter)     := null;
3818     l_old_val2(l_tab_counter)     := null;
3819     l_old_val3(l_tab_counter)     := null;
3820     l_old_val4(l_tab_counter)     := null;
3821     l_new_val1(l_tab_counter)     := l_new_absence_type;
3822     l_new_val2(l_tab_counter)     := l_new_absence_reason;
3823     l_new_val3(l_tab_counter)     := p_new_rec.date_start;
3824     l_new_val4(l_tab_counter)     := p_new_rec.date_end;
3825   --
3826   elsif p_event = 'DELETE' then
3827   --
3828     open c_absence_type(p_old_rec.absence_attendance_type_id);
3829     fetch c_absence_type into l_old_absence_type;
3830     close c_absence_type;
3831     open c_absence_reason(p_old_rec.abs_attendance_reason_id);
3832     fetch c_absence_reason into l_old_absence_reason;
3833     close c_absence_reason;
3834     --
3835     l_business_group_id := p_old_rec.business_group_id;
3836     l_person_id := p_old_rec.person_id;
3837     l_chg_eff_dt := trunc(sysdate);
3838     l_tab_counter := l_tab_counter + 1;
3839     l_chg_evt_tab(l_tab_counter) := 'DA';
3840     l_prmtr_01_tab(l_tab_counter) := p_old_rec.absence_attendance_id;
3841     l_prmtr_02_tab(l_tab_counter) := null;
3842     l_prmtr_03_tab(l_tab_counter) := null;
3843     l_prmtr_04_tab(l_tab_counter) := null;
3844     l_prmtr_05_tab(l_tab_counter) := null;
3845     l_prmtr_06_tab(l_tab_counter) := null;
3846     l_prmtr_07_tab(l_tab_counter) := null;
3847     l_old_val1(l_tab_counter)     := l_old_absence_type;
3848     l_old_val2(l_tab_counter)     := l_old_absence_reason;
3849     l_old_val3(l_tab_counter)     := p_old_rec.date_start;
3850     l_old_val4(l_tab_counter)     := p_old_rec.date_end;
3851     l_new_val1(l_tab_counter)     := null;
3852     l_new_val2(l_tab_counter)     := null;
3853     l_new_val3(l_tab_counter)     := null;
3854     l_new_val4(l_tab_counter)     := null;
3855   --
3856   end if;
3857   --
3858 --
3859   for l_count in 1..l_chg_evt_tab.count loop
3860    if change_event_is_enabled(l_chg_evt_tab(l_count),l_chg_eff_dt) then
3861     ben_ext_chg_evt_api.create_ext_chg_evt
3862     (p_validate                    => FALSE
3863     ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
3864     ,p_chg_evt_cd                  => l_chg_evt_tab(l_count)
3865     ,p_chg_eff_dt                  => l_chg_eff_dt
3866     ,p_prmtr_01                    => l_prmtr_01_tab(l_count)
3867     ,p_prmtr_02                    => l_prmtr_02_tab(l_count)
3868     ,p_prmtr_03                    => l_prmtr_03_tab(l_count)
3869     ,p_prmtr_04                    => l_prmtr_04_tab(l_count)
3870     ,p_prmtr_05                    => l_prmtr_05_tab(l_count)
3871     ,p_prmtr_06                    => l_prmtr_06_tab(l_count)
3872     ,p_prmtr_07                    => l_prmtr_07_tab(l_count)
3873     ,p_prmtr_10                    => p_new_rec.update_mode
3874     ,p_person_id                   => l_person_id
3875     ,p_business_group_id           => l_business_group_id
3876     ,p_object_version_number       => l_object_version_number
3877     ,p_effective_date              => l_chg_eff_dt
3878     ,p_new_val1                    => l_new_val1(l_count)
3879     ,p_new_val2                    => l_new_val2(l_count)
3880     ,p_new_val3                    => l_new_val3(l_count)
3881     ,p_new_val4                    => l_new_val4(l_count)
3882     ,p_old_val1                    => l_old_val1(l_count)
3883     ,p_old_val2                    => l_old_val2(l_count)
3884     ,p_old_val3                    => l_old_val3(l_count)
3885     ,p_old_val4                    => l_old_val4(l_count)
3886     );
3887    end if;
3888   end loop;
3889 --
3890   hr_utility.set_location('Exiting:'|| l_proc, 99);
3891 --
3892 end log_abs_chg;
3893 --
3894 --
3895 procedure log_benefit_chg(
3896         p_action                in varchar2, -- CREATE, REINSTATE, UPDATE, or DELETE
3897         p_pl_id                in number default null,
3898         p_old_pl_id            in number default null,
3899         p_oipl_id              in number default null,
3900         p_old_oipl_id          in number default null,
3901         p_enrt_cvg_strt_dt     in date default null,
3902         p_enrt_cvg_end_dt      in date default null,
3903         p_old_enrt_cvg_strt_dt in date default null,
3904         p_old_enrt_cvg_end_dt  in date default null,
3905         p_bnft_amt             in number default null,
3906         p_old_bnft_amt         in number default null,
3907         p_pen_attribute1       in varchar2 default null,
3908         p_pen_attribute2       in varchar2 default null,
3909         p_pen_attribute3       in varchar2 default null,
3910         p_pen_attribute4       in varchar2 default null,
3911         p_pen_attribute5       in varchar2 default null,
3912         p_pen_attribute6       in varchar2 default null,
3913         p_pen_attribute7       in varchar2 default null,
3914         p_pen_attribute8       in varchar2 default null,
3915         p_pen_attribute9       in varchar2 default null,
3916         p_pen_attribute10      in varchar2 default null,
3917         p_old_pen_attribute1   in varchar2 default null,
3918         p_old_pen_attribute2   in varchar2 default null,
3919         p_old_pen_attribute3   in varchar2 default null,
3920         p_old_pen_attribute4   in varchar2 default null,
3921         p_old_pen_attribute5   in varchar2 default null,
3922         p_old_pen_attribute6   in varchar2 default null,
3923         p_old_pen_attribute7   in varchar2 default null,
3924         p_old_pen_attribute8   in varchar2 default null,
3925         p_old_pen_attribute9   in varchar2 default null,
3926         p_old_pen_attribute10  in varchar2 default null,
3927         p_effective_start_date in date default null,
3928         p_effective_end_date   in date default null,
3929         p_prtt_enrt_rslt_id    in number default null,
3930         p_old_prtt_enrt_rslt_id in number default null,
3931         p_per_in_ler_id        in number default null,
3932         p_old_per_in_ler_id    in number default null,
3933         p_person_id            in number,
3934         p_business_group_id    in number,
3935         p_effective_date       in date ) is
3936 
3937   -- Local variable declarations
3938   --
3939   l_proc         varchar2(72) := 'ben_ext_chlg.log_benefit_chg';
3940 
3941   l_new_plan_name              ben_pl_f.name%type;
3942   l_old_plan_name              ben_pl_f.name%type;
3943   l_new_option_name            ben_opt_f.name%type;
3944   l_old_option_name            ben_opt_f.name%type;
3945   --
3946   l_ext_chg_evt_log_id number;
3947   l_object_version_number number;
3948   --
3949   -- Cursor declarations.
3950   cursor c_plan_name(p_pl_id number)
3951   is
3952   select name
3953   from ben_pl_f pl
3954   where pl.pl_id = p_pl_id
3955   and p_effective_date between pl.effective_start_date and pl.effective_end_date;
3956 
3957   cursor c_option_name(p_oipl_id number)
3958   is
3959   select opt.name
3960   from ben_oipl_f cop,
3961        ben_opt_f opt
3962   where cop.oipl_id = p_oipl_id
3963   and p_effective_date between cop.effective_start_date and cop.effective_end_date
3964   and cop.opt_id = opt.opt_id
3965   and p_effective_date between opt.effective_start_date and opt.effective_end_date;
3966   --
3967   begin
3968     --
3969     hr_utility.set_location('Entering:'||l_proc, 10);
3970     --
3971     -- Get the new values to be store or updated
3972     --
3973     if p_prtt_enrt_rslt_id is not null then
3974        --  fetch descriptions for old and new values.
3975        null;
3976     end if;
3977     --
3978     if p_action = 'CREATE' then
3979       --
3980       open c_plan_name(p_pl_id);
3981       fetch c_plan_name into l_new_plan_name;
3982       close c_plan_name;
3983       open c_option_name(p_oipl_id);
3984       fetch c_option_name into l_new_option_name;
3985       close c_option_name;
3986       --
3987      /* updating benefit amount actually creates a new result.
3988       so we need to add the following check to see if it's only
3989       a benefit amount update in which case we want the change log
3990       to show 'Update enrollment coverage amount'--shdas*/
3991 
3992       if p_old_pl_id is not null and p_pl_id = p_old_pl_id then
3993            if p_old_oipl_id is null or (p_old_oipl_id
3994            is not null and p_oipl_id = p_old_oipl_id) then
3995               if nvl(p_bnft_amt,0) <> nvl(p_old_bnft_amt,0) and
3996               change_event_is_enabled('COECA',p_effective_date) then
3997                  ben_ext_chg_evt_api.create_ext_chg_evt
3998                  (p_validate                    => FALSE
3999                  ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4000                  ,p_chg_evt_cd                  => 'COECA'  -- Change Coverage Amount
4001                  ,p_chg_eff_dt                  => p_effective_date
4002                  ,p_prmtr_01                    => to_char(p_pl_id)
4003                  ,p_prmtr_02                    => to_char(p_oipl_id)
4004                  ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4005                  ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4006                  ,p_person_id                   => p_person_id
4007                  ,p_business_group_id           => p_business_group_id
4008                  ,p_object_version_number       => l_object_version_number
4009                  ,p_effective_date              => p_effective_date
4010                  ,p_old_val1                    => p_old_bnft_amt
4011                  ,p_new_val1                    => p_bnft_amt
4012                  );
4013                end if;
4014             end if;
4015         --
4016       else
4017 
4018       if change_event_is_enabled('AB',p_effective_date) then
4019        ben_ext_chg_evt_api.create_ext_chg_evt
4020       (p_validate                    => FALSE
4021       ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4022       ,p_chg_evt_cd                  => 'AB'  -- Add Benefit
4023       ,p_chg_eff_dt                  => p_effective_date
4024       ,p_prmtr_01                    => to_char(p_pl_id)
4025       ,p_prmtr_02                    => to_char(p_oipl_id)
4026       ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4027       ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4028       ,p_person_id                   => p_person_id
4029       ,p_business_group_id           => p_business_group_id
4030       ,p_object_version_number       => l_object_version_number
4031       ,p_effective_date              => p_effective_date
4032       ,p_new_val1                    => l_new_plan_name
4033       ,p_new_val2                    => l_new_option_name
4034       ,p_new_val3                    => p_enrt_cvg_strt_dt
4035       ,p_new_val4                    => p_enrt_cvg_end_dt
4036       );
4037       end if;
4038      --
4039     end if;
4040     end if;  -- CREATE
4041     --
4042     if p_action = 'REINSTATE' then
4043       --
4044       open c_plan_name(p_pl_id);
4045       fetch c_plan_name into l_new_plan_name;
4046       close c_plan_name;
4047       open c_option_name(p_oipl_id);
4048       fetch c_option_name into l_new_option_name;
4049       close c_option_name;
4050       --
4051       if change_event_is_enabled('RB',p_effective_date) then
4052       ben_ext_chg_evt_api.create_ext_chg_evt
4053       (p_validate                    => FALSE
4054       ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4055       ,p_chg_evt_cd                  => 'RB'  -- Reinstate Benefit
4056       ,p_chg_eff_dt                  => p_effective_date
4057       ,p_prmtr_01                    => to_char(p_pl_id)
4058       ,p_prmtr_02                    => to_char(p_oipl_id)
4059       ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4060       ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4061       ,p_person_id                   => p_person_id
4062       ,p_business_group_id           => p_business_group_id
4063       ,p_object_version_number       => l_object_version_number
4064       ,p_effective_date              => p_effective_date
4065       ,p_old_val1                    => l_new_plan_name  --same as old
4066       ,p_old_val2                    => l_new_option_name -- same as old
4067       ,p_old_val3                    => p_old_enrt_cvg_strt_dt
4068       ,p_old_val4                    => p_old_enrt_cvg_end_dt
4069       ,p_new_val1                    => l_new_plan_name
4070       ,p_new_val2                    => l_new_option_name
4071       ,p_new_val3                    => p_enrt_cvg_strt_dt
4072       ,p_new_val4                    => p_enrt_cvg_end_dt
4073       );
4074       end if;
4075       --
4076     end if;  -- REINSTATE
4077     --
4078     if p_action = 'UPDATE' then
4079 
4080       if p_pl_id <> p_old_pl_id then
4081         --
4082         -- For Extract purposes, we recognize an update to plan as 2 separate
4083         -- changes:  Terminate Benefit, and Add Benefit.
4084         --
4085         if p_effective_date < p_old_enrt_cvg_strt_dt then
4086           --
4087           open c_plan_name(p_old_pl_id);
4088           fetch c_plan_name into l_old_plan_name;
4089           close c_plan_name;
4090           open c_option_name(p_old_oipl_id);
4091           fetch c_option_name into l_old_option_name;
4092           close c_option_name;
4093          --
4094          if change_event_is_enabled('TBBC',p_effective_date) then
4095           ben_ext_chg_evt_api.create_ext_chg_evt
4096           (p_validate                    => FALSE
4097           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4098           ,p_chg_evt_cd                  => 'TBBC'  -- Terminate Benefit before Coverage
4099           ,p_chg_eff_dt                  => p_effective_date  --??
4100           ,p_prmtr_01                    => to_char(p_old_pl_id)
4101           ,p_prmtr_02                    => to_char(p_old_oipl_id)
4102           ,p_prmtr_03                    => to_char(p_old_prtt_enrt_rslt_id)
4103           ,p_prmtr_05                    => to_char(p_old_per_in_ler_id)
4104           ,p_person_id                   => p_person_id
4105           ,p_business_group_id           => p_business_group_id
4106           ,p_object_version_number       => l_object_version_number
4107           ,p_effective_date              => p_effective_date
4108           ,p_old_val1                    => l_old_plan_name
4109           ,p_old_val2                    => l_old_option_name
4110           ,p_old_val3                    => p_old_enrt_cvg_strt_dt
4111           ,p_old_val4                    => p_old_enrt_cvg_end_dt
4112           ,p_new_val1                    => l_old_plan_name  --same value as new
4113           ,p_new_val2                    => l_old_option_name --same value as new
4114           ,p_new_val3                    => p_old_enrt_cvg_strt_dt
4115           ,p_new_val4                    => (p_old_enrt_cvg_strt_dt-1)--?
4116           );
4117          end if;
4118           --
4119         else
4120           --
4121           open c_plan_name(p_old_pl_id);
4122           fetch c_plan_name into l_old_plan_name;
4123           close c_plan_name;
4124           open c_option_name(p_old_oipl_id);
4125           fetch c_option_name into l_old_option_name;
4126           close c_option_name;
4127 
4128          if change_event_is_enabled('TBAC',p_effective_date) then
4129           ben_ext_chg_evt_api.create_ext_chg_evt
4130           (p_validate                    => FALSE
4131           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4132           ,p_chg_evt_cd                  => 'TBAC'  -- Terminate Benefit after Coverage
4133           ,p_chg_eff_dt                  => p_effective_date --??
4134           ,p_prmtr_01                    => to_char(p_old_pl_id)
4135           ,p_prmtr_02                    => to_char(p_old_oipl_id)
4136           ,p_prmtr_03                    => to_char(p_old_prtt_enrt_rslt_id)
4137           ,p_prmtr_05                    => to_char(p_old_per_in_ler_id)
4138           ,p_person_id                   => p_person_id
4139           ,p_business_group_id           => p_business_group_id
4140           ,p_object_version_number       => l_object_version_number
4141           ,p_effective_date              => p_effective_date
4142           ,p_old_val1                    => l_old_plan_name
4143           ,p_old_val2                    => l_old_option_name
4144           ,p_old_val3                    => p_old_enrt_cvg_strt_dt
4145           ,p_old_val4                    => p_old_enrt_cvg_end_dt
4146           ,p_new_val1                    => l_old_plan_name  --same value as new
4147           ,p_new_val2                    => l_old_option_name --same value as new
4148           ,p_new_val3                    => p_old_enrt_cvg_strt_dt
4149           ,p_new_val4                    => (p_old_enrt_cvg_strt_dt-1)--?
4150           );
4151          end if;
4152           --
4153         end if;  -- eff date
4154         --
4155         open c_plan_name(p_pl_id);
4156         fetch c_plan_name into l_new_plan_name;
4157         close c_plan_name;
4158         open c_option_name(p_oipl_id);
4159         fetch c_option_name into l_new_option_name;
4160         close c_option_name;
4161 
4162        if change_event_is_enabled('AB',p_effective_date) then
4163         ben_ext_chg_evt_api.create_ext_chg_evt
4164         (p_validate                    => FALSE
4165         ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4166         ,p_chg_evt_cd                  => 'AB'  -- Add Benefit
4167         ,p_chg_eff_dt                  => p_effective_date
4168         ,p_prmtr_01                    => to_char(p_pl_id)
4169         ,p_prmtr_02                    => to_char(p_oipl_id)
4170         ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4171         ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4172         ,p_person_id                   => p_person_id
4173         ,p_business_group_id           => p_business_group_id
4174         ,p_object_version_number       => l_object_version_number
4175         ,p_effective_date              => p_effective_date
4176         ,p_new_val1                    => l_new_plan_name
4177         ,p_new_val2                    => l_new_option_name
4178         ,p_new_val3                    => p_enrt_cvg_strt_dt
4179         ,p_new_val4                    => hr_api.g_eot --?
4180         );
4181        end if;
4182         --
4183       else -- plan did not change
4184 	  --
4185         if p_oipl_id <> p_old_oipl_id then
4186           --
4187           open c_plan_name(p_pl_id);
4188           fetch c_plan_name into l_new_plan_name;
4189           close c_plan_name;
4190           open c_option_name(p_oipl_id);
4191           fetch c_option_name into l_new_option_name;
4192           close c_option_name;
4193           open c_option_name(p_old_oipl_id);
4194           fetch c_option_name into l_old_option_name;
4195           close c_option_name;
4196          --
4197          if change_event_is_enabled('UOBO',p_effective_date) then
4198           ben_ext_chg_evt_api.create_ext_chg_evt
4199           (p_validate                    => FALSE
4200           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4201           ,p_chg_evt_cd                  => 'UOBO'  -- Change of Option
4202           ,p_chg_eff_dt                  => p_effective_date
4203           ,p_prmtr_01                    => to_char(p_pl_id)
4204           ,p_prmtr_02                    => to_char(p_oipl_id)
4205           ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4206           ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4207           ,p_prmtr_07                    => to_char(p_old_oipl_id)
4208           ,p_person_id                   => p_person_id
4209           ,p_business_group_id           => p_business_group_id
4210           ,p_object_version_number       => l_object_version_number
4211           ,p_effective_date              => p_effective_date
4212           ,p_old_val1                    => l_new_plan_name  -- same val as old
4213           ,p_old_val2                    => l_old_option_name
4214           ,p_new_val1                    => l_new_plan_name
4215           ,p_new_val2                    => l_new_option_name
4216           );
4217          end if;
4218  	    --
4219         end if;
4220         --
4221 	if p_enrt_cvg_strt_dt <> p_old_enrt_cvg_strt_dt then
4222           --
4223         if change_event_is_enabled('CCSD',p_effective_date) then
4224           ben_ext_chg_evt_api.create_ext_chg_evt
4225           (p_validate                    => FALSE
4226           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4227           ,p_chg_evt_cd                  => 'CCSD'  -- Change Coverage Start Date
4228           ,p_chg_eff_dt                  => p_effective_date
4229           ,p_prmtr_01                    => to_char(p_pl_id)
4230           ,p_prmtr_02                    => to_char(p_oipl_id)
4231           ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4232           ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4233           ,p_person_id                   => p_person_id
4234           ,p_business_group_id           => p_business_group_id
4235           ,p_object_version_number       => l_object_version_number
4236           ,p_effective_date              => p_effective_date
4237           ,p_old_val3                    => p_old_enrt_cvg_strt_dt
4238           ,p_new_val3                    => p_enrt_cvg_strt_dt
4239           );
4240          end if;
4241       end if;
4242         --
4243 	if p_enrt_cvg_end_dt <> p_old_enrt_cvg_end_dt then
4244           --
4245         if change_event_is_enabled('CCED',p_effective_date) then
4246           ben_ext_chg_evt_api.create_ext_chg_evt
4247           (p_validate                    => FALSE
4248           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4249           ,p_chg_evt_cd                  => 'CCED'  -- Change Coverage End Date
4250           ,p_chg_eff_dt                  => p_effective_date
4251           ,p_prmtr_01                    => to_char(p_pl_id)
4252           ,p_prmtr_02                    => to_char(p_oipl_id)
4253           ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4254           ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4255           ,p_person_id                   => p_person_id
4256           ,p_business_group_id           => p_business_group_id
4257           ,p_object_version_number       => l_object_version_number
4258           ,p_effective_date              => p_effective_date
4259           ,p_old_val4                    => p_old_enrt_cvg_end_dt
4260           ,p_new_val4                    => p_enrt_cvg_end_dt
4261           );
4262         end if;
4263       end if;
4264         --
4265 	if p_bnft_amt <> p_old_bnft_amt then
4266           --
4267         if change_event_is_enabled('COECA',p_effective_date) then
4268           ben_ext_chg_evt_api.create_ext_chg_evt
4269           (p_validate                    => FALSE
4270           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4271           ,p_chg_evt_cd                  => 'COECA'  -- Change Coverage Amount
4272           ,p_chg_eff_dt                  => p_effective_date
4273           ,p_prmtr_01                    => to_char(p_pl_id)
4274           ,p_prmtr_02                    => to_char(p_oipl_id)
4275           ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4276           ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4277           ,p_person_id                   => p_person_id
4278           ,p_business_group_id           => p_business_group_id
4279           ,p_object_version_number       => l_object_version_number
4280           ,p_effective_date              => p_effective_date
4281           ,p_old_val1                    => p_old_bnft_amt
4282           ,p_new_val1                    => p_bnft_amt
4283           );
4284         end if;
4285       end if;
4286         --
4287 	if p_pen_attribute1 <> p_old_pen_attribute1 then
4288           --
4289         if change_event_is_enabled('COEF01',p_effective_date) then
4290           ben_ext_chg_evt_api.create_ext_chg_evt
4291           (p_validate                    => FALSE
4292           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4293           ,p_chg_evt_cd                  => 'COEF01'  -- Change Flex field
4294           ,p_chg_eff_dt                  => p_effective_date
4295           ,p_prmtr_01                    => to_char(p_pl_id)
4296           ,p_prmtr_02                    => to_char(p_oipl_id)
4297           ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4298           ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4299           ,p_person_id                   => p_person_id
4300           ,p_business_group_id           => p_business_group_id
4301           ,p_object_version_number       => l_object_version_number
4302           ,p_effective_date              => p_effective_date
4303           ,p_old_val1                    => p_old_pen_attribute1
4304           ,p_new_val1                    => p_pen_attribute1
4305           );
4306         end if;
4307       end if;
4308         --
4309 	if p_pen_attribute2 <> p_old_pen_attribute2 then
4310           --
4311         if change_event_is_enabled('COEF02',p_effective_date) then
4312           ben_ext_chg_evt_api.create_ext_chg_evt
4313           (p_validate                    => FALSE
4314           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4315           ,p_chg_evt_cd                  => 'COEF02'  -- Change Flex field
4316           ,p_chg_eff_dt                  => p_effective_date
4317           ,p_prmtr_01                    => to_char(p_pl_id)
4318           ,p_prmtr_02                    => to_char(p_oipl_id)
4319           ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4320           ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4321           ,p_person_id                   => p_person_id
4322           ,p_business_group_id           => p_business_group_id
4323           ,p_object_version_number       => l_object_version_number
4324           ,p_effective_date              => p_effective_date
4325           ,p_old_val1                    => p_old_pen_attribute2
4326           ,p_new_val1                    => p_pen_attribute2
4327           );
4328         end if;
4329       end if;
4330         --
4331         --
4332 	if p_pen_attribute3 <> p_old_pen_attribute3 then
4333           --
4334         if change_event_is_enabled('COEF03',p_effective_date) then
4335           ben_ext_chg_evt_api.create_ext_chg_evt
4336           (p_validate                    => FALSE
4337           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4338           ,p_chg_evt_cd                  => 'COEF03'  -- Change Flex field
4339           ,p_chg_eff_dt                  => p_effective_date
4340           ,p_prmtr_01                    => to_char(p_pl_id)
4341           ,p_prmtr_02                    => to_char(p_oipl_id)
4342           ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4343           ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4344           ,p_person_id                   => p_person_id
4345           ,p_business_group_id           => p_business_group_id
4346           ,p_object_version_number       => l_object_version_number
4347           ,p_effective_date              => p_effective_date
4348           ,p_old_val1                    => p_old_pen_attribute3
4349           ,p_new_val1                    => p_pen_attribute3
4350           );
4351         end if;
4352       end if;
4353       --
4354 	if p_pen_attribute4 <> p_old_pen_attribute4 then
4355           --
4356         if change_event_is_enabled('COEF04',p_effective_date) then
4357           ben_ext_chg_evt_api.create_ext_chg_evt
4358           (p_validate                    => FALSE
4359           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4360           ,p_chg_evt_cd                  => 'COEF04'  -- Change Flex field
4361           ,p_chg_eff_dt                  => p_effective_date
4362           ,p_prmtr_01                    => to_char(p_pl_id)
4363           ,p_prmtr_02                    => to_char(p_oipl_id)
4364           ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4365           ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4366           ,p_person_id                   => p_person_id
4367           ,p_business_group_id           => p_business_group_id
4368           ,p_object_version_number       => l_object_version_number
4369           ,p_effective_date              => p_effective_date
4370           ,p_old_val1                    => p_old_pen_attribute4
4371           ,p_new_val1                    => p_pen_attribute4
4372           );
4373         end if;
4374       end if;
4375       --
4376 	if p_pen_attribute5 <> p_old_pen_attribute5 then
4377           --
4378         if change_event_is_enabled('COEF05',p_effective_date) then
4379           ben_ext_chg_evt_api.create_ext_chg_evt
4380           (p_validate                    => FALSE
4381           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4382           ,p_chg_evt_cd                  => 'COEF05'  -- Change Flex field
4383           ,p_chg_eff_dt                  => p_effective_date
4384           ,p_prmtr_01                    => to_char(p_pl_id)
4385           ,p_prmtr_02                    => to_char(p_oipl_id)
4386           ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4387           ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4388           ,p_person_id                   => p_person_id
4389           ,p_business_group_id           => p_business_group_id
4390           ,p_object_version_number       => l_object_version_number
4391           ,p_effective_date              => p_effective_date
4392           ,p_old_val1                    => p_old_pen_attribute5
4393           ,p_new_val1                    => p_pen_attribute5
4394           );
4395         end if;
4396       end if;
4397         --
4398 	if p_pen_attribute6 <> p_old_pen_attribute6 then
4399           --
4400         if change_event_is_enabled('COEF06',p_effective_date) then
4401           ben_ext_chg_evt_api.create_ext_chg_evt
4402           (p_validate                    => FALSE
4403           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4404           ,p_chg_evt_cd                  => 'COEF06'  -- Change Flex field
4405           ,p_chg_eff_dt                  => p_effective_date
4406           ,p_prmtr_01                    => to_char(p_pl_id)
4407           ,p_prmtr_02                    => to_char(p_oipl_id)
4408           ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4409           ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4410           ,p_person_id                   => p_person_id
4411           ,p_business_group_id           => p_business_group_id
4412           ,p_object_version_number       => l_object_version_number
4413           ,p_effective_date              => p_effective_date
4414           ,p_old_val1                    => p_old_pen_attribute6
4415           ,p_new_val1                    => p_pen_attribute6
4416           );
4417         end if;
4418       end if;
4419         --
4420 	if p_pen_attribute7 <> p_old_pen_attribute7 then
4421           --
4422         if change_event_is_enabled('COEF07',p_effective_date) then
4423           ben_ext_chg_evt_api.create_ext_chg_evt
4424           (p_validate                    => FALSE
4425           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4426           ,p_chg_evt_cd                  => 'COEF07'  -- Change Flex field
4427           ,p_chg_eff_dt                  => p_effective_date
4428           ,p_prmtr_01                    => to_char(p_pl_id)
4429           ,p_prmtr_02                    => to_char(p_oipl_id)
4430           ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4431           ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4432           ,p_person_id                   => p_person_id
4433           ,p_business_group_id           => p_business_group_id
4434           ,p_object_version_number       => l_object_version_number
4435           ,p_effective_date              => p_effective_date
4436           ,p_old_val1                    => p_old_pen_attribute7
4437           ,p_new_val1                    => p_pen_attribute7
4438           );
4439         end if;
4440       end if;
4441         --
4442 	if p_pen_attribute8 <> p_old_pen_attribute8 then
4443           --
4444         if change_event_is_enabled('COEF08',p_effective_date) then
4445           ben_ext_chg_evt_api.create_ext_chg_evt
4446           (p_validate                    => FALSE
4447           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4448           ,p_chg_evt_cd                  => 'COEF08'  -- Change Flex field
4449           ,p_chg_eff_dt                  => p_effective_date
4450           ,p_prmtr_01                    => to_char(p_pl_id)
4451           ,p_prmtr_02                    => to_char(p_oipl_id)
4452           ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4453           ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4454           ,p_person_id                   => p_person_id
4455           ,p_business_group_id           => p_business_group_id
4456           ,p_object_version_number       => l_object_version_number
4457           ,p_effective_date              => p_effective_date
4458           ,p_old_val1                    => p_old_pen_attribute8
4459           ,p_new_val1                    => p_pen_attribute8
4460           );
4461         end if;
4462       end if;
4463         --
4464 	if p_pen_attribute9 <> p_old_pen_attribute9 then
4465           --
4466         if change_event_is_enabled('COEF09',p_effective_date) then
4467           ben_ext_chg_evt_api.create_ext_chg_evt
4468           (p_validate                    => FALSE
4469           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4470           ,p_chg_evt_cd                  => 'COEF09'  -- Change Flex field
4471           ,p_chg_eff_dt                  => p_effective_date
4472           ,p_prmtr_01                    => to_char(p_pl_id)
4473           ,p_prmtr_02                    => to_char(p_oipl_id)
4474           ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4475           ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4476           ,p_person_id                   => p_person_id
4477           ,p_business_group_id           => p_business_group_id
4478           ,p_object_version_number       => l_object_version_number
4479           ,p_effective_date              => p_effective_date
4480           ,p_old_val1                    => p_old_pen_attribute9
4481           ,p_new_val1                    => p_pen_attribute9
4482           );
4483         end if;
4484       end if;
4485         --
4486 	if p_pen_attribute10 <> p_old_pen_attribute10 then
4487           --
4488         if change_event_is_enabled('COEF10',p_effective_date) then
4489           ben_ext_chg_evt_api.create_ext_chg_evt
4490           (p_validate                    => FALSE
4491           ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4492           ,p_chg_evt_cd                  => 'COEF10'  -- Change Flex field
4493           ,p_chg_eff_dt                  => p_effective_date
4494           ,p_prmtr_01                    => to_char(p_pl_id)
4495           ,p_prmtr_02                    => to_char(p_oipl_id)
4496           ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4497           ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4498           ,p_person_id                   => p_person_id
4499           ,p_business_group_id           => p_business_group_id
4500           ,p_object_version_number       => l_object_version_number
4501           ,p_effective_date              => p_effective_date
4502           ,p_old_val1                    => p_old_pen_attribute10
4503           ,p_new_val1                    => p_pen_attribute10
4504           );
4505         end if;
4506        end if;  -- attribute10 <>...
4507         --
4508       end if; -- plan changed?
4509       --
4510     end if;  -- UPDATE
4511     --
4512     if p_action = 'DELETE' then
4513       --
4514       if nvl(p_enrt_cvg_end_dt,p_effective_date) < p_enrt_cvg_strt_dt then
4515           --
4516         open c_plan_name(p_old_pl_id);
4517         fetch c_plan_name into l_old_plan_name;
4518         close c_plan_name;
4519         open c_option_name(p_old_oipl_id);
4520         fetch c_option_name into l_old_option_name;
4521         close c_option_name;
4522         --
4523        if change_event_is_enabled('TBBC',p_effective_date) then
4524         ben_ext_chg_evt_api.create_ext_chg_evt
4525         (p_validate                    => FALSE
4526         ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4527         ,p_chg_evt_cd                  => 'TBBC'  -- Terminate Benefit before Coverage
4528         ,p_chg_eff_dt                  => p_effective_date
4529         ,p_prmtr_01                    => to_char(p_old_pl_id)
4530         ,p_prmtr_02                    => to_char(p_old_oipl_id)
4531         ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4532         ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4533         ,p_person_id                   => p_person_id
4534         ,p_business_group_id           => p_business_group_id
4535         ,p_object_version_number       => l_object_version_number
4536         ,p_effective_date              => p_effective_date
4537         ,p_old_val1                    => l_old_plan_name
4538         ,p_old_val2                    => l_old_option_name
4539         ,p_old_val3                    => p_old_enrt_cvg_strt_dt
4540         ,p_old_val4                    => p_old_enrt_cvg_end_dt
4541         ,p_new_val1                    => l_old_plan_name  --same value as new
4542         ,p_new_val2                    => l_old_option_name --same value as new
4543         ,p_new_val3                    => p_enrt_cvg_strt_dt
4544         ,p_new_val4                    => p_enrt_cvg_end_dt
4545         );
4546        end if;
4547         --
4548       else
4549         --
4550         open c_plan_name(p_old_pl_id);
4551         fetch c_plan_name into l_old_plan_name;
4552         close c_plan_name;
4553         open c_option_name(p_old_oipl_id);
4554         fetch c_option_name into l_old_option_name;
4555         close c_option_name;
4556 
4557         if change_event_is_enabled('TBAC',p_effective_date) then
4558          ben_ext_chg_evt_api.create_ext_chg_evt
4559         (p_validate                    => FALSE
4560         ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4561         ,p_chg_evt_cd                  => 'TBAC'  -- Terminate Benefit after Coverage
4562         ,p_chg_eff_dt                  => p_effective_date
4563         ,p_prmtr_01                    => to_char(p_old_pl_id)
4564         ,p_prmtr_02                    => to_char(p_old_oipl_id)
4565         ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4566         ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4567         ,p_person_id                   => p_person_id
4568         ,p_business_group_id           => p_business_group_id
4569         ,p_object_version_number       => l_object_version_number
4570         ,p_effective_date              => p_effective_date
4571         ,p_old_val1                    => l_old_plan_name
4572         ,p_old_val2                    => l_old_option_name
4573         ,p_old_val3                    => p_old_enrt_cvg_strt_dt
4574         ,p_old_val4                    => p_old_enrt_cvg_end_dt
4575         ,p_new_val1                    => l_old_plan_name  --same value as new
4576         ,p_new_val2                    => l_old_option_name --same value as new
4577         ,p_new_val3                    => p_enrt_cvg_strt_dt
4578         ,p_new_val4                    => p_enrt_cvg_end_dt
4579         );
4580        end if;
4581         --
4582       end if; -- eff date
4583       --
4584     end if;  -- DELETE
4585     --
4586     --
4587     hr_utility.set_location('Exiting:'||l_proc, 99);
4588     --
4589   END log_benefit_chg;
4590 --
4591 procedure log_dependent_chg(
4592         p_action               in varchar2, -- CREATE, REINSTATE, or DELETE
4593         p_pl_id                in number default null,
4594         p_oipl_id              in number default null,
4595         p_cvg_strt_dt          in date default null,
4596         p_cvg_end_dt           in date default null,
4597         p_old_cvg_strt_dt      in date default null,
4598         p_old_cvg_end_dt       in date default null,
4599         p_effective_start_date in date default null,
4600         p_effective_end_date   in date default null,
4601         p_prtt_enrt_rslt_id    in number default null,
4602         p_per_in_ler_id        in number default null,
4603         p_elig_cvrd_dpnt_id    in number default null,
4604         p_person_id            in number,
4605         p_dpnt_person_id       in number,
4606         p_business_group_id    in number,
4607         p_effective_date       in date) is
4608 
4609   -- Local variable declarations
4610   --
4611   l_proc         varchar2(72) := 'ben_ext_chlg.log_dependent_chg';
4612 
4613   l_plan_name              ben_pl_f.name%type;
4614   l_option_name            ben_opt_f.name%type;
4615   l_dpnt_full_name             per_all_people_f.full_name%type;
4616   l_relationship               varchar2(200);
4617   --
4618   l_ext_chg_evt_log_id number;
4619   l_object_version_number number;
4620   --
4621   -- Cursor declarations.
4622   cursor c_plan_name(p_pl_id number)  is
4623   select pl.name
4624   from ben_pl_f pl
4625   where pl.pl_id = p_pl_id
4626   and p_effective_date between pl.effective_start_date and pl.effective_end_date;
4627   --
4628   cursor c_option_name(p_oipl_id number)
4629   is
4630   select opt.name
4631   from ben_oipl_f cop,
4632        ben_opt_f opt
4633   where cop.oipl_id = p_oipl_id
4634   and p_effective_date between cop.effective_start_date and cop.effective_end_date
4635   and cop.opt_id = opt.opt_id
4636   and p_effective_date between opt.effective_start_date and opt.effective_end_date;
4637   --
4638   cursor c_dpnt_full_name (p_person_id number) is
4639   SELECT ppf.full_name
4640   FROM   per_all_people_f ppf
4641   WHERE  ppf.person_id = p_person_id
4642   AND    p_effective_date between ppf.effective_start_date
4643          and ppf.effective_end_date
4644   AND    ppf.business_group_id = p_business_group_id;
4645   --
4646   cursor c_relationship(p_person_id number
4647                        ,p_dpnt_person_id number)is
4648   SELECT hl.meaning
4649   FROM   per_contact_relationships pcr,
4650          hr_lookups hl
4651   WHERE  pcr.person_id = p_person_id
4652   AND    pcr.contact_person_id = p_dpnt_person_id
4653   AND    pcr.contact_type = hl.lookup_code
4654   AND    hl.lookup_type = 'CONTACT';
4655   --
4656   --
4657   begin
4658     --
4659     hr_utility.set_location('Entering:'||l_proc, 10);
4660     --
4661     -- Get the new values to be store or updated
4662     --
4663       open c_plan_name(p_pl_id);
4664       fetch c_plan_name into l_plan_name;
4665       close c_plan_name;
4666       open c_option_name(p_oipl_id);
4667       fetch c_option_name into l_option_name;
4668       close c_option_name;
4669       open c_dpnt_full_name(p_dpnt_person_id);
4670       fetch c_dpnt_full_name into l_dpnt_full_name;
4671       close c_dpnt_full_name;
4672       open c_relationship(p_person_id, p_dpnt_person_id);
4673       fetch c_relationship into l_relationship;
4674       close c_relationship;
4675     --
4676     if p_action = 'CREATE' then
4677       --
4678       -- When we are creating a new dependent record we must record 2 records to
4679       -- the change log.  'Add Dependent' for the employee person, and 'Add Benefit'
4680       -- for the dependent person.
4681       --
4682       if change_event_is_enabled('AB',p_effective_date) then
4683        ben_ext_chg_evt_api.create_ext_chg_evt
4684       (p_validate                    => FALSE
4685       ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4686       ,p_chg_evt_cd                  => 'AB'  -- Add Benefit
4687       ,p_chg_eff_dt                  => p_effective_date
4688       ,p_prmtr_01                    => to_char(p_pl_id)
4689       ,p_prmtr_02                    => to_char(p_oipl_id)
4690       ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4691       ,p_prmtr_04                    => to_char(p_elig_cvrd_dpnt_id)
4692       ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4693       ,p_prmtr_06                    => to_char(p_person_id)
4694       ,p_person_id                   => p_dpnt_person_id
4695       ,p_business_group_id           => p_business_group_id
4696       ,p_object_version_number       => l_object_version_number
4697       ,p_effective_date              => p_effective_date
4698       ,p_new_val1                    => l_plan_name
4699       ,p_new_val2                    => l_option_name
4700       ,p_new_val3                    => p_cvg_strt_dt
4701       ,p_new_val4                    => p_cvg_end_dt
4702       );
4703       end if;
4704       --
4705       if change_event_is_enabled('AD',p_effective_date) then
4706        ben_ext_chg_evt_api.create_ext_chg_evt
4707       (p_validate                    => FALSE
4708       ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4709       ,p_chg_evt_cd                  => 'AD'  -- Add Dependent
4710       ,p_chg_eff_dt                  => p_effective_date
4711       ,p_prmtr_01                    => to_char(p_pl_id)
4712       ,p_prmtr_02                    => to_char(p_oipl_id)
4713       ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4714       ,p_prmtr_04                    => to_char(p_elig_cvrd_dpnt_id)
4715       ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4716       ,p_prmtr_06                    => to_char(p_dpnt_person_id)
4717       ,p_person_id                   => p_person_id
4718       ,p_business_group_id           => p_business_group_id
4719       ,p_object_version_number       => l_object_version_number
4720       ,p_effective_date              => p_effective_date
4721       ,p_new_val1                    => l_plan_name
4722       ,p_new_val2                    => l_option_name
4723       ,p_new_val3                    => p_cvg_strt_dt
4724       ,p_new_val4                    => p_cvg_end_dt
4725       ,p_new_val5                    => l_dpnt_full_name
4726       ,p_new_val6                    => l_relationship
4727       );
4728      end if;
4729     --
4730     elsif p_action = 'REINSTATE' then
4731       --
4732      if change_event_is_enabled('RB',p_effective_date) then
4733       ben_ext_chg_evt_api.create_ext_chg_evt
4734       (p_validate                    => FALSE
4735       ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4736       ,p_chg_evt_cd                  => 'RB'  -- Reinstate Benefit
4737       ,p_chg_eff_dt                  => p_effective_date
4738       ,p_prmtr_01                    => to_char(p_pl_id)
4739       ,p_prmtr_02                    => to_char(p_oipl_id)
4740       ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4741       ,p_prmtr_04                    => to_char(p_elig_cvrd_dpnt_id)
4742       ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4743       ,p_prmtr_06                    => to_char(p_person_id)
4744       ,p_person_id                   => p_dpnt_person_id
4745       ,p_business_group_id           => p_business_group_id
4746       ,p_object_version_number       => l_object_version_number
4747       ,p_effective_date              => p_effective_date
4748       ,p_old_val1                    => l_plan_name
4749       ,p_old_val2                    => l_option_name
4750       ,p_old_val3                    => p_old_cvg_strt_dt
4751       ,p_old_val4                    => p_old_cvg_end_dt
4752       ,p_new_val1                    => l_plan_name
4753       ,p_new_val2                    => l_option_name
4754       ,p_new_val3                    => p_cvg_strt_dt
4755       ,p_new_val4                    => p_cvg_end_dt
4756       );
4757       end if;
4758       --
4759      if change_event_is_enabled('AD',p_effective_date) then
4760       ben_ext_chg_evt_api.create_ext_chg_evt
4761       (p_validate                    => FALSE
4762       ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4763       ,p_chg_evt_cd                  => 'AD' -- Add dependent  This should later change to
4764                                              -- Reinstate Dependent.
4765       ,p_chg_eff_dt                  => p_effective_date
4766       ,p_prmtr_01                    => to_char(p_pl_id)
4767       ,p_prmtr_02                    => to_char(p_oipl_id)
4768       ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4769       ,p_prmtr_04                    => to_char(p_elig_cvrd_dpnt_id)
4770       ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4771       ,p_prmtr_06                    => to_char(p_dpnt_person_id)
4772       ,p_person_id                   => p_person_id
4773       ,p_business_group_id           => p_business_group_id
4774       ,p_object_version_number       => l_object_version_number
4775       ,p_effective_date              => p_effective_date
4776       ,p_old_val1                    => l_plan_name
4777       ,p_old_val2                    => l_option_name
4778       ,p_old_val3                    => p_old_cvg_strt_dt
4779       ,p_old_val4                    => p_old_cvg_end_dt
4780       ,p_old_val5                    => l_dpnt_full_name
4781       ,p_old_val6                    => l_relationship
4782       ,p_new_val1                    => l_plan_name
4783       ,p_new_val2                    => l_option_name
4784       ,p_new_val3                    => p_cvg_strt_dt
4785       ,p_new_val4                    => p_cvg_end_dt
4786       ,p_new_val5                    => l_dpnt_full_name
4787       ,p_new_val6                    => l_relationship
4788       );
4789       end if;
4790     --
4791     elsif p_action = 'DELETE' then
4792       --
4793       if p_cvg_end_dt < p_cvg_strt_dt then
4794           --
4795        if change_event_is_enabled('TBBC',p_effective_date) then
4796         ben_ext_chg_evt_api.create_ext_chg_evt
4797         (p_validate                    => FALSE
4798         ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4799         ,p_chg_evt_cd                  => 'TBBC'  -- Terminate Benefit before Coverage
4800         ,p_chg_eff_dt                  => p_effective_date
4801         ,p_prmtr_01                    => to_char(p_pl_id)
4802         ,p_prmtr_02                    => to_char(p_oipl_id)
4803         ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4804         ,p_prmtr_04                    => to_char(p_elig_cvrd_dpnt_id)
4805         ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4806         ,p_prmtr_06                    => to_char(p_person_id)
4807         ,p_person_id                   => p_dpnt_person_id
4808         ,p_business_group_id           => p_business_group_id
4809         ,p_object_version_number       => l_object_version_number
4810         ,p_effective_date              => p_effective_date
4811         ,p_old_val1                    => l_plan_name
4812         ,p_old_val2                    => l_option_name
4813         ,p_old_val3                    => p_old_cvg_strt_dt
4814         ,p_old_val4                    => p_old_cvg_end_dt
4815         ,p_new_val1                    => l_plan_name
4816         ,p_new_val2                    => l_option_name
4817         ,p_new_val3                    => p_cvg_strt_dt
4818         ,p_new_val4                    => p_cvg_end_dt
4819         );
4820        end if;
4821         --
4822       else
4823         --
4824        if change_event_is_enabled('TBAC',p_effective_date) then
4825         ben_ext_chg_evt_api.create_ext_chg_evt
4826         (p_validate                    => FALSE
4827         ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4828         ,p_chg_evt_cd                  => 'TBAC'  -- Terminate Benefit after Coverage
4829         ,p_chg_eff_dt                  => p_effective_date
4830         ,p_prmtr_01                    => to_char(p_pl_id)
4831         ,p_prmtr_02                    => to_char(p_oipl_id)
4832         ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4833         ,p_prmtr_04                    => to_char(p_elig_cvrd_dpnt_id)
4834         ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4835         ,p_prmtr_06                    => to_char(p_person_id)
4836         ,p_person_id                   => p_dpnt_person_id
4837         ,p_business_group_id           => p_business_group_id
4838         ,p_object_version_number       => l_object_version_number
4839         ,p_effective_date              => p_effective_date
4840         ,p_old_val1                    => l_plan_name
4841         ,p_old_val2                    => l_option_name
4842         ,p_old_val3                    => p_old_cvg_strt_dt
4843         ,p_old_val4                    => p_old_cvg_end_dt
4844         ,p_new_val1                    => l_plan_name
4845         ,p_new_val2                    => l_option_name
4846         ,p_new_val3                    => p_cvg_strt_dt
4847         ,p_new_val4                    => p_cvg_end_dt
4848         );
4849        end if;
4850         --
4851       end if; -- eff date
4852       --
4853       if change_event_is_enabled('DD',p_effective_date) then
4854        ben_ext_chg_evt_api.create_ext_chg_evt
4855         (p_validate                    => FALSE
4856         ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
4857         ,p_chg_evt_cd                  => 'DD'  -- Delete Dependent
4858         ,p_chg_eff_dt                  => p_effective_date
4859         ,p_prmtr_01                    => to_char(p_pl_id)
4860         ,p_prmtr_02                    => to_char(p_oipl_id)
4861         ,p_prmtr_03                    => to_char(p_prtt_enrt_rslt_id)
4862         ,p_prmtr_04                    => to_char(p_elig_cvrd_dpnt_id)
4863         ,p_prmtr_05                    => to_char(p_per_in_ler_id)
4864         ,p_prmtr_06                    => to_char(p_dpnt_person_id)
4865         ,p_person_id                   => p_person_id
4866         ,p_business_group_id           => p_business_group_id
4867         ,p_object_version_number       => l_object_version_number
4868         ,p_effective_date              => p_effective_date
4869         ,p_old_val1                    => l_plan_name
4870         ,p_old_val2                    => l_option_name
4871         ,p_old_val3                    => p_old_cvg_strt_dt
4872         ,p_old_val4                    => p_old_cvg_end_dt
4873         ,p_old_val5                    => l_dpnt_full_name
4874         ,p_old_val6                    => l_relationship
4875         ,p_new_val1                    => l_plan_name
4876         ,p_new_val2                    => l_option_name
4877         ,p_new_val3                    => p_cvg_strt_dt
4878         ,p_new_val4                    => p_cvg_end_dt
4879         ,p_new_val5                    => l_dpnt_full_name
4880         ,p_new_val6                    => l_relationship
4881         );
4882        end if;
4883     end if;
4884   --
4885   hr_utility.set_location('Exiting:'||l_proc, 99);
4886 --
4887 end log_dependent_chg;
4888 --
4889 procedure log_pcp_chg(
4890         p_action               in varchar2,
4891         p_ext_ident            in varchar2 default null,
4892         p_old_ext_ident        in varchar2 default null,
4893         p_name                 in varchar2 default null,
4894         p_old_name             in varchar2 default null,
4895         p_prmry_care_prvdr_typ_cd in varchar2 default null,
4896         p_old_prmry_care_prvdr_typ_cd in varchar2 default null,
4897         p_prmry_care_prvdr_id  in number default null,
4898         p_elig_cvrd_dpnt_id    in number default null,
4899         p_prtt_enrt_rslt_id    in number default null,
4900         p_effective_start_date in date default null,
4901         p_effective_end_date   in date default null,
4902         p_business_group_id    in number,
4903         p_effective_date       in date) is
4904   --
4905   -- Local variable declarations
4906   --
4907   l_proc         varchar2(72) := 'ben_ext_chlg.log_pcp_chg';
4908   l_relationship              per_all_people_f.person_id%type;
4909   l_contact                   per_contact_relationships.contact_relationship_id%type;
4910   l_name                      per_all_people_f.full_name%type;
4911   --
4912   cursor c_relationship(p_person_id number) is
4913   SELECT pcr.contact_relationship_id,pcr.person_id,ppf.full_name
4914   FROM   per_contact_relationships pcr,
4915          per_all_people_f ppf,
4916          per_person_types ppt,
4917          hr_lookups hl
4918   WHERE  pcr.contact_person_id = p_person_id
4919   AND    ppf.person_id = p_person_id
4920   AND    ppf.person_type_id = ppt.person_type_id
4921   AND    ppt.system_person_type = 'OTHER'
4922   AND    pcr.contact_type = hl.lookup_code
4923   AND    hl.lookup_type = 'CONTACT';
4924 
4925   cursor c_con_relationship(p_person_id number) is
4926   SELECT pcr.contact_relationship_id,pcr.person_id,ppf.full_name
4927   FROM   per_contact_relationships pcr,
4928          per_all_people_f ppf,
4929          hr_lookups hl
4930   WHERE  pcr.contact_person_id = p_person_id
4931   AND    ppf.person_id = p_person_id
4932   AND    pcr.contact_type = hl.lookup_code
4933   AND    hl.lookup_type = 'CONTACT'
4934   AND    pcr.personal_flag = 'Y'
4935   and    p_effective_date between  pcr.date_start and nvl(pcr.date_end, p_effective_date)
4936   ;
4937 
4938 --
4939 cursor c_prtt_person_id
4940   is
4941   select pen.person_id
4942   from ben_prtt_enrt_rslt_f pen
4943   where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
4944   and pen.business_group_id  = p_business_group_id
4945   and p_effective_date between pen.effective_start_date and pen.effective_end_date;
4946 
4947   cursor c_elig_cvrd_person_id
4948   is
4949   select ecd.dpnt_person_id
4950   from ben_elig_cvrd_dpnt_f ecd
4951   where ecd.elig_cvrd_dpnt_id = p_elig_cvrd_dpnt_id
4952   and ecd.business_group_id = p_business_group_id
4953   and p_effective_date between ecd.effective_start_date and ecd.effective_end_date;
4954 
4955   cursor c_prmry_care_prvdr_type(prmry_care_prvdr_typ_cd in varchar2)
4956   is
4957   select hl.meaning
4958   from hr_lookups hl
4959   where hl.lookup_type = 'BEN_PRMRY_CARE_PRVDR_TYP'
4960   and hl.lookup_code = prmry_care_prvdr_typ_cd;
4961   --
4962   l_person_id                 number;
4963   l_prmry_care_prvdr_typ_cd   varchar2(50);
4964   v_prmry_care_prvdr_typ_cd   varchar2(50);
4965   l_old_prmry_care_prvdr_typ_cd   varchar2(50);
4966   l_object_version_number     number;
4967   l_ext_chg_evt_log_id        number;
4968   l_pcp_chg boolean := FALSE;
4969   --
4970   begin
4971     --
4972     hr_utility.set_location('Entering:'||l_proc, 10);
4973     --
4974     -- Get the values to be store or updated
4975   if p_prtt_enrt_rslt_id is not null then
4976     open c_prtt_person_id;
4977     fetch c_prtt_person_id into l_person_id;
4978     close c_prtt_person_id;
4979   elsif p_elig_cvrd_dpnt_id is not null then
4980     open c_elig_cvrd_person_id;
4981     fetch c_elig_cvrd_person_id into l_person_id;
4982     close c_elig_cvrd_person_id;
4983   end if;
4984   if p_prmry_care_prvdr_typ_cd is not null then
4985     open c_prmry_care_prvdr_type(p_prmry_care_prvdr_typ_cd);
4986     fetch c_prmry_care_prvdr_type into l_prmry_care_prvdr_typ_cd;
4987     close c_prmry_care_prvdr_type;
4988   end if;
4989   if p_old_prmry_care_prvdr_typ_cd is not null then
4990     open c_prmry_care_prvdr_type(p_old_prmry_care_prvdr_typ_cd);
4991     fetch c_prmry_care_prvdr_type into l_old_prmry_care_prvdr_typ_cd;
4992     close c_prmry_care_prvdr_type;
4993   end if;
4994   --
4995   --
4996   if p_action = 'CREATE' then
4997     if change_event_is_enabled('APCP',p_effective_date) then
4998      l_pcp_chg := TRUE;
4999      if l_person_id is not null then
5000      ben_ext_chg_evt_api.create_ext_chg_evt
5001      (p_validate              => FALSE
5002      ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
5003      ,p_chg_evt_cd            => 'APCP'
5004      ,p_chg_eff_dt            => p_effective_date
5005      ,p_prmtr_03              => p_prtt_enrt_rslt_id
5006      ,p_prmtr_04              => p_elig_cvrd_dpnt_id
5007      ,p_prmtr_08              => p_prmry_care_prvdr_id
5008      ,p_person_id             => l_person_id
5009      ,p_business_group_id     => p_business_group_id
5010      ,p_object_version_number => l_object_version_number
5011      ,p_effective_date        => p_effective_date
5012      ,p_new_val1              => p_name
5013      ,p_new_val2              => p_ext_ident
5014      ,p_new_val3              => l_prmry_care_prvdr_typ_cd);
5015      end if;
5016     end if;
5017     --
5018   elsif p_action = 'UPDATE' then
5019 
5020    if p_prmry_care_prvdr_typ_cd <> p_old_prmry_care_prvdr_typ_cd then
5021     --
5022     if change_event_is_enabled('COPT',p_effective_date) then
5023      l_pcp_chg := TRUE;
5024      ben_ext_chg_evt_api.create_ext_chg_evt
5025     (p_validate                 => FALSE
5026     ,p_ext_chg_evt_log_id     => l_ext_chg_evt_log_id
5027     ,p_chg_evt_cd             => 'COPT'
5028      ,p_chg_eff_dt            => p_effective_date
5029      ,p_prmtr_03              => p_prtt_enrt_rslt_id
5030      ,p_prmtr_04              => p_elig_cvrd_dpnt_id
5031      ,p_prmtr_08              => p_prmry_care_prvdr_id
5032      ,p_person_id             => l_person_id
5033      ,p_business_group_id     => p_business_group_id
5034      ,p_object_version_number => l_object_version_number
5035      ,p_effective_date        => p_effective_date
5036      ,p_old_val1              => p_old_name
5037      ,p_old_val2              => p_old_ext_ident
5038      ,p_old_val3              => l_old_prmry_care_prvdr_typ_cd
5039      ,p_new_val1              => p_old_name
5040      ,p_new_val2              => p_old_ext_ident
5041      ,p_new_val3              => l_prmry_care_prvdr_typ_cd);
5042     end if;
5043     --
5044    end if;
5045    --
5046    if p_name <> p_old_name then
5047     --
5048     if change_event_is_enabled('COPN',p_effective_date) then
5049      l_pcp_chg := TRUE;
5050      ben_ext_chg_evt_api.create_ext_chg_evt
5051      (p_validate              => FALSE
5052      ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
5053      ,p_chg_evt_cd            => 'COPN'
5054      ,p_chg_eff_dt            => p_effective_date
5055      ,p_prmtr_03              => p_prtt_enrt_rslt_id
5056      ,p_prmtr_04              => p_elig_cvrd_dpnt_id
5057      ,p_prmtr_08              => p_prmry_care_prvdr_id
5058      ,p_person_id             => l_person_id
5059      ,p_business_group_id     => p_business_group_id
5060      ,p_object_version_number => l_object_version_number
5061      ,p_effective_date        => p_effective_date
5062      ,p_old_val1              => p_old_name
5063      ,p_old_val2              => p_old_ext_ident
5064      ,p_old_val3              => l_old_prmry_care_prvdr_typ_cd
5065      ,p_new_val1              => p_name
5066      ,p_new_val2              => p_old_ext_ident
5067      ,p_new_val3              => l_old_prmry_care_prvdr_typ_cd);
5068      end if;
5069     --
5070     end if;
5071     --
5072     if p_ext_ident <> p_old_ext_ident then
5073      if change_event_is_enabled('COPI',p_effective_date) then
5074       ben_ext_chg_evt_api.create_ext_chg_evt
5075      (p_validate               => FALSE
5076      ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
5077      ,p_chg_evt_cd            => 'COPI'
5078      ,p_chg_eff_dt            => p_effective_date
5079      ,p_prmtr_03              => p_prtt_enrt_rslt_id
5080      ,p_prmtr_04              => p_elig_cvrd_dpnt_id
5081      ,p_prmtr_08              => p_prmry_care_prvdr_id
5082      ,p_person_id             => l_person_id
5083      ,p_business_group_id     => p_business_group_id
5084      ,p_object_version_number => l_object_version_number
5085      ,p_effective_date        => p_effective_date
5086      ,p_old_val1              => p_old_name
5087      ,p_old_val2              => p_old_ext_ident
5088      ,p_old_val3              => l_old_prmry_care_prvdr_typ_cd
5089      ,p_new_val1              => p_old_name
5090      ,p_new_val2              => p_ext_ident
5091      ,p_new_val3              => l_old_prmry_care_prvdr_typ_cd);
5092     end if;
5093     --
5094    end if;
5095   --
5096   elsif p_action = 'DELETE' then
5097   --
5098      if change_event_is_enabled('DPCP',p_effective_date) then
5099      l_pcp_chg := TRUE;
5100       ben_ext_chg_evt_api.create_ext_chg_evt
5101      (p_validate               => FALSE
5102      ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
5103      ,p_chg_evt_cd            => 'DPCP'
5104      ,p_chg_eff_dt            => p_effective_date
5105      ,p_prmtr_03              => p_prtt_enrt_rslt_id
5106      ,p_prmtr_04              => p_elig_cvrd_dpnt_id
5107      ,p_prmtr_08              => p_prmry_care_prvdr_id
5108      ,p_person_id             => l_person_id
5109      ,p_business_group_id     => p_business_group_id
5110      ,p_object_version_number => l_object_version_number
5111      ,p_effective_date        => p_effective_date
5112      ,p_old_val1              => p_old_name
5113      ,p_old_val2              => p_old_ext_ident
5114      ,p_old_val3              => l_old_prmry_care_prvdr_typ_cd);
5115     end if;
5116   --
5117   end if;  --p_action
5118   --record change event(update contact's primary care provider) for participant.
5119   if l_pcp_chg then
5120     -- only the person type is contact
5121     open c_relationship(l_person_id);
5122     fetch c_relationship into l_contact,l_relationship,l_name;
5123     if c_relationship%notfound then
5124       close c_relationship;
5125     elsif c_relationship%found then
5126       close c_relationship;
5127       l_person_id := l_relationship;
5128       if p_action = 'CREATE' then
5129         ben_ext_chg_evt_api.create_ext_chg_evt
5130         (p_validate              => FALSE
5131         ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
5132         ,p_chg_evt_cd            => 'CCPC'
5133         ,p_chg_eff_dt            => p_effective_date
5134         ,p_prmtr_01              => l_relationship
5135         ,p_prmtr_03              => p_prtt_enrt_rslt_id
5136         ,p_prmtr_04              => p_elig_cvrd_dpnt_id
5137         ,p_prmtr_08              => p_prmry_care_prvdr_id
5138         ,p_person_id             => l_person_id
5139         ,p_business_group_id     => p_business_group_id
5140         ,p_object_version_number => l_object_version_number
5141         ,p_effective_date        => p_effective_date
5142         ,p_new_val1              => substr(l_name,1,240)
5143         ,p_new_val2              => substr(p_name,1,240)
5144         ,p_new_val3              => l_prmry_care_prvdr_typ_cd);
5145       elsif p_action = 'UPDATE' then
5146         if p_prmry_care_prvdr_typ_cd is not null then
5147            v_prmry_care_prvdr_typ_cd := l_prmry_care_prvdr_typ_cd;
5148         else
5149            v_prmry_care_prvdr_typ_cd := l_old_prmry_care_prvdr_typ_cd;
5150         end if;
5151          ben_ext_chg_evt_api.create_ext_chg_evt
5152          (p_validate              => FALSE
5153           ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
5154           ,p_chg_evt_cd            => 'CCPC'
5155           ,p_chg_eff_dt            => p_effective_date
5156           ,p_prmtr_01              => l_relationship
5157           ,p_prmtr_03              => p_prtt_enrt_rslt_id
5158           ,p_prmtr_04              => p_elig_cvrd_dpnt_id
5159           ,p_prmtr_08              => p_prmry_care_prvdr_id
5160           ,p_person_id             => l_person_id
5161           ,p_business_group_id     => p_business_group_id
5162           ,p_object_version_number => l_object_version_number
5163           ,p_effective_date        => p_effective_date
5164           ,p_old_val1              => substr(l_name,1,200)
5165           ,p_old_val2              => p_old_name
5166           ,p_old_val3              => l_old_prmry_care_prvdr_typ_cd
5167           ,p_new_val1              => substr(l_name,1,240)
5168           ,p_new_val2              => substr(p_name,1,240)
5169           ,p_new_val3              => v_prmry_care_prvdr_typ_cd);
5170        elsif p_action = 'DELETE' then
5171          ben_ext_chg_evt_api.create_ext_chg_evt
5172          (p_validate               => FALSE
5173           ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
5174           ,p_chg_evt_cd            => 'CCPC'
5175           ,p_chg_eff_dt            => p_effective_date
5176           ,p_prmtr_01              => l_relationship
5177           ,p_prmtr_03              => p_prtt_enrt_rslt_id
5178           ,p_prmtr_04              => p_elig_cvrd_dpnt_id
5179           ,p_prmtr_08              => p_prmry_care_prvdr_id
5180           ,p_person_id             => l_person_id
5181           ,p_business_group_id     => p_business_group_id
5182           ,p_object_version_number => l_object_version_number
5183           ,p_effective_date        => p_effective_date
5184           ,p_old_val1              => substr(l_name,1,240)
5185           ,p_old_val2              => p_old_name
5186           ,p_old_val3              => l_old_prmry_care_prvdr_typ_cd);
5187        end if;
5188     end if;
5189 
5190     --- all the contact relationship  person
5191 
5192     open c_con_relationship(l_person_id);
5193     Loop
5194       fetch c_con_relationship into l_contact,l_relationship,l_name;
5195       exit when c_con_relationship%notfound ;
5196       l_person_id := l_relationship;
5197       if p_action = 'CREATE' then
5198          ben_ext_chg_evt_api.create_ext_chg_evt
5199             (p_validate              => FALSE
5200             ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
5201             ,p_chg_evt_cd            => 'CCNPC'
5202             ,p_chg_eff_dt            => p_effective_date
5203             ,p_prmtr_01              => l_relationship
5204             ,p_prmtr_03              => p_prtt_enrt_rslt_id
5205             ,p_prmtr_04              => p_elig_cvrd_dpnt_id
5206             ,p_prmtr_08              => p_prmry_care_prvdr_id
5207             ,p_person_id             => l_person_id
5208             ,p_business_group_id     => p_business_group_id
5209             ,p_object_version_number => l_object_version_number
5210             ,p_effective_date        => p_effective_date
5211             ,p_new_val1              => substr(l_name,1,240)
5212             ,p_new_val2              => substr(p_name,1,240)
5213             ,p_new_val3              => l_prmry_care_prvdr_typ_cd);
5214       elsif p_action = 'UPDATE' then
5215          if p_prmry_care_prvdr_typ_cd is not null then
5216             v_prmry_care_prvdr_typ_cd := l_prmry_care_prvdr_typ_cd;
5217          else
5218             v_prmry_care_prvdr_typ_cd := l_old_prmry_care_prvdr_typ_cd;
5219          end if;
5220          ben_ext_chg_evt_api.create_ext_chg_evt
5221             (p_validate              => FALSE
5222             ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
5223             ,p_chg_evt_cd            => 'CCNPC'
5224             ,p_chg_eff_dt            => p_effective_date
5225             ,p_prmtr_01              => l_relationship
5226             ,p_prmtr_03              => p_prtt_enrt_rslt_id
5227             ,p_prmtr_04              => p_elig_cvrd_dpnt_id
5228             ,p_prmtr_08              => p_prmry_care_prvdr_id
5229             ,p_person_id             => l_person_id
5230             ,p_business_group_id     => p_business_group_id
5231             ,p_object_version_number => l_object_version_number
5232             ,p_effective_date        => p_effective_date
5233             ,p_old_val1              => substr(l_name,1,200)
5234             ,p_old_val2              => p_old_name
5235             ,p_old_val3              => l_old_prmry_care_prvdr_typ_cd
5236             ,p_new_val1              => substr(l_name,1,240)
5237             ,p_new_val2              => substr(p_name,1,240)
5238             ,p_new_val3              => v_prmry_care_prvdr_typ_cd);
5239       elsif p_action = 'DELETE' then
5240          ben_ext_chg_evt_api.create_ext_chg_evt
5241             (p_validate               => FALSE
5242             ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
5243             ,p_chg_evt_cd            => 'CCNPC'
5244             ,p_chg_eff_dt            => p_effective_date
5245             ,p_prmtr_01              => l_relationship
5246             ,p_prmtr_03              => p_prtt_enrt_rslt_id
5247             ,p_prmtr_04              => p_elig_cvrd_dpnt_id
5248             ,p_prmtr_08              => p_prmry_care_prvdr_id
5249             ,p_person_id             => l_person_id
5250             ,p_business_group_id     => p_business_group_id
5251             ,p_object_version_number => l_object_version_number
5252             ,p_effective_date        => p_effective_date
5253             ,p_old_val1              => substr(l_name,1,240)
5254             ,p_old_val2              => p_old_name
5255             ,p_old_val3              => l_old_prmry_care_prvdr_typ_cd);
5256        end if;
5257     End Loop ;
5258     close c_con_relationship;
5259     -- end of creating log for all relationship
5260   --
5261   end if;  --p_action
5262   hr_utility.set_location('Exiting:'||l_proc, 99);
5263 --
5264 end log_pcp_chg;
5265 --
5266 procedure log_pos_chg
5267           (p_event     in  varchar2
5268           ,p_old_rec   in  g_pos_rec_type
5269           ,p_new_rec   in  g_pos_rec_type
5270           ) is
5271 --
5272   l_chg_evt_tab           g_char_tab_type;
5273   l_prmtr_01_tab          g_char_tab_type;
5274   l_prmtr_02_tab          g_char_tab_type;
5275   l_prmtr_03_tab          g_char_tab_type;
5276   l_prmtr_04_tab          g_char_tab_type;
5277   l_prmtr_05_tab          g_char_tab_type;
5278   l_prmtr_06_tab          g_char_tab_type;
5279   l_prmtr_07_tab          g_char_tab_type;
5280   l_new_val1              g_new_val;
5281   l_new_val2              g_new_val;
5282   l_new_val3              g_new_val;
5283   l_new_val4              g_new_val;
5284   l_new_val5              g_new_val;
5285   l_new_val6              g_new_val;
5286   l_old_val1              g_old_val;
5287   l_old_val2              g_old_val;
5288   l_old_val3              g_old_val;
5289   l_old_val4              g_old_val;
5290   l_old_val5              g_old_val;
5291   l_old_val6              g_old_val;
5292   l_tab_counter           binary_integer := 0;
5293 --Bug 4539732  Changed the date type of l_chg_eff_dt to date table type
5294   l_chg_eff_dt            g_date_tab_type;
5295 --End Bug 4539732
5296   l_count                 number;
5297   l_ext_chg_evt_log_id    number;
5298   l_object_version_number number;
5299 --
5300   l_proc         varchar2(72) := 'ben_ext_chlg.log_pos_chg';
5301 --
5302 begin
5303 --
5304   hr_utility.set_location('Entering:'||l_proc, 10);
5305 
5306 
5307 --
5308   if p_event = 'UPDATE' then
5309 --
5310     if p_old_rec.actual_termination_date is null and p_new_rec.actual_termination_date is not null then
5311       l_tab_counter := l_tab_counter + 1;
5312 --Bug 4539732  Store the change effective date for each event in its own place
5313       l_chg_eff_dt(l_tab_counter) := p_new_rec.actual_termination_date;
5314 --End Bug 4539732
5315       l_chg_evt_tab(l_tab_counter) := 'AAT';
5316       l_prmtr_01_tab(l_tab_counter) := p_old_rec.period_of_service_id;
5317       l_prmtr_02_tab(l_tab_counter) := null;
5318       l_prmtr_03_tab(l_tab_counter) := null;
5319       l_prmtr_04_tab(l_tab_counter) := null;
5320       l_prmtr_05_tab(l_tab_counter) := null;
5321       l_prmtr_06_tab(l_tab_counter) := null;
5322       l_prmtr_07_tab(l_tab_counter) := null;
5323       l_old_val1(l_tab_counter)     := p_old_rec.actual_termination_date;
5324       l_new_val1(l_tab_counter)     := p_new_rec.actual_termination_date;
5325     end if;
5326     if p_old_rec.actual_termination_date is not null and
5327          p_new_rec.actual_termination_date is not null and
5328          p_old_rec.actual_termination_date <> p_new_rec.actual_termination_date then
5329       l_tab_counter := l_tab_counter + 1;
5330 --Bug 4539732  Store the change effective date for each event in its own place
5331       l_chg_eff_dt(l_tab_counter) := p_new_rec.actual_termination_date;
5332 --End Bug 4539732
5333       l_chg_evt_tab(l_tab_counter) := 'COAT';
5334       l_prmtr_01_tab(l_tab_counter) := p_old_rec.period_of_service_id;
5335       l_prmtr_02_tab(l_tab_counter) := null;
5336       l_prmtr_03_tab(l_tab_counter) := null;
5337       l_prmtr_04_tab(l_tab_counter) := null;
5338       l_prmtr_05_tab(l_tab_counter) := null;
5339       l_prmtr_06_tab(l_tab_counter) := null;
5340       l_prmtr_07_tab(l_tab_counter) := null;
5341       l_old_val1(l_tab_counter)     := p_old_rec.actual_termination_date;
5342       l_new_val1(l_tab_counter)     := p_new_rec.actual_termination_date;
5343     end if;
5344     if p_old_rec.actual_termination_date is not null and p_new_rec.actual_termination_date is null then
5345       l_tab_counter := l_tab_counter + 1;
5346 --Bug 4539732  Store the change effective date for each event in its own place
5347       l_chg_eff_dt(l_tab_counter) := p_old_rec.actual_termination_date;
5348 --End Bug 4539732
5349       l_chg_evt_tab(l_tab_counter) := 'DAT';
5350       l_prmtr_01_tab(l_tab_counter) := p_old_rec.period_of_service_id;
5351       l_prmtr_02_tab(l_tab_counter) := null;
5352       l_prmtr_03_tab(l_tab_counter) := null;
5353       l_prmtr_04_tab(l_tab_counter) := null;
5354       l_prmtr_05_tab(l_tab_counter) := null;
5355       l_prmtr_06_tab(l_tab_counter) := null;
5356       l_prmtr_07_tab(l_tab_counter) := null;
5357       l_old_val1(l_tab_counter)     := p_old_rec.actual_termination_date;
5358       l_new_val1(l_tab_counter)     := null;
5359     end if;
5360     if nvl(p_old_rec.leaving_reason,'*') <> nvl(p_new_rec.leaving_reason,'*') then
5361       l_tab_counter := l_tab_counter + 1;
5362 --Bug 4539732  Store the change effective date for each event in its own place
5363       l_chg_eff_dt(l_tab_counter) := nvl(p_old_rec.actual_termination_date,trunc(sysdate));
5364 --      truncated the sysdate so that only date gets into rather than time also getting into the table
5365 --End Bug 4539732
5366       l_chg_evt_tab(l_tab_counter) := 'COTR';
5367       l_prmtr_01_tab(l_tab_counter) := p_old_rec.period_of_service_id;
5368       l_prmtr_02_tab(l_tab_counter) := null;
5369       l_prmtr_03_tab(l_tab_counter) := null;
5370       l_prmtr_04_tab(l_tab_counter) := null;
5371       l_prmtr_05_tab(l_tab_counter) := null;
5372       l_prmtr_06_tab(l_tab_counter) := null;
5373       l_prmtr_07_tab(l_tab_counter) := null;
5374       l_old_val1(l_tab_counter)     := p_old_rec.leaving_reason;
5375       l_new_val1(l_tab_counter)     := p_new_rec.leaving_reason;
5376     end if;
5377    if p_old_rec.date_start is not null and
5378          p_new_rec.date_start is not null and
5379          p_old_rec.date_start <> p_new_rec.date_start then
5380       l_tab_counter := l_tab_counter + 1;
5381 --Bug 4539732  Store the change effective date for each event in its own place
5382       l_chg_eff_dt(l_tab_counter) := p_new_rec.date_start;
5383 --End Bug 4539732
5384       l_chg_evt_tab(l_tab_counter) := 'COPOS';
5385       l_prmtr_01_tab(l_tab_counter) := p_old_rec.period_of_service_id;
5386       l_prmtr_02_tab(l_tab_counter) := null;
5387       l_prmtr_03_tab(l_tab_counter) := null;
5388       l_prmtr_04_tab(l_tab_counter) := null;
5389       l_prmtr_05_tab(l_tab_counter) := null;
5390       l_prmtr_06_tab(l_tab_counter) := null;
5391       l_prmtr_07_tab(l_tab_counter) := null;
5392       l_old_val1(l_tab_counter)     := p_old_rec.date_start;
5393       l_new_val1(l_tab_counter)     := p_new_rec.date_start;
5394     end if;
5395   --
5396   elsif p_event = 'INSERT' then
5397       l_tab_counter := l_tab_counter + 1;
5398 --Bug 4539732  Store the change effective date for each event in its own place
5399       l_chg_eff_dt(l_tab_counter) := p_new_rec.date_start;
5400 --End Bug 4539732
5401       l_chg_evt_tab(l_tab_counter) := 'APS';
5402       l_prmtr_01_tab(l_tab_counter) := p_new_rec.period_of_service_id;
5403       l_prmtr_02_tab(l_tab_counter) := null;
5404       l_prmtr_03_tab(l_tab_counter) := null;
5405       l_prmtr_04_tab(l_tab_counter) := null;
5406       l_prmtr_05_tab(l_tab_counter) := null;
5407       l_prmtr_06_tab(l_tab_counter) := null;
5408       l_prmtr_07_tab(l_tab_counter) := null;
5409       l_old_val1(l_tab_counter)     := null;
5410       l_new_val1(l_tab_counter)     := p_new_rec.date_start;
5411   end if;
5412 --
5413   for l_count in 1..l_chg_evt_tab.count loop
5414    if change_event_is_enabled(l_chg_evt_tab(l_count),l_chg_eff_dt(l_count)) then
5415 --Bug 4539732  Create ext change event with each event having its own l_chg_eff_dt
5416     ben_ext_chg_evt_api.create_ext_chg_evt
5417     (p_validate                    => FALSE
5418     ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
5419     ,p_chg_evt_cd                  => l_chg_evt_tab(l_count)
5420     ,p_chg_eff_dt                  => l_chg_eff_dt(l_count)
5421     ,p_prmtr_01                    => l_prmtr_01_tab(l_count)
5422     ,p_prmtr_02                    => l_prmtr_02_tab(l_count)
5423     ,p_prmtr_03                    => l_prmtr_03_tab(l_count)
5424     ,p_prmtr_04                    => l_prmtr_04_tab(l_count)
5425     ,p_prmtr_05                    => l_prmtr_05_tab(l_count)
5426     ,p_prmtr_06                    => l_prmtr_06_tab(l_count)
5427     ,p_prmtr_07                    => l_prmtr_07_tab(l_count)
5428     ,p_prmtr_10                    => p_new_rec.update_mode
5429     ,p_person_id                   => p_new_rec.person_id
5430     ,p_business_group_id           => p_new_rec.business_group_id
5431     ,p_object_version_number       => l_object_version_number
5432     ,p_effective_date              => l_chg_eff_dt(l_count)
5433     ,p_new_val1                    => l_new_val1(l_count)
5434     ,p_old_val1                    => l_old_val1(l_count)
5435     );
5436 --End Bug 4539732
5437    end if;
5438   end loop;
5439 --
5440   hr_utility.set_location('Exiting:'||l_proc, 99);
5441 --
5442 end log_pos_chg;
5443 --
5444 procedure log_apl_chg
5445           (p_event     in  varchar2
5446           ,p_old_rec   in  g_apl_rec_type
5447           ,p_new_rec   in  g_apl_rec_type
5448           ) is
5449 --
5450   l_chg_evt_tab           g_char_tab_type;
5451   l_prmtr_01_tab          g_char_tab_type;
5452   l_prmtr_02_tab          g_char_tab_type;
5453   l_prmtr_03_tab          g_char_tab_type;
5454   l_prmtr_04_tab          g_char_tab_type;
5455   l_prmtr_05_tab          g_char_tab_type;
5456   l_prmtr_06_tab          g_char_tab_type;
5457   l_prmtr_07_tab          g_char_tab_type;
5458   l_new_val1              g_new_val;
5459   l_new_val2              g_new_val;
5460   l_new_val3              g_new_val;
5461   l_new_val4              g_new_val;
5462   l_new_val5              g_new_val;
5463   l_new_val6              g_new_val;
5464   l_old_val1              g_old_val;
5465   l_old_val2              g_old_val;
5466   l_old_val3              g_old_val;
5467   l_old_val4              g_old_val;
5468   l_old_val5              g_old_val;
5469   l_old_val6              g_old_val;
5470   l_tab_counter           binary_integer := 0;
5471   l_chg_eff_dt            date;
5472   l_count                 number;
5473   l_ext_chg_evt_log_id    number;
5474   l_object_version_number number;
5475 --
5476   l_proc         varchar2(72) := 'ben_ext_chlg.log_apl_chg';
5477 --
5478   cursor c_termination_reason (p_termination_reason per_applications.termination_reason%type)
5479   is
5480   select hl.meaning
5481   from   hr_lookups hl
5482   where  hl.lookup_type = 'TERM_APL_REASON'
5483   and    hl.lookup_code = p_termination_reason
5484   and    hl.enabled_flag = 'Y';
5485 --
5486   l_old_termination_reason  varchar2(50);
5487   l_new_termination_reason  varchar2(50);
5488 --
5489 begin
5490 --
5491   hr_utility.set_location('Entering:'||l_proc, 10);
5492 -- removed because the pos leaving reason should
5493 -- have been used.
5494 null;
5495 --
5496   hr_utility.set_location('Exiting:'||l_proc, 99);
5497 --
5498 end log_apl_chg;
5499 --
5500 
5501 
5502 procedure log_prem_mo_chg
5503           (p_event     in  varchar2
5504           ,p_old_rec   in  g_prem_mo_rec_type
5505           ,p_new_rec   in  g_prem_mo_rec_type
5506           )is
5507 --
5508   l_person_id             number ;
5509   l_ext_chg_evt_log_id    number ;
5510   l_object_version_number number;
5511 
5512   Cursor c_person(p_prtt_prem_id number) is
5513   select person_id
5514    from ben_per_in_ler  pil,
5515         ben_prtt_prem_f ppe
5516   where ppe.prtt_prem_id = p_prtt_prem_id
5517     and ppe.per_in_ler_id = pil.per_in_ler_id ;
5518 --
5519   l_proc         varchar2(72) := 'ben_ext_chlg.log_prem_mo_chg';
5520 Begin
5521   hr_utility.set_location('Entering:'||l_proc, 10);
5522   open c_person(p_new_rec.prtt_prem_id) ;
5523   fetch c_person into l_person_id  ;
5524   close c_person ;
5525 
5526   if  p_new_rec.val <> p_old_rec.val then
5527       -- before the fix there was a typo in lookp code
5528       -- lookup code is COPMPRM, event logged for CCOPMPRM
5529       -- this is fixed by obsolete the COPMPRM and added CCOPMPRM in lookup
5530       -- the code support for COPMPRM to make sure the customer has no problem
5531       -- if the data is logged, ct can get the data by changing the setup at anytime
5532 
5533        hr_utility.set_location('valiating chg evt cd :', 10);
5534       if (change_event_is_enabled('COPMPRM',p_new_rec.effective_start_date) or
5535           change_event_is_enabled('CCOPMPRM',p_new_rec.effective_start_date) )  then
5536 
5537           hr_utility.set_location('calling  log event :', 10);
5538 
5539           ben_ext_chg_evt_api.create_ext_chg_evt
5540              (p_validate              => FALSE
5541               ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
5542               ,p_chg_evt_cd            => 'CCOPMPRM'
5543               ,p_chg_eff_dt            => p_new_rec.effective_start_date
5544               ,p_business_group_id     => p_new_rec.business_group_id
5545               ,p_person_id             => l_person_id
5546               ,p_object_version_number => l_object_version_number
5547               ,p_effective_date        => p_new_rec.effective_start_date
5548               ,p_old_val1              => p_old_rec.val
5549               ,p_old_val2              => p_old_rec.cr_val
5550               ,p_old_val3              => p_old_rec.mo_num
5551               ,p_old_val4              => p_old_rec.yr_num
5552               ,p_new_val1              => p_new_rec.val
5553               ,p_new_val2              => p_new_rec.cr_val
5554               ,p_new_val3              => p_new_rec.mo_num
5555               ,p_new_val4              => p_new_rec.yr_num
5556              );
5557 
5558        end if ;
5559   end if ;
5560 --
5561   hr_utility.set_location('Exiting:'||l_proc, 99);
5562 --
5563 end log_prem_mo_chg;
5564 
5565 --
5566 procedure log_school_chg
5567           (p_event     in  varchar2
5568           ,p_old_rec   in  g_per_school_rec_type
5569           ,p_new_rec   in  g_per_school_rec_type
5570           ) is
5571 --
5572   l_old_name     PER_ESTABLISHMENTS.name%type ;
5573   l_new_name     PER_ESTABLISHMENTS.name%type ;
5574   l_ext_chg_evt_log_id    number ;
5575   l_object_version_number number;
5576 
5577   Cursor c_name(p_establishment_id number) is
5578   select name from PER_ESTABLISHMENTS
5579   where establishment_id = p_establishment_id ;
5580 
5581 --
5582   l_proc         varchar2(72) := 'ben_ext_chlg.log_school_chg';
5583 Begin
5584   hr_utility.set_location('Entering:'||l_proc, 10);
5585   open c_name(p_old_rec.establishment_id) ;
5586   fetch c_name into l_old_name  ;
5587   close c_name ;
5588 
5589   open c_name(p_new_rec.establishment_id) ;
5590   fetch c_name into l_new_name  ;
5591   close c_name ;
5592 
5593   if  nvl(l_new_name,'$$$$') <> nvl(l_old_name,'$$$$')
5594       or p_new_rec.attended_start_date <> p_old_rec.attended_start_date
5595       or p_new_rec.attended_end_date <> p_old_rec.attended_end_date then
5596       if change_event_is_enabled('COSCOL',p_new_rec.attended_start_date) then
5597           ben_ext_chg_evt_api.create_ext_chg_evt
5598              (p_validate              => FALSE
5599               ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
5600               ,p_chg_evt_cd            => 'COSCOL'
5601               ,p_chg_eff_dt            => p_new_rec.attended_start_date
5602               ,p_business_group_id     => p_new_rec.business_group_id
5603               ,p_person_id             => p_new_rec.person_id
5604               ,p_object_version_number => l_object_version_number
5605               ,p_effective_date        => p_new_rec.attended_start_date
5606               ,p_old_val1              => l_old_name
5607               ,p_old_val2              => p_old_rec.attended_start_date
5608               ,p_old_val3              => p_old_rec.attended_end_date
5609               ,p_new_val1              => l_new_name
5610               ,p_new_val2              => p_new_rec.attended_start_date
5611               ,p_new_val3              => p_new_rec.attended_end_date
5612              );
5613        end if ;
5614   end if ;
5615 --
5616   hr_utility.set_location('Exiting:'||l_proc, 99);
5617 --
5618 end log_school_chg;
5619 
5620 
5621 
5622 
5623 procedure log_per_pay_chg
5624           (p_event     in  varchar2
5625           ,p_old_rec   in  g_per_pay_rec_type
5626           ,p_new_rec   in  g_per_pay_rec_type
5627           ) is
5628 --
5629   l_chg_eff_dt            date;
5630   l_count                 number;
5631   l_ext_chg_evt_log_id    number;
5632   l_object_version_number number;
5633 --
5634   l_proc         varchar2(72) := 'ben_ext_chlg.log_per_pay_chg';
5635  cursor c_person (p_assignment_id number)
5636   is
5637   select person_id ,business_group_id
5638   from   per_all_Assignments_f  asg
5639   where  asg.assignment_id  = p_assignment_id ;
5640 --
5641    cursor c_old_sal(p_assignment_id number,p_change_date date)  is
5642      select
5643      proposed_salary_n, approved
5644      from per_pay_proposals b
5645       where
5646           b.assignment_id = p_assignment_id
5647           and b.change_date =
5648           (select max(d.change_date)
5649              from  per_pay_proposals d
5650              where  d.assignment_id = b.assignment_id
5651              and approved = 'Y'
5652              and change_date < p_change_date  )
5653            ;
5654 
5655 
5656   l_person_id              number ;
5657   l_business_group_id      number ;
5658   l_old_proposed_salary_n  per_pay_proposals.proposed_salary_n%type := p_old_rec.proposed_salary_n;
5659   l_old_approved           per_pay_proposals.approved%type ;
5660 --
5661 begin
5662 --
5663 
5664   hr_utility.set_location('Entering:'||l_proc, 10);
5665   hr_utility.set_location('assignment_id:'||p_new_rec.assignment_id, 10);
5666  /*
5667  open c_person(p_new_rec.assignment_id);
5668  fetch c_person into l_person_id,l_business_group_id ;
5669  close c_person ;
5670  */
5671  hr_utility.set_location(' EVENT ' || p_event, 99 );
5672 
5673  --- previously part of trigger  now the trigger moved to api (pepyprhi.pkb)
5674  --- so the approved validation moved here
5675 
5676  if nvl(p_new_rec.approved,'N') = 'Y' then
5677     if p_event = 'INSERT' then
5678        hr_utility.set_location('change_date' || p_new_rec.change_date,10);
5679        open c_old_sal(p_new_rec.assignment_id,p_new_rec.change_date);
5680        fetch c_old_sal into l_old_proposed_salary_n ,l_old_approved ;
5681        close c_old_sal ;
5682         hr_utility.set_location('salary ' || l_old_proposed_salary_n,10);
5683      end if ;
5684 
5685 
5686 
5687      if nvl(l_old_proposed_salary_n,-1) <> nvl(p_new_rec.proposed_salary_n,-1)
5688        or nvl(nvl(l_old_approved,p_old_rec.approved),'N') <> nvl(p_new_rec.approved,'N')  then
5689 
5690          if change_event_is_enabled('COBSAL',p_new_rec.change_date) then
5691 
5692             open c_person(p_new_rec.assignment_id);
5693             fetch c_person into l_person_id,l_business_group_id ;
5694             close c_person ;
5695 
5696              ben_ext_chg_evt_api.create_ext_chg_evt
5697                 (p_validate              => FALSE
5698                 ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
5699                 ,p_chg_evt_cd            => 'COBSAL'
5700                 ,p_chg_eff_dt            => p_new_rec.change_date
5701                 ,p_business_group_id     => l_business_group_id
5702                 ,p_person_id             => l_person_id
5703                 ,p_object_version_number => l_object_version_number
5704                 ,p_effective_date        => nvl(p_new_rec.change_date,p_new_rec.last_change_date)
5705                 ,p_old_val1              => l_old_proposed_salary_n
5706                 ,p_old_val2              => nvl(l_old_approved,p_old_rec.approved)
5707                 ,p_new_val1              => p_new_rec.proposed_salary_n
5708                 ,p_new_val2              => p_new_rec.approved
5709                );
5710            End if;
5711     end if ;
5712  end if ;
5713 --
5714   hr_utility.set_location('Exiting:'||l_proc, 99);
5715 --
5716 end log_per_pay_chg;
5717 
5718 ----
5719 
5720 procedure log_phn_chg
5721           (p_event     in  varchar2
5722           ,p_old_rec   in  g_phn_rec_type
5723           ,p_new_rec   in  g_phn_rec_type
5724           ) is
5725 --
5726   l_chg_evt_tab           g_char_tab_type;
5727   l_prmtr_01_tab          g_char_tab_type;
5728   l_prmtr_02_tab          g_char_tab_type;
5729   l_prmtr_03_tab          g_char_tab_type;
5730   l_prmtr_04_tab          g_char_tab_type;
5731   l_prmtr_05_tab          g_char_tab_type;
5732   l_prmtr_06_tab          g_char_tab_type;
5733   l_prmtr_07_tab          g_char_tab_type;
5734   l_new_val1              g_new_val;
5735   l_new_val2              g_new_val;
5736   l_new_val3              g_new_val;
5737   l_new_val4              g_new_val;
5738   l_new_val5              g_new_val;
5739   l_new_val6              g_new_val;
5740   l_old_val1              g_old_val;
5741   l_old_val2              g_old_val;
5742   l_old_val3              g_old_val;
5743   l_old_val4              g_old_val;
5744   l_old_val5              g_old_val;
5745   l_old_val6              g_old_val;
5746   l_tab_counter           binary_integer := 0;
5747   l_chg_eff_dt            date;
5748   l_count                 number := 0;
5749   l_ext_chg_evt_log_id    number;
5750   l_object_version_number number;
5751 --
5752   l_proc         varchar2(72) := 'ben_ext_chlg.log_phn_chg';
5753 --
5754   cursor c_termination_reason (p_termination_reason per_applications.termination_reason%type)
5755   is
5756   select meaning
5757   from   hr_lookups hl
5758   where  hl.lookup_type = 'TERM_APL_REASON'
5759   and    hl.lookup_code = p_termination_reason
5760   and    hl.enabled_flag = 'Y';
5761 --
5762   cursor c_business_group_id(p_person_id per_all_people_f.person_id%type
5763 				    /* ,p_effective_dt date */-- commented for bug 3361237
5764 					)
5765   is
5766   select ppf.business_group_id
5767   from   per_all_people_f ppf
5768   where  ppf.person_id = p_person_id;
5769 /*  and    p_effective_dt between nvl(ppf.effective_start_date, sysdate)
5770                         and nvl(ppf.effective_end_date, sysdate);*/
5771 -- commented for bug 3361237
5772 --
5773   l_old_termination_reason  varchar2(50);
5774   l_new_termination_reason  varchar2(50);
5775   l_chg_evt_code            varchar2(10);
5776   l_business_group_id       number;
5777   l_person_id               number;       --Bug 1554477
5778   l_update_mode             varchar2(15); --Bug 1554477
5779 --
5780 begin
5781 --
5782   hr_utility.set_location('Entering:'||l_proc, 10);
5783 --
5784   if p_event = 'UPDATE' and p_new_rec.parent_table = 'PER_ALL_PEOPLE_F'
5785     and p_new_rec.phone_type in ('H1', 'W1', 'HF','M') then
5786 --
5787     --Start Bug 1554477
5788       if p_old_rec.date_to is null and
5789             p_new_rec.date_to is not null then
5790 
5791         if p_new_rec.phone_type = 'H1' then
5792           l_chg_evt_code := 'AHPDT';
5793         elsif p_new_rec.phone_type = 'W1' then
5794           l_chg_evt_code := 'AWPDT';
5795         elsif p_new_rec.phone_type = 'HF' then
5796           l_chg_evt_code := 'AFPDT';
5797         elsif p_new_rec.phone_type = 'M' then
5798           l_chg_evt_code := 'AMDT';
5799         end if;
5800         l_chg_eff_dt := nvl(p_new_rec.date_to, sysdate);
5801         l_tab_counter := l_tab_counter + 1;
5802         l_chg_evt_tab(l_tab_counter) := l_chg_evt_code;
5803         l_prmtr_01_tab(l_tab_counter) := p_old_rec.phone_id;
5804         l_prmtr_02_tab(l_tab_counter) := null;
5805         l_prmtr_03_tab(l_tab_counter) := null;
5806         l_prmtr_04_tab(l_tab_counter) := null;
5807         l_prmtr_05_tab(l_tab_counter) := null;
5808         l_prmtr_06_tab(l_tab_counter) := null;
5809         l_prmtr_07_tab(l_tab_counter) := null;
5810         l_old_val1(l_tab_counter)     := p_old_rec.phone_number;
5811         l_new_val1(l_tab_counter)     := null;
5812         --
5813         l_update_mode := p_new_rec.update_mode;
5814         l_person_id := p_new_rec.parent_id;
5815        end if;
5816      --End Bug 1554477
5817 
5818       if nvl(p_old_rec.phone_number, '$') <>
5819            nvl(p_new_rec.phone_number, '$') then
5820         if p_new_rec.phone_type = 'H1' then
5821           l_chg_evt_code := 'COHP';
5822         elsif p_new_rec.phone_type = 'W1' then
5823           l_chg_evt_code := 'COWP';
5824         elsif p_new_rec.phone_type = 'HF' then
5825           l_chg_evt_code := 'COFP';
5826         elsif p_new_rec.phone_type = 'M' then	--Bug 1554477
5827           l_chg_evt_code := 'CMP';
5828         end if;
5829         l_chg_eff_dt := nvl(p_new_rec.date_from, sysdate);
5830         l_tab_counter := l_tab_counter + 1;
5831         l_chg_evt_tab(l_tab_counter) := l_chg_evt_code;
5832         l_prmtr_01_tab(l_tab_counter) := p_old_rec.phone_id;
5833         l_prmtr_02_tab(l_tab_counter) := null;
5834         l_prmtr_03_tab(l_tab_counter) := null;
5835         l_prmtr_04_tab(l_tab_counter) := null;
5836         l_prmtr_05_tab(l_tab_counter) := null;
5837         l_prmtr_06_tab(l_tab_counter) := null;
5838         l_prmtr_07_tab(l_tab_counter) := null;
5839         l_old_val1(l_tab_counter)     := p_old_rec.phone_number;
5840         l_new_val1(l_tab_counter)     := p_new_rec.phone_number;
5841         --
5842         l_update_mode := p_new_rec.update_mode;
5843         l_person_id := p_new_rec.parent_id;
5844        end if;
5845 
5846  --Start Bug 1554477
5847    elsif p_event = 'INSERT' and p_new_rec.parent_table = 'PER_ALL_PEOPLE_F'
5848     and p_new_rec.phone_type in ('H1', 'W1', 'HF', 'M') then
5849 --
5850         if p_old_rec.date_to is null and
5851             p_new_rec.date_to is not null then
5852         if p_new_rec.phone_type = 'H1' then
5853           l_chg_evt_code := 'AHPDT';
5854         elsif p_new_rec.phone_type = 'W1' then
5855           l_chg_evt_code := 'AWPDT';
5856         elsif p_new_rec.phone_type = 'HF' then
5857           l_chg_evt_code := 'AFPDT';
5858         elsif p_new_rec.phone_type = 'M' then
5859           l_chg_evt_code := 'AMDT';
5860         end if;
5861         l_chg_eff_dt := nvl(p_new_rec.date_to, sysdate);
5862         l_tab_counter := l_tab_counter + 1;
5863         l_chg_evt_tab(l_tab_counter) := l_chg_evt_code;
5864         l_prmtr_01_tab(l_tab_counter) := p_old_rec.phone_id;
5865         l_prmtr_02_tab(l_tab_counter) := null;
5866         l_prmtr_03_tab(l_tab_counter) := null;
5867         l_prmtr_04_tab(l_tab_counter) := null;
5868         l_prmtr_05_tab(l_tab_counter) := null;
5869         l_prmtr_06_tab(l_tab_counter) := null;
5870         l_prmtr_07_tab(l_tab_counter) := null;
5871         l_old_val1(l_tab_counter)     := p_new_rec.phone_number;
5872         l_new_val1(l_tab_counter)     := null;
5873         --
5874         l_update_mode := p_new_rec.update_mode;
5875         l_person_id := p_new_rec.parent_id;
5876         end if;
5877 
5878         if p_new_rec.phone_type = 'H1' then
5879           l_chg_evt_code := 'AHP';
5880         elsif p_new_rec.phone_type = 'W1' then
5881           l_chg_evt_code := 'AWP';
5882         elsif p_new_rec.phone_type = 'HF' then
5883           l_chg_evt_code := 'AFP';
5884         elsif p_new_rec.phone_type = 'M' then
5885           l_chg_evt_code := 'AMP';
5886         end if;
5887         l_chg_eff_dt := nvl(p_new_rec.date_from, sysdate);
5888         l_tab_counter := l_tab_counter + 1;
5889         l_chg_evt_tab(l_tab_counter) := l_chg_evt_code;
5890         l_prmtr_01_tab(l_tab_counter) := p_new_rec.phone_id;
5891         l_prmtr_02_tab(l_tab_counter) := null;
5892         l_prmtr_03_tab(l_tab_counter) := null;
5893         l_prmtr_04_tab(l_tab_counter) := null;
5894         l_prmtr_05_tab(l_tab_counter) := null;
5895         l_prmtr_06_tab(l_tab_counter) := null;
5896         l_prmtr_07_tab(l_tab_counter) := null;
5897         l_old_val1(l_tab_counter)     := null;
5898         l_new_val1(l_tab_counter)     := p_new_rec.phone_number;
5899         --
5900 
5901         l_update_mode := p_new_rec.update_mode;
5902         l_person_id := p_new_rec.parent_id;
5903 
5904     elsif p_event = 'DELETE' and p_old_rec.parent_table = 'PER_ALL_PEOPLE_F'
5905     and p_old_rec.phone_type in ('H1', 'W1', 'HF', 'M') then
5906 --
5907 
5908         if p_old_rec.phone_type = 'H1' then
5909           l_chg_evt_code := 'DHP';
5910         elsif p_old_rec.phone_type = 'W1' then
5911           l_chg_evt_code := 'DWP';
5912         elsif p_old_rec.phone_type = 'HF' then
5913           l_chg_evt_code := 'DFP';
5914         elsif p_old_rec.phone_type = 'M' then
5915           l_chg_evt_code := 'DMP';
5916         end if;
5917         --l_chg_eff_dt := nvl(p_old_rec.date_from, sysdate);-- 3361237
5918         l_chg_eff_dt := greatest(nvl(p_old_rec.date_to, p_old_rec.date_from), sysdate);
5919         l_tab_counter := l_tab_counter + 1;
5920         l_chg_evt_tab(l_tab_counter) := l_chg_evt_code;
5921         l_prmtr_01_tab(l_tab_counter) := p_old_rec.phone_id;
5922         l_prmtr_02_tab(l_tab_counter) := null;
5923         l_prmtr_03_tab(l_tab_counter) := null;
5924         l_prmtr_04_tab(l_tab_counter) := null;
5925         l_prmtr_05_tab(l_tab_counter) := null;
5926         l_prmtr_06_tab(l_tab_counter) := null;
5927         l_prmtr_07_tab(l_tab_counter) := null;
5928         l_old_val1(l_tab_counter)     := p_old_rec.phone_number;
5929         l_new_val1(l_tab_counter)     := null;
5930         --
5931 
5932         l_update_mode := p_old_rec.update_mode;
5933         l_person_id := p_old_rec.parent_id;
5934    end if;
5935 
5936 --Bug 1554477
5937 
5938 --
5939   open c_business_group_id(l_person_id); --, l_chg_eff_dt);    -- commented for bug 3361237
5940 -- Bug 1554477
5941   fetch c_business_group_id into l_business_group_id;
5942   close c_business_group_id;
5943   hr_utility.set_location('l_business_group_id:'||l_business_group_id, 876);
5944 
5945   for l_count in 1..l_chg_evt_tab.count loop
5946    if change_event_is_enabled(l_chg_evt_tab(l_count),l_chg_eff_dt) then
5947 
5948     ben_ext_chg_evt_api.create_ext_chg_evt
5949     (p_validate                    => FALSE
5950     ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
5951     ,p_chg_evt_cd                  => l_chg_evt_tab(l_count)
5952     ,p_chg_eff_dt                  => l_chg_eff_dt
5953     ,p_prmtr_01                    => l_prmtr_01_tab(l_count)
5954     ,p_prmtr_02                    => l_prmtr_02_tab(l_count)
5955     ,p_prmtr_03                    => l_prmtr_03_tab(l_count)
5956     ,p_prmtr_04                    => l_prmtr_04_tab(l_count)
5957     ,p_prmtr_05                    => l_prmtr_05_tab(l_count)
5958     ,p_prmtr_06                    => l_prmtr_06_tab(l_count)
5959     ,p_prmtr_07                    => l_prmtr_07_tab(l_count)
5960     ,p_prmtr_10                    => l_update_mode       --Bug 1554477
5961     ,p_person_id                   => l_person_id         --Bug 1554477
5962     ,p_business_group_id           => l_business_group_id
5963     ,p_object_version_number       => l_object_version_number
5964     ,p_effective_date              => l_chg_eff_dt
5965     ,p_new_val1                    => l_new_val1(l_count)
5966     ,p_old_val1                    => l_old_val1(l_count)
5967     );
5968 
5969     end if;
5970   end loop;
5971 --
5972   hr_utility.set_location('Exiting:'||l_proc, 99);
5973 --
5974 end log_phn_chg;
5975 --
5976 procedure log_ptu_chg
5977           (p_event     in  varchar2
5978           ,p_old_rec   in  g_ptu_rec_type
5979           ,p_new_rec   in  g_ptu_rec_type
5980           ) is
5981 --
5982   l_chg_evt_tab           g_char_tab_type;
5983   l_prmtr_01_tab          g_char_tab_type;
5984   l_prmtr_02_tab          g_char_tab_type;
5985   l_prmtr_03_tab          g_char_tab_type;
5986   l_prmtr_04_tab          g_char_tab_type;
5987   l_prmtr_05_tab          g_char_tab_type;
5988   l_prmtr_06_tab          g_char_tab_type;
5989   l_prmtr_07_tab          g_char_tab_type;
5990   l_new_val1              g_new_val;
5991   l_new_val2              g_new_val;
5992   l_new_val3              g_new_val;
5993   l_new_val4              g_new_val;
5994   l_new_val5              g_new_val;
5995   l_new_val6              g_new_val;
5996   l_old_val1              g_old_val;
5997   l_old_val2              g_old_val;
5998   l_old_val3              g_old_val;
5999   l_old_val4              g_old_val;
6000   l_old_val5              g_old_val;
6001   l_old_val6              g_old_val;
6002   l_tab_counter           binary_integer := 0;
6003   l_chg_eff_dt            date;
6004   l_count                 number := 0;
6005   l_ext_chg_evt_log_id    number;
6006   l_object_version_number number;
6007   l_old_user_person_type  ben_ext_chg_evt_log.old_val1%TYPE;
6008   l_old_person_typ        ben_ext_chg_evt_log.old_val1%TYPE;
6009   l_new_user_person_type  ben_ext_chg_evt_log.new_val1%TYPE;
6010   -- Bug 4705814.
6011 --
6012   l_proc         varchar2(72) := 'ben_ext_chlg.log_ptu_chg';
6013 --
6014   cursor c_person_type(p_person_type_id    per_person_types.person_type_id%type)
6015   is
6016   select ppt.system_person_type, ppt.user_person_type, ppt.business_group_id
6017   from   per_person_types ppt
6018   where  ppt.person_type_id = p_person_type_id;
6019 --
6020   l_chg_evt_code      varchar2(30);
6021   l_person_type       varchar2(30);
6022   l_business_group_id number;
6023 --
6024 begin
6025 --
6026   hr_utility.set_location('Entering:'||l_proc, 10);
6027 --
6028   if p_event = 'INSERT' then
6029 --
6030     open c_person_type(p_new_rec.person_type_id);
6031     fetch c_person_type into l_person_type, l_new_user_person_type, l_business_group_id;
6032     close c_person_type;
6033 
6034     l_chg_evt_code := null;
6035     if l_person_type = 'EMP' then
6036       l_chg_evt_code := 'AEPTU';
6037     elsif l_person_type = 'BNF' then
6038       l_chg_evt_code := 'ABPTU';
6039     elsif l_person_type = 'DPNT' then
6040       l_chg_evt_code := 'ADPTU';
6041     elsif l_person_type = 'PRTN' then
6042       l_chg_evt_code := 'APPTU';
6043     end if;
6044 
6045     open c_person_type(p_old_rec.person_type_id);
6046     fetch c_person_type into l_old_person_typ, l_old_user_person_type, l_business_group_id;
6047     close c_person_type;
6048 
6049     if l_chg_evt_code is not null then
6050 
6051       l_chg_eff_dt := nvl(p_new_rec.effective_start_date, sysdate);
6052       l_tab_counter := l_tab_counter + 1;
6053       l_chg_evt_tab(l_tab_counter) := l_chg_evt_code;
6054       l_prmtr_01_tab(l_tab_counter) := p_new_rec.person_type_usage_id;
6055       l_prmtr_02_tab(l_tab_counter) := null;
6056       l_prmtr_03_tab(l_tab_counter) := null;
6057       l_prmtr_04_tab(l_tab_counter) := null;
6058       l_prmtr_05_tab(l_tab_counter) := null;
6059       l_prmtr_06_tab(l_tab_counter) := null;
6060       l_prmtr_07_tab(l_tab_counter) := null;
6061       l_old_val1(l_tab_counter)     := l_old_user_person_type; -- null;
6062       l_new_val1(l_tab_counter)     := l_new_user_person_type; -- null;
6063       -- Bug 4705814, passing person_type ( Initially passed NULLs ) to Old, New Values
6064 
6065     end if;
6066 
6067   end if;
6068 --
6069   for l_count in 1..l_chg_evt_tab.count loop
6070    if change_event_is_enabled(l_chg_evt_tab(l_count),l_chg_eff_dt) then
6071     ben_ext_chg_evt_api.create_ext_chg_evt
6072     (p_validate                    => FALSE
6073     ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
6074     ,p_chg_evt_cd                  => l_chg_evt_tab(l_count)
6075     ,p_chg_eff_dt                  => l_chg_eff_dt
6076     ,p_prmtr_01                    => l_prmtr_01_tab(l_count)
6077     ,p_prmtr_02                    => l_prmtr_02_tab(l_count)
6078     ,p_prmtr_03                    => l_prmtr_03_tab(l_count)
6079     ,p_prmtr_04                    => l_prmtr_04_tab(l_count)
6080     ,p_prmtr_05                    => l_prmtr_05_tab(l_count)
6081     ,p_prmtr_06                    => l_prmtr_06_tab(l_count)
6082     ,p_prmtr_07                    => l_prmtr_07_tab(l_count)
6083     ,p_prmtr_10                    => p_new_rec.update_mode
6084     ,p_person_id                   => p_new_rec.person_id
6085     ,p_business_group_id           => l_business_group_id
6086     ,p_object_version_number       => l_object_version_number
6087     ,p_effective_date              => l_chg_eff_dt
6088     ,p_new_val1                    => l_new_val1(l_count)
6089     ,p_old_val1                    => l_old_val1(l_count)
6090     );
6091    end if;
6092   end loop;
6093 --
6094   hr_utility.set_location('Exiting:'||l_proc, 99);
6095 --
6096 end log_ptu_chg;
6097 --
6098 procedure log_element_chg(
6099         p_action               in varchar2,
6100         p_amt                  in number default null,
6101         p_old_amt              in number default null,
6102         p_input_value_id       in number default null,
6103         p_element_entry_id     in number default null,
6104         p_person_id            in number default null,
6105         p_effective_start_date in date default null,
6106         p_effective_end_date   in date default null,
6107         p_business_group_id    in number,
6108         p_effective_date       in date) is
6109 --
6110   l_proc         varchar2(72) := 'ben_ext_chlg.log_element_chg';
6111 --
6112 l_object_version_number number;
6113 l_ext_chg_evt_log_id number;
6114 --
6115 cursor c_get_element_info (p_input_value_id number) is
6116  select iv.name, et.element_name
6117  from pay_input_values_f iv,
6118       pay_element_types_f et
6119  where iv.input_value_id = p_input_value_id
6120  and   iv.element_type_id = et.element_type_id
6121  and   p_effective_date between iv.effective_start_date and iv.effective_end_date
6122  and   p_effective_date between et.effective_start_date and et.effective_end_date;
6123 --
6124 l_element_info c_get_element_info%rowtype;
6125 
6126 --
6127 begin
6128 --
6129   hr_utility.set_location('Entering:'||l_proc, 10);
6130 --
6131 open c_get_element_info(p_input_value_id);
6132 fetch c_get_element_info into l_element_info;
6133 close c_get_element_info;
6134 --
6135   if p_action = 'CREATE' then
6136     if change_event_is_enabled('AEE',p_effective_date) then
6137      ben_ext_chg_evt_api.create_ext_chg_evt
6138      (p_validate              => FALSE
6139      ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
6140      ,p_chg_evt_cd            => 'AEE'
6141      ,p_chg_eff_dt            => p_effective_date
6142      ,p_prmtr_01              => p_element_entry_id
6143      ,p_prmtr_02              => p_input_value_id
6144      ,p_person_id             => p_person_id
6145      ,p_business_group_id     => p_business_group_id
6146      ,p_object_version_number => l_object_version_number
6147      ,p_effective_date        => p_effective_date
6148      ,p_new_val1              => l_element_info.element_name
6149      ,p_new_val2              => l_element_info.name
6150      ,p_new_val3              => p_amt);
6151     end if;
6152     --
6153   elsif p_action = 'UPDATE' then
6154     if change_event_is_enabled('UEE',p_effective_date) then
6155      ben_ext_chg_evt_api.create_ext_chg_evt
6156      (p_validate              => FALSE
6157      ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
6158      ,p_chg_evt_cd            => 'UEE'
6159      ,p_chg_eff_dt            => p_effective_date
6160      ,p_prmtr_01              => p_element_entry_id
6161      ,p_prmtr_02              => p_input_value_id
6162      ,p_person_id             => p_person_id
6163      ,p_business_group_id     => p_business_group_id
6164      ,p_object_version_number => l_object_version_number
6165      ,p_effective_date        => p_effective_date
6166      ,p_old_val1              => l_element_info.element_name
6167      ,p_old_val2              => l_element_info.name
6168      ,p_old_val3              => p_old_amt
6169      ,p_new_val1              => l_element_info.element_name
6170      ,p_new_val2              => l_element_info.name
6171      ,p_new_val3              => p_amt);
6172     end if;
6173     --
6174   elsif p_action = 'DELETE' then
6175     hr_utility.set_location('deleteing element entry ' , 195);
6176     if change_event_is_enabled('DEE',p_effective_date) then
6177      ben_ext_chg_evt_api.create_ext_chg_evt
6178      (p_validate              => FALSE
6179      ,p_ext_chg_evt_log_id    => l_ext_chg_evt_log_id
6180      ,p_chg_evt_cd            => 'DEE'
6181      ,p_chg_eff_dt            => p_effective_date
6182      ,p_prmtr_01              => p_element_entry_id
6183      ,p_prmtr_02              => p_input_value_id
6184      ,p_person_id             => p_person_id
6185      ,p_business_group_id     => p_business_group_id
6186      ,p_object_version_number => l_object_version_number
6187      ,p_effective_date        => p_effective_date
6188      ,p_old_val1              => l_element_info.element_name
6189      ,p_old_val2              => l_element_info.name
6190      ,p_old_val3              => p_old_amt);
6191     end if;
6192   end if;
6193 --
6194 --
6195   hr_utility.set_location('Exiting:'||l_proc, 99);
6196 --
6197 end log_element_chg;
6198 --
6199 -- procedure for logging changes to per_disabilities_f
6200   procedure log_per_dis_chg
6201           (p_event     in  varchar2
6202           ,p_old_rec   in  per_dis_rec_type
6203           ,p_new_rec   in  per_dis_rec_type
6204           ) is
6205 --
6206   l_chg_evt_tab           g_char_tab_type;
6207   l_prmtr_01_tab          g_char_tab_type;
6208   l_prmtr_02_tab          g_char_tab_type;
6209   l_prmtr_03_tab          g_char_tab_type;
6210   l_prmtr_04_tab          g_char_tab_type;
6211   l_prmtr_05_tab          g_char_tab_type;
6212   l_prmtr_06_tab          g_char_tab_type;
6213   l_prmtr_07_tab          g_char_tab_type;
6214   l_old_val1              g_old_val;
6215   l_old_val2              g_old_val;
6216   l_old_val3              g_old_val;
6217   l_old_val4              g_old_val;
6218   l_old_val5              g_old_val;
6219   l_old_val6              g_old_val;
6220   l_new_val1              g_new_val;
6221   l_new_val2              g_new_val;
6222   l_new_val3              g_new_val;
6223   l_new_val4              g_new_val;
6224   l_new_val5              g_new_val;
6225   l_new_val6              g_new_val;
6226   l_tab_counter           binary_integer := 0;
6227   l_chg_eff_dt            date;
6228   l_count                 number;
6229   l_ext_chg_evt_log_id    number;
6230   l_object_version_number number;
6231 --
6232   cursor c_lookup_value
6233     (p_lookup_type hr_lookups.lookup_type%type
6234     ,p_lookup_code hr_lookups.lookup_code%type
6235     )
6236   is
6237   select meaning
6238   from hr_lookups hl
6239   where hl.lookup_type = p_lookup_type
6240   and hl.lookup_code = p_lookup_code;
6241 
6242 --
6243   l_proc               varchar2(100) := 'ben_ext_chlg.log_per_dis_chg';
6244 --
6245 
6246 --
6247  l_old_categoryname	hr_lookups.meaning%type;
6248  l_new_categoryname	hr_lookups.meaning%type;
6249  l_old_reason		hr_lookups.meaning%type;
6250  l_new_reason		hr_lookups.meaning%type;
6251  l_old_status		hr_lookups.meaning%type;
6252  l_new_status		hr_lookups.meaning%type;
6253  l_old_incident		per_work_incidents.incident_reference%type;
6254  l_new_incident		per_work_incidents.incident_reference%type;
6255  l_old_organization	hr_all_organization_units.name%type;
6256  l_new_organization	hr_all_organization_units.name%type;
6257 
6258 --
6259 begin
6260 --
6261   hr_utility.set_location('Entering:'|| l_proc, 10);
6262 --
6263   if p_event = 'UPDATE' then
6264 
6265   if nvl(p_old_rec.incident_id,1) <> nvl(p_new_rec.incident_id,1) then
6266 
6267       select incident_reference into l_old_incident
6268       from per_work_incidents
6269       where incident_id = p_old_rec.incident_id ;
6270 
6271       select incident_reference into l_new_incident
6272       from per_work_incidents
6273       where incident_id = l_new_incident ;
6274 
6275       l_tab_counter := l_tab_counter + 1;
6276       l_chg_evt_tab(l_tab_counter) := 'CINCID';
6277       l_prmtr_01_tab(l_tab_counter) := null;
6278       l_prmtr_02_tab(l_tab_counter) := null;
6279       l_prmtr_03_tab(l_tab_counter) := null;
6280       l_prmtr_04_tab(l_tab_counter) := null;
6281       l_prmtr_05_tab(l_tab_counter) := null;
6282       l_prmtr_06_tab(l_tab_counter) := null;
6283       l_prmtr_07_tab(l_tab_counter) := null;
6284       l_old_val1(l_tab_counter) := l_old_incident;
6285       l_new_val1(l_tab_counter) := l_new_incident;
6286       l_old_val2(l_tab_counter) := null;
6287       l_old_val3(l_tab_counter) := null;
6288       l_old_val4(l_tab_counter) := null;
6289       l_old_val5(l_tab_counter) := null;
6290       l_old_val6(l_tab_counter) := null;
6291       l_new_val2(l_tab_counter) := null;
6292       l_new_val3(l_tab_counter) := null;
6293       l_new_val4(l_tab_counter) := null;
6294       l_new_val5(l_tab_counter) := null;
6295       l_new_val6(l_tab_counter) := null;
6296   end if;
6297 
6298   if nvl(p_old_rec.organization_id,1) <> nvl(p_new_rec.organization_id,1) then
6299 
6300       select name into l_old_organization
6301       from hr_all_organization_units
6302       where organization_id = p_old_rec.organization_id ;
6303 
6304       select name into l_new_organization
6305       from hr_all_organization_units
6306       where organization_id = p_new_rec.organization_id ;
6307 
6308       l_tab_counter := l_tab_counter + 1;
6309       l_chg_evt_tab(l_tab_counter) := 'CORGID';
6310       l_prmtr_01_tab(l_tab_counter) := null;
6311       l_prmtr_02_tab(l_tab_counter) := null;
6312       l_prmtr_03_tab(l_tab_counter) := null;
6313       l_prmtr_04_tab(l_tab_counter) := null;
6314       l_prmtr_05_tab(l_tab_counter) := null;
6315       l_prmtr_06_tab(l_tab_counter) := null;
6316       l_prmtr_07_tab(l_tab_counter) := null;
6317       l_old_val1(l_tab_counter) := l_old_organization;
6318       l_new_val1(l_tab_counter) := l_new_organization;
6319       l_old_val2(l_tab_counter) := null;
6320       l_old_val3(l_tab_counter) := null;
6321       l_old_val4(l_tab_counter) := null;
6322       l_old_val5(l_tab_counter) := null;
6323       l_old_val6(l_tab_counter) := null;
6324       l_new_val2(l_tab_counter) := null;
6325       l_new_val3(l_tab_counter) := null;
6326       l_new_val4(l_tab_counter) := null;
6327       l_new_val5(l_tab_counter) := null;
6328       l_new_val6(l_tab_counter) := null;
6329   end if;
6330 
6331   if nvl(p_old_rec.registration_id,'$$$$$') <> nvl(p_new_rec.registration_id,'$$$$$') then
6332       l_tab_counter := l_tab_counter + 1;
6333       l_chg_evt_tab(l_tab_counter) := 'CREGID';
6334       l_prmtr_01_tab(l_tab_counter) := null;
6335       l_prmtr_02_tab(l_tab_counter) := null;
6336       l_prmtr_03_tab(l_tab_counter) := null;
6337       l_prmtr_04_tab(l_tab_counter) := null;
6338       l_prmtr_05_tab(l_tab_counter) := null;
6339       l_prmtr_06_tab(l_tab_counter) := null;
6340       l_prmtr_07_tab(l_tab_counter) := null;
6341       l_old_val1(l_tab_counter) := p_old_rec.registration_id;
6342       l_new_val1(l_tab_counter) := p_new_rec.registration_id;
6343       l_old_val2(l_tab_counter) := null;
6344       l_old_val3(l_tab_counter) := null;
6345       l_old_val4(l_tab_counter) := null;
6346       l_old_val5(l_tab_counter) := null;
6347       l_old_val6(l_tab_counter) := null;
6348       l_new_val2(l_tab_counter) := null;
6349       l_new_val3(l_tab_counter) := null;
6350       l_new_val4(l_tab_counter) := null;
6351       l_new_val5(l_tab_counter) := null;
6352       l_new_val6(l_tab_counter) := null;
6353   end if;
6354 
6355   if nvl(p_old_rec.registration_date,to_date('01/01/0001', 'dd/mm/yyyy')) <> nvl(p_new_rec.registration_date,to_date('01/01/0001', 'dd/mm/yyyy')) then
6356       l_tab_counter := l_tab_counter + 1;
6357       l_chg_evt_tab(l_tab_counter) := 'CREGDT';
6358       l_prmtr_01_tab(l_tab_counter) := null;
6359       l_prmtr_02_tab(l_tab_counter) := null;
6360       l_prmtr_03_tab(l_tab_counter) := null;
6361       l_prmtr_04_tab(l_tab_counter) := null;
6362       l_prmtr_05_tab(l_tab_counter) := null;
6363       l_prmtr_06_tab(l_tab_counter) := null;
6364       l_prmtr_07_tab(l_tab_counter) := null;
6365       l_old_val1(l_tab_counter) := p_old_rec.registration_date;
6366       l_new_val1(l_tab_counter) := p_new_rec.registration_date;
6367       l_old_val2(l_tab_counter) := null;
6368       l_old_val3(l_tab_counter) := null;
6369       l_old_val4(l_tab_counter) := null;
6370       l_old_val5(l_tab_counter) := null;
6371       l_old_val6(l_tab_counter) := null;
6372       l_new_val2(l_tab_counter) := null;
6373       l_new_val3(l_tab_counter) := null;
6374       l_new_val4(l_tab_counter) := null;
6375       l_new_val5(l_tab_counter) := null;
6376       l_new_val6(l_tab_counter) := null;
6377   end if;
6378 
6379   if nvl(p_old_rec.registration_exp_date,to_date('01/01/0001', 'dd/mm/yyyy')) <> nvl(p_new_rec.registration_exp_date,to_date('01/01/0001', 'dd/mm/yyyy')) then
6380       l_tab_counter := l_tab_counter + 1;
6381       l_chg_evt_tab(l_tab_counter) := 'CREGEXPDT';
6382       l_prmtr_01_tab(l_tab_counter) := null;
6383       l_prmtr_02_tab(l_tab_counter) := null;
6384       l_prmtr_03_tab(l_tab_counter) := null;
6385       l_prmtr_04_tab(l_tab_counter) := null;
6386       l_prmtr_05_tab(l_tab_counter) := null;
6387       l_prmtr_06_tab(l_tab_counter) := null;
6388       l_prmtr_07_tab(l_tab_counter) := null;
6389       l_old_val1(l_tab_counter) := p_old_rec.registration_exp_date;
6390       l_new_val1(l_tab_counter) := p_new_rec.registration_exp_date;
6391       l_old_val2(l_tab_counter) := null;
6392       l_old_val3(l_tab_counter) := null;
6393       l_old_val4(l_tab_counter) := null;
6394       l_old_val5(l_tab_counter) := null;
6395       l_old_val6(l_tab_counter) := null;
6396       l_new_val2(l_tab_counter) := null;
6397       l_new_val3(l_tab_counter) := null;
6398       l_new_val4(l_tab_counter) := null;
6399       l_new_val5(l_tab_counter) := null;
6400       l_new_val6(l_tab_counter) := null;
6401   end if;
6402 
6403   if nvl(p_old_rec.categoryname,'$$$$$') <> nvl(p_new_rec.categoryname,'$$$$$') then
6404        -- read category name from lookup table
6405       open c_lookup_value('DISABILITY_CATEGORY', p_old_rec.categoryname);
6406       fetch c_lookup_value into l_old_categoryname;
6407       close c_lookup_value;
6408       open c_lookup_value('DISABILITY_CATEGORY', p_new_rec.categoryname);
6409       fetch c_lookup_value into l_new_categoryname;
6410       close c_lookup_value;
6411       l_tab_counter := l_tab_counter + 1;
6412       l_chg_evt_tab(l_tab_counter) := 'CDISCAT';
6413       l_prmtr_01_tab(l_tab_counter) := null;
6414       l_prmtr_02_tab(l_tab_counter) := null;
6415       l_prmtr_03_tab(l_tab_counter) := null;
6416       l_prmtr_04_tab(l_tab_counter) := null;
6417       l_prmtr_05_tab(l_tab_counter) := null;
6418       l_prmtr_06_tab(l_tab_counter) := null;
6419       l_prmtr_07_tab(l_tab_counter) := null;
6420       l_old_val1(l_tab_counter) := l_old_categoryname ;
6421       l_new_val1(l_tab_counter) := l_new_categoryname;
6422       l_old_val2(l_tab_counter) := null;
6423       l_old_val3(l_tab_counter) := null;
6424       l_old_val4(l_tab_counter) := null;
6425       l_old_val5(l_tab_counter) := null;
6426       l_old_val6(l_tab_counter) := null;
6427       l_new_val2(l_tab_counter) := null;
6428       l_new_val3(l_tab_counter) := null;
6429       l_new_val4(l_tab_counter) := null;
6430       l_new_val5(l_tab_counter) := null;
6431       l_new_val6(l_tab_counter) := null;
6432   end if;
6433 
6434   if nvl(p_old_rec.description,'$$$$$') <> nvl(p_new_rec.description,'$$$$$') then
6435       l_tab_counter := l_tab_counter + 1;
6436       l_chg_evt_tab(l_tab_counter) := 'CDESC';
6437       l_prmtr_01_tab(l_tab_counter) := null;
6438       l_prmtr_02_tab(l_tab_counter) := null;
6439       l_prmtr_03_tab(l_tab_counter) := null;
6440       l_prmtr_04_tab(l_tab_counter) := null;
6441       l_prmtr_05_tab(l_tab_counter) := null;
6442       l_prmtr_06_tab(l_tab_counter) := null;
6443       l_prmtr_07_tab(l_tab_counter) := null;
6444       l_old_val1(l_tab_counter) := p_old_rec.description;
6445       l_new_val1(l_tab_counter) := p_new_rec.description;
6446       l_old_val2(l_tab_counter) := null;
6447       l_old_val3(l_tab_counter) := null;
6448       l_old_val4(l_tab_counter) := null;
6449       l_old_val5(l_tab_counter) := null;
6450       l_old_val6(l_tab_counter) := null;
6451       l_new_val2(l_tab_counter) := null;
6452       l_new_val3(l_tab_counter) := null;
6453       l_new_val4(l_tab_counter) := null;
6454       l_new_val5(l_tab_counter) := null;
6455       l_new_val6(l_tab_counter) := null;
6456   end if;
6457 
6458   if nvl(p_old_rec.degree,1) <> nvl(p_new_rec.degree,1) then
6459       l_tab_counter := l_tab_counter + 1;
6460       l_chg_evt_tab(l_tab_counter) := 'CDEG';
6461       l_prmtr_01_tab(l_tab_counter) := null;
6462       l_prmtr_02_tab(l_tab_counter) := null;
6463       l_prmtr_03_tab(l_tab_counter) := null;
6464       l_prmtr_04_tab(l_tab_counter) := null;
6465       l_prmtr_05_tab(l_tab_counter) := null;
6466       l_prmtr_06_tab(l_tab_counter) := null;
6467       l_prmtr_07_tab(l_tab_counter) := null;
6468       l_old_val1(l_tab_counter) := p_old_rec.degree;
6469       l_new_val1(l_tab_counter) := p_new_rec.degree;
6470       l_old_val2(l_tab_counter) := null;
6471       l_old_val3(l_tab_counter) := null;
6472       l_old_val4(l_tab_counter) := null;
6473       l_old_val5(l_tab_counter) := null;
6474       l_old_val6(l_tab_counter) := null;
6475       l_new_val2(l_tab_counter) := null;
6476       l_new_val3(l_tab_counter) := null;
6477       l_new_val4(l_tab_counter) := null;
6478       l_new_val5(l_tab_counter) := null;
6479       l_new_val6(l_tab_counter) := null;
6480   end if;
6481 
6482   if nvl(p_old_rec.quota_fte,1) <> nvl(p_new_rec.quota_fte,1) then
6483       l_tab_counter := l_tab_counter + 1;
6484       l_chg_evt_tab(l_tab_counter) := 'CQTA';
6485       l_prmtr_01_tab(l_tab_counter) := null;
6486       l_prmtr_02_tab(l_tab_counter) := null;
6487       l_prmtr_03_tab(l_tab_counter) := null;
6488       l_prmtr_04_tab(l_tab_counter) := null;
6489       l_prmtr_05_tab(l_tab_counter) := null;
6490       l_prmtr_06_tab(l_tab_counter) := null;
6491       l_prmtr_07_tab(l_tab_counter) := null;
6492       l_old_val1(l_tab_counter) := p_old_rec.quota_fte;
6493       l_new_val1(l_tab_counter) := p_new_rec.quota_fte;
6494       l_old_val2(l_tab_counter) := null;
6495       l_old_val3(l_tab_counter) := null;
6496       l_old_val4(l_tab_counter) := null;
6497       l_old_val5(l_tab_counter) := null;
6498       l_old_val6(l_tab_counter) := null;
6499       l_new_val2(l_tab_counter) := null;
6500       l_new_val3(l_tab_counter) := null;
6501       l_new_val4(l_tab_counter) := null;
6502       l_new_val5(l_tab_counter) := null;
6503       l_new_val6(l_tab_counter) := null;
6504   end if;
6505 
6506   if nvl(p_old_rec.reason,'$$$$$') <> nvl(p_new_rec.reason,'$$$$$') then
6507        -- read reason from lookup table
6508       open c_lookup_value('DISABILITY_REASON', p_old_rec.reason);
6509       fetch c_lookup_value into l_old_reason;
6510       close c_lookup_value;
6511       open c_lookup_value('DISABILITY_REASON', p_new_rec.reason);
6512       fetch c_lookup_value into l_new_reason;
6513       close c_lookup_value;
6514       l_tab_counter := l_tab_counter + 1;
6515       l_chg_evt_tab(l_tab_counter) := 'CDISRSN';
6516       l_prmtr_01_tab(l_tab_counter) := null;
6517       l_prmtr_02_tab(l_tab_counter) := null;
6518       l_prmtr_03_tab(l_tab_counter) := null;
6519       l_prmtr_04_tab(l_tab_counter) := null;
6520       l_prmtr_05_tab(l_tab_counter) := null;
6521       l_prmtr_06_tab(l_tab_counter) := null;
6522       l_prmtr_07_tab(l_tab_counter) := null;
6523       l_old_val1(l_tab_counter) := l_old_reason;
6524       l_new_val1(l_tab_counter) := l_new_reason;
6525       l_old_val2(l_tab_counter) := null;
6526       l_old_val3(l_tab_counter) := null;
6527       l_old_val4(l_tab_counter) := null;
6528       l_old_val5(l_tab_counter) := null;
6529       l_old_val6(l_tab_counter) := null;
6530       l_new_val2(l_tab_counter) := null;
6531       l_new_val3(l_tab_counter) := null;
6532       l_new_val4(l_tab_counter) := null;
6533       l_new_val5(l_tab_counter) := null;
6534       l_new_val6(l_tab_counter) := null;
6535   end if;
6536 
6537   if nvl(p_old_rec.pre_registration_job,'$$$$$') <> nvl(p_new_rec.pre_registration_job,'$$$$$') then
6538       l_tab_counter := l_tab_counter + 1;
6539       l_chg_evt_tab(l_tab_counter) := 'CPRREGJOB';
6540       l_prmtr_01_tab(l_tab_counter) := null;
6541       l_prmtr_02_tab(l_tab_counter) := null;
6542       l_prmtr_03_tab(l_tab_counter) := null;
6543       l_prmtr_04_tab(l_tab_counter) := null;
6544       l_prmtr_05_tab(l_tab_counter) := null;
6545       l_prmtr_06_tab(l_tab_counter) := null;
6546       l_prmtr_07_tab(l_tab_counter) := null;
6547       l_old_val1(l_tab_counter) := p_old_rec.pre_registration_job;
6548       l_new_val1(l_tab_counter) := p_new_rec.pre_registration_job;
6549       l_old_val2(l_tab_counter) := null;
6550       l_old_val3(l_tab_counter) := null;
6551       l_old_val4(l_tab_counter) := null;
6552       l_old_val5(l_tab_counter) := null;
6553       l_old_val6(l_tab_counter) := null;
6554       l_new_val2(l_tab_counter) := null;
6555       l_new_val3(l_tab_counter) := null;
6556       l_new_val4(l_tab_counter) := null;
6557       l_new_val5(l_tab_counter) := null;
6558       l_new_val6(l_tab_counter) := null;
6559   end if;
6560 
6561   if nvl(p_old_rec.work_restriction,'$$$$$') <> nvl(p_new_rec.work_restriction,'$$$$$') then
6562       l_tab_counter := l_tab_counter + 1;
6563       l_chg_evt_tab(l_tab_counter) := 'CWRKRESTR';
6564       l_prmtr_01_tab(l_tab_counter) := null;
6565       l_prmtr_02_tab(l_tab_counter) := null;
6566       l_prmtr_03_tab(l_tab_counter) := null;
6567       l_prmtr_04_tab(l_tab_counter) := null;
6568       l_prmtr_05_tab(l_tab_counter) := null;
6569       l_prmtr_06_tab(l_tab_counter) := null;
6570       l_prmtr_07_tab(l_tab_counter) := null;
6571       l_old_val1(l_tab_counter) := p_old_rec.work_restriction;
6572       l_new_val1(l_tab_counter) := p_new_rec.work_restriction;
6573       l_old_val2(l_tab_counter) := null;
6574       l_old_val3(l_tab_counter) := null;
6575       l_old_val4(l_tab_counter) := null;
6576       l_old_val5(l_tab_counter) := null;
6577       l_old_val6(l_tab_counter) := null;
6578       l_new_val2(l_tab_counter) := null;
6579       l_new_val3(l_tab_counter) := null;
6580       l_new_val4(l_tab_counter) := null;
6581       l_new_val5(l_tab_counter) := null;
6582       l_new_val6(l_tab_counter) := null;
6583   end if;
6584 
6585 
6586 if nvl(p_old_rec.status,'$$$$$') <> nvl(p_new_rec.status,'$$$$$') then
6587       -- read status from lookup table
6588       open c_lookup_value('DISABILITY_STATUS', p_old_rec.status);
6589       fetch c_lookup_value into l_old_status;
6590       close c_lookup_value;
6591       open c_lookup_value('DISABILITY_STATUS', p_new_rec.status);
6592       fetch c_lookup_value into l_new_status;
6593       close c_lookup_value;
6594       l_tab_counter := l_tab_counter + 1;
6595       l_chg_evt_tab(l_tab_counter) := 'CODS';
6596       l_prmtr_01_tab(l_tab_counter) := null;
6597       l_prmtr_02_tab(l_tab_counter) := null;
6598       l_prmtr_03_tab(l_tab_counter) := null;
6599       l_prmtr_04_tab(l_tab_counter) := null;
6600       l_prmtr_05_tab(l_tab_counter) := null;
6601       l_prmtr_06_tab(l_tab_counter) := null;
6602       l_prmtr_07_tab(l_tab_counter) := null;
6603       l_old_val1(l_tab_counter) := l_old_status;
6604       l_new_val1(l_tab_counter) := l_new_status;
6605       l_old_val2(l_tab_counter) := null;
6606       l_old_val3(l_tab_counter) := null;
6607       l_old_val4(l_tab_counter) := null;
6608       l_old_val5(l_tab_counter) := null;
6609       l_old_val6(l_tab_counter) := null;
6610       l_new_val2(l_tab_counter) := null;
6611       l_new_val3(l_tab_counter) := null;
6612       l_new_val4(l_tab_counter) := null;
6613       l_new_val5(l_tab_counter) := null;
6614       l_new_val6(l_tab_counter) := null;
6615   end if;
6616 
6617   if nvl(p_old_rec.attribute1,'$$$$$') <> nvl(p_new_rec.attribute1,'$$$$$') then
6618       l_tab_counter := l_tab_counter + 1;
6619       l_chg_evt_tab(l_tab_counter) := 'CATTR1';
6620       l_prmtr_01_tab(l_tab_counter) := null;
6621       l_prmtr_02_tab(l_tab_counter) := null;
6622       l_prmtr_03_tab(l_tab_counter) := null;
6623       l_prmtr_04_tab(l_tab_counter) := null;
6624       l_prmtr_05_tab(l_tab_counter) := null;
6625       l_prmtr_06_tab(l_tab_counter) := null;
6626       l_prmtr_07_tab(l_tab_counter) := null;
6627       l_old_val1(l_tab_counter) := p_old_rec.attribute1;
6628       l_new_val1(l_tab_counter) := p_new_rec.attribute1;
6629       l_old_val2(l_tab_counter) := null;
6630       l_old_val3(l_tab_counter) := null;
6631       l_old_val4(l_tab_counter) := null;
6632       l_old_val5(l_tab_counter) := null;
6633       l_old_val6(l_tab_counter) := null;
6634       l_new_val2(l_tab_counter) := null;
6635       l_new_val3(l_tab_counter) := null;
6636       l_new_val4(l_tab_counter) := null;
6637       l_new_val5(l_tab_counter) := null;
6638       l_new_val6(l_tab_counter) := null;
6639   end if;
6640 
6641   if nvl(p_old_rec.attribute2,'$$$$$') <> nvl(p_new_rec.attribute2,'$$$$$') then
6642       l_tab_counter := l_tab_counter + 1;
6643       l_chg_evt_tab(l_tab_counter) := 'CATTR2';
6644       l_prmtr_01_tab(l_tab_counter) := null;
6645       l_prmtr_02_tab(l_tab_counter) := null;
6646       l_prmtr_03_tab(l_tab_counter) := null;
6647       l_prmtr_04_tab(l_tab_counter) := null;
6648       l_prmtr_05_tab(l_tab_counter) := null;
6649       l_prmtr_06_tab(l_tab_counter) := null;
6650       l_prmtr_07_tab(l_tab_counter) := null;
6651       l_old_val1(l_tab_counter) := p_old_rec.attribute2;
6652       l_new_val1(l_tab_counter) := p_new_rec.attribute2;
6653       l_old_val2(l_tab_counter) := null;
6654       l_old_val3(l_tab_counter) := null;
6655       l_old_val4(l_tab_counter) := null;
6656       l_old_val5(l_tab_counter) := null;
6657       l_old_val6(l_tab_counter) := null;
6658       l_new_val2(l_tab_counter) := null;
6659       l_new_val3(l_tab_counter) := null;
6660       l_new_val4(l_tab_counter) := null;
6661       l_new_val5(l_tab_counter) := null;
6662       l_new_val6(l_tab_counter) := null;
6663   end if;
6664 
6665   if nvl(p_old_rec.attribute3,'$$$$$') <> nvl(p_new_rec.attribute3,'$$$$$') then
6666       l_tab_counter := l_tab_counter + 1;
6667       l_chg_evt_tab(l_tab_counter) := 'CATTR3';
6668       l_prmtr_01_tab(l_tab_counter) := null;
6669       l_prmtr_02_tab(l_tab_counter) := null;
6670       l_prmtr_03_tab(l_tab_counter) := null;
6671       l_prmtr_04_tab(l_tab_counter) := null;
6672       l_prmtr_05_tab(l_tab_counter) := null;
6673       l_prmtr_06_tab(l_tab_counter) := null;
6674       l_prmtr_07_tab(l_tab_counter) := null;
6675       l_old_val1(l_tab_counter) := p_old_rec.attribute3;
6676       l_new_val1(l_tab_counter) := p_new_rec.attribute3;
6677       l_old_val2(l_tab_counter) := null;
6678       l_old_val3(l_tab_counter) := null;
6679       l_old_val4(l_tab_counter) := null;
6680       l_old_val5(l_tab_counter) := null;
6681       l_old_val6(l_tab_counter) := null;
6682       l_new_val2(l_tab_counter) := null;
6683       l_new_val3(l_tab_counter) := null;
6684       l_new_val4(l_tab_counter) := null;
6685       l_new_val5(l_tab_counter) := null;
6686       l_new_val6(l_tab_counter) := null;
6687   end if;
6688 
6689   if nvl(p_old_rec.attribute4,'$$$$$') <> nvl(p_new_rec.attribute4,'$$$$$') then
6690       l_tab_counter := l_tab_counter + 1;
6691       l_chg_evt_tab(l_tab_counter) := 'CATTR4';
6692       l_prmtr_01_tab(l_tab_counter) := null;
6693       l_prmtr_02_tab(l_tab_counter) := null;
6694       l_prmtr_03_tab(l_tab_counter) := null;
6695       l_prmtr_04_tab(l_tab_counter) := null;
6696       l_prmtr_05_tab(l_tab_counter) := null;
6697       l_prmtr_06_tab(l_tab_counter) := null;
6698       l_prmtr_07_tab(l_tab_counter) := null;
6699       l_old_val1(l_tab_counter) := p_old_rec.attribute4;
6700       l_new_val1(l_tab_counter) := p_new_rec.attribute4;
6701       l_old_val2(l_tab_counter) := null;
6702       l_old_val3(l_tab_counter) := null;
6703       l_old_val4(l_tab_counter) := null;
6704       l_old_val5(l_tab_counter) := null;
6705       l_old_val6(l_tab_counter) := null;
6706       l_new_val2(l_tab_counter) := null;
6707       l_new_val3(l_tab_counter) := null;
6708       l_new_val4(l_tab_counter) := null;
6709       l_new_val5(l_tab_counter) := null;
6710       l_new_val6(l_tab_counter) := null;
6711   end if;
6712 
6713   if nvl(p_old_rec.attribute5,'$$$$$') <> nvl(p_new_rec.attribute5,'$$$$$') then
6714       l_tab_counter := l_tab_counter + 1;
6715       l_chg_evt_tab(l_tab_counter) := 'CATTR5';
6716       l_prmtr_01_tab(l_tab_counter) := null;
6717       l_prmtr_02_tab(l_tab_counter) := null;
6718       l_prmtr_03_tab(l_tab_counter) := null;
6719       l_prmtr_04_tab(l_tab_counter) := null;
6720       l_prmtr_05_tab(l_tab_counter) := null;
6721       l_prmtr_06_tab(l_tab_counter) := null;
6722       l_prmtr_07_tab(l_tab_counter) := null;
6723       l_old_val1(l_tab_counter) := p_old_rec.attribute5;
6724       l_new_val1(l_tab_counter) := p_new_rec.attribute5;
6725       l_old_val2(l_tab_counter) := null;
6726       l_old_val3(l_tab_counter) := null;
6727       l_old_val4(l_tab_counter) := null;
6728       l_old_val5(l_tab_counter) := null;
6729       l_old_val6(l_tab_counter) := null;
6730       l_new_val2(l_tab_counter) := null;
6731       l_new_val3(l_tab_counter) := null;
6732       l_new_val4(l_tab_counter) := null;
6733       l_new_val5(l_tab_counter) := null;
6734       l_new_val6(l_tab_counter) := null;
6735   end if;
6736 
6737   if nvl(p_old_rec.attribute6,'$$$$$') <> nvl(p_new_rec.attribute6,'$$$$$') then
6738       l_tab_counter := l_tab_counter + 1;
6739       l_chg_evt_tab(l_tab_counter) := 'CATTR6';
6740       l_prmtr_01_tab(l_tab_counter) := null;
6741       l_prmtr_02_tab(l_tab_counter) := null;
6742       l_prmtr_03_tab(l_tab_counter) := null;
6743       l_prmtr_04_tab(l_tab_counter) := null;
6744       l_prmtr_05_tab(l_tab_counter) := null;
6745       l_prmtr_06_tab(l_tab_counter) := null;
6746       l_prmtr_07_tab(l_tab_counter) := null;
6747       l_old_val1(l_tab_counter) := p_old_rec.attribute6;
6748       l_new_val1(l_tab_counter) := p_new_rec.attribute6;
6749       l_old_val2(l_tab_counter) := null;
6750       l_old_val3(l_tab_counter) := null;
6751       l_old_val4(l_tab_counter) := null;
6752       l_old_val5(l_tab_counter) := null;
6753       l_old_val6(l_tab_counter) := null;
6754       l_new_val2(l_tab_counter) := null;
6755       l_new_val3(l_tab_counter) := null;
6756       l_new_val4(l_tab_counter) := null;
6757       l_new_val5(l_tab_counter) := null;
6758       l_new_val6(l_tab_counter) := null;
6759   end if;
6760 
6761   if nvl(p_old_rec.attribute7,'$$$$$') <> nvl(p_new_rec.attribute7,'$$$$$') then
6762       l_tab_counter := l_tab_counter + 1;
6763       l_chg_evt_tab(l_tab_counter) := 'CATTR7';
6764       l_prmtr_01_tab(l_tab_counter) := null;
6765       l_prmtr_02_tab(l_tab_counter) := null;
6766       l_prmtr_03_tab(l_tab_counter) := null;
6767       l_prmtr_04_tab(l_tab_counter) := null;
6768       l_prmtr_05_tab(l_tab_counter) := null;
6769       l_prmtr_06_tab(l_tab_counter) := null;
6770       l_prmtr_07_tab(l_tab_counter) := null;
6771       l_old_val1(l_tab_counter) := p_old_rec.attribute7;
6772       l_new_val1(l_tab_counter) := p_new_rec.attribute7;
6773       l_old_val2(l_tab_counter) := null;
6774       l_old_val3(l_tab_counter) := null;
6775       l_old_val4(l_tab_counter) := null;
6776       l_old_val5(l_tab_counter) := null;
6777       l_old_val6(l_tab_counter) := null;
6778       l_new_val2(l_tab_counter) := null;
6779       l_new_val3(l_tab_counter) := null;
6780       l_new_val4(l_tab_counter) := null;
6781       l_new_val5(l_tab_counter) := null;
6782       l_new_val6(l_tab_counter) := null;
6783   end if;
6784 
6785   if nvl(p_old_rec.attribute8,'$$$$$') <> nvl(p_new_rec.attribute8,'$$$$$') then
6786       l_tab_counter := l_tab_counter + 1;
6787       l_chg_evt_tab(l_tab_counter) := 'CATTR8';
6788       l_prmtr_01_tab(l_tab_counter) := null;
6789       l_prmtr_02_tab(l_tab_counter) := null;
6790       l_prmtr_03_tab(l_tab_counter) := null;
6791       l_prmtr_04_tab(l_tab_counter) := null;
6792       l_prmtr_05_tab(l_tab_counter) := null;
6793       l_prmtr_06_tab(l_tab_counter) := null;
6794       l_prmtr_07_tab(l_tab_counter) := null;
6795       l_old_val1(l_tab_counter) := p_old_rec.attribute8;
6796       l_new_val1(l_tab_counter) := p_new_rec.attribute8;
6797       l_old_val2(l_tab_counter) := null;
6798       l_old_val3(l_tab_counter) := null;
6799       l_old_val4(l_tab_counter) := null;
6800       l_old_val5(l_tab_counter) := null;
6801       l_old_val6(l_tab_counter) := null;
6802       l_new_val2(l_tab_counter) := null;
6803       l_new_val3(l_tab_counter) := null;
6804       l_new_val4(l_tab_counter) := null;
6805       l_new_val5(l_tab_counter) := null;
6806       l_new_val6(l_tab_counter) := null;
6807   end if;
6808 
6809   if nvl(p_old_rec.attribute9,'$$$$$') <> nvl(p_new_rec.attribute9,'$$$$$') then
6810       l_tab_counter := l_tab_counter + 1;
6811       l_chg_evt_tab(l_tab_counter) := 'CATTR9';
6812       l_prmtr_01_tab(l_tab_counter) := null;
6813       l_prmtr_02_tab(l_tab_counter) := null;
6814       l_prmtr_03_tab(l_tab_counter) := null;
6815       l_prmtr_04_tab(l_tab_counter) := null;
6816       l_prmtr_05_tab(l_tab_counter) := null;
6817       l_prmtr_06_tab(l_tab_counter) := null;
6818       l_prmtr_07_tab(l_tab_counter) := null;
6819       l_old_val1(l_tab_counter) := p_old_rec.attribute9;
6820       l_new_val1(l_tab_counter) := p_new_rec.attribute9;
6821       l_old_val2(l_tab_counter) := null;
6822       l_old_val3(l_tab_counter) := null;
6823       l_old_val4(l_tab_counter) := null;
6824       l_old_val5(l_tab_counter) := null;
6825       l_old_val6(l_tab_counter) := null;
6826       l_new_val2(l_tab_counter) := null;
6827       l_new_val3(l_tab_counter) := null;
6828       l_new_val4(l_tab_counter) := null;
6829       l_new_val5(l_tab_counter) := null;
6830       l_new_val6(l_tab_counter) := null;
6831   end if;
6832 
6833   if nvl(p_old_rec.attribute10,'$$$$$') <> nvl(p_new_rec.attribute10,'$$$$$') then
6834       l_tab_counter := l_tab_counter + 1;
6835       l_chg_evt_tab(l_tab_counter) := 'CATTR10';
6836       l_prmtr_01_tab(l_tab_counter) := null;
6837       l_prmtr_02_tab(l_tab_counter) := null;
6838       l_prmtr_03_tab(l_tab_counter) := null;
6839       l_prmtr_04_tab(l_tab_counter) := null;
6840       l_prmtr_05_tab(l_tab_counter) := null;
6841       l_prmtr_06_tab(l_tab_counter) := null;
6842       l_prmtr_07_tab(l_tab_counter) := null;
6843       l_old_val1(l_tab_counter) := p_old_rec.attribute10;
6844       l_new_val1(l_tab_counter) := p_new_rec.attribute10;
6845       l_old_val2(l_tab_counter) := null;
6846       l_old_val3(l_tab_counter) := null;
6847       l_old_val4(l_tab_counter) := null;
6848       l_old_val5(l_tab_counter) := null;
6849       l_old_val6(l_tab_counter) := null;
6850       l_new_val2(l_tab_counter) := null;
6851       l_new_val3(l_tab_counter) := null;
6852       l_new_val4(l_tab_counter) := null;
6853       l_new_val5(l_tab_counter) := null;
6854       l_new_val6(l_tab_counter) := null;
6855   end if;
6856 
6857     if nvl(p_old_rec.dis_information1,'$$$$$') <> nvl(p_new_rec.dis_information1,'$$$$$') then
6858       l_tab_counter := l_tab_counter + 1;
6859       l_chg_evt_tab(l_tab_counter) := 'CDISINF1';
6860       l_prmtr_01_tab(l_tab_counter) := null;
6861       l_prmtr_02_tab(l_tab_counter) := null;
6862       l_prmtr_03_tab(l_tab_counter) := null;
6863       l_prmtr_04_tab(l_tab_counter) := null;
6864       l_prmtr_05_tab(l_tab_counter) := null;
6865       l_prmtr_06_tab(l_tab_counter) := null;
6866       l_prmtr_07_tab(l_tab_counter) := null;
6867       l_old_val1(l_tab_counter) := p_old_rec.dis_information1;
6868       l_new_val1(l_tab_counter) := p_new_rec.dis_information1;
6869       l_old_val2(l_tab_counter) := null;
6870       l_old_val3(l_tab_counter) := null;
6871       l_old_val4(l_tab_counter) := null;
6872       l_old_val5(l_tab_counter) := null;
6873       l_old_val6(l_tab_counter) := null;
6874       l_new_val2(l_tab_counter) := null;
6875       l_new_val3(l_tab_counter) := null;
6876       l_new_val4(l_tab_counter) := null;
6877       l_new_val5(l_tab_counter) := null;
6878       l_new_val6(l_tab_counter) := null;
6879   end if;
6880 
6881   if nvl(p_old_rec.dis_information2,'$$$$$') <> nvl(p_new_rec.dis_information2,'$$$$$') then
6882       l_tab_counter := l_tab_counter + 1;
6883       l_chg_evt_tab(l_tab_counter) := 'CDISINF2';
6884       l_prmtr_01_tab(l_tab_counter) := null;
6885       l_prmtr_02_tab(l_tab_counter) := null;
6886       l_prmtr_03_tab(l_tab_counter) := null;
6887       l_prmtr_04_tab(l_tab_counter) := null;
6888       l_prmtr_05_tab(l_tab_counter) := null;
6889       l_prmtr_06_tab(l_tab_counter) := null;
6890       l_prmtr_07_tab(l_tab_counter) := null;
6891       l_old_val1(l_tab_counter) := p_old_rec.attribute2;
6892       l_new_val1(l_tab_counter) := p_new_rec.attribute2;
6893       l_old_val2(l_tab_counter) := null;
6894       l_old_val3(l_tab_counter) := null;
6895       l_old_val4(l_tab_counter) := null;
6896       l_old_val5(l_tab_counter) := null;
6897       l_old_val6(l_tab_counter) := null;
6898       l_new_val2(l_tab_counter) := null;
6899       l_new_val3(l_tab_counter) := null;
6900       l_new_val4(l_tab_counter) := null;
6901       l_new_val5(l_tab_counter) := null;
6902       l_new_val6(l_tab_counter) := null;
6903   end if;
6904 
6905   if nvl(p_old_rec.dis_information3,'$$$$$') <> nvl(p_new_rec.dis_information3,'$$$$$') then
6906       l_tab_counter := l_tab_counter + 1;
6907       l_chg_evt_tab(l_tab_counter) := 'CDISINF3';
6908       l_prmtr_01_tab(l_tab_counter) := null;
6909       l_prmtr_02_tab(l_tab_counter) := null;
6910       l_prmtr_03_tab(l_tab_counter) := null;
6911       l_prmtr_04_tab(l_tab_counter) := null;
6912       l_prmtr_05_tab(l_tab_counter) := null;
6913       l_prmtr_06_tab(l_tab_counter) := null;
6914       l_prmtr_07_tab(l_tab_counter) := null;
6915       l_old_val1(l_tab_counter) := p_old_rec.dis_information3;
6916       l_new_val1(l_tab_counter) := p_new_rec.dis_information3;
6917       l_old_val2(l_tab_counter) := null;
6918       l_old_val3(l_tab_counter) := null;
6919       l_old_val4(l_tab_counter) := null;
6920       l_old_val5(l_tab_counter) := null;
6921       l_old_val6(l_tab_counter) := null;
6922       l_new_val2(l_tab_counter) := null;
6923       l_new_val3(l_tab_counter) := null;
6924       l_new_val4(l_tab_counter) := null;
6925       l_new_val5(l_tab_counter) := null;
6926       l_new_val6(l_tab_counter) := null;
6927   end if;
6928 
6929   if nvl(p_old_rec.dis_information4,'$$$$$') <> nvl(p_new_rec.dis_information4,'$$$$$') then
6930       l_tab_counter := l_tab_counter + 1;
6931       l_chg_evt_tab(l_tab_counter) := 'CDISINF4';
6932       l_prmtr_01_tab(l_tab_counter) := null;
6933       l_prmtr_02_tab(l_tab_counter) := null;
6934       l_prmtr_03_tab(l_tab_counter) := null;
6935       l_prmtr_04_tab(l_tab_counter) := null;
6936       l_prmtr_05_tab(l_tab_counter) := null;
6937       l_prmtr_06_tab(l_tab_counter) := null;
6938       l_prmtr_07_tab(l_tab_counter) := null;
6939       l_old_val1(l_tab_counter) := p_old_rec.dis_information4;
6940       l_new_val1(l_tab_counter) := p_new_rec.dis_information4;
6941       l_old_val2(l_tab_counter) := null;
6942       l_old_val3(l_tab_counter) := null;
6943       l_old_val4(l_tab_counter) := null;
6944       l_old_val5(l_tab_counter) := null;
6945       l_old_val6(l_tab_counter) := null;
6946       l_new_val2(l_tab_counter) := null;
6947       l_new_val3(l_tab_counter) := null;
6948       l_new_val4(l_tab_counter) := null;
6949       l_new_val5(l_tab_counter) := null;
6950       l_new_val6(l_tab_counter) := null;
6951   end if;
6952 
6953   if nvl(p_old_rec.dis_information5,'$$$$$') <> nvl(p_new_rec.dis_information5,'$$$$$') then
6954       l_tab_counter := l_tab_counter + 1;
6955       l_chg_evt_tab(l_tab_counter) := 'CDISINF5';
6956       l_prmtr_01_tab(l_tab_counter) := null;
6957       l_prmtr_02_tab(l_tab_counter) := null;
6958       l_prmtr_03_tab(l_tab_counter) := null;
6959       l_prmtr_04_tab(l_tab_counter) := null;
6960       l_prmtr_05_tab(l_tab_counter) := null;
6961       l_prmtr_06_tab(l_tab_counter) := null;
6962       l_prmtr_07_tab(l_tab_counter) := null;
6963       l_old_val1(l_tab_counter) := p_old_rec.dis_information5;
6964       l_new_val1(l_tab_counter) := p_new_rec.dis_information5;
6965       l_old_val2(l_tab_counter) := null;
6966       l_old_val3(l_tab_counter) := null;
6967       l_old_val4(l_tab_counter) := null;
6968       l_old_val5(l_tab_counter) := null;
6969       l_old_val6(l_tab_counter) := null;
6970       l_new_val2(l_tab_counter) := null;
6971       l_new_val3(l_tab_counter) := null;
6972       l_new_val4(l_tab_counter) := null;
6973       l_new_val5(l_tab_counter) := null;
6974       l_new_val6(l_tab_counter) := null;
6975   end if;
6976 
6977   if nvl(p_old_rec.dis_information6,'$$$$$') <> nvl(p_new_rec.dis_information6,'$$$$$') then
6978       l_tab_counter := l_tab_counter + 1;
6979       l_chg_evt_tab(l_tab_counter) := 'CDISINF6';
6980       l_prmtr_01_tab(l_tab_counter) := null;
6981       l_prmtr_02_tab(l_tab_counter) := null;
6982       l_prmtr_03_tab(l_tab_counter) := null;
6983       l_prmtr_04_tab(l_tab_counter) := null;
6984       l_prmtr_05_tab(l_tab_counter) := null;
6985       l_prmtr_06_tab(l_tab_counter) := null;
6986       l_prmtr_07_tab(l_tab_counter) := null;
6987       l_old_val1(l_tab_counter) := p_old_rec.dis_information6;
6988       l_new_val1(l_tab_counter) := p_new_rec.dis_information6;
6989       l_old_val2(l_tab_counter) := null;
6990       l_old_val3(l_tab_counter) := null;
6991       l_old_val4(l_tab_counter) := null;
6992       l_old_val5(l_tab_counter) := null;
6993       l_old_val6(l_tab_counter) := null;
6994       l_new_val2(l_tab_counter) := null;
6995       l_new_val3(l_tab_counter) := null;
6996       l_new_val4(l_tab_counter) := null;
6997       l_new_val5(l_tab_counter) := null;
6998       l_new_val6(l_tab_counter) := null;
6999   end if;
7000 
7001   if nvl(p_old_rec.dis_information7,'$$$$$') <> nvl(p_new_rec.dis_information7,'$$$$$') then
7002       l_tab_counter := l_tab_counter + 1;
7003       l_chg_evt_tab(l_tab_counter) := 'CDISINF7';
7004       l_prmtr_01_tab(l_tab_counter) := null;
7005       l_prmtr_02_tab(l_tab_counter) := null;
7006       l_prmtr_03_tab(l_tab_counter) := null;
7007       l_prmtr_04_tab(l_tab_counter) := null;
7008       l_prmtr_05_tab(l_tab_counter) := null;
7009       l_prmtr_06_tab(l_tab_counter) := null;
7010       l_prmtr_07_tab(l_tab_counter) := null;
7011       l_old_val1(l_tab_counter) := p_old_rec.dis_information7;
7012       l_new_val1(l_tab_counter) := p_new_rec.dis_information7;
7013       l_old_val2(l_tab_counter) := null;
7014       l_old_val3(l_tab_counter) := null;
7015       l_old_val4(l_tab_counter) := null;
7016       l_old_val5(l_tab_counter) := null;
7017       l_old_val6(l_tab_counter) := null;
7018       l_new_val2(l_tab_counter) := null;
7019       l_new_val3(l_tab_counter) := null;
7020       l_new_val4(l_tab_counter) := null;
7021       l_new_val5(l_tab_counter) := null;
7022       l_new_val6(l_tab_counter) := null;
7023   end if;
7024 
7025   if nvl(p_old_rec.dis_information8,'$$$$$') <> nvl(p_new_rec.dis_information8,'$$$$$') then
7026       l_tab_counter := l_tab_counter + 1;
7027       l_chg_evt_tab(l_tab_counter) := 'CDISINF8';
7028       l_prmtr_01_tab(l_tab_counter) := null;
7029       l_prmtr_02_tab(l_tab_counter) := null;
7030       l_prmtr_03_tab(l_tab_counter) := null;
7031       l_prmtr_04_tab(l_tab_counter) := null;
7032       l_prmtr_05_tab(l_tab_counter) := null;
7033       l_prmtr_06_tab(l_tab_counter) := null;
7034       l_prmtr_07_tab(l_tab_counter) := null;
7035       l_old_val1(l_tab_counter) := p_old_rec.dis_information8;
7036       l_new_val1(l_tab_counter) := p_new_rec.dis_information8;
7037       l_old_val2(l_tab_counter) := null;
7038       l_old_val3(l_tab_counter) := null;
7039       l_old_val4(l_tab_counter) := null;
7040       l_old_val5(l_tab_counter) := null;
7041       l_old_val6(l_tab_counter) := null;
7042       l_new_val2(l_tab_counter) := null;
7043       l_new_val3(l_tab_counter) := null;
7044       l_new_val4(l_tab_counter) := null;
7045       l_new_val5(l_tab_counter) := null;
7046       l_new_val6(l_tab_counter) := null;
7047   end if;
7048 
7049   if nvl(p_old_rec.dis_information9,'$$$$$') <> nvl(p_new_rec.dis_information9,'$$$$$') then
7050       l_tab_counter := l_tab_counter + 1;
7051       l_chg_evt_tab(l_tab_counter) := 'CDISINF9';
7052       l_prmtr_01_tab(l_tab_counter) := null;
7053       l_prmtr_02_tab(l_tab_counter) := null;
7054       l_prmtr_03_tab(l_tab_counter) := null;
7055       l_prmtr_04_tab(l_tab_counter) := null;
7056       l_prmtr_05_tab(l_tab_counter) := null;
7057       l_prmtr_06_tab(l_tab_counter) := null;
7058       l_prmtr_07_tab(l_tab_counter) := null;
7059       l_old_val1(l_tab_counter) := p_old_rec.dis_information9;
7060       l_new_val1(l_tab_counter) := p_new_rec.dis_information9;
7061       l_old_val2(l_tab_counter) := null;
7062       l_old_val3(l_tab_counter) := null;
7063       l_old_val4(l_tab_counter) := null;
7064       l_old_val5(l_tab_counter) := null;
7065       l_old_val6(l_tab_counter) := null;
7066       l_new_val2(l_tab_counter) := null;
7067       l_new_val3(l_tab_counter) := null;
7068       l_new_val4(l_tab_counter) := null;
7069       l_new_val5(l_tab_counter) := null;
7070       l_new_val6(l_tab_counter) := null;
7071   end if;
7072 
7073   if nvl(p_old_rec.dis_information10,'$$$$$') <> nvl(p_new_rec.dis_information10,'$$$$$') then
7074       l_tab_counter := l_tab_counter + 1;
7075       l_chg_evt_tab(l_tab_counter) := 'CDISINF10';
7076       l_prmtr_01_tab(l_tab_counter) := null;
7077       l_prmtr_02_tab(l_tab_counter) := null;
7078       l_prmtr_03_tab(l_tab_counter) := null;
7079       l_prmtr_04_tab(l_tab_counter) := null;
7080       l_prmtr_05_tab(l_tab_counter) := null;
7081       l_prmtr_06_tab(l_tab_counter) := null;
7082       l_prmtr_07_tab(l_tab_counter) := null;
7083       l_old_val1(l_tab_counter) := p_old_rec.dis_information10;
7084       l_new_val1(l_tab_counter) := p_new_rec.dis_information10;
7085       l_old_val2(l_tab_counter) := null;
7086       l_old_val3(l_tab_counter) := null;
7087       l_old_val4(l_tab_counter) := null;
7088       l_old_val5(l_tab_counter) := null;
7089       l_old_val6(l_tab_counter) := null;
7090       l_new_val2(l_tab_counter) := null;
7091       l_new_val3(l_tab_counter) := null;
7092       l_new_val4(l_tab_counter) := null;
7093       l_new_val5(l_tab_counter) := null;
7094       l_new_val6(l_tab_counter) := null;
7095   end if;
7096 
7097  for l_count in 1..l_chg_evt_tab.count loop
7098    if change_event_is_enabled(l_chg_evt_tab(l_count),p_new_rec.effective_start_date) then
7099     ben_ext_chg_evt_api.create_ext_chg_evt
7100     (p_validate                    => FALSE
7101     ,p_ext_chg_evt_log_id          => l_ext_chg_evt_log_id
7102     ,p_chg_evt_cd                  => l_chg_evt_tab(l_count)
7103     ,p_chg_eff_dt                  => p_new_rec.effective_start_date
7104     ,p_prmtr_01                    => l_prmtr_01_tab(l_count)
7105     ,p_prmtr_02                    => l_prmtr_02_tab(l_count)
7106     ,p_prmtr_03                    => l_prmtr_03_tab(l_count)
7107     ,p_prmtr_04                    => l_prmtr_04_tab(l_count)
7108     ,p_prmtr_05                    => l_prmtr_05_tab(l_count)
7109     ,p_prmtr_06                    => l_prmtr_06_tab(l_count)
7110     ,p_prmtr_07                    => l_prmtr_07_tab(l_count)
7111     ,p_prmtr_10                    => p_new_rec.update_mode
7112     ,p_person_id                   => p_new_rec.person_id
7113     ,p_business_group_id           => p_new_rec.business_group_id
7114     ,p_object_version_number       => l_object_version_number
7115     ,p_effective_date              => p_new_rec.effective_start_date
7116     ,p_old_val1                    => l_old_val1(l_count)
7117     ,p_old_val2                    => l_old_val2(l_count)
7118     ,p_old_val3                    => l_old_val3(l_count)
7119     ,p_old_val4                    => l_old_val4(l_count)
7120     ,p_old_val5                    => l_old_val5(l_count)
7121     ,p_old_val6                    => l_old_val6(l_count)
7122     ,p_new_val1                    => l_new_val1(l_count)
7123     ,p_new_val2                    => l_new_val2(l_count)
7124     ,p_new_val3                    => l_new_val3(l_count)
7125     ,p_new_val4                    => l_new_val4(l_count)
7126     ,p_new_val5                    => l_new_val5(l_count)
7127     ,p_new_val6                    => l_new_val6(l_count)
7128     );
7129    end if;
7130   end loop;
7131   --
7132 
7133     ----
7134  end if;
7135 --
7136   hr_utility.set_location('Exiting:'|| l_proc, 99);
7137 --
7138 end log_per_dis_chg;
7139 --
7140 end ben_ext_chlg;