[Home] [Help]
PACKAGE BODY: APPS.BEN_RELATED_PERSON_LER_API
Source
1 Package Body ben_Related_person_ler_api as
2 /* $Header: benrllrb.pkb 120.1.12000000.2 2007/04/13 07:22:11 ssarkar noship $ */
3 --
4 -- Package Variables
5 --
6 g_package varchar2(33) := ' ben_related_person_ler_api.';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |------------------------< create_related_person_ler >----------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 procedure create_related_person_ler
13 (p_validate in boolean default false,
14 p_person_id in number,
15 p_ler_id in number,
16 p_effective_date in date,
17 p_business_group_id in number,
18 p_csd_by_ptnl_ler_for_per_id in number default null,
19 p_from_form in varchar2 default 'Y') is
20 --
21 -- Declare cursors and local variables
22 --
23 l_proc varchar2(72) := g_package||'create_related_person_ler';
24 l_env_rec ben_env_object.g_global_env_rec_type;
25 --
26 cursor le_exists(p_person_id in number
27 ,p_ler_id in number
28 ,p_lf_evt_ocrd_dt in date) is
29 select 'Y'
30 from ben_ptnl_ler_for_per
31 where person_id = p_person_id
32 and ler_id = p_ler_id
33 /* commenting for bug 5968595
34 and PTNL_LER_FOR_PER_STAT_CD <> 'VOIDD' /* Bug : 4624390 */
35 and lf_evt_ocrd_dt = p_lf_evt_ocrd_dt;
36 --
37 --
38 -- output variables from API call.
39 --
40 l_ptnl_ler_for_per_id ben_ptnl_ler_for_per.ptnl_ler_for_per_id%type;
41 l_object_version_number ben_ptnl_ler_for_per.object_version_number%type;
42 --
43 l_mnl_dt date;
44 l_dtctd_dt date;
45 l_procd_dt date;
46 l_unprocd_dt date;
47 l_voidd_dt date;
48 l_con_rec ben_person_object.g_cache_con_table;
49 l_css_rec ben_life_object.g_cache_css_table;
50 l_per_rec per_all_people_f%rowtype;
51 l_ler_rec ben_ler_f%rowtype;
52 l_done_yet boolean := false;
53 l_le_exists VARCHAR2(1);
54 --
55 begin
56 --
57 hr_utility.set_location('Entering:'|| l_proc, 10);
58 --
59 -- Operation
60 -- =========
61 -- 1) Get the active life events occured date, this is what we use to check
62 -- for existing contacts and life event causes life event rows.
63 -- 2) Look for changes causes life event rows, then look for persons contacts
64 --
65 ben_env_object.get(p_rec => l_env_rec);
66 --
67 ben_life_object.get_object(p_ler_id => p_ler_id,
68 p_rec => l_css_rec);
69 --
70 if l_css_rec.exists(1) then
71 --
72 for l_count2 in l_css_rec.first..l_css_rec.last loop
73 --
74 -- look for related persons
75 --
76 if not l_done_yet then
77 --
78 ben_person_object.get_object(p_person_id => p_person_id,
79 p_rec => l_con_rec);
80 --
81 l_done_yet := true;
82 --
83 end if;
84 --
85 if l_con_rec.exists(1) then
86 --
87 for l_count in l_con_rec.first..l_con_rec.last loop
88 --
89 hr_utility.set_location(' St Loop CONREC:'||l_proc, 70);
90 --
91 -- Since l_con_rec has all the contacts for the person, make sure to
92 -- select only contacts whose relationships have not been end dated.
93 --
94 if l_con_rec(l_count).personal_flag = 'Y' and
95 nvl(l_con_rec(l_count).date_end, hr_api.g_eot) >= p_effective_date
96 then
97 --
98 open le_exists(l_con_rec(l_count).contact_person_id,
99 l_css_rec(l_count2).rsltg_ler_id,
100 l_env_rec.lf_evt_ocrd_dt);
101 fetch le_exists into l_le_exists;
102 --
103 -- If an already existing life event of this
104 -- type exists do nothing.
105 --
106 if le_exists%notfound then
107 close le_exists;
108 ben_ptnl_ler_for_per_api.create_ptnl_ler_for_per
109 (p_validate => false,
110 p_effective_date => p_effective_date,
111 p_business_group_id => p_business_group_id,
112 p_person_id => l_con_rec(l_count).contact_person_id,
113 p_ler_id => l_css_rec(l_count2).rsltg_ler_id,
114 p_lf_evt_ocrd_dt => l_env_rec.lf_evt_ocrd_dt,
115 p_ptnl_ler_for_per_stat_cd => 'DTCTD',
116 p_ptnl_ler_for_per_src_cd => 'SYSGND',
117 p_ptnl_ler_for_per_id => l_ptnl_ler_for_per_id,
118 p_csd_by_ptnl_ler_for_per_id => p_csd_by_ptnl_ler_for_per_id,
119 p_object_version_number => l_object_version_number,
120 p_program_application_id => fnd_global.prog_appl_id,
121 p_program_id => fnd_global.conc_program_id,
122 p_request_id => fnd_global.conc_request_id,
123 p_program_update_date => sysdate,
124 p_ntfn_dt => trunc(sysdate),
125 p_dtctd_dt => p_effective_date);
126 --
127 hr_utility.set_location(' Done CREPPL:'||l_proc, 70);
128 if p_from_form = 'Y' then
129 --
130 null;
131 --
132 else
133 --
134 -- Write log message.
135 --
136 ben_person_object.get_object
137 (p_person_id => l_con_rec(l_count).contact_person_id,
138 p_rec => l_per_rec);
139 --
140 hr_utility.set_location(' Done PERGOBJ:'||l_proc, 70);
141 ben_life_object.get_object
142 (p_ler_id => l_css_rec(l_count2).rsltg_ler_id,
143 p_rec => l_ler_rec);
144 hr_utility.set_location(' Done LIFEGOBJ:'||l_proc, 70);
145 --
146 fnd_message.set_name('BEN','BEN_92110_RELATED_PERSON_LER');
147 fnd_message.set_token('NAME',l_per_rec.full_name);
148 fnd_message.set_token('LER',l_ler_rec.name);
149 benutils.write(p_text => fnd_message.get);
150 --
151 end if;
152 else
153 close le_exists;
154 end if;
155 --
156 end if;
157 --
158 hr_utility.set_location(' End Loop CONREC:'||l_proc, 70);
159 end loop;
160 --
161 end if;
162 --
163 end loop;
164 --
165 end if;
166 --
167 hr_utility.set_location(' Leaving:'||l_proc, 70);
168 --
169 end create_related_person_ler;
170 --
171 end ben_Related_person_ler_api;