[Home] [Help]
Skip to content
PACKAGE BODY: APPS.BEN_DETERMINE_ELIGIBILITY2
Source
1 package body ben_determine_eligibility2 as
2 /* $Header: bendete2.pkb 120.23 2011/12/14 11:01:34 usaraswa ship $ */
3 /*
4 +========================================================================+
5 | Copyright (c) 1997 Oracle Corporation |
6 | Redwood Shores, California, USA |
7 | All rights reserved. |
8 +========================================================================+
9 --
10 Name
11 Determine person eligibility
12 Purpose
13 This package is used to determine persons eligibility based on
14 elibility profiles or rules associated with any comp object.
15 History
16 Date Who Version What?
17 ---- --- ------- -----
18 15 Dec 97 U Datta 110.0 Created
19 23 Dec 97 U Datta 110.1 Added flags for ELIG_FOR_PGM_
20 FLAG, ELIG_FOR_PL_FLAG,
21 REF_PGM_ID.
22 05 Jan 98 U Datta 110.2 No changes.
23 14 Jan 98 lmcdonal 110.5 Added or ...%notfound is null.
24 Chg dec to DEC.
25 Move all close cursors to after
26 not found if/end if.
27 Remove extra close cursors.
28 Remove elig_for_pgm_flag,
29 elig_for_pl_flag, ref_pgm_id,
30 elig_prfl_id.
31 19 Jan 98 lmcdonal 110.6 Add real messages.
32 20 Jan 98 lmcdonal 110.7 Add concept of first-time elig/inelig.
33 Don't write to p_elig_per with oipl info.
34 Add order by to cursors w/rownum criteria.
35 Add eff dt to cursor w/assignment criteria.
36
37 Prtn Start Date changes:
38
39 AFDFM: was last_day(p_effective_date +
40 l_wait_perd_val)+1.
41 now last_day(p_effective_date) + 1
42 + l_wait_perd_val.
43 AFDPPSY:
44 was last_day(add_months
45 (to_date(l_yrp_start_date)
46 ,'DD-MON-YYYY'),6)) + 1
47 now add_months(l_yrp_start_date,6)
48 AFDCPPY: was trunc(to_date(l_yrp_start_date
49 ,'DD-MON-YYYY'),'MONTH')
50 now l_yrp_start_date
51 AFDFPPY: was to_date(l_yrp_start_date
52 ,'DD-MON-YYYY')
53 now l_yrp_start_date
54 ALDCPPSY: was last_day(add_months
55 (l_yrp_start_date,6))
56 now (add_months
57 (l_yrp_start_date,6)- 1)
58 Add 'ATFDFPP' code to pl/pgm section of code
59 AFDPPSY: was add_months(l_yrp_start_date,6)
60 now it's conditional.
61
62 Prtn End Date changes:
63
64 ALDCPP: was last_day(l_pay_period_end_date)
65 now l_pay_period_end_date
66 ALDCPPY: was last_day(l_yrp_end_date)
67 now l_yrp_end_date
68
69 If the pay period doesn't exist and the strt
70 or end date is based on pp criteria, error
71 If the popl yr doesn't exist and the strt or
72 end date is based on plan yr criteria, error
73
74 Add more real messages.
75 Chg 'DEC' references to '12', MON-YYYY to
76 MM-RRRR.
77
78 Remove c_track_inelig_flg, use global.
79 Move checking of this global before
80 all the computation of strt and end
81 dates.
82
83 Add c_get_elig_id columns to
84 c_prev_opt_elig_check.
85 Remove ben_opt_f, ben_pl_f from
86 c_prev_opt_elig_check. Add eff dts
87 Add proc get_start_end_dates by
88 stripping code from check_prev_elig
89 Newly elig does update, not insert.
90 First Elig records have start date.
91 Newly Elig recs start date
92 Unless there is an 'overlapping' past rec:
93 Newly inelig recs update (corr) old rec
94 with computed end date, then update
95 record with start date = end date +1.
96 Newly elig recs update (corr) old rec
97 with computed (strt date-1), then update
98 record with computed start date.
99
100 First inelig have end date +1 in
101 start date
102 24 Jan 98 lmcdonal 110.8 Add opt_id back into c_elig_per_opt.
103 Add order by to c_opt_next_popl_yr.
104 24 Jan 98 lmcdonal 110.9 Add set_name before all raise
105 g_record_error.
106 Remove strt, end dt RL processing.
107 03 Feb 98 lmcdonal 110.10 Remove 'when other's in exception.
108 06 Mar 98 gperry 110.11 Removed certain cursors so code
109 now uses global structures. Other
110 general tidying up of code.
111 08 Apr 98 gperry 110.12 Added output string info for
112 improvements to the log.
113 26 May 98 thayden 110.13 Chg AFDPPSY to AFDFPPSY.
114 27 May 98 gperry 110.14 Added calls to formula cover
115 routine.
116 06 Jun 98 jmohapat 110.15 Added call to deenroll for newly ineligible
117 07 Jun 98 jmohapatra 110.16 procedure name changed to
118 ben_newly_ineligible.main
119 10 Jun 98 lmcdonal 110.17 made header line after create line.
120 12 Jun 98 gperry 110.18 Fixed update modes so we can
121 handle update_overrides.
122 14 Jun 98 gperry 110.19 Fixed log messages.
123 07 Jul 98 jmohapat 110.20 Added batch who cols to call of
124 apis like(ben_elig_person_option_api.
125 create_elig_person_option and update,
126 ben_eligibile_person_api.create_eligible
127 _person and update)
128 23 Jul 98 thayden 110.21 Added Inelg rsn cd.
129 23 Oct 98 gperry 115.11 Added in extra call to
130 ben_newly_ineligible to handle
131 plans as well as programs.
132 26 Oct 98 gperry 115.12 Corrected ben_elig_per_f so
133 pgm_id is populated if pl_id has
134 a program parent.
135 23 Nov 98 gperry 115.13 Supports new columns for
136 ben_elig_per_f and
137 ben_elig_per_opt_f
138 23 Nov 98 gperry 115.14 Added inelg_rsn_cd.
139 02 Jan 99 gperry 115.15 Made trk inelig per flag work.
140 18 Jan 99 G Perry 115.16 LED V ED
141 25 Jan 99 G Perry 115.17 Fixed first time inelig case
142 for options.
143 17 Feb 99 G Perry 115.18 Added once_r_cntug_cd to insert
144 and update of elig_per and
145 elig_per_opt.
146 25 Feb 99 G Perry 115.19 Converted get_start_end_dates
147 to use generic call to
148 ben_determine_date.main.
149 09 Mar 99 G Perry 115.20 IS to AS.
150 03 May 99 S Das 115.23 Added parameters to genutils.formula.
151 04 May 99 S Das 115.24 Added jurisdiction code.
152 05 May 99 G Perry 115.25 Changed code to use
153 ben_comp_object routine.
154 ben_elig_object routine.
155 Both routines use hashed indexes.
156 06 May 99 G Perry 115.26 Added call to ben_comp_object
157 that was missed in last arcs in.
158 06 May 99 jcarpent 115.27 Fork of 115.19 to change cache
159 06 May 99 jcarpent 115.28 Same as 115.26
160 14 May 99 bbulusu 115.29 Added waiting period logic in check_prev_el.
161 Added function get_prtn_st_dt_aftr_wtg.
162 14 May 99 G Perry 115.30 Added support for PLIP and PTIP.
163 14 Jun 99 T Mathers 115.31 Changed to_dates to be NLS compliant
164 17 Jun 99 bbulusu 115.32 Added wait_perd_cmpltn_dt to the Elig per
165 and elig per opt apis. Added hr_api.g_sot.
166 23 Jun 99 G Perry 115.33 performance fixes and fixed balas spurious
167 use of dates.
168 28 Jun 99 jcarpent 115.34 Added per_in_ler_id to elig_per api call.
169 and added p_per_in_ler_id to check_prev_elg
170 08 Jul 99 maagrawa 115.35 Modified c_ptnl_le cursor to look for
171 non-voided potentials (Bug 2698).
172 11 Jul 99 mhoyes 115.36 - Added new trace messages.
173 - Removed + 0s from all cursors.
174 12 Jul 99 jcarpent 115.37 - Added checks for backed out nocopy pil.
175 13 Jul 99 mhoyes 115.38 - Added trace messages.
176 20-JUL-99 Gperry 115.39 genutils -> benutils package rename.
177 28-JUL-99 mhoyes 115.40 - Added trace messages.
178 - Removed product join from cursor
179 c_prev_elig_check.
180 03-AUG-99 jcarpent 115.41 - changed prev_elig_check cursor to
181 weed out nocopy backed out nocopy pils.
182 10-AUG-99 Gperry 115.42 Removed references to g_cache_person.
183 Fix all date formula calls to use
184 fnd_date.canonical_to_date.
185 19-AUG-99 Shdas 115.43 Added pl_ordr_num,plip_ordr_num,ptip_ordr_num
186 in create_eligible_person and oipl_ordr_num
187 in create_elig_person_option.
188 GPerry Added call to get benefits assignment if no
189 employee assignment is found.
190 17-SEP-99 pbodla 115.44 Bug 2551 fixes. Code reshuffled see comments
191 01-OCT-99 gperry 115.45 Backport of 115.42 with Eligibility fixed.
192 Now still elig records
193 get created even though eligibility hasn't
194 changed.
195 04-OCT-99 gperry 115.46 Leapfrog of 115.44 with Eligibility fixed.
196 03-NOV-99 mhoyes 115.47 - Added eligibility transition state.
197 OUT NOCOPY parameters to check_prev_elig.
198 - Added new logic to flag when a non tracked
199 first time in-eligible occurs. This is only
200 stored and passed as an OUT NOCOPY parameter. No
201 elig per is written.
202 - Passed p_override_validation to EPO and PEP
203 APIs to bypass insert_validate validation.
204 This doubles the execution speed of these
205 two APIs.
206 12-NOV-99 mhoyes 115.48 - Added new trace messages.
207 12-NOV-99 stee 115.49 - Added business_group_id parameter to some
208 of the calls to ben_determine_date
209 procedure.
210 10-JAN-00 stee 115.50 - Get per_in_ler info in get_start_end_dates
211 procedure for date calculations.
212 WWBUG:1096812
213 11-Feb-00 jcarpent 115.51 - Use db mode globals.
214 - pass pgm_id to beninelg
215 21-FEB-00 tguy 115.52 Fixed heirarchy in get_start_end_dates
216 procedure to walk down levels of comp obj
217 wwbugs: 1161304,1161305,1183241,1167918
218 23-Feb-00 lmcdonal 115.53 Bug 1167918: Only inherit plip, ptip, pgm
219 if plan/oipl is in a program. And if plan
220 is in pgm, look for plip before pl.
221 Get ptip inheritance to work.
222 24-Feb-00 jcarpent 115.54 - same as 115.51
223 24-Feb-00 jcarpent 115.55 - Don't call beninelg unless have oipl, pl,
224 or pgm. - patch of 115.51
225 24-Feb-00 jcarpent 115.56 - Leapfrog. same fix as above to 115.53.
226 26-Feb-00 mhoyes 115.57 - Added p_comp_obj_tree_row to
227 check_prev_elig and passed into
228 derive_rates_and_factors.
229 03-Mar-00 mhoyes 115.58 - Passed p_comp_obj_tree_row into
230 ben_det_wait_perd_cmpltn.main.
231 03-Mar-00 mhoyes 115.59 - Phased out nocopy ben_env_object.
232 07-Mar-00 gperry 115.60 Fixed trk_inelig_per_flag for PTIP and PLIP.
233 31-Mar-00 gperry 115.61 Added oiplip support hangs off plip.
234 03-Apr-00 mmogel 115.62 - Added tokens to message calls to make
235 messages more meaningful to the user
236 07-Apr-00 gperry 115.63 If person fails waiting period make them
237 ineligible for the object.
238 WWBUG 1230645, previously it errored rec.
239 15-Mar-00 mhoyes 115.64 - Modified calls to create_Eligible_Person to
240 create_perf_Eligible_Person.
241 - Re-referenced and cleared junk from get
242 start and end dates.
243 - Modified calls to
244 create_Elig_Person_Option to
245 create_perf_Elig_Person_Option.
246 22-May-00 mhoyes 115.65 - Replaced benutils function call to get the
247 per in ler with a cache call.
248 22-May-00 mhoyes 115.66 - Reduced cache calls in get start and end
249 dates by using passed in records.
250 23-May-00 shdas 115.67 - bug5224 call ben_newly_inelig.main if inelig for
251 plip and ptip.
252 24-May-00 mhoyes 115.68 - Tuned check_prev_elig cursors.
253 02-Jun-00 mhoyes 115.70 - Re-instated 115.68.
254 28-Jun-00 mhoyes 115.71 - Passed current row information into waiting
255 periods.
256 - Cached eligibility cursors.
257 30-Jun-00 mhoyes 115.72 - Passed in context parameters into bendrpar.
258 13-Jul-00 mhoyes 115.73 - Removed context parameters.
259 04-Aug-00 jcarpent 115.74 - 5412. Don't reset override fields
260 when doing an update.
261 14-Sep-00 mhoyes 115.75 - Removed highly executed hr_utility.set_location
262 statements.
263 02-Oct-00 pbodla 115.76 - Bugs : 1412882, part of bug 1412951
264 When elig per or opt rows are created they
265 should be created as of least of p_effective_date
266 and p_lf_evt_ocrd_dt
267 06-Oct-00 pbodla 115.77 - Above fix caused problem for selection and
268 temporal mode of benmngle run : due to null
269 passed to effective_date while pep/epo
270 api's are called. So put a nvl around
271 p_lf_evt_ocrd_dt.
272 29-Nov-00 Tmathers 115.78 - Fixed Invalid cursor error, wwbug
273 - 1517275, caused by having a Temporal
274 - LE created by BENDRPAR then re-closing
275 - already closed cursor.
276 15-Dec-00 rchase 115.79 - Bug 1531030. p_comp_rec and p_oiplip_rec
277 were not being refreshed with updated info.
278 01-May-01 mhoyes 115.80 - Pointed c_prev_oiplip_elig_check to the
279 EPO cache.
280 18-Jul-01 kmahendr 115.81 - Bug#1871579-Effective date is passed as least of
281 p_effective_date or lf_evt_ocrd_dt to cursors in
282 check_prv_eligibility
283 01-Aug-01 kmahendr 115.82 - Plan not in programs not getting deenrolled on selection
284 mode-bug#1871579. nvl is used to return effective date
285 for least function in 3 places where it was not there before
286 27-aug-01 tilak 115.83 bug:1949361 jurisdiction code is
287 derived inside benutils.formula.
288 26-sep-01 tjesumic 115.84 wait_perd_Strt_dt added
289 19-dec-01 pbodla 115.85 CWB Changes - Look for non comp potential
290 life events when waiting periods are defined.
291 20-Dec-01 ikasire 115.86 added dbdrv lines
292 07-Jan-02 Rpillay 115.87 Added Set Verify Off.
293 11-Mar-02 mhoyes 115.88 Dependent eligibility tuning.
294 12-Mar-02 pbodla 115.89 Bug 2284417 : Do not update the per in ler id
295 with new per in ler id as this peice of
296 row should belong to previous per in ler.
297 Next update will update the per in ler id as
298 well as new prtn strt dt.
299 12-Jul-02 mhoyes 115.90 - Added calls to get_curroiplippep_dets and
300 get_currplnpep_dets.
301 20-Aug-02 mhoyes 115.91 - Populated comp object list row eligible values.
302 12-Oct-02 ikasire 115.92 - Bug 2551834 fixed the codes ALDCPPSY and ALDCPPY
303 in get_start_and_end_dates procedure
304 29-Jan-03 kmahendr 115.93 - In P mode participation start date and end date are
305 defaulted to Event and 1 day before event
306 10-feb-03 hnarayan 115.94 - Added NOCOPY Changes
307 11-Mar-03 rpillay 115.95 - Bug 2806554 - Changed default for
308 Participation End Date Code from AEOT to
309 ODBED
310 17-Mar-03 vsethi 115.96 - Bug 2650247 - populating the value of inelg_rsn_cd
311 in p_comp_obj_tree_row record.
312 07-Apr-03 mmudigon 115.97 - Bug#2841136-Effective date is passed as
313 least of p_effective_date or lf_evt_ocrd_dt
314 to calls to ben_pep_cache.
315 Corrected typo in determining DT Track mode
316 for updating OIPLIP.
317 24-Jun-03 hnarayan 115.98 - Bug 3001411 - changed cursor c_ptnl_le to
318 ignore LEs of type SCHEDDU, ABS, COMP and GSP
319 becos the presence of these LE shud not make a
320 person ineligible in case of waiting period setup.
321 02-Sep-03 rpgupta 115.99 - Bug 3111613 - if cache does'nt return any
322 elig_per_id, raise an error
323 18-Sep-03 mhoyes 115.100 - Phased in calls to ben_pep_cache1 rather than
324 ben_pep_cache.
325 19 Sep 03 mhoyes 115.101 - 3150329 - Update eligibility APIs.
326 26 Sep 03 mhoyes 115.102 - More update eligibility APIs.
327 21 Jan 04 ikasire 115.103 BUG 3327841 - fixed the wrong assignment of epo
328 data to pep. Also calling clear_down_cache
329 to get the right data.
330 02 Feb 04 ikasire 115.104 BUG 3327841 Using the ben_pep_cache1.get_currplnpep_dets
331 to get the current pep info instread of depending on
332 ben_pep_cache.get_pilepo_dets
333 30 Mar 04 ikasire 115.105 fonm changes.
334 15 Apr 04 ikasire 115.106 Bug 3550789 added a new procedure save_to_restore
335 to save the PEP EPO data in certain cases when
336 we loose the data and can't restore as part of
337 reprocess
338 1 June 04 kmahendr 115.108 removed assignment of prtn_strt_dt in fonm
339 mode per prasad
340 4 June 04 rpgupta 115.109 3597303 - Make person eligible even if a ptnl
341 LE exists before the waiting period end
342 28-Sep-04 abparekh 115.110 iRec : Modified procedure check_prev_elig
343 Modified cursor c_prev_elig_check and
344 c_prev_opt_elig_check in check_prev_elig
345 28-Mar-05 ikasire 115.111 Bug 4241413 fix for the data type of
346 wait_perd_cmpltn_dt
347 26-Apr-05 mmudigon 115.112 Score and Weight
348 17-Jun-05 abparekh 115.113 Bug 4438430 : Pass PER_IN_LER_ID while creating
349 ESW record
350 12-jan-05 ssarkar 115.114 Bug 4947426 : passed l_effective_dt to update_perf_Eligible_Person
351 23-Jan-06 kmahendr 115.115 Bug#4960082 - newly_ineligible process is
352 added to still_ineligible condition
353 27-Jan-06 mhoyes 115.116 Bug#4968123 - hr_utility debug and locally
354 defined plsql tuning.
355 30-Jan-06 mhoyes 115.117 Bug#4968123 - moved out locall defined procs
356 to ben_determine_eligibility3.
357 30-Jan-06 mhoyes 115.118 Bug#4968123 - moved out cursors
358 to ben_determine_eligibility4.
359 28-Jun-06 swjain 115.119 Bug 5331889 Added person_id param in call to
360 benutils.formula in procedure get_start_end_dates
361 24-Jul-06 kmahendr 115.120 Bug#5404392-added ben_newly_ineligible call
362 in the case of first time ineligible.
363 25-aug-06 ssarkar 115.121 bug# 5478994 - passed ler_id to update_perf_eligible_person
364 11-Dec-06 rgajula 115.122 Bug 5682845 - passed the l_envplipid to the call to ben_pep_Cache.get_pilepo_dets.
365 07-Feb-07 kmahendr 115.124 Fidelity Enh to update inelig rows and
366 reversed fix made for 5682845
367 08-Feb-07 kmahendr 115.125 Reversed the condition to update inelig rows
368 16-Feb-07 rtagarra 115.126 ICM Changes.
369 12-jun-07 rtagarra 115.127 ICM: Bug 6038232. Also incorporated changes of Bug 6000303 : Defer Deenrollment ENH
370 on 04-Dec-07 from branchline.
371 23-Jan-2008 sallumwa 115.128 Bug 6601884 : For still ineligible records, when ineligibility is to be tracked,
372 the records should be updated with correct datetrack mode for both ben_elig_per_f
373 and ben_elig_per_opt_f.
374 12-Jan-2009 krupani 120.17.12010000.1 Forward ported fix of 11i bug 8542643
375 31-Oct-09 velvanop 120.17.12010000.2 Bug 9081414: Fwd port of Bug 9020962 : If future eligibility record exists for the previous per_in_ler_id, then insert the future eligiblity record
376 in backup table ben_le_clsn_n_rstr
377 16-Aug-10 krupani 120.17.12010000.4 Bug 10029253 - 12.1 forward port of 9789915 : In still-ineligible case,
378 p_still_inelig was not getting set. Fixed the same.
379 30-Aug-10 velvanop 120.17.12010000.5 Bug 10030441; If a Life Event is processed after the waiting period completion date
380 for a plan, then set the l_wait_perd_cmpltn_dt to null. Since participant has satisfied the
381 waiting period, there is no need to determine the participation start date code after the l_wait_perd_cmpltn_dt
382 19-Sep-11 usaraswa 120.17.12010000.6 Bug 12964414: If the unrestricted Le is pocessed in a future date and if we run a concurrent request of mode = 'S'
383 on present date then prtn_strt_dt of the eligibility record created in ben_elig_per_f and
384 ben_elig_per_opt_f should be the date on which concurrent request is run.
385 14-dec-11 usaraswa 120.17.12010000.7 Bug 12732878: If future eligibility record exists for the previous per_in_ler_id for oipl and oiplip comp object, then insert
386 the future eligiblity record in to backup table ben_le_clsn_n_rstr
387 --------------------------------------------------------------------------------
388 */
389 --
390 -- -----------------------------------------------------------------------------
391 -- |----------------------< get_start_end_dates >------------------------------|
392 -- -----------------------------------------------------------------------------
393 --
394 procedure get_start_end_dates
395 (p_comp_obj_tree_row in ben_manage_life_events.g_cache_proc_objects_rec
396 ,p_pil_row in ben_per_in_ler%rowtype
397 ,p_effective_date in date
398 ,p_business_group_id in number
399 ,p_person_id in number
400 ,p_pl_id in number
401 ,p_pgm_id in number
402 ,p_oipl_id in number
403 ,p_plip_id in number
404 ,p_ptip_id in number
405 ,p_prev_prtn_strt_dt in date
406 ,p_prev_prtn_end_dt in date
407 ,p_start_or_end in varchar2
408 ,p_prtn_eff_strt_dt out nocopy date
409 ,p_prtn_eff_strt_dt_cd out nocopy varchar2
410 ,p_prtn_eff_strt_dt_rl out nocopy number
411 ,p_prtn_eff_end_dt out nocopy date
412 )
413 is
414 --
415 /* 4968123
416 l_proc varchar2(100):=g_package||'get_start_end_dates';
417 */
418 --
419 l_wait_perd_val ben_prtn_elig_f.wait_perd_val%TYPE;
420 l_wait_perd_uom ben_prtn_elig_f.wait_perd_uom%TYPE;
421 l_prtn_eff_strt_dt_cd ben_prtn_elig_f.prtn_eff_strt_dt_cd%TYPE;
422 l_prtn_eff_end_dt_cd ben_prtn_elig_f.prtn_eff_end_dt_cd%TYPE;
423 l_prtn_eff_strt_dt_rl ben_prtn_elig_f.prtn_eff_strt_dt_rl%TYPE;
424 l_prtn_eff_end_dt_rl ben_prtn_elig_f.prtn_eff_end_dt_rl%TYPE;
425 l_outputs ff_exec.outputs_t;
426 l_oipl_rec ben_cobj_cache.g_oipl_inst_row;
427 l_pl_rec ben_pl_f%rowtype;
428 l_elig_pgm_rec ben_cobj_cache.g_etpr_inst_row;
429 l_elig_ptip_rec ben_cobj_cache.g_etpr_inst_row;
430 l_elig_plip_rec ben_cobj_cache.g_etpr_inst_row;
431 l_elig_pl_rec ben_cobj_cache.g_etpr_inst_row;
432 l_elig_oipl_rec ben_cobj_cache.g_etpr_inst_row;
433 l_prtn_elig_pl_rec ben_cobj_cache.g_prel_inst_row;
434 l_prtn_elig_pgm_rec ben_cobj_cache.g_prel_inst_row;
435 l_prtn_elig_oipl_rec ben_cobj_cache.g_prel_inst_row;
436 l_prtn_elig_plip_rec ben_cobj_cache.g_prel_inst_row;
437 l_prtn_elig_ptip_rec ben_cobj_cache.g_prel_inst_row;
438 l_ass_rec per_all_assignments_f%rowtype;
439 l_loc_rec hr_locations_all%rowtype;
440 l_jurisdiction_code varchar2(30);
441 --
442 l_envpgm_id number;
443 l_envptip_id number;
444 l_envplip_id number;
445 l_envpl_id number;
446 l_env_rec ben_env_object.g_global_env_rec_type;
447 l_benmngle_parm_rec benutils.g_batch_param_rec;
448 --FONM
449 l_fonm_cvg_strt_dt DATE ;
450 --END FONM
451 --
452 l_temp_prtn_strt_dt date ;
453 --
454 begin
455 -- hr_utility.set_location('Entering ben_determine_eligibility2.get_start_end_dates',10);
456 --
457 -- Performance tuning commented out hr_utility statements
458 --
459 -- hr_utility.set_location('p_pgm_id -> ' ||p_pgm_id ,123);
460 -- hr_utility.set_location('p_ptip_id -> ' ||p_ptip_id,123);
461 -- hr_utility.set_location('p_plip_id -> ' ||p_plip_id,123);
462 -- hr_utility.set_location('p_pl_id -> ' ||p_pl_id ,123);
463 -- hr_utility.set_location('p_oipl_id -> ' ||p_oipl_id,123);
464 --
465 if ben_manage_life_events.fonm = 'Y'
466 and ben_manage_life_events.g_fonm_cvg_strt_dt is not null then
467 --
468 l_fonm_cvg_strt_dt := ben_manage_life_events.g_fonm_cvg_strt_dt ;
469 --
470 end if;
471 --
472 -- if the mode is Personnel Action - the participation start date and end date needs to be
473 -- defaulted to Event and 1 day before event
474 ben_env_object.get(p_rec => l_env_rec);
475 benutils.get_batch_parameters(p_benefit_action_id => l_env_rec.benefit_action_id
476 ,p_rec => l_benmngle_parm_rec);
477 if l_benmngle_parm_rec.mode_cd = 'P' then
478 --
479 if p_start_or_end = 'S' then
480 --
481 p_prtn_eff_strt_dt := p_effective_date;
482 --
483 elsif p_start_or_end = 'E' then
484 --
485 p_prtn_eff_end_dt := p_effective_date - 1;
486 --
487 end if;
488 return;
489 end if;
490
491
492
493 -- Assign comp object locals
494 --
495 l_envpgm_id := p_comp_obj_tree_row.par_pgm_id;
496 l_envptip_id := p_comp_obj_tree_row.par_ptip_id;
497 l_envplip_id := p_comp_obj_tree_row.par_plip_id;
498 l_envpl_id := p_comp_obj_tree_row.par_pl_id;
499 --
500 -- Read participation dates for the comp object from the cached environment.
501 --
502 if p_pgm_id is not null then
503 -- hr_utility.set_location('get pgm l_prtn_eff_strt_dt_cd',123);
504 --
505 -- Performance fix to reduce cache calls
506 --
507 l_elig_pgm_rec := ben_cobj_cache.g_pgmetpr_currow;
508 --
509 l_prtn_eff_strt_dt_rl := l_elig_pgm_rec.prtn_eff_strt_dt_rl;
510 l_prtn_eff_end_dt_rl := l_elig_pgm_rec.prtn_eff_end_dt_rl;
511 l_prtn_eff_strt_dt_cd := l_elig_pgm_rec.prtn_eff_strt_dt_cd;
512 l_prtn_eff_end_dt_cd := l_elig_pgm_rec.prtn_eff_end_dt_cd;
513 --
514 -- If the date codes are not found in the elig_to_prte_rsn table, look for
515 -- them in prtn_elig_f.
516 --
517 if l_prtn_eff_strt_dt_cd is null then
518 --
519 l_prtn_elig_pgm_rec := ben_cobj_cache.g_pgmprel_currow;
520 --
521 l_prtn_eff_strt_dt_cd := l_prtn_elig_pgm_rec.prtn_eff_strt_dt_cd;
522 l_prtn_eff_end_dt_cd := l_prtn_elig_pgm_rec.prtn_eff_end_dt_cd;
523 l_prtn_eff_strt_dt_rl := l_prtn_elig_pgm_rec.prtn_eff_strt_dt_rl;
524 l_prtn_eff_end_dt_rl := l_prtn_elig_pgm_rec.prtn_eff_end_dt_rl;
525 end if;
526
527 -- hr_utility.set_location('Done NN PGM ben_determine_eligibility2.get_start_end_dates',10);
528 end if;
529 -- hr_utility.set_location('PTIP NN ben_determine_eligibility2.get_start_end_dates',10);
530 if p_ptip_id is not null then
531 --
532 -- Performance fix to reduce cache calls
533 --
534 l_elig_ptip_rec := ben_cobj_cache.g_ptipetpr_currow;
535 --
536 l_prtn_eff_strt_dt_cd := l_elig_ptip_rec.prtn_eff_strt_dt_cd;
537 l_prtn_eff_end_dt_cd := l_elig_ptip_rec.prtn_eff_end_dt_cd;
538 l_prtn_eff_strt_dt_rl := l_elig_ptip_rec.prtn_eff_strt_dt_rl;
539 l_prtn_eff_end_dt_rl := l_elig_ptip_rec.prtn_eff_end_dt_rl;
540 --
541 -- If the date codes are not found in the elig_to_prte_rsn table, look for
542 -- them in prtn_elig_f.
543 --
544 if l_prtn_eff_strt_dt_cd is null then
545 --
546 l_prtn_elig_ptip_rec := ben_cobj_cache.g_ptipprel_currow;
547 --
548 l_prtn_eff_strt_dt_cd := l_prtn_elig_ptip_rec.prtn_eff_strt_dt_cd;
549 l_prtn_eff_end_dt_cd := l_prtn_elig_ptip_rec.prtn_eff_end_dt_cd;
550 l_prtn_eff_strt_dt_rl := l_prtn_elig_ptip_rec.prtn_eff_strt_dt_rl;
551 l_prtn_eff_end_dt_rl := l_prtn_elig_ptip_rec.prtn_eff_end_dt_rl;
552 end if;
553 --
554 -- if cd is still null then get it from pgm
555 --
556 if l_prtn_eff_strt_dt_cd is null then
557 l_elig_pgm_rec := ben_cobj_cache.g_pgmetpr_currow;
558 --
559 l_prtn_elig_pgm_rec := ben_cobj_cache.g_pgmprel_currow;
560 --
561 l_prtn_eff_strt_dt_cd := nvl(l_elig_pgm_rec.prtn_eff_strt_dt_cd,l_prtn_elig_pgm_rec.prtn_eff_strt_dt_cd);
562 l_prtn_eff_end_dt_cd := nvl(l_elig_pgm_rec.prtn_eff_end_dt_cd ,l_prtn_elig_pgm_rec.prtn_eff_end_dt_cd );
563 l_prtn_eff_strt_dt_rl := nvl(l_elig_pgm_rec.prtn_eff_strt_dt_rl,l_prtn_elig_pgm_rec.prtn_eff_strt_dt_rl);
564 l_prtn_eff_end_dt_rl := nvl(l_elig_pgm_rec.prtn_eff_end_dt_rl ,l_prtn_elig_pgm_rec.prtn_eff_end_dt_rl );
565 end if;
566 -- hr_utility.set_location('Done NN PTIP ben_determine_eligibility2.get_start_end_dates',10);
567
568 end if;
569 -- hr_utility.set_location('PLIP NN ben_determine_eligibility2.get_start_end_dates',10);
570 if p_plip_id is not null then
571 -- hr_utility.set_location('get plip l_prtn_eff_strt_dt_cd',123);
572 --
573 l_elig_plip_rec := ben_cobj_cache.g_plipetpr_currow;
574 l_prtn_eff_strt_dt_cd := l_elig_plip_rec.prtn_eff_strt_dt_cd;
575 l_prtn_eff_end_dt_cd := l_elig_plip_rec.prtn_eff_end_dt_cd;
576 l_prtn_eff_strt_dt_rl := l_elig_plip_rec.prtn_eff_strt_dt_rl;
577 l_prtn_eff_end_dt_rl := l_elig_plip_rec.prtn_eff_end_dt_rl;
578 --
579 -- If the date codes are not found in the elig_to_prte_rsn table, look for
580 -- them in prtn_elig_f.
581 --
582 if l_prtn_eff_strt_dt_cd is null then
583 l_prtn_elig_plip_rec := ben_cobj_cache.g_plipprel_currow;
584 l_prtn_eff_strt_dt_cd := l_prtn_elig_plip_rec.prtn_eff_strt_dt_cd;
585 l_prtn_eff_end_dt_cd := l_prtn_elig_plip_rec.prtn_eff_end_dt_cd;
586 l_prtn_eff_strt_dt_rl := l_prtn_elig_plip_rec.prtn_eff_strt_dt_rl;
587 l_prtn_eff_end_dt_rl := l_prtn_elig_plip_rec.prtn_eff_end_dt_rl;
588 end if;
589 --
590 -- if cd is still null then look in ptip then pgm
591 --
592 if l_prtn_eff_strt_dt_cd is null then
593 l_elig_ptip_rec := ben_cobj_cache.g_ptipetpr_currow;
594 l_prtn_elig_ptip_rec := ben_cobj_cache.g_ptipprel_currow;
595 l_prtn_eff_strt_dt_cd := nvl(l_elig_ptip_rec.prtn_eff_strt_dt_cd,l_prtn_elig_ptip_rec.prtn_eff_strt_dt_cd);
596 l_prtn_eff_end_dt_cd := nvl(l_elig_ptip_rec.prtn_eff_end_dt_cd ,l_prtn_elig_ptip_rec.prtn_eff_end_dt_cd );
597 l_prtn_eff_strt_dt_rl := nvl(l_elig_ptip_rec.prtn_eff_strt_dt_rl,l_prtn_elig_ptip_rec.prtn_eff_strt_dt_rl);
598 l_prtn_eff_end_dt_rl := nvl(l_elig_ptip_rec.prtn_eff_end_dt_rl ,l_prtn_elig_ptip_rec.prtn_eff_end_dt_rl );
599
600 if l_prtn_eff_strt_dt_cd is null then
601 l_elig_pgm_rec := ben_cobj_cache.g_pgmetpr_currow;
602 l_prtn_elig_pgm_rec := ben_cobj_cache.g_pgmprel_currow;
603 l_prtn_eff_strt_dt_cd := nvl(l_elig_pgm_rec.prtn_eff_strt_dt_cd,l_prtn_elig_pgm_rec.prtn_eff_strt_dt_cd);
604 l_prtn_eff_end_dt_cd := nvl(l_elig_pgm_rec.prtn_eff_end_dt_cd ,l_prtn_elig_pgm_rec.prtn_eff_end_dt_cd );
605 l_prtn_eff_strt_dt_rl := nvl(l_elig_pgm_rec.prtn_eff_strt_dt_rl,l_prtn_elig_pgm_rec.prtn_eff_strt_dt_rl);
606 l_prtn_eff_end_dt_rl := nvl(l_elig_pgm_rec.prtn_eff_end_dt_rl ,l_prtn_elig_pgm_rec.prtn_eff_end_dt_rl );
607 end if;
608 end if;
609
610 -- hr_utility.set_location('Done NN PLIP ben_determine_eligibility2.get_start_end_dates',10);
611 end if;
612 -- hr_utility.set_location('PLN NN ben_determine_eligibility2.get_start_end_dates',10);
613 if p_pl_id is not null then
614
615 -- For plans in pgm, look at plip first.
616 if l_envplip_id is not null then
617 l_elig_plip_rec := ben_cobj_cache.g_plipetpr_currow;
618 l_prtn_elig_plip_rec := ben_cobj_cache.g_plipprel_currow;
619 l_prtn_eff_strt_dt_cd := nvl(l_elig_plip_rec.prtn_eff_strt_dt_cd,l_prtn_elig_plip_rec.prtn_eff_strt_dt_cd);
620 l_prtn_eff_end_dt_cd := nvl(l_elig_plip_rec.prtn_eff_end_dt_cd ,l_prtn_elig_plip_rec.prtn_eff_end_dt_cd );
621 l_prtn_eff_strt_dt_rl := nvl(l_elig_plip_rec.prtn_eff_strt_dt_rl,l_prtn_elig_plip_rec.prtn_eff_strt_dt_rl);
622 l_prtn_eff_end_dt_rl := nvl(l_elig_plip_rec.prtn_eff_end_dt_rl ,l_prtn_elig_plip_rec.prtn_eff_end_dt_rl );
623 end if;
624
625 -- if plip not found, or plan not in program, look at pl level
626 if l_prtn_eff_strt_dt_cd is null then
627 -- hr_utility.set_location('get pl l_prtn_eff_strt_dt_cd',123);
628 --
629 l_elig_pl_rec := ben_cobj_cache.g_pletpr_currow;
630 l_prtn_eff_strt_dt_cd := l_elig_pl_rec.prtn_eff_strt_dt_cd;
631 l_prtn_eff_end_dt_cd := l_elig_pl_rec.prtn_eff_end_dt_cd;
632 l_prtn_eff_strt_dt_rl := l_elig_pl_rec.prtn_eff_strt_dt_rl;
633 l_prtn_eff_end_dt_rl := l_elig_pl_rec.prtn_eff_end_dt_rl;
634
635 -- If the date codes are not found in the elig_to_prte_rsn table, look for
636 -- them in prtn_elig_f.
637 --
638 if l_prtn_eff_strt_dt_cd is null then
639 l_prtn_elig_pl_rec := ben_cobj_cache.g_plprel_currow;
640 l_prtn_eff_strt_dt_cd := l_prtn_elig_pl_rec.prtn_eff_strt_dt_cd;
641 l_prtn_eff_end_dt_cd := l_prtn_elig_pl_rec.prtn_eff_end_dt_cd;
642 l_prtn_eff_strt_dt_rl := l_prtn_elig_pl_rec.prtn_eff_strt_dt_rl;
643 l_prtn_eff_end_dt_rl := l_prtn_elig_pl_rec.prtn_eff_end_dt_rl;
644 end if;
645
646 -- if cd is still null and pl is in pgm, get from ptip or pgm.
647 --
648 if l_prtn_eff_strt_dt_cd is null and l_envptip_id is not null then
649 l_elig_ptip_rec := ben_cobj_cache.g_ptipetpr_currow;
650 l_prtn_elig_ptip_rec := ben_cobj_cache.g_ptipprel_currow;
651 l_prtn_eff_strt_dt_cd := nvl(l_elig_ptip_rec.prtn_eff_strt_dt_cd,l_prtn_elig_ptip_rec.prtn_eff_strt_dt_cd);
652 l_prtn_eff_end_dt_cd := nvl(l_elig_ptip_rec.prtn_eff_end_dt_cd ,l_prtn_elig_ptip_rec.prtn_eff_end_dt_cd );
653 l_prtn_eff_strt_dt_rl := nvl(l_elig_ptip_rec.prtn_eff_strt_dt_rl,l_prtn_elig_ptip_rec.prtn_eff_strt_dt_rl);
654 l_prtn_eff_end_dt_rl := nvl(l_elig_ptip_rec.prtn_eff_end_dt_rl ,l_prtn_elig_ptip_rec.prtn_eff_end_dt_rl );
655
656 if l_prtn_eff_strt_dt_cd is null then
657 l_elig_pgm_rec := ben_cobj_cache.g_pgmetpr_currow;
658 l_prtn_elig_pgm_rec := ben_cobj_cache.g_pgmprel_currow;
659 l_prtn_eff_strt_dt_cd := nvl(l_elig_pgm_rec.prtn_eff_strt_dt_cd,l_prtn_elig_pgm_rec.prtn_eff_strt_dt_cd);
660 l_prtn_eff_end_dt_cd := nvl(l_elig_pgm_rec.prtn_eff_end_dt_cd ,l_prtn_elig_pgm_rec.prtn_eff_end_dt_cd );
661 l_prtn_eff_strt_dt_rl := nvl(l_elig_pgm_rec.prtn_eff_strt_dt_rl,l_prtn_elig_pgm_rec.prtn_eff_strt_dt_rl);
662 l_prtn_eff_end_dt_rl := nvl(l_elig_pgm_rec.prtn_eff_end_dt_rl ,l_prtn_elig_pgm_rec.prtn_eff_end_dt_rl );
663 end if;
664
665 end if;
666 end if;
667 -- hr_utility.set_location('Done NN PLN ben_determine_eligibility2.get_start_end_dates',10);
668 end if;
669 -- hr_utility.set_location('OIPL NN ben_determine_eligibility2.get_start_end_dates',10);
670 if p_oipl_id is not null then
671 -- hr_utility.set_location('getting oipl l_prtn_eff_strt_dt_cd',123);
672 l_elig_oipl_rec := ben_cobj_cache.g_oipletpr_currow;
673 l_prtn_eff_strt_dt_cd := l_elig_oipl_rec.prtn_eff_strt_dt_cd;
674 l_prtn_eff_end_dt_cd := l_elig_oipl_rec.prtn_eff_end_dt_cd;
675 l_prtn_eff_strt_dt_rl := l_elig_oipl_rec.prtn_eff_strt_dt_rl;
676 l_prtn_eff_end_dt_rl := l_elig_oipl_rec.prtn_eff_end_dt_rl;
677 --
678 -- If the date codes are not found in the elig_to_prte_rsn table, look for
679 -- them in prtn_elig_f.
680 --
681 if l_prtn_eff_strt_dt_cd is null then
682 l_prtn_elig_oipl_rec := ben_cobj_cache.g_oiplprel_currow;
683 l_prtn_eff_strt_dt_cd := l_prtn_elig_oipl_rec.prtn_eff_strt_dt_cd;
684 l_prtn_eff_end_dt_cd := l_prtn_elig_oipl_rec.prtn_eff_end_dt_cd;
685 l_prtn_eff_strt_dt_rl := l_prtn_elig_oipl_rec.prtn_eff_strt_dt_rl;
686 l_prtn_eff_end_dt_rl := l_prtn_elig_oipl_rec.prtn_eff_end_dt_rl;
687 end if;
688 --
689 -- if cd is still null then get from plip if in pgm, plan if not
690 --
691 if l_prtn_eff_strt_dt_cd is null and l_envplip_id is not null then
692 l_elig_plip_rec := ben_cobj_cache.g_plipetpr_currow;
693 l_prtn_elig_plip_rec := ben_cobj_cache.g_plipprel_currow;
694 l_prtn_eff_strt_dt_cd := nvl(l_elig_plip_rec.prtn_eff_strt_dt_cd,l_prtn_elig_plip_rec.prtn_eff_strt_dt_cd);
695 l_prtn_eff_end_dt_cd := nvl(l_elig_plip_rec.prtn_eff_end_dt_cd ,l_prtn_elig_plip_rec.prtn_eff_end_dt_cd );
696 l_prtn_eff_strt_dt_rl := nvl(l_elig_plip_rec.prtn_eff_strt_dt_rl,l_prtn_elig_plip_rec.prtn_eff_strt_dt_rl);
697 l_prtn_eff_end_dt_rl := nvl(l_elig_plip_rec.prtn_eff_end_dt_rl ,l_prtn_elig_plip_rec.prtn_eff_end_dt_rl );
698 end if;
699
700 if l_prtn_eff_strt_dt_cd is null then
701 l_elig_pl_rec := ben_cobj_cache.g_pletpr_currow;
702 l_prtn_elig_pl_rec := ben_cobj_cache.g_plprel_currow;
703 l_prtn_eff_strt_dt_cd := nvl(l_elig_pl_rec.prtn_eff_strt_dt_cd,l_prtn_elig_pl_rec.prtn_eff_strt_dt_cd);
704 l_prtn_eff_end_dt_cd := nvl(l_elig_pl_rec.prtn_eff_end_dt_cd ,l_prtn_elig_pl_rec.prtn_eff_end_dt_cd );
705 l_prtn_eff_strt_dt_rl := nvl(l_elig_pl_rec.prtn_eff_strt_dt_rl,l_prtn_elig_pl_rec.prtn_eff_strt_dt_rl);
706 l_prtn_eff_end_dt_rl := nvl(l_elig_pl_rec.prtn_eff_end_dt_rl ,l_prtn_elig_pl_rec.prtn_eff_end_dt_rl );
707
708 -- if cd is still null and oipl is in a program then get from ptip or pgm
709 if l_prtn_eff_strt_dt_cd is null and l_envptip_id is not null then
710 l_elig_ptip_rec := ben_cobj_cache.g_ptipetpr_currow;
711 l_prtn_elig_ptip_rec := ben_cobj_cache.g_ptipprel_currow;
712 l_prtn_eff_strt_dt_cd := nvl(l_elig_ptip_rec.prtn_eff_strt_dt_cd,l_prtn_elig_ptip_rec.prtn_eff_strt_dt_cd);
713 l_prtn_eff_end_dt_cd := nvl(l_elig_ptip_rec.prtn_eff_end_dt_cd ,l_prtn_elig_ptip_rec.prtn_eff_end_dt_cd );
714 l_prtn_eff_strt_dt_rl := nvl(l_elig_ptip_rec.prtn_eff_strt_dt_rl,l_prtn_elig_ptip_rec.prtn_eff_strt_dt_rl);
715 l_prtn_eff_end_dt_rl := nvl(l_elig_ptip_rec.prtn_eff_end_dt_rl ,l_prtn_elig_ptip_rec.prtn_eff_end_dt_rl );
716
717 if l_prtn_eff_strt_dt_cd is null then
718 l_elig_pgm_rec := ben_cobj_cache.g_pgmetpr_currow;
719 l_prtn_elig_pgm_rec := ben_cobj_cache.g_pgmprel_currow;
720 l_prtn_eff_strt_dt_cd := nvl(l_elig_pgm_rec.prtn_eff_strt_dt_cd,l_prtn_elig_pgm_rec.prtn_eff_strt_dt_cd);
721 l_prtn_eff_end_dt_cd := nvl(l_elig_pgm_rec.prtn_eff_end_dt_cd ,l_prtn_elig_pgm_rec.prtn_eff_end_dt_cd );
722 l_prtn_eff_strt_dt_rl := nvl(l_elig_pgm_rec.prtn_eff_strt_dt_rl,l_prtn_elig_pgm_rec.prtn_eff_strt_dt_rl);
723 l_prtn_eff_end_dt_rl := nvl(l_elig_pgm_rec.prtn_eff_end_dt_rl ,l_prtn_elig_pgm_rec.prtn_eff_end_dt_rl );
724 end if;
725 end if;
726 end if;
727 -- hr_utility.set_location('Done NN OIPL ben_determine_eligibility2.get_start_end_dates',10);
728 end if;
729 if l_prtn_eff_strt_dt_cd is null then
730 -- hr_utility.set_location('Null l_prtn_eff_strt_dt_cd, so assign aed',123);
731 l_prtn_eff_strt_dt_cd := 'AED'; -- as of event date
732 end if;
733
734 if l_prtn_eff_end_dt_cd is null then
735 -- hr_utility.set_location('null l_prtn_eff_end_dt_cd, so assign odbed',123);
736 -- Bug 2806554 - Changed to ODBED from AEOT
737 l_prtn_eff_end_dt_cd := 'ODBED'; -- one day before event date
738 end if;
739 --
740 -- Set the out parameter to the date code that is being used.
741 --
742 p_prtn_eff_strt_dt_cd := l_prtn_eff_strt_dt_cd;
743 p_prtn_eff_strt_dt_rl := l_prtn_eff_strt_dt_rl;
744 --
745 -- hr_utility.set_location('p_start_or_end ben_determine_eligibility2.get_start_end_dates', 10);
746 if p_start_or_end = 'S' then
747 if l_prtn_eff_strt_dt_cd <> 'RL' then
748 -- hr_utility.set_location('ben_determine_eligibility2.get_start_end_dates SOE S not RL ben_determine_eligibility2.get_start_end_dates', 10);
749 /* -- FONM START
750 if ben_manage_life_events.fonm = 'Y' and
751 ben_manage_life_events.g_fonm_cvg_strt_dt is not null then
752 --
753 p_prtn_eff_strt_dt := ben_manage_life_events.g_fonm_cvg_strt_dt ;
754 --
755 else
756 --
757 --FONM END
758 */
759 ben_determine_date.main
760 (p_date_cd => l_prtn_eff_strt_dt_cd
761 ,p_per_in_ler_id => p_pil_row.per_in_ler_id
762 ,p_person_id => p_person_id
763 ,p_pgm_id => l_envpgm_id
764 ,p_pl_id => l_envpl_id
765 ,p_oipl_id => p_oipl_id
766 ,p_business_group_id => p_business_group_id
767 ,p_formula_id => l_prtn_eff_strt_dt_rl
768 ,p_lf_evt_ocrd_dt => p_pil_row.lf_evt_ocrd_dt
769 ,p_start_date => null
770 ,p_effective_date => p_effective_date
771 ,p_returned_date => p_prtn_eff_strt_dt
772 );
773 --
774 -- FONM START
775 -- end if;
776 -- FONM END
777 --
778 -- hr_utility.set_location('Done det date ben_determine_eligibility2.get_start_end_dates', 10);
779
780 --
781 elsif l_prtn_eff_strt_dt_cd = 'RL' then
782 -- hr_utility.set_location('ben_determine_eligibility2.get_start_end_dates SOE S RL ben_determine_eligibility2.get_start_end_dates', 10);
783 --
784 -- Get the date from calling a fast formula rule
785 --
786 --
787 ben_person_object.get_object(p_person_id => p_person_id,
788 p_rec => l_ass_rec);
789 if l_ass_rec.assignment_id is null then
790 ben_person_object.get_benass_object(p_person_id => p_person_id,
791 p_rec => l_ass_rec);
792 end if;
793 if l_ass_rec.location_id is not null then
794 ben_location_object.get_object(p_location_id => l_ass_rec.location_id,
795 p_rec => l_loc_rec);
796 -- if l_loc_rec.region_2 is not null then
797 -- l_jurisdiction_code :=
798 -- pay_mag_utils.lookup_jurisdiction_code
799 -- (p_state => l_loc_rec.region_2);
800 -- end if;
801 end if;
802 --
803 -- Rule = Participation Eligibility Start Date (ID = -82)
804 --
805 -- Call formula initialise routine
806 --
807 if l_envpl_id is not null then
808 --
809 ben_comp_object.get_object
810 (p_pl_id => l_envpl_id
811 ,p_rec => l_pl_rec
812 );
813 --
814 end if;
815 --
816 if p_oipl_id is not null then
817 --
818 l_oipl_rec := ben_cobj_cache.g_oipl_currow;
819 --
820 end if;
821 --
822 l_outputs := benutils.formula
823 (p_formula_id => l_prtn_eff_strt_dt_rl
824 ,p_effective_date => p_effective_date
825 ,p_business_group_id => p_business_group_id
826 ,p_assignment_id => l_ass_rec.assignment_id
827 ,p_organization_id => l_ass_rec.organization_id
828 ,p_pl_id => l_envpl_id
829 ,p_pl_typ_id => l_pl_rec.pl_typ_id
830 ,p_pgm_id => l_envpgm_id
831 ,p_opt_id => l_oipl_rec.opt_id
832 ,p_ler_id => p_pil_row.ler_id
833 ,p_param1 => 'BEN_IV_RT_STRT_DT'
834 ,p_param1_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_rt_strt_dt)
835 ,p_param2 => 'BEN_IV_CVG_STRT_DT'
836 ,p_param2_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_cvg_strt_dt)
837 ,p_param3 => 'BEN_IV_PERSON_ID' -- Bug 5331889
838 ,p_param3_value => to_char(p_person_id)
839 ,p_jurisdiction_code => l_jurisdiction_code
840 );
841 --
842 -- Formula will return a date but code defensively in case the
843 -- date can not be typecast.
844 --
845 begin
846 p_prtn_eff_strt_dt := fnd_date.canonical_to_date
847 (l_outputs(l_outputs.first).value);
848 exception
849 when others then
850 fnd_message.set_name('BEN','BEN_91329_FORMULA_RETURN');
851 fnd_message.set_token('RL','prtn_eff_strt_dt_rl');
852 fnd_message.set_token('PROC','ben_determine_eligibility2.get_start_end_dates');
853 raise ben_manage_life_events.g_record_error;
854 end;
855 else
856 fnd_message.set_name('BEN','BEN_91342_UNKNOWN_CODE_1');
857 fnd_message.set_token('PROC','ben_determine_eligibility2.get_start_end_dates');
858 fnd_message.set_token('CODE1',l_prtn_eff_strt_dt_cd);
859 raise ben_manage_life_events.g_record_error ;
860 end if;
861
862 elsif p_start_or_end = 'E' then
863 --
864 -- hr_utility.set_location('ben_determine_eligibility2.get_start_end_dates p_start_or_end is E ' , 10);
865 -- FONM START
866 if ben_manage_life_events.fonm = 'Y' and
867 ben_manage_life_events.g_fonm_cvg_strt_dt is not null then
868 --
869 p_prtn_eff_end_dt := ben_manage_life_events.g_fonm_cvg_strt_dt - 1 ;
870 --
871 --END FONM
872 elsif l_prtn_eff_end_dt_cd = 'A30DFPSD' then
873 hr_utility.set_location('ben_determine_eligibility2.get_start_end_dates SOE E A30DFPSD ben_determine_eligibility2.get_start_end_dates', 10);
874 --
875 -- as of 30 days from prtn strt date
876 -- the start date used here in the case of an oipl is from the
877 -- elig_per_opt record, whereas for the pl or pgm the date is from
878 -- the elig_per record.
879 --
880 ben_determine_date.main
881 (p_date_cd => l_prtn_eff_end_dt_cd
882 ,p_start_date => p_prev_prtn_strt_dt
883 ,p_business_group_id => p_business_group_id
884 ,p_effective_date => p_effective_date
885 ,p_returned_date => p_prtn_eff_end_dt
886 );
887 --
888 elsif l_prtn_eff_end_dt_cd = 'A12MFPSD' then
889 -- hr_utility.set_location('ben_determine_eligibility2.get_start_end_dates SOE E A12MFPSD ben_determine_eligibility2.get_start_end_dates', 10);
890 --
891 -- as of 12 months from prtn strt date
892 -- the start date used here in the case of an oipl is from the
893 -- elig_per_opt record, whereas for the pl or pgm the date is from
894 -- the elig_per record.
895 --
896 ben_determine_date.main
897 (p_date_cd => l_prtn_eff_end_dt_cd
898 ,p_start_date => p_prev_prtn_strt_dt
899 ,p_business_group_id => p_business_group_id
900 ,p_effective_date => p_effective_date
901 ,p_returned_date => p_prtn_eff_end_dt
902 );
903 --
904 elsif l_prtn_eff_end_dt_cd = 'ALDCPP' then
905 -- hr_utility.set_location('ben_determine_eligibility2.get_start_end_dates SOE E ALDCPP ben_determine_eligibility2.get_start_end_dates', 10);
906 --
907 -- as of the last day of the pay period where date occurred
908 --
909 ben_determine_date.main
910 (p_date_cd => l_prtn_eff_end_dt_cd
911 ,p_person_id => p_person_id
912 ,p_returned_date => p_prtn_eff_end_dt
913 ,p_business_group_id => p_business_group_id
914 ,p_effective_date => p_effective_date
915 );
916 --
917 elsif l_prtn_eff_end_dt_cd = 'ALDCM' then
918 -- hr_utility.set_location('ben_determine_eligibility2.get_start_end_dates SOE E ALDCM ben_determine_eligibility2.get_start_end_dates', 10);
919 --
920 -- as of the last day of the month where date occurred
921 --
922 ben_determine_date.main
923 (p_date_cd => l_prtn_eff_end_dt_cd
924 ,p_person_id => p_person_id
925 ,p_returned_date => p_prtn_eff_end_dt
926 ,p_business_group_id => p_business_group_id
927 ,p_effective_date => p_effective_date
928 );
929 --
930 elsif l_prtn_eff_end_dt_cd = 'ALDCPPSY' then
931 -- hr_utility.set_location('ben_determine_eligibility2.get_start_end_dates SOE E ALDCPPSY ben_determine_eligibility2.get_start_end_dates', 10);
932 --
933 -- as of the last day of the pl semi-year where date occurred
934 --Bug 2551834 Added nvl cases to handle ptip/plip cases
935 ben_determine_date.main
936 (p_date_cd => l_prtn_eff_end_dt_cd
937 ,p_person_id => p_person_id
938 ,p_pgm_id => nvl(p_pgm_id,l_envpgm_id)
939 ,p_pl_id => nvl(p_pl_id,l_envpl_id)
940 ,p_oipl_id => p_oipl_id
941 ,p_returned_date => p_prtn_eff_end_dt
942 ,p_business_group_id => p_business_group_id
943 ,p_effective_date => p_effective_date
944 );
945 --
946 elsif l_prtn_eff_end_dt_cd = 'ALDCPPY' then
947 -- hr_utility.set_location('ben_determine_eligibility2.get_start_end_dates SOE E ALDCPPY ben_determine_eligibility2.get_start_end_dates', 10);
948 --
949 -- as of the last day of the pl yr where date occurred
950 --Bug 2551834 Added nvl cases to handle ptip/plip cases
951 ben_determine_date.main
952 (p_date_cd => l_prtn_eff_end_dt_cd
953 ,p_person_id => p_person_id
954 ,p_pgm_id => nvl(p_pgm_id,l_envpgm_id)
955 ,p_pl_id => nvl(p_pl_id,l_envpl_id)
956 ,p_oipl_id => p_oipl_id
957 ,p_returned_date => p_prtn_eff_end_dt
958 ,p_business_group_id => p_business_group_id
959 ,p_effective_date => p_effective_date
960 );
961 --
962 /* Bug : 2551
963 Following elsif is moved from the top as it logically
964 belongs here. All the refrences to eff_strt_dt_cd are
965 changed to eff_end_dt_cd.
966 */
967 elsif l_prtn_eff_end_dt_cd <> 'RL' then
968 --
969 -- hr_utility.set_location('ben_determine_eligibility2.get_start_end_dates SOE E <> RL ben_determine_eligibility2.get_start_end_dates', 10);
970 hr_utility.set_location(' SOE E <> RLBefore EEDT' || p_prtn_eff_end_dt,20);
971 --NOCOPY ISSUE
972 l_temp_prtn_strt_dt := p_prtn_eff_end_dt ;
973 --
974 ben_determine_date.main
975 (p_date_cd => l_prtn_eff_end_dt_cd
976 ,p_per_in_ler_id => p_pil_row.per_in_ler_id
977 ,p_person_id => p_person_id
978 ,p_pgm_id => l_envpgm_id
979 ,p_pl_id => l_envpl_id
980 ,p_oipl_id => p_oipl_id
981 ,p_business_group_id => p_business_group_id
982 ,p_formula_id => l_prtn_eff_end_dt_rl
983 ,p_lf_evt_ocrd_dt => p_pil_row.lf_evt_ocrd_dt
984 ,p_start_date => l_temp_prtn_strt_dt -- NOCOPY ISSUE p_prtn_eff_end_dt
985 ,p_effective_date => p_effective_date
986 ,p_returned_date => p_prtn_eff_end_dt
987 );
988 --
989 hr_utility.set_location(' SOE E <> RLAfter EEDT' || p_prtn_eff_end_dt,20);
990 --
991 elsif l_prtn_eff_end_dt_cd = 'RL' then
992 -- hr_utility.set_location('ben_determine_eligibility2.get_start_end_dates SOE E RL ben_determine_eligibility2.get_start_end_dates', 10);
993 --
994 -- Get the date from calling a fast formula rule
995 --
996 -- Rule = Participation Eligibility End Date (-83)
997 --
998 ben_person_object.get_object(p_person_id => p_person_id,
999 p_rec => l_ass_rec);
1000 if l_ass_rec.assignment_id is null then
1001 ben_person_object.get_benass_object(p_person_id => p_person_id,
1002 p_rec => l_ass_rec);
1003 end if;
1004 if l_ass_rec.location_id is not null then
1005 ben_location_object.get_object(p_location_id => l_ass_rec.location_id,
1006 p_rec => l_loc_rec);
1007 -- if l_loc_rec.region_2 is not null then
1008 -- l_jurisdiction_code :=
1009 -- pay_mag_utils.lookup_jurisdiction_code
1010 -- (p_state => l_loc_rec.region_2);
1011 -- end if;
1012 end if;
1013 --
1014 -- Call formula initialise routine
1015 --
1016 if l_envpl_id is not null then
1017 --
1018 ben_comp_object.get_object
1019 (p_pl_id => l_envpl_id
1020 ,p_rec => l_pl_rec
1021 );
1022 --
1023 end if;
1024 --
1025 if p_oipl_id is not null then
1026 --
1027 l_oipl_rec := ben_cobj_cache.g_oipl_currow;
1028 --
1029 end if;
1030 --
1031 l_outputs := benutils.formula
1032 (p_formula_id => l_prtn_eff_end_dt_rl
1033 ,p_effective_date => p_effective_date
1034 ,p_business_group_id => p_business_group_id
1035 ,p_assignment_id => l_ass_rec.assignment_id
1036 ,p_organization_id => l_ass_rec.organization_id
1037 ,p_pl_id => l_envpl_id
1038 ,p_pl_typ_id => l_pl_rec.pl_typ_id
1039 ,p_pgm_id => l_envpgm_id
1040 ,p_opt_id => l_oipl_rec.opt_id
1041 ,p_ler_id => p_pil_row.ler_id
1042 ,p_param1 => 'BEN_IV_RT_STRT_DT'
1043 ,p_param1_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_rt_strt_dt)
1044 ,p_param2 => 'BEN_IV_CVG_STRT_DT'
1045 ,p_param2_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_cvg_strt_dt)
1046 ,p_param3 => 'BEN_IV_PERSON_ID' -- Bug 5331889
1047 ,p_param3_value => to_char(p_person_id)
1048 ,p_jurisdiction_code => l_jurisdiction_code
1049 );
1050 --
1051 -- Formula will return a date but code defensively in case the
1052 -- date can not be typecast.
1053 --
1054 begin
1055 p_prtn_eff_end_dt := fnd_date.canonical_to_date
1056 (l_outputs(l_outputs.first).value);
1057 exception
1058 when others then
1059 fnd_message.set_name('BEN','BEN_91329_FORMULA_RETURN');
1060 fnd_message.set_token('RL','prtn_eff_end_dt_rl');
1061 fnd_message.set_token('PROC','ben_determine_eligibility2.get_start_end_dates');
1062 raise ben_manage_life_events.g_record_error;
1063 end;
1064
1065 else
1066 fnd_message.set_name('BEN','BEN_91342_UNKNOWN_CODE_1');
1067 fnd_message.set_token('PROC','ben_determine_eligibility2.get_start_end_dates');
1068 fnd_message.set_token('CODE1',l_prtn_eff_end_dt_cd);
1069 raise ben_manage_life_events.g_record_error;
1070 end if;
1071 else
1072 fnd_message.set_name('BEN','BEN_91393_STRT_END_ERROR');
1073 fnd_message.set_token('PROC','ben_determine_eligibility2.get_start_end_dates');
1074 raise ben_manage_life_events.g_record_error;
1075 end if;
1076 -- hr_utility.set_location('Leaving ben_determine_eligibility2.get_start_end_dates',10);
1077
1078 end get_start_end_dates;
1079 --
1080
1081 --
1082 -- -----------------------------------------------------------------------------
1083 -- |------------------------< check_prev_elig >--------------------------------|
1084 -- -----------------------------------------------------------------------------
1085 --
1086 procedure check_prev_elig
1087 (p_comp_obj_tree_row in out NOCOPY ben_manage_life_events.g_cache_proc_objects_rec
1088 ,p_per_row in out NOCOPY per_all_people_f%rowtype
1089 ,p_empasg_row in out NOCOPY per_all_assignments_f%rowtype
1090 ,p_benasg_row in out NOCOPY per_all_assignments_f%rowtype
1091 ,p_pil_row in out NOCOPY ben_per_in_ler%rowtype
1092 ,p_person_id in number
1093 ,p_business_group_id in number
1094 ,p_effective_date in date
1095 ,p_lf_evt_ocrd_dt in date
1096 ,p_pl_id in number
1097 ,p_pgm_id in number
1098 ,p_oipl_id in number
1099 ,p_plip_id in number
1100 ,p_ptip_id in number
1101 ,p_ler_id in number
1102 ,p_comp_rec in out NOCOPY ben_derive_part_and_rate_facts.g_cache_structure
1103 ,p_oiplip_rec in out NOCOPY ben_derive_part_and_rate_facts.g_cache_structure
1104 ,p_inelg_rsn_cd in varchar2
1105 --
1106 ,p_elig_flag in out nocopy boolean
1107 ,p_newly_elig out nocopy boolean
1108 ,p_newly_inelig out nocopy boolean
1109 ,p_first_elig out nocopy boolean
1110 ,p_first_inelig out nocopy boolean
1111 ,p_still_elig out nocopy boolean
1112 ,p_still_inelig out nocopy boolean
1113 ,p_score_tab in ben_evaluate_elig_profiles.scoreTab default ben_evaluate_elig_profiles.t_default_score_tbl
1114 )
1115 is
1116 --
1117 /* 4968123
1118 l_proc varchar2(100) := g_package||'check_prev_elig';
1119 */
1120 --
1121 -- There are six things a person can be:
1122 --
1123 l_newly_elig boolean := FALSE; -- elig and prev inelig
1124 l_newly_inelig boolean := FALSE; -- inelig and prev elig
1125 l_first_elig boolean := FALSE; -- elig and prev did not exist
1126 l_first_inelig boolean := FALSE; -- inelig and prev did not exist
1127 l_still_elig boolean := FALSE; -- elig and still elig
1128 l_still_inelig boolean := FALSE; -- elig and still elig
1129 --
1130 -- This flag covers the case where a person is first time in-eligible
1131 -- but we do not want to track in-eligibility.
1132 --
1133 /*PLEASE NOTE THE FOLLOWING:
1134
1135 1. Option eligibility is written to ben_elig_per_opt_f
1136 2. Plan and Program eligibility is written to ben_elig_per_f
1137 3. When a person is found eligible or ineligible for a pgm, pl or oipl,
1138 a check for previous eligibility/ineligibility will determine
1139 whether a new row will be inserted or an existing row will be
1140 updated.
1141 4. If a person is still eligible or ineligible, then nothing is done.
1142 5. If a person is newly eligible, then a new row will be inserted.
1143 6. If a person is newly ineligible, then an existing row will be
1144 updated.
1145 7. If a person is first-time eligible, then a new row will be inserted.
1146 8. If a person is first-time ineligible, and the track ineligible persons
1147 flag is 'Y' on the program, plan or option we are processing then a
1148 new row will be inserted with elig_flag of 'N'.
1149 9. If a person is found "eligible again"--meaning the history of the
1150 person shows that they were once eligible, then found ineligible
1151 and now are eligible again, then that person will be treated as
1152 though they are newly eligible, i.e. a row will be inserted.
1153 */
1154 --
1155 l_epo_row ben_derive_part_and_rate_facts.g_cache_structure;
1156 l_oiplipepo_row ben_derive_part_and_rate_facts.g_cache_structure;
1157 l_oiplippep_row ben_derive_part_and_rate_facts.g_cache_structure;
1158 l_pep_row ben_derive_part_and_rate_facts.g_cache_structure;
1159 --
1160 l_new_per_in_ler_id ben_elig_per_f.per_in_ler_id%type;
1161 l_per_in_ler_id ben_elig_per_f.per_in_ler_id%type;
1162 l_prev_per_in_ler_id ben_elig_per_f.per_in_ler_id%type;
1163 l_elig_per_id ben_elig_per_f.elig_per_id%TYPE;
1164 l_elig_per_elig_flag ben_elig_per_f.elig_flag%TYPE;
1165 l_object_version_number ben_elig_per_f.object_version_number%TYPE;
1166 l_object_version_number_opt ben_elig_per_opt_f.object_version_number%type;
1167 l_t_object_version_number ben_elig_per_opt_f.object_version_number%type;
1168 l_p_object_version_number ben_elig_per_f.object_version_number%type;
1169 l_t_effective_dt date;
1170 l_prev_elig boolean := FALSE;
1171 l_prtn_eff_strt_dt date;
1172 l_prtn_eff_end_dt date;
1173 l_elig_per_prtn_strt_dt date;
1174 l_elig_per_prtn_end_dt date;
1175 l_prev_prtn_strt_dt date;
1176 l_prev_prtn_end_dt date;
1177 l_effective_start_date date;
1178 l_effective_end_date date;
1179 l_datetrack_mode varchar2(100);
1180 l_elig_per_opt_id ben_elig_per_opt_f.elig_per_opt_id%type;
1181 l_elig_per_oiplip_id ben_elig_per_opt_f.elig_per_opt_id%type;
1182 l_effective_start_date_opt date;
1183 l_effective_end_date_opt date;
1184 l_opt_elig_flag ben_elig_per_opt_f.elig_flag%type;
1185 l_opt_id ben_opt_f.opt_id%type;
1186 l_pl_id ben_pl_f.pl_id%type;
1187 l_start_or_end varchar2(1);
1188 l_end_dt_plus_one date;
1189 l_wait_perd_cmpltn_dt date;
1190 l_wait_perd_strt_dt date;
1191 l_after_wtg_prtn_strt_dt date;
1192 l_correction boolean;
1193 l_update boolean;
1194 l_update_override boolean;
1195 l_update_change_insert boolean;
1196 l_oipl_rec ben_cobj_cache.g_oipl_inst_row;
1197 --
1198 l_envpgm_id number;
1199 l_envptip_id number;
1200 l_envplip_id number;
1201 l_envpl_id number;
1202 l_effective_dt date := least(p_effective_date,nvl(p_lf_evt_ocrd_dt,p_effective_date));
1203 --
1204 --FONM
1205 l_fonm_cvg_strt_dt DATE ;
1206 --END FONM
1207
1208 -- iRec
1209 l_env_rec ben_env_object.g_global_env_rec_type;
1210 l_benmngle_parm_rec benutils.g_batch_param_rec;
1211 -- End iRec
1212 /* 4968123
1213 -- Cursor to check previous eligibility for plan/program.
1214 --
1215 CURSOR c_prev_elig_check
1216 (c_person_id in number
1217 ,c_pgm_id in number
1218 ,c_pl_id in number
1219 ,c_ptip_id in number
1220 ,c_effective_date in date
1221 )
1222 IS
1223 select pep.elig_per_id,
1224 pep.elig_flag,
1225 pep.prtn_strt_dt,
1226 pep.prtn_end_dt,
1227 pep.per_in_ler_id,
1228 pep.object_version_number
1229 from ben_elig_per_f pep,
1230 ben_per_in_ler pil
1231 where pep.person_id = c_person_id
1232 and nvl(pep.pgm_id,-1) = c_pgm_id
1233 and nvl(pep.pl_id,-1) = c_pl_id
1234 and pep.plip_id is null
1235 and nvl(pep.ptip_id,-1) = c_ptip_id
1236 and c_effective_date
1237 between pep.effective_start_date
1238 and pep.effective_end_date
1239 and pil.per_in_ler_id(+)=pep.per_in_ler_id
1240 and pil.business_group_id(+)=pep.business_group_id
1241 and ( pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
1242 or pil.per_in_ler_stat_cd is null -- outer join condition
1243 )
1244 and nvl(pil.assignment_id, -9999) = decode ( l_benmngle_parm_rec.mode_cd,
1245 'I',
1246 ben_manage_life_events.g_irec_ass_rec.assignment_id,
1247 nvl(pil.assignment_id, -9999) ) -- iRec : Match assignment_id for iRec
1248 ;
1249 */
1250 /* 4968123
1251 --
1252 -- Cursor to check previous eligibility for option.
1253 --
1254 cursor c_prev_opt_elig_check
1255 (c_person_id in number
1256 ,c_effective_date in date
1257 ,c_pl_id in number
1258 ,c_opt_id in number
1259 )
1260 is
1261 select epo.elig_per_opt_id,
1262 epo.elig_flag,
1263 epo.prtn_strt_dt,
1264 epo.prtn_end_dt,
1265 epo.object_version_number,
1266 pep.elig_per_id,
1267 epo.per_in_ler_id,
1268 pep.prtn_strt_dt,
1269 pep.prtn_end_dt
1270 from ben_elig_per_opt_f epo,
1271 ben_per_in_ler pil,
1272 ben_elig_per_f pep
1273 where pep.person_id = c_person_id
1274 and pep.pl_id = c_pl_id
1275 and epo.opt_id = c_opt_id
1276 and pep.elig_per_id = epo.elig_per_id
1277 and pep.pgm_id is null
1278 and c_effective_date
1279 between pep.effective_start_date
1280 and pep.effective_end_date
1281 and c_effective_date
1282 between epo.effective_start_date
1283 and epo.effective_end_date
1284 and pil.per_in_ler_id(+)=epo.per_in_ler_id
1285 and pil.business_group_id(+)=epo.business_group_id
1286 and ( pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
1287 or pil.per_in_ler_stat_cd is null)
1288 and nvl(pil.assignment_id,-9999) = decode ( l_benmngle_parm_rec.mode_cd,
1289 'I',
1290 ben_manage_life_events.g_irec_ass_rec.assignment_id,
1291 nvl(pil.assignment_id, -9999) ); -- iRec : Match assignment_id for iRec
1292 */
1293 --
1294 cursor c_prev_oiplip_elig_check
1295 (c_person_id in number
1296 ,c_effective_date in date
1297 ,c_pgm_id in number
1298 ,c_plip_id in number
1299 ,c_opt_id in number
1300 )
1301 is
1302 select epo.elig_per_opt_id,
1303 epo.elig_per_id,
1304 epo.effective_start_date,
1305 epo.object_version_number
1306 from ben_elig_per_opt_f epo,
1307 ben_per_in_ler pil,
1308 ben_elig_per_f pep
1309 where pep.person_id = c_person_id
1310 and pep.pgm_id = c_pgm_id
1311 and pep.plip_id = c_plip_id
1312 and epo.opt_id = c_opt_id
1313 and pep.elig_per_id = epo.elig_per_id
1314 and c_effective_date
1315 between pep.effective_start_date
1316 and pep.effective_end_date
1317 and c_effective_date
1318 between epo.effective_start_date
1319 and epo.effective_end_date
1320 and pil.per_in_ler_id(+)=epo.per_in_ler_id
1321 and pil.business_group_id(+)=epo.business_group_id
1322 and ( pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
1323 or pil.per_in_ler_stat_cd is null) ;
1324 --
1325 l_prev_oiplip_elig_check c_prev_oiplip_elig_check%rowtype;
1326 --
1327 -- Cursor to check for overlapping eligiblitiy
1328 --
1329 CURSOR c_overlap
1330 (c_prtn_eff_strt_dt in date
1331 ,c_elig_flag in varchar2
1332 ,c_add_one in number
1333 )
1334 is
1335 select pep.prtn_strt_dt
1336 from ben_elig_per_f pep,
1337 ben_per_in_ler pil
1338 where pep.person_id = p_person_id
1339 and nvl(pep.pgm_id,-1) =
1340 nvl(p_pgm_id,nvl(l_envpgm_id,-1))
1341 and nvl(pep.pl_id,-1) = nvl(p_pl_id,-1)
1342 and nvl(pep.plip_id,-1) = nvl(p_plip_id,-1)
1343 and nvl(pep.ptip_id,-1) = nvl(p_ptip_id,-1)
1344 and c_prtn_eff_strt_dt between pep.prtn_strt_dt
1345 and (pep.prtn_end_dt + c_add_one)
1346 and pep.elig_flag = c_elig_flag
1347 and pil.per_in_ler_id(+)=pep.per_in_ler_id
1348 and pil.business_group_id(+)=pep.business_group_id
1349 and ( pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
1350 or pil.per_in_ler_stat_cd is null -- outer join condition
1351 );
1352 --
1353 cursor c_get_pl_id(c_effective_date date) is select pl_id
1354 from ben_plip_f cpp
1355 where cpp.plip_id = p_plip_id
1356 and c_effective_date
1357 between cpp.effective_start_date
1358 and cpp.effective_end_date;
1359 --
1360 cursor c_get_pl_from_ptip(c_effective_date date) is
1361 select pl.pl_id
1362 from ben_ptip_f ctp,ben_pl_f pl
1363 where ctp.ptip_id = p_ptip_id
1364 and pl.pl_typ_id = ctp.pl_typ_id
1365 and c_effective_date
1366 between ctp.effective_start_date
1367 and ctp.effective_end_date
1368 and c_effective_date
1369 between pl.effective_start_date
1370 and pl.effective_end_date;
1371 --
1372 l_overlap c_overlap%ROWTYPE;
1373 --
1374 -- Cursor to check for overlapping eligiblitiy
1375 --
1376 cursor c_opt_overlap
1377 (c_prtn_eff_strt_dt in date
1378 ,c_elig_flag in varchar2
1379 ,c_add_one in number
1380 )
1381 is
1382 select epo.prtn_strt_dt
1383 from ben_elig_per_opt_f epo,
1384 ben_elig_per_f pep,
1385 ben_per_in_ler pil
1386 where pep.person_id = p_person_id
1387 and pep.pl_id = l_envpl_id
1388 and nvl(pep.pgm_id,-1) = nvl(l_envpgm_id,-1)
1389 and pep.elig_per_id = epo.elig_per_id
1390 and c_prtn_eff_strt_dt
1391 between epo.prtn_strt_dt
1392 and (epo.prtn_end_dt + c_add_one)
1393 and epo.opt_id = l_oipl_rec.opt_id
1394 and epo.elig_flag = c_elig_flag
1395 and pil.per_in_ler_id(+)=epo.per_in_ler_id
1396 and pil.business_group_id(+)=epo.business_group_id+0
1397 and ( pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
1398 or pil.per_in_ler_stat_cd is null);
1399 --
1400 l_opt_overlap c_opt_overlap%ROWTYPE;
1401 --
1402 -- CWB changes : Modified cusrsor
1403 --
1404 -- bug 3001411 - Presence of unrestricted LE between eff date and
1405 -- waiting perd compltn date should not considered as a reason to
1406 -- make the person ineligible. So added the not in clause for ler.typ_cd
1407 -- As per PM, we should ignore the 'unrestricted' , Absences, CWB and
1408 -- any 'Non-Benefits' type of life event.
1409 --
1410 -- iRec : Added mode iRecruitmnent (I)
1411 cursor c_ptnl_le(v_wait_end_dt date) is
1412 select 's'
1413 from ben_ptnl_ler_for_per ptl,
1414 ben_ler_f ler
1415 where ptl.person_id = p_person_id
1416 and ptl.ler_id <> p_ler_id
1417 and ler.ler_id = ptl.ler_id
1418 and ler.typ_cd not in ('COMP', 'ABS', 'SCHEDDU', 'GSP', 'IREC') -- iRec
1419 and ptl.ptnl_ler_for_per_stat_cd <> 'VOIDD'
1420 and ptl.lf_evt_ocrd_dt
1421 between p_effective_date
1422 and v_wait_end_dt
1423 and ptl.business_group_id = p_business_group_id;
1424 --
1425 cursor c_plip_ordr(c_effective_date date ) is
1426 select plip.ordr_num from ben_plip_f plip
1427 where plip.pgm_id = nvl(p_pgm_id,l_envpgm_id)
1428 and pl_id = p_pl_id
1429 and c_effective_date
1430 between plip.effective_start_date
1431 and plip.effective_end_date
1432 and plip.business_group_id = p_business_group_id;
1433
1434 l_ptnl_le c_ptnl_le%rowtype;
1435 --
1436 l_trk_inelig_per_flag varchar2(30);
1437 l_pgm_rec ben_cobj_cache.g_pgm_inst_row;
1438 l_pl_rec ben_cobj_cache.g_pl_inst_row;
1439 l_plip_rec ben_cobj_cache.g_plip_inst_row;
1440 l_ptip_rec ben_cobj_cache.g_ptip_inst_row;
1441 l_prtn_st_dt_aftr_wtg date;
1442 l_prtn_eff_strt_dt_cd varchar2(80);
1443 l_prtn_eff_strt_dt_rl number(15);
1444 l_plan_ordr_num ben_pl_f.ordr_num%type;
1445 --
1446 l_comp_rec ben_derive_part_and_rate_facts.g_cache_structure;
1447 l_oiplip_rec ben_derive_part_and_rate_facts.g_cache_structure;
1448 l_pil_rec ben_per_in_ler%rowtype;
1449 l_prev_eligibility boolean;
1450 --
1451 l_oiplippep_dets ben_pep_cache.g_pep_rec;
1452 l_plnpep_dets ben_pep_cache.g_pep_rec;
1453 --
1454 l_elig_flag varchar2(1);
1455 l_prtn_strt_dt date;
1456 l_oiplip_pep_id number;
1457 l_oiplip_epo_id number;
1458 l_oiplip_elig_flag varchar2(1);
1459 l_old_age_val number;
1460 l_old_los_val number;
1461 l_count_icm1 number;
1462 l_count_icm number;
1463 l_count_icm3 number;
1464 l_count_icm31 number :=0;
1465
1466
1467 /* Bug 9020962 */
1468 /* Cursor to get the previous per_in_ler_id*/
1469 cursor c_prev_pil(c_per_in_ler_id number ) is
1470 select pil.per_in_ler_id
1471 from ben_per_in_ler pil,
1472 ben_ler_f ler
1473 where pil.per_in_ler_id not in (c_per_in_ler_id)
1474 and pil.person_id = p_person_id
1475 and pil.ler_id = ler.ler_id
1476 and p_effective_date between
1477 ler.effective_start_date and ler.effective_end_date
1478 and ler.typ_cd not in ('IREC', 'SCHEDDU', 'COMP', 'GSP', 'ABS')
1479 and pil.per_in_ler_stat_cd not in('BCKDT', 'VOIDD')
1480 order by pil.lf_evt_ocrd_dt desc;
1481
1482 /* Cursor to get the eligibility record */
1483 cursor c_elig_rec(c_elig_per_id number,c_per_in_ler_id number) is
1484 select * from ben_elig_per_f
1485 where elig_per_id = c_elig_per_id
1486 and per_in_ler_id = c_per_in_ler_id;
1487
1488 l_prev_pil_id number;
1489
1490 l_elig_per_rec c_elig_rec%rowtype;
1491
1492 /* Cursor to check whether future eligibility record exists for the previous
1493 life event */
1494 cursor c_elig_per_id(c_per_in_ler_id number,
1495 c_pl_id number,
1496 c_pgm_id number,
1497 c_ptip_id number,
1498 c_plip_id number,
1499 c_effective_date date) is
1500 select * from ben_elig_per_f pep
1501 where nvl(pep.pgm_id,-1) = nvl(c_pgm_id,-1)
1502 and nvl(pep.pl_id,-1) = nvl(c_pl_id,-1)
1503 and nvl(pep.plip_id,-1) = nvl(c_plip_id ,-1)
1504 and nvl(pep.ptip_id,-1) = nvl(c_ptip_id,-1)
1505 and pep.per_in_ler_id = c_per_in_ler_id
1506 and c_effective_date < pep.effective_start_date;
1507
1508 l_ftr_elig_per_rec c_elig_rec%rowtype;
1509 /* End of Bug 9020962*/
1510 --------------------------------------------------------------------------------
1511 --Bug 12732878 changes start
1512
1513 cursor c_elig_opt_rec(c_elig_per_opt_id number,c_per_in_ler_id number)
1514 is
1515 select * from ben_elig_per_opt_f
1516 where elig_per_opt_id = c_elig_per_opt_id
1517 and per_in_ler_id = c_per_in_ler_id;
1518
1519 l_elig_per_opt_rec c_elig_opt_rec%rowtype;
1520
1521
1522 cursor c_elig_per_opt_id(c_per_in_ler_id number,
1523 c_elig_per_opt_id number,
1524 c_effective_date date)
1525 is
1526 select * from ben_elig_per_opt_f epo
1527 where epo.elig_per_opt_id = c_elig_per_opt_id
1528 and epo.per_in_ler_id = c_per_in_ler_id
1529 and c_effective_date < epo.effective_start_date;
1530
1531 l_ftr_elig_per_opt_rec c_elig_per_opt_id%rowtype;
1532
1533 --Bug 12732878 changes end;
1534 -------------------------------------------------------------------------------
1535
1536 --
1537 begin
1538 --
1539 g_debug := hr_utility.debug_enabled;
1540 --
1541 if g_debug then
1542 --
1543 hr_utility.set_location('Entering : ben_determine_eligibility2.check_prev_elig', 10);
1544 hr_utility.set_location('p_pgm_id -> ' ||p_pgm_id ,223);
1545 hr_utility.set_location('p_ptip_id -> ' ||p_ptip_id,223);
1546 hr_utility.set_location('p_plip_id -> ' ||p_plip_id,223);
1547 hr_utility.set_location('p_pl_id -> ' ||p_pl_id ,223);
1548 hr_utility.set_location('p_oipl_id -> ' ||p_oipl_id,223);
1549 --
1550 end if;
1551 --
1552 -- iRec
1553 ben_env_object.get(p_rec => l_env_rec);
1554 benutils.get_batch_parameters( p_benefit_action_id => l_env_rec.benefit_action_id
1555 ,p_rec => l_benmngle_parm_rec);
1556 hr_utility.set_location('l_benmngle_parm_rec.mode_cd'||l_benmngle_parm_rec.mode_cd,125);
1557 -- iRec
1558 if ben_manage_life_events.fonm = 'Y'
1559 and ben_manage_life_events.g_fonm_cvg_strt_dt is not null then
1560 --
1561 l_fonm_cvg_strt_dt := ben_manage_life_events.g_fonm_cvg_strt_dt ;
1562 --
1563 end if;
1564 --
1565 l_effective_dt := nvl(l_fonm_cvg_strt_dt,l_effective_dt);
1566 --
1567 -- First check to see if there is a waiting period for the comp object being
1568 -- processed. This applies only if the participant is found first-time or
1569 -- newly eligible (after being ineligible).
1570 --
1571 -- Assign comp object locals
1572 --
1573 l_envpgm_id := p_comp_obj_tree_row.par_pgm_id;
1574 l_envptip_id := p_comp_obj_tree_row.par_ptip_id;
1575 l_envplip_id := p_comp_obj_tree_row.par_plip_id;
1576 l_envpl_id := p_comp_obj_tree_row.par_pl_id;
1577 --
1578 -- get the per_in_ler_id
1579 --
1580 l_pil_rec := p_pil_row;
1581 --
1582 l_new_per_in_ler_id:=l_pil_rec.per_in_ler_id;
1583 --
1584 if p_elig_flag = TRUE then
1585 --
1586 if g_debug then
1587 hr_utility.set_location('Wait period: ben_determine_eligibility2.check_prev_elig', 10);
1588 end if;
1589 --
1590 IF nvl(l_env_rec.mode_cd,'~') <> 'D' THEN
1591 --
1592 ben_det_wait_perd_cmpltn.main
1593 (p_comp_obj_tree_row => p_comp_obj_tree_row
1594 ,p_person_id => p_person_id
1595 ,p_effective_date => p_effective_date
1596 ,p_business_group_id => p_business_group_id
1597 ,p_ler_id => l_pil_rec.ler_id
1598 ,p_oipl_id => p_oipl_id
1599 ,p_pl_id => p_pl_id
1600 ,p_pgm_id => p_pgm_id
1601 ,p_plip_id => p_plip_id
1602 ,p_ptip_id => p_ptip_id
1603 ,p_lf_evt_ocrd_dt => l_pil_rec.lf_evt_ocrd_dt
1604 ,p_ntfn_dt => l_pil_rec.ntfn_dt
1605 ,p_return_date => l_wait_perd_cmpltn_dt
1606 ,p_wait_perd_strt_dt => l_wait_perd_strt_dt
1607 );
1608
1609 /*Bug 10030441; If a Life Event is processed after the waiting period completion date
1610 for a plan, then set the l_wait_perd_cmpltn_dt to null. Since participant has satisfied the
1611 waiting period, there is no need to determine the participation start date code after the
1612 l_wait_perd_cmpltn_dt*/
1613 if(l_wait_perd_cmpltn_dt < p_lf_evt_ocrd_dt ) then
1614 l_wait_perd_strt_dt := null;
1615 l_wait_perd_cmpltn_dt := null;
1616 end if;
1617 /*End of Bug 10030441 */
1618 --
1619 if g_debug then
1620 hr_utility.set_location('Dn Wait period: ben_determine_eligibility2.check_prev_elig', 10);
1621 hr_utility.set_location('Wait period strt dt : ' || l_wait_perd_strt_dt, 10);
1622 end if;
1623 if l_wait_perd_cmpltn_dt is not null then
1624 -- If a potential life event exists between the effective date and the
1625 -- waiting period completion date, then raise an error and stop further
1626 -- processing of this comp object. Also write a descriptive message to the
1627 -- log.
1628 hr_utility.set_location('Checking for ptnl life events ben_determine_eligibility2.check_prev_elig', 10);
1629
1630 open c_ptnl_le(l_wait_perd_cmpltn_dt);
1631 fetch c_ptnl_le into l_ptnl_le;
1632 if c_ptnl_le%found
1633 and l_benmngle_parm_rec.mode_cd <> 'I' --iRec:Do not raise the error when BENMNGLE processed in iRecruitment mode
1634 then
1635 close c_ptnl_le;
1636 fnd_message.set_name ('BEN','BEN_93992_PTNL_IN_WTG_PERD'); -- 3597303
1637 hr_utility.set_location('PTNL LE FOUND ben_determine_eligibility2.check_prev_elig', 10);
1638 ben_manage_life_events.g_output_string :=
1639 ben_manage_life_events.g_output_string||
1640 'Elg: Yes '||-- 3597303
1641 'Warning:'||fnd_message.get;
1642 --
1643 -- DDW change, set object ineligible
1644 --
1645 p_elig_flag := true;---false; -- bug 3597303
1646 --
1647 else
1648 hr_utility.set_location('PTNL LE not found. Call BENDRPAR', 10);
1649 close c_ptnl_le;
1650
1651 -- There's no potential life event. Re determine temporal factors using
1652 -- the wait perd cmpltn date as the life event ocrd date or ntfn date.
1653 ben_derive_part_and_rate_facts.derive_rates_and_factors
1654 (p_comp_obj_tree_row => p_comp_obj_tree_row
1655 --
1656 ,p_per_row => p_per_row
1657 ,p_empasg_row => p_empasg_row
1658 ,p_benasg_row => p_benasg_row
1659 ,p_pil_row => p_pil_row
1660 --
1661 ,p_person_id => p_person_id
1662 ,p_business_group_id => p_business_group_id
1663 ,p_pgm_id => p_pgm_id
1664 ,p_pl_id => p_pl_id
1665 ,p_oipl_id => p_oipl_id
1666 ,p_plip_id => p_plip_id
1667 ,p_ptip_id => p_ptip_id
1668 ,p_ptnl_ler_trtmt_cd => NULL
1669 ,p_comp_rec => l_comp_rec
1670 ,p_oiplip_rec => l_oiplip_rec
1671 ,p_effective_date => p_effective_date
1672 ,p_lf_evt_ocrd_dt => l_wait_perd_cmpltn_dt
1673 );
1674 --RCHASE bug 1531030. Was not passing back updated values.
1675 p_comp_rec:=l_comp_rec;
1676 p_oiplip_rec:=l_oiplip_rec;
1677 --
1678 --
1679 -- Check if any temporal life events got created because of the call
1680 -- to BENDRPAR above and if yes, stop processing and log message.
1681 --
1682 open c_ptnl_le(l_wait_perd_cmpltn_dt);
1683 fetch c_ptnl_le into l_ptnl_le;
1684
1685 if c_ptnl_le%found
1686 and l_benmngle_parm_rec.mode_cd <> 'I' --iRec:Do not raise the error when BENMNGLE processed in iRecruitment mode
1687 then
1688 close c_ptnl_le;
1689 fnd_message.set_name ('BEN','BEN_93992_PTNL_IN_WTG_PERD'); -- 3597303
1690 ben_manage_life_events.g_output_string :=
1691 ben_manage_life_events.g_output_string||
1692 'Elg: Yes '||-- 3597303
1693 'Warning:'||fnd_message.get;
1694 --
1695 -- DDW change, set object ineligible
1696 --
1697 p_elig_flag := true; -- 3597303
1698 --
1699 -- 1517275 : added else and moved end if
1700 -- and hr_utility.set_location
1701 -- tm 11/29
1702 else -- no rows returned
1703 hr_utility.set_location('TEMPORAL PTNL LE not found.', 15);
1704 close c_ptnl_le;
1705 end if;
1706 end if; -- c_ptnl_le
1707 end if; -- wait_perd_cmpltn_dt
1708 end if; --'D' mode
1709 end if; -- elig_flag
1710 --
1711 -- Check for previous eligibility for oipl.
1712 --
1713 if p_oipl_id is not null then --a
1714 --
1715 l_oipl_rec := ben_cobj_cache.g_oipl_currow;
1716 --
1717 if g_debug then
1718 hr_utility.set_location('open c_prvoptelch ben_determine_eligibility2.check_prev_elig', 10);
1719 end if;
1720 --
1721 -- Check for oipl in a program
1722 --
1723 if l_envpgm_id is not null then
1724 --
1725 --BUG 3327841 this needs to be cached with right l_effective_dt
1726 --Remember that as part of PLAN elig process, that record got updated
1727 --and we need to cache it again so that we get the previus epo records
1728 --with current pep record which fetched the right l_epo_row.prtn_strt_dt
1729 --like it is done in the c_prev_opt_elig_check cursor in the else clause
1730 --below.
1731 --
1732 -- ben_pep_cache.clear_down_cache ;
1733 -- clear_down_cache is not required as we have to use this
1734 -- output for only the previous eligibility. But keep in mind that the cursor
1735 -- c_prev_opt_elig_check return the previous elig_per_opt record with current
1736 -- elig_per record while evaluating the options.
1737 --
1738 --reversed the fix made for 5682845 - it creates new set of rows
1739
1740 ben_pep_cache.get_pilepo_dets
1741 (p_person_id => p_person_id
1742 ,p_business_group_id => p_business_group_id
1743 ,p_effective_date => l_effective_dt
1744 ,p_pgm_id => l_envpgm_id
1745 -- ,p_plip_id => l_envplip_id --Bug 5682845 passed the plipid
1746 ,p_pl_id => l_envpl_id
1747 ,p_opt_id => l_oipl_rec.opt_id
1748 ,p_date_sync => TRUE
1749 ,p_inst_row => l_epo_row
1750 );
1751 --
1752 if g_debug then
1753 hr_utility.set_location('ik-l_effective_dt '||l_oipl_rec.opt_id,10);
1754 hr_utility.set_location('ik-l_oipl_rec.opt_id '||l_oipl_rec.opt_id,10);
1755 hr_utility.set_location('ik-l_epo_row.elig_per_opt_id '||l_epo_row.elig_per_opt_id,10);
1756 end if;
1757 --
1758 if l_epo_row.elig_per_opt_id is null then
1759 --
1760 l_prev_eligibility := false;
1761 --
1762 else
1763 --
1764 l_prev_eligibility := true;
1765 --
1766 end if;
1767 --
1768 l_elig_per_opt_id := l_epo_row.elig_per_opt_id;
1769 l_opt_elig_flag := l_epo_row.elig_flag;
1770 l_prev_prtn_strt_dt := l_epo_row.prtn_strt_dt;
1771 l_prev_prtn_end_dt := l_epo_row.prtn_end_dt;
1772 l_object_version_number_opt := l_epo_row.object_version_number;
1773 l_elig_per_id := l_epo_row.elig_per_id;
1774 l_per_in_ler_id := l_epo_row.per_in_ler_id;
1775 l_old_age_val := l_epo_row.age_val;
1776 l_old_los_val := l_epo_row.los_val;
1777 --
1778 --BUG 3327841 Getting EOT for EPE and ECR records due wrong
1779 --assignment we do here.
1780 --
1781 /*
1782 l_elig_per_prtn_strt_dt := l_epo_row.prtn_strt_dt;
1783 l_elig_per_prtn_end_dt := l_epo_row.prtn_end_dt;
1784 */
1785 l_elig_per_prtn_strt_dt :=l_epo_row.pep_prtn_strt_dt;
1786 l_elig_per_prtn_end_dt :=l_epo_row.pep_prtn_end_dt;
1787 --
1788 -- Check for oipl not in a program
1789 --
1790 else
1791 --
1792 if g_debug then
1793 hr_utility.set_location('fetch c_prvoptelch ben_determine_eligibility2.check_prev_elig', 10);
1794 end if;
1795 --
1796 ben_determine_eligibility4.prev_opt_elig_check
1797 (p_person_id => p_person_id
1798 ,p_effective_date => l_effective_dt
1799 ,p_pl_id => l_envpl_id
1800 ,p_opt_id => l_oipl_rec.opt_id
1801 ,p_mode_cd => l_benmngle_parm_rec.mode_cd
1802 ,p_irec_asg_id => ben_manage_life_events.g_irec_ass_rec.assignment_id
1803 --
1804 ,p_prev_eligibility => l_prev_eligibility
1805 ,p_elig_per_opt_id => l_elig_per_opt_id
1806 ,p_opt_elig_flag => l_opt_elig_flag
1807 ,p_prev_prtn_strt_dt => l_prev_prtn_strt_dt
1808 ,p_prev_prtn_end_dt => l_prev_prtn_end_dt
1809 ,p_object_version_number_opt => l_object_version_number_opt
1810 ,p_elig_per_id => l_elig_per_id
1811 ,p_per_in_ler_id => l_per_in_ler_id
1812 ,p_elig_per_prtn_strt_dt => l_elig_per_prtn_strt_dt
1813 ,p_elig_per_prtn_end_dt => l_elig_per_prtn_end_dt
1814 ,p_prev_age_val => l_old_age_val
1815 ,p_prev_los_val => l_old_los_val
1816 );
1817 --
1818 l_t_object_version_number := l_object_version_number_opt;
1819 l_t_effective_dt := l_effective_dt;
1820 --
1821 /* 4968123
1822 open c_prev_opt_elig_check
1823 (c_person_id => p_person_id
1824 ,c_effective_date => l_effective_dt
1825 ,c_pl_id => l_envpl_id
1826 ,c_opt_id => l_oipl_rec.opt_id
1827 );
1828 fetch c_prev_opt_elig_check into l_elig_per_opt_id,
1829 l_opt_elig_flag,
1830 l_prev_prtn_strt_dt,
1831 l_prev_prtn_end_dt,
1832 l_object_version_number_opt,
1833 l_elig_per_id,
1834 l_per_in_ler_id,
1835 l_elig_per_prtn_strt_dt,
1836 l_elig_per_prtn_end_dt;
1837 if c_prev_opt_elig_check%notfound then
1838 --
1839 l_prev_eligibility := false;
1840 --
1841 else
1842 --
1843 l_prev_eligibility := true;
1844 --
1845 end if;
1846 close c_prev_opt_elig_check;
1847 --
1848 */
1849 if g_debug then
1850 hr_utility.set_location('Dn fetch c_prvoptelch ben_determine_eligibility2.check_prev_elig', 10);
1851 end if;
1852 end if;
1853 --
1854 l_prev_per_in_ler_id := l_per_in_ler_id;
1855 --
1856 if l_new_per_in_ler_id is not null then
1857 --
1858 l_per_in_ler_id:=l_new_per_in_ler_id;
1859 --
1860 end if;
1861 --
1862 if not l_prev_eligibility
1863 then --b
1864 -- No record exist Person not previously elig or inelig for selctd oipl
1865 if p_elig_flag then
1866 --
1867 hr_utility.set_location ('oipl first elig',121);
1868 l_first_elig := true;
1869 l_start_or_end := 'S';
1870 fnd_message.set_name ('BEN','BEN_91385_FIRST_ELIG');
1871 benutils.write(p_text => fnd_message.get);
1872 --
1873 else
1874 --
1875 fnd_message.set_name ('BEN','BEN_92533_FIRST_INELIG2');
1876 benutils.write(p_text => fnd_message.get);
1877 -- only continue with program and call of api if we want to track
1878 -- inelig people.
1879 l_trk_inelig_per_flag := l_oipl_rec.trk_inelig_per_flag;
1880 --
1881 if l_trk_inelig_per_flag = 'Y' then
1882 --
1883 hr_utility.set_location ('first inelig',121);
1884 l_first_inelig := true;
1885 l_start_or_end := 'E';
1886 --
1887 else
1888 --
1889 -- Set transition state for processing only. Elig
1890 -- per is not written
1891 p_first_inelig := true;
1892 -- person is inelig for the first time
1893 -- and not being recorded.
1894 if instr(ben_manage_life_events.g_output_string,
1895 'Elg:') = 0 then
1896 --
1897 ben_manage_life_events.g_output_string :=
1898 ben_manage_life_events.g_output_string||
1899 'Elg: No '||
1900 'Rsn: Inelig FT';
1901 --
1902 end if;
1903 --
1904 return;
1905 --
1906 end if;
1907 --
1908 end if;
1909 --
1910 elsif l_prev_eligibility
1911 then--b
1912 --
1913 if l_opt_elig_flag = 'Y' and p_elig_flag then --d
1914 -- Person still eligible, do nothing.
1915 fnd_message.set_name ('BEN','BEN_91345_ELIG_PREV_ELIG');
1916 benutils.write(p_text => fnd_message.get);
1917 --
1918 if instr(ben_manage_life_events.g_output_string,
1919 'Elg:') = 0 then
1920 --
1921 ben_manage_life_events.g_output_string :=
1922 ben_manage_life_events.g_output_string||
1923 'Elg: Yes '||
1924 'Rsn: Still Elig';
1925 --
1926 end if;
1927 --
1928 hr_utility.set_location ('still elig',121); --Since we clear cache after every run so even though
1929 l_start_or_end := 'S'; -- still elig need to build the cache
1930 l_still_elig := true;
1931 --
1932 --return;
1933 --
1934 elsif l_opt_elig_flag = 'Y' and p_elig_flag = false then --d
1935 -- person is newly inelig
1936 hr_utility.set_location ('newly inelig',121);
1937 l_newly_inelig := true;
1938 l_start_or_end := 'E';
1939 fnd_message.set_name('BEN','BEN_91347_NOT_ELIG_PREV_ELIG');
1940 benutils.write(p_text => fnd_message.get);
1941 --
1942 elsif l_opt_elig_flag = 'N' and p_elig_flag = false then --d
1943 -- person is still inelig, do nothing.
1944 fnd_message.set_name('BEN','BEN_91348_NOT_ELIG_PREV_NT_ELG');
1945 benutils.write(p_text => fnd_message.get);
1946 --
1947 -- Set transition state for processing only. Elig
1948 -- per is not written
1949 --
1950 p_still_inelig := TRUE; --Bug 9789915 : changed l_still_inelig to p_still_inelig
1951 /*Fidelity enh inelg to inelg */
1952 if l_benmngle_parm_rec.mode_cd in ('L','C') then
1953 l_trk_inelig_per_flag := l_oipl_rec.trk_inelig_per_flag;
1954 end if;
1955 if g_debug then
1956 hr_utility.set_location ('Track INelig flag'||l_trk_inelig_per_flag,100);
1957 hr_utility.set_location ('age val '||p_comp_rec.age_val,101);
1958 end if;
1959 -- Bug 8542643: Update the still inelig records irrespective of whether
1960 -- old value is greater or new value is greater for age or los
1961 if l_trk_inelig_per_flag = 'Y' then
1962 if p_comp_rec.age_val is not null or
1963 p_comp_rec.los_val is not null
1964 then
1965 if g_debug then
1966 hr_utility.set_location ('New update for elig per opt',100);
1967 end if;
1968 --
1969 l_t_object_version_number := l_object_version_number_opt;
1970 --
1971 -- Start of changes against bug 6601884
1972
1973 -- Get the datetrack update mode. If the record already exists and the effective date is
1974 -- same as start date, then update should be done in correction mode. In that case, the old
1975 -- record should be inserted in the backup table
1976
1977 dt_api.find_dt_upd_modes
1978 (p_effective_date => l_effective_dt,
1979 p_base_table_name => 'BEN_ELIG_PER_OPT_F',
1980 p_base_key_column => 'elig_per_opt_id',
1981 p_base_key_value => l_elig_per_opt_id,
1982 p_correction => l_correction,
1983 p_update => l_update,
1984 p_update_override => l_update_override,
1985 p_update_change_insert => l_update_change_insert);
1986 --
1987 if l_update_override then
1988 l_datetrack_mode := hr_api.g_update_override;
1989
1990 if g_debug then
1991 hr_utility.set_location('EPO l_datetrack_mode '||l_datetrack_mode, 777);
1992 end if;
1993
1994 elsif l_update then
1995 l_datetrack_mode := hr_api.g_update;
1996
1997 if g_debug then
1998 hr_utility.set_location('EPO l_datetrack_mode '||l_datetrack_mode, 777);
1999 end if;
2000 else
2001 l_datetrack_mode := hr_api.g_correction;
2002
2003 if g_debug then
2004 hr_utility.set_location('EPO l_datetrack_mode '||l_datetrack_mode, 777);
2005 end if;
2006 end if;
2007
2008 hr_utility.set_location('EPO l_per_in_ler_id' || l_per_in_ler_id, 777);
2009
2010 -- insert into backup table if updating in correction mode
2011
2012 IF l_datetrack_mode = hr_api.g_correction AND
2013 l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
2014 --
2015 ben_determine_eligibility3.save_to_restore
2016 (p_current_per_in_ler_id => l_per_in_ler_id
2017 ,p_per_in_ler_id => l_prev_per_in_ler_id
2018 ,p_elig_per_id => NULL
2019 ,p_elig_per_opt_id => l_elig_per_opt_id
2020 ,p_effective_date => l_effective_dt
2021 );
2022 --
2023 END IF;
2024 ben_Eligible_Person_perf_api.update_perf_Elig_Person_Option
2025 (p_validate => FALSE,
2026 p_elig_per_opt_id => l_elig_per_opt_id,
2027 p_elig_per_id => l_elig_per_id,
2028 p_effective_start_date => l_effective_start_date,
2029 p_effective_end_date => l_effective_end_date,
2030 p_per_in_ler_id => l_per_in_ler_id,
2031 p_elig_flag => 'N',
2032 p_prtn_strt_dt => l_prtn_strt_dt,
2033 p_prtn_end_dt => null,
2034 p_rt_comp_ref_amt => p_comp_rec.rt_comp_ref_amt,
2035 p_rt_cmbn_age_n_los_val => p_comp_rec.rt_cmbn_age_n_los_val,
2036 p_rt_comp_ref_uom => p_comp_rec.rt_comp_ref_uom,
2037 p_rt_age_val => p_comp_rec.rt_age_val,
2038 p_rt_los_val => p_comp_rec.rt_los_val,
2039 p_rt_hrs_wkd_val => p_comp_rec.rt_hrs_wkd_val,
2040 p_rt_hrs_wkd_bndry_perd_cd => p_comp_rec.rt_hrs_wkd_bndry_perd_cd,
2041 p_rt_age_uom => p_comp_rec.rt_age_uom,
2042 p_rt_los_uom => p_comp_rec.rt_los_uom,
2043 p_rt_pct_fl_tm_val => p_comp_rec.rt_pct_fl_tm_val,
2044 p_rt_frz_los_flag => 'N',
2045 p_rt_frz_age_flag => 'N',
2046 p_rt_frz_cmp_lvl_flag => 'N',
2047 p_rt_frz_pct_fl_tm_flag => 'N',
2048 p_rt_frz_hrs_wkd_flag => 'N',
2049 p_rt_frz_comb_age_and_los_flag => 'N',
2050 p_once_r_cntug_cd => p_comp_rec.once_r_cntug_cd,
2051 p_comp_ref_amt => p_comp_rec.comp_ref_amt,
2052 p_cmbn_age_n_los_val => p_comp_rec.cmbn_age_n_los_val,
2053 p_comp_ref_uom => p_comp_rec.comp_ref_uom,
2054 p_age_val => p_comp_rec.age_val,
2055 p_los_val => p_comp_rec.los_val,
2056 p_hrs_wkd_val => p_comp_rec.hrs_wkd_val,
2057 p_hrs_wkd_bndry_perd_cd => p_comp_rec.hrs_wkd_bndry_perd_cd,
2058 p_age_uom => p_comp_rec.age_uom,
2059 p_los_uom => p_comp_rec.los_uom,
2060 p_pct_fl_tm_val => p_comp_rec.pct_fl_tm_val,
2061 p_frz_los_flag => 'N',
2062 p_frz_age_flag => 'N',
2063 p_frz_cmp_lvl_flag => 'N',
2064 p_frz_pct_fl_tm_flag => 'N',
2065 p_frz_hrs_wkd_flag => 'N',
2066 p_frz_comb_age_and_los_flag => 'N',
2067 p_wait_perd_strt_dt => l_wait_perd_strt_dt,
2068 p_wait_perd_cmpltn_date => l_wait_perd_cmpltn_dt,
2069 p_effective_date => l_effective_dt,
2070 p_object_version_number => l_object_version_number_opt,
2071 p_datetrack_mode => l_datetrack_mode,
2072 p_program_application_id => fnd_global.prog_appl_id,
2073 p_program_id => fnd_global.conc_program_id,
2074 p_request_id => fnd_global.conc_request_id,
2075 p_program_update_date => sysdate);
2076 --
2077
2078 if p_score_tab.count > 0 then
2079 hr_utility.set_location('writing score records ',5.6);
2080 ben_elig_scre_wtg_api.load_score_weight
2081 (p_validate => false
2082 ,p_score_tab => p_score_tab
2083 ,p_effective_date => l_effective_dt
2084 ,p_per_in_ler_id => l_per_in_ler_id /* Bug 4438430 */
2085 ,p_elig_per_id => l_elig_per_id
2086 ,p_elig_per_opt_id => l_elig_per_opt_id);
2087 end if;
2088
2089 -- End of changes against bug 6601884
2090 end if;
2091 -- ICM
2092 IF nvl(l_env_rec.mode_cd,'~') = 'D' THEN
2093 --
2094 IF NOT ben_icm_life_events.g_cache_epo_object.EXISTS(1) THEN
2095 --
2096 l_count_icm1 := 1;
2097 --
2098 ELSE
2099 --
2100 l_count_icm1 := ben_icm_life_events.g_cache_epo_object.LAST + 1;
2101 --
2102 END IF;
2103 --
2104 hr_utility.set_location('Building epo cache1 1'|| l_count_icm1,123);
2105 --
2106 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_id := l_elig_per_id;
2107 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_opt_id := l_elig_per_opt_id;
2108 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_start_date :=l_effective_start_date;
2109 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_end_date :=l_effective_end_date;
2110 ben_icm_life_events.g_cache_epo_object(l_count_icm1).business_group_id := p_business_group_id;
2111 ben_icm_life_events.g_cache_epo_object(l_count_icm1).per_in_ler_id :=l_per_in_ler_id;
2112 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_strt_dt := l_prtn_strt_dt;
2113 ben_icm_life_events.g_cache_epo_object(l_count_icm1).opt_id := l_oipl_rec.opt_id;
2114 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_end_dt := null;
2115 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_strt_dt := l_wait_perd_strt_dt;
2116 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_flag :='N';
2117 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_amt := p_comp_rec.comp_ref_amt;
2118 ben_icm_life_events.g_cache_epo_object(l_count_icm1).cmbn_age_n_los_val := p_comp_rec.cmbn_age_n_los_val;
2119 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_uom := p_comp_rec.comp_ref_uom;
2120 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_val := p_comp_rec.age_val;
2121 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_uom := p_comp_rec.age_uom;
2122 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_val := p_comp_rec.los_val;
2123 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_uom := p_comp_rec.los_uom;
2124 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_val := p_comp_rec.hrs_wkd_val;
2125 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_cmpltn_date := l_wait_perd_cmpltn_dt;
2126 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_bndry_perd_cd := p_comp_rec.hrs_wkd_bndry_perd_cd;
2127 ben_icm_life_events.g_cache_epo_object(l_count_icm1).pct_fl_tm_val := p_comp_rec.pct_fl_tm_val;
2128 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_los_flag :='N';
2129 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_age_flag :='N';
2130 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_cmp_lvl_flag :='N';
2131 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_pct_fl_tm_flag :='N';
2132 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_hrs_wkd_flag :='N';
2133 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_comb_age_and_los_flag :='N';
2134 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_amt := p_comp_rec.rt_comp_ref_amt;
2135 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_cmbn_age_n_los_val := p_comp_rec.rt_cmbn_age_n_los_val;
2136 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_uom := p_comp_rec.rt_comp_ref_uom;
2137 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_val := p_comp_rec.rt_age_val;
2138 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_uom := p_comp_rec.rt_age_uom;
2139 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_val := p_comp_rec.rt_los_val;
2140 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_uom := p_comp_rec.rt_los_uom;
2141 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_val := p_comp_rec.rt_hrs_wkd_val;
2142 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_bndry_perd_cd := p_comp_rec.rt_hrs_wkd_bndry_perd_cd;
2143 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_pct_fl_tm_val := p_comp_rec.rt_pct_fl_tm_val;
2144 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_los_flag :='N';
2145 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_age_flag :='N';
2146 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_cmp_lvl_flag :='N';
2147 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_pct_fl_tm_flag :='N';
2148 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_hrs_wkd_flag :='N';
2149 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_comb_age_and_los_flag :='N';
2150 ben_icm_life_events.g_cache_epo_object(l_count_icm1).once_r_cntug_cd := p_comp_rec.once_r_cntug_cd;
2151 ben_icm_life_events.g_cache_epo_object(l_count_icm1).object_version_number := l_t_object_version_number;
2152 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_application_id :=fnd_global.prog_appl_id;
2153 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_id :=fnd_global.conc_program_id;
2154 ben_icm_life_events.g_cache_epo_object(l_count_icm1).request_id :=fnd_global.conc_request_id;
2155 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_update_date :=sysdate;
2156 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_datetrack_mode:= 'UPDATE';
2157 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_effective_date:= l_t_effective_dt;
2158 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_newly_elig := l_newly_elig;
2159 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_newly_inelig:= l_newly_inelig;
2160 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_first_elig := l_first_elig;
2161 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_first_inelig := l_first_inelig;
2162 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_still_elig := l_still_elig;
2163 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_still_inelig:= l_still_inelig;
2164 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_pl_id := l_envpl_id;
2165 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_ovridn_flag := 'N';
2166 ben_icm_life_events.g_cache_epo_object(l_count_icm1).no_mx_prtn_ovrid_thru_flag := 'N';
2167 --
2168 END IF;
2169 end if;
2170 --ICM
2171 --
2172 return;
2173 --
2174 elsif l_opt_elig_flag = 'N' and p_elig_flag then --d
2175 -- person is newly elig
2176 hr_utility.set_location('new elig',23);
2177 l_newly_elig := true;
2178 l_start_or_end := 'S';
2179 fnd_message.set_name('BEN','BEN_91346_ELIG_PREV_NOT_ELIG');
2180 benutils.write(p_text => fnd_message.get);
2181 --
2182 else
2183 fnd_message.set_name('BEN','BEN_91006_INVALID_FLAG');
2184 fnd_message.set_token('FLAG','epo.elig_flag');
2185 fnd_message.set_token('PROC','ben_determine_eligibility2.check_prev_elig');
2186 raise ben_manage_life_events.g_record_error;
2187 --
2188 end if; --d
2189 --
2190 end if; --b
2191 --
2192 if g_debug then
2193 hr_utility.set_location('Call GSED 1 ben_determine_eligibility2.check_prev_elig', 10);
2194 end if;
2195 --
2196 get_start_end_dates
2197 (p_comp_obj_tree_row => p_comp_obj_tree_row
2198 ,p_pil_row => l_pil_rec
2199 ,p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date)
2200 ,p_business_group_id => p_business_group_id
2201 ,p_person_id => p_person_id
2202 ,p_pl_id => p_pl_id
2203 ,p_pgm_id => p_pgm_id
2204 ,p_oipl_id => p_oipl_id
2205 ,p_plip_id => p_plip_id
2206 ,p_ptip_id => p_ptip_id
2207 ,p_prev_prtn_strt_dt => l_prev_prtn_strt_dt
2208 ,p_prev_prtn_end_dt => l_prev_prtn_end_dt
2209 ,p_start_or_end => l_start_or_end
2210 ,p_prtn_eff_strt_dt => l_prtn_eff_strt_dt
2211 ,p_prtn_eff_strt_dt_cd => l_prtn_eff_strt_dt_cd
2212 ,p_prtn_eff_strt_dt_rl => l_prtn_eff_strt_dt_rl
2213 ,p_prtn_eff_end_dt => l_prtn_eff_end_dt
2214 );
2215 --
2216 if g_debug then
2217 --
2218 hr_utility.set_location('Done GSED 1 ben_determine_eligibility2.check_prev_elig', 10);
2219 hr_utility.set_location(' l_prtn_eff_strt_dt : ' ||l_prtn_eff_strt_dt, 10);
2220 hr_utility.set_location(' l_prtn_eff_end_dt : ' ||l_prtn_eff_end_dt, 10);
2221 --
2222 end if;
2223 -- compute end date plus one.
2224 if to_char(l_prtn_eff_end_dt,'DD-MM-RRRR') = '31-12-4712' then
2225 --
2226 l_end_dt_plus_one := l_prtn_eff_end_dt;
2227 --
2228 else
2229 --
2230 l_end_dt_plus_one := l_prtn_eff_end_dt + 1;
2231 --
2232 end if;
2233 -- Now determine what records to write
2234 -- Find the elig_per record id that we need to join to.
2235 -- Have to do this for first timers because cursor for prev elig
2236 -- would not have brought back a record.
2237 --
2238 /* Bug 3327841 This info needs to be derived for the elig_per_opt
2239 records even in the subsequent life event also as the value
2240 we are getting from the ben_pep_cache is for the previous
2241 life event.
2242 */
2243 if l_first_elig or l_oipl_rec.opt_id is not null then
2244 --
2245 --Get elig id from ben_elig_per_f for the plan
2246 --
2247 if g_debug then
2248 hr_utility.set_location('open c_get_elig_id ben_determine_eligibility2.check_prev_elig', 10);
2249 end if;
2250 --
2251 ben_pep_cache1.get_currplnpep_dets
2252 (p_comp_obj_tree_row => p_comp_obj_tree_row
2253 ,p_person_id => p_person_id
2254 ,p_effective_date => l_effective_dt
2255 --
2256 ,p_inst_row => l_plnpep_dets
2257 );
2258 --
2259 if l_plnpep_dets.elig_per_id is null
2260 then
2261 --
2262 fnd_message.set_name('BEN','BEN_91394_ELIG_NOT_FOUND');
2263 raise ben_manage_life_events.g_record_error;
2264 --
2265 else
2266 --
2267 l_elig_per_id := l_plnpep_dets.elig_per_id;
2268 l_elig_per_prtn_strt_dt := l_plnpep_dets.prtn_strt_dt;
2269 l_elig_per_prtn_end_dt := l_plnpep_dets.prtn_end_dt;
2270 --
2271 end if;
2272 --
2273 if g_debug then
2274 hr_utility.set_location('close c_get_elig_id ben_determine_eligibility2.check_prev_elig', 10);
2275 end if;
2276 --
2277 -- Get opt id from cached oipl structure
2278 --
2279 l_opt_id := l_oipl_rec.opt_id;
2280 --
2281 end if;
2282 --
2283 -- In case its a new oiplip get plip row
2284 --
2285 if l_prtn_eff_strt_dt < l_elig_per_prtn_strt_dt then --j
2286 --
2287 -- prtn strt dt for oipl cannot come before prtn
2288 -- strt dt for plan
2289 l_prtn_eff_strt_dt := l_elig_per_prtn_strt_dt;
2290 --
2291 end if;--j
2292 --
2293 if l_prtn_eff_end_dt > l_elig_per_prtn_end_dt then--k
2294 -- prtn end dt for oipl cannot come after prtn
2295 -- end date for plan
2296 l_prtn_eff_end_dt := l_elig_per_prtn_end_dt;
2297 end if;--k
2298 --
2299 -- compute end date plus one.
2300 if to_char(l_prtn_eff_end_dt,'DD-MM-RRRR') = '31-12-4712' then
2301 --
2302 l_end_dt_plus_one := l_prtn_eff_end_dt;
2303 --
2304 else
2305 --
2306 l_end_dt_plus_one := l_prtn_eff_end_dt + 1;
2307 --
2308 end if;
2309 --
2310 if l_first_elig then --n
2311 hr_utility.set_location ('first elig',121);
2312 -- Create Elig Person for Option
2313 if instr(ben_manage_life_events.g_output_string,
2314 'Elg:') = 0 then
2315 --
2316 ben_manage_life_events.g_output_string :=
2317 ben_manage_life_events.g_output_string||
2318 'Elg: Yes '||
2319 'Rsn: First Time Elig';
2320 --
2321 end if;
2322
2323 --Bug 12964414: If the unrestricted Le is pocessed in a future date and
2324 -- if we run a concurrent request of mode = 'S' on present date
2325 -- then prtn_strt_dt of the eligibility record created in
2326 -- ben_elig_per_f and ben_elig_per_opt_f should be the date on
2327 -- which concurrent request is run.
2328
2329 if ben_manage_life_events.g_modified_mode in ('S') then
2330 if l_prtn_eff_strt_dt > l_elig_per_prtn_strt_dt then
2331 l_prtn_eff_strt_dt := l_elig_per_prtn_strt_dt;
2332 end if;
2333 end if;
2334
2335 --Bug 12964414 end.
2336
2337
2338 -- If a waiting period applies, get the date when participation will begin
2339 -- after the waiting period ends.
2340 if l_wait_perd_cmpltn_dt is not null and l_benmngle_parm_rec.mode_cd <> 'D' then
2341 -- Apply the participation start date code to the l_wait_perd_cmpltn_dt
2342 l_prtn_st_dt_aftr_wtg :=
2343 ben_determine_eligibility3.get_prtn_st_dt_aftr_wtg
2344 (p_person_id => p_person_id
2345 ,p_effective_date => p_effective_date
2346 ,p_business_group_id => p_business_group_id
2347 ,p_prtn_eff_strt_dt_cd => l_prtn_eff_strt_dt_cd
2348 ,p_prtn_eff_strt_dt_rl => l_prtn_eff_strt_dt_rl
2349 ,p_wtg_perd_cmpltn_dt => l_wait_perd_cmpltn_dt
2350 ,p_pl_id => p_pl_id
2351 ,p_pl_typ_id => l_pl_rec.pl_typ_id
2352 ,p_pgm_id => p_pgm_id
2353 ,p_oipl_id => p_oipl_id
2354 ,p_plip_id => p_plip_id
2355 ,p_ptip_id => p_ptip_id
2356 ,p_opt_id => l_oipl_rec.opt_id
2357 );
2358 --
2359 -- Use the later of the l_after_wtg_prtn_dt and l_prtn_eff_strt_dt
2360 -- for the participation start date.
2361 l_prtn_eff_strt_dt := greatest(nvl(l_prtn_st_dt_aftr_wtg
2362 ,hr_api.g_sot),l_prtn_eff_strt_dt);
2363 --
2364 end if;
2365 --
2366 if g_debug then
2367 hr_utility.set_location('Using prtn_eff_strt_dt : ' ||
2368 l_prtn_eff_strt_dt, 10);
2369 hr_utility.set_location('FIR ELIG Cre EPO ben_determine_eligibility2.check_prev_elig', 10);
2370 end if;
2371 --
2372 l_elig_flag := 'Y';
2373 l_prtn_strt_dt := l_prtn_eff_strt_dt;
2374 --
2375 ben_Eligible_Person_perf_api.create_perf_Elig_Person_Option
2376 (p_validate => FALSE,
2377 p_elig_per_opt_id => l_elig_per_opt_id,
2378 p_elig_per_id => l_elig_per_id,
2379 p_per_in_ler_id => l_per_in_ler_id,
2380 p_prtn_ovridn_flag => 'N',
2381 p_prtn_ovridn_thru_dt => null,
2382 p_no_mx_prtn_ovrid_thru_flag => 'N',
2383 p_elig_flag => l_elig_flag,
2384 p_prtn_strt_dt => l_prtn_strt_dt,
2385 p_opt_id => l_opt_id,
2386 p_rt_comp_ref_amt => p_comp_rec.rt_comp_ref_amt,
2387 p_rt_cmbn_age_n_los_val => p_comp_rec.rt_cmbn_age_n_los_val,
2388 p_rt_comp_ref_uom => p_comp_rec.rt_comp_ref_uom,
2389 p_rt_age_val => p_comp_rec.rt_age_val,
2390 p_rt_los_val => p_comp_rec.rt_los_val,
2391 p_rt_hrs_wkd_val => p_comp_rec.rt_hrs_wkd_val,
2392 p_rt_hrs_wkd_bndry_perd_cd => p_comp_rec.rt_hrs_wkd_bndry_perd_cd,
2393 p_rt_age_uom => p_comp_rec.rt_age_uom,
2394 p_rt_los_uom => p_comp_rec.rt_los_uom,
2395 p_rt_pct_fl_tm_val => p_comp_rec.rt_pct_fl_tm_val,
2396 p_rt_frz_los_flag => 'N',
2397 p_rt_frz_age_flag => 'N',
2398 p_rt_frz_cmp_lvl_flag => 'N',
2399 p_rt_frz_pct_fl_tm_flag => 'N',
2400 p_rt_frz_hrs_wkd_flag => 'N',
2401 p_rt_frz_comb_age_and_los_flag => 'N',
2402 p_once_r_cntug_cd => p_comp_rec.once_r_cntug_cd,
2403 p_comp_ref_amt => p_comp_rec.comp_ref_amt,
2404 p_cmbn_age_n_los_val => p_comp_rec.cmbn_age_n_los_val,
2405 p_comp_ref_uom => p_comp_rec.comp_ref_uom,
2406 p_age_val => p_comp_rec.age_val,
2407 p_los_val => p_comp_rec.los_val,
2408 p_hrs_wkd_val => p_comp_rec.hrs_wkd_val,
2409 p_hrs_wkd_bndry_perd_cd => p_comp_rec.hrs_wkd_bndry_perd_cd,
2410 p_age_uom => p_comp_rec.age_uom,
2411 p_los_uom => p_comp_rec.los_uom,
2412 p_pct_fl_tm_val => p_comp_rec.pct_fl_tm_val,
2413 p_frz_los_flag => 'N',
2414 p_frz_age_flag => 'N',
2415 p_frz_cmp_lvl_flag => 'N',
2416 p_frz_pct_fl_tm_flag => 'N',
2417 p_frz_hrs_wkd_flag => 'N',
2418 p_frz_comb_age_and_los_flag => 'N',
2419 -- p_wait_perd_cmpltn_dt => l_wait_perd_cmpltn_dt,
2420 p_wait_perd_cmpltn_date => l_wait_perd_cmpltn_dt,
2421 p_wait_perd_strt_dt => l_wait_perd_strt_dt,
2422 p_effective_start_date => l_effective_start_date,
2423 p_effective_end_date => l_effective_end_date,
2424 p_object_version_number => l_object_version_number_opt,
2425 p_oipl_ordr_num => l_oipl_rec.ordr_num,
2426 p_business_group_id => p_business_group_id,
2427 p_program_application_id => fnd_global.prog_appl_id,
2428 p_program_id => fnd_global.conc_program_id,
2429 p_request_id => fnd_global.conc_request_id,
2430 p_program_update_date => sysdate,
2431 --
2432 -- Bugs : 1412882, part of bug 1412951
2433 --
2434 p_effective_date => l_effective_dt,
2435 -- p_effective_date => p_effective_date
2436 --
2437 -- Bypass insert validate validation for performance
2438 --
2439 p_override_validation => TRUE
2440 );
2441 -- ICM
2442 IF nvl(l_env_rec.mode_cd,'~') = 'D' THEN
2443 --
2444 IF NOT ben_icm_life_events.g_cache_epo_object.EXISTS(1) THEN
2445 --
2446 l_count_icm1 := 1;
2447 --
2448 ELSE
2449 --
2450 l_count_icm1 := ben_icm_life_events.g_cache_epo_object.LAST + 1;
2451 --
2452 END IF;
2453 --
2454 hr_utility.set_location('Building epo cache1 2 : count ' || l_count_icm1,123);
2455 --
2456 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_id := l_elig_per_id;
2457 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_opt_id := l_elig_per_opt_id;
2458 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_start_date :=l_effective_start_date;
2459 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_end_date :=l_effective_end_date;
2460 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_ovridn_flag := 'N';
2461 ben_icm_life_events.g_cache_epo_object(l_count_icm1).no_mx_prtn_ovrid_thru_flag := 'N';
2462 ben_icm_life_events.g_cache_epo_object(l_count_icm1).business_group_id := p_business_group_id;
2463 ben_icm_life_events.g_cache_epo_object(l_count_icm1).per_in_ler_id :=l_per_in_ler_id;
2464 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_strt_dt := l_prtn_strt_dt;
2465 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_ovridn_thru_dt := null;
2466 ben_icm_life_events.g_cache_epo_object(l_count_icm1).opt_id := l_opt_id;
2467 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_strt_dt := l_wait_perd_strt_dt;
2468 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_flag := l_elig_flag;
2469 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_amt := p_comp_rec.comp_ref_amt;
2470 ben_icm_life_events.g_cache_epo_object(l_count_icm1).cmbn_age_n_los_val := p_comp_rec.cmbn_age_n_los_val;
2471 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_uom := p_comp_rec.comp_ref_uom;
2472 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_val := p_comp_rec.age_val;
2473 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_uom := p_comp_rec.age_uom;
2474 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_val := p_comp_rec.los_val;
2475 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_uom := p_comp_rec.los_uom;
2476 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_val := p_comp_rec.hrs_wkd_val;
2477 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_cmpltn_date := l_wait_perd_cmpltn_dt;
2478 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_bndry_perd_cd := p_comp_rec.hrs_wkd_bndry_perd_cd;
2479 ben_icm_life_events.g_cache_epo_object(l_count_icm1).pct_fl_tm_val := p_comp_rec.pct_fl_tm_val;
2480 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_los_flag :='N';
2481 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_age_flag :='N';
2482 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_cmp_lvl_flag :='N';
2483 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_pct_fl_tm_flag :='N';
2484 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_hrs_wkd_flag :='N';
2485 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_comb_age_and_los_flag :='N';
2486 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_amt := p_comp_rec.rt_comp_ref_amt;
2487 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_cmbn_age_n_los_val := p_comp_rec.rt_cmbn_age_n_los_val;
2488 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_uom := p_comp_rec.rt_comp_ref_uom;
2489 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_val := p_comp_rec.rt_age_val;
2490 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_uom := p_comp_rec.rt_age_uom;
2491 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_val := p_comp_rec.rt_los_val;
2492 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_uom := p_comp_rec.rt_los_uom;
2493 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_val := p_comp_rec.rt_hrs_wkd_val;
2494 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_bndry_perd_cd := p_comp_rec.rt_hrs_wkd_bndry_perd_cd;
2495 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_pct_fl_tm_val := p_comp_rec.rt_pct_fl_tm_val;
2496 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_los_flag :='N';
2497 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_age_flag :='N';
2498 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_cmp_lvl_flag :='N';
2499 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_pct_fl_tm_flag :='N';
2500 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_hrs_wkd_flag :='N';
2501 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_comb_age_and_los_flag :='N';
2502 ben_icm_life_events.g_cache_epo_object(l_count_icm1).oipl_ordr_num := l_oipl_rec.ordr_num;
2503 ben_icm_life_events.g_cache_epo_object(l_count_icm1).once_r_cntug_cd := p_comp_rec.once_r_cntug_cd;
2504 ben_icm_life_events.g_cache_epo_object(l_count_icm1).object_version_number := l_object_version_number_opt;
2505 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_application_id :=fnd_global.prog_appl_id;
2506 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_id :=fnd_global.conc_program_id;
2507 ben_icm_life_events.g_cache_epo_object(l_count_icm1).request_id :=fnd_global.conc_request_id;
2508 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_update_date :=sysdate;
2509 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_effective_date:= l_effective_dt;
2510 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_newly_elig := l_newly_elig;
2511 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_newly_inelig:= l_newly_inelig;
2512 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_first_elig := l_first_elig;
2513 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_first_inelig := l_first_inelig;
2514 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_still_elig := l_still_elig;
2515 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_still_inelig:= l_still_inelig;
2516 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_pl_id := l_envpl_id;
2517 --
2518 END IF;
2519 --ICM
2520 --
2521 if p_score_tab.count > 0 then
2522 hr_utility.set_location('writing score records ',5.5);
2523 ben_elig_scre_wtg_api.load_score_weight
2524 (p_validate => false
2525 ,p_score_tab => p_score_tab
2526 ,p_effective_date => l_effective_dt
2527 ,p_per_in_ler_id => l_per_in_ler_id /* Bug 4438430 */
2528 ,p_elig_per_id => l_elig_per_id
2529 ,p_elig_per_opt_id => l_elig_per_opt_id);
2530 end if;
2531 hr_utility.set_location('Dn FIR ELIG Cre EPO ben_determine_eligibility2.check_prev_elig', 10);
2532 --
2533 elsif l_still_elig then --n
2534 --
2535 hr_utility.set_location ('still elig',121);
2536 if instr(ben_manage_life_events.g_output_string,
2537 'Elg:') = 0 then
2538 --
2539 ben_manage_life_events.g_output_string :=
2540 ben_manage_life_events.g_output_string||
2541 'Elg: Yes '||
2542 'Rsn: Prev elig';
2543 --
2544 end if;
2545 --
2546 -- if the previous row's start date is greater than or equal the computed
2547 -- start date, then they never really became ineligible. Go find
2548 -- another start elig date to use.
2549 --
2550 dt_api.find_dt_upd_modes
2551 (-- p_effective_date => p_effective_date,
2552 --
2553 -- Bugs : 1412882, part of bug 1412951
2554 --
2555 p_effective_date => l_effective_dt,
2556 --
2557 p_base_table_name => 'BEN_ELIG_PER_OPT_F',
2558 p_base_key_column => 'elig_per_opt_id',
2559 p_base_key_value => l_elig_per_opt_id,
2560 p_correction => l_correction,
2561 p_update => l_update,
2562 p_update_override => l_update_override,
2563 p_update_change_insert => l_update_change_insert);
2564 --
2565 if l_update_override then
2566 --
2567 l_datetrack_mode := hr_api.g_update_override;
2568 --
2569 elsif l_update then
2570 --
2571 l_datetrack_mode := hr_api.g_update;
2572 --
2573 else
2574 --
2575 l_datetrack_mode := hr_api.g_correction;
2576 --
2577 end if;
2578 --
2579 -- If a waiting period applies, get the date when participation will begin
2580 -- after the waiting period ends.
2581 --
2582 if l_wait_perd_cmpltn_dt is not null and l_benmngle_parm_rec.mode_cd <> 'D' then
2583 --
2584 -- Apply the participation start date code to the l_wait_perd_cmpltn_dt
2585 --
2586 l_prtn_st_dt_aftr_wtg :=
2587 ben_determine_eligibility3.get_prtn_st_dt_aftr_wtg
2588 (p_person_id => p_person_id,
2589 p_effective_date => p_effective_date,
2590 p_business_group_id => p_business_group_id,
2591 p_prtn_eff_strt_dt_cd => l_prtn_eff_strt_dt_cd,
2592 p_prtn_eff_strt_dt_rl => l_prtn_eff_strt_dt_rl,
2593 p_wtg_perd_cmpltn_dt => l_wait_perd_cmpltn_dt,
2594 p_pl_id => p_pl_id,
2595 p_pl_typ_id => l_pl_rec.pl_typ_id,
2596 p_pgm_id => p_pgm_id,
2597 p_oipl_id => p_oipl_id,
2598 p_plip_id => p_plip_id,
2599 p_ptip_id => p_ptip_id,
2600 p_opt_id => l_oipl_rec.opt_id);
2601 --
2602 -- Use the later of the l_after_wtg_prtn_dt and l_prtn_eff_strt_dt
2603 -- for the participation start date.
2604 --
2605 l_prtn_eff_strt_dt :=
2606 greatest(nvl(l_prtn_st_dt_aftr_wtg,hr_api.g_sot),l_prtn_eff_strt_dt);
2607 --
2608 end if;
2609 --
2610 l_elig_flag := 'Y';
2611 l_prtn_strt_dt := l_prtn_eff_strt_dt;
2612 --
2613 hr_utility.set_location('SARKAR EPO l_per_in_ler_id' || l_per_in_ler_id, 10);
2614 IF l_datetrack_mode = hr_api.g_correction AND
2615 l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) AND l_benmngle_parm_rec.mode_cd <> 'D' THEN
2616 --
2617 ben_determine_eligibility3.save_to_restore
2618 (p_current_per_in_ler_id => l_per_in_ler_id
2619 ,p_per_in_ler_id => l_prev_per_in_ler_id
2620 ,p_elig_per_id => NULL
2621 ,p_elig_per_opt_id => l_elig_per_opt_id
2622 ,p_effective_date => l_effective_dt
2623 );
2624 --
2625 END IF;
2626 -------------------------------------------------------------------------------
2627 --Bug 12732878 changes
2628 --If the oipl comp object is still eligible then checking whether for the same comp object
2629 --Future records are present in ben_elig_per_opt_f tables.If present inserting them into
2630 --backup table.
2631
2632 IF (l_datetrack_mode = hr_api.g_update_override) -- AND
2633 -- l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
2634 then --
2635 open c_prev_pil(p_pil_row.per_in_ler_id);
2636 fetch c_prev_pil into l_prev_pil_id;
2637 close c_prev_pil;
2638
2639 hr_utility.set_location('l_prev_pil_id ' || l_prev_pil_id, 7776);
2640 -- gets the opt record for previous per_in_ler
2641 open c_elig_opt_rec(l_elig_per_opt_id,l_prev_pil_id);
2642 fetch c_elig_opt_rec into l_elig_per_opt_rec;
2643 close c_elig_opt_rec;
2644
2645 hr_utility.set_location('uxx l_elig_per_opt_rec.elig_per_opt_id '||l_elig_per_opt_rec.elig_per_opt_id,10);
2646 -- checks the opt record having start date greater than effective date.
2647 open c_elig_per_opt_id(l_prev_pil_id,
2648 l_elig_per_opt_rec.elig_per_opt_id,
2649 p_effective_date);
2650 fetch c_elig_per_opt_id into l_ftr_elig_per_opt_rec;
2651 close c_elig_per_opt_id;
2652
2653 hr_utility.set_location('uxx l_ftr_elig_per_opt_rec.elig_per_opt_id '||l_ftr_elig_per_opt_rec.elig_per_opt_id,10);
2654 hr_utility.set_location('uxx l_ftr_elig_per_opt_rec.effective_start_date '||l_ftr_elig_per_opt_rec.effective_start_date,10);
2655
2656 if(l_ftr_elig_per_opt_rec.elig_per_opt_id is not null) then
2657 hr_utility.set_location('uxx save to restore in if ',10);
2658
2659 ben_determine_eligibility3.save_to_restore
2660 (p_current_per_in_ler_id => l_per_in_ler_id
2661 ,p_per_in_ler_id => l_prev_pil_id
2662 ,p_elig_per_id => NUll
2663 ,p_elig_per_opt_id => l_ftr_elig_per_opt_rec.elig_per_opt_id
2664 ,p_effective_date => l_ftr_elig_per_opt_rec.effective_start_date
2665 );
2666 else
2667 hr_utility.set_location('uxx save to restore in else ',10);
2668 ben_determine_eligibility3.save_to_restore
2669 (p_current_per_in_ler_id => l_per_in_ler_id
2670 ,p_per_in_ler_id => l_prev_per_in_ler_id
2671 ,p_elig_per_id => NULL
2672 ,p_elig_per_opt_id => l_elig_per_opt_id
2673 ,p_effective_date => l_effective_dt
2674 );
2675 end if;
2676 --
2677 END IF;
2678 --Bug 12732878 changes end
2679 --------------------------------------------------------------------------------
2680 --
2681 l_t_object_version_number := l_object_version_number_opt;
2682 --
2683
2684
2685 ben_Eligible_Person_perf_api.update_perf_Elig_Person_Option
2686 (p_validate => FALSE,
2687 p_elig_per_opt_id => l_elig_per_opt_id,
2688 p_elig_per_id => l_elig_per_id,
2689 p_effective_start_date => l_effective_start_date,
2690 p_effective_end_date => l_effective_end_date,
2691 p_per_in_ler_id => l_per_in_ler_id,
2692 p_elig_flag => l_elig_flag,
2693 p_prtn_strt_dt => l_prtn_strt_dt,
2694 p_prtn_end_dt => null,
2695 p_rt_comp_ref_amt => p_comp_rec.rt_comp_ref_amt,
2696 p_rt_cmbn_age_n_los_val => p_comp_rec.rt_cmbn_age_n_los_val,
2697 p_rt_comp_ref_uom => p_comp_rec.rt_comp_ref_uom,
2698 p_rt_age_val => p_comp_rec.rt_age_val,
2699 p_rt_los_val => p_comp_rec.rt_los_val,
2700 p_rt_hrs_wkd_val => p_comp_rec.rt_hrs_wkd_val,
2701 p_rt_hrs_wkd_bndry_perd_cd => p_comp_rec.rt_hrs_wkd_bndry_perd_cd,
2702 p_rt_age_uom => p_comp_rec.rt_age_uom,
2703 p_rt_los_uom => p_comp_rec.rt_los_uom,
2704 p_rt_pct_fl_tm_val => p_comp_rec.rt_pct_fl_tm_val,
2705 p_rt_frz_los_flag => 'N',
2706 p_rt_frz_age_flag => 'N',
2707 p_rt_frz_cmp_lvl_flag => 'N',
2708 p_rt_frz_pct_fl_tm_flag => 'N',
2709 p_rt_frz_hrs_wkd_flag => 'N',
2710 p_rt_frz_comb_age_and_los_flag => 'N',
2711 p_once_r_cntug_cd => p_comp_rec.once_r_cntug_cd,
2712 p_comp_ref_amt => p_comp_rec.comp_ref_amt,
2713 p_cmbn_age_n_los_val => p_comp_rec.cmbn_age_n_los_val,
2714 p_comp_ref_uom => p_comp_rec.comp_ref_uom,
2715 p_age_val => p_comp_rec.age_val,
2716 p_los_val => p_comp_rec.los_val,
2717 p_hrs_wkd_val => p_comp_rec.hrs_wkd_val,
2718 p_hrs_wkd_bndry_perd_cd => p_comp_rec.hrs_wkd_bndry_perd_cd,
2719 p_age_uom => p_comp_rec.age_uom,
2720 p_los_uom => p_comp_rec.los_uom,
2721 p_pct_fl_tm_val => p_comp_rec.pct_fl_tm_val,
2722 p_frz_los_flag => 'N',
2723 p_frz_age_flag => 'N',
2724 p_frz_cmp_lvl_flag => 'N',
2725 p_frz_pct_fl_tm_flag => 'N',
2726 p_frz_hrs_wkd_flag => 'N',
2727 p_frz_comb_age_and_los_flag => 'N',
2728 -- p_wait_perd_cmpltn_dt => l_wait_perd_cmpltn_dt,
2729 p_wait_perd_strt_dt => l_wait_perd_strt_dt,
2730 p_wait_perd_cmpltn_date => l_wait_perd_cmpltn_dt,
2731 --
2732 -- Bugs : 1412882, part of bug 1412951
2733 --
2734 p_effective_date => l_effective_dt,
2735 -- p_effective_date => p_effective_date,
2736 p_object_version_number => l_object_version_number_opt,
2737 p_datetrack_mode => l_datetrack_mode,
2738 p_program_application_id => fnd_global.prog_appl_id,
2739 p_program_id => fnd_global.conc_program_id,
2740 p_request_id => fnd_global.conc_request_id,
2741 p_program_update_date => sysdate);
2742 --
2743 IF nvl(l_env_rec.mode_cd,'~') = 'D' THEN
2744 --
2745 IF NOT ben_icm_life_events.g_cache_epo_object.EXISTS(1) THEN
2746 --
2747 l_count_icm1 := 1;
2748 --
2749 ELSE
2750 --
2751 l_count_icm1 := ben_icm_life_events.g_cache_epo_object.LAST + 1;
2752 --
2753 END IF;
2754 --
2755 hr_utility.set_location('Building epo cache1 3 : count ',123);
2756 --ICM
2757 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_id := l_elig_per_id;
2758 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_opt_id := l_elig_per_opt_id;
2759 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_start_date :=l_effective_start_date;
2760 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_end_date :=l_effective_end_date;
2761 ben_icm_life_events.g_cache_epo_object(l_count_icm1).business_group_id := p_business_group_id;
2762 ben_icm_life_events.g_cache_epo_object(l_count_icm1).per_in_ler_id :=l_per_in_ler_id;
2763 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_strt_dt := l_prtn_strt_dt;
2764 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_end_dt := null;
2765 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_strt_dt := l_wait_perd_strt_dt;
2766 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_flag := l_elig_flag;
2767 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_amt := p_comp_rec.comp_ref_amt;
2768 ben_icm_life_events.g_cache_epo_object(l_count_icm1).cmbn_age_n_los_val := p_comp_rec.cmbn_age_n_los_val;
2769 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_uom := p_comp_rec.comp_ref_uom;
2770 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_val := p_comp_rec.age_val;
2771 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_uom := p_comp_rec.age_uom;
2772 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_val := p_comp_rec.los_val;
2773 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_uom := p_comp_rec.los_uom;
2774 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_val := p_comp_rec.hrs_wkd_val;
2775 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_cmpltn_date := l_wait_perd_cmpltn_dt;
2776 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_bndry_perd_cd := p_comp_rec.hrs_wkd_bndry_perd_cd;
2777 ben_icm_life_events.g_cache_epo_object(l_count_icm1).pct_fl_tm_val := p_comp_rec.pct_fl_tm_val;
2778 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_los_flag :='N';
2779 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_age_flag :='N';
2780 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_cmp_lvl_flag :='N';
2781 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_pct_fl_tm_flag :='N';
2782 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_hrs_wkd_flag :='N';
2783 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_comb_age_and_los_flag :='N';
2784 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_amt := p_comp_rec.rt_comp_ref_amt;
2785 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_cmbn_age_n_los_val := p_comp_rec.rt_cmbn_age_n_los_val;
2786 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_uom := p_comp_rec.rt_comp_ref_uom;
2787 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_val := p_comp_rec.rt_age_val;
2788 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_uom := p_comp_rec.rt_age_uom;
2789 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_val := p_comp_rec.rt_los_val;
2790 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_uom := p_comp_rec.rt_los_uom;
2791 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_val := p_comp_rec.rt_hrs_wkd_val;
2792 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_bndry_perd_cd := p_comp_rec.rt_hrs_wkd_bndry_perd_cd;
2793 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_pct_fl_tm_val := p_comp_rec.rt_pct_fl_tm_val;
2794 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_los_flag :='N';
2795 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_age_flag :='N';
2796 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_cmp_lvl_flag :='N';
2797 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_pct_fl_tm_flag :='N';
2798 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_hrs_wkd_flag :='N';
2799 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_comb_age_and_los_flag :='N';
2800 ben_icm_life_events.g_cache_epo_object(l_count_icm1).once_r_cntug_cd := p_comp_rec.once_r_cntug_cd;
2801 ben_icm_life_events.g_cache_epo_object(l_count_icm1).object_version_number := l_t_object_version_number;
2802 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_application_id :=fnd_global.prog_appl_id;
2803 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_id :=fnd_global.conc_program_id;
2804 ben_icm_life_events.g_cache_epo_object(l_count_icm1).request_id :=fnd_global.conc_request_id;
2805 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_update_date :=sysdate;
2806 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_datetrack_mode:= l_datetrack_mode;
2807 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_effective_date:= l_effective_dt;
2808 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_newly_elig := l_newly_elig;
2809 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_newly_inelig:= l_newly_inelig;
2810 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_first_elig := l_first_elig;
2811 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_first_inelig := l_first_inelig;
2812 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_still_elig := l_still_elig;
2813 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_still_inelig:= l_still_inelig;
2814 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_pl_id := l_envpl_id;
2815 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_ovridn_flag := 'N';
2816 ben_icm_life_events.g_cache_epo_object(l_count_icm1).no_mx_prtn_ovrid_thru_flag := 'N';
2817 ben_icm_life_events.g_cache_epo_object(l_count_icm1).opt_id := l_oipl_rec.opt_id;
2818 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_cmpltn_dt :=l_wait_perd_cmpltn_dt;
2819 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_ovridn_thru_dt := null;
2820 --
2821 END IF;
2822 --ICM
2823 if p_score_tab.count > 0 then
2824 hr_utility.set_location('writing score records ',5.6);
2825 ben_elig_scre_wtg_api.load_score_weight
2826 (p_validate => false
2827 ,p_score_tab => p_score_tab
2828 ,p_effective_date => l_effective_dt
2829 ,p_per_in_ler_id => l_per_in_ler_id /* Bug 4438430 */
2830 ,p_elig_per_id => l_elig_per_id
2831 ,p_elig_per_opt_id => l_elig_per_opt_id);
2832 end if;
2833 elsif l_newly_elig then --n
2834 --
2835 hr_utility.set_location('new elig',23);
2836 if instr(ben_manage_life_events.g_output_string,
2837 'Elg:') = 0 then
2838 --
2839 ben_manage_life_events.g_output_string :=
2840 ben_manage_life_events.g_output_string||
2841 'Elg: Yes '||
2842 'Rsn: Prev Inelig';
2843 --
2844 end if;
2845 --
2846 l_t_object_version_number := l_object_version_number_opt;
2847 --
2848 -- if the previous row's start date is greater than or equal the computed
2849 -- start date, then they never really became ineligible. Go find
2850 -- another start elig date to use.
2851 --
2852 if l_prev_prtn_strt_dt >= l_prtn_eff_strt_dt then --p
2853 --
2854 -- Check for an existing eligible record where our computed start
2855 -- date falls between existing records start and end dates.
2856 -- If there is one, then the person never really lost eligiblity
2857 -- and we need to use the old start date.
2858 --
2859 open c_opt_overlap (c_prtn_eff_strt_dt => l_prtn_eff_strt_dt
2860 ,c_elig_flag => 'Y'
2861 ,c_add_one => 1);
2862 --
2863 fetch c_opt_overlap into l_opt_overlap;
2864 --
2865 close c_opt_overlap;
2866 --
2867 if l_opt_overlap.prtn_strt_dt is not null then
2868 --
2869 l_prtn_eff_strt_dt := l_opt_overlap.prtn_strt_dt;
2870 --
2871 end if;
2872 --
2873 else
2874 --
2875 -- Call API to Update old inelig record with end date of computed
2876 -- start date - 1 (correction) unless the old inelig record has a
2877 -- start date greater than our computed start date.
2878 --
2879 if l_prev_prtn_strt_dt < l_prtn_eff_strt_dt then
2880 --
2881 ben_Eligible_Person_perf_api.update_perf_Elig_Person_Option
2882 (p_validate => FALSE,
2883 p_elig_per_opt_id => l_elig_per_opt_id,
2884 p_elig_per_id => l_elig_per_id,
2885 --
2886 -- Bug 2284417 : Do not update the per in ler id with new
2887 -- per in ler id as this row peice of row should belong to
2888 -- previous per in ler. Next update will update the
2889 -- per in ler id as well as new prtn strt dt.
2890 --
2891 -- p_per_in_ler_id => l_per_in_ler_id,
2892 p_effective_start_date => l_effective_start_date,
2893 p_effective_end_date => l_effective_end_date,
2894 p_prtn_end_dt => l_prtn_eff_strt_dt-1,
2895 -- p_effective_date => p_effective_date,
2896 p_effective_date => l_effective_dt,
2897 p_object_version_number => l_object_version_number_opt,
2898 p_datetrack_mode => hr_api.g_correction,
2899 p_program_application_id => fnd_global.prog_appl_id,
2900 p_program_id => fnd_global.conc_program_id,
2901 p_request_id => fnd_global.conc_request_id,
2902 p_program_update_date => sysdate);
2903 --
2904 --
2905 end if;
2906 end if; --p
2907 --
2908 -- Then call in update mode to create a new elig record with
2909 -- computed start date.
2910 --
2911 dt_api.find_dt_upd_modes
2912 (-- p_effective_date => p_effective_date,
2913 --
2914 -- Bugs : 1412882, part of bug 1412951
2915 --
2916 p_effective_date => l_effective_dt,
2917 --
2918 p_base_table_name => 'BEN_ELIG_PER_OPT_F',
2919 p_base_key_column => 'elig_per_opt_id',
2920 p_base_key_value => l_elig_per_opt_id,
2921 p_correction => l_correction,
2922 p_update => l_update,
2923 p_update_override => l_update_override,
2924 p_update_change_insert => l_update_change_insert);
2925 --
2926 if l_update_override then
2927 --
2928 l_datetrack_mode := hr_api.g_update_override;
2929 --
2930 elsif l_update then
2931 --
2932 l_datetrack_mode := hr_api.g_update;
2933 --
2934 else
2935 --
2936 l_datetrack_mode := hr_api.g_correction;
2937 --
2938 end if;
2939 --
2940 -- If a waiting period applies, get the date when participation will begin
2941 -- after the waiting period ends.
2942 --
2943 if l_wait_perd_cmpltn_dt is not null then
2944 --
2945 -- Apply the participation start date code to the l_wait_perd_cmpltn_dt
2946 --
2947 l_prtn_st_dt_aftr_wtg :=
2948 ben_determine_eligibility3.get_prtn_st_dt_aftr_wtg
2949 (p_person_id => p_person_id,
2950 p_effective_date => p_effective_date,
2951 p_business_group_id => p_business_group_id,
2952 p_prtn_eff_strt_dt_cd => l_prtn_eff_strt_dt_cd,
2953 p_prtn_eff_strt_dt_rl => l_prtn_eff_strt_dt_rl,
2954 p_wtg_perd_cmpltn_dt => l_wait_perd_cmpltn_dt,
2955 p_pl_id => p_pl_id,
2956 p_pl_typ_id => l_pl_rec.pl_typ_id,
2957 p_pgm_id => p_pgm_id,
2958 p_oipl_id => p_oipl_id,
2959 p_plip_id => p_plip_id,
2960 p_ptip_id => p_ptip_id,
2961 p_opt_id => l_oipl_rec.opt_id);
2962 --
2963 -- Use the later of the l_after_wtg_prtn_dt and l_prtn_eff_strt_dt
2964 -- for the participation start date.
2965 --
2966 l_prtn_eff_strt_dt :=
2967 greatest(nvl(l_prtn_st_dt_aftr_wtg,hr_api.g_sot),l_prtn_eff_strt_dt);
2968 --
2969 end if;
2970 --
2971 l_elig_flag := 'Y';
2972 l_prtn_strt_dt := l_prtn_eff_strt_dt;
2973 --
2974 --
2975 IF l_datetrack_mode = hr_api.g_correction AND
2976 l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
2977 --
2978 ben_determine_eligibility3.save_to_restore
2979 (p_current_per_in_ler_id => l_per_in_ler_id
2980 ,p_per_in_ler_id => l_prev_per_in_ler_id
2981 ,p_elig_per_id => NULL
2982 ,p_elig_per_opt_id => l_elig_per_opt_id
2983 ,p_effective_date => l_effective_dt
2984 );
2985 --
2986 END IF;
2987 --
2988 -------------------------------------------------------------------------------
2989 --Bug 12732878 changes
2990 --If the oipl comp object is Newly eligible then checking whether for the same comp object
2991 --Future records are present in ben_elig_per_opt_f tables.If present inserting them into
2992 --backup table.
2993
2994 IF (l_datetrack_mode = hr_api.g_update_override) -- AND
2995 -- l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
2996 then --
2997 open c_prev_pil(p_pil_row.per_in_ler_id);
2998 fetch c_prev_pil into l_prev_pil_id;
2999 close c_prev_pil;
3000
3001 hr_utility.set_location('l_prev_pil_id ' || l_prev_pil_id, 7776);
3002
3003 open c_elig_opt_rec(l_elig_per_opt_id,l_prev_pil_id);
3004 fetch c_elig_opt_rec into l_elig_per_opt_rec;
3005 close c_elig_opt_rec;
3006
3007 hr_utility.set_location('uxx l_elig_per_opt_rec.elig_per_opt_id '||l_elig_per_opt_rec.elig_per_opt_id,10);
3008
3009 open c_elig_per_opt_id(l_prev_pil_id,
3010 l_elig_per_opt_rec.elig_per_opt_id,
3011 p_effective_date);
3012 fetch c_elig_per_opt_id into l_ftr_elig_per_opt_rec;
3013 close c_elig_per_opt_id;
3014
3015 hr_utility.set_location('uxx l_ftr_elig_per_opt_rec.elig_per_opt_id '||l_ftr_elig_per_opt_rec.elig_per_opt_id,10);
3016 hr_utility.set_location('uxx l_ftr_elig_per_opt_rec.effective_start_date '||l_ftr_elig_per_opt_rec.effective_start_date,10);
3017
3018 if(l_ftr_elig_per_opt_rec.elig_per_opt_id is not null) then
3019 hr_utility.set_location('uxx save to restore in if ',10);
3020
3021 ben_determine_eligibility3.save_to_restore
3022 (p_current_per_in_ler_id => l_per_in_ler_id
3023 ,p_per_in_ler_id => l_prev_pil_id
3024 ,p_elig_per_id => NUll
3025 ,p_elig_per_opt_id => l_ftr_elig_per_opt_rec.elig_per_opt_id
3026 ,p_effective_date => l_ftr_elig_per_opt_rec.effective_start_date
3027 );
3028 /* else
3029 hr_utility.set_location('uxx save to restore in else ',10);
3030 ben_determine_eligibility3.save_to_restore
3031 (p_current_per_in_ler_id => l_per_in_ler_id
3032 ,p_per_in_ler_id => l_prev_per_in_ler_id
3033 ,p_elig_per_id => NULL
3034 ,p_elig_per_opt_id => l_elig_per_opt_id
3035 ,p_effective_date => l_effective_dt
3036 );*/
3037 end if;
3038 --
3039 END IF;
3040 --Bug 12732878 changes end
3041 --------------------------------------------------------------------------------
3042
3043 ben_Eligible_Person_perf_api.update_perf_Elig_Person_Option
3044 (p_validate => FALSE,
3045 p_elig_per_opt_id => l_elig_per_opt_id,
3046 p_elig_per_id => l_elig_per_id,
3047 p_effective_start_date => l_effective_start_date,
3048 p_effective_end_date => l_effective_end_date,
3049 p_per_in_ler_id => l_per_in_ler_id,
3050 p_elig_flag => l_elig_flag,
3051 p_prtn_strt_dt => l_prtn_strt_dt,
3052 p_prtn_end_dt => null,
3053 p_rt_comp_ref_amt => p_comp_rec.rt_comp_ref_amt,
3054 p_rt_cmbn_age_n_los_val => p_comp_rec.rt_cmbn_age_n_los_val,
3055 p_rt_comp_ref_uom => p_comp_rec.rt_comp_ref_uom,
3056 p_rt_age_val => p_comp_rec.rt_age_val,
3057 p_rt_los_val => p_comp_rec.rt_los_val,
3058 p_rt_hrs_wkd_val => p_comp_rec.rt_hrs_wkd_val,
3059 p_rt_hrs_wkd_bndry_perd_cd => p_comp_rec.rt_hrs_wkd_bndry_perd_cd,
3060 p_rt_age_uom => p_comp_rec.rt_age_uom,
3061 p_rt_los_uom => p_comp_rec.rt_los_uom,
3062 p_rt_pct_fl_tm_val => p_comp_rec.rt_pct_fl_tm_val,
3063 p_rt_frz_los_flag => 'N',
3064 p_rt_frz_age_flag => 'N',
3065 p_rt_frz_cmp_lvl_flag => 'N',
3066 p_rt_frz_pct_fl_tm_flag => 'N',
3067 p_rt_frz_hrs_wkd_flag => 'N',
3068 p_rt_frz_comb_age_and_los_flag => 'N',
3069 p_once_r_cntug_cd => p_comp_rec.once_r_cntug_cd,
3070 p_comp_ref_amt => p_comp_rec.comp_ref_amt,
3071 p_cmbn_age_n_los_val => p_comp_rec.cmbn_age_n_los_val,
3072 p_comp_ref_uom => p_comp_rec.comp_ref_uom,
3073 p_age_val => p_comp_rec.age_val,
3074 p_los_val => p_comp_rec.los_val,
3075 p_hrs_wkd_val => p_comp_rec.hrs_wkd_val,
3076 p_hrs_wkd_bndry_perd_cd => p_comp_rec.hrs_wkd_bndry_perd_cd,
3077 p_age_uom => p_comp_rec.age_uom,
3078 p_los_uom => p_comp_rec.los_uom,
3079 p_pct_fl_tm_val => p_comp_rec.pct_fl_tm_val,
3080 p_frz_los_flag => 'N',
3081 p_frz_age_flag => 'N',
3082 p_frz_cmp_lvl_flag => 'N',
3083 p_frz_pct_fl_tm_flag => 'N',
3084 p_frz_hrs_wkd_flag => 'N',
3085 p_frz_comb_age_and_los_flag => 'N',
3086 -- p_wait_perd_cmpltn_dt => l_wait_perd_cmpltn_dt,
3087 p_wait_perd_cmpltn_date => l_wait_perd_cmpltn_dt,
3088 p_wait_perd_strt_dt => l_wait_perd_strt_dt,
3089 --
3090 -- Bugs : 1412882, part of bug 1412951
3091 --
3092 p_effective_date => l_effective_dt,
3093 -- p_effective_date => p_effective_date,
3094 p_object_version_number => l_object_version_number_opt,
3095 p_datetrack_mode => l_datetrack_mode,
3096 p_program_application_id => fnd_global.prog_appl_id,
3097 p_program_id => fnd_global.conc_program_id,
3098 p_request_id => fnd_global.conc_request_id,
3099 p_program_update_date => sysdate);
3100 --
3101 IF nvl(l_env_rec.mode_cd,'~') = 'D' THEN
3102 --
3103 IF NOT ben_icm_life_events.g_cache_epo_object.EXISTS(1) THEN
3104 --
3105 l_count_icm1 := 1;
3106 --
3107 ELSE
3108 --
3109 l_count_icm1 := ben_icm_life_events.g_cache_epo_object.LAST + 1;
3110 --
3111 END IF;
3112 --
3113 hr_utility.set_location('Building epo cache1 4 : count ' || l_count_icm1,123);
3114 --ICM
3115 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_id := l_elig_per_id;
3116 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_opt_id := l_elig_per_opt_id;
3117 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_start_date :=l_effective_start_date;
3118 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_end_date :=l_effective_end_date;
3119 ben_icm_life_events.g_cache_epo_object(l_count_icm1).business_group_id := p_business_group_id;
3120 ben_icm_life_events.g_cache_epo_object(l_count_icm1).per_in_ler_id :=l_per_in_ler_id;
3121 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_strt_dt := l_prtn_strt_dt;
3122 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_end_dt := null;
3123 ben_icm_life_events.g_cache_epo_object(l_count_icm1).opt_id := l_oipl_rec.opt_id;
3124 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_strt_dt := l_wait_perd_strt_dt;
3125 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_flag :=l_elig_flag;
3126 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_amt := p_comp_rec.comp_ref_amt;
3127 ben_icm_life_events.g_cache_epo_object(l_count_icm1).cmbn_age_n_los_val := p_comp_rec.cmbn_age_n_los_val;
3128 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_uom := p_comp_rec.comp_ref_uom;
3129 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_val := p_comp_rec.age_val;
3130 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_uom := p_comp_rec.age_uom;
3131 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_val := p_comp_rec.los_val;
3132 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_uom := p_comp_rec.los_uom;
3133 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_val := p_comp_rec.hrs_wkd_val;
3134 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_cmpltn_date := l_wait_perd_cmpltn_dt;
3135 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_bndry_perd_cd := p_comp_rec.hrs_wkd_bndry_perd_cd;
3136 ben_icm_life_events.g_cache_epo_object(l_count_icm1).pct_fl_tm_val := p_comp_rec.pct_fl_tm_val;
3137 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_los_flag :='N';
3138 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_age_flag :='N';
3139 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_cmp_lvl_flag :='N';
3140 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_pct_fl_tm_flag :='N';
3141 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_hrs_wkd_flag :='N';
3142 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_comb_age_and_los_flag :='N';
3143 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_amt := p_comp_rec.rt_comp_ref_amt;
3144 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_cmbn_age_n_los_val := p_comp_rec.rt_cmbn_age_n_los_val;
3145 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_uom := p_comp_rec.rt_comp_ref_uom;
3146 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_val := p_comp_rec.rt_age_val;
3147 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_uom := p_comp_rec.rt_age_uom;
3148 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_val := p_comp_rec.rt_los_val;
3149 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_uom := p_comp_rec.rt_los_uom;
3150 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_val := p_comp_rec.rt_hrs_wkd_val;
3151 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_bndry_perd_cd := p_comp_rec.rt_hrs_wkd_bndry_perd_cd;
3152 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_pct_fl_tm_val := p_comp_rec.rt_pct_fl_tm_val;
3153 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_los_flag :='N';
3154 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_age_flag :='N';
3155 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_cmp_lvl_flag :='N';
3156 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_pct_fl_tm_flag :='N';
3157 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_hrs_wkd_flag :='N';
3158 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_comb_age_and_los_flag :='N';
3159 ben_icm_life_events.g_cache_epo_object(l_count_icm1).once_r_cntug_cd := p_comp_rec.once_r_cntug_cd;
3160 ben_icm_life_events.g_cache_epo_object(l_count_icm1).object_version_number := l_t_object_version_number;
3161 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_application_id :=fnd_global.prog_appl_id;
3162 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_id :=fnd_global.conc_program_id;
3163 ben_icm_life_events.g_cache_epo_object(l_count_icm1).request_id :=fnd_global.conc_request_id;
3164 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_update_date :=sysdate;
3165 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_datetrack_mode:= l_datetrack_mode;
3166 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_effective_date:= l_effective_dt;
3167 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_newly_elig := l_newly_elig;
3168 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_newly_inelig:= l_newly_inelig;
3169 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_first_elig := l_first_elig;
3170 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_first_inelig := l_first_inelig;
3171 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_still_elig := l_still_elig;
3172 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_still_inelig:= l_still_inelig;
3173 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_pl_id := l_envpl_id;
3174 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_ovridn_flag := 'N';
3175 ben_icm_life_events.g_cache_epo_object(l_count_icm1).no_mx_prtn_ovrid_thru_flag := 'N';
3176 --
3177 END IF;
3178 --ICM
3179 if p_score_tab.count > 0 then
3180 hr_utility.set_location('writing score records ',5.7);
3181 ben_elig_scre_wtg_api.load_score_weight
3182 (p_validate => false
3183 ,p_score_tab => p_score_tab
3184 ,p_effective_date => l_effective_dt
3185 ,p_per_in_ler_id => l_per_in_ler_id /* Bug 4438430 */
3186 ,p_elig_per_id => l_elig_per_id
3187 ,p_elig_per_opt_id => l_elig_per_opt_id);
3188 end if;
3189 elsif l_newly_inelig then --n
3190 --
3191 hr_utility.set_location ('newly inelig',121);
3192 -- Person was found not eligible for this oipl.
3193 -- Person was prev eligible. Now is newly ineligible.
3194 -- Call API to Update old record with end date (correction)
3195 -- Then call in update mode to create a new inelig record with
3196 -- start date = computed end date plus 1.
3197 -- if the previous row's start date is greater than the computed
3198 -- end date, then they never really became eligible. Go find
3199 -- another 'start' inelig date to use.
3200 --
3201 l_t_object_version_number := l_object_version_number_opt;
3202 --
3203 if l_prev_prtn_strt_dt > l_prtn_eff_end_dt then --p
3204 --
3205 -- Check for an existing ineligible record where our computed end
3206 -- date falls between existing records start and end dates.
3207 --
3208 open c_opt_overlap (c_prtn_eff_strt_dt => l_prtn_eff_end_dt
3209 ,c_elig_flag => 'N'
3210 ,c_add_one => 0);
3211 --
3212 fetch c_opt_overlap into l_opt_overlap;
3213 --
3214 close c_opt_overlap;
3215 --
3216 if l_opt_overlap.prtn_strt_dt is not null then
3217 --
3218 l_end_dt_plus_one := l_opt_overlap.prtn_strt_dt;
3219 --
3220 end if;
3221 --
3222 else --p
3223 --
3224 ben_Eligible_Person_perf_api.update_perf_Elig_Person_Option
3225 (p_validate => FALSE,
3226 p_elig_per_opt_id => l_elig_per_opt_id,
3227 p_elig_per_id => l_elig_per_id,
3228 --
3229 -- Bug 2284417 : Do not update the per in ler id with new
3230 -- per in ler id as this row peice of row should belong to
3231 -- previous per in ler. Next update will update the
3232 -- per in ler id as well as new prtn strt dt.
3233 --
3234 -- p_per_in_ler_id => l_per_in_ler_id,
3235 p_effective_start_date => l_effective_start_date,
3236 p_effective_end_date => l_effective_end_date,
3237 p_prtn_end_dt => l_prtn_eff_end_dt,
3238 -- p_effective_date => p_effective_date,
3239 p_effective_date => l_effective_dt,
3240 p_object_version_number => l_object_version_number_opt,
3241 p_datetrack_mode => hr_api.g_correction,
3242 p_program_application_id => fnd_global.prog_appl_id,
3243 p_program_id => fnd_global.conc_program_id,
3244 p_request_id => fnd_global.conc_request_id,
3245 p_program_update_date => sysdate);
3246 --
3247 end if; --p
3248 --
3249 dt_api.find_dt_upd_modes
3250 (-- p_effective_date => p_effective_date,
3251 --
3252 -- Bugs : 1412882, part of bug 1412951
3253 --
3254 p_effective_date => l_effective_dt,
3255 --
3256 p_base_table_name => 'BEN_ELIG_PER_OPT_F',
3257 p_base_key_column => 'elig_per_opt_id',
3258 p_base_key_value => l_elig_per_opt_id,
3259 p_correction => l_correction,
3260 p_update => l_update,
3261 p_update_override => l_update_override,
3262 p_update_change_insert => l_update_change_insert);
3263 --
3264 if l_update_override then
3265 --
3266 l_datetrack_mode := hr_api.g_update_override;
3267 --
3268 elsif l_update then
3269 --
3270 l_datetrack_mode := hr_api.g_update;
3271 --
3272 else
3273 --
3274 l_datetrack_mode := hr_api.g_correction;
3275 --
3276 end if;
3277 --
3278 --
3279 IF l_datetrack_mode = hr_api.g_correction AND
3280 l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
3281 --
3282 ben_determine_eligibility3.save_to_restore
3283 (p_current_per_in_ler_id => l_per_in_ler_id
3284 ,p_per_in_ler_id => l_prev_per_in_ler_id
3285 ,p_elig_per_id => NULL
3286 ,p_elig_per_opt_id => l_elig_per_opt_id
3287 ,p_effective_date => l_effective_dt
3288 );
3289 --
3290 END IF;
3291 --
3292 -------------------------------------------------------------------------------
3293 --Bug 12732878 changes
3294 --If the oipl comp object is newly ineligible then checking whether for the same comp object
3295 --Future records are present in ben_elig_per_opt_f tables.If present inserting them into
3296 --backup table.
3297
3298 IF (l_datetrack_mode = hr_api.g_update_override) -- AND
3299 -- l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
3300 then --
3301 open c_prev_pil(p_pil_row.per_in_ler_id);
3302 fetch c_prev_pil into l_prev_pil_id;
3303 close c_prev_pil;
3304
3305 hr_utility.set_location('l_prev_pil_id ' || l_prev_pil_id, 7776);
3306
3307 open c_elig_opt_rec(l_elig_per_opt_id,l_prev_pil_id);
3308 fetch c_elig_opt_rec into l_elig_per_opt_rec;
3309 close c_elig_opt_rec;
3310
3311 hr_utility.set_location('uxx l_elig_per_opt_rec.elig_per_opt_id '||l_elig_per_opt_rec.elig_per_opt_id,10);
3312
3313 open c_elig_per_opt_id(l_prev_pil_id,
3314 l_elig_per_opt_rec.elig_per_opt_id,
3315 p_effective_date);
3316 fetch c_elig_per_opt_id into l_ftr_elig_per_opt_rec;
3317 close c_elig_per_opt_id;
3318
3319 hr_utility.set_location('uxx l_ftr_elig_per_opt_rec.elig_per_opt_id '||l_ftr_elig_per_opt_rec.elig_per_opt_id,10);
3320 hr_utility.set_location('uxx l_ftr_elig_per_opt_rec.effective_start_date '||l_ftr_elig_per_opt_rec.effective_start_date,10);
3321
3322 if(l_ftr_elig_per_opt_rec.elig_per_opt_id is not null) then
3323 hr_utility.set_location('uxx save to restore in if ',10);
3324
3325 ben_determine_eligibility3.save_to_restore
3326 (p_current_per_in_ler_id => l_per_in_ler_id
3327 ,p_per_in_ler_id => l_prev_pil_id
3328 ,p_elig_per_id => NUll
3329 ,p_elig_per_opt_id => l_ftr_elig_per_opt_rec.elig_per_opt_id
3330 ,p_effective_date => l_ftr_elig_per_opt_rec.effective_start_date
3331 );
3332 /* else
3333 hr_utility.set_location('uxx save to restore in else ',10);
3334 ben_determine_eligibility3.save_to_restore
3335 (p_current_per_in_ler_id => l_per_in_ler_id
3336 ,p_per_in_ler_id => l_prev_per_in_ler_id
3337 ,p_elig_per_id => NULL
3338 ,p_elig_per_opt_id => l_elig_per_opt_id
3339 ,p_effective_date => l_effective_dt
3340 );*/
3341 end if;
3342 --
3343 END IF;
3344 --Bug 12732878 changes end
3345 --------------------------------------------------------------------------
3346 l_elig_flag := 'N';
3347 l_prtn_strt_dt := l_end_dt_plus_one;
3348 --
3349
3350 ben_Eligible_Person_perf_api.update_perf_Elig_Person_Option
3351 (p_validate => FALSE,
3352 p_elig_per_opt_id => l_elig_per_opt_id,
3353 p_elig_per_id => l_elig_per_id,
3354 p_per_in_ler_id => l_per_in_ler_id,
3355 p_effective_start_date => l_effective_start_date,
3356 p_effective_end_date => l_effective_end_date,
3357 p_elig_flag => l_elig_flag,
3358 p_prtn_strt_dt => l_prtn_strt_dt,
3359 p_prtn_end_dt => null,
3360 p_rt_comp_ref_amt => p_comp_rec.rt_comp_ref_amt,
3361 p_rt_cmbn_age_n_los_val => p_comp_rec.rt_cmbn_age_n_los_val,
3362 p_rt_comp_ref_uom => p_comp_rec.rt_comp_ref_uom,
3363 p_rt_age_val => p_comp_rec.rt_age_val,
3364 p_rt_los_val => p_comp_rec.rt_los_val,
3365 p_rt_hrs_wkd_val => p_comp_rec.rt_hrs_wkd_val,
3366 p_rt_hrs_wkd_bndry_perd_cd => p_comp_rec.rt_hrs_wkd_bndry_perd_cd,
3367 p_rt_age_uom => p_comp_rec.rt_age_uom,
3368 p_rt_los_uom => p_comp_rec.rt_los_uom,
3369 p_rt_pct_fl_tm_val => p_comp_rec.rt_pct_fl_tm_val,
3370 p_rt_frz_los_flag => 'N',
3371 p_rt_frz_age_flag => 'N',
3372 p_rt_frz_cmp_lvl_flag => 'N',
3373 p_rt_frz_pct_fl_tm_flag => 'N',
3374 p_rt_frz_hrs_wkd_flag => 'N',
3375 p_rt_frz_comb_age_and_los_flag => 'N',
3376 p_once_r_cntug_cd => p_comp_rec.once_r_cntug_cd,
3377 p_comp_ref_amt => p_comp_rec.comp_ref_amt,
3378 p_cmbn_age_n_los_val => p_comp_rec.cmbn_age_n_los_val,
3379 p_comp_ref_uom => p_comp_rec.comp_ref_uom,
3380 p_age_val => p_comp_rec.age_val,
3381 p_los_val => p_comp_rec.los_val,
3382 p_hrs_wkd_val => p_comp_rec.hrs_wkd_val,
3383 p_hrs_wkd_bndry_perd_cd => p_comp_rec.hrs_wkd_bndry_perd_cd,
3384 p_age_uom => p_comp_rec.age_uom,
3385 p_los_uom => p_comp_rec.los_uom,
3386 p_pct_fl_tm_val => p_comp_rec.pct_fl_tm_val,
3387 p_frz_los_flag => 'N',
3388 p_frz_age_flag => 'N',
3389 p_frz_cmp_lvl_flag => 'N',
3390 p_frz_pct_fl_tm_flag => 'N',
3391 p_frz_hrs_wkd_flag => 'N',
3392 p_frz_comb_age_and_los_flag => 'N',
3393 --
3394 -- Bugs : 1412882, part of bug 1412951
3395 --
3396 p_effective_date => l_effective_dt,
3397 -- p_effective_date => p_effective_date,
3398 p_object_version_number => l_object_version_number_opt,
3399 p_datetrack_mode => l_datetrack_mode,
3400 p_program_application_id => fnd_global.prog_appl_id,
3401 p_program_id => fnd_global.conc_program_id,
3402 p_request_id => fnd_global.conc_request_id,
3403 p_program_update_date => sysdate,
3404 p_inelg_rsn_cd => p_inelg_rsn_cd);
3405 --
3406
3407 IF nvl(l_env_rec.mode_cd,'~') = 'D' THEN
3408 IF NOT ben_icm_life_events.g_cache_epo_object.EXISTS(1) THEN
3409 --
3410 l_count_icm1 := 1;
3411 --
3412 ELSE
3413 --
3414 l_count_icm1 := ben_icm_life_events.g_cache_epo_object.LAST + 1;
3415 --
3416 END IF;
3417 --
3418 hr_utility.set_location('Building epo cache1 6 : count ' || l_count_icm1,123);
3419 --ICM
3420 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_id := l_elig_per_id;
3421 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_opt_id := l_elig_per_opt_id;
3422 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_start_date :=l_effective_start_date;
3423 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_end_date :=l_effective_end_date;
3424 ben_icm_life_events.g_cache_epo_object(l_count_icm1).business_group_id := p_business_group_id;
3425 ben_icm_life_events.g_cache_epo_object(l_count_icm1).per_in_ler_id :=l_per_in_ler_id;
3426 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_strt_dt := l_prtn_strt_dt;
3427 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_end_dt := null;
3428 ben_icm_life_events.g_cache_epo_object(l_count_icm1).opt_id := l_oipl_rec.opt_id;
3429 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_flag :=l_elig_flag;
3430 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_amt := p_comp_rec.comp_ref_amt;
3431 ben_icm_life_events.g_cache_epo_object(l_count_icm1).cmbn_age_n_los_val := p_comp_rec.cmbn_age_n_los_val;
3432 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_uom := p_comp_rec.comp_ref_uom;
3433 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_val := p_comp_rec.age_val;
3434 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_uom := p_comp_rec.age_uom;
3435 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_val := p_comp_rec.los_val;
3436 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_uom := p_comp_rec.los_uom;
3437 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_val := p_comp_rec.hrs_wkd_val;
3438 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_bndry_perd_cd := p_comp_rec.hrs_wkd_bndry_perd_cd;
3439 ben_icm_life_events.g_cache_epo_object(l_count_icm1).pct_fl_tm_val := p_comp_rec.pct_fl_tm_val;
3440 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_los_flag :='N';
3441 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_age_flag :='N';
3442 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_cmp_lvl_flag :='N';
3443 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_pct_fl_tm_flag :='N';
3444 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_hrs_wkd_flag :='N';
3445 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_comb_age_and_los_flag :='N';
3446 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_amt := p_comp_rec.rt_comp_ref_amt;
3447 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_cmbn_age_n_los_val := p_comp_rec.rt_cmbn_age_n_los_val;
3448 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_uom := p_comp_rec.rt_comp_ref_uom;
3449 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_val := p_comp_rec.rt_age_val;
3450 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_uom := p_comp_rec.rt_age_uom;
3451 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_val := p_comp_rec.rt_los_val;
3452 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_uom := p_comp_rec.rt_los_uom;
3453 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_val := p_comp_rec.rt_hrs_wkd_val;
3454 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_bndry_perd_cd := p_comp_rec.rt_hrs_wkd_bndry_perd_cd;
3455 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_pct_fl_tm_val := p_comp_rec.rt_pct_fl_tm_val;
3456 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_los_flag :='N';
3457 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_age_flag :='N';
3458 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_cmp_lvl_flag :='N';
3459 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_pct_fl_tm_flag :='N';
3460 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_hrs_wkd_flag :='N';
3461 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_comb_age_and_los_flag :='N';
3462 ben_icm_life_events.g_cache_epo_object(l_count_icm1).once_r_cntug_cd := p_comp_rec.once_r_cntug_cd;
3463 ben_icm_life_events.g_cache_epo_object(l_count_icm1).object_version_number := l_t_object_version_number;
3464 ben_icm_life_events.g_cache_epo_object(l_count_icm1).oipl_ordr_num := null;
3465 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_application_id :=fnd_global.prog_appl_id;
3466 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_id :=fnd_global.conc_program_id;
3467 ben_icm_life_events.g_cache_epo_object(l_count_icm1).request_id :=fnd_global.conc_request_id;
3468 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_update_date :=sysdate;
3469 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_datetrack_mode:= l_datetrack_mode;
3470 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_effective_date:= l_effective_dt;
3471 ben_icm_life_events.g_cache_epo_object(l_count_icm1).inelg_rsn_cd := p_inelg_rsn_cd;
3472 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_newly_elig := l_newly_elig;
3473 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_newly_inelig:= l_newly_inelig;
3474 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_first_elig := l_first_elig;
3475 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_first_inelig := l_first_inelig;
3476 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_still_elig := l_still_elig;
3477 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_still_inelig:= l_still_inelig;
3478 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_pl_id := l_envpl_id;
3479 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_ovridn_flag := 'N';
3480 ben_icm_life_events.g_cache_epo_object(l_count_icm1).no_mx_prtn_ovrid_thru_flag := 'N';
3481 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_ovridn_thru_dt := null;
3482 --
3483 END IF;
3484 --ICM
3485 -- ben_newly_ineligible does not handle levels other than
3486 -- plan,option in plan, or program. Don't call it if not
3487 -- necessary.
3488 --
3489 if p_score_tab.count > 0 then
3490 hr_utility.set_location('writing score records ',5.5);
3491 ben_elig_scre_wtg_api.load_score_weight
3492 (p_validate => false
3493 ,p_score_tab => p_score_tab
3494 ,p_effective_date => l_effective_dt
3495 ,p_per_in_ler_id => l_per_in_ler_id /* Bug 4438430 */
3496 ,p_elig_per_id => l_elig_per_id
3497 ,p_elig_per_opt_id => l_elig_per_opt_id);
3498 end if;
3499 --
3500 if p_plip_id is not null then
3501 open c_get_pl_id(nvl(l_fonm_cvg_strt_dt,p_effective_date));
3502 fetch c_get_pl_id into l_pl_id;
3503 close c_get_pl_id;
3504 end if;
3505 if p_pl_id is not null then
3506 l_pl_id := p_pl_id;
3507 end if;
3508 if (l_pl_id is not null or
3509 p_oipl_id is not null or
3510 p_pgm_id is not null) then
3511 --
3512 if nvl(ben_manage_life_events.g_defer_deenrol_flag,'N') <> 'Y' then -- Defer ENH
3513 --
3514 ben_newly_ineligible.main
3515 (p_person_id => p_person_id,
3516 p_pl_id => l_pl_id,
3517 p_pgm_id => nvl(p_pgm_id,l_envpgm_id),
3518 p_oipl_id => p_oipl_id,
3519 p_business_group_id => p_business_group_id,
3520 p_ler_id => p_ler_id,
3521 p_effective_date => l_effective_dt);
3522 -- p_effective_date => p_effective_date);
3523 --
3524 end if;
3525 --
3526 end if;
3527 --
3528 if p_ptip_id is not null then
3529 if nvl(ben_manage_life_events.g_defer_deenrol_flag,'N') <> 'Y' then -- Defer ENH
3530 --
3531 for l_rec in c_get_pl_from_ptip(nvl(l_fonm_cvg_strt_dt,p_effective_date)) loop
3532 ben_newly_ineligible.main
3533 (p_person_id => p_person_id,
3534 p_pl_id => l_rec.pl_id,
3535 p_pgm_id => nvl(p_pgm_id,l_envpgm_id),
3536 p_oipl_id => p_oipl_id,
3537 p_business_group_id => p_business_group_id,
3538 p_ler_id => p_ler_id,
3539 p_effective_date => l_effective_dt);
3540 -- p_effective_date => p_effective_date);
3541 end loop;
3542 --
3543 --
3544 end if;
3545 --
3546
3547 end if;
3548
3549 elsif l_first_inelig then --n
3550 --
3551 hr_utility.set_location ('first inelig',121);
3552 -- Get elig id from ben_elig_per_f for the plan
3553 --
3554 ben_pep_cache1.get_currplnpep_dets
3555 (p_comp_obj_tree_row => p_comp_obj_tree_row
3556 ,p_person_id => p_person_id
3557 ,p_effective_date => l_effective_dt
3558 --
3559 ,p_inst_row => l_plnpep_dets
3560 );
3561 --
3562 if l_plnpep_dets.elig_per_id is null
3563 then
3564 --
3565 fnd_message.set_name('BEN','BEN_91394_ELIG_NOT_FOUND');
3566 raise ben_manage_life_events.g_record_error;
3567 --
3568 else
3569 --
3570 l_elig_per_id := l_plnpep_dets.elig_per_id;
3571 l_elig_per_prtn_strt_dt := l_plnpep_dets.prtn_strt_dt;
3572 l_elig_per_prtn_end_dt := l_plnpep_dets.prtn_end_dt;
3573 --
3574 end if;
3575 --
3576 l_opt_id := l_oipl_rec.opt_id;
3577 --
3578 hr_utility.set_location('l_elig_per_id '||l_elig_per_id,10);
3579 hr_utility.set_location('l_elig_per_opt_id '||l_elig_per_opt_id,10);
3580 hr_utility.set_location('l_opt_id '||l_opt_id,10);
3581 hr_utility.set_location('p_effective_date '||p_effective_date,10);
3582 --
3583 -- Person not eligible now or in the past.
3584 -- Create elig person with elig flag = 'n'
3585 -- Call API
3586 --
3587 if instr(ben_manage_life_events.g_output_string,
3588 'Elg:') = 0 then
3589 --
3590 ben_manage_life_events.g_output_string :=
3591 ben_manage_life_events.g_output_string||
3592 'Elg: No '||
3593 'Rsn: Not Elig FTIME';
3594 --
3595 end if;
3596 --
3597 hr_utility.set_location('ben_determine_eligibility2.check_prev_elig Fir inel Cre EPO ' , 10);
3598 --
3599 l_elig_flag := 'N';
3600 l_prtn_strt_dt := l_end_dt_plus_one;
3601 --
3602 ben_Eligible_Person_perf_api.create_perf_Elig_Person_Option
3603 (p_validate => FALSE,
3604 p_elig_per_opt_id => l_elig_per_opt_id,
3605 p_elig_per_id => l_elig_per_id,
3606 p_per_in_ler_id => l_per_in_ler_id,
3607 p_effective_start_date => l_effective_start_date,
3608 p_effective_end_date => l_effective_end_date,
3609 p_prtn_ovridn_flag => 'N',
3610 p_prtn_ovridn_thru_dt => null,
3611 p_no_mx_prtn_ovrid_thru_flag => 'N',
3612 p_elig_flag => l_elig_flag,
3613 p_prtn_strt_dt => l_prtn_strt_dt,
3614 p_opt_id => l_opt_id,
3615 p_rt_comp_ref_amt => p_comp_rec.rt_comp_ref_amt,
3616 p_rt_cmbn_age_n_los_val => p_comp_rec.rt_cmbn_age_n_los_val,
3617 p_rt_comp_ref_uom => p_comp_rec.rt_comp_ref_uom,
3618 p_rt_age_val => p_comp_rec.rt_age_val,
3619 p_rt_los_val => p_comp_rec.rt_los_val,
3620 p_rt_hrs_wkd_val => p_comp_rec.rt_hrs_wkd_val,
3621 p_rt_hrs_wkd_bndry_perd_cd => p_comp_rec.rt_hrs_wkd_bndry_perd_cd,
3622 p_rt_age_uom => p_comp_rec.rt_age_uom,
3623 p_rt_los_uom => p_comp_rec.rt_los_uom,
3624 p_rt_pct_fl_tm_val => p_comp_rec.rt_pct_fl_tm_val,
3625 p_rt_frz_los_flag => 'N',
3626 p_rt_frz_age_flag => 'N',
3627 p_rt_frz_cmp_lvl_flag => 'N',
3628 p_rt_frz_pct_fl_tm_flag => 'N',
3629 p_rt_frz_hrs_wkd_flag => 'N',
3630 p_rt_frz_comb_age_and_los_flag => 'N',
3631 p_once_r_cntug_cd => p_comp_rec.once_r_cntug_cd,
3632 p_comp_ref_amt => p_comp_rec.comp_ref_amt,
3633 p_cmbn_age_n_los_val => p_comp_rec.cmbn_age_n_los_val,
3634 p_comp_ref_uom => p_comp_rec.comp_ref_uom,
3635 p_age_val => p_comp_rec.age_val,
3636 p_los_val => p_comp_rec.los_val,
3637 p_hrs_wkd_val => p_comp_rec.hrs_wkd_val,
3638 p_hrs_wkd_bndry_perd_cd => p_comp_rec.hrs_wkd_bndry_perd_cd,
3639 p_age_uom => p_comp_rec.age_uom,
3640 p_los_uom => p_comp_rec.los_uom,
3641 p_pct_fl_tm_val => p_comp_rec.pct_fl_tm_val,
3642 p_frz_los_flag => 'N',
3643 p_frz_age_flag => 'N',
3644 p_frz_cmp_lvl_flag => 'N',
3645 p_frz_pct_fl_tm_flag => 'N',
3646 p_frz_hrs_wkd_flag => 'N',
3647 p_frz_comb_age_and_los_flag => 'N',
3648 p_oipl_ordr_num => l_oipl_rec.ordr_num,
3649 p_business_group_id => p_business_group_id,
3650 --
3651 -- Bugs : 1412882, part of bug 1412951
3652 --
3653 p_effective_date => l_effective_dt,
3654 -- p_effective_date => p_effective_date,
3655 p_object_version_number => l_object_version_number_opt,
3656 p_program_application_id => fnd_global.prog_appl_id,
3657 p_program_id => fnd_global.conc_program_id,
3658 p_request_id => fnd_global.conc_request_id,
3659 p_program_update_date => sysdate,
3660 p_inelg_rsn_cd => p_inelg_rsn_cd
3661 --
3662 -- Bypass insert validate validation for performance
3663 --
3664 ,p_override_validation => TRUE);
3665 --
3666 hr_utility.set_location('ben_determine_eligibility2.check_prev_elig Dn Fir inel Cre EPO ' , 10);
3667 --
3668 -- ICM
3669 IF nvl(l_env_rec.mode_cd,'~') = 'D' THEN
3670 IF NOT ben_icm_life_events.g_cache_epo_object.EXISTS(1) THEN
3671 --
3672 l_count_icm1 := 1;
3673 --
3674 ELSE
3675 --
3676 l_count_icm1 := ben_icm_life_events.g_cache_epo_object.LAST + 1;
3677 --
3678 END IF;
3679 --
3680 hr_utility.set_location('Building epo cache1 7 : count ' || l_count_icm1,123);
3681 --
3682 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_id := l_elig_per_id;
3683 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_opt_id := l_elig_per_opt_id;
3684 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_start_date :=l_effective_start_date;
3685 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_end_date :=l_effective_end_date;
3686 ben_icm_life_events.g_cache_epo_object(l_count_icm1).business_group_id := p_business_group_id;
3687 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_ovridn_thru_dt := null;
3688 ben_icm_life_events.g_cache_epo_object(l_count_icm1).per_in_ler_id :=l_per_in_ler_id;
3689 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_ovridn_flag := 'N';
3690 ben_icm_life_events.g_cache_epo_object(l_count_icm1).no_mx_prtn_ovrid_thru_flag := 'N';
3691 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_strt_dt := l_prtn_strt_dt;
3692 ben_icm_life_events.g_cache_epo_object(l_count_icm1).opt_id := l_opt_id;
3693 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_flag :=l_elig_flag;
3694 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_amt := p_comp_rec.comp_ref_amt;
3695 ben_icm_life_events.g_cache_epo_object(l_count_icm1).cmbn_age_n_los_val := p_comp_rec.cmbn_age_n_los_val;
3696 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_uom := p_comp_rec.comp_ref_uom;
3697 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_val := p_comp_rec.age_val;
3698 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_uom := p_comp_rec.age_uom;
3699 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_val := p_comp_rec.los_val;
3700 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_uom := p_comp_rec.los_uom;
3701 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_val := p_comp_rec.hrs_wkd_val;
3702 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_bndry_perd_cd := p_comp_rec.hrs_wkd_bndry_perd_cd;
3703 ben_icm_life_events.g_cache_epo_object(l_count_icm1).pct_fl_tm_val := p_comp_rec.pct_fl_tm_val;
3704 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_los_flag :='N';
3705 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_age_flag :='N';
3706 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_cmp_lvl_flag :='N';
3707 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_pct_fl_tm_flag :='N';
3708 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_hrs_wkd_flag :='N';
3709 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_comb_age_and_los_flag :='N';
3710 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_amt := p_comp_rec.rt_comp_ref_amt;
3711 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_cmbn_age_n_los_val := p_comp_rec.rt_cmbn_age_n_los_val;
3712 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_uom := p_comp_rec.rt_comp_ref_uom;
3713 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_val := p_comp_rec.rt_age_val;
3714 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_uom := p_comp_rec.rt_age_uom;
3715 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_val := p_comp_rec.rt_los_val;
3716 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_uom := p_comp_rec.rt_los_uom;
3717 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_val := p_comp_rec.rt_hrs_wkd_val;
3718 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_bndry_perd_cd := p_comp_rec.rt_hrs_wkd_bndry_perd_cd;
3719 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_pct_fl_tm_val := p_comp_rec.rt_pct_fl_tm_val;
3720 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_los_flag :='N';
3721 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_age_flag :='N';
3722 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_cmp_lvl_flag :='N';
3723 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_pct_fl_tm_flag :='N';
3724 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_hrs_wkd_flag :='N';
3725 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_comb_age_and_los_flag :='N';
3726 ben_icm_life_events.g_cache_epo_object(l_count_icm1).once_r_cntug_cd := p_comp_rec.once_r_cntug_cd;
3727 ben_icm_life_events.g_cache_epo_object(l_count_icm1).oipl_ordr_num := l_oipl_rec.ordr_num;
3728 ben_icm_life_events.g_cache_epo_object(l_count_icm1).object_version_number := l_object_version_number_opt;
3729 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_application_id :=fnd_global.prog_appl_id;
3730 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_id :=fnd_global.conc_program_id;
3731 ben_icm_life_events.g_cache_epo_object(l_count_icm1).request_id :=fnd_global.conc_request_id;
3732 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_update_date :=sysdate;
3733 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_effective_date:= l_effective_dt;
3734 ben_icm_life_events.g_cache_epo_object(l_count_icm1).inelg_rsn_cd := p_inelg_rsn_cd;
3735 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_newly_elig := l_newly_elig;
3736 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_newly_inelig:= l_newly_inelig;
3737 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_first_elig := l_first_elig;
3738 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_first_inelig := l_first_inelig;
3739 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_still_elig := l_still_elig;
3740 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_still_inelig:= l_still_inelig;
3741 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_pl_id := l_envpl_id;
3742 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_cmpltn_dt := null;
3743 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_strt_dt := null;
3744 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_cmpltn_date := null;
3745 --
3746 END IF;
3747 if p_score_tab.count > 0 then
3748 hr_utility.set_location('writing score records ',5.5);
3749 ben_elig_scre_wtg_api.load_score_weight
3750 (p_validate => false
3751 ,p_score_tab => p_score_tab
3752 ,p_effective_date => l_effective_dt
3753 ,p_per_in_ler_id => l_per_in_ler_id /* Bug 4438430 */
3754 ,p_elig_per_id => l_elig_per_id
3755 ,p_elig_per_opt_id => l_elig_per_opt_id);
3756 end if;
3757 else
3758 --
3759 fnd_message.set_name('BEN','BEN_91392_ELIG_FLAG_ERROR');
3760 raise ben_manage_life_events.g_record_error;
3761 --
3762 end if; --n
3763 --
3764 -- Now check for the oiplip case.
3765 -- 1) Check if there is an oiplip for the oipl
3766 -- 2) Check if a prev oiplip row existed
3767 -- 3) If effective date is the same do a correction
3768 -- 4) If effective start date is another date so an update or update
3769 -- override
3770 -- 5) If the effective date is null then do an insert
3771 --
3772 if p_comp_obj_tree_row.oiplip_id is not null then
3773 --
3774 if g_debug then
3775 hr_utility.set_location('Creating OIPLIP',10);
3776 end if;
3777 l_object_version_number := null;
3778 --
3779 if g_debug then
3780 hr_utility.set_location('PLIP'||l_envplip_id,10);
3781 hr_utility.set_location('PGM'||l_envpgm_id,10);
3782 hr_utility.set_location('PERSON'||p_person_id,10);
3783 hr_utility.set_location('OPT_ID'||l_oipl_rec.opt_id,10);
3784 end if;
3785 --
3786 -- Check for previous OIPLIP
3787 --
3788 ben_pep_cache.get_pilepo_dets
3789 (p_person_id => p_person_id
3790 ,p_business_group_id => p_business_group_id
3791 ,p_effective_date => l_effective_dt
3792 ,p_pgm_id => l_envpgm_id
3793 ,p_plip_id => l_envplip_id
3794 ,p_opt_id => l_oipl_rec.opt_id
3795 ,p_date_sync => TRUE
3796 ,p_inst_row => l_oiplipepo_row
3797 );
3798 --
3799 if l_oiplipepo_row.elig_per_opt_id is null then
3800 --
3801 if g_debug then
3802 hr_utility.set_location('Record not found',10);
3803 end if;
3804 --
3805 ben_pep_cache1.get_curroiplippep_dets
3806 (p_comp_obj_tree_row => p_comp_obj_tree_row
3807 ,p_person_id => p_person_id
3808 ,p_effective_date => l_effective_dt
3809 --
3810 ,p_inst_row => l_oiplippep_dets
3811 );
3812 --
3813 l_prev_oiplip_elig_check.elig_per_id := l_oiplippep_dets.elig_per_id;
3814 --
3815 else
3816 --
3817 l_prev_oiplip_elig_check.elig_per_opt_id := l_oiplipepo_row.elig_per_opt_id;
3818 l_prev_oiplip_elig_check.elig_per_id := l_oiplipepo_row.elig_per_id;
3819 l_prev_oiplip_elig_check.object_version_number := l_oiplipepo_row.object_version_number;
3820 --
3821 end if;
3822 --
3823 if l_prev_oiplip_elig_check.elig_per_opt_id is null then
3824 --
3825 -- Bug 3111613
3826 -- if cache reeturns a null here, raise an error
3827 if l_prev_oiplip_elig_check.elig_per_id is null then
3828 fnd_message.set_name('BEN','BEN_91394_ELIG_NOT_FOUND');
3829 raise ben_manage_life_events.g_record_error;
3830 end if;
3831
3832
3833 -- Create oiplip record
3834 --
3835 if g_debug then
3836 hr_utility.set_location('ben_determine_eligibility2.check_prev_elig BEPOAPI_CreOIPLIP ' , 10);
3837 end if;
3838 --
3839 ben_Eligible_Person_perf_api.create_perf_Elig_Person_Option
3840 (p_validate => FALSE,
3841 p_elig_per_opt_id => l_prev_oiplip_elig_check.elig_per_opt_id,
3842 p_elig_per_id => l_prev_oiplip_elig_check.elig_per_id,
3843 p_per_in_ler_id => l_per_in_ler_id,
3844 p_prtn_ovridn_flag => 'N',
3845 p_prtn_ovridn_thru_dt => null,
3846 p_no_mx_prtn_ovrid_thru_flag => 'N',
3847 p_elig_flag => 'Y',
3848 p_prtn_strt_dt => null,
3849 p_opt_id => l_oipl_rec.opt_id,
3850 p_rt_comp_ref_amt => p_oiplip_rec.rt_comp_ref_amt,
3851 p_rt_cmbn_age_n_los_val => p_oiplip_rec.rt_cmbn_age_n_los_val,
3852 p_rt_comp_ref_uom => p_oiplip_rec.rt_comp_ref_uom,
3853 p_rt_age_val => p_oiplip_rec.rt_age_val,
3854 p_rt_los_val => p_oiplip_rec.rt_los_val,
3855 p_rt_hrs_wkd_val => p_oiplip_rec.rt_hrs_wkd_val,
3856 p_rt_hrs_wkd_bndry_perd_cd => p_oiplip_rec.rt_hrs_wkd_bndry_perd_cd,
3857 p_rt_age_uom => p_oiplip_rec.rt_age_uom,
3858 p_rt_los_uom => p_oiplip_rec.rt_los_uom,
3859 p_rt_pct_fl_tm_val => p_oiplip_rec.rt_pct_fl_tm_val,
3860 p_rt_frz_los_flag => 'N',
3861 p_rt_frz_age_flag => 'N',
3862 p_rt_frz_cmp_lvl_flag => 'N',
3863 p_rt_frz_pct_fl_tm_flag => 'N',
3864 p_rt_frz_hrs_wkd_flag => 'N',
3865 p_rt_frz_comb_age_and_los_flag => 'N',
3866 p_once_r_cntug_cd => p_oiplip_rec.once_r_cntug_cd,
3867 p_comp_ref_amt => p_oiplip_rec.comp_ref_amt,
3868 p_cmbn_age_n_los_val => p_oiplip_rec.cmbn_age_n_los_val,
3869 p_comp_ref_uom => p_oiplip_rec.comp_ref_uom,
3870 p_age_val => p_oiplip_rec.age_val,
3871 p_los_val => p_oiplip_rec.los_val,
3872 p_hrs_wkd_val => p_oiplip_rec.hrs_wkd_val,
3873 p_hrs_wkd_bndry_perd_cd => p_oiplip_rec.hrs_wkd_bndry_perd_cd,
3874 p_age_uom => p_oiplip_rec.age_uom,
3875 p_los_uom => p_oiplip_rec.los_uom,
3876 p_pct_fl_tm_val => p_oiplip_rec.pct_fl_tm_val,
3877 p_frz_los_flag => 'N',
3878 p_frz_age_flag => 'N',
3879 p_frz_cmp_lvl_flag => 'N',
3880 p_frz_pct_fl_tm_flag => 'N',
3881 p_frz_hrs_wkd_flag => 'N',
3882 p_frz_comb_age_and_los_flag => 'N',
3883 -- p_wait_perd_cmpltn_dt => null,
3884 p_wait_perd_cmpltn_date => null,
3885 p_wait_perd_strt_dt => null,
3886 p_effective_start_date => l_effective_start_date,
3887 p_effective_end_date => l_effective_end_date,
3888 p_object_version_number => l_prev_oiplip_elig_check.object_version_number,
3889 p_oipl_ordr_num => null,
3890 p_business_group_id => p_business_group_id,
3891 p_program_application_id => fnd_global.prog_appl_id,
3892 p_program_id => fnd_global.conc_program_id,
3893 p_request_id => fnd_global.conc_request_id,
3894 p_program_update_date => sysdate,
3895 --
3896 -- Bugs : 1412882, part of bug 1412951
3897 --
3898 p_effective_date => l_effective_dt,
3899 -- p_effective_date => p_effective_date
3900 p_override_validation => TRUE);
3901 --
3902 -- ICM
3903 IF nvl(l_env_rec.mode_cd,'~') = 'D' THEN
3904 IF NOT ben_icm_life_events.g_cache_epo_object.EXISTS(1) THEN
3905 --
3906 l_count_icm1 := 1;
3907 --
3908 ELSE
3909 --
3910 l_count_icm1 := ben_icm_life_events.g_cache_epo_object.LAST + 1;
3911 --
3912 END IF;
3913 --
3914 hr_utility.set_location('Building epo cache1 8 : count ' || l_count_icm1,123);
3915 --
3916 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_id := l_prev_oiplip_elig_check.elig_per_id;
3917 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_opt_id := l_prev_oiplip_elig_check.elig_per_opt_id;
3918 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_start_date :=l_effective_start_date;
3919 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_end_date :=l_effective_end_date;
3920 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_ovridn_flag := 'N';
3921 ben_icm_life_events.g_cache_epo_object(l_count_icm1).business_group_id := p_business_group_id;
3922 ben_icm_life_events.g_cache_epo_object(l_count_icm1).per_in_ler_id := l_per_in_ler_id;
3923 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_strt_dt := null;
3924 ben_icm_life_events.g_cache_epo_object(l_count_icm1).opt_id := l_oipl_rec.opt_id;
3925 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_ovridn_thru_dt := null;
3926 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_strt_dt :=null;
3927 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_cmpltn_date :=null;
3928 ben_icm_life_events.g_cache_epo_object(l_count_icm1).no_mx_prtn_ovrid_thru_flag := 'N';
3929 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_flag := 'Y';
3930 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_amt := p_oiplip_rec.comp_ref_amt;
3931 ben_icm_life_events.g_cache_epo_object(l_count_icm1).cmbn_age_n_los_val := p_oiplip_rec.cmbn_age_n_los_val;
3932 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_uom := p_oiplip_rec.comp_ref_uom;
3933 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_val := p_oiplip_rec.age_val;
3934 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_uom := p_oiplip_rec.age_uom;
3935 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_val := p_oiplip_rec.los_val;
3936 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_uom := p_oiplip_rec.los_uom;
3937 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_val := p_oiplip_rec.hrs_wkd_val;
3938 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_bndry_perd_cd := p_oiplip_rec.hrs_wkd_bndry_perd_cd;
3939 ben_icm_life_events.g_cache_epo_object(l_count_icm1).pct_fl_tm_val := p_oiplip_rec.pct_fl_tm_val;
3940 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_los_flag :='N';
3941 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_age_flag :='N';
3942 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_cmp_lvl_flag :='N';
3943 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_pct_fl_tm_flag :='N';
3944 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_hrs_wkd_flag :='N';
3945 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_comb_age_and_los_flag :='N';
3946 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_amt := p_oiplip_rec.rt_comp_ref_amt;
3947 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_cmbn_age_n_los_val := p_oiplip_rec.rt_cmbn_age_n_los_val;
3948 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_uom := p_oiplip_rec.rt_comp_ref_uom;
3949 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_val := p_oiplip_rec.rt_age_val;
3950 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_uom := p_oiplip_rec.rt_age_uom;
3951 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_val := p_oiplip_rec.rt_los_val;
3952 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_uom := p_oiplip_rec.rt_los_uom;
3953 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_val := p_oiplip_rec.rt_hrs_wkd_val;
3954 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_bndry_perd_cd := p_oiplip_rec.rt_hrs_wkd_bndry_perd_cd;
3955 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_pct_fl_tm_val := p_oiplip_rec.rt_pct_fl_tm_val;
3956 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_los_flag :='N';
3957 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_age_flag :='N';
3958 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_cmp_lvl_flag :='N';
3959 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_pct_fl_tm_flag :='N';
3960 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_hrs_wkd_flag :='N';
3961 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_comb_age_and_los_flag :='N';
3962 ben_icm_life_events.g_cache_epo_object(l_count_icm1).once_r_cntug_cd := p_oiplip_rec.once_r_cntug_cd;
3963 ben_icm_life_events.g_cache_epo_object(l_count_icm1).oipl_ordr_num := null;
3964 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_application_id :=fnd_global.prog_appl_id;
3965 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_id :=fnd_global.conc_program_id;
3966 ben_icm_life_events.g_cache_epo_object(l_count_icm1).request_id :=fnd_global.conc_request_id;
3967 ben_icm_life_events.g_cache_epo_object(l_count_icm1).object_version_number := l_prev_oiplip_elig_check.object_version_number;
3968 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_update_date :=sysdate;
3969 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_effective_date:= l_effective_dt;
3970 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_pl_id := l_envpl_id;
3971 --
3972 END IF;
3973 if g_debug then
3974 hr_utility.set_location('ben_determine_eligibility2.check_prev_elig Dn BEPOAPI_CreOIPLIP ' , 10);
3975 end if;
3976 --
3977 else
3978 --
3979 l_t_object_version_number := l_prev_oiplip_elig_check.object_version_number;
3980 --
3981 dt_api.find_dt_upd_modes
3982 (-- p_effective_date => p_effective_date,
3983 --
3984 -- Bugs : 1412882, part of bug 1412951
3985 --
3986 p_effective_date => l_effective_dt,
3987 --
3988 p_base_table_name => 'BEN_ELIG_PER_OPT_F',
3989 p_base_key_column => 'elig_per_opt_id',
3990 p_base_key_value => l_prev_oiplip_elig_check.elig_per_opt_id,
3991 p_correction => l_correction,
3992 p_update => l_update,
3993 p_update_override => l_update_override,
3994 p_update_change_insert => l_update_change_insert);
3995 --
3996 if l_update_override then
3997 --
3998 l_datetrack_mode := hr_api.g_update_override;
3999 --
4000 elsif l_update then
4001 --
4002 l_datetrack_mode := hr_api.g_update;
4003 --
4004 else
4005 --
4006 l_datetrack_mode := hr_api.g_correction;
4007 --
4008 end if;
4009 --
4010 -- Update oiplip record with correct mode
4011 --
4012 IF l_datetrack_mode = hr_api.g_correction AND
4013 l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
4014 --
4015 ben_determine_eligibility3.save_to_restore
4016 (p_current_per_in_ler_id => l_per_in_ler_id
4017 ,p_per_in_ler_id => l_prev_per_in_ler_id
4018 ,p_elig_per_id => NULL
4019 ,p_elig_per_opt_id => l_prev_oiplip_elig_check.elig_per_opt_id
4020 ,p_effective_date => l_effective_dt
4021 );
4022 --
4023 END IF;
4024 --
4025 ---------------------------------------------------------------------------------
4026 --Bug 12732878 changes
4027 --If the oiplip comp object is Newly eligible/Still eligible then checking whether the same comp object
4028 --Future records are present in ben_elig_per_opt_f tables.If present inserting them into
4029 --backup table.
4030
4031 IF (l_datetrack_mode = hr_api.g_update_override) -- AND
4032 -- l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
4033 then --
4034 open c_prev_pil(p_pil_row.per_in_ler_id);
4035 fetch c_prev_pil into l_prev_pil_id;
4036 close c_prev_pil;
4037
4038 hr_utility.set_location('l_prev_pil_id ' || l_prev_pil_id, 7776);
4039
4040 open c_elig_opt_rec(l_prev_oiplip_elig_check.elig_per_opt_id,l_prev_pil_id);
4041 fetch c_elig_opt_rec into l_elig_per_opt_rec;
4042 close c_elig_opt_rec;
4043
4044 hr_utility.set_location('uxx l_elig_per_opt_rec.elig_per_opt_id '||l_elig_per_opt_rec.elig_per_opt_id,10);
4045
4046 open c_elig_per_opt_id(l_prev_pil_id,
4047 l_elig_per_opt_rec.elig_per_opt_id,
4048 p_effective_date);
4049 fetch c_elig_per_opt_id into l_ftr_elig_per_opt_rec;
4050 close c_elig_per_opt_id;
4051
4052 hr_utility.set_location('uxx l_ftr_elig_per_opt_rec.elig_per_opt_id '||l_ftr_elig_per_opt_rec.elig_per_opt_id,10);
4053 hr_utility.set_location('uxx l_ftr_elig_per_opt_rec.effective_start_date '||l_ftr_elig_per_opt_rec.effective_start_date,10);
4054
4055 if(l_ftr_elig_per_opt_rec.elig_per_opt_id is not null) then
4056 hr_utility.set_location('uxx save to restore in if ',10);
4057
4058 ben_determine_eligibility3.save_to_restore
4059 (p_current_per_in_ler_id => l_per_in_ler_id
4060 ,p_per_in_ler_id => l_prev_pil_id
4061 ,p_elig_per_id => NUll
4062 ,p_elig_per_opt_id => l_ftr_elig_per_opt_rec.elig_per_opt_id
4063 ,p_effective_date => l_ftr_elig_per_opt_rec.effective_start_date
4064 );
4065 /* else
4066 hr_utility.set_location('uxx save to restore in else ',10);
4067 ben_determine_eligibility3.save_to_restore
4068 (p_current_per_in_ler_id => l_per_in_ler_id
4069 ,p_per_in_ler_id => l_prev_per_in_ler_id
4070 ,p_elig_per_id => NULL
4071 ,p_elig_per_opt_id => l_prev_oiplip_elig_check.elig_per_opt_id
4072 ,p_effective_date => l_effective_dt
4073 );*/
4074 end if;
4075 --
4076 END IF;
4077 --Bug 12732878 changes end
4078 ----------------------------------------------------------------------------
4079
4080
4081 ben_Eligible_Person_perf_api.update_perf_Elig_Person_Option
4082 (p_validate => FALSE,
4083 p_elig_per_opt_id => l_prev_oiplip_elig_check.elig_per_opt_id,
4084 p_elig_per_id => l_prev_oiplip_elig_check.elig_per_id,
4085 p_effective_start_date => l_effective_start_date,
4086 p_effective_end_date => l_effective_end_date,
4087 p_per_in_ler_id => l_per_in_ler_id,
4088 p_elig_flag => 'Y',
4089 p_prtn_strt_dt => null,
4090 p_prtn_end_dt => null,
4091 p_rt_comp_ref_amt => p_oiplip_rec.rt_comp_ref_amt,
4092 p_rt_cmbn_age_n_los_val => p_oiplip_rec.rt_cmbn_age_n_los_val,
4093 p_rt_comp_ref_uom => p_oiplip_rec.rt_comp_ref_uom,
4094 p_rt_age_val => p_oiplip_rec.rt_age_val,
4095 p_rt_los_val => p_oiplip_rec.rt_los_val,
4096 p_rt_hrs_wkd_val => p_oiplip_rec.rt_hrs_wkd_val,
4097 p_rt_hrs_wkd_bndry_perd_cd => p_oiplip_rec.rt_hrs_wkd_bndry_perd_cd,
4098 p_rt_age_uom => p_oiplip_rec.rt_age_uom,
4099 p_rt_los_uom => p_oiplip_rec.rt_los_uom,
4100 p_rt_pct_fl_tm_val => p_oiplip_rec.rt_pct_fl_tm_val,
4101 p_rt_frz_los_flag => 'N',
4102 p_rt_frz_age_flag => 'N',
4103 p_rt_frz_cmp_lvl_flag => 'N',
4104 p_rt_frz_pct_fl_tm_flag => 'N',
4105 p_rt_frz_hrs_wkd_flag => 'N',
4106 p_rt_frz_comb_age_and_los_flag => 'N',
4107 p_once_r_cntug_cd => p_oiplip_rec.once_r_cntug_cd,
4108 p_comp_ref_amt => p_oiplip_rec.comp_ref_amt,
4109 p_cmbn_age_n_los_val => p_oiplip_rec.cmbn_age_n_los_val,
4110 p_comp_ref_uom => p_oiplip_rec.comp_ref_uom,
4111 p_age_val => p_oiplip_rec.age_val,
4112 p_los_val => p_oiplip_rec.los_val,
4113 p_hrs_wkd_val => p_oiplip_rec.hrs_wkd_val,
4114 p_hrs_wkd_bndry_perd_cd => p_oiplip_rec.hrs_wkd_bndry_perd_cd,
4115 p_age_uom => p_oiplip_rec.age_uom,
4116 p_los_uom => p_oiplip_rec.los_uom,
4117 p_pct_fl_tm_val => p_oiplip_rec.pct_fl_tm_val,
4118 p_frz_los_flag => 'N',
4119 p_frz_age_flag => 'N',
4120 p_frz_cmp_lvl_flag => 'N',
4121 p_frz_pct_fl_tm_flag => 'N',
4122 p_frz_hrs_wkd_flag => 'N',
4123 p_frz_comb_age_and_los_flag => 'N',
4124 -- p_wait_perd_cmpltn_dt => null,
4125 p_wait_perd_cmpltn_date => null,
4126 p_wait_perd_strt_dt => null,
4127 --
4128 -- Bugs : 1412882, part of bug 1412951
4129 --
4130 p_effective_date => l_effective_dt,
4131 -- p_effective_date => p_effective_date,
4132 p_object_version_number => l_prev_oiplip_elig_check.object_version_number,
4133 p_datetrack_mode => l_datetrack_mode,
4134 p_program_application_id => fnd_global.prog_appl_id,
4135 p_program_id => fnd_global.conc_program_id,
4136 p_request_id => fnd_global.conc_request_id,
4137 p_program_update_date => sysdate);
4138 --
4139 IF nvl(l_env_rec.mode_cd,'~') = 'D' THEN
4140 IF NOT ben_icm_life_events.g_cache_epo_object.EXISTS(1) THEN
4141 --
4142 l_count_icm1 := 1;
4143 --
4144 ELSE
4145 --
4146 l_count_icm1 := ben_icm_life_events.g_cache_epo_object.LAST + 1;
4147 --
4148 END IF;
4149 --
4150 hr_utility.set_location('Building epo cache1 9 : count ',123);
4151 --
4152 --ICM
4153 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_id := l_prev_oiplip_elig_check.elig_per_id;
4154 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_per_opt_id := l_prev_oiplip_elig_check.elig_per_opt_id;
4155 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_start_date :=l_effective_start_date;
4156 ben_icm_life_events.g_cache_epo_object(l_count_icm1).effective_end_date :=l_effective_end_date;
4157 ben_icm_life_events.g_cache_epo_object(l_count_icm1).business_group_id := p_business_group_id;
4158 ben_icm_life_events.g_cache_epo_object(l_count_icm1).per_in_ler_id :=l_per_in_ler_id;
4159 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_strt_dt := null;
4160 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_end_dt := null;
4161 ben_icm_life_events.g_cache_epo_object(l_count_icm1).opt_id := l_oipl_rec.opt_id;
4162 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_cmpltn_date := null;
4163 ben_icm_life_events.g_cache_epo_object(l_count_icm1).wait_perd_strt_dt := null;
4164 ben_icm_life_events.g_cache_epo_object(l_count_icm1).elig_flag := 'Y';
4165 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_amt := p_oiplip_rec.comp_ref_amt;
4166 ben_icm_life_events.g_cache_epo_object(l_count_icm1).cmbn_age_n_los_val := p_oiplip_rec.cmbn_age_n_los_val;
4167 ben_icm_life_events.g_cache_epo_object(l_count_icm1).comp_ref_uom := p_oiplip_rec.comp_ref_uom;
4168 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_val := p_oiplip_rec.age_val;
4169 ben_icm_life_events.g_cache_epo_object(l_count_icm1).age_uom := p_oiplip_rec.age_uom;
4170 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_val := p_oiplip_rec.los_val;
4171 ben_icm_life_events.g_cache_epo_object(l_count_icm1).los_uom := p_oiplip_rec.los_uom;
4172 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_val := p_oiplip_rec.hrs_wkd_val;
4173 ben_icm_life_events.g_cache_epo_object(l_count_icm1).hrs_wkd_bndry_perd_cd := p_oiplip_rec.hrs_wkd_bndry_perd_cd;
4174 ben_icm_life_events.g_cache_epo_object(l_count_icm1).pct_fl_tm_val := p_oiplip_rec.pct_fl_tm_val;
4175 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_los_flag :='N';
4176 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_age_flag :='N';
4177 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_cmp_lvl_flag :='N';
4178 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_pct_fl_tm_flag :='N';
4179 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_hrs_wkd_flag :='N';
4180 ben_icm_life_events.g_cache_epo_object(l_count_icm1).frz_comb_age_and_los_flag :='N';
4181 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_amt := p_oiplip_rec.rt_comp_ref_amt;
4182 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_cmbn_age_n_los_val := p_oiplip_rec.rt_cmbn_age_n_los_val;
4183 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_comp_ref_uom := p_oiplip_rec.rt_comp_ref_uom;
4184 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_val := p_oiplip_rec.rt_age_val;
4185 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_age_uom := p_oiplip_rec.rt_age_uom;
4186 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_val := p_oiplip_rec.rt_los_val;
4187 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_los_uom := p_oiplip_rec.rt_los_uom;
4188 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_val := p_oiplip_rec.rt_hrs_wkd_val;
4189 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_hrs_wkd_bndry_perd_cd := p_oiplip_rec.rt_hrs_wkd_bndry_perd_cd;
4190 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_pct_fl_tm_val := p_oiplip_rec.rt_pct_fl_tm_val;
4191 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_los_flag :='N';
4192 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_age_flag :='N';
4193 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_cmp_lvl_flag :='N';
4194 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_pct_fl_tm_flag :='N';
4195 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_hrs_wkd_flag :='N';
4196 ben_icm_life_events.g_cache_epo_object(l_count_icm1).rt_frz_comb_age_and_los_flag :='N';
4197 ben_icm_life_events.g_cache_epo_object(l_count_icm1).once_r_cntug_cd := p_oiplip_rec.once_r_cntug_cd;
4198 ben_icm_life_events.g_cache_epo_object(l_count_icm1).object_version_number := l_t_object_version_number; --l_prev_oiplip_elig_check.object_version_number-1;
4199 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_application_id :=fnd_global.prog_appl_id;
4200 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_id :=fnd_global.conc_program_id;
4201 ben_icm_life_events.g_cache_epo_object(l_count_icm1).request_id :=fnd_global.conc_request_id;
4202 ben_icm_life_events.g_cache_epo_object(l_count_icm1).program_update_date :=sysdate;
4203 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_effective_date:= l_effective_dt;
4204 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_datetrack_mode:=l_datetrack_mode;
4205 ben_icm_life_events.g_cache_epo_object(l_count_icm1).p_pl_id := l_envpl_id;
4206 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_ovridn_flag := 'N';
4207 ben_icm_life_events.g_cache_epo_object(l_count_icm1).no_mx_prtn_ovrid_thru_flag := 'N';
4208 ben_icm_life_events.g_cache_epo_object(l_count_icm1).prtn_ovridn_thru_dt := null;
4209 --
4210 END IF;
4211 --ICM
4212 end if;
4213 --
4214 end if;
4215 --
4216 else --a
4217 --
4218 if g_debug then
4219 hr_utility.set_location(' Chk Prev Oipl ben_determine_eligibility2.check_prev_elig ', 10);
4220 end if;
4221 --
4222 -- Check for a plan in program or a plip
4223 --
4224 if l_envpgm_id is not null
4225 and (p_pl_id is not null
4226 or p_plip_id is not null)
4227 then
4228 --
4229 if g_debug then
4230 hr_utility.set_location(' before pilpep ',111);
4231 end if;
4232 ben_pep_cache.get_pilpep_dets
4233 (p_person_id => p_person_id
4234 ,p_business_group_id => p_business_group_id
4235 ,p_effective_date => l_effective_dt
4236 ,p_pgm_id => l_envpgm_id
4237 ,p_pl_id => p_pl_id
4238 ,p_plip_id => p_plip_id
4239 ,p_date_sync => TRUE
4240 ,p_inst_row => l_pep_row
4241 );
4242 --
4243 l_elig_per_id := l_pep_row.elig_per_id;
4244 l_elig_per_elig_flag := l_pep_row.elig_flag;
4245 l_prev_prtn_strt_dt := l_pep_row.prtn_strt_dt;
4246 l_prev_prtn_end_dt := l_pep_row.prtn_end_dt;
4247 l_per_in_ler_id := l_pep_row.per_in_ler_id;
4248 l_object_version_number := l_pep_row.object_version_number;
4249 --
4250 if g_debug then
4251 hr_utility.set_location('elig per id'||l_elig_per_id,11);
4252 hr_utility.set_location('per in ler id'||l_per_in_ler_id,11);
4253 hr_utility.set_location('prtn start date'||l_prev_prtn_strt_dt,12);
4254 hr_utility.set_location(' effective date '|| l_effective_dt,111);
4255 end if;
4256 if l_pep_row.elig_per_id is null then
4257 --
4258 l_prev_eligibility := false;
4259 --
4260 else
4261 --
4262 l_prev_eligibility := true;
4263 --
4264 end if;
4265 --
4266 -- plan not in a program, pgm or ptip
4267 --
4268 else
4269 --
4270 if g_debug then
4271 hr_utility.set_location('l effective date'|| l_effective_dt,11);
4272 hr_utility.set_location('lf evt ocrd date'|| p_lf_evt_ocrd_dt,11);
4273 end if;
4274 --
4275 ben_determine_eligibility4.prev_elig_check
4276 (p_person_id => p_person_id
4277 ,p_pgm_id => nvl(p_pgm_id,nvl(l_envpgm_id,-1))
4278 ,p_pl_id => nvl(p_pl_id,-1)
4279 ,p_ptip_id => nvl(p_ptip_id,-1)
4280 ,p_effective_date => l_effective_dt
4281 ,p_mode_cd => l_benmngle_parm_rec.mode_cd
4282 ,p_irec_asg_id => ben_manage_life_events.g_irec_ass_rec.assignment_id
4283 --
4284 ,p_prev_eligibility => l_prev_eligibility
4285 ,p_elig_per_id => l_elig_per_id
4286 ,p_elig_per_elig_flag => l_elig_per_elig_flag
4287 ,p_prev_prtn_strt_dt => l_prev_prtn_strt_dt
4288 ,p_prev_prtn_end_dt => l_prev_prtn_end_dt
4289 ,p_per_in_ler_id => l_per_in_ler_id
4290 ,p_object_version_number => l_object_version_number
4291 ,p_prev_age_val => l_old_age_val
4292 ,p_prev_los_val => l_old_los_val
4293 );
4294 --
4295 -- l_p_object_version_number := l_object_version_number;
4296 end if;
4297 --
4298 if g_debug then
4299 hr_utility.set_location('object version number'||l_object_version_number,11);
4300 hr_utility.set_location('Dn fetch c_prvelgchk ben_determine_eligibility2.check_prev_elig', 10);
4301 end if;
4302 --
4303 l_prev_per_in_ler_id := l_per_in_ler_id;
4304 --
4305 if l_new_per_in_ler_id is not null then
4306 l_per_in_ler_id:=l_new_per_in_ler_id;
4307 end if;
4308 --
4309 if g_debug then
4310 hr_utility.set_location('before prev notfound check ben_determine_eligibility2.check_prev_elig', 10);
4311 end if;
4312 --
4313 if p_pgm_id is not null then
4314 --
4315 l_pgm_rec := ben_cobj_cache.g_pgm_currow;
4316 --
4317 end if;
4318 --
4319 if p_pl_id is not null then
4320 --
4321 l_pl_rec := ben_cobj_cache.g_pl_currow;
4322 --
4323 end if;
4324 --
4325 if p_plip_id is not null then
4326 --
4327 l_plip_rec := ben_cobj_cache.g_plip_currow;
4328 --
4329 end if;
4330 --
4331 if p_ptip_id is not null then
4332 --
4333 l_ptip_rec := ben_cobj_cache.g_ptip_currow;
4334 --
4335 end if;
4336 --
4337 if not l_prev_eligibility
4338 then
4339 --
4340 --No record exists. Person not previously elig or inelig.
4341 --
4342 if g_debug then
4343 hr_utility.set_location('prev elig notfound ben_determine_eligibility2.check_prev_elig', 10);
4344 end if;
4345
4346 if p_elig_flag then
4347 --
4348 if g_debug then
4349 hr_utility.set_location('elig is true ben_determine_eligibility2.check_prev_elig', 10);
4350 end if;
4351 l_first_elig := true;
4352 hr_utility.set_location ('first elig',121);
4353 l_start_or_end := 'S';
4354 fnd_message.set_name ('BEN','BEN_91385_FIRST_ELIG');
4355 benutils.write(p_text => fnd_message.get);
4356 --
4357 else
4358 --
4359 hr_utility.set_location('elig is false ben_determine_eligibility2.check_prev_elig', 10);
4360 fnd_message.set_name ('BEN','BEN_92533_FIRST_INELIG2');
4361 benutils.write(p_text => fnd_message.get);
4362 --
4363 -- only continue with program and call of api if we want to track
4364 -- inelig people.
4365 --
4366 if p_pgm_id is not null then
4367 --
4368 l_trk_inelig_per_flag := l_pgm_rec.trk_inelig_per_flag;
4369 hr_utility.set_location('Dn p_pgm_id NN ben_determine_eligibility2.check_prev_elig', 10);
4370 --
4371 elsif p_pl_id is not null then
4372 --
4373 l_trk_inelig_per_flag := l_pl_rec.trk_inelig_per_flag;
4374 hr_utility.set_location('Dn p_pl_id NN ben_determine_eligibility2.check_prev_elig', 10);
4375 --
4376 elsif p_plip_id is not null then
4377 --
4378 l_trk_inelig_per_flag := l_plip_rec.trk_inelig_per_flag;
4379 --
4380 hr_utility.set_location('Dn p_plip_id NN ben_determine_eligibility2.check_prev_elig', 10);
4381 elsif p_ptip_id is not null then
4382 --
4383 l_trk_inelig_per_flag := l_ptip_rec.trk_inelig_per_flag;
4384 --
4385 hr_utility.set_location('Dn p_ptip_id NN ben_determine_eligibility2.check_prev_elig', 10);
4386 end if;
4387 --
4388 if l_trk_inelig_per_flag = 'Y' then
4389 --
4390 hr_utility.set_location ('first inelig',121);
4391 l_first_inelig := true;
4392 l_start_or_end := 'E';
4393 --
4394 else
4395 --
4396 if instr(ben_manage_life_events.g_output_string,
4397 'Elg:') = 0 then
4398 --
4399 ben_manage_life_events.g_output_string :=
4400 ben_manage_life_events.g_output_string||
4401 'Elg: No '||
4402 'Rsn: Not Elig FTIME';
4403 --
4404 end if;
4405 --
4406 -- Set transition state for processing only. Elig
4407 -- per is not written
4408 --
4409 hr_utility.set_location('NT Fir InEl TRUE ben_determine_eligibility2.check_prev_elig', 10);
4410 p_first_inelig := true;
4411 --
4412 -- bug#5404392 - previous FONM event creates the elig per row in future
4413 -- the subsequent finds first ineligible
4414 if p_pgm_id is not null then
4415 if nvl(ben_manage_life_events.g_defer_deenrol_flag,'N') <> 'Y' then -- Defer ENH
4416 --
4417 ben_newly_ineligible.main
4418 (p_person_id => p_person_id,
4419 p_pl_id => null,
4420 p_pgm_id => p_pgm_id,
4421 p_oipl_id => null,
4422 p_business_group_id => p_business_group_id,
4423 p_ler_id => p_ler_id,
4424 p_effective_date => l_effective_dt);
4425 --
4426 --
4427 end if;
4428 --
4429 end if;
4430 --
4431 return;
4432 --
4433 end if;
4434 --
4435 end if;
4436 --
4437 elsif l_prev_eligibility
4438 then
4439 --
4440 hr_utility.set_location('Prev eligibility true ',100);
4441 hr_utility.set_location( 'l_elig_per_elig_flag'||l_elig_per_elig_flag,123);
4442 if l_elig_per_elig_flag = 'Y' and p_elig_flag then --d
4443 --
4444 hr_utility.set_location ('still elig',121);
4445 -- Person still eligible, do nothing.
4446 --
4447 fnd_message.set_name ('BEN','BEN_91345_ELIG_PREV_ELIG');
4448 benutils.write(p_text => fnd_message.get);
4449 l_start_or_end := 'S';
4450 l_still_elig := true;
4451 --
4452 --return;
4453 --
4454 elsif l_elig_per_elig_flag = 'Y' and p_elig_flag = false then --d
4455 -- person is newly inelig
4456 hr_utility.set_location ('newly inelig',121);
4457 l_newly_inelig := true;
4458 l_start_or_end := 'E';
4459 fnd_message.set_name('BEN','BEN_91347_NOT_ELIG_PREV_ELIG');
4460 benutils.write(p_text => fnd_message.get);
4461 --
4462 elsif l_elig_per_elig_flag = 'N' and p_elig_flag = false then --d
4463 -- person is still inelig, do nothing.
4464 fnd_message.set_name('BEN','BEN_91348_NOT_ELIG_PREV_NT_ELG');
4465 benutils.write(p_text => fnd_message.get);
4466 --
4467 -- Set transition state for processing only. Elig
4468 -- per is not written
4469 --
4470 p_still_inelig := TRUE; --Bug 9789915 : changed l_still_inelig to p_still_inelig
4471 --
4472 /* Fidelity Enh - inelig to inelig */
4473 if l_benmngle_parm_rec.mode_cd in ('L','C') then
4474 if p_pgm_id is not null then
4475 --
4476 l_trk_inelig_per_flag := l_pgm_rec.trk_inelig_per_flag;
4477 --
4478 elsif p_pl_id is not null then
4479 --
4480 l_trk_inelig_per_flag := l_pl_rec.trk_inelig_per_flag;
4481 --
4482 elsif p_plip_id is not null then
4483 --
4484 l_trk_inelig_per_flag := l_plip_rec.trk_inelig_per_flag;
4485 --
4486 elsif p_ptip_id is not null then
4487 --
4488 l_trk_inelig_per_flag := l_ptip_rec.trk_inelig_per_flag;
4489 --
4490 end if;
4491 end if;
4492
4493 if g_debug then
4494 hr_utility.set_location ('New update for elig per'||l_elig_per_id,101);
4495 hr_utility.set_location ('Update mode'||l_datetrack_mode,102);
4496 end if;
4497 --
4498 if l_trk_inelig_per_flag = 'Y' then
4499 if l_envpgm_id is not null
4500 and (p_pl_id is not null
4501 or p_plip_id is not null) then
4502 l_old_age_val := l_pep_row.age_val;
4503 l_old_los_val := l_pep_row.los_val;
4504 end if;
4505 --
4506 -- Bug 8542643: Update the still inelig records irrespective of whether
4507 -- old value is greater or new value is greater for age or los
4508 if p_comp_rec.age_val is not null or
4509 p_comp_rec.los_val is not null
4510 then
4511 --
4512 l_p_object_version_number := l_object_version_number;
4513 --
4514 -- start of changes against bug 6601884
4515 --
4516
4517 -- Get the datetrack update mode. If the record already exists and the effective date is
4518 -- same as start date, then update should be done in correction mode. In that case, the old
4519 -- record should be inserted in the backup table
4520
4521 if g_debug then
4522 hr_utility.set_location('ben_determine_eligibility2.check_prev_elig DTAPI_FDUM ', 889);
4523 hr_utility.set_location('l_elig_per_id '||l_elig_per_id, 889);
4524 hr_utility.set_location('l_object_version_number '||l_object_version_number, 889);
4525 hr_utility.set_location('l_effective_dt '||l_effective_dt, 889);
4526 end if;
4527
4528 dt_api.find_dt_upd_modes
4529 (p_effective_date => l_effective_dt,
4530 p_base_table_name => 'BEN_ELIG_PER_F',
4531 p_base_key_column => 'elig_per_id',
4532 p_base_key_value => l_elig_per_id,
4533 p_correction => l_correction,
4534 p_update => l_update,
4535 p_update_override => l_update_override,
4536 p_update_change_insert => l_update_change_insert);
4537
4538 if g_debug then
4539 hr_utility.set_location('ben_determine_eligibility2.check_prev_elig Dn DTAPI_FDUM ', 10);
4540 end if;
4541
4542 if l_update_override then
4543 l_datetrack_mode := hr_api.g_update_override;
4544
4545 if g_debug then
4546 hr_utility.set_location('ben_elig_per_f l_datetrack_mode '|| l_datetrack_mode, 777);
4547 end if;
4548
4549 elsif l_update then
4550 l_datetrack_mode := hr_api.g_update;
4551
4552 if g_debug then
4553 hr_utility.set_location('ben_elig_per_f l_datetrack_mode '|| l_datetrack_mode, 777);
4554 end if;
4555
4556 else
4557 l_datetrack_mode := hr_api.g_correction;
4558
4559 if g_debug then
4560 hr_utility.set_location('ben_elig_per_f l_datetrack_mode '|| l_datetrack_mode, 777);
4561 end if;
4562
4563 end if;
4564
4565
4566 hr_utility.set_location('l_per_in_ler_id'||l_per_in_ler_id,112);
4567 hr_utility.set_location('l_prev_per_in_ler_id'|| l_prev_per_in_ler_id,112);
4568 hr_utility.set_location('p_ler_id '|| p_ler_id,112);
4569
4570 IF l_datetrack_mode = hr_api.g_correction AND
4571 l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
4572
4573 ben_determine_eligibility3.save_to_restore
4574 (p_current_per_in_ler_id => l_per_in_ler_id
4575 ,p_per_in_ler_id => l_prev_per_in_ler_id
4576 ,p_elig_per_id => l_elig_per_id
4577 ,p_elig_per_opt_id => NULL
4578 ,p_effective_date => l_effective_dt
4579 );
4580
4581 END IF;
4582
4583 /* Bug 9020962: If future eligibility record exists, then insert the record
4584 in backup table ben_le_clsn_n_rstr */
4585 IF (l_datetrack_mode = hr_api.g_update_override) AND
4586 l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
4587 --
4588
4589 open c_prev_pil(p_pil_row.per_in_ler_id);
4590 fetch c_prev_pil into l_prev_pil_id;
4591 close c_prev_pil;
4592 hr_utility.set_location('l_prev_pil_id ' || l_prev_pil_id, 7776);
4593
4594 open c_elig_rec(l_elig_per_id,l_prev_per_in_ler_id);
4595 fetch c_elig_rec into l_elig_per_rec;
4596 close c_elig_rec;
4597
4598 open c_elig_per_id(l_prev_pil_id,
4599 l_elig_per_rec.pl_id,
4600 l_elig_per_rec.pgm_id,
4601 l_elig_per_rec.ptip_id,
4602 l_elig_per_rec.plip_id,
4603 p_effective_date);
4604 fetch c_elig_per_id into l_ftr_elig_per_rec;
4605 close c_elig_per_id;
4606 if(l_ftr_elig_per_rec.elig_per_id is not null) then
4607 ben_determine_eligibility3.save_to_restore
4608 (p_current_per_in_ler_id => l_per_in_ler_id
4609 ,p_per_in_ler_id => l_prev_pil_id
4610 ,p_elig_per_id => l_ftr_elig_per_rec.elig_per_id
4611 ,p_elig_per_opt_id => NULL
4612 ,p_effective_date => l_ftr_elig_per_rec.effective_start_date
4613 );
4614 else
4615 ben_determine_eligibility3.save_to_restore
4616 (p_current_per_in_ler_id => l_per_in_ler_id
4617 ,p_per_in_ler_id => l_prev_per_in_ler_id
4618 ,p_elig_per_id => l_elig_per_id
4619 ,p_elig_per_opt_id => NULL
4620 ,p_effective_date => l_effective_dt
4621 );
4622 end if;
4623 --
4624 END IF;
4625 /* End of Bug 9020962 */
4626
4627 hr_utility.set_location('Updating pep with l_per_in_ler_id'||l_per_in_ler_id,112);
4628
4629 ben_Eligible_Person_perf_api.update_perf_Eligible_Person
4630 (p_validate => FALSE,
4631 p_elig_per_id => l_elig_per_id,
4632 p_per_in_ler_id => l_per_in_ler_id,
4633 p_effective_start_date => l_effective_start_date,
4634 p_effective_end_date => l_effective_end_date,
4635 p_elig_flag => 'N', --l_elig_flag,
4636 p_prtn_strt_dt => l_prtn_strt_dt,
4637 p_prtn_end_dt => null,
4638 p_ler_id => p_ler_id, -- bug 5478994
4639 p_rt_comp_ref_amt => p_comp_rec.rt_comp_ref_amt,
4640 p_rt_cmbn_age_n_los_val => p_comp_rec.rt_cmbn_age_n_los_val,
4641 p_rt_comp_ref_uom => p_comp_rec.rt_comp_ref_uom,
4642 p_rt_age_val => p_comp_rec.rt_age_val,
4643 p_rt_los_val => p_comp_rec.rt_los_val,
4644 p_rt_hrs_wkd_val => p_comp_rec.rt_hrs_wkd_val,
4645 p_rt_hrs_wkd_bndry_perd_cd => p_comp_rec.rt_hrs_wkd_bndry_perd_cd,
4646 p_rt_age_uom => p_comp_rec.rt_age_uom,
4647 p_rt_los_uom => p_comp_rec.rt_los_uom,
4648 p_rt_pct_fl_tm_val => p_comp_rec.rt_pct_fl_tm_val,
4649 p_rt_frz_los_flag => 'N',
4650 p_rt_frz_age_flag => 'N',
4651 p_rt_frz_cmp_lvl_flag => 'N',
4652 p_rt_frz_pct_fl_tm_flag => 'N',
4653 p_rt_frz_hrs_wkd_flag => 'N',
4654 p_rt_frz_comb_age_and_los_flag => 'N',
4655 p_once_r_cntug_cd => p_comp_rec.once_r_cntug_cd,
4656 p_comp_ref_amt => p_comp_rec.comp_ref_amt,
4657 p_cmbn_age_n_los_val => p_comp_rec.cmbn_age_n_los_val,
4658 p_comp_ref_uom => p_comp_rec.comp_ref_uom,
4659 p_age_val => p_comp_rec.age_val,
4660 p_los_val => p_comp_rec.los_val,
4661 p_hrs_wkd_val => p_comp_rec.hrs_wkd_val,
4662 p_hrs_wkd_bndry_perd_cd => p_comp_rec.hrs_wkd_bndry_perd_cd,
4663 p_age_uom => p_comp_rec.age_uom,
4664 p_los_uom => p_comp_rec.los_uom,
4665 p_pct_fl_tm_val => p_comp_rec.pct_fl_tm_val,
4666 p_frz_los_flag => 'N',
4667 p_frz_age_flag => 'N',
4668 p_frz_cmp_lvl_flag => 'N',
4669 p_frz_pct_fl_tm_flag => 'N',
4670 p_frz_hrs_wkd_flag => 'N',
4671 p_frz_comb_age_and_los_flag => 'N',
4672 p_wait_perd_cmpltn_dt => l_wait_perd_cmpltn_dt,
4673 p_wait_perd_strt_dt => l_wait_perd_strt_dt,
4674 p_object_version_number => l_object_version_number,
4675 p_effective_date => l_effective_dt,
4676 p_datetrack_mode => l_datetrack_mode,
4677 p_program_application_id => fnd_global.prog_appl_id,
4678 p_program_id => fnd_global.conc_program_id,
4679 p_request_id => fnd_global.conc_request_id,
4680 p_program_update_date => sysdate);
4681 --
4682
4683 if g_debug then
4684 hr_utility.set_location('Dn Still El Upd PEP ben_determine_eligibility2.check_prev_elig', 10);
4685 end if;
4686
4687 if p_score_tab.count > 0 then
4688 hr_utility.set_location('writing score records ',5.5);
4689 ben_elig_scre_wtg_api.load_score_weight
4690 (p_validate => false
4691 ,p_score_tab => p_score_tab
4692 ,p_per_in_ler_id => l_per_in_ler_id
4693 ,p_effective_date => l_effective_dt
4694 ,p_elig_per_id => l_elig_per_id);
4695 end if;
4696
4697 -- end of changes against bug 6601884
4698
4699 end if;
4700 --ICM
4701 IF nvl(l_env_rec.mode_cd,'~') = 'D' THEN
4702 hr_utility.set_location('Building PEP1',214);
4703 IF NOT ben_icm_life_events.g_cache_pep_object.EXISTS(1) THEN
4704 --
4705 l_count_icm := 1;
4706 --
4707 ELSE
4708 --
4709 l_count_icm := ben_icm_life_events.g_cache_pep_object.LAST + 1;
4710 --
4711 END IF;
4712 --
4713 ben_icm_life_events.g_cache_pep_object(l_count_icm).elig_per_id := l_elig_per_id;
4714 ben_icm_life_events.g_cache_pep_object(l_count_icm).effective_start_date :=l_effective_start_date;
4715 ben_icm_life_events.g_cache_pep_object(l_count_icm).effective_end_date :=l_effective_end_date;
4716 ben_icm_life_events.g_cache_pep_object(l_count_icm).business_group_id := p_business_group_id;
4717 ben_icm_life_events.g_cache_pep_object(l_count_icm).ler_id := p_ler_id;
4718 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_id := p_pl_id;
4719 ben_icm_life_events.g_cache_pep_object(l_count_icm).plip_id := p_plip_id;
4720 ben_icm_life_events.g_cache_pep_object(l_count_icm).ptip_id := p_ptip_id;
4721 ben_icm_life_events.g_cache_pep_object(l_count_icm).pgm_id:= nvl(p_pgm_id,l_envpgm_id);
4722 ben_icm_life_events.g_cache_pep_object(l_count_icm).per_in_ler_id :=l_per_in_ler_id;
4723 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_strt_dt :=l_prtn_strt_dt;
4724 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_end_dt := null;
4725 ben_icm_life_events.g_cache_pep_object(l_count_icm).wait_perd_cmpltn_dt :=l_wait_perd_cmpltn_dt;
4726 ben_icm_life_events.g_cache_pep_object(l_count_icm).wait_perd_strt_dt :=l_wait_perd_strt_dt;
4727 ben_icm_life_events.g_cache_pep_object(l_count_icm).elig_flag := 'N';
4728 ben_icm_life_events.g_cache_pep_object(l_count_icm).comp_ref_amt :=p_comp_rec.comp_ref_amt;
4729 ben_icm_life_events.g_cache_pep_object(l_count_icm).cmbn_age_n_los_val :=p_comp_rec.cmbn_age_n_los_val;
4730 ben_icm_life_events.g_cache_pep_object(l_count_icm).comp_ref_uom :=p_comp_rec.comp_ref_uom;
4731 ben_icm_life_events.g_cache_pep_object(l_count_icm).age_val :=p_comp_rec.age_val;
4732 ben_icm_life_events.g_cache_pep_object(l_count_icm).age_uom :=p_comp_rec.age_uom;
4733 ben_icm_life_events.g_cache_pep_object(l_count_icm).los_val :=p_comp_rec.los_val;
4734 ben_icm_life_events.g_cache_pep_object(l_count_icm).los_uom :=p_comp_rec.los_uom;
4735 ben_icm_life_events.g_cache_pep_object(l_count_icm).hrs_wkd_val :=p_comp_rec.hrs_wkd_val;
4736 ben_icm_life_events.g_cache_pep_object(l_count_icm).hrs_wkd_bndry_perd_cd :=p_comp_rec.hrs_wkd_bndry_perd_cd;
4737 ben_icm_life_events.g_cache_pep_object(l_count_icm).pct_fl_tm_val :=p_comp_rec.pct_fl_tm_val;
4738 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_los_flag :='N';
4739 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_age_flag :='N';
4740 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_cmp_lvl_flag :='N';
4741 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_pct_fl_tm_flag :='N';
4742 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_hrs_wkd_flag :='N';
4743 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_comb_age_and_los_flag :='N';
4744 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_comp_ref_amt :=p_comp_rec.rt_comp_ref_amt;
4745 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_cmbn_age_n_los_val :=p_comp_rec.rt_cmbn_age_n_los_val;
4746 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_comp_ref_uom :=p_comp_rec.rt_comp_ref_uom;
4747 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_age_val :=p_comp_rec.rt_age_val;
4748 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_age_uom :=p_comp_rec.rt_age_uom;
4749 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_los_val :=p_comp_rec.rt_los_val;
4750 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_los_uom :=p_comp_rec.rt_los_uom;
4751 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_hrs_wkd_val :=p_comp_rec.rt_hrs_wkd_val;
4752 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_hrs_wkd_bndry_perd_cd :=p_comp_rec.rt_hrs_wkd_bndry_perd_cd;
4753 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_pct_fl_tm_val :=p_comp_rec.rt_pct_fl_tm_val;
4754 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_los_flag :='N';
4755 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_age_flag :='N';
4756 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_cmp_lvl_flag :='N';
4757 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_pct_fl_tm_flag :='N';
4758 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_hrs_wkd_flag :='N';
4759 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_comb_age_and_los_flag :='N';
4760 ben_icm_life_events.g_cache_pep_object(l_count_icm).once_r_cntug_cd :=p_comp_rec.once_r_cntug_cd;
4761 ben_icm_life_events.g_cache_pep_object(l_count_icm).object_version_number := l_p_object_version_number;
4762 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_application_id :=fnd_global.prog_appl_id;
4763 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_id :=fnd_global.conc_program_id;
4764 ben_icm_life_events.g_cache_pep_object(l_count_icm).request_id :=fnd_global.conc_request_id;
4765 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_update_date :=sysdate;
4766 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_newly_elig := l_newly_elig;
4767 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_newly_inelig:= l_newly_inelig;
4768 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_first_elig := l_first_elig;
4769 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_first_inelig := l_first_inelig;
4770 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_still_elig := l_still_elig;
4771 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_still_inelig:= l_still_inelig;
4772 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_datetrack_mode:= 'UPDATE';
4773 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_effective_date:= l_effective_dt;
4774 ben_icm_life_events.g_cache_pep_object(l_count_icm).dpnt_othr_pl_cvrd_rl_flag :='N';
4775 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_key_ee_flag := 'N';
4776 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_hghly_compd_flag:= 'N';
4777 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_ovridn_flag :='N';
4778 ben_icm_life_events.g_cache_pep_object(l_count_icm).no_mx_prtn_ovrid_thru_flag :='N';
4779 ben_icm_life_events.g_cache_pep_object(l_count_icm).dstr_rstcn_flag :='N';
4780 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_wvd_flag :='N';
4781 ben_icm_life_events.g_cache_pep_object(l_count_icm).person_id := p_person_id;
4782
4783 --
4784 END IF;
4785 --ICM
4786 end if;
4787
4788 hr_utility.set_location('still eligibility true ',100);
4789 --bug#4960082
4790
4791 if p_plip_id is not null then
4792 open c_get_pl_id(nvl(l_fonm_cvg_strt_dt,p_effective_date));
4793 fetch c_get_pl_id into l_pl_id;
4794 close c_get_pl_id;
4795 end if;
4796 if p_pl_id is not null then
4797 l_pl_id := p_pl_id;
4798 end if;
4799
4800 if (l_pl_id is not null or
4801 p_oipl_id is not null or
4802 p_pgm_id is not null) then
4803
4804 if nvl(ben_manage_life_events.g_defer_deenrol_flag,'N') <> 'Y' then -- Defer ENH
4805 ben_newly_ineligible.main
4806 (p_person_id => p_person_id,
4807 p_pl_id => l_pl_id,
4808 p_pgm_id => nvl(p_pgm_id,l_envpgm_id),
4809 p_oipl_id => p_oipl_id,
4810 p_business_group_id => p_business_group_id,
4811 p_ler_id => p_ler_id,
4812 p_effective_date => l_effective_dt);
4813 -- p_effective_date => p_effective_date);
4814 --
4815 end if;
4816 --
4817
4818 end if;
4819 --
4820 if p_ptip_id is not null then
4821 if nvl(ben_manage_life_events.g_defer_deenrol_flag,'N') <> 'Y' then -- Defer ENH
4822 for l_rec in c_get_pl_from_ptip(nvl(l_fonm_cvg_strt_dt,p_effective_date)) loop
4823 ben_newly_ineligible.main
4824 (p_person_id => p_person_id,
4825 p_pl_id => l_rec.pl_id,
4826 p_pgm_id => nvl(p_pgm_id,l_envpgm_id),
4827 p_oipl_id => p_oipl_id,
4828 p_business_group_id => p_business_group_id,
4829 p_ler_id => p_ler_id,
4830 p_effective_date => l_effective_dt);
4831 -- p_effective_date => p_effective_date);
4832 end loop;
4833 --
4834 end if;
4835 --
4836 end if;
4837 return;
4838 --
4839 elsif l_elig_per_elig_flag = 'N' and p_elig_flag then --d
4840 -- person is newly elig
4841 hr_utility.set_location('new elig',23);
4842 l_newly_elig := true;
4843 l_start_or_end := 'S';
4844 fnd_message.set_name('BEN','BEN_91346_ELIG_PREV_NOT_ELIG');
4845 benutils.write(p_text => fnd_message.get);
4846 --
4847 else
4848 --
4849 fnd_message.set_name('BEN','BEN_91392_ELIG_FLAG_ERROR');
4850 raise ben_manage_life_events.g_record_error;
4851 --
4852 end if; --d
4853 --
4854 end if; --a2
4855 --
4856 if g_debug then
4857 hr_utility.set_location('Call GSED 2 ben_determine_eligibility2.check_prev_elig', 10);
4858 end if;
4859 --
4860 get_start_end_dates
4861 (p_comp_obj_tree_row => p_comp_obj_tree_row
4862 ,p_pil_row => l_pil_rec
4863 ,p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date)
4864 ,p_business_group_id => p_business_group_id
4865 ,p_person_id => p_person_id
4866 ,p_pl_id => p_pl_id
4867 ,p_pgm_id => p_pgm_id
4868 ,p_oipl_id => p_oipl_id
4869 ,p_plip_id => p_plip_id
4870 ,p_ptip_id => p_ptip_id
4871 ,p_prev_prtn_strt_dt => l_prev_prtn_strt_dt
4872 ,p_prev_prtn_end_dt => l_prev_prtn_end_dt
4873 ,p_start_or_end => l_start_or_end
4874 ,p_prtn_eff_strt_dt => l_prtn_eff_strt_dt
4875 ,p_prtn_eff_strt_dt_cd => l_prtn_eff_strt_dt_cd
4876 ,p_prtn_eff_strt_dt_rl => l_prtn_eff_strt_dt_rl
4877 ,p_prtn_eff_end_dt => l_prtn_eff_end_dt
4878 );
4879 --
4880 if g_debug then
4881 hr_utility.set_location('Done GSED 2 ben_determine_eligibility2.check_prev_elig', 10);
4882 --
4883 hr_utility.set_location(' l_prtn_eff_strt_dt : ' ||l_prtn_eff_strt_dt, 10);
4884 hr_utility.set_location(' l_prtn_eff_end_dt : ' ||l_prtn_eff_end_dt, 10);
4885 end if;
4886 --
4887 -- compute end date plus one.
4888 --
4889 if to_char(l_prtn_eff_end_dt,'DD-MM-RRRR') = '31-12-4712' then
4890 --
4891 l_end_dt_plus_one := l_prtn_eff_end_dt;
4892 --
4893 else
4894 --
4895 l_end_dt_plus_one := l_prtn_eff_end_dt+ 1;
4896 --
4897 end if;
4898 --
4899 if l_first_elig then --c
4900 --
4901 hr_utility.set_location ('first elig',121);
4902 if instr(ben_manage_life_events.g_output_string,
4903 'Elg:') = 0 then
4904 --
4905 ben_manage_life_events.g_output_string :=
4906 ben_manage_life_events.g_output_string||
4907 'Elg: Yes '||
4908 'Rsn: FTIME Elig';
4909 --
4910 end if;
4911 --
4912
4913 --Bug 12964414: If the unrestricted Le is pocessed in a future date and
4914 -- if we run a concurrent request of mode = 'S' on present date
4915 -- then prtn_strt_dt of the eligibility record created in
4916 -- ben_elig_per_f and ben_elig_per_opt_f should be the date on
4917 -- which concurrent request is run.
4918 --
4919 if ben_manage_life_events.g_modified_mode in ('S') then
4920 if l_prtn_eff_strt_dt > p_effective_date then
4921 l_prtn_eff_strt_dt := p_effective_date;
4922 end if;
4923 end if;
4924 --Bug 12964414 end.
4925 --
4926
4927 -- If a waiting period applies, get the date when participation will begin
4928 -- after the waiting period ends.
4929 --
4930 if l_wait_perd_cmpltn_dt is not null then
4931 --
4932 -- Apply the participation start date code to the l_wait_perd_cmpltn_dt
4933 --
4934 l_prtn_st_dt_aftr_wtg :=
4935 ben_determine_eligibility3.get_prtn_st_dt_aftr_wtg
4936 (p_person_id => p_person_id,
4937 p_effective_date => p_effective_date,
4938 p_business_group_id => p_business_group_id,
4939 p_prtn_eff_strt_dt_cd => l_prtn_eff_strt_dt_cd,
4940 p_prtn_eff_strt_dt_rl => l_prtn_eff_strt_dt_rl,
4941 p_wtg_perd_cmpltn_dt => l_wait_perd_cmpltn_dt,
4942 p_pl_id => p_pl_id,
4943 p_pl_typ_id => l_pl_rec.pl_typ_id,
4944 p_pgm_id => p_pgm_id,
4945 p_oipl_id => p_oipl_id,
4946 p_plip_id => p_plip_id,
4947 p_ptip_id => p_ptip_id,
4948 p_opt_id => l_oipl_rec.opt_id);
4949 --
4950 -- Use the later of the l_after_wtg_prtn_dt and l_prtn_eff_strt_dt
4951 -- for the participation start date.
4952 --
4953 l_prtn_eff_strt_dt :=
4954 greatest(nvl(l_prtn_st_dt_aftr_wtg,hr_api.g_sot),l_prtn_eff_strt_dt);
4955 --
4956 end if;
4957 --
4958 hr_utility.set_location('Using prtn_eff_strt_dt : ' ||
4959 l_prtn_eff_strt_dt, 10);
4960 --
4961 if (p_pgm_id is not null or l_envpgm_id is not null) and
4962 p_pl_id is not null then
4963 --
4964 open c_plip_ordr(nvl(l_fonm_cvg_strt_dt,p_effective_date));
4965 --
4966 fetch c_plip_ordr into l_plan_ordr_num;
4967 --
4968 close c_plip_ordr;
4969 --
4970 elsif p_pgm_id is null and l_envpgm_id is null and
4971 p_pl_id is not null then
4972 --
4973 l_plan_ordr_num := l_pl_rec.ordr_num;
4974 --
4975 end if;
4976 --
4977 if g_debug then
4978 hr_utility.set_location('l_prtn_eff_strt_dt -> '||l_prtn_eff_strt_dt, 123);
4979 hr_utility.set_location('ben_determine_eligibility2.check_prev_elig Fir El Cre PEP ', 10);
4980 end if;
4981 --
4982 l_elig_flag := 'Y';
4983 l_prtn_strt_dt := l_prtn_eff_strt_dt;
4984 --
4985 ben_Eligible_Person_perf_api.create_perf_Eligible_Person
4986 (p_validate => FALSE,
4987 p_elig_per_id => l_elig_per_id,
4988 p_effective_start_date => l_effective_start_date,
4989 p_effective_end_date => l_effective_end_date,
4990 p_business_group_id => p_business_group_id,
4991 p_pl_id => p_pl_id,
4992 p_plip_id => p_plip_id,
4993 p_ptip_id => p_ptip_id,
4994 p_pgm_id => nvl(p_pgm_id,l_envpgm_id),
4995 p_ler_id => p_ler_id,
4996 p_person_id => p_person_id,
4997 p_per_in_ler_id => l_per_in_ler_id,
4998 p_dpnt_othr_pl_cvrd_rl_flag => 'N',
4999 p_pl_key_ee_flag => 'N',
5000 p_pl_hghly_compd_flag => 'N',
5001 p_prtn_ovridn_flag => 'N',
5002 p_prtn_ovridn_thru_dt => null,
5003 p_no_mx_prtn_ovrid_thru_flag => 'N',
5004 p_prtn_strt_dt => l_prtn_strt_dt,
5005 p_dstr_rstcn_flag => 'N',
5006 p_pl_wvd_flag => 'N',
5007 p_wait_perd_cmpltn_dt => l_wait_perd_cmpltn_dt,
5008 p_wait_perd_strt_dt => l_wait_perd_strt_dt,
5009 p_elig_flag => l_elig_flag,
5010 p_comp_ref_amt => p_comp_rec.comp_ref_amt,
5011 p_cmbn_age_n_los_val => p_comp_rec.cmbn_age_n_los_val,
5012 p_comp_ref_uom => p_comp_rec.comp_ref_uom,
5013 p_age_val => p_comp_rec.age_val,
5014 p_age_uom => p_comp_rec.age_uom,
5015 p_los_val => p_comp_rec.los_val,
5016 p_los_uom => p_comp_rec.los_uom,
5017 p_hrs_wkd_val => p_comp_rec.hrs_wkd_val,
5018 p_hrs_wkd_bndry_perd_cd => p_comp_rec.hrs_wkd_bndry_perd_cd,
5019 p_pct_fl_tm_val => p_comp_rec.pct_fl_tm_val,
5020 p_frz_los_flag => 'N',
5021 p_frz_age_flag => 'N',
5022 p_frz_cmp_lvl_flag => 'N',
5023 p_frz_pct_fl_tm_flag => 'N',
5024 p_frz_hrs_wkd_flag => 'N',
5025 p_frz_comb_age_and_los_flag => 'N',
5026 p_rt_comp_ref_amt => p_comp_rec.rt_comp_ref_amt,
5027 p_rt_cmbn_age_n_los_val => p_comp_rec.rt_cmbn_age_n_los_val,
5028 p_rt_comp_ref_uom => p_comp_rec.rt_comp_ref_uom,
5029 p_rt_age_val => p_comp_rec.rt_age_val,
5030 p_rt_age_uom => p_comp_rec.rt_age_uom,
5031 p_rt_los_val => p_comp_rec.rt_los_val,
5032 p_rt_los_uom => p_comp_rec.rt_los_uom,
5033 p_rt_hrs_wkd_val => p_comp_rec.rt_hrs_wkd_val,
5034 p_rt_hrs_wkd_bndry_perd_cd => p_comp_rec.rt_hrs_wkd_bndry_perd_cd,
5035 p_rt_pct_fl_tm_val => p_comp_rec.rt_pct_fl_tm_val,
5036 p_rt_frz_los_flag => 'N',
5037 p_rt_frz_age_flag => 'N',
5038 p_rt_frz_cmp_lvl_flag => 'N',
5039 p_rt_frz_pct_fl_tm_flag => 'N',
5040 p_rt_frz_hrs_wkd_flag => 'N',
5041 p_rt_frz_comb_age_and_los_flag => 'N',
5042 p_once_r_cntug_cd => p_comp_rec.once_r_cntug_cd,
5043 p_pl_ordr_num => l_plan_ordr_num,
5044 p_plip_ordr_num => l_plip_rec.ordr_num,
5045 p_ptip_ordr_num => l_ptip_rec.ordr_num,
5046 p_object_version_number => l_object_version_number,
5047 --
5048 -- Bugs : 1412882, part of bug 1412951
5049 --
5050 p_effective_date => l_effective_dt,
5051 -- p_effective_date => p_effective_date,
5052 p_program_application_id => fnd_global.prog_appl_id,
5053 p_program_id => fnd_global.conc_program_id,
5054 p_request_id => fnd_global.conc_request_id,
5055 p_program_update_date => sysdate
5056 --
5057 -- Bypass insert validate validation for performance
5058 --
5059 ,p_override_validation => TRUE);
5060 --
5061 --ICM
5062 IF nvl(l_env_rec.mode_cd,'~') = 'D' THEN
5063 hr_utility.set_location('Building PEP2',214);
5064 IF NOT ben_icm_life_events.g_cache_pep_object.EXISTS(1) THEN
5065 --
5066 l_count_icm := 1;
5067 --
5068 ELSE
5069 --
5070 l_count_icm := ben_icm_life_events.g_cache_pep_object.LAST + 1;
5071 --
5072 END IF;
5073 --
5074 ben_icm_life_events.g_cache_pep_object(l_count_icm).elig_per_id := l_elig_per_id;
5075 ben_icm_life_events.g_cache_pep_object(l_count_icm).effective_start_date :=l_effective_start_date;
5076 ben_icm_life_events.g_cache_pep_object(l_count_icm).effective_end_date :=l_effective_end_date;
5077 ben_icm_life_events.g_cache_pep_object(l_count_icm).business_group_id := p_business_group_id;
5078 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_id :=p_pl_id;
5079 ben_icm_life_events.g_cache_pep_object(l_count_icm).plip_id :=p_plip_id;
5080 ben_icm_life_events.g_cache_pep_object(l_count_icm).ptip_id :=p_ptip_id;
5081 ben_icm_life_events.g_cache_pep_object(l_count_icm).pgm_id:=nvl(p_pgm_id,l_envpgm_id);
5082 ben_icm_life_events.g_cache_pep_object(l_count_icm).ler_id :=p_ler_id;
5083 ben_icm_life_events.g_cache_pep_object(l_count_icm).person_id :=p_person_id;
5084 ben_icm_life_events.g_cache_pep_object(l_count_icm).per_in_ler_id :=l_per_in_ler_id;
5085 ben_icm_life_events.g_cache_pep_object(l_count_icm).dpnt_othr_pl_cvrd_rl_flag :='N';
5086 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_ovridn_flag :='N';
5087 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_ovridn_thru_dt := null;
5088 ben_icm_life_events.g_cache_pep_object(l_count_icm).no_mx_prtn_ovrid_thru_flag :='N';
5089 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_strt_dt :=l_prtn_strt_dt;
5090 ben_icm_life_events.g_cache_pep_object(l_count_icm).dstr_rstcn_flag :='N';
5091 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_wvd_flag :='N';
5092 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_key_ee_flag := 'N';
5093 ben_icm_life_events.g_cache_pep_object(l_count_icm).wait_perd_cmpltn_dt :=l_wait_perd_cmpltn_dt;
5094 ben_icm_life_events.g_cache_pep_object(l_count_icm).wait_perd_strt_dt :=l_wait_perd_strt_dt;
5095 ben_icm_life_events.g_cache_pep_object(l_count_icm).elig_flag :=l_elig_flag;
5096 ben_icm_life_events.g_cache_pep_object(l_count_icm).comp_ref_amt :=p_comp_rec.comp_ref_amt;
5097 ben_icm_life_events.g_cache_pep_object(l_count_icm).cmbn_age_n_los_val :=p_comp_rec.cmbn_age_n_los_val;
5098 ben_icm_life_events.g_cache_pep_object(l_count_icm).comp_ref_uom :=p_comp_rec.comp_ref_uom;
5099 ben_icm_life_events.g_cache_pep_object(l_count_icm).age_val :=p_comp_rec.age_val;
5100 ben_icm_life_events.g_cache_pep_object(l_count_icm).age_uom :=p_comp_rec.age_uom;
5101 ben_icm_life_events.g_cache_pep_object(l_count_icm).los_val :=p_comp_rec.los_val;
5102 ben_icm_life_events.g_cache_pep_object(l_count_icm).los_uom :=p_comp_rec.los_uom;
5103 ben_icm_life_events.g_cache_pep_object(l_count_icm).hrs_wkd_val :=p_comp_rec.hrs_wkd_val;
5104 ben_icm_life_events.g_cache_pep_object(l_count_icm).hrs_wkd_bndry_perd_cd :=p_comp_rec.hrs_wkd_bndry_perd_cd;
5105 ben_icm_life_events.g_cache_pep_object(l_count_icm).pct_fl_tm_val :=p_comp_rec.pct_fl_tm_val;
5106 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_los_flag :='N';
5107 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_age_flag :='N';
5108 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_cmp_lvl_flag :='N';
5109 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_pct_fl_tm_flag :='N';
5110 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_hrs_wkd_flag :='N';
5111 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_comb_age_and_los_flag :='N';
5112 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_comp_ref_amt :=p_comp_rec.rt_comp_ref_amt;
5113 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_cmbn_age_n_los_val :=p_comp_rec.rt_cmbn_age_n_los_val;
5114 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_comp_ref_uom :=p_comp_rec.rt_comp_ref_uom;
5115 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_age_val :=p_comp_rec.rt_age_val;
5116 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_age_uom :=p_comp_rec.rt_age_uom;
5117 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_los_val :=p_comp_rec.rt_los_val;
5118 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_los_uom :=p_comp_rec.rt_los_uom;
5119 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_hrs_wkd_val :=p_comp_rec.rt_hrs_wkd_val;
5120 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_hrs_wkd_bndry_perd_cd :=p_comp_rec.rt_hrs_wkd_bndry_perd_cd;
5121 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_pct_fl_tm_val :=p_comp_rec.rt_pct_fl_tm_val;
5122 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_los_flag :='N';
5123 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_age_flag :='N';
5124 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_cmp_lvl_flag :='N';
5125 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_pct_fl_tm_flag :='N';
5126 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_hrs_wkd_flag :='N';
5127 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_comb_age_and_los_flag :='N';
5128 ben_icm_life_events.g_cache_pep_object(l_count_icm).once_r_cntug_cd :=p_comp_rec.once_r_cntug_cd;
5129 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_ordr_num :=l_plan_ordr_num;
5130 ben_icm_life_events.g_cache_pep_object(l_count_icm).plip_ordr_num := l_plip_rec.ordr_num;
5131 ben_icm_life_events.g_cache_pep_object(l_count_icm).ptip_ordr_num := l_ptip_rec.ordr_num;
5132 ben_icm_life_events.g_cache_pep_object(l_count_icm).object_version_number := l_object_version_number;
5133 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_application_id :=fnd_global.prog_appl_id;
5134 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_id := fnd_global.conc_program_id;
5135 ben_icm_life_events.g_cache_pep_object(l_count_icm).request_id := fnd_global.conc_request_id;
5136 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_update_date :=sysdate;
5137 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_newly_elig := l_newly_elig;
5138 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_newly_inelig:= l_newly_inelig;
5139 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_first_elig := l_first_elig;
5140 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_first_inelig:= l_first_inelig;
5141 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_still_elig := l_still_elig;
5142 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_still_inelig:= l_still_inelig;
5143 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_effective_date:= l_effective_dt;
5144 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_hghly_compd_flag:= 'N';
5145 --
5146 END IF;
5147 --ICM
5148 if g_debug then
5149 hr_utility.set_location('ben_determine_eligibility2.check_prev_elig Dn Cre PEP Fir El ', 10);
5150 end if;
5151 --
5152 if p_score_tab.count > 0 then
5153 hr_utility.set_location('writing score records ',5.5);
5154 ben_elig_scre_wtg_api.load_score_weight
5155 (p_validate => false
5156 ,p_score_tab => p_score_tab
5157 ,p_per_in_ler_id => l_per_in_ler_id /* Bug 4438430 */
5158 ,p_effective_date => l_effective_dt
5159 ,p_elig_per_id => l_elig_per_id);
5160 end if;
5161 elsif l_still_elig then --c
5162 --
5163 hr_utility.set_location('ben_determine_eligibility2.check_prev_elig l_still_elig ', 10);
5164 if instr(ben_manage_life_events.g_output_string,
5165 'Elg:') = 0 then
5166 --
5167 ben_manage_life_events.g_output_string :=
5168 ben_manage_life_events.g_output_string||
5169 'Elg: Yes '||
5170 'Rsn: Prev Elig';
5171 --
5172 end if;
5173 --
5174 -- if the previous row's start date is greater than or equal the computed
5175 -- start date, then they never really became ineligible. Go find
5176 -- another start elig date to use.
5177 --
5178 hr_utility.set_location('ben_determine_eligibility2.check_prev_elig DTAPI_FDUM ', 10);
5179 dt_api.find_dt_upd_modes
5180 (-- p_effective_date => p_effective_date,
5181 --
5182 -- Bugs : 1412882, part of bug 1412951
5183 --
5184 p_effective_date => l_effective_dt,
5185 --
5186 p_base_table_name => 'BEN_ELIG_PER_F',
5187 p_base_key_column => 'elig_per_id',
5188 p_base_key_value => l_elig_per_id,
5189 p_correction => l_correction,
5190 p_update => l_update,
5191 p_update_override => l_update_override,
5192 p_update_change_insert => l_update_change_insert);
5193 hr_utility.set_location('ben_determine_eligibility2.check_prev_elig Dn DTAPI_FDUM ', 10);
5194 --
5195 if l_update_override then
5196 --
5197 l_datetrack_mode := hr_api.g_update_override;
5198 --
5199 elsif l_update then
5200 --
5201 l_datetrack_mode := hr_api.g_update;
5202 --
5203 else
5204 --
5205 l_datetrack_mode := hr_api.g_correction;
5206 --
5207 end if;
5208 --
5209 -- If a waiting period applies, get the date when participation will begin
5210 -- after the waiting period ends.
5211 --
5212 if l_wait_perd_cmpltn_dt is not null then
5213 --
5214 -- Apply the participation start date code to the l_wait_perd_cmpltn_dt
5215 --
5216 hr_utility.set_location('ben_determine_eligibility2.check_prev_elig GET_PSDAWTG ', 10);
5217 l_prtn_st_dt_aftr_wtg :=
5218 ben_determine_eligibility3.get_prtn_st_dt_aftr_wtg
5219 (p_person_id => p_person_id,
5220 p_effective_date => p_effective_date,
5221 p_business_group_id => p_business_group_id,
5222 p_prtn_eff_strt_dt_cd => l_prtn_eff_strt_dt_cd,
5223 p_prtn_eff_strt_dt_rl => l_prtn_eff_strt_dt_rl,
5224 p_wtg_perd_cmpltn_dt => l_wait_perd_cmpltn_dt,
5225 p_pl_id => p_pl_id,
5226 p_pl_typ_id => l_pl_rec.pl_typ_id,
5227 p_pgm_id => p_pgm_id,
5228 p_oipl_id => p_oipl_id,
5229 p_plip_id => p_plip_id,
5230 p_ptip_id => p_ptip_id,
5231 p_opt_id => l_oipl_rec.opt_id);
5232 hr_utility.set_location('ben_determine_eligibility2.check_prev_elig GET_PSDAWTG ', 10);
5233 --
5234 -- Use the later of the l_after_wtg_prtn_dt and l_prtn_eff_strt_dt
5235 -- for the participation start date.
5236 --
5237 l_prtn_eff_strt_dt := greatest(nvl(l_prtn_st_dt_aftr_wtg, hr_api.g_sot)
5238 ,l_prtn_eff_strt_dt);
5239 --
5240 end if;
5241 --
5242 hr_utility.set_location('Using prtn_eff_strt_dt : ' ||
5243 l_prtn_eff_strt_dt, 10);
5244 --
5245 hr_utility.set_location('Still El Upd PEP ben_determine_eligibility2.check_prev_elig', 10);
5246 hr_utility.set_location('elig per id'||l_elig_per_id,111);
5247 hr_utility.set_location('object version number'||l_object_version_number,112);
5248 --
5249 l_elig_flag := 'Y';
5250 l_prtn_strt_dt := l_prtn_eff_strt_dt;
5251 --
5252 --
5253 hr_utility.set_location('SARKAR l_per_in_ler_id'||l_per_in_ler_id,112);
5254 hr_utility.set_location('SARKAR l_prev_per_in_ler_id'|| l_prev_per_in_ler_id,112);
5255 hr_utility.set_location('SARKAR p_ler_id '|| p_ler_id,112);
5256 IF l_datetrack_mode = hr_api.g_correction AND
5257 l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
5258 --
5259 ben_determine_eligibility3.save_to_restore
5260 (p_current_per_in_ler_id => l_per_in_ler_id
5261 ,p_per_in_ler_id => l_prev_per_in_ler_id
5262 ,p_elig_per_id => l_elig_per_id
5263 ,p_elig_per_opt_id => NULL
5264 ,p_effective_date => l_effective_dt
5265 );
5266 --
5267 END IF;
5268 /* Bug 9020962: If future eligibility record exists, then insert the record
5269 in backup table ben_le_clsn_n_rstr */
5270 IF (l_datetrack_mode = hr_api.g_update_override) AND
5271 l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
5272 --
5273 open c_prev_pil(p_pil_row.per_in_ler_id);
5274 fetch c_prev_pil into l_prev_pil_id;
5275 close c_prev_pil;
5276 hr_utility.set_location('l_prev_pil_id ' || l_prev_pil_id, 7777);
5277
5278 open c_elig_rec(l_elig_per_id,l_prev_per_in_ler_id);
5279 fetch c_elig_rec into l_elig_per_rec;
5280 close c_elig_rec;
5281 open c_elig_per_id(l_prev_pil_id,
5282 l_elig_per_rec.pl_id,
5283 l_elig_per_rec.pgm_id,
5284 l_elig_per_rec.ptip_id,
5285 l_elig_per_rec.plip_id,
5286 p_effective_date);
5287 fetch c_elig_per_id into l_ftr_elig_per_rec;
5288 close c_elig_per_id;
5289
5290 if(l_ftr_elig_per_rec.elig_per_id is not null) then
5291 ben_determine_eligibility3.save_to_restore
5292 (p_current_per_in_ler_id => l_per_in_ler_id
5293 ,p_per_in_ler_id => l_prev_pil_id
5294 ,p_elig_per_id => l_ftr_elig_per_rec.elig_per_id
5295 ,p_elig_per_opt_id => NULL
5296 ,p_effective_date => l_ftr_elig_per_rec.effective_start_date
5297 );
5298 else
5299 ben_determine_eligibility3.save_to_restore
5300 (p_current_per_in_ler_id => l_per_in_ler_id
5301 ,p_per_in_ler_id => l_prev_per_in_ler_id
5302 ,p_elig_per_id => l_elig_per_id
5303 ,p_elig_per_opt_id => NULL
5304 ,p_effective_date => l_effective_dt
5305 );
5306 end if;
5307 --
5308 END IF;
5309 /* End of Bug 9020962 */
5310 --
5311 hr_utility.set_location('SARKAR updating pep with l_per_in_ler_id'||l_per_in_ler_id,112);
5312 --
5313 l_p_object_version_number := l_object_version_number;
5314 --
5315 ben_Eligible_Person_perf_api.update_perf_Eligible_Person
5316 (p_validate => FALSE,
5317 p_elig_per_id => l_elig_per_id,
5318 p_per_in_ler_id => l_per_in_ler_id,
5319 p_effective_start_date => l_effective_start_date,
5320 p_effective_end_date => l_effective_end_date,
5321 p_elig_flag => l_elig_flag,
5322 p_prtn_strt_dt => l_prtn_strt_dt,
5323 p_prtn_end_dt => null,
5324 p_ler_id => p_ler_id, -- bug 5478994
5325 p_rt_comp_ref_amt => p_comp_rec.rt_comp_ref_amt,
5326 p_rt_cmbn_age_n_los_val => p_comp_rec.rt_cmbn_age_n_los_val,
5327 p_rt_comp_ref_uom => p_comp_rec.rt_comp_ref_uom,
5328 p_rt_age_val => p_comp_rec.rt_age_val,
5329 p_rt_los_val => p_comp_rec.rt_los_val,
5330 p_rt_hrs_wkd_val => p_comp_rec.rt_hrs_wkd_val,
5331 p_rt_hrs_wkd_bndry_perd_cd => p_comp_rec.rt_hrs_wkd_bndry_perd_cd,
5332 p_rt_age_uom => p_comp_rec.rt_age_uom,
5333 p_rt_los_uom => p_comp_rec.rt_los_uom,
5334 p_rt_pct_fl_tm_val => p_comp_rec.rt_pct_fl_tm_val,
5335 p_rt_frz_los_flag => 'N',
5336 p_rt_frz_age_flag => 'N',
5337 p_rt_frz_cmp_lvl_flag => 'N',
5338 p_rt_frz_pct_fl_tm_flag => 'N',
5339 p_rt_frz_hrs_wkd_flag => 'N',
5340 p_rt_frz_comb_age_and_los_flag => 'N',
5341 p_once_r_cntug_cd => p_comp_rec.once_r_cntug_cd,
5342 p_comp_ref_amt => p_comp_rec.comp_ref_amt,
5343 p_cmbn_age_n_los_val => p_comp_rec.cmbn_age_n_los_val,
5344 p_comp_ref_uom => p_comp_rec.comp_ref_uom,
5345 p_age_val => p_comp_rec.age_val,
5346 p_los_val => p_comp_rec.los_val,
5347 p_hrs_wkd_val => p_comp_rec.hrs_wkd_val,
5348 p_hrs_wkd_bndry_perd_cd => p_comp_rec.hrs_wkd_bndry_perd_cd,
5349 p_age_uom => p_comp_rec.age_uom,
5350 p_los_uom => p_comp_rec.los_uom,
5351 p_pct_fl_tm_val => p_comp_rec.pct_fl_tm_val,
5352 p_frz_los_flag => 'N',
5353 p_frz_age_flag => 'N',
5354 p_frz_cmp_lvl_flag => 'N',
5355 p_frz_pct_fl_tm_flag => 'N',
5356 p_frz_hrs_wkd_flag => 'N',
5357 p_frz_comb_age_and_los_flag => 'N',
5358 p_wait_perd_cmpltn_dt => l_wait_perd_cmpltn_dt,
5359 p_wait_perd_strt_dt => l_wait_perd_strt_dt,
5360 p_object_version_number => l_object_version_number,
5361 --
5362 -- Bugs : 1412882, part of bug 1412951
5363 --
5364 p_effective_date => l_effective_dt,
5365 -- p_effective_date => p_effective_date,
5366 p_datetrack_mode => l_datetrack_mode,
5367 p_program_application_id => fnd_global.prog_appl_id,
5368 p_program_id => fnd_global.conc_program_id,
5369 p_request_id => fnd_global.conc_request_id,
5370 p_program_update_date => sysdate);
5371 --ICM
5372 IF nvl(l_env_rec.mode_cd,'~') = 'D' THEN
5373 --
5374 hr_utility.set_location('Building PEP3',214);
5375 --
5376 IF NOT ben_icm_life_events.g_cache_pep_object.EXISTS(1) THEN
5377 --
5378 l_count_icm := 1;
5379 --
5380 ELSE
5381 --
5382 l_count_icm := ben_icm_life_events.g_cache_pep_object.LAST + 1;
5383 --
5384 END IF;
5385 --
5386 ben_icm_life_events.g_cache_pep_object(l_count_icm).elig_per_id := l_elig_per_id;
5387 ben_icm_life_events.g_cache_pep_object(l_count_icm).effective_start_date := l_effective_start_date;
5388 ben_icm_life_events.g_cache_pep_object(l_count_icm).effective_end_date := l_effective_end_date;
5389 ben_icm_life_events.g_cache_pep_object(l_count_icm).business_group_id := p_business_group_id;
5390 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_id := p_pl_id;
5391 ben_icm_life_events.g_cache_pep_object(l_count_icm).ler_id := p_ler_id;
5392 ben_icm_life_events.g_cache_pep_object(l_count_icm).per_in_ler_id := l_per_in_ler_id;
5393 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_strt_dt := l_prtn_strt_dt;
5394 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_end_dt := null;
5395 ben_icm_life_events.g_cache_pep_object(l_count_icm).wait_perd_cmpltn_dt := l_wait_perd_cmpltn_dt;
5396 ben_icm_life_events.g_cache_pep_object(l_count_icm).wait_perd_strt_dt := l_wait_perd_strt_dt;
5397 ben_icm_life_events.g_cache_pep_object(l_count_icm).elig_flag := l_elig_flag;
5398 ben_icm_life_events.g_cache_pep_object(l_count_icm).comp_ref_amt := p_comp_rec.comp_ref_amt;
5399 ben_icm_life_events.g_cache_pep_object(l_count_icm).cmbn_age_n_los_val := p_comp_rec.rt_cmbn_age_n_los_val;
5400 ben_icm_life_events.g_cache_pep_object(l_count_icm).comp_ref_uom := p_comp_rec.comp_ref_uom;
5401 ben_icm_life_events.g_cache_pep_object(l_count_icm).age_val := p_comp_rec.age_val;
5402 ben_icm_life_events.g_cache_pep_object(l_count_icm).age_uom := p_comp_rec.age_uom;
5403 ben_icm_life_events.g_cache_pep_object(l_count_icm).los_val := p_comp_rec.los_val;
5404 ben_icm_life_events.g_cache_pep_object(l_count_icm).los_uom := p_comp_rec.los_uom;
5405 ben_icm_life_events.g_cache_pep_object(l_count_icm).hrs_wkd_val := p_comp_rec.hrs_wkd_val;
5406 ben_icm_life_events.g_cache_pep_object(l_count_icm).hrs_wkd_bndry_perd_cd := p_comp_rec.hrs_wkd_bndry_perd_cd;
5407 ben_icm_life_events.g_cache_pep_object(l_count_icm).pct_fl_tm_val := p_comp_rec.pct_fl_tm_val;
5408 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_los_flag := 'N';
5409 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_age_flag := 'N';
5410 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_cmp_lvl_flag := 'N';
5411 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_pct_fl_tm_flag := 'N';
5412 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_hrs_wkd_flag := 'N';
5413 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_comb_age_and_los_flag := 'N';
5414 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_comp_ref_amt := p_comp_rec.rt_comp_ref_amt;
5415 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_cmbn_age_n_los_val := p_comp_rec.rt_cmbn_age_n_los_val;
5416 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_comp_ref_uom := p_comp_rec.rt_comp_ref_uom;
5417 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_age_val := p_comp_rec.rt_age_val;
5418 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_age_uom := p_comp_rec.rt_age_uom;
5419 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_los_val := p_comp_rec.rt_los_val;
5420 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_los_uom := p_comp_rec.rt_los_uom;
5421 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_hrs_wkd_val := p_comp_rec.rt_hrs_wkd_val;
5422 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_hrs_wkd_bndry_perd_cd := p_comp_rec.rt_hrs_wkd_bndry_perd_cd;
5423 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_pct_fl_tm_val := p_comp_rec.rt_pct_fl_tm_val;
5424 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_los_flag := 'N';
5425 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_age_flag := 'N';
5426 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_cmp_lvl_flag := 'N';
5427 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_pct_fl_tm_flag := 'N';
5428 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_hrs_wkd_flag := 'N';
5429 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_comb_age_and_los_flag := 'N';
5430 ben_icm_life_events.g_cache_pep_object(l_count_icm).once_r_cntug_cd := p_comp_rec.once_r_cntug_cd;
5431 ben_icm_life_events.g_cache_pep_object(l_count_icm).object_version_number := l_p_object_version_number;
5432 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_application_id :=fnd_global.prog_appl_id;
5433 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_id :=fnd_global.conc_program_id;
5434 ben_icm_life_events.g_cache_pep_object(l_count_icm).request_id :=fnd_global.conc_request_id;
5435 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_update_date :=sysdate;
5436 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_newly_elig := l_newly_elig;
5437 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_newly_inelig:= l_newly_inelig;
5438 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_first_elig := l_first_elig;
5439 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_first_inelig := l_first_inelig;
5440 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_still_elig := l_still_elig;
5441 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_still_inelig:= l_still_inelig;
5442 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_effective_date := l_effective_dt;
5443 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_datetrack_mode:= l_datetrack_mode;
5444 ben_icm_life_events.g_cache_pep_object(l_count_icm).dpnt_othr_pl_cvrd_rl_flag :='N';
5445 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_key_ee_flag := 'N';
5446 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_hghly_compd_flag:= 'N';
5447 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_ovridn_flag :='N';
5448 ben_icm_life_events.g_cache_pep_object(l_count_icm).no_mx_prtn_ovrid_thru_flag :='N';
5449 ben_icm_life_events.g_cache_pep_object(l_count_icm).dstr_rstcn_flag :='N';
5450 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_wvd_flag :='N';
5451 ben_icm_life_events.g_cache_pep_object(l_count_icm).person_id := p_person_id;
5452 --
5453 END IF;
5454 hr_utility.set_location('Dn Still El Upd PEP ben_determine_eligibility2.check_prev_elig', 10);
5455 --
5456 if p_score_tab.count > 0 then
5457 hr_utility.set_location('writing score records ',5.5);
5458 ben_elig_scre_wtg_api.load_score_weight
5459 (p_validate => false
5460 ,p_score_tab => p_score_tab
5461 ,p_per_in_ler_id => l_per_in_ler_id /* Bug 4438430 */
5462 ,p_effective_date => l_effective_dt
5463 ,p_elig_per_id => l_elig_per_id);
5464 end if;
5465 elsif l_newly_elig then --c
5466 --
5467 hr_utility.set_location('newly eligible',23);
5468 --
5469 l_p_object_version_number := l_object_version_number;
5470 --
5471 if instr(ben_manage_life_events.g_output_string,
5472 'Elg:') = 0 then
5473 --
5474 ben_manage_life_events.g_output_string :=
5475 ben_manage_life_events.g_output_string||
5476 'Elg: Yes '||
5477 'Rsn: Prev InElig';
5478 --
5479 end if;
5480 --
5481 -- if the previous row's start date is greater than or equal the computed
5482 -- start date, then they never really became ineligible. Go find
5483 -- another start elig date to use.
5484 --
5485 if l_prev_prtn_strt_dt >= l_prtn_eff_strt_dt then --p
5486 --
5487 -- Check for an existing eligible record where our computed start
5488 -- date falls between existing records start and end dates.
5489 -- If there is one, then the person never really lost eligiblity
5490 -- and we need to use the old start date.
5491 --
5492 open c_overlap (c_prtn_eff_strt_dt => l_prtn_eff_strt_dt
5493 ,c_elig_flag => 'Y'
5494 ,c_add_one => 1);
5495 --
5496 fetch c_overlap into l_overlap;
5497 --
5498 close c_overlap;
5499 --
5500 if l_overlap.prtn_strt_dt is not null then
5501 --
5502 -- Use old records start date
5503 --
5504 l_prtn_eff_strt_dt := l_overlap.prtn_strt_dt;
5505 --
5506 end if;
5507 --
5508 else
5509 --
5510 -- if the previous row's start date is less than the computed
5511 -- start date,
5512 -- Call API to Update old inelig record with end date of computed
5513 -- start date - 1 (correction) unless the old inelig record has a
5514 -- start date greater than our computed start date.
5515 --
5516 hr_utility.set_location('elig per id'||l_elig_per_id,211);
5517 hr_utility.set_location('object version number'||l_object_version_number,212);
5518 ben_Eligible_Person_perf_api.update_perf_Eligible_Person
5519 (p_validate => FALSE,
5520 p_elig_per_id => l_elig_per_id,
5521 p_effective_start_date => l_effective_start_date,
5522 p_effective_end_date => l_effective_end_date,
5523 p_prtn_end_dt => (l_prtn_eff_strt_dt -1),
5524 p_object_version_number => l_object_version_number,
5525 p_effective_date => l_effective_dt, -- 4947426
5526 p_datetrack_mode => hr_api.g_correction,
5527 p_program_application_id => fnd_global.prog_appl_id,
5528 p_program_id => fnd_global.conc_program_id,
5529 p_request_id => fnd_global.conc_request_id,
5530 p_program_update_date => sysdate);
5531 --
5532 end if; --p
5533 --
5534 -- Then call in update mode to create a new elig record with
5535 -- computed start date.
5536 --
5537 dt_api.find_dt_upd_modes
5538 (-- p_effective_date => p_effective_date,
5539 --
5540 -- Bugs : 1412882, part of bug 1412951
5541 --
5542 p_effective_date => l_effective_dt,
5543 --
5544 p_base_table_name => 'BEN_ELIG_PER_F',
5545 p_base_key_column => 'elig_per_id',
5546 p_base_key_value => l_elig_per_id,
5547 p_correction => l_correction,
5548 p_update => l_update,
5549 p_update_override => l_update_override,
5550 p_update_change_insert => l_update_change_insert);
5551 --
5552 if l_update_override then
5553 --
5554 l_datetrack_mode := hr_api.g_update_override;
5555 --
5556 elsif l_update then
5557 --
5558 l_datetrack_mode := hr_api.g_update;
5559 --
5560 else
5561 --
5562 l_datetrack_mode := hr_api.g_correction;
5563 --
5564 end if;
5565 --
5566 -- If a waiting period applies, get the date when participation will begin
5567 -- after the waiting period ends.
5568 --
5569 if l_wait_perd_cmpltn_dt is not null then
5570 --
5571 -- Apply the participation start date code to the l_wait_perd_cmpltn_dt
5572 --
5573 l_prtn_st_dt_aftr_wtg :=
5574 ben_determine_eligibility3.get_prtn_st_dt_aftr_wtg
5575 (p_person_id => p_person_id,
5576 p_effective_date => p_effective_date,
5577 p_business_group_id => p_business_group_id,
5578 p_prtn_eff_strt_dt_cd => l_prtn_eff_strt_dt_cd,
5579 p_prtn_eff_strt_dt_rl => l_prtn_eff_strt_dt_rl,
5580 p_wtg_perd_cmpltn_dt => l_wait_perd_cmpltn_dt,
5581 p_pl_id => p_pl_id,
5582 p_pl_typ_id => l_pl_rec.pl_typ_id,
5583 p_pgm_id => p_pgm_id,
5584 p_oipl_id => p_oipl_id,
5585 p_plip_id => p_plip_id,
5586 p_ptip_id => p_ptip_id,
5587 p_opt_id => l_oipl_rec.opt_id);
5588 --
5589 -- Use the later of the l_after_wtg_prtn_dt and l_prtn_eff_strt_dt
5590 -- for the participation start date.
5591 --
5592 l_prtn_eff_strt_dt := greatest(nvl(l_prtn_st_dt_aftr_wtg, hr_api.g_sot)
5593 ,l_prtn_eff_strt_dt);
5594 --
5595 end if;
5596 --
5597 hr_utility.set_location('Using prtn_eff_strt_dt : ' ||
5598 l_prtn_eff_strt_dt, 10);
5599 --
5600 hr_utility.set_location('New El Upd PEP ben_determine_eligibility2.check_prev_elig', 10);
5601 hr_utility.set_location('elig per id'||l_elig_per_id,311);
5602 hr_utility.set_location('object version number'||l_object_version_number,312);
5603 --
5604 l_elig_flag := 'Y';
5605 l_prtn_strt_dt := l_prtn_eff_strt_dt;
5606 --
5607 --
5608 IF l_datetrack_mode = hr_api.g_correction AND
5609 l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
5610 --
5611 ben_determine_eligibility3.save_to_restore
5612 (p_current_per_in_ler_id => l_per_in_ler_id
5613 ,p_per_in_ler_id => l_prev_per_in_ler_id
5614 ,p_elig_per_id => l_elig_per_id
5615 ,p_elig_per_opt_id => NULL
5616 ,p_effective_date => l_effective_dt
5617 );
5618 end if;
5619
5620 /* Bug 9020962: If future eligibility record exists, then insert the record
5621 in backup table ben_le_clsn_n_rstr */
5622 IF (l_datetrack_mode = hr_api.g_update_override) AND
5623 l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
5624 --
5625 open c_prev_pil(p_pil_row.per_in_ler_id);
5626 fetch c_prev_pil into l_prev_pil_id;
5627 close c_prev_pil;
5628 hr_utility.set_location('l_prev_pil_id ' || l_prev_pil_id, 7778);
5629
5630 open c_elig_rec(l_elig_per_id,l_prev_per_in_ler_id);
5631 fetch c_elig_rec into l_elig_per_rec;
5632 close c_elig_rec;
5633 open c_elig_per_id(l_prev_pil_id,
5634 l_elig_per_rec.pl_id,
5635 l_elig_per_rec.pgm_id,
5636 l_elig_per_rec.ptip_id,
5637 l_elig_per_rec.plip_id,
5638 p_effective_date);
5639 fetch c_elig_per_id into l_ftr_elig_per_rec;
5640 close c_elig_per_id;
5641 if(l_ftr_elig_per_rec.elig_per_id is not null) then
5642 ben_determine_eligibility3.save_to_restore
5643 (p_current_per_in_ler_id => l_per_in_ler_id
5644 ,p_per_in_ler_id => l_prev_pil_id
5645 ,p_elig_per_id => l_ftr_elig_per_rec.elig_per_id
5646 ,p_elig_per_opt_id => NULL
5647 ,p_effective_date => l_ftr_elig_per_rec.effective_start_date
5648 );
5649 else
5650 ben_determine_eligibility3.save_to_restore
5651 (p_current_per_in_ler_id => l_per_in_ler_id
5652 ,p_per_in_ler_id => l_prev_per_in_ler_id
5653 ,p_elig_per_id => l_elig_per_id
5654 ,p_elig_per_opt_id => NULL
5655 ,p_effective_date => l_effective_dt
5656 );
5657 end if;
5658 --
5659 END IF;
5660 /* End of Bug 9020962 */
5661 --
5662 ben_Eligible_Person_perf_api.update_perf_Eligible_Person
5663 (p_validate => FALSE,
5664 p_elig_per_id => l_elig_per_id,
5665 p_per_in_ler_id => l_per_in_ler_id,
5666 p_effective_start_date => l_effective_start_date,
5667 p_effective_end_date => l_effective_end_date,
5668 p_elig_flag => l_elig_flag,
5669 p_prtn_strt_dt => l_prtn_strt_dt,
5670 p_prtn_end_dt => null,
5671 p_ler_id => p_ler_id, -- bug 5478994
5672 p_rt_comp_ref_amt => p_comp_rec.rt_comp_ref_amt,
5673 p_rt_cmbn_age_n_los_val => p_comp_rec.rt_cmbn_age_n_los_val,
5674 p_rt_comp_ref_uom => p_comp_rec.rt_comp_ref_uom,
5675 p_rt_age_val => p_comp_rec.rt_age_val,
5676 p_rt_los_val => p_comp_rec.rt_los_val,
5677 p_rt_hrs_wkd_val => p_comp_rec.rt_hrs_wkd_val,
5678 p_rt_hrs_wkd_bndry_perd_cd => p_comp_rec.rt_hrs_wkd_bndry_perd_cd,
5679 p_rt_age_uom => p_comp_rec.rt_age_uom,
5680 p_rt_los_uom => p_comp_rec.rt_los_uom,
5681 p_rt_pct_fl_tm_val => p_comp_rec.rt_pct_fl_tm_val,
5682 p_rt_frz_los_flag => 'N',
5683 p_rt_frz_age_flag => 'N',
5684 p_rt_frz_cmp_lvl_flag => 'N',
5685 p_rt_frz_pct_fl_tm_flag => 'N',
5686 p_rt_frz_hrs_wkd_flag => 'N',
5687 p_rt_frz_comb_age_and_los_flag => 'N',
5688 p_once_r_cntug_cd => p_comp_rec.once_r_cntug_cd,
5689 p_comp_ref_amt => p_comp_rec.comp_ref_amt,
5690 p_cmbn_age_n_los_val => p_comp_rec.cmbn_age_n_los_val,
5691 p_comp_ref_uom => p_comp_rec.comp_ref_uom,
5692 p_age_val => p_comp_rec.age_val,
5693 p_los_val => p_comp_rec.los_val,
5694 p_hrs_wkd_val => p_comp_rec.hrs_wkd_val,
5695 p_hrs_wkd_bndry_perd_cd => p_comp_rec.hrs_wkd_bndry_perd_cd,
5696 p_age_uom => p_comp_rec.age_uom,
5697 p_los_uom => p_comp_rec.los_uom,
5698 p_pct_fl_tm_val => p_comp_rec.pct_fl_tm_val,
5699 p_frz_los_flag => 'N',
5700 p_frz_age_flag => 'N',
5701 p_frz_cmp_lvl_flag => 'N',
5702 p_frz_pct_fl_tm_flag => 'N',
5703 p_frz_hrs_wkd_flag => 'N',
5704 p_frz_comb_age_and_los_flag => 'N',
5705 p_wait_perd_cmpltn_dt => l_wait_perd_cmpltn_dt,
5706 p_wait_perd_strt_dt => l_wait_perd_strt_dt,
5707 p_object_version_number => l_object_version_number,
5708 --
5709 -- Bugs : 1412882, part of bug 1412951
5710 --
5711 p_effective_date => l_effective_dt,
5712 -- p_effective_date => p_effective_date,
5713 p_datetrack_mode => l_datetrack_mode,
5714 p_program_application_id => fnd_global.prog_appl_id,
5715 p_program_id => fnd_global.conc_program_id,
5716 p_request_id => fnd_global.conc_request_id,
5717 p_program_update_date => sysdate);
5718 --ICM
5719 IF nvl(l_env_rec.mode_cd,'~') = 'D' THEN
5720 hr_utility.set_location('Building PEP5',214);
5721 IF NOT ben_icm_life_events.g_cache_pep_object.EXISTS(1) THEN
5722 --
5723 l_count_icm := 1;
5724 --
5725 ELSE
5726 --
5727 l_count_icm := ben_icm_life_events.g_cache_pep_object.LAST + 1;
5728 --
5729 END IF;
5730 --
5731 ben_icm_life_events.g_cache_pep_object(l_count_icm).elig_per_id := l_elig_per_id;
5732 ben_icm_life_events.g_cache_pep_object(l_count_icm).effective_start_date :=l_effective_start_date;
5733 ben_icm_life_events.g_cache_pep_object(l_count_icm).effective_end_date :=l_effective_end_date;
5734 ben_icm_life_events.g_cache_pep_object(l_count_icm).business_group_id := p_business_group_id;
5735 ben_icm_life_events.g_cache_pep_object(l_count_icm).ler_id :=p_ler_id;
5736 ben_icm_life_events.g_cache_pep_object(l_count_icm).per_in_ler_id :=l_per_in_ler_id;
5737 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_strt_dt :=l_prtn_strt_dt;
5738 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_end_dt := null;
5739 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_id :=p_pl_id;
5740 ben_icm_life_events.g_cache_pep_object(l_count_icm).plip_id :=p_plip_id;
5741 ben_icm_life_events.g_cache_pep_object(l_count_icm).ptip_id :=p_ptip_id;
5742 ben_icm_life_events.g_cache_pep_object(l_count_icm).pgm_id:=nvl(p_pgm_id,l_envpgm_id);
5743 ben_icm_life_events.g_cache_pep_object(l_count_icm).dpnt_othr_pl_cvrd_rl_flag := 'N';
5744 ben_icm_life_events.g_cache_pep_object(l_count_icm).wait_perd_cmpltn_dt :=l_wait_perd_cmpltn_dt;
5745 ben_icm_life_events.g_cache_pep_object(l_count_icm).wait_perd_strt_dt :=l_wait_perd_strt_dt;
5746 ben_icm_life_events.g_cache_pep_object(l_count_icm).elig_flag :=l_elig_flag;
5747 ben_icm_life_events.g_cache_pep_object(l_count_icm).comp_ref_amt :=p_comp_rec.comp_ref_amt;
5748 ben_icm_life_events.g_cache_pep_object(l_count_icm).cmbn_age_n_los_val :=p_comp_rec.cmbn_age_n_los_val;
5749 ben_icm_life_events.g_cache_pep_object(l_count_icm).comp_ref_uom :=p_comp_rec.comp_ref_uom;
5750 ben_icm_life_events.g_cache_pep_object(l_count_icm).age_val :=p_comp_rec.age_val;
5751 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_key_ee_flag := 'N';
5752 ben_icm_life_events.g_cache_pep_object(l_count_icm).age_uom :=p_comp_rec.age_uom;
5753 ben_icm_life_events.g_cache_pep_object(l_count_icm).los_val :=p_comp_rec.los_val;
5754 ben_icm_life_events.g_cache_pep_object(l_count_icm).los_uom :=p_comp_rec.los_uom;
5755 ben_icm_life_events.g_cache_pep_object(l_count_icm).hrs_wkd_val :=p_comp_rec.hrs_wkd_val;
5756 ben_icm_life_events.g_cache_pep_object(l_count_icm).hrs_wkd_bndry_perd_cd :=p_comp_rec.hrs_wkd_bndry_perd_cd;
5757 ben_icm_life_events.g_cache_pep_object(l_count_icm).pct_fl_tm_val :=p_comp_rec.pct_fl_tm_val;
5758 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_los_flag :='N';
5759 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_age_flag :='N';
5760 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_cmp_lvl_flag :='N';
5761 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_pct_fl_tm_flag :='N';
5762 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_hrs_wkd_flag :='N';
5763 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_comb_age_and_los_flag :='N';
5764 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_comp_ref_amt :=p_comp_rec.rt_comp_ref_amt;
5765 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_cmbn_age_n_los_val :=p_comp_rec.rt_cmbn_age_n_los_val;
5766 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_comp_ref_uom :=p_comp_rec.rt_comp_ref_uom;
5767 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_age_val :=p_comp_rec.rt_age_val;
5768 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_age_uom :=p_comp_rec.rt_age_uom;
5769 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_los_val :=p_comp_rec.rt_los_val;
5770 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_los_uom :=p_comp_rec.rt_los_uom;
5771 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_hrs_wkd_val :=p_comp_rec.rt_hrs_wkd_val;
5772 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_hrs_wkd_bndry_perd_cd :=p_comp_rec.rt_hrs_wkd_bndry_perd_cd;
5773 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_pct_fl_tm_val :=p_comp_rec.rt_pct_fl_tm_val;
5774 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_los_flag :='N';
5775 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_age_flag :='N';
5776 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_cmp_lvl_flag :='N';
5777 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_pct_fl_tm_flag :='N';
5778 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_hrs_wkd_flag :='N';
5779 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_comb_age_and_los_flag :='N';
5780 ben_icm_life_events.g_cache_pep_object(l_count_icm).once_r_cntug_cd :=p_comp_rec.once_r_cntug_cd;
5781 ben_icm_life_events.g_cache_pep_object(l_count_icm).object_version_number := l_p_object_version_number;
5782 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_application_id :=fnd_global.prog_appl_id;
5783 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_id :=fnd_global.conc_program_id;
5784 ben_icm_life_events.g_cache_pep_object(l_count_icm).request_id :=fnd_global.conc_request_id;
5785 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_update_date :=sysdate;
5786 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_newly_elig := l_newly_elig;
5787 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_newly_inelig:= l_newly_inelig;
5788 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_first_elig := l_first_elig;
5789 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_first_inelig:= l_first_inelig;
5790 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_still_elig := l_still_elig;
5791 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_still_inelig:= l_still_inelig;
5792 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_datetrack_mode:= l_datetrack_mode;
5793 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_effective_date:= l_effective_dt;
5794 ben_icm_life_events.g_cache_pep_object(l_count_icm).dpnt_othr_pl_cvrd_rl_flag :='N';
5795 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_key_ee_flag := 'N';
5796 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_hghly_compd_flag:= 'N';
5797 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_ovridn_flag :='N';
5798 ben_icm_life_events.g_cache_pep_object(l_count_icm).no_mx_prtn_ovrid_thru_flag :='N';
5799 ben_icm_life_events.g_cache_pep_object(l_count_icm).dstr_rstcn_flag :='N';
5800 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_wvd_flag :='N';
5801 ben_icm_life_events.g_cache_pep_object(l_count_icm).person_id := p_person_id;
5802 --
5803 END IF;
5804 --ICM
5805 hr_utility.set_location('Dn New El Upd PEP ben_determine_eligibility2.check_prev_elig', 10);
5806 --
5807 if p_score_tab.count > 0 then
5808 hr_utility.set_location('writing score records ',5.5);
5809 ben_elig_scre_wtg_api.load_score_weight
5810 (p_validate => false
5811 ,p_score_tab => p_score_tab
5812 ,p_per_in_ler_id => l_per_in_ler_id /* Bug 4438430 */
5813 ,p_effective_date => l_effective_dt
5814 ,p_elig_per_id => l_elig_per_id);
5815 end if;
5816 elsif l_newly_inelig then --c
5817 --
5818 hr_utility.set_location ('newly inelig',121);
5819 --
5820 l_p_object_version_number := l_object_version_number;
5821 --
5822 if instr(ben_manage_life_events.g_output_string,
5823 'Elg:') = 0 then
5824 --
5825 ben_manage_life_events.g_output_string :=
5826 ben_manage_life_events.g_output_string||
5827 'Elg: No '||
5828 'Rsn: Prev Elig';
5829 --
5830 end if;
5831 --
5832 -- if the previous row's start date is greater than the computed
5833 -- end date, then they never really became eligible. Go find
5834 -- another 'start' inelig date to use.
5835 --
5836 if l_prev_prtn_strt_dt > l_prtn_eff_end_dt then --p
5837 -- Check for an existing ineligible record where our computed end
5838 -- date falls between existing records start and end dates.
5839 open c_overlap (c_prtn_eff_strt_dt => l_prtn_eff_end_dt
5840 ,c_elig_flag => 'N'
5841 ,c_add_one => 0);
5842 --
5843 fetch c_overlap into l_overlap;
5844 --
5845 close c_overlap;
5846 --
5847 if l_overlap.prtn_strt_dt is not null then
5848 --
5849 l_end_dt_plus_one := l_overlap.prtn_strt_dt;
5850 --
5851 -- Using old records start date.
5852 --
5853 end if;
5854 --
5855 else --p
5856 -- If the previous row's start date is less than or equal the commputed
5857 -- they were eligible for at least a day. Update the old record with
5858 -- an end date in correction mode, then update (to create a new inelig
5859 -- record.
5860 hr_utility.set_location('elig per id'||l_elig_per_id,411);
5861 hr_utility.set_location('object version number'||l_object_version_number,412);
5862 hr_utility.set_location('l_elig_flag'|| l_elig_flag,412);
5863 ben_Eligible_Person_perf_api.update_perf_Eligible_Person
5864 (p_validate => FALSE,
5865 p_elig_per_id => l_elig_per_id,
5866 p_effective_start_date => l_effective_start_date,
5867 p_effective_end_date => l_effective_end_date,
5868 p_prtn_end_dt => l_prtn_eff_end_dt,
5869 p_object_version_number => l_object_version_number,
5870 -- p_effective_date => p_effective_date,
5871 p_effective_date => l_effective_dt,
5872 p_datetrack_mode => hr_api.g_correction,
5873 p_program_application_id => fnd_global.prog_appl_id,
5874 p_program_id => fnd_global.conc_program_id,
5875 p_request_id => fnd_global.conc_request_id,
5876 p_program_update_date => sysdate);
5877 --
5878 hr_utility.set_location('Building epo cache1 10 : count ' || l_count_icm1,123);
5879 hr_utility.set_location('Building epo cache1 1'|| l_count_icm1,123);
5880 end if; --p
5881 --
5882 dt_api.find_dt_upd_modes
5883 (-- p_effective_date => p_effective_date,
5884 --
5885 -- Bugs : 1412882, part of bug 1412951
5886 --
5887 p_effective_date => l_effective_dt,
5888 --
5889 p_base_table_name => 'BEN_ELIG_PER_F',
5890 p_base_key_column => 'elig_per_id',
5891 p_base_key_value => l_elig_per_id,
5892 p_correction => l_correction,
5893 p_update => l_update,
5894 p_update_override => l_update_override,
5895 p_update_change_insert => l_update_change_insert);
5896 --
5897 if l_update_override then
5898 --
5899 l_datetrack_mode := hr_api.g_update_override;
5900 --
5901 elsif l_update then
5902 --
5903 l_datetrack_mode := hr_api.g_update;
5904 --
5905 else
5906 --
5907 l_datetrack_mode := hr_api.g_correction;
5908 --
5909 end if;
5910 --
5911 -- Update pil_id also since new row added due to current pil
5912 --
5913 hr_utility.set_location('New InEl Upd PEP ben_determine_eligibility2.check_prev_elig', 10);
5914 hr_utility.set_location('elig per id'||l_elig_per_id,511);
5915 hr_utility.set_location('object version number'||l_object_version_number,512);
5916 --
5917 l_elig_flag := 'N';
5918 l_prtn_strt_dt := l_end_dt_plus_one;
5919 --
5920 --
5921 IF l_datetrack_mode = hr_api.g_correction AND
5922 l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
5923 --
5924 ben_determine_eligibility3.save_to_restore
5925 (p_current_per_in_ler_id => l_per_in_ler_id
5926 ,p_per_in_ler_id => l_prev_per_in_ler_id
5927 ,p_elig_per_id => l_elig_per_id
5928 ,p_elig_per_opt_id => NULL
5929 ,p_effective_date => l_effective_dt
5930 );
5931 --
5932 END IF;
5933
5934 /* Bug 9020962: If future eligibility record exists, then insert the record
5935 in backup table ben_le_clsn_n_rstr */
5936 IF (l_datetrack_mode = hr_api.g_update_override) AND
5937 l_per_in_ler_id <> NVL(l_prev_per_in_ler_id,-1) THEN
5938 --
5939 open c_prev_pil(p_pil_row.per_in_ler_id);
5940 fetch c_prev_pil into l_prev_pil_id;
5941 close c_prev_pil;
5942 hr_utility.set_location('l_prev_pil_id ' || l_prev_pil_id, 7779);
5943
5944 open c_elig_rec(l_elig_per_id,l_prev_per_in_ler_id);
5945 fetch c_elig_rec into l_elig_per_rec;
5946 close c_elig_rec;
5947
5948 open c_elig_per_id(l_prev_pil_id,
5949 l_elig_per_rec.pl_id,
5950 l_elig_per_rec.pgm_id,
5951 l_elig_per_rec.ptip_id,
5952 l_elig_per_rec.plip_id,
5953 p_effective_date);
5954 fetch c_elig_per_id into l_ftr_elig_per_rec;
5955 close c_elig_per_id;
5956
5957 if(l_ftr_elig_per_rec.elig_per_id is not null) then
5958 ben_determine_eligibility3.save_to_restore
5959 (p_current_per_in_ler_id => l_per_in_ler_id
5960 ,p_per_in_ler_id => l_prev_pil_id
5961 ,p_elig_per_id => l_ftr_elig_per_rec.elig_per_id
5962 ,p_elig_per_opt_id => NULL
5963 ,p_effective_date => l_ftr_elig_per_rec.effective_start_date
5964 );
5965 else
5966 ben_determine_eligibility3.save_to_restore
5967 (p_current_per_in_ler_id => l_per_in_ler_id
5968 ,p_per_in_ler_id => l_prev_per_in_ler_id
5969 ,p_elig_per_id => l_elig_per_id
5970 ,p_elig_per_opt_id => NULL
5971 ,p_effective_date => l_effective_dt
5972 );
5973 end if;
5974 --
5975 END IF;
5976 --
5977 ben_Eligible_Person_perf_api.update_perf_Eligible_Person
5978 (p_validate => FALSE,
5979 p_elig_per_id => l_elig_per_id,
5980 p_effective_start_date => l_effective_start_date,
5981 p_effective_end_date => l_effective_end_date,
5982 p_per_in_ler_id => l_per_in_ler_id,
5983 p_elig_flag => l_elig_flag,
5984 p_prtn_strt_dt => l_prtn_strt_dt,
5985 p_prtn_end_dt => null,
5986 p_ler_id => p_ler_id, -- bug 5478994
5987 p_rt_comp_ref_amt => p_comp_rec.rt_comp_ref_amt,
5988 p_rt_cmbn_age_n_los_val => p_comp_rec.rt_cmbn_age_n_los_val,
5989 p_rt_comp_ref_uom => p_comp_rec.rt_comp_ref_uom,
5990 p_rt_age_val => p_comp_rec.rt_age_val,
5991 p_rt_los_val => p_comp_rec.rt_los_val,
5992 p_rt_hrs_wkd_val => p_comp_rec.rt_hrs_wkd_val,
5993 p_rt_hrs_wkd_bndry_perd_cd => p_comp_rec.rt_hrs_wkd_bndry_perd_cd,
5994 p_rt_age_uom => p_comp_rec.rt_age_uom,
5995 p_rt_los_uom => p_comp_rec.rt_los_uom,
5996 p_rt_pct_fl_tm_val => p_comp_rec.rt_pct_fl_tm_val,
5997 p_rt_frz_los_flag => 'N',
5998 p_rt_frz_age_flag => 'N',
5999 p_rt_frz_cmp_lvl_flag => 'N',
6000 p_rt_frz_pct_fl_tm_flag => 'N',
6001 p_rt_frz_hrs_wkd_flag => 'N',
6002 p_rt_frz_comb_age_and_los_flag => 'N',
6003 p_once_r_cntug_cd => p_comp_rec.once_r_cntug_cd,
6004 p_comp_ref_amt => p_comp_rec.comp_ref_amt,
6005 p_cmbn_age_n_los_val => p_comp_rec.cmbn_age_n_los_val,
6006 p_comp_ref_uom => p_comp_rec.comp_ref_uom,
6007 p_age_val => p_comp_rec.age_val,
6008 p_los_val => p_comp_rec.los_val,
6009 p_hrs_wkd_val => p_comp_rec.hrs_wkd_val,
6010 p_hrs_wkd_bndry_perd_cd => p_comp_rec.hrs_wkd_bndry_perd_cd,
6011 p_age_uom => p_comp_rec.age_uom,
6012 p_los_uom => p_comp_rec.los_uom,
6013 p_pct_fl_tm_val => p_comp_rec.pct_fl_tm_val,
6014 p_frz_los_flag => 'N',
6015 p_frz_age_flag => 'N',
6016 p_frz_cmp_lvl_flag => 'N',
6017 p_frz_pct_fl_tm_flag => 'N',
6018 p_frz_hrs_wkd_flag => 'N',
6019 p_frz_comb_age_and_los_flag => 'N',
6020 p_object_version_number => l_object_version_number,
6021 --
6022 -- Bugs : 1412882, part of bug 1412951
6023 --
6024 p_effective_date => l_effective_dt,
6025 -- p_effective_date => p_effective_date,
6026 p_datetrack_mode => l_datetrack_mode,
6027 p_program_application_id => fnd_global.prog_appl_id,
6028 p_program_id => fnd_global.conc_program_id,
6029 p_request_id => fnd_global.conc_request_id,
6030 p_program_update_date => sysdate,
6031 p_inelg_rsn_cd => p_inelg_rsn_cd);
6032 --ICM
6033 IF nvl(l_env_rec.mode_cd,'~') = 'D' THEN
6034 hr_utility.set_location('Building PEP7',214);
6035 IF NOT ben_icm_life_events.g_cache_pep_object.EXISTS(1) THEN
6036 --
6037 l_count_icm := 1;
6038 --
6039 ELSE
6040 --
6041 l_count_icm := ben_icm_life_events.g_cache_pep_object.LAST + 1;
6042 --
6043 END IF;
6044 --
6045 ben_icm_life_events.g_cache_pep_object(l_count_icm).elig_per_id := l_elig_per_id;
6046 ben_icm_life_events.g_cache_pep_object(l_count_icm).effective_start_date :=l_effective_start_date;
6047 ben_icm_life_events.g_cache_pep_object(l_count_icm).effective_end_date :=l_effective_end_date;
6048 ben_icm_life_events.g_cache_pep_object(l_count_icm).business_group_id := p_business_group_id;
6049 ben_icm_life_events.g_cache_pep_object(l_count_icm).ler_id :=p_ler_id;
6050 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_id :=p_pl_id;
6051 ben_icm_life_events.g_cache_pep_object(l_count_icm).plip_id :=p_plip_id;
6052 ben_icm_life_events.g_cache_pep_object(l_count_icm).ptip_id :=p_ptip_id;
6053 ben_icm_life_events.g_cache_pep_object(l_count_icm).pgm_id:=nvl(p_pgm_id,l_envpgm_id);
6054 ben_icm_life_events.g_cache_pep_object(l_count_icm).per_in_ler_id :=l_per_in_ler_id;
6055 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_strt_dt :=l_prtn_strt_dt;
6056 ben_icm_life_events.g_cache_pep_object(l_count_icm).wait_perd_cmpltn_dt :=l_wait_perd_cmpltn_dt;
6057 ben_icm_life_events.g_cache_pep_object(l_count_icm).wait_perd_strt_dt :=l_wait_perd_strt_dt;
6058 ben_icm_life_events.g_cache_pep_object(l_count_icm).elig_flag :=l_elig_flag;
6059 ben_icm_life_events.g_cache_pep_object(l_count_icm).comp_ref_amt :=p_comp_rec.comp_ref_amt;
6060 ben_icm_life_events.g_cache_pep_object(l_count_icm).cmbn_age_n_los_val :=p_comp_rec.cmbn_age_n_los_val;
6061 ben_icm_life_events.g_cache_pep_object(l_count_icm).dpnt_othr_pl_cvrd_rl_flag := 'N';
6062 ben_icm_life_events.g_cache_pep_object(l_count_icm).comp_ref_uom :=p_comp_rec.comp_ref_uom;
6063 ben_icm_life_events.g_cache_pep_object(l_count_icm).age_val :=p_comp_rec.age_val;
6064 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_key_ee_flag := 'N';
6065 ben_icm_life_events.g_cache_pep_object(l_count_icm).age_uom :=p_comp_rec.age_uom;
6066 ben_icm_life_events.g_cache_pep_object(l_count_icm).los_val :=p_comp_rec.los_val;
6067 ben_icm_life_events.g_cache_pep_object(l_count_icm).los_uom :=p_comp_rec.los_uom;
6068 ben_icm_life_events.g_cache_pep_object(l_count_icm).hrs_wkd_val :=p_comp_rec.hrs_wkd_val;
6069 ben_icm_life_events.g_cache_pep_object(l_count_icm).hrs_wkd_bndry_perd_cd :=p_comp_rec.hrs_wkd_bndry_perd_cd;
6070 ben_icm_life_events.g_cache_pep_object(l_count_icm).pct_fl_tm_val :=p_comp_rec.pct_fl_tm_val;
6071 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_los_flag :='N';
6072 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_age_flag :='N';
6073 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_cmp_lvl_flag :='N';
6074 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_pct_fl_tm_flag :='N';
6075 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_hrs_wkd_flag :='N';
6076 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_comb_age_and_los_flag :='N';
6077 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_comp_ref_amt :=p_comp_rec.rt_comp_ref_amt;
6078 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_cmbn_age_n_los_val :=p_comp_rec.rt_cmbn_age_n_los_val;
6079 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_comp_ref_uom :=p_comp_rec.rt_comp_ref_uom;
6080 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_age_val :=p_comp_rec.rt_age_val;
6081 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_age_uom :=p_comp_rec.rt_age_uom;
6082 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_los_val :=p_comp_rec.rt_los_val;
6083 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_los_uom :=p_comp_rec.rt_los_uom;
6084 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_hrs_wkd_val :=p_comp_rec.rt_hrs_wkd_val;
6085 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_hrs_wkd_bndry_perd_cd :=p_comp_rec.rt_hrs_wkd_bndry_perd_cd;
6086 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_pct_fl_tm_val :=p_comp_rec.rt_pct_fl_tm_val;
6087 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_los_flag :='N';
6088 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_age_flag :='N';
6089 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_cmp_lvl_flag :='N';
6090 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_pct_fl_tm_flag :='N';
6091 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_hrs_wkd_flag :='N';
6092 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_comb_age_and_los_flag :='N';
6093 ben_icm_life_events.g_cache_pep_object(l_count_icm).once_r_cntug_cd :=p_comp_rec.once_r_cntug_cd;
6094 ben_icm_life_events.g_cache_pep_object(l_count_icm).object_version_number := l_p_object_version_number;
6095 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_application_id :=fnd_global.prog_appl_id;
6096 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_id :=fnd_global.conc_program_id;
6097 ben_icm_life_events.g_cache_pep_object(l_count_icm).request_id :=fnd_global.conc_request_id;
6098 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_update_date :=sysdate;
6099 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_newly_elig := l_newly_elig;
6100 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_newly_inelig:= l_newly_inelig;
6101 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_first_elig := l_first_elig;
6102 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_first_inelig:= l_first_inelig;
6103 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_still_elig := l_still_elig;
6104 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_still_inelig:= l_still_inelig;
6105 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_datetrack_mode:= l_datetrack_mode;
6106 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_effective_date:= l_effective_dt;
6107 ben_icm_life_events.g_cache_pep_object(l_count_icm).dpnt_othr_pl_cvrd_rl_flag :='N';
6108 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_key_ee_flag := 'N';
6109 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_hghly_compd_flag:= 'N';
6110 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_ovridn_flag :='N';
6111 ben_icm_life_events.g_cache_pep_object(l_count_icm).no_mx_prtn_ovrid_thru_flag :='N';
6112 ben_icm_life_events.g_cache_pep_object(l_count_icm).dstr_rstcn_flag :='N';
6113 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_wvd_flag :='N';
6114 ben_icm_life_events.g_cache_pep_object(l_count_icm).person_id := p_person_id;
6115 END IF;
6116 --
6117 --ICM
6118 hr_utility.set_location('Dn New InEl Upd PEP ben_determine_eligibility2.check_prev_elig', 10);
6119 if p_score_tab.count > 0 then
6120 hr_utility.set_location('writing score records ',5.5);
6121 ben_elig_scre_wtg_api.load_score_weight
6122 (p_validate => false
6123 ,p_score_tab => p_score_tab
6124 ,p_per_in_ler_id => l_per_in_ler_id /* Bug 4438430 */
6125 ,p_effective_date => l_effective_dt
6126 ,p_elig_per_id => l_elig_per_id);
6127 end if;
6128 --
6129 -- ben_newly_ineligible does not handle levels other than
6130 -- plan,option in plan, or program. Don't call it if not
6131 -- necessary.
6132 --
6133 if p_plip_id is not null then
6134 open c_get_pl_id(nvl(l_fonm_cvg_strt_dt,p_effective_date));
6135 fetch c_get_pl_id into l_pl_id;
6136 close c_get_pl_id;
6137 end if;
6138 if p_pl_id is not null then
6139 l_pl_id := p_pl_id;
6140 end if;
6141
6142 if (l_pl_id is not null or
6143 p_oipl_id is not null or
6144 p_pgm_id is not null) then
6145 if nvl(ben_manage_life_events.g_defer_deenrol_flag,'N') <> 'Y' then -- Defer ENH
6146 ben_newly_ineligible.main
6147 (p_person_id => p_person_id,
6148 p_pl_id => l_pl_id,
6149 p_pgm_id => nvl(p_pgm_id,l_envpgm_id),
6150 p_oipl_id => p_oipl_id,
6151 p_business_group_id => p_business_group_id,
6152 p_ler_id => p_ler_id,
6153 p_effective_date => l_effective_dt);
6154 -- p_effective_date => p_effective_date);
6155
6156 --
6157 end if;
6158 --
6159 end if;
6160 --
6161 if p_ptip_id is not null then
6162 if nvl(ben_manage_life_events.g_defer_deenrol_flag,'N') <> 'Y' then -- Defer ENH
6163 for l_rec in c_get_pl_from_ptip(nvl(l_fonm_cvg_strt_dt,p_effective_date)) loop
6164 ben_newly_ineligible.main
6165 (p_person_id => p_person_id,
6166 p_pl_id => l_rec.pl_id,
6167 p_pgm_id => nvl(p_pgm_id,l_envpgm_id),
6168 p_oipl_id => p_oipl_id,
6169 p_business_group_id => p_business_group_id,
6170 p_ler_id => p_ler_id,
6171 p_effective_date => l_effective_dt);
6172 -- p_effective_date => p_effective_date);
6173 end loop;
6174 --
6175 end if;
6176 --
6177 end if;
6178 elsif l_first_inelig then --c
6179 --
6180 hr_utility.set_location ('first inelig',121);
6181 if instr(ben_manage_life_events.g_output_string,
6182 'Elg:') = 0 then
6183 --
6184 ben_manage_life_events.g_output_string :=
6185 ben_manage_life_events.g_output_string||
6186 'Elg: No '||
6187 'Rsn: FTIME InElig';
6188 --
6189 end if;
6190 --
6191 if p_pgm_id is not null or l_envpgm_id is not null and p_pl_id is not null then
6192 open c_plip_ordr(nvl(l_fonm_cvg_strt_dt,p_effective_date));
6193 fetch c_plip_ordr into l_plan_ordr_num;
6194 close c_plip_ordr;
6195 elsif p_pgm_id is null and l_envpgm_id is null and p_pl_id is not null then
6196 l_plan_ordr_num := l_pl_rec.ordr_num;
6197 end if;
6198 hr_utility.set_location('Fir InEl Cre PEP ben_determine_eligibility2.check_prev_elig', 10);
6199 hr_utility.set_location('l_prtn_eff_strt_dt -> '||l_prtn_eff_strt_dt, 123);
6200 --
6201 l_elig_flag := 'N';
6202 l_prtn_strt_dt := l_end_dt_plus_one;
6203 --
6204 ben_Eligible_Person_perf_api.create_perf_Eligible_Person
6205 (p_validate => FALSE,
6206 p_elig_per_id => l_elig_per_id,
6207 p_per_in_ler_id => l_per_in_ler_id,
6208 p_effective_start_date => l_effective_start_date,
6209 p_effective_end_date => l_effective_end_date,
6210 p_business_group_id => p_business_group_id,
6211 p_pl_id => p_pl_id,
6212 p_plip_id => p_plip_id,
6213 p_ptip_id => p_ptip_id,
6214 p_pgm_id => nvl(p_pgm_id,l_envpgm_id),
6215 p_ler_id => p_ler_id,
6216 p_person_id => p_person_id,
6217 p_dpnt_othr_pl_cvrd_rl_flag => 'N',
6218 p_pl_key_ee_flag => 'N',
6219 p_pl_hghly_compd_flag => 'N',
6220 p_elig_flag => l_elig_flag,
6221 p_prtn_strt_dt => l_prtn_strt_dt,
6222 p_prtn_ovridn_flag => 'N',
6223 p_no_mx_prtn_ovrid_thru_flag => 'N',
6224 p_prtn_ovridn_thru_dt => null,
6225 p_dstr_rstcn_flag => 'N',
6226 p_pl_wvd_flag => 'N',
6227 p_rt_comp_ref_amt => p_comp_rec.rt_comp_ref_amt,
6228 p_rt_cmbn_age_n_los_val => p_comp_rec.rt_cmbn_age_n_los_val,
6229 p_rt_comp_ref_uom => p_comp_rec.rt_comp_ref_uom,
6230 p_rt_age_val => p_comp_rec.rt_age_val,
6231 p_rt_los_val => p_comp_rec.rt_los_val,
6232 p_rt_hrs_wkd_val => p_comp_rec.rt_hrs_wkd_val,
6233 p_rt_hrs_wkd_bndry_perd_cd => p_comp_rec.rt_hrs_wkd_bndry_perd_cd,
6234 p_rt_age_uom => p_comp_rec.rt_age_uom,
6235 p_rt_los_uom => p_comp_rec.rt_los_uom,
6236 p_rt_pct_fl_tm_val => p_comp_rec.rt_pct_fl_tm_val,
6237 p_rt_frz_los_flag => 'N',
6238 p_rt_frz_age_flag => 'N',
6239 p_rt_frz_cmp_lvl_flag => 'N',
6240 p_rt_frz_pct_fl_tm_flag => 'N',
6241 p_rt_frz_hrs_wkd_flag => 'N',
6242 p_rt_frz_comb_age_and_los_flag => 'N',
6243 p_once_r_cntug_cd => p_comp_rec.once_r_cntug_cd,
6244 p_comp_ref_amt => p_comp_rec.comp_ref_amt,
6245 p_cmbn_age_n_los_val => p_comp_rec.cmbn_age_n_los_val,
6246 p_comp_ref_uom => p_comp_rec.comp_ref_uom,
6247 p_age_val => p_comp_rec.age_val,
6248 p_los_val => p_comp_rec.los_val,
6249 p_hrs_wkd_val => p_comp_rec.hrs_wkd_val,
6250 p_hrs_wkd_bndry_perd_cd => p_comp_rec.hrs_wkd_bndry_perd_cd,
6251 p_age_uom => p_comp_rec.age_uom,
6252 p_los_uom => p_comp_rec.los_uom,
6253 p_pct_fl_tm_val => p_comp_rec.pct_fl_tm_val,
6254 p_frz_los_flag => 'N',
6255 p_frz_age_flag => 'N',
6256 p_frz_cmp_lvl_flag => 'N',
6257 p_frz_pct_fl_tm_flag => 'N',
6258 p_frz_hrs_wkd_flag => 'N',
6259 p_frz_comb_age_and_los_flag => 'N',
6260 p_object_version_number => l_object_version_number,
6261 p_pl_ordr_num => l_plan_ordr_num,
6262 p_plip_ordr_num => l_plip_rec.ordr_num,
6263 p_ptip_ordr_num => l_ptip_rec.ordr_num,
6264 --
6265 -- Bugs : 1412882, part of bug 1412951
6266 --
6267 p_effective_date => l_effective_dt,
6268 -- p_effective_date => p_effective_date,
6269 p_program_application_id => fnd_global.prog_appl_id,
6270 p_program_id => fnd_global.conc_program_id,
6271 p_request_id => fnd_global.conc_request_id,
6272 p_program_update_date => sysdate,
6273 p_inelg_rsn_cd => p_inelg_rsn_cd
6274 --
6275 -- Bypass insert validate validation for performance
6276 --
6277 ,p_override_validation => TRUE
6278 );
6279 --ICM
6280 IF nvl(l_env_rec.mode_cd,'~') = 'D' THEN
6281 hr_utility.set_location('Building PEP8',214);
6282 IF NOT ben_icm_life_events.g_cache_pep_object.EXISTS(1) THEN
6283 --
6284 l_count_icm := 1;
6285 --
6286 ELSE
6287 --
6288 l_count_icm := ben_icm_life_events.g_cache_pep_object.LAST + 1;
6289 --
6290 END IF;
6291 --
6292 ben_icm_life_events.g_cache_pep_object(l_count_icm).elig_per_id := l_elig_per_id;
6293 ben_icm_life_events.g_cache_pep_object(l_count_icm).effective_start_date :=l_effective_start_date;
6294 ben_icm_life_events.g_cache_pep_object(l_count_icm).effective_end_date :=l_effective_end_date;
6295 ben_icm_life_events.g_cache_pep_object(l_count_icm).business_group_id := p_business_group_id;
6296 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_id :=p_pl_id;
6297 ben_icm_life_events.g_cache_pep_object(l_count_icm).plip_id :=p_plip_id;
6298 ben_icm_life_events.g_cache_pep_object(l_count_icm).ptip_id :=p_ptip_id;
6299 ben_icm_life_events.g_cache_pep_object(l_count_icm).pgm_id:=nvl(p_pgm_id,l_envpgm_id);
6300 ben_icm_life_events.g_cache_pep_object(l_count_icm).ler_id :=p_ler_id;
6301 ben_icm_life_events.g_cache_pep_object(l_count_icm).person_id :=p_person_id;
6302 ben_icm_life_events.g_cache_pep_object(l_count_icm).per_in_ler_id :=l_per_in_ler_id;
6303 ben_icm_life_events.g_cache_pep_object(l_count_icm).dpnt_othr_pl_cvrd_rl_flag :='N';
6304 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_key_ee_flag :='N';
6305 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_ovridn_flag :='N';
6306 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_ovridn_thru_dt := null;
6307 ben_icm_life_events.g_cache_pep_object(l_count_icm).no_mx_prtn_ovrid_thru_flag :='N';
6308 ben_icm_life_events.g_cache_pep_object(l_count_icm).prtn_strt_dt :=l_prtn_strt_dt;
6309 ben_icm_life_events.g_cache_pep_object(l_count_icm).dstr_rstcn_flag :='N';
6310 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_wvd_flag :='N';
6311 ben_icm_life_events.g_cache_pep_object(l_count_icm).wait_perd_cmpltn_dt :=l_wait_perd_cmpltn_dt;
6312 ben_icm_life_events.g_cache_pep_object(l_count_icm).wait_perd_strt_dt :=l_wait_perd_strt_dt;
6313 ben_icm_life_events.g_cache_pep_object(l_count_icm).elig_flag :=l_elig_flag;
6314 ben_icm_life_events.g_cache_pep_object(l_count_icm).comp_ref_amt :=p_comp_rec.comp_ref_amt;
6315 ben_icm_life_events.g_cache_pep_object(l_count_icm).cmbn_age_n_los_val :=p_comp_rec.cmbn_age_n_los_val;
6316 ben_icm_life_events.g_cache_pep_object(l_count_icm).comp_ref_uom :=p_comp_rec.comp_ref_uom;
6317 ben_icm_life_events.g_cache_pep_object(l_count_icm).age_val :=p_comp_rec.age_val;
6318 ben_icm_life_events.g_cache_pep_object(l_count_icm).age_uom :=p_comp_rec.age_uom;
6319 ben_icm_life_events.g_cache_pep_object(l_count_icm).los_val :=p_comp_rec.los_val;
6320 ben_icm_life_events.g_cache_pep_object(l_count_icm).los_uom :=p_comp_rec.los_uom;
6321 ben_icm_life_events.g_cache_pep_object(l_count_icm).hrs_wkd_val :=p_comp_rec.hrs_wkd_val;
6322 ben_icm_life_events.g_cache_pep_object(l_count_icm).hrs_wkd_bndry_perd_cd :=p_comp_rec.hrs_wkd_bndry_perd_cd;
6323 ben_icm_life_events.g_cache_pep_object(l_count_icm).pct_fl_tm_val :=p_comp_rec.pct_fl_tm_val;
6324 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_los_flag :='N';
6325 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_age_flag :='N';
6326 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_cmp_lvl_flag :='N';
6327 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_pct_fl_tm_flag :='N';
6328 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_hrs_wkd_flag :='N';
6329 ben_icm_life_events.g_cache_pep_object(l_count_icm).frz_comb_age_and_los_flag :='N';
6330 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_comp_ref_amt :=p_comp_rec.rt_comp_ref_amt;
6331 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_cmbn_age_n_los_val :=p_comp_rec.rt_cmbn_age_n_los_val;
6332 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_comp_ref_uom :=p_comp_rec.rt_comp_ref_uom;
6333 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_age_val :=p_comp_rec.rt_age_val;
6334 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_age_uom :=p_comp_rec.rt_age_uom;
6335 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_los_val :=p_comp_rec.rt_los_val;
6336 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_los_uom :=p_comp_rec.rt_los_uom;
6337 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_hrs_wkd_val :=p_comp_rec.rt_hrs_wkd_val;
6338 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_hrs_wkd_bndry_perd_cd :=p_comp_rec.rt_hrs_wkd_bndry_perd_cd;
6339 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_pct_fl_tm_val :=p_comp_rec.rt_pct_fl_tm_val;
6340 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_los_flag :='N';
6341 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_age_flag :='N';
6342 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_cmp_lvl_flag :='N';
6343 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_pct_fl_tm_flag :='N';
6344 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_hrs_wkd_flag :='N';
6345 ben_icm_life_events.g_cache_pep_object(l_count_icm).rt_frz_comb_age_and_los_flag :='N';
6346 ben_icm_life_events.g_cache_pep_object(l_count_icm).once_r_cntug_cd :=p_comp_rec.once_r_cntug_cd;
6347 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_ordr_num :=l_plan_ordr_num;
6348 ben_icm_life_events.g_cache_pep_object(l_count_icm).plip_ordr_num :=l_plip_rec.ordr_num;
6349 ben_icm_life_events.g_cache_pep_object(l_count_icm).ptip_ordr_num :=l_ptip_rec.ordr_num;
6350 ben_icm_life_events.g_cache_pep_object(l_count_icm).object_version_number :=l_object_version_number;
6351 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_application_id :=fnd_global.prog_appl_id;
6352 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_id :=fnd_global.conc_program_id;
6353 ben_icm_life_events.g_cache_pep_object(l_count_icm).request_id :=fnd_global.conc_request_id;
6354 ben_icm_life_events.g_cache_pep_object(l_count_icm).program_update_date :=sysdate;
6355 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_newly_elig := l_newly_elig;
6356 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_newly_inelig:= l_newly_inelig;
6357 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_first_elig := l_first_elig;
6358 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_first_inelig:= l_first_inelig;
6359 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_still_elig := l_still_elig;
6360 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_still_inelig:= l_still_inelig;
6361 ben_icm_life_events.g_cache_pep_object(l_count_icm).p_effective_date:= l_effective_dt;
6362 ben_icm_life_events.g_cache_pep_object(l_count_icm).pl_hghly_compd_flag:= 'N';
6363 --
6364 END IF;
6365 --ICM
6366 hr_utility.set_location('Dn Fir InEl Cre PEP ben_determine_eligibility2.check_prev_elig', 10);
6367 --
6368 if p_score_tab.count > 0 then
6369 hr_utility.set_location('writing score records ',5.5);
6370 ben_elig_scre_wtg_api.load_score_weight
6371 (p_validate => false
6372 ,p_score_tab => p_score_tab
6373 ,p_per_in_ler_id => l_per_in_ler_id /* Bug 4438430 */
6374 ,p_effective_date => l_effective_dt
6375 ,p_elig_per_id => l_elig_per_id);
6376 end if;
6377 end if; --c
6378 --
6379 end if; --a if p_oipl_id is not null
6380 --
6381 if g_debug then
6382 hr_utility.set_location('Leaving : ben_determine_eligibility2.check_prev_elig', 10);
6383 end if;
6384 --
6385 -- Set eligbility transition states
6386 --
6387
6388 p_newly_elig := l_newly_elig;
6389 p_newly_inelig := l_newly_inelig;
6390 p_first_elig := l_first_elig;
6391 p_first_inelig := l_first_inelig;
6392 p_still_elig := l_still_elig;
6393 p_still_inelig := l_still_inelig;
6394 --
6395 -- Set PEP and EPO details on comp object list row
6396 --
6397 p_comp_obj_tree_row.elig_per_id := l_elig_per_id;
6398 p_comp_obj_tree_row.elig_per_opt_id := l_elig_per_opt_id;
6399 p_comp_obj_tree_row.elig_flag := l_elig_flag;
6400 p_comp_obj_tree_row.prtn_strt_dt := l_prtn_strt_dt;
6401 p_comp_obj_tree_row.inelg_rsn_cd := p_inelg_rsn_cd; -- 2650247
6402 --
6403 end check_prev_elig;
6404 --
6405 end ben_determine_eligibility2;