1 PACKAGE BODY ben_enrollment_action_items as
2 /* $Header: benactcm.pkb 120.28.12010000.4 2008/09/24 07:21:36 sallumwa ship $ */
3 --
4 /*
5 --
6 Name
7 Determine Enrollment Action Items - ENTE66R06
8 Purpose
9 This package is used to check enrollment action items. It is meant to be
10 used in the enrollment process. As a batch job with several entry points
11 callable by other processes.
12 Process 1) Determines if an enrollment action item(s) need to be written
13 when a person enrolls in a plan. Check dependents and beneficiary info.
14 2) Updates new enrollment action item(s) when an enrollment is changed.
15 3) Updates enrollment when an action item is completed in Designate Dpnt,
16 Desginate Beneficiary or Certification forms.
17 4) Create Certifications required for a person to complete action items.
18 5) Suspends an enrollment when an action item is created.
19 --------------------------------------------------------------------------------
20 History
21 -------
22 Version Date Author Comment
23 -------+----------+----------------+------------------------------------------
24 110.0 22 Apr 98 J Schneider Created.
25 110.1 06 Jun 98 S Tee Fixed invalid cursor when creating a BNF
26 action item and also BNFADDNL cursor,
27 c_cntngnt_types as it was not selecting
28 any rows.
29 110.2 06 Jun 98 J Schneider fixed DD if no dependents. changed
30 get_enrt_actn_id to return object_version_
31 number for updates.
32 110.3 08 Jun 98 J Schneider change to write multiple DDCTFN, BNFCTFN
33 added deenrollment proc
34 110.4 09 Jun 98 J Schneider added cmpltd_dt support get_enrt_actn_id
35 p_suspend_flag added
36 110.5 10 Jun 98 J Schneider uncommented exit
37 110.6 11 Jun 98 J Schneider moved suspend_actn stuff to API ben_prtt_
38 enrt_actn_f so all action items will
39 suspend enrt if new or cmpltd_dt is NULL
40 110.7 13 Jun 98 J Schneider l_g_suspend,l_suspend_flag rechecked for
41 problems
42 110.8 15 Jun 98 J Schneider ben_dsgn_rqmt_f now uses oipl_id
43 110.9 15 Jun 98 J Schneider redo oipl pl dsgn_rqmt
44 110.10 16 Jun 98 J Schneider dsgn_rqmt needs more work for DDADDNL
45 110.11 17 Jun 98 J Schneider recheck for DDADDNL if no dependents found
46 110.12 18 Jun 98 J Schneider return suspend flag at all times
47 110.13 18 Jun 98 J Schneider 110.13 typo
48 110.14 18 Jun 98 J Schneider DDADDNL redone
49 110.15 23 Jun 98 J Schneider fix DD and suspend mode
50 110.16 30 Jun 98 J Schneider datetrack_mode changes when doing updates,
51 get_enrt_actn_id a proc
52 110.17 07 Jul 98 J Mohapatra Added batch who cols in call to ben_cvrd_
53 dpnt_ctfn_prvdd_api.create...
54 110.18 15 Jul 98 J Schneider add exception handlers, fix dpnt ctfns.
55 110.19 16 Jul 98 J Schneider dependent certifications changes
56 110.20 17 Jul 98 J Schneider post rslt flag added for calls to suspend
57 enrollment
58 110.21 22 Jul 98 maagrawa rslt_object_version_number added to calls
59 to suspend enrollment.
60 115.10 12 Oct 98 bbulusu Modified a lot of procedures and functions
61 that go against action items to handle
62 dpnts and bnfs. Added out nocopy parameters to
63 determine_action_items to send msgs back
64 to forms. Made dpnt dsgn rqmts work at
65 plan and option level. Modified call to
66 delete_prtt_enrt_actn_. Wrote the get_due_
67 date function. Modified the check_bnf_ttee
68 func to check if a trustee is assigned.
69 115.11 26 Oct 98 bbulusu Modified get_due_dt function
70 115.12 06 Nov 98 bbulusu Fixed determine_bnf_action_items to insert
71 an opitional action item if the dsgn rqmt
72 is optional. Fixed the get_due_date func
73 to not error out nocopy if popl_actn_typ notfound
74 115.13 09 Dec 98 bbulusu Fixed problem with warning flags not being
75 returned.
76 115.14 10-Dec-98 lmcdonal re-write complete_dependent_designation.
77 115.15 22-Dec-98 bbulusu Fixed determine_bnf_actn_items to complete
78 a BNF actn item if one already exists and
79 bnfs are found Fixed determine_dpnt_actn_
80 items to complete a DD actn item if one
81 already exists and dpns are found Added
82 calls to the close unresolved actn items
83 batch process. Removed complete_all_actn_
84 items procedure (redundant). Fixed determ
85 ine_bnf_actn_items to delete all other bnf
86 actn item when a BNF actn item is written.
87 Minor fix to complete_dpnt_dsgn don't
88 need to check to see if an actn item was
89 found before calling process_action_item.
90 115.16 22-Dec-98 bbulusu uncommented exit statement.
91 115.17 28-Dec-98 stee Set the default for post_rslt_flag = 'Y'.
92 115.18 30-Dec-98 bbulusu Removed call to cls unresolved actn items.
93 115.19 24-Feb-99 bbulusu Modified check_dpnt_ctfn. Modified cursors
94 c_dpnt_ctfn_pl, c_dpnt_ctfn_pgm, c_dpnt_
95 ctfn_ptip to select dpnt ctfns based on
96 the contact type. Added function
97 check_ctfns_defined.
98 115.20 02-Mar-99 bbulusu Modified check_bnf_ctfn and determine_bnf
99 _actn_items for bug fixes.
100 115.21 04-Mar-99 bbulusu Modified get_due_dt and determine_bnf_miss
101 _actn_items.
102 115.22 08-Mar-99 tmathers Changed the not-equal operators to <>.
103 115.23 23-Mar-99 bbulusu Modified determine_addnl_bnf
104 115.24 29-Apr-99 bbulusu Fixed determine_addnl_bnf to pick up all
105 bnfs that are not spouses.
106 115.25 29-APR-99 shdas Added pl_typ_id,opt_id,ler_id,
107 business_group_id organization_id,
108 assignment_id to the parameter list of
109 genutils.formula
110 115.26 03-may-99 shdas Added jurisdiction_code.
111 115.28 08-may-99 jcarpent Check ('VOIDD', 'BCKDT') for pil stat cd
112 115.29 13-may-99 jcarpent More of same.
113 115.30 02-Jun-99 bbulusu Fix to not call check_bnf_ttee if dob is
114 not found for the bnf.
115 115.31 07-Jul-99 maagrawa Modified determine_dpnt_miss_actn_items
116 to work for plans not in programs.
117 115.32 09-Jul-99 bbulusu Added checks for backed out nocopy life evts.
118 115.33 14-Jul-99 maagrawa Corrected opening of cursor c_nsc_ctfn_pl.
119 Use of bnf_ctfn_rqd_flag and
120 dpnt_dsgn_no_ctfn_rqd_flag negated.
121 115.34 20-JUL-99 Gperry genutils -> benutils package rename.
122 115.35 24-Aug-99 maagrawa Changes related to breaking of dependents
123 table.
124 115.36 07-Sep-99 tguy fixed call to pay_mag_util
125 115.37 27-Sep-99 maagrawa Modified Check procedures for prtt, dpnt,
126 bnf certifications. Created new procedure
127 process_new_ctfn_action to create/update
128 a action item when new ctfn is created.
129 115.38 27-Sep-99 tguy Modified call to determine_date to
130 accomadate new codes.
131 115.39 12-Oct-99 stee Fixed enrollment certification for
132 benefit amount. Cursor c_ecc2 was
133 selecting comparing choice id to bnft_id.
134 Also set the enrt_ctfn_warning flag.
135 115.40 12-Nov-99 lmcdonal Better debugging messages.
136 115.41 09-Dec-99 maagrawa Call the date routine to calculate the
137 action item due date only if the date
138 code is not null.
139 115.42 10-Jan-00 lmcdonal If bnf dsgn is optional, do not make the
140 BNF% actions rqd.
141 115.43 14-Jan-00 lmcdonal Bug 1148447: When dpnt ctfn's are at PTIP lvl,
142 process was not writing actions nor ctfns
143 because pgm and ptip ids were not being passed
144 to check_ctfns_defined. Also, removed use of
145 lack...flag, using rqd_flag instead for dpnts.
146 115.44 17-Jan-00 TMathers Fixed syntax error in previous fix.
147 115.45 31-Mar-00 MMogel Added tokens to messages to make messages
148 more meaningful to the user
149 115.46 31-mar-00 shdas don't always create a rqd action item for addnl dpnt(3629).
150 115.47 03-apr-00 shdas bring c_chc_flags cursor into process_dpnt_action_items
151 from complete_dependent_desigantion and determine_dpnt_action_items.
152 115.48 12-May-00 lmcdonal Bug 1249901. before writing bnft ctfn's, check
153 if cvg entered at enrt, then entered amt greater
154 than max-wout-ctfn.
155 115.49 06-Jul-00 kmahendr Bug 5140- sub-query to get contact_type returns more than
156 one row as dependent may be a contact to more than one
157 participant. All the sub-query to get contact_type were
158 modified by adding prtt_person_id in the where clause
159 115.50 07-Jul-00 kmahendr Bug#1319520 is fixed on version 115.46 for aera
160 115.51 07-Jul-00 kmahendr Changes made in 115.50 applied to 115.49
161 115.52 18-Jul-00 bbulusu Fixed bug #5386. Added code to check for
162 ctfns defined in the ben_ler_chg_dpnt_
163 cvg_ctfn_f table for dpnt change of life
164 events.
165 115.53 08-Aug-00 bbulusu Bug 5432. Ctfn being recreated in
166 subsequenct life event.
167 115.54 15-Aug-00 IAli PCP Required for Participant and for Dependent process is added
168 115.55 16-Aug-00 IAli Fixed the infinite loop in determine_pcp_action procedure
169 115.56 19-Aug-00 Shdas added process_pcp_actn_items and
170 and process_pcp_dpnt_actn_items.
171 115.57 25-Aug-00 Shdas added warnings for process_pcp_actn_items
172 and process_pcp_dpnt_actn_items.
173 115.58 28-Aug-00 cdaniels OraBug# 4988. Suppressed raising of
174 error 91457 when alws_dpnt_desgn_flag
175 and dpnt_dsgn_cd not found for a
176 specified enrt_rslt_id and effective
177 date. Defaulted these values to 'N'
178 and 'O', respectively, for the case
179 when not found.
180 115.59 29-Aug-00 jcarpent Merge of 57 and 58 changes. 57 changes
181 were not ready for primetime so leaped
182 now in synch.
183 115.60 06-Sep-00 jcarpent 1269016. Handling of future change dt mode.
184 115.61 07-Sep-00 jcarpent Changes from 115.60 based on version 115.58.
185 Leapfrog version not containing pcp stuff.
186 115.62 07-Sep-00 jcarpent Same as version
187 115.63 26-Oct-00 pbodla - Enhancement : Pass contact person id as
188 input value for "certification required
189 when rule" if the rule is for contacts.
190 115.64 27-Oct-00 pbodla - param1(CON_PERSON_ID) passed to formula
191 115.65 15-Nov-00 jcarpent Bug 1488666. Was creating same ctfn
192 2 times because both cursors ecc1+2
193 were returning the same row.
194 115.66 22-Nov-00 jcarpent Bug 1488666. Was creating same ctfn
195 when one was a benefit ctfn and one
196 was an enrt ctfn. No need for both.
197 115.67 29-Dec-00 ikasire bug fix 1491912
198 115.68 08-mar-01 ikasire bug fix 1421978 modified the pcp cursors
199 for dependent and participant
200 115.69 20-apr-01 ikasire bug 1421978 Only one action item for pcp
201 is created for all the dependents of the
202 prtt. This is fixed to get the pcp
203 action item one for each dependent.
204 Added p_elig_cvrd_dpnt_id parameter to the
205 determine_pcp_dpnt_actn_items procedure.
206 Also passed p_elig_cvrd_dpnt_id parameter
207 for the call to get_prtt_enrt_actn_id and
208 process_action_item procedures from the
209 determine_pcp_dpnt_actn_items procedure.
210 115.70 25-Apr-01 maagrawa Performance changes.
211 115.71 17-May-01 maagrawa More Performance changes.
212 115.72 17-May-01 maagrawa Added exit statement.
213 115.73 02-Jul-01 kmahendr Bug#1842614- increased l_pln_name variable to 80
214 115.74 27-aug-01 tilak bug:1949361 jurisdiction code is
215 derived inside benutils.formula.
216 115.75 26-Dec-01 pabodla bug:1857685 - Do not create dependent and
217 beneficiary related action items for
218 waive plans and options.
219 115.76 08-FEB-02 aprabhak added an action item for future salary
220 increase
221 115.77 21-FEB-02 ikasire bug 2228123 getting the suspend_flag in
222 determine_action_items procedure
223 115.78 02-MAR-02 aprabhak modified the salary cursor to pickup
224 only salary increase plan
225 115.79 08-MAR-02 aprabhak Modified the future salary cursor.
226 Removed the rate join.
227 115.80 14-Mar-02 rpillay UTF8 Changes Bug 2254683
228 115.81 30-Apr-02 kmahendr Added token to message 91832.
229 115.82 23-May-02 ikasire Bug 2389261 Inconsistent results due to
230 not exclusion on epe with bnft_prvdr_pool_id
231 from the cursors
232 115.83 30-May-02 ikasire Bug 2386000 Added p_called_from to the
233 delete_cvrd_dpnt_ctfn_prvdd call
234 115.84 08-Jun-02 pabodla Do not select the contingent worker
235 assignment when assignment data is
236 fetched.
237 115.85 30-jul-02 hnarayan bug 1169240 - added the function
238 check_bnf_actn_item_dfnd to check for
239 any action items defined for beneficiaries
240 115.86 26-DEC-02 kichoudh NOCOPY changes
241 115.87 13-feb-03 hnarayan hr_utility.set_location - 'if g_debug' changes
242 115.88 21-Mar-03 mmudigon Bug 2858700. Added dt condition and order
243 by clause to cursor c_dpnt_bnf_adrs.
244 115.89 24-Mar-03 mmudigon Bug 2858700 continued. Added order by
245 clause to cursor c_prtt_adrs.
246 115.90 22-Jul-03 ikasire Bug 3042379 dont create action items for the
247 interim enrollment. defensive code.
248 115.91 19-Aug-03 ikasire Bug 3105160 added raise in the exception clause.
249 115.92 25-aug-03 kmahendr Bug#3108422 - if ERL is the cvg_mlt_cd certification action item
250 is called.
251 115.93 26-aug-03 kmahendr Condition modified for ERL
252 115.94 08-aug-03 pbodla Bug 3183266 : For flat range mx_wout_ctfn_val
253 will be null, so use nvl around it.
254 115.95 17-oct-03 hmani Modified the arg passed to
255 write_new_bnf_ctfn_item call - Bug 3196152
256 115.96 05-Nov-03 tjesumic contact_type are expected to have more than one row for epnt
257 sub query failing due to =, now changed to in # 3228530
258 115.97 13-Nov-03 bmanyam Bug.3248711. Allowing Dpnt Dsgn Action item to get created,
259 when (epe.alws_dpnt_dsgn_flag = 'Y' OR epe.dpnt_dsgn_cd = 'R'
260 115.98 17-Dec-03 vvprabhu Added the assignment for g_debug at the start
261 of each public procedure
262 115.99 21-Jan-2003 vvprabhu Added the assignment for g_debug at the start
263 of each public Function
264 115.100 20-Feb-2004 kmahendr Bug#3442729 - added codes to set_cmpltd_dt
265 115.101 19-Apr-2004 bmanyam Bug# 3510501 - In the date_track_verify method,
266 set the date-track-mode to UPDATE, in the ELSE..part.
267 115.102 01-Jun-2004 kmahendr Bug#3643597 - added a new private procedure
268 check_ctfn_prvdd.
269 115.103 02-Jun-2004 kmahendr Bug#3643597 - cursor c_prtt_enrt_rslt modified.
270 115.104 03-jun-2004 kmahendr Bug#3643597 - cursor c_prtt_enrt_rslt modified.
271 115.105 01-jul-2004 bmanyam Bug#3730053 - cursor c_emp_only modified.
272 OIPL level DSGN_RQMTS override OPT level
273 115.106 01-jul-2004 kmahendr bug#3590524 - Added codes to check_ctfn_prvdd
274 115.107 21-jul-2004 rpgupta bug#3771346 - If waive flag not checked at option level, check at the plan level
275 115.108 29-jul-2004 kmahendr bug#3748133 - Added codes to check_ctfn_prvdd
276 115.109 17-Aug-2004 hmani bug#3806262 - p_crntly_enrd_flag can be 'N' for new enrollment
277 115.110 19-Aug-2004 kmahendr Optional certification changes
278 115.111 23-Aug-2004 mmudigon CFW. Added p_act_item flag
279 2534391 :NEED TO LEAVE ACTION ITEMS
280 115.112 26-aug-2004 nhunur gscc compliance
281 115.113 26-Aug-2004 abparekh Bug# 3854556 - Modified cursor c_dsgn_bnf
282 115.114 31-Aug-2004 abparekh Bug# 3851427 Added p_susp_if_ctfn_not_prvd_flag to function
283 check_ctfns_defined. Consider "Suspend Enrollment" flag at
284 LER_CHG_DPNT level when certifications are considered at
285 LER_CHG_DPNT level. Modified p_rqd flag parameter in write_new_action_item
286 115.115 31-Aug-2004 pbodla CFW. Several cursors modified to join per_in_ler
287 115.116 09-sep-2004 mmudigon CFW. p_act_item flag no longer needed
288 115.117 03-nov-2004 kmahendr Bug3976575- cursor c_ctfn_defined modified to pl_id and
289 added codes in write_new_action_items for handling message
290 115.118 01-Dec-2004 abparekh Bug 4039404 : Fixed cursor c_pl_name in write_new_action_item
291 115.119 30-dec-2004 nhunur 4031733 - No need to open cursor c_state.
292 115.120 18-Mar-2005 swjain 4241743 - Added cursor c_prev_actn_ler in determine_other_actn_items
293 and modified if conditions to create action items also when ler id is different
294 115.121 22-Mar-2005 swjain Removed show errors
295 115.122 12-Apr-2005 swjain 4241743 - Removed cursor c_prev_actn_ler and added c_enrt_actn
296 115.123 13-Jun-2005 rbingi Bug:4396160 - Curosr name is changed from c_emp_only to c_tot_mn_mx_dpnts_req
297 cursor query changed to selects the total no. of Min and Max Dpnts req for the CompObj.
298 Changed Procedure: determine_dpnt_actn_items sothat,
299 For both Min and Max = 0, Action Item will NOT be created.
300 For Min = 0 and Max > 0, Action Item will be created IF Elig dpnts exists
301 For both Min and Max > 0, Action Item will be created irrespective of Elig dpnts.
302 115.124 13-Jun-2005 rbingi Corrected previuos change to create Action Item when no DD record is defined.
303 115.125 13-Jun-2005 rbingi Corrected compilation errors had in previuos version
304 115.126 29-Jun-2005 ikasire Bug 4422667 getting into loop issue
305 115.127 13-Jul-2005 ikasire Bug 4454990 fixed for the code
306 115.128 02-Aug-2005 rgajula Bug No 4525608
307 115.129 10-Aug-2005 A new parameter l_ctfn_actn_warning_o
308 was defined in determine_action_items which is passed on to
309 process_dpnt_actn_items and inturn passed to determine_other_actn_items
310 as out parameters.The signatures of the procedures have been changed accordingly
311 This flag whould capture the certification required action warning
312 if dependent details have been furnished and plan level certification have
313 not been furnished.
314 115.130 31-Aug-2005 ikasire BUG 4558512 completion date fix in set_cmpltd_dt procedure
315 115.131 01-Sep-2005 ikasire BUG 4558512 more changes
316 115.132 15-sep-2005 rgajula Bug 4610971 Passed the p_business_group_id to the procedure
317 ben_determine_date.main in procedure get_due_date so that
318 it ill be available to Action Type Due Date rule .
319 115.133 27-Apr-2006 swjain Bug 5156111 : Added additional logic for certications for organizations
320 in procedure determine_additional_bnf
321 115.134 28-Apr-2006 swjain Bug 5156111 : Updated cursor c_nsc_ctfn_pl in procedure determine_additional_bnf
322 115.135 02-May-2006 swjain Bug 5156111 : Updated cursor c_spouse to check for BNF_MAY_DSGT_ORG_FLAG flag
323 115.136 29-jun-2006 nhunur bug 5362890 : Added date clauses for pcr in c_spouse
324 114.137 11-Aug-2006 abparekh Bug 5461171 : Modified clauses in CURSOR c_nsc_ctfn_pl
325 115.138 9/20/2006 gsehgal bug 5513339 : added cursor c_curr_ovn_of_actn to pass right ovn
326 to delete_action_item
327 115.139 10-Jan-2007 bmanyam 5736589: No need for to check for Option Restrictions
328 when ctfn_determine_cd = 'ENRAT', as certifications are
329 determined at bendenrr (check_ctfn_prvdd)
330 115.141 23-Feb-07 swjain Bug 5887665: In procedure determine_other_actn_items, for coverage
331 certifications, added code to evaluate suspended codes
332 115.142 27-Feb-07 swjain Additional changes in procedure determine_other_actn_items and added new
333 parameter p_enrt_r_bnft_ctfn_cd in call to procedure check_ctfn_prvdd.
334 115.143 2-May-2007 rgajula Bug 5998009 : Corrected the code in the procedure determine_dpnt_miss_actn_items so as to make the system behaviour
335 ideal when Formula for 'Dependent Certification Required' type is used
336 115.144 04-May-2007 swjain Bug 6022327: Updated cursor c_ctfn_exists in procedure write_new_prtt_ctfn_prvdd_item
337 115.145 18-May-2007 swjain Bug 5965415: In procedure check_ctfn_prvdd, updated the cursor c_ctfn_prvdd and
338 c_ctfn_prvdd2 to check if any certification received in past for the same plan-option
339 (and not based on pen_id as it changes when coverage amount changes)
340 115.146 19-Jun-2007 gsehgal bug 6010780: checking future rows in update and correction mode also
341 115.147
342 115.148
343 115.149 23-Aug-2007 rgajula Bug 6353069 : Modified the procedure process_new_ctfn_action to check for dpnt certification suspend flag at various levels.
344 115.150 24-Sep-2007 rtagarra Bug 6434143 : before suspending enrollment check for SUSP_IF_CTFN_NOT_PRVD_FLAG flag.
345 115.151 22-Feb-2008 rtagarra 6840074
346 115.152 22-Sep-2008 sallumwa Bug 7417593 : Modified the cursor c_ctfn_prvdd to check if the certification is already received
347 in the past or not for the same plan and option.
348 115.153 24-sep-2008 sallumwa Bug 7417474 : Modified the cursor c_prtt_enrt_rslt,so that it doesn't fetch the record if two options
349 from the same plan are enrolled.
350 -------------------------------------------------------------------------------------------------------------------------------------------
351 */
352 --
353 -- Package Variables
354 --
355 g_debug boolean := hr_utility.debug_enabled;
356 --
357 -- -----------------------------------------------------------------------------
358 -- |-----------------------< check_ctfns_defined >-----------------------------|
359 -- -----------------------------------------------------------------------------
360 --
361 function check_ctfns_defined
362 (p_dpnt_person_id in number
363 ,p_person_id in number
364 ,p_prtt_enrt_rslt_id in number
365 ,p_lvl_cd in varchar2
366 ,p_pgm_id in number default null
367 ,p_pl_id in number default null
368 ,p_ptip_id in number default null
369 ,p_effective_date in date
370 ,p_business_group_id in number
371 ,p_ctfn_at_ler_chg out nocopy boolean
372 ,p_susp_if_ctfn_not_prvd_flag out nocopy varchar2
373 )
374 return boolean is
375 --
376 -- This function checks whether certifications have defined for a certain
377 -- contact type and sets the out parameter if the ctfn has been found at the
378 -- ben_ler_chg_dpnt_cvg_ctfn_f table.
379 -- Here the assumption is that if a certification is defined
380 -- without a contact type, then it is for all contact types. The function
381 -- returns TRUE if either a certification is found for the person's contact
382 -- type or a certification with a contact type of null is found.
383 --
384 -- Bug# 3851427 : Defined out parameter P_SUSP_IF_CTFN_NOT_PRVD_FLAG. This
385 -- parameter holds the value of "Suspend Enrollment" flag defined for
386 -- Dependent Change Of Life Event (BEN_LER_CHG_DPNT_CVG_F). Whenever certifications
387 -- are considered at "Dependent Change Of Life Event" level and NOT at PLN, PTIP or PGM
388 -- level, suspension should also be considered based on "Suspension Enrollment" flag value
389 -- at the "Dependent Change Of Life Event" level. Hence this flag will return valid
390 -- value only when P_CTFN_AT_LER_CHG is also true.
391 --
392 cursor c_ctfns_ler_chg is
393 select ldc.susp_if_ctfn_not_prvd_flag
394 from ben_ler_chg_dpnt_cvg_ctfn_f lcc,
395 ben_ler_chg_dpnt_cvg_f ldc,
396 ben_prtt_enrt_rslt_f pen
397 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
398 and pen.business_group_id = p_business_group_id
399 and p_effective_date between pen.effective_start_date
400 and pen.effective_end_date
401 and pen.ler_id = ldc.ler_id
402 and p_effective_date between ldc.effective_start_date
403 and ldc.effective_end_date
404 and pen.prtt_enrt_rslt_stat_cd is null
405 and ((p_lvl_cd = 'PTIP' and ldc.ptip_id = p_ptip_id) OR
406 (p_lvl_cd = 'PL' and ldc.pl_id = p_pl_id) OR
407 (p_lvl_cd = 'PGM' and ldc.pgm_id = p_pgm_id))
408 and ldc.ler_chg_dpnt_cvg_id = lcc.ler_chg_dpnt_cvg_id
409 and p_effective_date between lcc.effective_start_date
410 and lcc.effective_end_date
411 and (lcc.rlshp_typ_cd is null
412 or
413 lcc.rlshp_typ_cd in (select contact_type
414 from per_contact_relationships
415 where contact_person_id = p_dpnt_person_id
416 and person_id = p_person_id
417 and business_group_id = p_business_group_id
418 and p_effective_date
419 between nvl(date_start, p_effective_date)
420 and nvl(date_end, hr_api.g_eot)));
421
422 --
423 cursor c_ctfns_pgm is
424 select 'x'
425 from ben_pgm_dpnt_cvg_ctfn_f
426 where pgm_id = p_pgm_id
427 and business_group_id = p_business_group_id
428 and p_effective_date between effective_start_date
429 and effective_end_date
430 and (rlshp_typ_cd is null
431 or
432 rlshp_typ_cd in (select contact_type
433 from per_contact_relationships
434 where contact_person_id = p_dpnt_person_id
435 and person_id = p_person_id
436 and business_group_id = p_business_group_id
437 and p_effective_date
438 between nvl(date_start, p_effective_date)
439 and nvl(date_end, hr_api.g_eot)));
440 --
441 cursor c_ctfns_ptip is
442 select 'x'
443 from ben_ptip_dpnt_cvg_ctfn_f
444 where ptip_id = p_ptip_id
445 and business_group_id = p_business_group_id
446 and p_effective_date between effective_start_date
447 and effective_end_date
448 and (rlshp_typ_cd is null
449 or
450 rlshp_typ_cd in (select contact_type
451 from per_contact_relationships
452 where contact_person_id = p_dpnt_person_id
453 and person_id = p_person_id
454 and business_group_id = p_business_group_id
455 and p_effective_date
456 between nvl(date_start, p_effective_date)
457 and nvl(date_end, hr_api.g_eot)));
458 --
459 cursor c_ctfns_pl is
460 select 'x'
461 from ben_pl_dpnt_cvg_ctfn_f
462 where pl_id = p_pl_id
463 and business_group_id = p_business_group_id
464 and p_effective_date between effective_start_date
465 and effective_end_date
466 and (rlshp_typ_cd is null
467 or
468 rlshp_typ_cd in (select contact_type
469 from per_contact_relationships
470 where contact_person_id = p_dpnt_person_id
471 and person_id = p_person_id
472 and business_group_id = p_business_group_id
473 and p_effective_date
474 between nvl(date_start, p_effective_date)
475 and nvl(date_end, hr_api.g_eot)));
476 --
477 l_dummy varchar2(1);
478 l_return boolean := FALSE;
479 --
480 l_proc varchar2(80) ;
481 l_susp_if_ctfn_not_prvd_flag varchar2(30);
482 --
483 begin
484 --
485 if g_debug then
486 l_proc := g_package || '.check_ctfns_defined';
487 hr_utility.set_location('Entering ' || l_proc, 10);
488 end if;
489 if g_debug then
490 hr_utility.set_location('Dpnt dsgn level code : ' || p_lvl_cd, 10);
491 end if;
492 --
493 l_susp_if_ctfn_not_prvd_flag := null;
494 --
495 if p_lvl_cd = 'PGM' then
496 --
497 -- At the program level, first check for ctfns defined for the ler change
498 -- and then check for regular ctfns.
499 --
500 open c_ctfns_ler_chg;
501 fetch c_ctfns_ler_chg into l_susp_if_ctfn_not_prvd_flag;
502 if c_ctfns_ler_chg%found then
503 close c_ctfns_ler_chg;
504 l_return := TRUE;
505 p_ctfn_at_ler_chg := TRUE;
506 else
507 close c_ctfns_ler_chg;
508 open c_ctfns_pgm;
509 fetch c_ctfns_pgm into l_dummy;
510 if c_ctfns_pgm%found then
511 l_return := TRUE;
512 else
513 l_return := FALSE;
514 end if;
515 close c_ctfns_pgm;
516 end if;
517 --
518 elsif p_lvl_cd = 'PTIP' then
519 --
520 -- At the ptip level, first check for ctfns defined for the ler change
521 -- and then check for regular ctfns.
522 --
523 open c_ctfns_ler_chg;
524 fetch c_ctfns_ler_chg into l_susp_if_ctfn_not_prvd_flag;
525 if c_ctfns_ler_chg%found then
526 close c_ctfns_ler_chg;
527 l_return := TRUE;
528 p_ctfn_at_ler_chg := TRUE;
529 else
530 close c_ctfns_ler_chg;
531 open c_ctfns_ptip;
532 fetch c_ctfns_ptip into l_dummy;
533 if c_ctfns_ptip%found then
534 l_return := TRUE;
535 else
536 l_return := FALSE;
537 end if;
538 close c_ctfns_ptip;
539 end if;
540 --
541 else
542 --
543 -- At the plan level, first check for ctfns defined for the ler change
544 -- and then check for regular ctfns.
545 --
546 open c_ctfns_ler_chg;
547 fetch c_ctfns_ler_chg into l_susp_if_ctfn_not_prvd_flag;
548 if c_ctfns_ler_chg%found then
549 close c_ctfns_ler_chg;
550 l_return := TRUE;
551 p_ctfn_at_ler_chg := TRUE;
552 else
553 close c_ctfns_ler_chg;
554 open c_ctfns_pl;
555 fetch c_ctfns_pl into l_dummy;
556 if c_ctfns_pl%found then
557 l_return := TRUE;
558 else
559 l_return := FALSE;
560 end if;
561 close c_ctfns_pl;
562 end if;
563 --
564 end if;
565 --
566 p_susp_if_ctfn_not_prvd_flag := l_susp_if_ctfn_not_prvd_flag;
567 --
568 if l_return then
569 if g_debug then
570 hr_utility.set_location('CTFNS are defined', 99);
571 end if;
572 else
573 if g_debug then
574 hr_utility.set_location('CTFNS not defined', 99);
575 end if;
576 end if;
577 --
578 if g_debug then
579 hr_utility.set_location('Leaving ' || l_proc, 99);
580 end if;
581 --
582 return l_return;
583 --
584 end check_ctfns_defined;
585 --
586 -- -----------------------------------------------------------------------------
587 -- |-----------------------------< get_due_date >------------------------------|
588 -- -----------------------------------------------------------------------------
589 --
590 function get_due_date
591 (p_prtt_enrt_rslt_id in number
592 ,p_actn_typ_id in number
593 ,p_effective_date in date
594 ,p_business_group_id in number)
595 return date is
596 --
597 l_proc varchar2(80) := g_package || '.get_due_date';
598 --
599 -- Cursor to fetch the due date code for an action item. The action type can
600 -- be defined at either the program or the plan level. If an action type is
601 -- defined at both levels, then the one at the plan level should be selected.
602 --
603 cursor c_pl_popl_actn_typ(v_pl_id number) is
604 select pat.popl_actn_typ_id,
605 pat.effective_start_date,
606 pat.effective_end_date,
607 pat.actn_typ_due_dt_cd,
608 pat.actn_typ_due_dt_rl
609 from ben_popl_actn_typ_f pat
610 where pat.pl_id = v_pl_id
611 and pat.actn_typ_id = p_actn_typ_id
612 and pat.business_group_id = p_business_group_id
613 and p_effective_date between pat.effective_start_date
614 and pat.effective_end_date;
615 --
616 cursor c_pgm_popl_actn_typ(v_pgm_id number) is
617 select pat.popl_actn_typ_id,
618 pat.effective_start_date,
619 pat.effective_end_date,
620 pat.actn_typ_due_dt_cd,
621 pat.actn_typ_due_dt_rl
622 from ben_popl_actn_typ_f pat
623 where pat.pgm_id = v_pgm_id
624 and pat.actn_typ_id = p_actn_typ_id
625 and pat.business_group_id = p_business_group_id
626 and p_effective_date between pat.effective_start_date
627 and pat.effective_end_date;
628 --
629 l_pat c_pl_popl_actn_typ%rowtype;
630 --
631 -- Cursor to fetch elctbl_chc_id for the prtt_enrt_rslt_id
632 --
633 cursor c_elctbl_chc is
634 select epe.elig_per_elctbl_chc_id,
635 epe.pl_id,
636 epe.pgm_id
637 from ben_prtt_enrt_rslt_f pen,
638 ben_elig_per_elctbl_chc epe,
639 ben_per_in_ler pil
640 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
641 and pen.prtt_enrt_rslt_stat_cd is null
642 and p_effective_date between
643 pen.effective_start_date and pen.effective_end_date
644 and pen.prtt_enrt_rslt_id = epe.prtt_enrt_rslt_id
645 and pen.per_in_ler_id = epe.per_in_ler_id
646 and pil.per_in_ler_id = epe.per_in_ler_id
647 and pil.business_group_id = p_business_group_id
648 and pil.per_in_ler_stat_cd not in ('VOIDD', 'BCKDT');
649 --
650 l_elig_per_elctbl_chc_id number(15) := null;
651 l_pl_id number;
652 l_pgm_id number;
653 --
654 -- Cursor to fetch the start date for the enrollment period
655 --
656 l_returned_date date := null;
657 --
658 pat_not_found exception;
659 --
660 begin
661 --
662 if g_debug then
663 hr_utility.set_location ('Entering '||l_proc,10);
664 end if;
665 --
666 if p_actn_typ_id is null then
667 --
668 fnd_message.set_name('BEN','BEN_91832_PACKAGE_PARAM_NULL');
669 fnd_message.set_token('PACKAGE',l_proc);
670 fnd_message.set_token('PROC','Enrollment Action Items');
671 fnd_message.set_token('PARAM','p_actn_typ_id');
672 fnd_message.raise_error;
673 --
674 end if;
675 --
676 open c_elctbl_chc;
677 fetch c_elctbl_chc into l_elig_per_elctbl_chc_id, l_pl_id, l_pgm_id;
678 close c_elctbl_chc;
679 --
680 open c_pl_popl_actn_typ(l_pl_id);
681 fetch c_pl_popl_actn_typ into l_pat;
682 close c_pl_popl_actn_typ;
683 --
684 if l_pat.popl_actn_typ_id is null and
685 l_pgm_id is not null then
686 --
687 open c_pgm_popl_actn_typ(l_pgm_id);
688 fetch c_pgm_popl_actn_typ into l_pat;
689 close c_pgm_popl_actn_typ;
690 --
691 end if;
692 --
693 if l_pat.popl_actn_typ_id is null then
694 raise pat_not_found;
695 end if;
696 --
697 --
698 -- Call the ben_determine_date.main procedure
699 --
700 --
701 -- Call the date routine only if the due date code is not null.
702 --
703 if l_pat.actn_typ_due_dt_cd is not null then
704 --
705 --Bug 4610971 Passed the p_business_group_id to the procedure
706 -- ben_determine_date.main so that it ill be available to Action Type Due Date rule
707 ben_determine_date.main
708 (p_date_cd => l_pat.actn_typ_due_dt_cd
709 ,p_effective_date => p_effective_date
710 ,p_elig_per_elctbl_chc_id => l_elig_per_elctbl_chc_id
711 ,p_formula_id => l_pat.actn_typ_due_dt_rl
712 ,p_business_group_id => p_business_group_id
713 ,p_returned_date => l_returned_date);
714 --
715 --End Bug 4610971
716 end if;
717 --
718 if g_debug then
719 hr_utility.set_location ('Leaving '||l_proc,10);
720 end if;
721 --
722 return l_returned_date;
723 --
724 exception
725 --
726 when pat_not_found then
727 --
728 if g_debug then
729 hr_utility.set_location('Leaving : ' || l_proc, 10);
730 end if;
731 l_returned_date := NULL;
732 return l_returned_date;
733 --
734 when others then
735 if g_debug then
736 hr_utility.set_location('Exception Raised '||l_proc, 10);
737 end if;
738 raise;
739 --
740 end get_due_date;
741 --
742 -- ----------------------------------------------------------------------------
743 -- |--------------------------< get_actn_typ_id >-----------------------------|
744 -- ----------------------------------------------------------------------------
745 --
746 function get_actn_typ_id
747 (p_type_cd in varchar2
748 ,p_business_group_id in number)
749 return number is
750 --
751 -- Return the actn_typ_id or NULL when given the ben_actn_typ.type_cd
752 -- type_cd examples DDDOB, DDSSN, BNFADDR, etc.
753 -- note: future improvement could be to get this list once and then find
754 -- the values from the pl/sql record
755 --
756 l_proc varchar2(80);
757 l_actn_typ_id ben_actn_typ.actn_typ_id%type := NULL;
758 --
759 cursor c_actn_typ_id is
760 select bat.actn_typ_id
761 from ben_actn_typ bat
762 where bat.type_cd = p_type_cd
763 and bat.business_group_id = p_business_group_id;
764 --
765 begin
766 --
767 g_debug := hr_utility.debug_enabled;
768 if g_debug then
769 l_proc := g_package||'.get_actn_typ_id';
770 hr_utility.set_location ('Entering '||l_proc,10);
771 end if;
772 --
773 open c_actn_typ_id;
774 fetch c_actn_typ_id into l_actn_typ_id;
775 --
776 if c_actn_typ_id%notfound then
777 l_actn_typ_id := NULL;
778 end if;
779 --
780 close c_actn_typ_id;
781 --
782 if g_debug then
783 hr_utility.set_location ('Leaving '||l_proc, 10);
784 end if;
785 --
786 return l_actn_typ_id;
787 --
788 exception
789 when others then
790 if g_debug then
791 hr_utility.set_location('Exception Raised '||l_proc, 10);
792 end if;
793 raise;
794 --
795 end get_actn_typ_id;
796 --
797 -- ----------------------------------------------------------------------------
798 -- |-------------------------< get_prtt_enrt_actn_id >------------------------|
799 -- ----------------------------------------------------------------------------
800 --
801 procedure get_prtt_enrt_actn_id
802 (p_actn_typ_id in number
803 ,p_prtt_enrt_rslt_id in number
804 ,p_elig_cvrd_dpnt_id in number default null
805 ,p_pl_bnf_id in number default null
806 ,p_effective_date in date
807 ,p_business_group_id in number
808 ,p_prtt_enrt_actn_id out nocopy number
809 ,p_cmpltd_dt out nocopy date
810 ,p_object_version_number in out nocopy number) is
811 --
812 -- This procedure returns the prtt_enrt_actn_id for either a general action
813 -- type like DD that can only be associated with an enrt rslt or it can be
814 -- used to retrieve a more specific action id like DDDOB which is tied to an
815 -- eligible covered dependent using the elig_cvrd_dpnt_id
816 --
817 l_proc varchar2(80);
818 --
819 -- Cursor to fetch an action item record that is not associated with any dpnt
820 -- or a bnf but is tied to the participant's enrt rslt id and is of a general
821 -- action type like DD or BNF
822 --
823 cursor c_enrt_actn is
824 select pea.prtt_enrt_actn_id,
825 pea.cmpltd_dt,
826 pea.object_version_number
827 from ben_prtt_enrt_actn_f pea,
828 ben_per_in_ler pil
829 where pea.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
830 and pea.actn_typ_id = p_actn_typ_id
831 and pea.pl_bnf_id is null
832 and pea.elig_cvrd_dpnt_id is null
833 and pea.per_in_ler_id = pil.per_in_ler_id
834 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
835 and pea.business_group_id = p_business_group_id
836 and p_effective_date between pea.effective_start_date
837 and pea.effective_end_date ;
838 --
839 l_enrt_actn c_enrt_actn%rowtype;
840 l_object_version_number number(15);
841
842 --
843 -- Cursor to fetch an action item record for a particular dependent and for
844 -- a particular action type.
845 --
846 cursor c_enrt_actn_dpnt is
847 select pea.prtt_enrt_actn_id,
848 pea.cmpltd_dt,
849 pea.object_version_number
850 from ben_prtt_enrt_actn_f pea,
851 ben_per_in_ler pil
852 where pea.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
853 and pea.actn_typ_id = p_actn_typ_id
854 and pea.per_in_ler_id = pil.per_in_ler_id
855 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
856 and pea.elig_cvrd_dpnt_id = p_elig_cvrd_dpnt_id
857 and pea.business_group_id = p_business_group_id
858 and p_effective_date between pea.effective_start_date
859 and pea.effective_end_date;
860 --
861 l_enrt_actn_dpnt c_enrt_actn_dpnt%rowtype;
862 --
863 -- Cursor to fetch an action item record for a particular beneficiary and for
864 -- a particular action type.
865 --
866 cursor c_enrt_actn_bnf is
867 select pea.prtt_enrt_actn_id,
868 pea.cmpltd_dt,
869 pea.object_version_number
870 from ben_prtt_enrt_actn_f pea,
871 ben_per_in_ler pil
872 where pea.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
873 and pea.actn_typ_id = p_actn_typ_id
874 and pea.pl_bnf_id = p_pl_bnf_id
875 and pea.per_in_ler_id = pil.per_in_ler_id
876 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
877 and pea.business_group_id = p_business_group_id
878 and p_effective_date between pea.effective_start_date
879 and pea.effective_end_date;
880 --
881 l_enrt_actn_bnf c_enrt_actn_bnf%rowtype;
882
883 --
884 begin
885 --
886 g_debug := hr_utility.debug_enabled;
887 if g_debug then
888 l_proc := g_package||'.get_prtt_enrt_actn_id';
889 hr_utility.set_location ('Entering '||l_proc,10);
890 end if;
891 l_object_version_number := p_object_version_number ;
892
893 hr_utility.set_location ('p_prtt_enrt_rslt_id '|| p_prtt_enrt_rslt_id,10);
894 hr_utility.set_location ('p_elig_cvrd_dpnt_id '|| p_elig_cvrd_dpnt_id,10);
895 hr_utility.set_location ('p_pl_bnf_id '|| p_pl_bnf_id,10);
896
897 --
898 if p_prtt_enrt_rslt_id is not null then
899 --
900 if p_elig_cvrd_dpnt_id is null and
901 p_pl_bnf_id is null then
902 --
903 -- A general enrt action id was requested from the calling proc.
904 -- Open the appropriate cursor
905 --
906 open c_enrt_actn;
907 fetch c_enrt_actn into l_enrt_actn;
908 --
909 if c_enrt_actn%notfound then
910 p_prtt_enrt_actn_id := NULL;
911 p_cmpltd_dt := NULL;
912 else
913 p_prtt_enrt_actn_id := l_enrt_actn.prtt_enrt_actn_id;
914 p_cmpltd_dt := l_enrt_actn.cmpltd_dt;
915 p_object_version_number := l_enrt_actn.object_version_number;
916 end if;
917 --
918 close c_enrt_actn;
919 --
920 hr_utility.set_location ('p_prtt_enrt_actn_id '|| p_prtt_enrt_actn_id,11);
921 hr_utility.set_location ('p_cmpltd_dt '|| p_cmpltd_dt,11);
922
923
924
925 elsif p_elig_cvrd_dpnt_id is not null and
926 p_pl_bnf_id is null then
927 --
928 -- A request for a dependent's specific action item was made
929 --
930 open c_enrt_actn_dpnt;
931 fetch c_enrt_actn_dpnt into l_enrt_actn_dpnt;
932 --
933 if c_enrt_actn_dpnt%notfound then
934 p_prtt_enrt_actn_id := NULL;
935 p_cmpltd_dt := NULL;
936 else
937 p_prtt_enrt_actn_id := l_enrt_actn_dpnt.prtt_enrt_actn_id;
938 p_cmpltd_dt := l_enrt_actn_dpnt.cmpltd_dt;
939 p_object_version_number := l_enrt_actn_dpnt.object_version_number;
940 end if;
941 --
942 close c_enrt_actn_dpnt;
943 --
944 hr_utility.set_location ('p_prtt_enrt_actn_id '|| p_prtt_enrt_actn_id,12);
945 hr_utility.set_location ('p_cmpltd_dt '|| p_cmpltd_dt,12);
946
947 elsif p_elig_cvrd_dpnt_id is null and
948 p_pl_bnf_id is not null then
949 --
950 -- A request for a benefiary's specific action item was made
951 --
952 open c_enrt_actn_bnf;
953 fetch c_enrt_actn_bnf into l_enrt_actn_bnf;
954 --
955 if c_enrt_actn_bnf%notfound then
956 p_prtt_enrt_actn_id := NULL;
957 p_cmpltd_dt := NULL;
958 else
959 p_prtt_enrt_actn_id := l_enrt_actn_bnf.prtt_enrt_actn_id;
960 p_cmpltd_dt := l_enrt_actn_bnf.cmpltd_dt;
961 p_object_version_number := l_enrt_actn_bnf.object_version_number;
962 end if;
963 --
964 close c_enrt_actn_bnf;
965 --
966 hr_utility.set_location ('p_prtt_enrt_actn_id '|| p_prtt_enrt_actn_id,13);
967 hr_utility.set_location ('p_cmpltd_dt '|| p_cmpltd_dt,13);
968
969 end if;
970 --
971 else
972 -- p_enrt_rslt_id is null
973 --
974 p_prtt_enrt_actn_id := NULL;
975 p_cmpltd_dt := NULL;
976 p_object_version_number := NULL;
977 end if;
978 --
979 if g_debug then
980 hr_utility.set_location ('Leaving '||l_proc, 10);
981 end if;
982 --
983 exception
984 when others then
985
986 -- Init Variables for NOCOPY
987 p_prtt_enrt_actn_id :=null ;
988 p_cmpltd_dt :=null ;
989 p_object_version_number := l_object_version_number ;
990 --
991 if g_debug then
992 hr_utility.set_location('Exception Raised '||l_proc, 10);
993 end if;
994 raise;
995 --
996 end get_prtt_enrt_actn_id;
997 --
998 -- ----------------------------------------------------------------------------
999 -- |--------------------------< date_track_verify >---------------------------|
1000 -- ----------------------------------------------------------------------------
1001 --
1002 function date_track_verify
1003 (p_dt_mode in varchar2
1004 ,p_dflt_mode in varchar2
1005 ,p_eff_date in date
1006 ,p_start_date in date)
1007 return varchar2 is
1008 --
1009 l_proc varchar2(80);
1010 l_datetrack_mode varchar2(30);
1011 --
1012 begin
1013 --
1014 if g_debug then
1015 l_proc := g_package||'.date_track_verify';
1016 hr_utility.set_location ('Entering '||l_proc,10);
1017 end if;
1018 --
1019 -- Date track settings need some massaging right now.
1020 -- This routine is used to set the rules for mode settings depending
1021 -- on what we are passed and action we are doing.
1022 --
1023 if p_dt_mode IS NULL then
1024 l_datetrack_mode := p_dflt_mode;
1025 else
1026 l_datetrack_mode := p_dt_mode;
1027 end if;
1028 --
1029 -- there are other rules now that we must apply
1030 --
1031 if l_datetrack_mode = DTMODE_ZAP then
1032 -- zap mode converts to correction
1033 l_datetrack_mode := hr_api.g_correction;
1034 --
1035 elsif l_datetrack_mode = DTMODE_DELETE then
1036 -- delete mode converts to update
1037 l_datetrack_mode := DTMODE_UPDATE;
1038 elsif l_datetrack_mode = hr_api.g_future_change then
1039 l_datetrack_mode := DTMODE_UPDATE;
1040 --
1041 else
1042 -- Bug: 3510501: In all other cases, set date-track mode to 'UPDATE'.
1043 -- NULL;
1044 l_datetrack_mode := DTMODE_UPDATE;
1045 end if;
1046 --
1047 -- recheck the DTMODE_UPDATE by comparing effective date with effective start
1048 -- date
1049 --
1050 if l_datetrack_mode = DTMODE_UPDATE and
1051 p_eff_date IS NOT NULL and
1052 p_start_date IS NOT NULL and
1053 p_eff_date = p_start_date then
1054 l_datetrack_mode := hr_api.g_correction;
1055 end if;
1056 --
1057 if g_debug then
1058 hr_utility.set_location ('Leaving '||l_proc, 10);
1059 end if;
1060 --
1061 return l_datetrack_mode;
1062 --
1063 exception
1064 when others then
1065 if g_debug then
1066 hr_utility.set_location('Exception Raised '||l_proc, 10);
1067 end if;
1068 raise;
1069 --
1070 end date_track_verify;
1071 --
1072 -- ----------------------------------------------------------------------------
1073 -- |-----------------------< write_new_action_item >--------------------------|
1074 -- ----------------------------------------------------------------------------
1075 --
1076 procedure write_new_action_item
1077 (p_prtt_enrt_rslt_id in number
1078 ,p_rslt_object_version_number in out nocopy number
1079 ,p_actn_typ_id in number
1080 ,p_elig_cvrd_dpnt_id in number default null
1081 ,p_pl_bnf_id in number default null
1082 ,p_rqd_flag in varchar2 default 'Y'
1083 ,p_cmpltd_dt in date default null
1084 ,p_effective_date in date
1085 ,p_business_group_id in number
1086 ,p_post_rslt_flag in varchar2 default 'Y'
1087 ,p_object_version_number out nocopy number
1088 ,p_prtt_enrt_actn_id out nocopy number) is
1089 --
1090 cursor c_act_name is
1091 select tl.name actn_typ_name
1092 from ben_actn_typ typ,
1093 ben_actn_typ_tl tl
1094 where p_actn_typ_id = typ.actn_typ_id
1095 and typ.actn_typ_id = tl.actn_typ_id
1096 and tl.language = userenv('lang')
1097 and typ.type_cd <> 'BNF'
1098 and typ.type_cd like 'BNF%'
1099 and typ.business_group_id = p_business_group_id;
1100 --
1101 cursor c_pl_name is
1102 select pln.name,
1103 pen.person_id
1104 from ben_pl_f pln,
1105 ben_prtt_enrt_rslt_f pen
1106 where pln.pl_id = pen.pl_id
1107 and pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id /* Bug 4039404 */
1108 and pen.prtt_enrt_rslt_stat_cd is null
1109 and p_effective_date between pln.effective_Start_date
1110 and pln.effective_end_date
1111 and p_effective_date between pen.effective_Start_date
1112 and pen.effective_end_date;
1113 --
1114 l_act_name varchar2(300);
1115 l_pl_name varchar2(300);
1116 l_person_id number;
1117 l_proc varchar2(80);
1118 l_effective_start_date date;
1119 l_effective_end_date date;
1120 l_due_dt date;
1121 l_rslt_object_version_number number(15);
1122 l_message1 varchar2(300) := 'BEN_94108_BNF_ACT_ITEM';
1123
1124 --
1125 begin
1126 --
1127 g_debug := hr_utility.debug_enabled;
1128 if g_debug then
1129 l_proc := g_package||'.write_new_action_item';
1130 hr_utility.set_location ('Entering '||l_proc,10);
1131 end if;
1132 l_rslt_object_version_number := p_rslt_object_version_number ;
1133 --
1134 -- Get the due date for the action item
1135 --
1136 l_due_dt := get_due_date
1137 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1138 ,p_actn_typ_id => p_actn_typ_id
1139 ,p_effective_date => p_effective_date
1140 ,p_business_group_id => p_business_group_id);
1141 --
1142 -- Using table api write a new record for an action item
1143 --
1144 ben_prtt_enrt_actn_api.create_prtt_enrt_actn
1145 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1146 ,p_rslt_object_version_number => p_rslt_object_version_number
1147 ,p_actn_typ_id => p_actn_typ_id
1148 ,p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id
1149 ,p_pl_bnf_id => p_pl_bnf_id
1150 ,p_due_dt => l_due_dt
1151 ,p_rqd_flag => p_rqd_flag
1152 ,p_cmpltd_dt => p_cmpltd_dt
1153 ,p_effective_date => p_effective_date
1154 ,p_post_rslt_flag => p_post_rslt_flag
1155 ,p_business_group_id => p_business_group_id
1156 ,p_object_version_number => p_object_version_number
1157 ,p_effective_start_date => l_effective_start_date
1158 ,p_effective_end_date => l_effective_end_date
1159 ,p_prtt_enrt_actn_id => p_prtt_enrt_actn_id);
1160 if p_pl_bnf_id is not null then
1161 --
1162 open c_act_name;
1163 fetch c_act_name into l_act_name;
1164 close c_act_name;
1165 --
1166 open c_pl_name;
1167 fetch c_pl_name into l_pl_name, l_person_id;
1168 close c_pl_name;
1169 --
1170
1171 ben_warnings.load_warning
1172 (p_application_short_name => 'BEN',
1173 p_message_name => l_message1,
1174 p_parma => l_act_name,
1175 p_parmb => l_pl_name,
1176 p_person_id => l_person_id);
1177
1178 --
1179 end if;
1180 --
1181 if g_debug then
1182 hr_utility.set_location ('Leaving '||l_proc, 10);
1183 end if;
1184 --
1185 exception
1186 when others then
1187
1188
1189 -- Init Variables for NOCOPY
1190 p_rslt_object_version_number :=l_rslt_object_version_number;
1191 p_object_version_number :=null;
1192 p_prtt_enrt_actn_id :=null;
1193
1194 if g_debug then
1195 hr_utility.set_location('Exception Raised '||l_proc, 10);
1196 end if;
1197 raise;
1198 --
1199 end write_new_action_item;
1200 --
1201 -- ----------------------------------------------------------------------------
1202 -- |-----------------------< write_new_dpnt_ctfn_item >-----------------------|
1203 -- ----------------------------------------------------------------------------
1204 --
1205 procedure write_new_dpnt_ctfn_item
1206 (p_elig_cvrd_dpnt_id in number
1207 ,p_prtt_enrt_actn_id in number
1208 ,p_dpnt_dsgn_ctfn_typ_cd in varchar2
1209 ,p_dpnt_dsgn_ctfn_rqd_flag in varchar2
1210 ,p_effective_date in date
1211 ,p_business_group_id in number
1212 ,p_object_version_number out nocopy number
1213 ,p_cvrd_dpnt_ctfn_prvdd_id out nocopy number) is
1214 --
1215 -- this procedure writes a dependent certification to
1216 -- ben_cvrd_dpnt_ctfn_prvdd_f
1217 --
1218 l_proc varchar2(80);
1219 l_effective_start_date date;
1220 l_effective_end_date date;
1221 --
1222 begin
1223 --
1224 if g_debug then
1225 l_proc := g_package||'.write_new_dpnt_ctfn_item';
1226 hr_utility.set_location ('Entering '||l_proc,10);
1227 end if;
1228 --
1229 -- write a new record for a dependent certification item
1230 --
1231 ben_cvrd_dpnt_ctfn_prvdd_api.create_cvrd_dpnt_ctfn_prvdd
1232 (p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id
1233 ,p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
1234 ,p_dpnt_dsgn_ctfn_typ_cd => p_dpnt_dsgn_ctfn_typ_cd
1235 ,p_dpnt_dsgn_ctfn_rqd_flag => p_dpnt_dsgn_ctfn_rqd_flag
1236 ,p_effective_date => p_effective_date
1237 ,p_business_group_id => p_business_group_id
1238 ,p_object_version_number => p_object_version_number
1239 ,p_effective_start_date => l_effective_start_date
1240 ,p_effective_end_date => l_effective_end_date
1241 ,p_cvrd_dpnt_ctfn_prvdd_id => p_cvrd_dpnt_ctfn_prvdd_id
1242 ,p_program_application_id => fnd_global.prog_appl_id
1243 ,p_program_id => fnd_global.conc_program_id
1244 ,p_request_id => fnd_global.conc_request_id
1245 ,p_program_update_date => sysdate);
1246 --
1247 if g_debug then
1248 hr_utility.set_location ('Leaving '||l_proc, 10);
1249 end if;
1250 --
1251 exception
1252 /* we could have duplicates already here from prior run
1253 - BEN_91632_DUP_DPNT_CTFN */
1254 when others then
1255
1256 -- Init Variables for NOCOPY
1257 p_object_version_number :=null ;
1258 p_cvrd_dpnt_ctfn_prvdd_id :=null ;
1259 if g_debug then
1260 hr_utility.set_location('Exception Raised '||l_proc, 10);
1261 end if;
1262 raise;
1263 --
1264 end write_new_dpnt_ctfn_item;
1265 --
1266 -- ----------------------------------------------------------------------------
1267 -- |-------------------< write_new_prtt_ctfn_prvdd_item >---------------------|
1268 -- ----------------------------------------------------------------------------
1269 --
1270 procedure write_new_prtt_ctfn_prvdd_item
1271 (p_rqd_flag in varchar2
1272 ,p_enrt_ctfn_typ_cd in varchar2
1273 ,p_enrt_r_bnft_ctfn_cd in varchar2
1274 ,p_prtt_enrt_rslt_id in number
1275 ,p_prtt_enrt_actn_id in number
1276 ,p_effective_date in date
1277 ,p_business_group_id in number
1278 ,p_object_version_number out nocopy number
1279 ,p_prtt_enrt_ctfn_prvdd_id out nocopy number) is
1280 --
1281 -- Does this ctfn already exist for this action item?
1282 --
1283 cursor c_ctfn_exists is
1284 select null
1285 from ben_prtt_enrt_ctfn_prvdd_f ecp
1286 where ecp.enrt_ctfn_typ_cd=p_enrt_ctfn_typ_cd
1287 and ecp.enrt_ctfn_rqd_flag=p_rqd_flag
1288 and p_effective_date between
1289 ecp.effective_start_date and ecp.effective_end_date
1290 and ecp.business_group_id=p_business_group_id
1291 and ecp.prtt_enrt_actn_id=p_prtt_enrt_actn_id
1292 and exists -- Bug 6022327: Changed from not exists to exists
1293 ( select pea.prtt_enrt_actn_id
1294 from ben_prtt_enrt_actn_f pea,
1295 ben_per_in_ler pil
1296 where pea.per_in_ler_id = pil.per_in_ler_id
1297 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
1298 and pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1299 and p_effective_date between
1300 pea.effective_start_date and pea.effective_end_date);
1301 --
1302 -- this procedure writes to the ben_prtt_enrt_ctfn_prvdd_f
1303 --
1304 l_proc varchar2(80);
1305 l_effective_start_date date;
1306 l_effective_end_date date;
1307 l_ctfn_exists varchar2(30):='N';
1308 --
1309 begin
1310 --
1311 if g_debug then
1312 l_proc := g_package||'.write_new_prtt_ctfn_prvdd_item';
1313 hr_utility.set_location ('Entering '||l_proc,10);
1314 end if;
1315 --
1316 -- write a new record for a participant certification item
1317 --
1318 -- if it does not already exist
1319 --
1320 open c_ctfn_exists;
1321 fetch c_ctfn_exists into l_ctfn_exists;
1322 close c_ctfn_exists;
1323 if l_ctfn_exists='N' then
1324 ben_prtt_enrt_ctfn_prvdd_api.create_prtt_enrt_ctfn_prvdd
1325 (p_enrt_ctfn_rqd_flag => p_rqd_flag
1326 ,p_enrt_ctfn_typ_cd => p_enrt_ctfn_typ_cd
1327 ,p_enrt_r_bnft_ctfn_cd => p_enrt_r_bnft_ctfn_cd
1328 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1329 ,p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
1330 ,p_effective_date => p_effective_date
1331 ,p_business_group_id => p_business_group_id
1332 ,p_object_version_number => p_object_version_number
1333 ,p_effective_start_date => l_effective_start_date
1334 ,p_effective_end_date => l_effective_end_date
1335 ,p_prtt_enrt_ctfn_prvdd_id => p_prtt_enrt_ctfn_prvdd_id
1336 );
1337 else
1338 hr_utility.set_location ('Already certification exists. No need to create new one', 10);
1339 end if;
1340 --
1341 if g_debug then
1342 hr_utility.set_location ('Leaving '||l_proc, 10);
1343 end if;
1344 --
1345 exception
1346 when others then
1347
1348 -- Init Variables for NOCOPY
1349 p_object_version_number := null ;
1350 p_prtt_enrt_ctfn_prvdd_id:= null;
1351
1352 if g_debug then
1353 hr_utility.set_location('Exception Raised '||l_proc, 10);
1354 end if;
1355 raise;
1356 --
1357 end write_new_prtt_ctfn_prvdd_item;
1358 --
1359 -- ----------------------------------------------------------------------------
1360 -- |---------------------------< set_cmpltd_dt >------------------------------|
1361 -- ----------------------------------------------------------------------------
1362 --
1363 procedure set_cmpltd_dt
1364 (p_prtt_enrt_actn_id in number
1365 ,p_prtt_enrt_rslt_id in number
1366 ,p_rslt_object_version_number in out nocopy number
1367 ,p_actn_typ_id in number
1368 ,p_rqd_flag in varchar2 default 'Y'
1369 ,p_effective_date in date
1370 ,p_post_rslt_flag in varchar2 default 'Y'
1371 ,p_business_group_id in number
1372 ,p_object_version_number in out nocopy number
1373 ,p_open_close in varchar2
1374 ,p_datetrack_mode in varchar2 default hr_api.g_correction) is
1375 --
1376 l_proc varchar2(80);
1377 l_datetrack_mode varchar2(30);
1378 -- bug 6010780
1379 l_datetrack_mode2 varchar2(30);
1380 l_cmpltd_dt date := NULL;
1381 l_effective_start_date date;
1382 l_effective_end_date date;
1383 l_rslt_object_version_number number ;
1384 l_object_version_number number ;
1385
1386 --
1387 -- the cursor is for datetrack mode verify
1388 --
1389 cursor c_start_date is
1390 select pea.effective_start_date
1391 from ben_prtt_enrt_actn_f pea
1392 where pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1393 and pea.business_group_id = p_business_group_id
1394 and p_effective_date between pea.effective_start_date
1395 and pea.effective_end_date;
1396 --
1397 cursor c_future_row is
1398 select object_version_number
1399 from ben_prtt_enrt_actn_f pea
1400 where pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1401 and pea.business_group_id = p_business_group_id
1402 and p_effective_date < pea.effective_start_date
1403 ;
1404 --
1405 --BUG 4558512 new cursors to determine the right completion date
1406 --
1407 cursor c_pcs(p_prtt_enrt_rslt_id number,p_prtt_enrt_actn_id number) is
1408 select max(pcs.enrt_ctfn_recd_dt) ctfn_recd_dt
1409 from ben_prtt_enrt_ctfn_prvdd_f pcs
1410 where pcs.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
1411 and pcs.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1412 and p_effective_date between
1413 pcs.effective_start_date and pcs.effective_end_date;
1414 --
1415 cursor c_ccp(p_prtt_enrt_actn_id number) is
1416 select max(ccp.dpnt_dsgn_ctfn_recd_dt) ctfn_recd_dt
1417 from ben_cvrd_dpnt_ctfn_prvdd_f ccp,
1418 ben_prtt_enrt_actn_f pea
1419 where ccp.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1420 and pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1421 and ccp.elig_cvrd_dpnt_id = pea.elig_cvrd_dpnt_id
1422 and p_effective_date between
1423 pea.effective_start_date and pea.effective_end_date
1424 and p_effective_date between
1425 ccp.effective_start_date and ccp.effective_end_date;
1426 --
1427 cursor c_pbc(p_prtt_enrt_actn_id number) is
1428 select max(pbc.bnf_ctfn_recd_dt) ctfn_recd_dt
1429 from ben_pl_bnf_ctfn_prvdd_f pbc,
1430 ben_prtt_enrt_actn_f pea
1431 where pbc.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1432 and pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1433 and pbc.pl_bnf_id = pea.pl_bnf_id
1434 and p_effective_date between
1435 pea.effective_start_date and pea.effective_end_date
1436 and p_effective_date between
1437 pbc.effective_start_date and pbc.effective_end_date;
1438 --
1439 l_object_version_number2 number;
1440 l_start_date c_start_date%rowtype;
1441 l_dummy_number number;
1442 l_prvdd_dt date := NULL;
1443
1444 --
1445 cursor c_curr_ovn_of_actn (c_prtt_enrt_actn_id number) is
1446 select object_version_number
1447 from ben_prtt_enrt_actn_f
1448 where prtt_enrt_actn_id = c_prtt_enrt_actn_id
1449 and business_group_id = p_business_group_id
1450 and p_effective_date between effective_start_date
1451 and effective_end_date;
1452
1453 curr_ovn ben_prtt_enrt_actn_f.object_version_number%TYPE;
1454 --
1455 --
1456 begin
1457 --
1458 if g_debug then
1459 l_proc := g_package||'.set_cmpltd_dt';
1460 hr_utility.set_location ('Entering '||l_proc,10);
1461 hr_utility.set_location('p_prtt_enrt_actn_id '||p_prtt_enrt_actn_id,119);
1462 hr_utility.set_location('p_prtt_enrt_rslt_id '||p_prtt_enrt_rslt_id,119);
1463 --
1464 end if;
1465 --
1466
1467 l_rslt_object_version_number := p_rslt_object_version_number ;
1468 l_object_version_number := p_object_version_number ;
1469
1470 -- Using table api update existing record for an action item
1471 -- setting the cmpltd_dt to effective_date
1472 --
1473 open c_start_date;
1474 fetch c_start_date into l_start_date;
1475 close c_start_date;
1476 --
1477 if p_open_close = 'OPEN' then
1478 l_cmpltd_dt := NULL;
1479 elsif p_open_close = 'CLOSE' then
1480 --
1481 if p_prtt_enrt_rslt_id is not null and
1482 p_prtt_enrt_actn_id is not null then
1483 --
1484 open c_pcs(p_prtt_enrt_rslt_id,p_prtt_enrt_actn_id);
1485 fetch c_pcs into l_prvdd_dt ;
1486 close c_pcs ;
1487 --
1488 end if;
1489 --
1490 l_cmpltd_dt := l_prvdd_dt ;
1491 --
1492 hr_utility.set_location('FIRST l_cmpltd_dt '||l_cmpltd_dt,119);
1493 --
1494 open c_ccp(p_prtt_enrt_actn_id);
1495 fetch c_ccp into l_prvdd_dt ;
1496 close c_ccp ;
1497 --
1498 if l_prvdd_dt > nvl(l_cmpltd_dt,l_prvdd_dt-1) then
1499 l_cmpltd_dt := l_prvdd_dt ;
1500 end if;
1501 --
1502 hr_utility.set_location('SECOND l_cmpltd_dt '||l_cmpltd_dt,119);
1503 --
1504 open c_pbc(p_prtt_enrt_actn_id);
1505 fetch c_pbc into l_prvdd_dt ;
1506 close c_pbc ;
1507 --
1508 if l_prvdd_dt > nvl(l_cmpltd_dt,l_prvdd_dt-1) then
1509 l_cmpltd_dt := l_prvdd_dt ;
1510 end if;
1511 --
1512 hr_utility.set_location(' p_effective_date '||p_effective_date,119);
1513 hr_utility.set_location(' l_cmpltd_dt '||l_cmpltd_dt,119);
1514 l_cmpltd_dt := nvl(l_cmpltd_dt,p_effective_date) ;
1515 --
1516 end if;
1517 --
1518 l_datetrack_mode := date_track_verify
1519 (p_dt_mode => p_datetrack_mode
1520 ,p_dflt_mode => DTMODE_CORRECT
1521 ,p_eff_date => p_effective_date
1522 ,p_start_date => l_start_date.effective_start_date);
1523 --
1524 -- if p_datetrack_mode = hr_api.g_future_change then -- bug 6010780
1525 --
1526 open c_future_row;
1527 fetch c_future_row into l_object_version_number2;
1528 close c_future_row;
1529 --
1530 -- end if;
1531 if l_object_version_number2 is not null
1532 and p_datetrack_mode = hr_api.g_future_change
1533 then -- future rows exists
1534 --
1535 ben_prtt_enrt_actn_api.delete_PRTT_ENRT_ACTN
1536 (
1537 p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
1538 ,p_business_group_id => p_business_group_id
1539 ,p_effective_date => p_effective_date
1540 ,p_datetrack_mode => p_datetrack_mode
1541 ,p_object_version_number => p_object_version_number
1542 ,p_unsuspend_enrt_flag => 'N'
1543 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1544 ,p_rslt_object_version_number => l_dummy_number
1545 ,p_effective_start_date => l_effective_start_date
1546 ,p_effective_end_date => l_effective_end_date
1547 );
1548 --
1549 else
1550 --
1551 -- bug 6010780
1552 if l_object_version_number2 is not null then
1553 l_datetrack_mode2 := 'FUTURE_CHANGE';
1554
1555 hr_utility.set_location(' Future change exists fo update or correction ', 121 );
1556 hr_utility.set_location(' p_object_version_number 1 ' || p_object_version_number , 121 );
1557
1558 ben_prtt_enrt_actn_api.delete_prtt_enrt_actn
1559 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id,
1560 p_business_group_id => p_business_group_id,
1561 p_effective_date => p_effective_date,
1562 p_datetrack_mode => l_datetrack_mode2,
1563 p_object_version_number => p_object_version_number,
1564 p_unsuspend_enrt_flag => 'N',
1565 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
1566 p_rslt_object_version_number => l_dummy_number,
1567 p_effective_start_date => l_effective_start_date,
1568 p_effective_end_date => l_effective_end_date
1569 );
1570 end if;
1571 hr_utility.set_location(' p_object_version_number 2 ' || p_object_version_number , 121 );
1572 open c_curr_ovn_of_actn(p_prtt_enrt_actn_id);
1573 fetch c_curr_ovn_of_actn into curr_ovn;
1574 close c_curr_ovn_of_actn;
1575 hr_utility.set_location('curr_ovn ' || curr_ovn , 121 );
1576 if curr_ovn is not null then
1577 ben_prtt_enrt_actn_api.update_prtt_enrt_actn
1578 (p_cmpltd_dt => l_cmpltd_dt
1579 ,p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
1580 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1581 ,p_rslt_object_version_number => p_rslt_object_version_number
1582 ,p_actn_typ_id => p_actn_typ_id
1583 ,p_rqd_flag => p_rqd_flag
1584 ,p_effective_date => p_effective_date
1585 ,p_post_rslt_flag => p_post_rslt_flag
1586 ,p_business_group_id => p_business_group_id
1587 ,p_effective_start_date => l_effective_start_date
1588 ,p_effective_end_date => l_effective_end_date
1589 -- ,p_object_version_number => p_object_version_number 6010780
1590 ,p_object_version_number => curr_ovn
1591 ,p_datetrack_mode => l_datetrack_mode
1592 );
1593 end if;
1594 end if;
1595 --
1596 if g_debug then
1597 hr_utility.set_location ('Leaving '||l_proc, 10);
1598 end if;
1599 --
1600 exception
1601 when others then
1602
1603 if g_debug then
1604 hr_utility.set_location('Exception Raised '||l_proc, 10);
1605 end if;
1606 -- Init Variables for NOCOPY
1607 p_rslt_object_version_number := l_rslt_object_version_number ;
1608 p_object_version_number := l_object_version_number ;
1609
1610 raise;
1611 --
1612 end set_cmpltd_dt;
1613 --
1614 -- ----------------------------------------------------------------------------
1615 -- |---------------------< complete_this_action_item >-----------------------|
1616 -- ----------------------------------------------------------------------------
1617 --
1618 procedure complete_this_action_item
1619 (p_prtt_enrt_actn_id in number
1620 ,p_effective_date in date
1621 ,p_validate in boolean default false
1622 ,p_datetrack_mode in varchar2 default hr_api.g_correction
1623 ,p_post_rslt_flag in varchar2 default 'Y') is
1624 --
1625 -- this procedure will set the completed date for a single open action item
1626 -- for a participant result both dependent and beneficiary
1627 --
1628 l_proc varchar2(80);
1629 --
1630 cursor c_actn_this is
1631 select pea.prtt_enrt_rslt_id,
1632 pea.actn_typ_id,
1633 pea.object_version_number,
1634 pea.business_group_id,
1635 pea.effective_start_date,
1636 pea.effective_end_date,
1637 pen.object_version_number rslt_object_version_number
1638 from ben_prtt_enrt_actn_f pea,
1639 ben_prtt_enrt_rslt_f pen
1640 where pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1641 and pea.cmpltd_dt IS NULL
1642 and pen.prtt_enrt_rslt_stat_cd is null
1643 and p_effective_date between pea.effective_start_date
1644 and pea.effective_end_date
1645 and pea.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
1646 and p_effective_date between pen.effective_start_date
1647 and pen.effective_end_date
1648 ;
1649 --
1650 begin
1651 --
1652 g_debug := hr_utility.debug_enabled;
1653 if g_debug then
1654 l_proc := g_package||'.complete_this_action_item';
1655 hr_utility.set_location ('Entering '||l_proc,10);
1656 end if;
1657 --
1658 -- Using table api update the record for an action item
1659 --
1660 for l_actn_this in c_actn_this loop
1661 --
1662 set_cmpltd_dt
1663 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
1664 ,p_prtt_enrt_rslt_id => l_actn_this.prtt_enrt_rslt_id
1665 ,p_rslt_object_version_number => l_actn_this.rslt_object_version_number
1666 ,p_actn_typ_id => l_actn_this.actn_typ_id
1667 ,p_effective_date => p_effective_date
1668 ,p_post_rslt_flag => p_post_rslt_flag
1669 ,p_business_group_id => l_actn_this.business_group_id
1670 ,p_object_version_number => l_actn_this.object_version_number
1671 ,p_open_close => 'CLOSE'
1672 ,p_datetrack_mode => p_datetrack_mode);
1673 --
1674 end loop;
1675 --
1676 if g_debug then
1677 hr_utility.set_location ('Leaving '||l_proc, 10);
1678 end if;
1679 --
1680 exception
1681 when others then
1682 if g_debug then
1683 hr_utility.set_location('Exception Raised '||l_proc, 10);
1684 end if;
1685 raise;
1686 --
1687 end complete_this_action_item;
1688 --
1689 -- ----------------------------------------------------------------------------
1690 -- |------------------------< delete_prtt_ctfn_prvdd >------------------------|
1691 -- ----------------------------------------------------------------------------
1692 --
1693 procedure delete_prtt_ctfn_prvdd
1694 (p_prtt_enrt_ctfn_prvdd_id in number
1695 ,p_object_version_number in out nocopy number
1696 ,p_effective_date in date
1697 ,p_datetrack_mode in varchar2 default DTMODE_DELETE) is
1698 --
1699 -- for participant certifications
1700 -- this procedure datetrack deletes the ben_prtt_enrt_ctfn_prvdd_f
1701 --
1702 l_proc varchar2(80);
1703 l_effective_start_date date;
1704 l_effective_end_date date;
1705 l_object_version_number number(15);
1706
1707 --
1708 begin
1709 --
1710 if g_debug then
1711 l_proc := g_package||'.delete_prtt_ctfn_prvdd';
1712 hr_utility.set_location ('Entering '||l_proc,10);
1713 end if;
1714 --
1715 l_object_version_number := p_object_version_number ;
1716
1717 -- date track delete the record for a participant certification item
1718 --
1719 ben_prtt_enrt_ctfn_prvdd_api.delete_prtt_enrt_ctfn_prvdd
1720 (p_prtt_enrt_ctfn_prvdd_id => p_prtt_enrt_ctfn_prvdd_id
1721 ,p_effective_start_date => l_effective_start_date
1722 ,p_effective_end_date => l_effective_end_date
1723 ,p_object_version_number => p_object_version_number
1724 ,p_effective_date => p_effective_date
1725 ,p_datetrack_mode => p_datetrack_mode);
1726 --
1727 if g_debug then
1728 hr_utility.set_location ('Leaving '||l_proc, 10);
1729 end if;
1730 --
1731 exception
1732 when others then
1733
1734 if g_debug then
1735 hr_utility.set_location('Exception Raised '||l_proc, 10);
1736 end if;
1737 p_object_version_number := l_object_version_number ;
1738
1739 raise;
1740 --
1741 end delete_prtt_ctfn_prvdd;
1742 --
1743 -- ----------------------------------------------------------------------------
1744 -- |-----------------------< delete_dpnt_ctfn_prvdd >-------------------------|
1745 -- ----------------------------------------------------------------------------
1746 --
1747 procedure delete_dpnt_ctfn_prvdd
1748 (p_cvrd_dpnt_ctfn_prvdd_id in number
1749 ,p_object_version_number in out nocopy number
1750 ,p_effective_date in date
1751 ,p_business_group_id in number
1752 ,p_datetrack_mode in varchar2 default DTMODE_DELETE) is
1753 --
1754 -- for a dependent certification for a participant
1755 -- datetrack_mode delete
1756 --
1757 l_proc varchar2(80);
1758 l_effective_start_date date;
1759 l_effective_end_date date;
1760 l_object_version_number number(15);
1761
1762 --
1763 begin
1764 --
1765 if g_debug then
1766 l_proc := g_package||'.delete_dpnt_ctfn_prvdd';
1767 hr_utility.set_location ('Entering '||l_proc,10);
1768 end if;
1769 --
1770 l_object_version_number := p_object_version_number ;
1771
1772 -- date track delete the record for a dependent certification item
1773 --
1774 ben_cvrd_dpnt_ctfn_prvdd_api.delete_cvrd_dpnt_ctfn_prvdd
1775 (p_cvrd_dpnt_ctfn_prvdd_id => p_cvrd_dpnt_ctfn_prvdd_id
1776 ,p_effective_start_date => l_effective_start_date
1777 ,p_effective_end_date => l_effective_end_date
1778 ,p_object_version_number => p_object_version_number
1779 ,p_effective_date => p_effective_date
1780 ,p_business_group_id => p_business_group_id
1781 ,p_datetrack_mode => p_datetrack_mode
1782 ,p_called_from => 'benactcm' );
1783 --
1784 if g_debug then
1785 hr_utility.set_location ('Leaving '||l_proc, 10);
1786 end if;
1787 --
1788 exception
1789 when others then
1790 if g_debug then
1791 hr_utility.set_location('Exception Raised '||l_proc, 10);
1792 end if;
1793 p_object_version_number := l_object_version_number ;
1794 raise;
1795 --
1796 end delete_dpnt_ctfn_prvdd;
1797 --
1798 -- ----------------------------------------------------------------------------
1799 -- |----------------------< remove_prtt_certifications >----------------------|
1800 -- ----------------------------------------------------------------------------
1801 --
1802 procedure remove_prtt_certifications
1803 (p_prtt_enrt_rslt_id in number
1804 ,p_effective_date in date
1805 ,p_business_group_id in number
1806 ,p_datetrack_mode in varchar2 default DTMODE_DELETE) is
1807 --
1808 -- this procedure removes participant certifications from
1809 -- ben_prtt_enrt_ctfn_prvdd_f. This is datetrack_mode controlled
1810 --
1811 l_proc varchar2(80);
1812 -- CFW2
1813 cursor c_prtt_ctfn_prvdd is
1814 select pcs.prtt_enrt_ctfn_prvdd_id,
1815 pcs.object_version_number
1816 from ben_prtt_enrt_ctfn_prvdd_f pcs,
1817 ben_prtt_enrt_actn_f pea,
1818 ben_per_in_ler pil
1819 where pcs.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
1820 and pcs.enrt_ctfn_recd_dt is NULL
1821 and pcs.business_group_id = p_business_group_id
1822 and p_effective_date between pcs.effective_start_date
1823 and pcs.effective_end_date
1824 and pea.prtt_enrt_actn_id=pcs.prtt_enrt_actn_id
1825 and pea.pl_bnf_id is null
1826 and pea.elig_cvrd_dpnt_id is null
1827 and pea.per_in_ler_id = pil.per_in_ler_id
1828 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
1829 and pea.business_group_id=p_business_group_id
1830 and p_effective_date between pea.effective_start_date
1831 and pea.effective_end_date
1832 ;
1833 --
1834 begin
1835 --
1836 if g_debug then
1837 l_proc := g_package||'.remove_prtt_certifications';
1838 hr_utility.set_location ('Entering '||l_proc,10);
1839 end if;
1840 --
1841 -- Using table api write a new record for an action item
1842 --
1843 for l_prtt_ctfn_prvdd in c_prtt_ctfn_prvdd loop
1844 --
1845 delete_prtt_ctfn_prvdd
1846 (p_prtt_enrt_ctfn_prvdd_id => l_prtt_ctfn_prvdd.prtt_enrt_ctfn_prvdd_id
1847 ,p_object_version_number => l_prtt_ctfn_prvdd.object_version_number
1848 ,p_effective_date => p_effective_date
1849 ,p_datetrack_mode => p_datetrack_mode);
1850 --
1851 end loop;
1852 --
1853 if g_debug then
1854 hr_utility.set_location ('Leaving '||l_proc, 10);
1855 end if;
1856 --
1857 exception
1858 when others then
1859 if g_debug then
1860 hr_utility.set_location('Exception Raised '||l_proc, 10);
1861 end if;
1862 raise;
1863 --
1864 end remove_prtt_certifications;
1865 --
1866 -- ----------------------------------------------------------------------------
1867 -- |----------------------< remove_dpnt_certifications >----------------------|
1868 -- ----------------------------------------------------------------------------
1869 --
1870 procedure remove_dpnt_certifications
1871 (p_prtt_enrt_rslt_id in number
1872 ,p_effective_date in date
1873 ,p_business_group_id in number
1874 ,p_datetrack_mode in varchar2 default DTMODE_DELETE
1875 ,p_effective_start_date out nocopy date
1876 ,p_effective_end_date out nocopy date) is
1877 --
1878 -- this procedure removes certifications for dependents of a participant
1879 -- if cvrd_flag = Y and dpnt_dsgn_ctfn_recd_dt is NULL
1880 -- this is datetrack_mode controlled
1881 --
1882 l_proc varchar2(80);
1883
1884 --
1885 cursor c_dpnt_ctfn_prvdd is
1886 select prv.cvrd_dpnt_ctfn_prvdd_id,
1887 prv.object_version_number
1888 from ben_elig_cvrd_dpnt_f ecd, ben_cvrd_dpnt_ctfn_prvdd_f prv,
1889 ben_per_in_ler pil
1890 where ecd.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
1891 and ecd.cvg_strt_dt is not null
1892 and nvl(ecd.cvg_thru_dt, hr_api.g_eot) = hr_api.g_eot
1893 and ecd.elig_cvrd_dpnt_id = prv.elig_cvrd_dpnt_id
1894 and prv.dpnt_dsgn_ctfn_recd_dt is NULL
1895 and ecd.business_group_id = p_business_group_id
1896 and p_effective_date between ecd.effective_start_date
1897 and ecd.effective_end_date
1898 and prv.business_group_id = p_business_group_id
1899 and p_effective_date between prv.effective_start_date
1900 and prv.effective_end_date
1901 and pil.per_in_ler_id=ecd.per_in_ler_id
1902 and pil.business_group_id=p_business_group_id
1903 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
1904 --
1905 begin
1906 --
1907 if g_debug then
1908 l_proc := g_package||'.remove_dpnt_certifications';
1909 hr_utility.set_location ('Entering '||l_proc,10);
1910 end if;
1911 --
1912 for l_dpnt_ctfn_prvdd in c_dpnt_ctfn_prvdd loop
1913 --
1914 delete_dpnt_ctfn_prvdd
1915 (p_cvrd_dpnt_ctfn_prvdd_id => l_dpnt_ctfn_prvdd.cvrd_dpnt_ctfn_prvdd_id
1916 ,p_object_version_number => l_dpnt_ctfn_prvdd.object_version_number
1917 ,p_effective_date => p_effective_date
1918 ,p_business_group_id => p_business_group_id
1919 ,p_datetrack_mode => p_datetrack_mode);
1920 --
1921 end loop;
1922 --
1923 if g_debug then
1924 hr_utility.set_location ('Leaving '||l_proc, 10);
1925 end if;
1926 --
1927 exception
1928 when others then
1929 p_effective_start_date := null;
1930 p_effective_end_date := null;
1931
1932 if g_debug then
1933 hr_utility.set_location('Exception Raised '||l_proc, 10);
1934 end if;
1935 raise;
1936 --
1937 end remove_dpnt_certifications;
1938 --
1939 -- ----------------------------------------------------------------------------
1940 -- |-------------------------< delete_action_item >---------------------------|
1941 -- ----------------------------------------------------------------------------
1942 --
1943 procedure delete_action_item
1944 (p_prtt_enrt_actn_id in number
1945 ,p_object_version_number in out nocopy number
1946 ,p_business_group_id in number
1947 ,p_effective_date in date
1948 ,p_datetrack_mode in varchar2 default DTMODE_DELETE
1949 ,p_prtt_enrt_rslt_id in number
1950 ,p_rslt_object_version_number in out nocopy number
1951 ,p_post_rslt_flag in varchar2) is
1952 --
1953 l_proc varchar2(80);
1954 l_effective_start_date date;
1955 l_effective_end_date date;
1956 l_object_version_number number(15);
1957 l_rslt_object_version_number number(15);
1958
1959 --
1960 begin
1961 --
1962 if g_debug then
1963 l_proc := g_package||'.delete_action_item';
1964 hr_utility.set_location ('Entering '||l_proc,10);
1965 end if;
1966 if g_debug then
1967 hr_utility.set_location(p_datetrack_mode || ' ' || l_proc, 10);
1968 end if;
1969 --
1970 l_object_version_number := p_object_version_number;
1971 l_rslt_object_version_number := p_rslt_object_version_number ;
1972
1973 -- Using table api datetrack delete the record for an action item
1974 --
1975 ben_prtt_enrt_actn_api.delete_prtt_enrt_actn
1976 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
1977 ,p_business_group_id => p_business_group_id
1978 ,p_effective_date => p_effective_date
1979 ,p_datetrack_mode => p_datetrack_mode
1980 ,p_object_version_number => p_object_version_number
1981 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1982 ,p_rslt_object_version_number => p_rslt_object_version_number
1983 ,p_post_rslt_flag => p_post_rslt_flag
1984 ,p_effective_start_date => l_effective_start_date
1985 ,p_effective_end_date => l_effective_end_date);
1986 --
1987 if g_debug then
1988 hr_utility.set_location ('Leaving '||l_proc, 10);
1989 end if;
1990 --
1991 exception
1992 when others then
1993 if g_debug then
1994 hr_utility.set_location('Exception Raised '||l_proc, 10);
1995 end if;
1996 p_object_version_number := l_object_version_number ;
1997 p_rslt_object_version_number := l_rslt_object_version_number ;
1998 raise;
1999 --
2000 end delete_action_item;
2001 --
2002 --
2003 procedure get_ctfn_count
2004 (p_prtt_enrt_actn_id in number,
2005 p_prtt_enrt_rslt_id in number default null,
2006 p_elig_cvrd_dpnt_id in number default null,
2007 p_pl_bnf_id in number default null,
2008 p_effective_date in date,
2009 p_optional_count out nocopy number,
2010 p_required_count out nocopy number,
2011 p_open_optional_count out nocopy number,
2012 p_open_required_count out nocopy number) is
2013 --
2014 cursor c_pcs is
2015 select sum(1) tot_ctfn,
2016 sum(decode(pcs.enrt_ctfn_rqd_flag,'Y',1,0)) tot_rqd,
2017 sum(decode(pcs.enrt_ctfn_recd_dt,null,1,0)) tot_open_ctfn,
2018 sum(decode(pcs.enrt_ctfn_rqd_flag,'N',0,
2019 decode(pcs.enrt_ctfn_recd_dt,null,1,0))) tot_open_rqd
2020 from ben_prtt_enrt_ctfn_prvdd_f pcs
2021 where pcs.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
2022 and pcs.prtt_enrt_actn_id = p_prtt_enrt_actn_id
2023 and p_effective_date between
2024 pcs.effective_start_date and pcs.effective_end_date;
2025 --
2026 cursor c_ccp is
2027 select sum(1) tot_ctfn,
2028 sum(decode(ccp.dpnt_dsgn_ctfn_rqd_flag,'Y',1,0)) tot_rqd,
2029 sum(decode(ccp.dpnt_dsgn_ctfn_recd_dt,null,1,0)) tot_open_ctfn,
2030 sum(decode(ccp.dpnt_dsgn_ctfn_rqd_flag,'N',0,
2031 decode(ccp.dpnt_dsgn_ctfn_recd_dt,null,1,0))) tot_open_rqd
2032 from ben_cvrd_dpnt_ctfn_prvdd_f ccp
2033 where ccp.prtt_enrt_actn_id = p_prtt_enrt_actn_id
2034 and ccp.elig_cvrd_dpnt_id = p_elig_cvrd_dpnt_id
2035 and p_effective_date between
2036 ccp.effective_start_date and ccp.effective_end_date;
2037 --
2038 cursor c_pbc is
2039 select sum(1) tot_ctfn,
2040 sum(decode(pbc.bnf_ctfn_rqd_flag,'Y',1,0)) tot_rqd,
2041 sum(decode(pbc.bnf_ctfn_recd_dt,null,1,0)) tot_open_ctfn,
2042 sum(decode(pbc.bnf_ctfn_rqd_flag,'N',0,
2043 decode(pbc.bnf_ctfn_recd_dt,null,1,0))) tot_open_rqd
2044 from ben_pl_bnf_ctfn_prvdd_f pbc
2045 where pbc.prtt_enrt_actn_id = p_prtt_enrt_actn_id
2046 and pbc.pl_bnf_id = p_pl_bnf_id
2047 and p_effective_date between
2048 pbc.effective_start_date and pbc.effective_end_date;
2049 --
2050 l_ctfn c_pbc%rowtype;
2051 --
2052 l_proc varchar2(80) ;
2053 --
2054 begin
2055 --
2056 if g_debug then
2057 l_proc := g_package || '.get_ctfn_count';
2058 hr_utility.set_location ('Entering '||l_proc,10);
2059 end if;
2060 --
2061 p_optional_count := 0;
2062 p_required_count := 0;
2063 p_open_required_count := 0;
2064 p_open_optional_count := 0;
2065 --
2066 if p_prtt_enrt_actn_id is null then
2067 if g_debug then
2068 hr_utility.set_location ('Leaving '||l_proc,97);
2069 end if;
2070 return;
2071 end if;
2072 --
2073 if p_elig_cvrd_dpnt_id is not null then
2074 --
2075 open c_ccp;
2076 fetch c_ccp into l_ctfn;
2077 close c_ccp;
2078 --
2079 elsif p_pl_bnf_id is not null then
2080 --
2081 open c_pbc;
2082 fetch c_pbc into l_ctfn;
2083 close c_pbc;
2084 --
2085 elsif p_prtt_enrt_rslt_id is not null then
2086 --
2087 open c_pcs;
2088 fetch c_pcs into l_ctfn;
2089 close c_pcs;
2090 --
2091 else
2092 if g_debug then
2093 hr_utility.set_location ('Leaving '||l_proc,98);
2094 end if;
2095 return;
2096 --
2097 end if;
2098 --
2099 p_required_count := l_ctfn.tot_rqd +0;
2100 p_optional_count := l_ctfn.tot_ctfn - l_ctfn.tot_rqd + 0;
2101 p_open_required_count := l_ctfn.tot_open_rqd + 0;
2102 p_open_optional_count := l_ctfn.tot_open_ctfn - p_open_required_count +0;
2103
2104 hr_utility.set_location ('l_ctfn.tot_rqd '|| l_ctfn.tot_rqd,10);
2105 hr_utility.set_location ('l_ctfn.tot_ctfn '|| l_ctfn.tot_ctfn,10);
2106 hr_utility.set_location ('l_ctfn.tot_open_rqd '|| l_ctfn.tot_open_rqd,10);
2107 hr_utility.set_location ('l_ctfn.tot_open_ctfn '|| l_ctfn.tot_open_ctfn,10);
2108 hr_utility.set_location ('p_open_required_count '|| p_open_required_count,10);
2109
2110 --
2111 if g_debug then
2112 hr_utility.set_location ('Leaving '||l_proc,99);
2113 end if;
2114 --
2115 end get_ctfn_count;
2116 --
2117 --
2118 -- ----------------------------------------------------------------------------
2119 -- |-------------------------< process_action_item >--------------------------|
2120 -- ----------------------------------------------------------------------------
2121 --
2122 procedure process_action_item
2123 (p_prtt_enrt_actn_id in out nocopy number
2124 ,p_actn_typ_id in number
2125 ,p_cmpltd_dt in date
2126 ,p_object_version_number in out nocopy number
2127 ,p_effective_date in date
2128 ,p_rqd_data_found in boolean
2129 ,p_prtt_enrt_rslt_id in number
2130 ,p_elig_cvrd_dpnt_id in number default null
2131 ,p_pl_bnf_id in number default null
2132 ,p_rqd_flag in varchar2 default 'Y'
2133 ,p_post_rslt_flag in varchar2 default 'Y'
2134 ,p_business_group_id in number
2135 ,p_datetrack_mode in varchar2
2136 ,p_rslt_object_version_number in out nocopy number) is
2137 --
2138 l_proc varchar2(80);
2139
2140 l_prtt_enrt_actn_id number(15);
2141 l_object_version_number number(15);
2142 l_rslt_object_version_number number(15);
2143
2144
2145 --
2146 begin
2147 --
2148 g_debug := hr_utility.debug_enabled;
2149 if g_debug then
2150 l_proc := g_package||'.process_action_item';
2151 hr_utility.set_location ('Entering '||l_proc,10);
2152 end if;
2153 --
2154 l_prtt_enrt_actn_id := p_prtt_enrt_actn_id ;
2155 l_object_version_number := p_object_version_number ;
2156 l_rslt_object_version_number := p_rslt_object_version_number;
2157
2158 --
2159 if (p_prtt_enrt_actn_id IS NULL and p_rqd_data_found = FALSE) then
2160 --
2161 -- An action item does not exist and required data is not found. Write a
2162 -- new action item
2163 --
2164 write_new_action_item
2165 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
2166 ,p_rslt_object_version_number => p_rslt_object_version_number
2167 ,p_actn_typ_id => p_actn_typ_id
2168 ,p_effective_date => p_effective_date
2169 ,p_post_rslt_flag => p_post_rslt_flag
2170 ,p_business_group_id => p_business_group_id
2171 ,p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id
2172 ,p_pl_bnf_id => p_pl_bnf_id
2173 ,p_rqd_flag => p_rqd_flag
2174 ,p_cmpltd_dt => p_cmpltd_dt
2175 ,p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
2176 ,p_object_version_number => p_object_version_number);
2177 --
2178 elsif p_prtt_enrt_actn_id IS NOT NULL and
2179 p_rqd_data_found = TRUE and
2180 p_cmpltd_dt IS NULL then
2181 --
2182 -- Existing open action item but we now have required data. Close the open
2183 -- action item by setting cmpltd_dt field
2184 --
2185 set_cmpltd_dt
2186 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
2187 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
2188 ,p_rslt_object_version_number => p_rslt_object_version_number
2189 ,p_actn_typ_id => p_actn_typ_id
2190 ,p_rqd_flag => p_rqd_flag
2191 ,p_effective_date => p_effective_date
2192 ,p_post_rslt_flag => p_post_rslt_flag
2193 ,p_business_group_id => p_business_group_id
2194 ,p_object_version_number => p_object_version_number
2195 ,p_open_close => 'CLOSE'
2196 ,p_datetrack_mode => p_datetrack_mode);
2197 --
2198 elsif p_prtt_enrt_actn_id IS NOT NULL and
2199 p_rqd_data_found = FALSE and
2200 p_cmpltd_dt IS NOT NULL then
2201 --
2202 -- Found a closed action item. But required data is missing. Reopen item
2203 --
2204 set_cmpltd_dt
2205 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
2206 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
2207 ,p_rslt_object_version_number => p_rslt_object_version_number
2208 ,p_actn_typ_id => p_actn_typ_id
2209 ,p_rqd_flag => p_rqd_flag
2210 ,p_effective_date => p_effective_date
2211 ,p_post_rslt_flag => p_post_rslt_flag
2212 ,p_business_group_id => p_business_group_id
2213 ,p_object_version_number => p_object_version_number
2214 ,p_open_close => 'OPEN'
2215 ,p_datetrack_mode => p_datetrack_mode);
2216 --
2217 else
2218 -- p_prtt_enrt_actn_id IS NOT NULL and p_rqd_data_found = FALSE
2219 -- and p_cmpltd_dt is null
2220 -- i.e. existing action still no information and not completed.
2221 -- p_prtt_enrt_actn_id IS NOT NULL and p_rqd_data_found=TRUE
2222 -- and p_cmpltd_dt is not null.
2223 -- i.e. action action had already been completed with all information.
2224 -- p_prtt_enrt_actn_id IS NULL and p_rqd_data_found = TRUE
2225 -- i.e. have always had information
2226 NULL;
2227 end if;
2228 --
2229 if g_debug then
2230 hr_utility.set_location ('Leaving '||l_proc, 10);
2231 end if;
2232 --
2233 exception
2234 when others then
2235
2236 if g_debug then
2237 hr_utility.set_location('Exception Raised '||l_proc, 10);
2238 end if;
2239
2240 p_prtt_enrt_actn_id := l_prtt_enrt_actn_id ;
2241 p_object_version_number := l_object_version_number ;
2242 p_rslt_object_version_number := l_rslt_object_version_number ;
2243
2244 raise;
2245 --
2246 end process_action_item;
2247 --
2248 procedure process_new_ctfn_action(
2249 p_prtt_enrt_rslt_id in number,
2250 p_elig_cvrd_dpnt_id in number default null,
2251 p_pl_bnf_id in number default null,
2252 p_actn_typ_cd in varchar2,
2253 p_ctfn_rqd_flag in varchar2,
2254 p_ctfn_recd_dt in date default null,
2255 p_business_group_id in number,
2256 p_effective_date in date,
2257 p_prtt_enrt_actn_id out nocopy number) is
2258 --
2259 l_proc varchar2(80);
2260 --
2261 l_actn_typ_id number := null;
2262 l_cmpltd_dt date := null;
2263 l_data_found boolean := false;
2264 l_object_version_number number := null;
2265 l_rslt_object_version_number number := null;
2266 l_optional number;
2267 l_required number;
2268 l_open_optional number;
2269 l_open_required number;
2270 --
2271 --Bug 6353069
2272 cursor c_pen is
2273 select pen.pgm_id,
2274 pen.ptip_id,
2275 pen.pl_id,
2276 pen.pl_typ_id,
2277 pen.oipl_id,
2278 pen.ler_id,
2279 pen.person_id,
2280 pen.object_version_number
2281 from ben_prtt_enrt_rslt_f pen
2282 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
2283 and pen.business_group_id = p_business_group_id
2284 and pen.prtt_enrt_rslt_stat_cd is null
2285 and p_effective_date between
2286 pen.effective_start_date and pen.effective_end_date;
2287
2288 l_rslt c_pen%rowtype;
2289
2290 -- Cursor to retrieve the dependent designation level
2291 --
2292 cursor c_dpnt_lvl_cd (p_pgm_id number) is
2293 select pgm.dpnt_dsgn_lvl_cd
2294 from ben_pgm_f pgm
2295 where pgm.pgm_id = p_pgm_id
2296 and pgm.business_group_id = p_business_group_id
2297 and p_effective_date between
2298 pgm.effective_start_date and pgm.effective_end_date;
2299 --
2300 -- Cursor to retrieve dependant required flags at the pgm level
2301 --
2302 cursor c_dpnt_pgm (p_pgm_id number) is
2303 select pgm.susp_if_ctfn_not_dpnt_flag
2304 from ben_pgm_f pgm
2305 where pgm.pgm_id = p_pgm_id
2306 and pgm.business_group_id = p_business_group_id
2307 and p_effective_date between
2308 pgm.effective_start_date and pgm.effective_end_date;
2309 --
2310 l_dpnt c_dpnt_pgm%rowtype;
2311 --
2312 -- cursor to retrieve dpnts' required-info-flags at the ptip level
2313 --
2314 cursor c_dpnt_ptip (p_ptip_id number) is
2315 select ptip.susp_if_ctfn_not_dpnt_flag
2316 from ben_ptip_f ptip
2317 where ptip.ptip_id = p_ptip_id
2318 and ptip.business_group_id = p_business_group_id
2319 and p_effective_date between
2320 ptip.effective_start_date and ptip.effective_end_date;
2321 --
2322 -- Cursor to retrieve dpnt required flags at the plan level
2323 --
2324 cursor c_dpnt_pl (p_pl_id number) is
2325 select pl.susp_if_ctfn_not_dpnt_flag
2326 from ben_pl_f pl
2327 where pl.pl_id = p_pl_id
2328 and pl.business_group_id = p_business_group_id
2329 and p_effective_date between
2330 pl.effective_start_date and pl.effective_end_date;
2331 --
2332 -- Cursor to retrieve Suspend Enrollment Flag at the various levels
2333 --
2334 cursor c_ldc (p_lvl_cd varchar) is
2335 select ldc.susp_if_ctfn_not_prvd_flag
2336 from BEN_LER_CHG_DPNT_CVG_f ldc,
2337 ben_prtt_enrt_rslt_f pen
2338 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
2339 and pen.business_group_id = p_business_group_id
2340 and p_effective_date between pen.effective_start_date
2341 and pen.effective_end_date
2342 and pen.ler_id = ldc.ler_id
2343 and pen.prtt_enrt_rslt_stat_cd is null
2344 and p_effective_date between ldc.effective_start_date
2345 and ldc.effective_end_date
2346 and ((p_lvl_cd = 'PTIP' and ldc.ptip_id = pen.ptip_id) OR
2347 (p_lvl_cd = 'PL' and ldc.pl_id = pen.pl_id) OR
2348 (p_lvl_cd = 'PGM' and ldc.pgm_id = pen.pgm_id));
2349
2350
2351 l_ler_susp_if_ctfn_not_prvd varchar2(30);
2352 l_rqd_flag varchar2(30) := 'Y';
2353 l_lvl_cd ben_pgm_f.dpnt_dsgn_lvl_cd%type;
2354
2355 --End Bug 6353069
2356
2357
2358 --
2359 begin
2360 --
2361 g_debug := hr_utility.debug_enabled;
2362 if g_debug then
2363 l_proc := g_package||'.process_ctfn_action_item';
2364 hr_utility.set_location ('Entering '||l_proc, 10);
2365 end if;
2366 --
2367 p_prtt_enrt_actn_id := null;
2368 --
2369 l_actn_typ_id := get_actn_typ_id
2370 (p_type_cd => p_actn_typ_cd,
2371 p_business_group_id => p_business_group_id);
2372 --
2373 get_prtt_enrt_actn_id
2374 (p_actn_typ_id => l_actn_typ_id,
2375 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
2376 p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id,
2377 p_pl_bnf_id => p_pl_bnf_id,
2378 p_effective_date => p_effective_date,
2379 p_business_group_id => p_business_group_id,
2380 p_prtt_enrt_actn_id => p_prtt_enrt_actn_id,
2381 p_cmpltd_dt => l_cmpltd_dt,
2382 p_object_version_number => l_object_version_number);
2383 --
2384 if p_ctfn_rqd_flag = 'Y' and p_ctfn_recd_dt is null then
2385 --
2386 -- Case 1: Required open ctfn
2387 -- We require a open action item for this open required ctfn.
2388 --
2389 l_data_found := false;
2390 --
2391 elsif p_ctfn_rqd_flag = 'Y' and p_ctfn_recd_dt is not null then
2392 --
2393 -- Case 2: Required Closed Ctfn.
2394 --
2395 if p_prtt_enrt_actn_id is not null then
2396 --
2397 -- The ctfn we are inserting is required but also closed, so
2398 -- we just require the action item id to write the ctfn.
2399 -- Action item found, do not do anything with action items.
2400 --
2401 return;
2402 --
2403 else
2404 --
2405 -- No action item found, so we need to create a closed
2406 -- action item.
2407 --
2408 l_data_found := false;
2409 l_cmpltd_dt := p_effective_date;
2410 --
2411 end if;
2412 --
2413 elsif p_ctfn_rqd_flag = 'N' and p_ctfn_recd_dt is null then
2414 --
2415 -- Case 3: Optional Open Ctfn.
2416 --
2417 hr_utility.set_location ('p_ctfn_rqd_flag '|| p_ctfn_rqd_flag,10);
2418 hr_utility.set_location ('p_ctfn_recd_dt '|| p_ctfn_recd_dt,10);
2419
2420 get_ctfn_count
2421 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
2422 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
2423 ,p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id
2424 ,p_pl_bnf_id => p_pl_bnf_id
2425 ,p_effective_date => p_effective_date
2426 ,p_required_count => l_required
2427 ,p_optional_count => l_optional
2428 ,p_open_required_count => l_open_required
2429 ,p_open_optional_count => l_open_optional);
2430 --
2431 if l_optional > 0 then
2432 --
2433 -- Optional Ctfn already exists. It means the action item would
2434 -- have been already created. Creation of new Optional Open Ctfn
2435 -- does not change anything, so just return.
2436 --
2437 return;
2438 --
2439 else
2440 --
2441 -- No optional ctfn. exists. So we need to have a open action item.
2442 --
2443 l_data_found := false;
2444 --
2445 end if;
2446 --
2447 elsif p_ctfn_rqd_flag = 'N' and p_ctfn_recd_dt is not null then
2448 --
2449 -- Case 4: Optional Closed Ctfn.
2450 --
2451 hr_utility.set_location ('p_ctfn_rqd_flag '|| p_ctfn_rqd_flag,11);
2452 hr_utility.set_location ('p_ctfn_recd_dt '|| p_ctfn_recd_dt,11);
2453
2454 get_ctfn_count
2455 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
2456 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
2457 ,p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id
2458 ,p_pl_bnf_id => p_pl_bnf_id
2459 ,p_effective_date => p_effective_date
2460 ,p_required_count => l_required
2461 ,p_optional_count => l_optional
2462 ,p_open_required_count => l_open_required
2463 ,p_open_optional_count => l_open_optional);
2464 --
2465 if l_optional > 0 and
2466 l_open_optional = l_optional and
2467 l_open_required = 0 then
2468 --
2469 -- All required Ctfn closed and optional ctfn exists and none of
2470 -- the optional ctfn is closed. It means that the new optional closed
2471 -- ctfn. which we are inserting, should close the action item.
2472 --
2473 l_data_found := true;
2474 --
2475 elsif p_prtt_enrt_actn_id is null then
2476 --
2477 -- No action item exists, so we need to create a closed action item.
2478 --
2479 l_data_found := false;
2480 l_cmpltd_dt := p_effective_date;
2481 --
2482 else
2483 --
2484 -- The state of action item remains the same in all other cases,
2485 -- so just return
2486 --
2487 return;
2488 --
2489 end if;
2490 --
2491 else
2492 --
2493 -- Invalid Case.
2494 --
2495 return;
2496 --
2497 end if;
2498 --
2499
2500 --Bug 6353069
2501 OPEN c_pen;
2502 FETCH c_pen INTO l_rslt;
2503 CLOSE c_pen;
2504
2505 IF (p_prtt_enrt_actn_id IS NULL AND l_data_found = FALSE AND p_elig_cvrd_dpnt_id is not NULL)
2506 THEN
2507 --
2508 -- Fetch the designation level code from the ben_pgm_f table.
2509 --
2510 IF l_rslt.pgm_id IS NOT NULL
2511 THEN
2512 OPEN c_dpnt_lvl_cd (p_pgm_id => l_rslt.pgm_id);
2513 FETCH c_dpnt_lvl_cd INTO l_lvl_cd;
2514 CLOSE c_dpnt_lvl_cd;
2515 END IF;
2516
2517 --
2518
2519 IF g_debug
2520 THEN
2521 hr_utility.set_location ('Designation level code : ' || l_lvl_cd,14 );
2522 END IF;
2523
2524 --
2525 -- check the level code for program, ptip or plan (default) and fetch the
2526 -- appropriate required-info-flags.
2527 --
2528 IF (l_lvl_cd = 'PGM' AND l_rslt.pgm_id IS NOT NULL)
2529 THEN
2530 -- Fetch the flags at the program level
2531 OPEN c_dpnt_pgm (p_pgm_id => l_rslt.pgm_id);
2532 FETCH c_dpnt_pgm INTO l_dpnt;
2533 CLOSE c_dpnt_pgm;
2534 --
2535 ELSIF (l_lvl_cd = 'PTIP' AND l_rslt.pgm_id IS NOT NULL)
2536 THEN
2537 -- Fetch the flags at the ptip level
2538 OPEN c_dpnt_ptip (p_ptip_id => l_rslt.ptip_id);
2539 FETCH c_dpnt_ptip INTO l_dpnt;
2540 CLOSE c_dpnt_ptip;
2541 --
2542 ELSE
2543 -- always use plan as default
2544 OPEN c_dpnt_pl (p_pl_id => l_rslt.pl_id);
2545 FETCH c_dpnt_pl INTO l_dpnt;
2546 CLOSE c_dpnt_pl;
2547 l_lvl_cd := 'PL';
2548 --
2549 END IF;
2550
2551 l_rqd_flag := l_dpnt.susp_if_ctfn_not_dpnt_flag;
2552 OPEN c_ldc (l_lvl_cd);
2553 FETCH c_ldc INTO l_ler_susp_if_ctfn_not_prvd;
2554 CLOSE c_ldc;
2555
2556 IF (l_ler_susp_if_ctfn_not_prvd <> NULL)
2557 THEN
2558 l_rqd_flag := l_ler_susp_if_ctfn_not_prvd;
2559 END IF;
2560 ELSE
2561 l_rqd_flag := 'Y';
2562 END IF;
2563
2564 IF g_debug
2565 THEN
2566 hr_utility.set_location ('l_rqd_flag : ' || l_rqd_flag, 14);
2567 END IF;
2568 --End Bug 6353069
2569 --
2570 process_action_item
2571 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id,
2572 p_actn_typ_id => l_actn_typ_id,
2573 p_cmpltd_dt => l_cmpltd_dt,
2574 p_object_version_number => l_object_version_number,
2575 p_effective_date => p_effective_date,
2576 p_rqd_data_found => l_data_found,
2577 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
2578 p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id,
2579 p_pl_bnf_id => p_pl_bnf_id,
2580 p_rqd_flag => l_rqd_flag, --Bug 6353069
2581 p_post_rslt_flag => 'N',
2582 p_business_group_id => p_business_group_id,
2583 p_datetrack_mode => hr_api.g_update,
2584 p_rslt_object_version_number => l_rslt.object_version_number);
2585 --
2586 if g_debug then
2587 hr_utility.set_location ('Leaving '||l_proc, 10);
2588 end if;
2589 --
2590 end process_new_ctfn_action;
2591 --
2592 -- ----------------------------------------------------------------------------
2593 -- |----------------------------< check_dob >---------------------------------|
2594 -- ----------------------------------------------------------------------------
2595 --
2596 function check_dob
2597 (p_person_id in number
2598 ,p_effective_date in date
2599 ,p_business_group_id in number)
2600 return boolean is
2601 --
2602 l_proc varchar2(80) ;
2603 l_dob_found boolean;
2604 --
2605 cursor c_date_of_birth is
2606 select per.date_of_birth
2607 from per_all_people_f per
2608 where per.person_id = p_person_id
2609 and per.business_group_id = p_business_group_id
2610 and p_effective_date between per.effective_start_date
2611 and per.effective_end_date;
2612 --
2613 l_date_of_birth date;
2614 --
2615 begin
2616 --
2617 g_debug := hr_utility.debug_enabled;
2618 if g_debug then
2619 l_proc := g_package||'.check_dob';
2620 hr_utility.set_location ('Entering '||l_proc,10);
2621 end if;
2622 --
2623 open c_date_of_birth;
2624 fetch c_date_of_birth into l_date_of_birth;
2625 close c_date_of_birth;
2626 --
2627 if l_date_of_birth is not null then
2628 l_dob_found := TRUE;
2629 else
2630 l_dob_found := FALSE;
2631 end if;
2632 --
2633 if g_debug then
2634 hr_utility.set_location ('Leaving ' ||l_proc,10);
2635 end if;
2636 --
2637 return l_dob_found;
2638 --
2639 exception
2640 when others then
2641 if g_debug then
2642 hr_utility.set_location('Exception Raised '||l_proc, 10);
2643 end if;
2644 raise;
2645 --
2646 end check_dob;
2647 --
2648 -- ----------------------------------------------------------------------------
2649 -- |----------------------------< check_adrs >--------------------------------|
2650 -- ----------------------------------------------------------------------------
2651 --
2652 function check_adrs
2653 (p_prtt_enrt_rslt_id in number
2654 ,p_dpnt_bnf_person_id in number
2655 ,p_effective_date in date
2656 ,p_business_group_id in number)
2657 return boolean is
2658 --
2659 -- this function has many things to do. We need to check person resides with
2660 -- the participant. Does the participant have a primary address. A valid
2661 -- zip code. If person does not reside with participant do they have a
2662 -- primary address and a valid zip code.
2663 --
2664 l_proc varchar2(80) ;
2665 l_rsds per_contact_relationships.rltd_per_rsds_w_dsgntr_flag%type;
2666 l_valid_adrs boolean;
2667 --
2668 -- Cursor to check if person resides with participant
2669 --
2670 cursor c_rsds is
2671 select pcr.rltd_per_rsds_w_dsgntr_flag
2672 from per_contact_relationships pcr, ben_prtt_enrt_rslt_f perslt
2673 where perslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
2674 and perslt.person_id = pcr.person_id
2675 and pcr.contact_person_id = p_dpnt_bnf_person_id
2676 and pcr.business_group_id = p_business_group_id
2677 and perslt.business_group_id = p_business_group_id
2678 and perslt.prtt_enrt_rslt_stat_cd is null
2679 and p_effective_date between
2680 perslt.effective_start_date and perslt.effective_end_date;
2681 --
2682 -- Cursor to check if participant has primary address
2683 --
2684 cursor c_prtt_adrs is
2685 select peradd.primary_flag,
2686 peradd.address_line1,
2687 peradd.postal_code
2688 from per_addresses peradd,
2689 ben_prtt_enrt_rslt_f perslt
2690 where perslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
2691 and perslt.person_id = peradd.person_id
2692 and peradd.business_group_id = p_business_group_id
2693 and perslt.business_group_id = p_business_group_id
2694 and perslt.prtt_enrt_rslt_stat_cd is null
2695 and p_effective_date between
2696 perslt.effective_start_date and perslt.effective_end_date
2697 order by decode(peradd.primary_flag,'Y',1,2);
2698 --
2699 l_prtt_adrs c_prtt_adrs%rowtype;
2700 --
2701 -- Cursor to check if the dependent or beneficiary has their own primary addr
2702 --
2703 -- Bug 2858700. Added dt condition and order by clause to the original
2704 -- cursor (commented below).
2705 cursor c_dpnt_bnf_adrs is
2706 select peradd.primary_flag,
2707 peradd.address_line1,
2708 peradd.postal_code
2709 from per_addresses peradd
2710 where peradd.person_id = p_dpnt_bnf_person_id
2711 and peradd.business_group_id = p_business_group_id
2712 and p_effective_date between peradd.date_from and
2713 nvl(peradd.date_to,p_effective_date)
2714 order by decode(peradd.primary_flag,'Y',1,2);
2715
2716 /* cursor c_dpnt_bnf_adrs is
2717 select peradd.primary_flag,
2718 peradd.address_line1,
2719 peradd.postal_code
2720 from per_addresses peradd
2721 where peradd.person_id = p_dpnt_bnf_person_id
2722 and peradd.business_group_id = p_business_group_id; */
2723 --
2724 l_dpnt_bnf_adrs c_dpnt_bnf_adrs%rowtype;
2725 --
2726 begin
2727 --
2728 g_debug := hr_utility.debug_enabled;
2729 if g_debug then
2730 l_proc := g_package||'.check_adrs';
2731 hr_utility.set_location ('Entering '||l_proc,10);
2732 end if;
2733 --
2734 -- check if the person resides with the participant
2735 --
2736 open c_rsds;
2737 fetch c_rsds into l_rsds;
2738 close c_rsds;
2739 --
2740 -- if they reside together. Does participant have primary address and zipcode
2741 --
2742 if l_rsds = 'Y' then
2743 open c_prtt_adrs;
2744 fetch c_prtt_adrs into l_prtt_adrs;
2745 close c_prtt_adrs;
2746 --
2747 -- now check if participant has valid primary address and valid zipcode
2748 --
2749 if l_prtt_adrs.primary_flag = 'Y' and
2750 l_prtt_adrs.postal_code IS NOT NULL then
2751 l_valid_adrs := TRUE;
2752 else
2753 l_valid_adrs := FALSE;
2754 end if;
2755 --
2756 elsif l_rsds = 'N' or l_rsds is null then
2757 --
2758 -- dependent or beneficiary does not reside with participant.
2759 -- Then check if the dependent/beneficiary has a primary address
2760 -- and valid zipcode.
2761 --
2762 open c_dpnt_bnf_adrs;
2763 fetch c_dpnt_bnf_adrs into l_dpnt_bnf_adrs;
2764 close c_dpnt_bnf_adrs;
2765 --
2766 if l_dpnt_bnf_adrs.primary_flag = 'Y' and
2767 l_dpnt_bnf_adrs.postal_code IS NOT NULL then
2768 l_valid_adrs := TRUE;
2769 else
2770 l_valid_adrs := FALSE;
2771 end if;
2772 --
2773 end if; -- l_rsds
2774 --
2775 if g_debug then
2776 hr_utility.set_location ('Leaving ' ||l_proc,10);
2777 end if;
2778 --
2779 return l_valid_adrs;
2780 --
2781 exception
2782 when others then
2783 if g_debug then
2784 hr_utility.set_location('Exception Raised '||l_proc, 10);
2785 end if;
2786 raise;
2787 --
2788 end check_adrs;
2789 --
2790 -- ----------------------------------------------------------------------------
2791 -- |----------------------------< check_legid >-------------------------------|
2792 -- ----------------------------------------------------------------------------
2793 --
2794 function check_legid
2795 (p_person_id in number
2796 ,p_effective_date in date
2797 ,p_business_group_id in number)
2798 return boolean is
2799 --
2800 -- this function checks the social security number, ssn, or
2801 -- national identifier. We are just checking if NULL, not the value.
2802 -- return Y if there is a value found otherwise N.
2803 --
2804 l_proc varchar2(80) ;
2805 l_legid_found boolean;
2806 --
2807 cursor c_leg_id is
2808 select per.national_identifier
2809 from per_all_people_f per
2810 where per.person_id = p_person_id
2811 and per.business_group_id = p_business_group_id
2812 and p_effective_date between
2813 per.effective_start_date and per.effective_end_date;
2814 --
2815 l_leg_id c_leg_id%rowtype;
2816 --
2817 begin
2818 --
2819 g_debug := hr_utility.debug_enabled;
2820 if g_debug then
2821 l_proc := g_package||'.check_legid';
2822 hr_utility.set_location ('Entering '||l_proc,10);
2823 end if;
2824 --
2825 open c_leg_id;
2826 fetch c_leg_id into l_leg_id;
2827 close c_leg_id;
2828 --
2829 if l_leg_id.national_identifier IS NOT NULL then
2830 l_legid_found := TRUE;
2831 else
2832 l_legid_found := FALSE;
2833 end if;
2834 --
2835 if g_debug then
2836 hr_utility.set_location ('Leaving ' ||l_proc,10);
2837 end if;
2838 --
2839 return l_legid_found;
2840 --
2841 exception
2842 when others then
2843 if g_debug then
2844 hr_utility.set_location('Exception Raised '||l_proc, 10);
2845 end if;
2846 raise;
2847 --
2848 end check_legid;
2849 --
2850 -- ----------------------------------------------------------------------------
2851 -- |----------------------------< check_ctfn >--------------------------------|
2852 -- ----------------------------------------------------------------------------
2853 --
2854 function check_ctfn(p_required_count in number
2855 ,p_optional_count in number
2856 ,p_open_required_count in number
2857 ,p_open_optional_count in number)
2858 return boolean is
2859 --
2860 l_proc varchar2(80) ;
2861 --
2862 begin
2863 --
2864 if g_debug then
2865 l_proc := g_package ||'.check_ctfn';
2866 hr_utility.set_location ('Entering '||l_proc,10);
2867 end if;
2868 --
2869 if (p_required_count + p_optional_count) = 0 then
2870 --
2871 -- No certifications were found. Return FALSE.
2872 if g_debug then
2873 hr_utility.set_location ('Leaving '||l_proc,95);
2874 end if;
2875 return FALSE;
2876 --
2877 end if;
2878 --
2879 --
2880 if p_open_required_count = 0 and
2881 p_optional_count = 0 then
2882 -- all reqd provided and no optional ones found
2883 if g_debug then
2884 hr_utility.set_location ('Leaving '||l_proc,96);
2885 end if;
2886 return TRUE;
2887 --
2888 elsif p_open_required_count = 0 and
2889 p_optional_count <> p_open_optional_count then
2890 -- all rqd prvdd and atleast one optional prvdd
2891 if g_debug then
2892 hr_utility.set_location ('Leaving '||l_proc,97);
2893 end if;
2894 return TRUE;
2895 --
2896 else
2897 -- certifications missing or no optional ones provided
2898 if g_debug then
2899 hr_utility.set_location ('Leaving '||l_proc,98);
2900 end if;
2901 return FALSE;
2902 --
2903 end if;
2904 --
2905 if g_debug then
2906 hr_utility.set_location ('Leaving '||l_proc,99);
2907 end if;
2908 --
2909 end check_ctfn;
2910 --
2911 -- ----------------------------------------------------------------------------
2912 -- |----------------------------< check_enrt_ctfn >---------------------------|
2913 -- ----------------------------------------------------------------------------
2914 --
2915 function check_enrt_ctfn
2916 (p_prtt_enrt_actn_id in number
2917 ,p_prtt_enrt_rslt_id in number
2918 ,p_effective_date in date)
2919 return boolean is
2920 --
2921 -- This function checks for certifications for an enrollment result.
2922 -- Check if certifications were provided. For this participant
2923 -- if the enrt_ctfn_rqd_flag is 'Y'if the enrt_ctfn_recd_dt IS NULL
2924 -- The recd_dt is filled in via a form interface.
2925 -- we are also checking for at least one optional certification.
2926 -- optional means dpnt_dsgn_ctfn_rqd_flag is 'N' for the ctfn_prvdd entry
2927 -- with the dpnt_dsgn_ctfn_recd_dt not NULL
2928 --
2929 l_required number;
2930 l_optional number;
2931 l_open_required number;
2932 l_open_optional number;
2933 l_return boolean;
2934 --
2935 l_proc varchar2(80) ;
2936 --
2937 begin
2938 --
2939 g_debug := hr_utility.debug_enabled;
2940 if g_debug then
2941 l_proc := g_package||'.check_enrt_ctfn';
2942 hr_utility.set_location ('Entering '||l_proc,10);
2943 end if;
2944 --
2945 get_ctfn_count
2946 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
2947 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
2948 ,p_effective_date => p_effective_date
2949 ,p_required_count => l_required
2950 ,p_optional_count => l_optional
2951 ,p_open_required_count => l_open_required
2952 ,p_open_optional_count => l_open_optional);
2953 --
2954 l_return := check_ctfn(p_required_count => l_required
2955 ,p_optional_count => l_optional
2956 ,p_open_required_count => l_open_required
2957 ,p_open_optional_count => l_open_optional);
2958 --
2959 if g_debug then
2960 hr_utility.set_location ('Leaving '||l_proc,10);
2961 end if;
2962 --
2963 return l_return;
2964 --
2965 exception
2966 when others then
2967 if g_debug then
2968 hr_utility.set_location('Exception Raised '||l_proc, 10);
2969 end if;
2970 raise;
2971 --
2972 end check_enrt_ctfn;
2973 --
2974 -- ----------------------------------------------------------------------------
2975 -- |----------------------------< check_dpnt_ctfn >---------------------------|
2976 -- ----------------------------------------------------------------------------
2977 --
2978 function check_dpnt_ctfn
2979 (p_prtt_enrt_actn_id in number
2980 ,p_elig_cvrd_dpnt_id in number
2981 ,p_effective_date in date)
2982 return boolean is
2983 --
2984 -- This function checks for certifications for an enrollment result.
2985 -- Check if certifications were provided. For this covered dependent check
2986 -- if the dpnt_dsgn_ctfn_rqd_flag is 'Y'if the dpnt_dsgn_ctfn_recd_dt IS NULL
2987 -- The recd_dt is filled in via a form interface.
2988 -- we are also checking for at least one optional certification.
2989 -- optional means dpnt_dsgn_ctfn_rqd_flag is 'N' for the ctfn_prvdd entry
2990 -- with the dpnt_dsgn_ctfn_recd_dt not NULL
2991 --
2992 l_required number;
2993 l_optional number;
2994 l_open_required number;
2995 l_open_optional number;
2996 l_return boolean;
2997 --
2998 l_proc varchar2(80) ;
2999 --
3000 begin
3001 --
3002 g_debug := hr_utility.debug_enabled;
3003 if g_debug then
3004 l_proc := g_package||'.check_dpnt_ctfn';
3005 hr_utility.set_location ('Entering '||l_proc,10);
3006 end if;
3007 --
3008 get_ctfn_count
3009 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
3010 ,p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id
3011 ,p_effective_date => p_effective_date
3012 ,p_required_count => l_required
3013 ,p_optional_count => l_optional
3014 ,p_open_required_count => l_open_required
3015 ,p_open_optional_count => l_open_optional);
3016 --
3017 l_return := check_ctfn(p_required_count => l_required
3018 ,p_optional_count => l_optional
3019 ,p_open_required_count => l_open_required
3020 ,p_open_optional_count => l_open_optional);
3021 --
3022 if g_debug then
3023 hr_utility.set_location ('Leaving '||l_proc,99);
3024 end if;
3025 --
3026 return l_return;
3027 --
3028 exception
3029 when others then
3030 if g_debug then
3031 hr_utility.set_location('Exception Raised '||l_proc, 999);
3032 end if;
3033 raise;
3034 --
3035 end check_dpnt_ctfn;
3036 --
3037 -- ----------------------------------------------------------------------------
3038 -- |-----------------------< check_write_ctfn >-------------------------------|
3039 -- ----------------------------------------------------------------------------
3040 --
3041 function check_write_ctfn
3042 (p_formula_id in number
3043 ,p_pgm_id in number default NULL
3044 ,p_pl_id in number default NULL
3045 ,p_pl_typ_id in number default NULL
3046 ,p_oipl_id in number default NULL
3047 ,p_ler_id in number default NULL
3048 ,p_param1 in varchar2 default NULL
3049 ,p_param1_value in varchar2 default NULL
3050 ,p_business_group_id in number default NULL
3051 ,p_assignment_id in number default NULL
3052 ,p_organization_id in number default NULL
3053 ,p_jurisdiction_code in varchar2
3054 ,p_effective_date in date)
3055 return boolean is
3056 --
3057 l_write_ctfn boolean := TRUE;
3058 l_outputs ff_exec.outputs_t;
3059 l_proc varchar2(80) ;
3060 --
3061 cursor c_opt is
3062 select oipl.opt_id
3063 from ben_oipl_f oipl
3064 where oipl.oipl_id = p_oipl_id
3065 and business_group_id = p_business_group_id
3066 and p_effective_date between
3067 oipl.effective_start_date and oipl.effective_end_date;
3068
3069 l_opt c_opt%rowtype;
3070 --
3071 begin
3072 --
3073 if g_debug then
3074 l_proc := g_package||'.check_write_ctfn';
3075 hr_utility.set_location ('Entering '||l_proc,10);
3076 end if;
3077 --
3078 if p_formula_id IS NOT NULL then
3079 --
3080 if p_oipl_id is not null then
3081 open c_opt;
3082 fetch c_opt into l_opt;
3083 close c_opt;
3084 end if;
3085 --
3086 l_outputs := benutils.formula
3087 (p_formula_id => p_formula_id
3088 ,p_pgm_id => p_pgm_id
3089 ,p_pl_id => p_pl_id
3090 ,p_pl_typ_id => p_pl_typ_id
3091 ,p_opt_id => l_opt.opt_id
3092 ,p_ler_id => p_ler_id
3093 ,p_param1 => p_param1
3094 ,p_param1_value => p_param1_value
3095 ,p_business_group_id => p_business_group_id
3096 ,p_assignment_id => p_assignment_id
3097 ,p_organization_id => p_organization_id
3098 ,p_jurisdiction_code => p_jurisdiction_code
3099 ,p_effective_date => p_effective_date);
3100 --
3101 if l_outputs(l_outputs.first).value = 'N' then
3102 l_write_ctfn := FALSE;
3103 end if;
3104 --
3105 else
3106 NULL; -- nothing to do at this time
3107 end if;
3108 --
3109 if g_debug then
3110 hr_utility.set_location ('Leaving ' ||l_proc,10);
3111 end if;
3112 --
3113 return l_write_ctfn;
3114 --
3115 exception
3116 when others then
3117 if g_debug then
3118 hr_utility.set_location('Exception Raised '||l_proc, 10);
3119 end if;
3120 raise;
3121 --
3122 end check_write_ctfn;
3123 --
3124 -- ----------------------------------------------------------------------------
3125 -- |-------------------< determine_dpnt_miss_actn_items >---------------------|
3126 -- ----------------------------------------------------------------------------
3127 --
3128 procedure determine_dpnt_miss_actn_items
3129 (p_validate in boolean default false
3130 ,p_effective_date in date
3131 ,p_business_group_id in number
3132 ,p_datetrack_mode in varchar2 default hr_api.g_correction
3133 ,p_prtt_enrt_rslt_id in number
3134 ,p_rslt_object_version_number in out nocopy number
3135 ,p_post_rslt_flag in varchar2 default 'Y'
3136 ,p_dpnt_actn_warning out nocopy boolean) is
3137 --
3138 -- This procedure determines if a desgnated dependent has missing information
3139 -- DOB, SSN, ADRS, CTFN that are required to complete an enrollment. It also
3140 -- completes the DD action. The dependent information requirements are defined
3141 -- at the program, plan, and plan type in program level.
3142 --
3143 l_proc varchar2(80) ;
3144 l_rslt_object_version_number number(15);
3145
3146 --
3147 l_allws_flag varchar2(30);
3148 l_lvl_cd ben_pgm_f.dpnt_dsgn_lvl_cd%type;
3149 l_actn_typ_id number;
3150 l_rqd_data_found boolean; -- holds return value from check_xxx functions
3151 l_effective_start_date date;
3152 l_effective_end_date date;
3153 l_object_version_number number;
3154 l_cmpltd_dt date;
3155 l_prtt_enrt_actn_id number;
3156 l_prtt_enrt_ctfn_prvdd_id number;
3157 --
3158 l_dpnt_actn_warning boolean := FALSE;
3159
3160 l_dpnt_ctfn_actn_warning boolean := FALSE; -- Bug 5998009
3161
3162 l_all_lvls varchar2(30); -- flag for processing levels of dpnt certs
3163 l_outputs ff_exec.outputs_t;
3164 l_write_ctfn boolean := FALSE;
3165 l_ctfns_defined boolean := FALSE;
3166 l_ff_ctfns_exists boolean := FALSE ; -- Bug1491912
3167 l_susp_if_ctfn_not_prvd_flag varchar2(30);
3168
3169 -- Cursor to select context parameters for benutils.formula
3170
3171 cursor c_rslt is
3172 select rslt.pgm_id,
3173 rslt.ptip_id,
3174 rslt.pl_id,
3175 rslt.pl_typ_id,
3176 rslt.oipl_id,
3177 rslt.ler_id,
3178 rslt.person_id,
3179 rslt.business_group_id
3180 from ben_prtt_enrt_rslt_f rslt
3181 where rslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3182 and rslt.prtt_enrt_rslt_stat_cd is null
3183 and p_effective_date between
3184 rslt.effective_start_date and rslt.effective_end_date;
3185
3186 l_rslt c_rslt%rowtype;
3187
3188 cursor c_asg is
3189 select asg.assignment_id,asg.organization_id
3190 from per_all_assignments_f asg
3191 where asg.person_id = l_rslt.person_id
3192 and asg.assignment_type <> 'C'
3193 and asg.primary_flag = 'Y'
3194 and p_effective_date between
3195 asg.effective_start_date and asg.effective_end_date;
3196
3197 l_asg c_asg%rowtype;
3198
3199 Cursor c_state is
3200 select region_2
3201 from hr_locations_all loc,per_all_assignments_f asg
3202 where loc.location_id = asg.location_id
3203 and asg.person_id = l_rslt.person_id
3204 and asg.assignment_type <> 'C'
3205 and p_effective_date between
3206 asg.effective_start_date and asg.effective_end_date
3207 and asg.business_group_id=p_business_group_id;
3208
3209 l_state c_state%rowtype;
3210
3211 -- Cursor to retrieve the dependent designation level
3212 --
3213 cursor c_dpnt_lvl_cd (p_pgm_id number) is
3214 select pgm.dpnt_dsgn_lvl_cd
3215 from ben_pgm_f pgm
3216 where pgm.pgm_id = p_pgm_id
3217 and pgm.business_group_id = p_business_group_id
3218 and p_effective_date between
3219 pgm.effective_start_date and pgm.effective_end_date;
3220 --
3221 -- Cursor to retrieve dependant required flags at the pgm level
3222 --
3223 cursor c_dpnt_pgm (p_pgm_id number) is
3224 select pgm.susp_if_dpnt_ssn_nt_prv_cd,
3225 pgm.susp_if_dpnt_dob_nt_prv_cd,
3226 pgm.susp_if_dpnt_adr_nt_prv_cd,
3227 pgm.susp_if_ctfn_not_dpnt_flag,
3228 pgm.dpnt_ctfn_determine_cd,
3229 pgm.dpnt_dsgn_no_ctfn_rqd_flag
3230 from ben_pgm_f pgm
3231 where pgm.pgm_id = p_pgm_id
3232 and pgm.business_group_id = p_business_group_id
3233 and p_effective_date between
3234 pgm.effective_start_date and pgm.effective_end_date;
3235 --
3236 l_dpnt c_dpnt_pgm%rowtype;
3237 --
3238 -- cursor to retrieve dpnts' required-info-flags at the ptip level
3239 --
3240 cursor c_dpnt_ptip (p_ptip_id number) is
3241 select ptip.susp_if_dpnt_ssn_nt_prv_cd,
3242 ptip.susp_if_dpnt_dob_nt_prv_cd,
3243 ptip.susp_if_dpnt_adr_nt_prv_cd,
3244 ptip.susp_if_ctfn_not_dpnt_flag,
3245 ptip.dpnt_ctfn_determine_cd,
3246 ptip.dpnt_cvg_no_ctfn_rqd_flag
3247 from ben_ptip_f ptip
3248 where ptip.ptip_id = p_ptip_id
3249 and ptip.business_group_id = p_business_group_id
3250 and p_effective_date between
3251 ptip.effective_start_date and ptip.effective_end_date;
3252 --
3253 -- Cursor to retrieve dpnt required flags at the plan level
3254 --
3255 cursor c_dpnt_pl (p_pl_id number) is
3256 select pl.susp_if_dpnt_ssn_nt_prv_cd,
3257 pl.susp_if_dpnt_dob_nt_prv_cd,
3258 pl.susp_if_dpnt_adr_nt_prv_cd,
3259 pl.susp_if_ctfn_not_dpnt_flag,
3260 pl.dpnt_ctfn_determine_cd,
3261 pl.dpnt_no_ctfn_rqd_flag
3262 from ben_pl_f pl
3263 where pl.pl_id = p_pl_id
3264 and pl.business_group_id = p_business_group_id
3265 and p_effective_date between
3266 pl.effective_start_date and pl.effective_end_date;
3267 --
3268 cursor c_ctfns_ler_chg(v_lvl_cd varchar2
3269 ,v_dpnt_person_id number
3270 ,v_person_id number
3271 ,v_pgm_id number
3272 ,v_pl_id number
3273 ,v_ptip_id number) is
3274 select lcc.dpnt_cvg_ctfn_typ_cd,
3275 lcc.ctfn_rqd_when_rl,
3276 lcc.rqd_flag,
3277 lcc.rlshp_typ_cd,
3278 ldc.susp_if_ctfn_not_prvd_flag,
3279 ldc.ctfn_determine_cd
3280 from ben_ler_chg_dpnt_cvg_ctfn_f lcc,
3281 ben_ler_chg_dpnt_cvg_f ldc,
3282 ben_prtt_enrt_rslt_f pen
3283 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3284 and pen.business_group_id = p_business_group_id
3285 and p_effective_date between pen.effective_start_date
3286 and pen.effective_end_date
3287 and pen.ler_id = ldc.ler_id
3288 and pen.prtt_enrt_rslt_stat_cd is null
3289 and p_effective_date between ldc.effective_start_date
3290 and ldc.effective_end_date
3291 and ((v_lvl_cd = 'PTIP' and ldc.ptip_id = v_ptip_id) OR
3292 (v_lvl_cd = 'PL' and ldc.pl_id = v_pl_id) OR
3293 (v_lvl_cd = 'PGM' and ldc.pgm_id = v_pgm_id))
3294 and ldc.ler_chg_dpnt_cvg_id = lcc.ler_chg_dpnt_cvg_id
3295 and p_effective_date between lcc.effective_start_date
3296 and lcc.effective_end_date
3297 and (lcc.rlshp_typ_cd is null
3298 or
3299 lcc.rlshp_typ_cd in (select contact_type
3300 from per_contact_relationships
3301 where contact_person_id = v_dpnt_person_id
3302 and person_id = v_person_id
3303 and business_group_id = p_business_group_id
3304 and p_effective_date
3305 between nvl(date_start, p_effective_date)
3306 and nvl(date_end, hr_api.g_eot)));
3307 --
3308 -- Cursor to retrieve dependent certification information at the plan level
3309 --
3310 cursor c_dpnt_ctfn_pl(v_pl_id number, v_dpnt_person_id number, v_person_id number) is
3311 select pl.dpnt_cvg_ctfn_typ_cd ctcvgcd,
3312 pl.ctfn_rqd_when_rl ctrrl,
3313 pl.rqd_flag,
3314 pl.rlshp_typ_cd ctrlshcd,
3315 pl.pl_id
3316 from ben_pl_dpnt_cvg_ctfn_f pl
3317 where pl.pl_id = v_pl_id
3318 and pl.business_group_id = p_business_group_id
3319 and p_effective_date between pl.effective_start_date
3320 and pl.effective_end_date
3321 and (pl.rlshp_typ_cd is null
3322 or
3323 pl.rlshp_typ_cd in (select contact_type
3324 from per_contact_relationships
3325 where contact_person_id = v_dpnt_person_id
3326 and person_id = v_person_id
3327 and business_group_id = p_business_group_id
3328 and p_effective_date
3329 between nvl(date_start, p_effective_date)
3330 and nvl(date_end, hr_api.g_eot)));
3331 --
3332 -- Cursor to retrieve dependent certification at the program level
3333 --
3334 cursor c_dpnt_ctfn_pgm(v_pgm_id number, v_dpnt_person_id number, v_person_id number) is
3335 select pgm.dpnt_cvg_ctfn_typ_cd ctcvgcd,
3336 pgm.ctfn_rqd_when_rl ctrrl,
3337 pgm.rqd_flag,
3338 pgm.rlshp_typ_cd ctrlshcd,
3339 pgm.pgm_id
3340 from ben_pgm_dpnt_cvg_ctfn_f pgm
3341 where pgm.pgm_id = v_pgm_id
3342 and pgm.business_group_id = p_business_group_id
3343 and p_effective_date between pgm.effective_start_date
3344 and pgm.effective_end_date
3345 and (pgm.rlshp_typ_cd is null
3346 or
3347 pgm.rlshp_typ_cd in (select contact_type
3348 from per_contact_relationships
3349 where contact_person_id = v_dpnt_person_id
3350 and person_id = v_person_id
3351 and business_group_id = p_business_group_id
3352 and p_effective_date
3353 between nvl(date_start, p_effective_date)
3354 and nvl(date_end, hr_api.g_eot)));
3355
3356 --
3357 -- Cursor to retrieve dependent certifications at the ptip level
3358 --
3359 cursor c_dpnt_ctfn_ptip(v_ptip_id number, v_dpnt_person_id number, v_person_id number) is
3360 select ptip.dpnt_cvg_ctfn_typ_cd ctcvgcd,
3361 ptip.ctfn_rqd_when_rl ctrrl,
3362 ptip.rqd_flag,
3363 ptip.rlshp_typ_cd ctrlshcd,
3364 ptip.ptip_id
3365 from ben_ptip_dpnt_cvg_ctfn_f ptip
3366 where ptip.ptip_id = v_ptip_id
3367 and ptip.business_group_id = p_business_group_id
3368 and p_effective_date between ptip.effective_start_date
3369 and ptip.effective_end_date
3370 and (ptip.rlshp_typ_cd is null
3371 or
3372 ptip.rlshp_typ_cd in (select contact_type
3373 from per_contact_relationships
3374 where contact_person_id = v_dpnt_person_id
3375 and person_id = v_person_id
3376 and business_group_id = p_business_group_id
3377 and p_effective_date
3378 between nvl(date_start, p_effective_date)
3379 and nvl(date_end, hr_api.g_eot)));
3380
3381 --
3382 -- Cursor to fetch the covered dependents for an enrt_rslt_id
3383 --
3384 cursor c_cvrd_dpnt is
3385 select ecd.dpnt_person_id,
3386 ecd.elig_cvrd_dpnt_id,
3387 pen.pgm_id,
3388 pen.ptip_id,
3389 pen.pl_id
3390 from ben_elig_cvrd_dpnt_f ecd,
3391 ben_prtt_enrt_rslt_f pen,
3392 ben_per_in_ler pil
3393 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3394 and pen.prtt_enrt_rslt_id = ecd.prtt_enrt_rslt_id
3395 and ecd.cvg_strt_dt is not null
3396 and nvl(ecd.cvg_thru_dt, hr_api.g_eot) = hr_api.g_eot
3397 and ecd.business_group_id = p_business_group_id
3398 and p_effective_date between
3399 ecd.effective_start_date and ecd.effective_end_date
3400 and p_effective_date between
3401 pen.effective_start_date and pen.effective_end_date
3402 and pen.prtt_enrt_rslt_stat_cd is null
3403 and pil.per_in_ler_id=ecd.per_in_ler_id
3404 and pil.business_group_id=p_business_group_id
3405 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
3406 --
3407 cursor c_mng_dpnts (cl_dpnt_id number) is
3408 select ccp.elig_cvrd_dpnt_id,
3409 ccp.dpnt_dsgn_ctfn_typ_cd,
3410 ccp.dpnt_dsgn_ctfn_rqd_flag,
3411 ccp.dpnt_dsgn_ctfn_recd_dt
3412 from ben_cvrd_dpnt_ctfn_prvdd_f ccp,
3413 ben_elig_cvrd_dpnt_f ecd,
3414 ben_per_in_ler pil
3415 where ccp.elig_cvrd_dpnt_id = cl_dpnt_id
3416 and ccp.dpnt_dsgn_ctfn_recd_dt IS NULL
3417 and ccp.business_group_id = p_business_group_id
3418 and p_effective_date between
3419 ccp.effective_start_date and ccp.effective_end_date
3420 and ecd.elig_cvrd_dpnt_id=ccp.elig_cvrd_dpnt_id
3421 and ecd.business_group_id = p_business_group_id
3422 and p_effective_date between
3423 ecd.effective_start_date and ecd.effective_end_date
3424 and pil.per_in_ler_id=ecd.per_in_ler_id
3425 and pil.business_group_id=p_business_group_id
3426 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
3427 --
3428 -- bug: 5513339
3429 cursor c_curr_ovn_of_actn (c_prtt_enrt_actn_id number) is
3430 select object_version_number
3431 from ben_prtt_enrt_actn_f
3432 where prtt_enrt_actn_id = c_prtt_enrt_actn_id
3433 and business_group_id = p_business_group_id
3434 and p_effective_date between effective_start_date
3435 and effective_end_date;
3436
3437 --
3438 l_mng_dpnts c_mng_dpnts%rowtype;
3439 l_jurisdiction_code varchar2(30);
3440 l_ctfn_at_ler_chg boolean := FALSE;
3441 l_rqd_flag varchar2(30);
3442
3443 --
3444 begin
3445 --
3446 if g_debug then
3447 l_proc := g_package||'.determine_dpnt_miss_actn_items';
3448 hr_utility.set_location ('Entering '||l_proc,10);
3449 end if;
3450
3451 l_rslt_object_version_number := p_rslt_object_version_number ;
3452
3453 --
3454 if p_prtt_enrt_rslt_id is not null then
3455 open c_rslt;
3456 fetch c_rslt into l_rslt;
3457 close c_rslt;
3458 else
3459 if g_debug then
3460 hr_utility.set_location('RESULT ID IS NULL!!' , 13);
3461 end if;
3462 end if;
3463 --
3464 if l_rslt.person_id is not null then
3465 open c_asg;
3466 fetch c_asg into l_asg;
3467 close c_asg;
3468 end if;
3469 --
3470
3471 /* -- 4031733 - Cursor used to populate l_state.region_2 param for benutils.limit_checks
3472 -- which is not used down the line
3473 --
3474 if l_rslt.person_id is not null then
3475 open c_state;
3476 fetch c_state into l_state;
3477 close c_state;
3478
3479 -- if l_state.region_2 is not null then
3480
3481 -- l_jurisdiction_code :=
3482 -- pay_mag_utils.lookup_jurisdiction_code
3483 -- (p_state => l_state.region_2);
3484
3485 -- end if;
3486 end if;
3487 */
3488
3489 --
3490 -- Fetch the designation level code from the ben_pgm_f table.
3491 --
3492 if l_rslt.pgm_id is not null then
3493 open c_dpnt_lvl_cd(p_pgm_id => l_rslt.pgm_id);
3494 fetch c_dpnt_lvl_cd into l_lvl_cd;
3495 close c_dpnt_lvl_cd;
3496 end if;
3497 --
3498 if g_debug then
3499 hr_utility.set_location('Designation level code : ' || l_lvl_cd, 14);
3500 end if;
3501 --
3502 -- check the level code for program, ptip or plan (default) and fetch the
3503 -- appropriate required-info-flags.
3504 --
3505 if (l_lvl_cd = 'PGM' and l_rslt.pgm_id IS NOT NULL) then
3506 -- Fetch the flags at the program level
3507 open c_dpnt_pgm(p_pgm_id => l_rslt.pgm_id);
3508 fetch c_dpnt_pgm into l_dpnt;
3509 close c_dpnt_pgm;
3510 --
3511 elsif (l_lvl_cd = 'PTIP' and l_rslt.pgm_id IS NOT NULL) then
3512 -- Fetch the flags at the ptip level
3513 open c_dpnt_ptip(p_ptip_id => l_rslt.ptip_id);
3514 fetch c_dpnt_ptip into l_dpnt;
3515 close c_dpnt_ptip;
3516 --
3517 else
3518 -- always use plan as default
3519 open c_dpnt_pl(p_pl_id => l_rslt.pl_id);
3520 fetch c_dpnt_pl into l_dpnt;
3521 close c_dpnt_pl;
3522 l_lvl_cd := 'PL';
3523 --
3524 end if;
3525 --
3526 -- for each dependent covered by participant check
3527 -- date of birth, address, national id, certifications
3528 --
3529 for l_cvrd_dpnt in c_cvrd_dpnt loop
3530 -- date of birth action item
3531 --
3532 -- Check if a DDDOB action item exists for the dependent
3533 --
3534 l_ff_ctfns_exists := FALSE ;
3535 --
3536 if g_debug then
3537 hr_utility.set_location('DOB action item ', 30);
3538 end if;
3539 --
3540 l_actn_typ_id := get_actn_typ_id
3541 (p_type_cd => 'DDDOB'
3542 ,p_business_group_id => p_business_group_id);
3543 --
3544 get_prtt_enrt_actn_id
3545 (p_actn_typ_id => l_actn_typ_id
3546 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3547 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3548 ,p_effective_date => p_effective_date
3549 ,p_business_group_id => p_business_group_id
3550 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3551 ,p_cmpltd_dt => l_cmpltd_dt
3552 ,p_object_version_number => l_object_version_number);
3553 --
3554 if l_dpnt.susp_if_dpnt_dob_nt_prv_cd is not null then
3555 --
3556 -- check if person has a date of birth entry
3557 --
3558 if g_debug then
3559 hr_utility.set_location('DOB is rqd', 35);
3560 end if;
3561 --
3562 if l_dpnt.susp_if_dpnt_dob_nt_prv_cd = 'RQDS' then
3563 l_rqd_flag := 'Y';
3564 else
3565 l_rqd_flag := 'N';
3566 end if;
3567 l_rqd_data_found := check_dob
3568 (p_person_id => l_cvrd_dpnt.dpnt_person_id
3569 ,p_effective_date => p_effective_date
3570 ,p_business_group_id => p_business_group_id);
3571 --
3572 -- Process the action item
3573 --
3574 process_action_item
3575 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3576 ,p_actn_typ_id => l_actn_typ_id
3577 ,p_cmpltd_dt => l_cmpltd_dt
3578 ,p_object_version_number => l_object_version_number
3579 ,p_effective_date => p_effective_date
3580 ,p_rqd_data_found => l_rqd_data_found
3581 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3582 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3583 ,p_rqd_flag => l_rqd_flag --'Y'
3584 ,p_post_rslt_flag => p_post_rslt_flag
3585 ,p_business_group_id => p_business_group_id
3586 ,p_datetrack_mode => p_datetrack_mode
3587 ,p_rslt_object_version_number => p_rslt_object_version_number);
3588 --
3589 if l_rqd_data_found = FALSE then
3590 l_dpnt_actn_warning := TRUE;
3591 end if;
3592 --
3593 else
3594 -- dpnt_dob_rqd_flag is 'N'
3595 -- if date_track mode is updating and designation at plan level
3596 -- delete action item of type DDDOB.
3597 --
3598 if g_debug then
3599 hr_utility.set_location('DOB is not required', 40);
3600 end if;
3601 --
3602 if (l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE) then
3603 --
3604 delete_action_item
3605 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3606 ,p_object_version_number => l_object_version_number
3607 ,p_business_group_id => p_business_group_id
3608 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3609 ,p_rslt_object_version_number => p_rslt_object_version_number
3610 ,p_effective_date => p_effective_date
3611 ,p_datetrack_mode => p_datetrack_mode
3612 ,p_post_rslt_flag => p_post_rslt_flag);
3613 --
3614 else
3615 NULL; -- nothing to do at this time.
3616 end if;
3617 --
3618 end if; -- dpnt_dob_rqd_flag
3619 --
3620 -- Social security number/national identifier action item
3621 --
3622 if g_debug then
3623 hr_utility.set_location('SSN action item ', 45);
3624 end if;
3625 --
3626 l_actn_typ_id := get_actn_typ_id
3627 (p_type_cd => 'DDSSN'
3628 ,p_business_group_id => p_business_group_id);
3629 --
3630 get_prtt_enrt_actn_id
3631 (p_actn_typ_id => l_actn_typ_id
3632 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3633 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3634 ,p_effective_date => p_effective_date
3635 ,p_business_group_id => p_business_group_id
3636 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3637 ,p_cmpltd_dt => l_cmpltd_dt
3638 ,p_object_version_number => l_object_version_number);
3639 --
3640 if l_dpnt.susp_if_dpnt_ssn_nt_prv_cd is not null then
3641 --
3642 -- check if person has a national identifier entry
3643 --
3644 if g_debug then
3645 hr_utility.set_location('SSN is rqd', 50);
3646 end if;
3647 --
3648 if l_dpnt.susp_if_dpnt_ssn_nt_prv_cd = 'RQDS' then
3649 l_rqd_flag := 'Y';
3650 else
3651 l_rqd_flag := 'N';
3652 end if;
3653 l_rqd_data_found := check_legid
3654 (p_person_id => l_cvrd_dpnt.dpnt_person_id
3655 ,p_effective_date => p_effective_date
3656 ,p_business_group_id => p_business_group_id);
3657 --
3658 -- Process the action item
3659 --
3660 process_action_item
3661 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3662 ,p_actn_typ_id => l_actn_typ_id
3663 ,p_cmpltd_dt => l_cmpltd_dt
3664 ,p_object_version_number => l_object_version_number
3665 ,p_effective_date => p_effective_date
3666 ,p_rqd_data_found => l_rqd_data_found
3667 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3668 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3669 ,p_rqd_flag => l_rqd_flag --'Y'
3670 ,p_post_rslt_flag => p_post_rslt_flag
3671 ,p_business_group_id => p_business_group_id
3672 ,p_datetrack_mode => p_datetrack_mode
3673 ,p_rslt_object_version_number => p_rslt_object_version_number);
3674 --
3675 if l_rqd_data_found = FALSE then
3676 l_dpnt_actn_warning := TRUE;
3677 end if;
3678 --
3679 else
3680 --
3681 if g_debug then
3682 hr_utility.set_location('SSN is not rqd', 55);
3683 end if;
3684 --
3685 -- dpnt_leg_id_rqd_flag is 'N'
3686 -- if date_track mode is updating and designation at plan level
3687 -- delete action type of type DDSSN.
3688 --
3689 if l_prtt_enrt_actn_id IS NOT NULL and
3690 p_datetrack_mode = DTMODE_DELETE then
3691 --
3692 delete_action_item
3693 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3694 ,p_object_version_number => l_object_version_number
3695 ,p_business_group_id => p_business_group_id
3696 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3697 ,p_rslt_object_version_number => p_rslt_object_version_number
3698 ,p_effective_date => p_effective_date
3699 ,p_datetrack_mode => p_datetrack_mode
3700 ,p_post_rslt_flag => p_post_rslt_flag);
3701 --
3702 else
3703 NULL; -- nothing to do at this time.
3704 end if;
3705 --
3706 end if; -- dpnt_leg_id_rqd_flag
3707 --
3708 -- address action item
3709 --
3710 if g_debug then
3711 hr_utility.set_location('ADDR action item ' , 60);
3712 end if;
3713 --
3714 l_actn_typ_id := get_actn_typ_id
3715 (p_type_cd => 'DDADDR'
3716 ,p_business_group_id => p_business_group_id);
3717 --
3718 get_prtt_enrt_actn_id
3719 (p_actn_typ_id => l_actn_typ_id
3720 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3721 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3722 ,p_effective_date => p_effective_date
3723 ,p_business_group_id => p_business_group_id
3724 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3725 ,p_cmpltd_dt => l_cmpltd_dt
3726 ,p_object_version_number => l_object_version_number);
3727 --
3728 if l_dpnt.susp_if_dpnt_adr_nt_prv_cd is not null then
3729 --
3730 -- check if person has an address
3731 --
3732 if g_debug then
3733 hr_utility.set_location('ADDR is rqd', 65);
3734 end if;
3735 --
3736 if l_dpnt.susp_if_dpnt_adr_nt_prv_cd = 'RQDS' then
3737 l_rqd_flag := 'Y';
3738 else
3739 l_rqd_flag := 'N';
3740 end if;
3741 l_rqd_data_found := check_adrs
3742 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3743 ,p_dpnt_bnf_person_id => l_cvrd_dpnt.dpnt_person_id
3744 ,p_effective_date => p_effective_date
3745 ,p_business_group_id => p_business_group_id);
3746 --
3747 -- Process the action item
3748 --
3749 process_action_item
3750 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3751 ,p_actn_typ_id => l_actn_typ_id
3752 ,p_cmpltd_dt => l_cmpltd_dt
3753 ,p_object_version_number => l_object_version_number
3754 ,p_effective_date => p_effective_date
3755 ,p_rqd_data_found => l_rqd_data_found
3756 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3757 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3758 ,p_rqd_flag => l_rqd_flag --'Y'
3759 ,p_post_rslt_flag => p_post_rslt_flag
3760 ,p_business_group_id => p_business_group_id
3761 ,p_datetrack_mode => p_datetrack_mode
3762 ,p_rslt_object_version_number => p_rslt_object_version_number);
3763 --
3764 if l_rqd_data_found = FALSE then
3765 l_dpnt_actn_warning := TRUE;
3766 end if;
3767 --
3768 else
3769 --
3770 if g_debug then
3771 hr_utility.set_location('ADD is not rqd', 70);
3772 end if;
3773 --
3774 -- dpnt_adrs_rqd_flag is 'N'
3775 -- if date_track mode is updating and designation at plan level
3776 -- delete action type of type DDADDR.
3777 --
3778 if (l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE) then
3779 --
3780 delete_action_item
3781 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3782 ,p_object_version_number => l_object_version_number
3783 ,p_business_group_id => p_business_group_id
3784 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3785 ,p_rslt_object_version_number => p_rslt_object_version_number
3786 ,p_effective_date => p_effective_date
3787 ,p_datetrack_mode => p_datetrack_mode
3788 ,p_post_rslt_flag => p_post_rslt_flag);
3789 --
3790 end if;
3791 --
3792 end if; -- dpnt_adrs_rqd_flag
3793 --
3794 -- certification action item
3795 --
3796 if g_debug then
3797 hr_utility.set_location('CTFN action item ' , 75);
3798 end if;
3799 --
3800 l_actn_typ_id := get_actn_typ_id
3801 (p_type_cd => 'DDCTFN'
3802 ,p_business_group_id => p_business_group_id);
3803 --
3804 -- Check if a dpnt ctfn action item exists.
3805 --
3806 get_prtt_enrt_actn_id
3807 (p_actn_typ_id => l_actn_typ_id
3808 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3809 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3810 ,p_effective_date => p_effective_date
3811 ,p_business_group_id => p_business_group_id
3812 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3813 ,p_cmpltd_dt => l_cmpltd_dt
3814 ,p_object_version_number => l_object_version_number);
3815 --
3816 -- ************************************************************
3817 -- Note, the flag says NO Dependent Certification Required.
3818 -- ************************************************************
3819 --
3820 if l_dpnt.dpnt_dsgn_no_ctfn_rqd_flag = 'N' then
3821 -- double negative....ctfn is required.
3822 if g_debug then
3823 hr_utility.set_location('DPNT CTFN is rqd', 80);
3824 end if;
3825 --
3826 --
3827 -- check if person has certification
3828 --
3829 l_rqd_data_found := check_dpnt_ctfn
3830 (p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3831 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3832 ,p_effective_date => p_effective_date);
3833 --
3834 -- Check if any certifications are defined for the comp object.
3835 --
3836 l_ctfns_defined := check_ctfns_defined
3837 (p_dpnt_person_id => l_cvrd_dpnt.dpnt_person_id
3838 ,p_person_id => l_rslt.person_id
3839 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3840 ,p_lvl_cd => l_lvl_cd
3841 ,p_pgm_id => l_rslt.pgm_id
3842 ,p_pl_id => l_cvrd_dpnt.pl_id
3843 ,p_ptip_id => l_rslt.ptip_id
3844 ,p_effective_date => p_effective_date
3845 ,p_business_group_id => p_business_group_id
3846 ,p_ctfn_at_ler_chg => l_ctfn_at_ler_chg
3847 ,p_susp_if_ctfn_not_prvd_flag => l_susp_if_ctfn_not_prvd_flag);
3848 --
3849 if l_prtt_enrt_actn_id IS NULL and
3850 not(l_rqd_data_found) and
3851 (l_ctfns_defined) then
3852 --
3853 if g_debug then
3854 hr_utility.set_location('Ctfn defined and not provided', 85);
3855 end if;
3856 --
3857 -- Bug 3851427 : If certifications are considered at LER_CHG_DPNT level, then Suspension of
3858 -- enrollment ( SUSP_IF_CTFN_NOT_PRVD_FLAG ) should also be considered at LER_CHG_DPNT level
3859 --
3860 if l_ctfn_at_ler_chg = true
3861 then
3862 --
3863 l_rqd_flag := l_susp_if_ctfn_not_prvd_flag; -- This flag is at LER_CHG_DPNT
3864 --
3865 else
3866 --
3867 l_rqd_flag := l_dpnt.susp_if_ctfn_not_dpnt_flag; -- This flag is at PTIP, PLN or PGM level
3868 --
3869 end if;
3870 --
3871 -- Since an action item is being written set the out warning param
3872 --
3873 -- l_dpnt_actn_warning := TRUE; -- Bug 5998009 Commented out the assignment statement
3874 --
3875 -- Certifications are required and certifications are defined. However
3876 -- no certifications were found for this person. Create an action item.
3877 --
3878 write_new_action_item
3879 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3880 ,p_rslt_object_version_number => p_rslt_object_version_number
3881 ,p_actn_typ_id => l_actn_typ_id
3882 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3883 ,p_rqd_flag => l_rqd_flag -- Bug 3851427
3884 ,p_effective_date => p_effective_date
3885 ,p_post_rslt_flag => p_post_rslt_flag
3886 ,p_business_group_id => p_business_group_id
3887 ,p_object_version_number => l_object_version_number
3888 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id);
3889 --
3890 -- loop thru all the specified certifications at the proper level
3891 -- write each one specified to the cvrd_dpnt_ctfn_prvdd_f table
3892 -- if no records then write them for all levels. Otherwise just
3893 -- the level they are requested for
3894 --
3895 -- first check if there are any existing certification
3896 -- for this dependent moved over from Managed Dependent process
3897 --
3898 l_all_lvls := YES_FOUND; -- init value
3899 --
3900 open c_mng_dpnts(l_cvrd_dpnt.elig_cvrd_dpnt_id);
3901 fetch c_mng_dpnts into l_mng_dpnts;
3902 --
3903 if c_mng_dpnts%NOTFOUND then
3904 l_all_lvls := NOT_FOUND; -- write for all levels since nothing found
3905 end if;
3906 --
3907 close c_mng_dpnts;
3908 --
3909 if g_debug then
3910 hr_utility.set_location('l_all_lvls:'||l_all_lvls|| 'l_lvl_cd:'||
3911 l_lvl_cd||' l_pgm_id:'||to_char(l_rslt.pgm_id), 87);
3912 end if;
3913 --
3914 -- now write out the appropriate certifications for each level
3915 --
3916 if l_all_lvls = NOT_FOUND and
3917 l_lvl_cd = 'PGM' and
3918 l_rslt.pgm_id IS NOT NULL then
3919 --
3920 if l_ctfn_at_ler_chg = TRUE then
3921 --
3922 -- Certifications defined for dpnt ler change
3923 --
3924 for l_ctfn in c_ctfns_ler_chg(l_lvl_cd
3925 ,l_cvrd_dpnt.dpnt_person_id
3926 ,l_rslt.person_id
3927 ,l_cvrd_dpnt.pgm_id
3928 ,l_cvrd_dpnt.pl_id
3929 ,l_cvrd_dpnt.ptip_id) loop
3930 --
3931 l_write_ctfn := check_write_ctfn
3932 (p_formula_id => l_ctfn.ctfn_rqd_when_rl
3933 ,p_pgm_id => l_rslt.pgm_id
3934 ,p_pl_id => l_rslt.pl_id
3935 ,p_pl_typ_id => l_rslt.pl_typ_id
3936 ,p_oipl_id => l_rslt.oipl_id
3937 ,p_ler_id => l_rslt.ler_id
3938 ,p_param1 => 'CON_PERSON_ID'
3939 ,p_param1_value => to_char(l_cvrd_dpnt.dpnt_person_id)
3940 ,p_business_group_id => l_rslt.business_group_id
3941 ,p_assignment_id => l_asg.assignment_id
3942 ,p_organization_id => l_asg.organization_id
3943 ,p_jurisdiction_code => l_jurisdiction_code
3944 ,p_effective_date => p_effective_date);
3945 --
3946 if l_write_ctfn then
3947 -- 9999
3948 l_ff_ctfns_exists := TRUE ;
3949 --
3950 -- presently we want to write the certifications always.
3951 -- unless the above rule indicates not to.
3952 --
3953 write_new_dpnt_ctfn_item
3954 (p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3955 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3956 ,p_dpnt_dsgn_ctfn_typ_cd => l_ctfn.dpnt_cvg_ctfn_typ_cd
3957 ,p_dpnt_dsgn_ctfn_rqd_flag => l_ctfn.rqd_flag
3958 ,p_effective_date => p_effective_date
3959 ,p_business_group_id => p_business_group_id
3960 ,p_object_version_number => l_object_version_number
3961 ,p_cvrd_dpnt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
3962 --
3963 end if;
3964 --
3965 end loop;
3966 --
3967 else
3968 --
3969 -- No ctfns for ler change. Fetch the regular ctfns
3970 --
3971 for l_dpnt_ctfn_pgm in c_dpnt_ctfn_pgm(l_cvrd_dpnt.pgm_id
3972 ,l_cvrd_dpnt.dpnt_person_id
3973 ,l_rslt.person_id) loop
3974 --
3975 l_write_ctfn := check_write_ctfn
3976 (p_formula_id => l_dpnt_ctfn_pgm.ctrrl
3977 ,p_pgm_id => l_rslt.pgm_id
3978 ,p_pl_id => l_rslt.pl_id
3979 ,p_pl_typ_id => l_rslt.pl_typ_id
3980 ,p_oipl_id => l_rslt.oipl_id
3981 ,p_ler_id => l_rslt.ler_id
3982 ,p_param1 => 'CON_PERSON_ID'
3983 ,p_param1_value => to_char(l_cvrd_dpnt.dpnt_person_id)
3984 ,p_business_group_id => l_rslt.business_group_id
3985 ,p_assignment_id => l_asg.assignment_id
3986 ,p_organization_id => l_asg.organization_id
3987 ,p_jurisdiction_code => l_jurisdiction_code
3988 ,p_effective_date => p_effective_date);
3989 --
3990 if l_write_ctfn then
3991 --
3992 -- 9999
3993 l_ff_ctfns_exists := TRUE ;
3994 --
3995 -- presently we want to write the certifications always.
3996 -- unless the above rule indicates not to.
3997 --
3998 write_new_dpnt_ctfn_item
3999 (p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
4000 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4001 ,p_dpnt_dsgn_ctfn_typ_cd => l_dpnt_ctfn_pgm.ctcvgcd
4002 ,p_dpnt_dsgn_ctfn_rqd_flag => l_dpnt_ctfn_pgm.rqd_flag
4003 ,p_effective_date => p_effective_date
4004 ,p_business_group_id => p_business_group_id
4005 ,p_object_version_number => l_object_version_number
4006 ,p_cvrd_dpnt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
4007 --
4008 end if;
4009 --
4010 end loop;
4011 --
4012 end if;
4013 --
4014 end if;
4015 --
4016 if l_all_lvls = NOT_FOUND and
4017 l_lvl_cd = 'PTIP' and
4018 l_rslt.pgm_id IS NOT NULL then
4019 --
4020 if l_ctfn_at_ler_chg = TRUE then
4021 --
4022 -- Certifications defined for dpnt ler change
4023 --
4024 for l_ctfn in c_ctfns_ler_chg(l_lvl_cd
4025 ,l_cvrd_dpnt.dpnt_person_id
4026 ,l_rslt.person_id
4027 ,l_cvrd_dpnt.pgm_id
4028 ,l_cvrd_dpnt.pl_id
4029 ,l_cvrd_dpnt.ptip_id) loop
4030 --
4031 l_write_ctfn := check_write_ctfn
4032 (p_formula_id => l_ctfn.ctfn_rqd_when_rl
4033 ,p_pgm_id => l_rslt.pgm_id
4034 ,p_pl_id => l_rslt.pl_id
4035 ,p_pl_typ_id => l_rslt.pl_typ_id
4036 ,p_oipl_id => l_rslt.oipl_id
4037 ,p_ler_id => l_rslt.ler_id
4038 ,p_param1 => 'CON_PERSON_ID'
4039 ,p_param1_value => to_char(l_cvrd_dpnt.dpnt_person_id)
4040 ,p_business_group_id => l_rslt.business_group_id
4041 ,p_assignment_id => l_asg.assignment_id
4042 ,p_organization_id => l_asg.organization_id
4043 ,p_jurisdiction_code => l_jurisdiction_code
4044 ,p_effective_date => p_effective_date);
4045 --
4046 if l_write_ctfn then
4047 --
4048 -- 9999
4049 l_ff_ctfns_exists := TRUE ;
4050 --
4051 -- presently we want to write the certifications always.
4052 -- unless the above rule indicates not to.
4053 --
4054 write_new_dpnt_ctfn_item
4055 (p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
4056 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4057 ,p_dpnt_dsgn_ctfn_typ_cd => l_ctfn.dpnt_cvg_ctfn_typ_cd
4058 ,p_dpnt_dsgn_ctfn_rqd_flag => l_ctfn.rqd_flag
4059 ,p_effective_date => p_effective_date
4060 ,p_business_group_id => p_business_group_id
4061 ,p_object_version_number => l_object_version_number
4062 ,p_cvrd_dpnt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
4063 --
4064 else
4065 if g_debug then
4066 hr_utility.set_location('Dpnt ctfns at ptip in else - false returned ', 111);
4067 end if;
4068 end if;
4069 --
4070 end loop;
4071 if g_debug then
4072 hr_utility.set_location('Dpnt ctfns at ptip level - false returned ', 990);
4073 end if;
4074 --
4075 else
4076 --
4077 for l_dpnt_ctfn_ptip in c_dpnt_ctfn_ptip(l_cvrd_dpnt.ptip_id
4078 ,l_cvrd_dpnt.dpnt_person_id
4079 ,l_rslt.person_id) loop
4080 --
4081 l_write_ctfn := check_write_ctfn
4082 (p_formula_id => l_dpnt_ctfn_ptip.ctrrl
4083 ,p_pgm_id => l_rslt.pgm_id
4084 ,p_pl_id => l_rslt.pl_id
4085 ,p_pl_typ_id => l_rslt.pl_typ_id
4086 ,p_oipl_id => l_rslt.oipl_id
4087 ,p_ler_id => l_rslt.ler_id
4088 ,p_param1 => 'CON_PERSON_ID'
4089 ,p_param1_value => to_char(l_cvrd_dpnt.dpnt_person_id)
4090 ,p_business_group_id => l_rslt.business_group_id
4091 ,p_assignment_id => l_asg.assignment_id
4092 ,p_organization_id => l_asg.organization_id
4093 ,p_jurisdiction_code => l_jurisdiction_code
4094 ,p_effective_date => p_effective_date);
4095 --
4096 if l_write_ctfn then
4097 --
4098 -- 9999
4099 l_ff_ctfns_exists := TRUE ;
4100 --
4101 -- presently we want to write the certifications always.
4102 -- unless the above rule indicates not to.
4103 --
4104 write_new_dpnt_ctfn_item
4105 (p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
4106 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4107 ,p_dpnt_dsgn_ctfn_typ_cd => l_dpnt_ctfn_ptip.ctcvgcd
4108 ,p_dpnt_dsgn_ctfn_rqd_flag => l_dpnt_ctfn_ptip.rqd_flag
4109 ,p_effective_date => p_effective_date
4110 ,p_business_group_id => p_business_group_id
4111 ,p_object_version_number => l_object_version_number
4112 ,p_cvrd_dpnt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
4113 --
4114 end if;
4115 --
4116 end loop;
4117 --
4118 end if;
4119 --
4120 end if;
4121 --
4122 --
4123 if l_all_lvls = NOT_FOUND and
4124 (l_lvl_cd = 'PL' ) then
4125 --
4126 if g_debug then
4127 hr_utility.set_location('Dpnt ctfns at plan level', 90);
4128 end if;
4129 --
4130 if l_ctfn_at_ler_chg = TRUE then
4131 --
4132 -- Certifications defined for dpnt ler change
4133 --
4134 for l_ctfn in c_ctfns_ler_chg(l_lvl_cd
4135 ,l_cvrd_dpnt.dpnt_person_id
4136 ,l_rslt.person_id
4137 ,l_cvrd_dpnt.pgm_id
4138 ,l_cvrd_dpnt.pl_id
4139 ,l_cvrd_dpnt.ptip_id) loop
4140 --
4141 l_write_ctfn := check_write_ctfn
4142 (p_formula_id => l_ctfn.ctfn_rqd_when_rl
4143 ,p_pgm_id => l_rslt.pgm_id
4144 ,p_pl_id => l_rslt.pl_id
4145 ,p_pl_typ_id => l_rslt.pl_typ_id
4146 ,p_oipl_id => l_rslt.oipl_id
4147 ,p_ler_id => l_rslt.ler_id
4148 ,p_param1 => 'CON_PERSON_ID'
4149 ,p_param1_value => to_char(l_cvrd_dpnt.dpnt_person_id)
4150 ,p_business_group_id => l_rslt.business_group_id
4151 ,p_assignment_id => l_asg.assignment_id
4152 ,p_organization_id => l_asg.organization_id
4153 ,p_jurisdiction_code => l_jurisdiction_code
4154 ,p_effective_date => p_effective_date);
4155 --
4156 if l_write_ctfn then
4157 --
4158 --
4159 -- 9999
4160 l_ff_ctfns_exists := TRUE ;
4161 --
4162 -- presently we want to write the certifications always.
4163 -- unless the above rule indicates not to.
4164 --
4165 write_new_dpnt_ctfn_item
4166 (p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
4167 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4168 ,p_dpnt_dsgn_ctfn_typ_cd => l_ctfn.dpnt_cvg_ctfn_typ_cd
4169 ,p_dpnt_dsgn_ctfn_rqd_flag => l_ctfn.rqd_flag
4170 ,p_effective_date => p_effective_date
4171 ,p_business_group_id => p_business_group_id
4172 ,p_object_version_number => l_object_version_number
4173 ,p_cvrd_dpnt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
4174 --
4175 end if;
4176 --
4177 end loop;
4178 --
4179 else
4180 --
4181 for l_dpnt_ctfn_pl in c_dpnt_ctfn_pl(l_cvrd_dpnt.pl_id
4182 ,l_cvrd_dpnt.dpnt_person_id
4183 ,l_rslt.person_id) loop
4184 --
4185 l_write_ctfn := check_write_ctfn
4186 (p_formula_id => l_dpnt_ctfn_pl.ctrrl
4187 ,p_pgm_id => l_rslt.pgm_id
4188 ,p_pl_id => l_rslt.pl_id
4189 ,p_pl_typ_id => l_rslt.pl_typ_id
4190 ,p_oipl_id => l_rslt.oipl_id
4191 ,p_ler_id => l_rslt.ler_id
4192 ,p_param1 => 'CON_PERSON_ID'
4193 ,p_param1_value => to_char(l_cvrd_dpnt.dpnt_person_id)
4194 ,p_business_group_id => l_rslt.business_group_id
4195 ,p_assignment_id => l_asg.assignment_id
4196 ,p_organization_id => l_asg.organization_id
4197 ,p_jurisdiction_code => l_jurisdiction_code
4198 ,p_effective_date => p_effective_date);
4199 --
4200 --
4201 if l_write_ctfn then
4202 --
4203 --
4204 -- 9999
4205 l_ff_ctfns_exists := TRUE ;
4206 --
4207 -- presently we want to write the certifications always.
4208 -- unless the above rule indicates not to.
4209 --
4210 if g_debug then
4211 hr_utility.set_location('Writing Certification', 95);
4212 end if;
4213 --
4214 write_new_dpnt_ctfn_item
4215 (p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
4216 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4217 ,p_dpnt_dsgn_ctfn_typ_cd => l_dpnt_ctfn_pl.ctcvgcd
4218 ,p_dpnt_dsgn_ctfn_rqd_flag => l_dpnt_ctfn_pl.rqd_flag
4219 ,p_effective_date => p_effective_date
4220 ,p_business_group_id => p_business_group_id
4221 ,p_object_version_number => l_object_version_number
4222 ,p_cvrd_dpnt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
4223 --
4224 else
4225 if g_debug then
4226 hr_utility.set_location('Rule failed.. not writing ctfn', 100);
4227 end if;
4228 end if;
4229 --
4230 end loop;
4231 --
4232 end if;
4233 --
4234 end if;
4235 --
4236
4237 -- 9999 Bug1491912 prtt act item row is deleted if there are no certifications created for
4238 -- for that action item.
4239 IF l_ff_ctfns_exists = FALSE
4240 THEN
4241 --
4242 if g_debug then
4243 hr_utility.set_location ('Entering l_ff_ctfns_exists',999);
4244 end if;
4245 --
4246 -- bug: 5513339
4247 open c_curr_ovn_of_actn (l_prtt_enrt_actn_id);
4248 fetch c_curr_ovn_of_actn into l_object_version_number;
4249 close c_curr_ovn_of_actn ;
4250 delete_action_item
4251 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4252 ,p_object_version_number => l_object_version_number
4253 ,p_business_group_id => p_business_group_id
4254 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4255 ,p_rslt_object_version_number => p_rslt_object_version_number
4256 ,p_effective_date => p_effective_date
4257 ,p_datetrack_mode => hr_api.g_zap
4258 ,p_post_rslt_flag => p_post_rslt_flag);
4259 --
4260 if g_debug then
4261 hr_utility.set_location ('Leaving l_ff_ctfns_exists',999);
4262 end if;
4263 --Start Bug 5998009
4264 ELSE
4265 l_dpnt_ctfn_actn_warning := TRUE;
4266 --End Bug 5998009
4267 END IF ;
4268 --
4269 elsif l_prtt_enrt_actn_id IS NOT NULL and
4270 l_rqd_data_found = TRUE and
4271 l_cmpltd_dt IS NULL then
4272 --
4273 -- Bug 6434143
4274 if l_ctfn_at_ler_chg = true
4275 then
4276 --
4277 l_rqd_flag := l_susp_if_ctfn_not_prvd_flag; -- This flag is at LER_CHG_DPNT
4278 --
4279 else
4280 --
4281 l_rqd_flag := l_dpnt.susp_if_ctfn_not_dpnt_flag; -- This flag is at PTIP, PLN or PGM level
4282 --
4283 end if;
4284 --
4285 -- Bug 6434143
4286 if g_debug then
4287 hr_utility.set_location('Existing actn item. Have rqd info', 110);
4288 end if;
4289 --
4290 -- Existing open action item. But we now have required info. Close the
4291 -- action item by setting the cmpltd_dt field.
4292 --
4293 set_cmpltd_dt
4294 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4295 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4296 ,p_rslt_object_version_number => p_rslt_object_version_number
4297 ,p_actn_typ_id => l_actn_typ_id
4298 -- ,p_rqd_flag => 'Y' -- Bug 6434143
4299 ,p_rqd_flag => l_rqd_flag
4300 ,p_effective_date => p_effective_date
4301 ,p_post_rslt_flag => p_post_rslt_flag
4302 ,p_business_group_id => p_business_group_id
4303 ,p_object_version_number => l_object_version_number
4304 ,p_open_close => 'CLOSE'
4305 ,p_datetrack_mode => p_datetrack_mode);
4306 --
4307 elsif l_prtt_enrt_actn_id IS NOT NULL and
4308 l_rqd_data_found = FALSE and
4309 l_cmpltd_dt IS NULL then
4310 --
4311 -- Existing closed action item. But required info is missing. Reopen the
4312 -- action item.
4313 --
4314 if g_debug then
4315 hr_utility.set_location('Existing actn item. Rqd info missing', 115);
4316 end if;
4317 --
4318 --Bug 6434143
4319 if l_ctfn_at_ler_chg = true
4320 then
4321 --
4322 l_rqd_flag := l_susp_if_ctfn_not_prvd_flag;
4323 --
4324 else
4325 --
4326 l_rqd_flag := l_dpnt.susp_if_ctfn_not_dpnt_flag;
4327 --
4328 end if;
4329 --
4330 --Bug 6434143
4331
4332 set_cmpltd_dt
4333 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4334 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4335 ,p_rslt_object_version_number => p_rslt_object_version_number
4336 ,p_actn_typ_id => l_actn_typ_id
4337 -- ,p_rqd_flag => 'Y' -- Bug 6434143
4338 ,p_rqd_flag => l_rqd_flag
4339 ,p_effective_date => p_effective_date
4340 ,p_post_rslt_flag => p_post_rslt_flag
4341 ,p_business_group_id => p_business_group_id
4342 ,p_object_version_number => l_object_version_number
4343 ,p_open_close => 'OPEN'
4344 ,p_datetrack_mode => p_datetrack_mode);
4345 --
4346 end if;
4347 --
4348 else
4349 --
4350 if g_debug then
4351 hr_utility.set_location('Dpnt ctfn rqd flag is N', 120);
4352 end if;
4353 --
4354 -- dpnt_ctfn_rqd_flag is 'N'
4355 -- if date_track mode is updating and designation at plan level
4356 -- delete action type of type DDCTFN.
4357 --
4358 if (l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE) then
4359 --
4360 delete_action_item
4361 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4362 ,p_object_version_number => l_object_version_number
4363 ,p_business_group_id => p_business_group_id
4364 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4365 ,p_rslt_object_version_number => p_rslt_object_version_number
4366 ,p_effective_date => p_effective_date
4367 ,p_datetrack_mode => p_datetrack_mode
4368 ,p_post_rslt_flag => p_post_rslt_flag);
4369 --
4370 else
4371 NULL; -- nothing to do at this time
4372 end if;
4373 --
4374 end if; -- dpnt_ctfn_rqd_flag
4375 --
4376 end loop; -- dpnt loop
4377 --
4378 if g_debug then
4379 hr_utility.set_location ('Leaving '||l_proc,999);
4380 end if;
4381 --
4382 p_dpnt_actn_warning := l_dpnt_actn_warning;
4383 --
4384
4385 --Start Bug 5998009
4386 if(l_dpnt_ctfn_actn_warning = TRUE) then
4387 p_dpnt_actn_warning := TRUE;
4388 end if;
4389 --End Bug 5998009
4390
4391
4392 exception
4393 --
4394 when others then
4395 if g_debug then
4396 hr_utility.set_location('Exception Raised '||l_proc, 997);
4397 end if;
4398 p_rslt_object_version_number :=l_rslt_object_version_number;
4399 p_dpnt_actn_warning := null;
4400
4401 raise;
4402 --
4403 end determine_dpnt_miss_actn_items;
4404 --
4405 -- Added by Anil
4406 -- ----------------------------------------------------------------------------
4407 -- |--------------------< determine_future_sal_incr_actn_items >----- ---------|
4408 -- ----------------------------------------------------------------------------
4409 --
4410 procedure det_fut_sal_incr_actn_items
4411 (
4412 p_prtt_enrt_rslt_id in number
4413 ,p_effective_date in date
4414 ,p_business_group_id in number
4415 ,p_validate in boolean default FALSE
4416 ,p_datetrack_mode in varchar2 default hr_api.g_correction
4417 ,p_post_rslt_flag in varchar2 default 'Y'
4418 ,p_rslt_object_version_number in out nocopy number
4419 ,p_suspend_flag in out nocopy varchar2
4420 ) is
4421 --
4422 l_proc varchar2(80) := g_package||'.determine_future_sal_incr_actn_items';
4423 l_actn_typ_id number(15);
4424 l_dummy varchar2(30);
4425 l_object_version_number number;
4426 l_prtt_enrt_actn_id number(15);
4427 l_rslt_object_version_number number(15);
4428 l_suspend_flag varchar2(10);
4429 --
4430 cursor c_future_sal_inc is
4431 Select 'X'
4432 from per_pay_proposals pay
4433 ,ben_prtt_enrt_rslt_f rslt
4434 ,ben_pl_typ_f tyP
4435 Where rslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
4436 and p_effective_date between rslt.effective_start_date and rslt.effective_end_date
4437 and pay.approved = 'Y'
4438 and rslt.assignment_id = pay.assignment_id
4439 and pay.business_group_id = p_business_group_id
4440 and pay.change_date >= p_effective_date
4441 and typ.pl_typ_id = rslt.pl_typ_id
4442 and rslt.prtt_enrt_rslt_stat_cd is null
4443 and p_effective_date between typ.effective_start_date and typ.effective_end_date
4444 and typ.comp_typ_cd = 'ICM7';
4445 --
4446 l_future_sal_inc c_future_sal_inc%ROWTYPE;
4447 --
4448 BEGIN
4449 --
4450 if g_debug then
4451 hr_utility.set_location ('Entering '||l_proc,10);
4452 end if;
4453 --
4454
4455 l_rslt_object_version_number := p_rslt_object_version_number ;
4456 l_suspend_flag := p_suspend_flag ;
4457
4458 -- Issue a savepoint if operating in validate only mode
4459 --
4460 OPEN c_future_sal_inc;
4461 fetch c_future_sal_inc into l_future_sal_inc;
4462 /*fnd_file.put_line(fnd_file.log,'-->The info garnered from the sal cursor');
4463 fnd_file.put_line(fnd_file.log,'-->l_future_sal_inc.prtt_enrt_rslt_id'||l_future_sal_inc.rslt_id);
4464 fnd_file.put_line(fnd_file.log,'-->l_future_sal_inc.per_in_ler_id'||l_future_sal_inc.per_in_ler_id);
4465 fnd_file.put_line(fnd_file.log,'-->l_future_sal_inc.assignment_id'||l_future_sal_inc.assignment_id);*/
4466 IF c_future_sal_inc%FOUND THEN
4467 l_actn_typ_id := get_actn_typ_id
4468 (p_type_cd => 'MRRFS'
4469 ,p_business_group_id => p_business_group_id);
4470 /*fnd_file.put_line(fnd_file.log,'-->The Action item type is l_actn_typ_id'||l_actn_typ_id);
4471 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item writing the action item with the following parameters');
4472 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item p_prtt_enrt_rslt_id '||p_prtt_enrt_rslt_id);
4473 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item p_effective_date '||p_effective_date);
4474 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item p_business_group_id '||p_business_group_id );
4475 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item p_datetrack_mode '||p_datetrack_mode);
4476 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item p_post_rslt_flag '||p_post_rslt_flag);
4477 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item p_rslt_object_version_number'||p_rslt_object_version_number);
4478 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item p_prtt_enrt_actn_id '||l_prtt_enrt_actn_id);
4479 fnd_file.put_line(fnd_file.log,'---------------------------------------------------------------------------');*/
4480 write_new_action_item
4481 ( p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4482 ,p_rslt_object_version_number => p_rslt_object_version_number
4483 ,p_actn_typ_id => l_actn_typ_id
4484 ,p_effective_date => p_effective_date
4485 ,p_post_rslt_flag => p_post_rslt_flag
4486 ,p_business_group_id => p_business_group_id
4487 ,p_object_version_number => l_object_version_number
4488 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id);
4489 p_suspend_flag := 'Y';
4490 END IF;
4491
4492 CLOSE c_future_sal_inc;
4493 -- new call to write to ben_reporting
4494 if g_debug then
4495 hr_utility.set_location ('Leaving '||l_proc, 10);
4496 end if;
4497 --
4498 EXCEPTION
4499 WHEN OTHERS THEN
4500 if g_debug then
4501 hr_utility.set_location('Exception Raised '||l_proc, 10);
4502 end if;
4503 fnd_file.put_line(fnd_file.log,'Exception Raised -'||l_proc);
4504 fnd_file.put_line(fnd_file.log,fnd_message.get);
4505 fnd_file.put_line(fnd_file.log,sqlerrm);
4506
4507 p_rslt_object_version_number :=l_rslt_object_version_number;
4508 p_suspend_flag :=l_suspend_flag ;
4509 RAISE;
4510 --
4511 END DET_FUT_SAL_INCR_ACTN_ITEMS;
4512 --
4513 -- ----------------------------------------------------------------------------
4514 -- |--------------------< process_cwb_actn_items >----------------------------|
4515 -- ----------------------------------------------------------------------------
4516 --
4517 procedure process_cwb_actn_items
4518 (p_validate in boolean default FALSE
4519 ,p_prtt_enrt_rslt_id in number
4520 ,p_effective_date in date
4521 ,p_business_group_id in number
4522 ,p_datetrack_mode in varchar2 default hr_api.g_correction
4523 ,p_post_rslt_flag in varchar2 default 'Y'
4524 ,p_rslt_object_version_number in out nocopy number
4525 ,p_suspend_flag in out nocopy varchar2) is
4526 --
4527 l_proc varchar2(80);
4528 l_rslt_object_version_number number(15);
4529 l_suspend_flag varchar2(15);
4530
4531
4532 --
4533 begin
4534 --
4535 g_debug := hr_utility.debug_enabled;
4536 if g_debug then
4537 l_proc := g_package||'.process_cwb_actn_items';
4538 hr_utility.set_location ('Entering '||l_proc,10);
4539 end if;
4540 if g_debug then
4541 hr_utility.set_location ('Entering rslt id '||to_char(p_prtt_enrt_rslt_id),11);
4542 end if;
4543 --
4544 l_rslt_object_version_number := p_rslt_object_version_number ;
4545 l_suspend_flag := p_suspend_flag ;
4546
4547 -- Issue a savepoint if operating in validate only mode
4548 --
4549 savepoint process_cwb_actn_items;
4550 --
4551 /*fnd_file.put_line(fnd_file.log,'-->fut_sal_incr det_fut_sal_incr_actn_items with the following parameters');
4552 fnd_file.put_line(fnd_file.log,'-->fut_sal_incr p_prtt_enrt_rslt_id '||p_prtt_enrt_rslt_id);
4553 fnd_file.put_line(fnd_file.log,'-->fut_sal_incr p_effective_date '||p_effective_date);
4554 fnd_file.put_line(fnd_file.log,'-->fut_sal_incr p_business_group_id '||p_business_group_id );
4555 fnd_file.put_line(fnd_file.log,'-->fut_sal_incr p_datetrack_mode '||p_datetrack_mode);
4556 fnd_file.put_line(fnd_file.log,'-->fut_sal_incr p_post_rslt_flag '||p_post_rslt_flag);
4557 fnd_file.put_line(fnd_file.log,'-->fut_sal_incr p_rslt_object_version_number'||p_rslt_object_version_number);
4558 fnd_file.put_line(fnd_file.log,'-->fut_sal_incr p_suspend_flag '||p_suspend_flag);
4559 fnd_file.put_line(fnd_file.log,'---------------------------------------------------------------------------');*/
4560 --
4561 det_fut_sal_incr_actn_items
4562 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4563 ,p_rslt_object_version_number => p_rslt_object_version_number
4564 ,p_effective_date => p_effective_date
4565 ,p_business_group_id => p_business_group_id
4566 ,p_datetrack_mode => p_datetrack_mode
4567 ,p_post_rslt_flag => p_post_rslt_flag
4568 ,p_suspend_flag => p_suspend_flag
4569 ,p_validate => p_validate);
4570
4571 if p_validate then
4572 raise hr_api.validate_enabled;
4573 end if;
4574 --
4575 if g_debug then
4576 hr_utility.set_location ('Leaving '||l_proc, 10);
4577 end if;
4578 --
4579 exception
4580 --
4581 when hr_api.validate_enabled
4582 then
4583 rollback to process_cwb_actn_items;
4584 --
4585 if g_debug then
4586 hr_utility.set_location(' Leaving:'||l_proc, 10);
4587 end if;
4588 --
4589 when others then
4590 if g_debug then
4591 hr_utility.set_location('Exception Raised '||l_proc, 10);
4592 end if;
4593 p_rslt_object_version_number := l_rslt_object_version_number ;
4594 p_suspend_flag := l_suspend_flag ;
4595 raise;
4596 --
4597 end process_cwb_actn_items;
4598 --
4599 -- ----------------------------------------------------------------------------
4600 -- |-------------------< determine_dpnt_actn_items >--------------------------|
4601 -- ----------------------------------------------------------------------------
4602 --
4603 procedure determine_dpnt_actn_items
4604 (p_validate in boolean default FALSE
4605 ,p_prtt_enrt_rslt_id in number
4606 ,p_effective_date in date
4607 ,p_business_group_id in number
4608 ,p_datetrack_mode in varchar2 default hr_api.g_correction
4609 ,p_post_rslt_flag in varchar2 default 'Y'
4610 ,p_allws_flag in varchar2
4611 ,p_dsgn_cd in varchar2
4612 ,p_rslt_object_version_number in out nocopy number
4613 ,p_dd_actn_item_open out nocopy boolean
4614 ,p_hack out nocopy varchar2) is
4615 -- this procedure determines if dependents are required to complete enrollment
4616 -- for an enrollment result check ben_elig_per_elctbl_chc.alws_dpnt_dsgn_flag
4617 -- if 'Y' and a new enrollment result write DD action item.
4618 -- A DD action item is only written when no dependents were designated.
4619 -- in additon if the dependent designation is 'R' required, suspend enrollment
4620 -- or if designation 'O' optional, do not suspend.
4621 --
4622 l_proc varchar2(80) ;
4623 --
4624 l_actn_typ_id number(15);
4625 l_cmpltd_dt date;
4626 l_object_version_number number;
4627 l_prtt_enrt_actn_id number(15);
4628 l_rqd_flag varchar2(30);
4629
4630 l_rslt_object_version_number number(15);
4631
4632
4633
4634 --
4635 cursor c_dpnt_dsgn is
4636 select ecd.dpnt_person_id
4637 from ben_elig_cvrd_dpnt_f ecd,
4638 ben_per_in_ler pil
4639 where ecd.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
4640 and ecd.cvg_strt_dt is not null
4641 and nvl(ecd.cvg_thru_dt, hr_api.g_eot) = hr_api.g_eot
4642 and ecd.business_group_id = p_business_group_id
4643 and p_effective_date between
4644 ecd.effective_start_date and ecd.effective_end_date
4645 and pil.per_in_ler_id=ecd.per_in_ler_id
4646 and pil.business_group_id=p_business_group_id
4647 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
4648 --
4649 l_dpnt_dsgn c_dpnt_dsgn%rowtype;
4650 --
4651 -- Cursor to fetch dependent action items other than the DD item. this will
4652 -- be used to delete all dependent action items after a DD action item is
4653 -- written
4654 --
4655 cursor c_other_dpnt_actn_items is
4656 select pea.prtt_enrt_actn_id,
4657 pea.object_version_number
4658 from ben_prtt_enrt_actn_f pea,
4659 ben_actn_typ typ,
4660 ben_per_in_ler pil
4661 where pea.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
4662 and pea.business_group_id = p_business_group_id
4663 and typ.type_cd <> 'DD'
4664 and typ.type_cd like 'DD%'
4665 and pea.per_in_ler_id = pil.per_in_ler_id
4666 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
4667 and typ.business_group_id = p_business_group_id
4668 and pea.actn_typ_id = typ.actn_typ_id
4669 and p_effective_date between
4670 pea.effective_start_date and pea.effective_end_date
4671 ;
4672 --
4673 -- Cursor to check if the enrt rslt is for an employee only option where the
4674 -- min and max dpnts will be 0.
4675 -- 3730053: Designation Requirements for OPT overrides OIPL overrides PLN.
4676 -- Bug 4396160: Curosr name is changed from c_emp_only to c_tot_mn_mx_dpnts_req
4677 -- sothat total number of Min and Max no of dpnts calculated
4678 -- If no DD record is defined, Query will result in Both totals as NULL
4679 cursor c_tot_mn_mx_dpnts_req is -- c_not_emp_only is
4680 select sum(tot_mn_dpnts_rqd_num) tot_mn_dpnts_rqd_num,
4681 sum(tot_mx_dpnts_alwd_num) tot_mx_dpnts_alwd_num
4682 from (select sum(nvl(drq.mn_dpnts_rqd_num, 0 )) tot_mn_dpnts_rqd_num,
4683 sum(nvl(drq.mx_dpnts_alwd_num,9999999999)) tot_mx_dpnts_alwd_num
4684 from ben_dsgn_rqmt_f drq,
4685 ben_oipl_f cop,
4686 ben_prtt_enrt_rslt_f pen
4687 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
4688 -- and drq.oipl_id = pen.oipl_id -- 3730053: OPT level DSGN_RQMTS override OIPL level
4689 and pen.oipl_id = cop.oipl_id
4690 and ( (drq.oipl_id = pen.oipl_id
4691 and not exists
4692 (select null
4693 from ben_dsgn_rqmt_f drq2
4694 where drq2.opt_id = cop.opt_id
4695 and p_effective_date between drq2.effective_start_date
4696 and drq2.effective_end_date))
4697 or cop.opt_id = drq.opt_id)
4698 and drq.dsgn_typ_cd = 'DPNT'
4699 --and drq.mn_dpnts_rqd_num > 0
4700 --and drq.mx_dpnts_alwd_num = 0
4701 and cop.business_group_id = p_business_group_id
4702 and p_effective_date between cop.effective_start_date
4703 and cop.effective_end_date
4704 and pen.business_group_id = p_business_group_id
4705 and p_effective_date between pen.effective_start_date
4706 and pen.effective_end_date
4707 and drq.business_group_id = p_business_group_id
4708 and p_effective_date between drq.effective_start_date
4709 and drq.effective_end_date
4710 UNION -- 3730053: Added this to check PL-level designation requirements are specified at PLAN-LEVEL.
4711 select sum(nvl(drq.mn_dpnts_rqd_num, 0 )) tot_mn_dpnts_rqd_num,
4712 sum(nvl(drq.mx_dpnts_alwd_num,9999999999)) tot_mx_dpnts_alwd_num
4713 from ben_dsgn_rqmt_f drq,
4714 ben_prtt_enrt_rslt_f pen
4715 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
4716 and drq.pl_id = pen.pl_id
4717 and drq.dsgn_typ_cd = 'DPNT'
4718 --and drq.mn_dpnts_rqd_num > 0
4719 --and drq.mx_dpnts_alwd_num = 0
4720 and pen.business_group_id = p_business_group_id
4721 and p_effective_date between pen.effective_start_date
4722 and pen.effective_end_date
4723 and drq.business_group_id = p_business_group_id
4724 and p_effective_date between drq.effective_start_date
4725 and drq.effective_end_date
4726 and (pen.oipl_id IS NULL
4727 OR NOT EXISTS (select null
4728 from ben_dsgn_rqmt_f drq3
4729 where drq3.oipl_id = pen.oipl_id
4730 and p_effective_date between drq3.effective_start_date and drq3.effective_end_date
4731 UNION ALL
4732 select null
4733 from ben_dsgn_rqmt_f drq4,
4734 ben_oipl_f cop
4735 where cop.oipl_id = pen.oipl_id
4736 and drq4.opt_id = cop.opt_id
4737 and p_effective_date between cop.effective_start_date and cop.effective_end_date
4738 and p_effective_date between drq4.effective_start_date and drq4.effective_end_date))
4739 );
4740 --
4741 --
4742 cursor c_elig_dpnts is
4743 SELECT 'S'
4744 from BEN_ELIG_DPNT egd,
4745 BEN_ELIG_PER_ELCTBL_CHC epe,
4746 BEN_PRTT_ENRT_RSLT_F pen
4747 where pen.PRTT_ENRT_RSLT_ID = p_prtt_enrt_rslt_id
4748 and pen.PRTT_ENRT_RSLT_ID = epe.PRTT_ENRT_RSLT_ID
4749 and egd.elig_per_elctbl_chc_id = epe.elig_per_elctbl_chc_id
4750 and pen.prtt_enrt_rslt_stat_cd is null
4751 and p_effective_date between pen.effective_start_date and pen.effective_end_date
4752 and dpnt_inelig_flag = 'N' ;
4753 --
4754 l_dummy varchar2(1);
4755 l_open_act_item_flag boolean := TRUE;
4756 l_mn_tot_dpnts_req number ;
4757 l_mx_tot_dpnts_alwd number ;
4758 --
4759 begin
4760 --
4761 if g_debug then
4762 l_proc := g_package||'.determine_dpnt_actn_items';
4763 hr_utility.set_location ('Entering '||l_proc,10);
4764 end if;
4765 --
4766 l_rslt_object_version_number :=p_rslt_object_version_number ;
4767
4768 --
4769 l_actn_typ_id := get_actn_typ_id
4770 (p_type_cd => 'DD'
4771 ,p_business_group_id => p_business_group_id);
4772 --
4773 get_prtt_enrt_actn_id
4774 (p_actn_typ_id => l_actn_typ_id
4775 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4776 ,p_effective_date => p_effective_date
4777 ,p_business_group_id => p_business_group_id
4778 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4779 ,p_cmpltd_dt => l_cmpltd_dt
4780 ,p_object_version_number => l_object_version_number);
4781 --
4782
4783 -- BUG:3248711: Since epe.alws_dpnt_dsgn_flag = 'N' (LE doesn't allow dpnt dsgn)
4784 -- and yet epe.dpnt_dsgn_cd = 'R' (Dpnt Dsgn is Required)
4785 -- In this case.. we'll have to show the the message that 'Dpnt design is pending'
4786 -- and also suspend the plan. Hence the or-condition (l_dsgn_cd = 'R') as been added
4787 -- to below if-condition
4788
4789 if ((p_allws_flag = 'Y') or (p_dsgn_cd = 'R')) then
4790 --
4791 if g_debug then
4792 hr_utility.set_location('Dpnt dsgn allowed', 10);
4793 end if;
4794 --
4795 -- Check if any dependents are designated
4796 --
4797 open c_dpnt_dsgn;
4798 fetch c_dpnt_dsgn into l_dpnt_dsgn;
4799 --
4800 -- check the dsgn code for R - required or O - optional and set the
4801 -- parameter to be passed to process_action_items. This will ensure that
4802 -- the enrollment is suspended if required.
4803 --
4804 if p_dsgn_cd = 'R' then
4805 l_rqd_flag := 'Y';
4806 else
4807 l_rqd_flag := 'N';
4808 end if;
4809 --
4810 if g_debug then
4811 hr_utility.set_location('Dpnt dsgn rqd flag : ' || l_rqd_flag || ' ' || l_proc, 20);
4812 end if;
4813 --
4814 if c_dpnt_dsgn%NOTFOUND then
4815 --
4816 if g_debug then
4817 hr_utility.set_location('No dpnts designated', 10);
4818 end if;
4819 --
4820 -- there are no dependents designated
4821 --
4822 -- If the enrt is for an employee only option then a DD actn item
4823 -- need not be written.
4824 --
4825 -- Changed for Bug: 4396160,
4826 -- Action Items will not be created if both total min and max are zero for the Paln/Option
4827 -- For Min = 0 and Max > 0, Action Item will be created if Elig dpnts exists
4828 -- For both Min and Max > 0, Action Items will be created irrespective of Elig dpnts.
4829 -- Added case to create Action Items if no DD records defined also.
4830 open c_tot_mn_mx_dpnts_req;
4831 fetch c_tot_mn_mx_dpnts_req into l_mn_tot_dpnts_req, l_mx_tot_dpnts_alwd ;
4832 close c_tot_mn_mx_dpnts_req;
4833 --
4834 if l_mn_tot_dpnts_req is not null and l_mx_tot_dpnts_alwd is not null then -- DD record is defined
4835 if l_mn_tot_dpnts_req = 0 then
4836 --
4837 if l_mx_tot_dpnts_alwd = 0 then
4838 --
4839 l_open_act_item_flag := FALSE ;
4840 --
4841 else
4842 --
4843 Open c_elig_dpnts;
4844 Fetch c_elig_dpnts into l_Dummy;
4845 --
4846 If c_elig_dpnts%FOUND then
4847 --
4848 l_open_act_item_flag := TRUE ;
4849 if g_debug then
4850 hr_utility.set_location('Eligible dpnts found: ', 10);
4851 end if;
4852 --
4853 Else
4854 l_open_act_item_flag := FALSE ;
4855 End if;
4856 --
4857 Close c_elig_dpnts;
4858 --
4859 End if;
4860 Else
4861 --
4862 l_open_act_item_flag := TRUE ;
4863 --
4864 End if;
4865 --
4866 Else -- if No DD record is defined, Then also create Action Item.
4867 l_open_act_item_flag := TRUE ;
4868 --
4869 End if;
4870
4871 /* if c_not_emp_only%found then
4872 --
4873 if g_debug then
4874 hr_utility.set_location('c_not_emp_only found', 10);
4875 end if;
4876 --
4877 l_open_act_item_flag := TRUE ;
4878 --
4879 else
4880 --
4881 if g_debug then
4882 hr_utility.set_location('c_not_emp_only not found: l_mx_dpnts_alwd_num: '||l_mx_dpnts_alwd_num, 10);
4883 end if;
4884 --
4885 Open c_elig_dpnts;
4886 Fetch c_elig_dpnts into l_Dummy;
4887 --
4888 If c_elig_dpnts%FOUND then
4889 --
4890 l_open_act_item_flag := TRUE ;
4891 if g_debug then
4892 hr_utility.set_location('c_lig_dpnts found: ', 10);
4893 end if;
4894 --
4895 Else
4896 l_open_act_item_flag := FALSE ;
4897 End if;
4898 Close c_elig_dpnts;
4899 End if;
4900 Close c_not_emp_only;*/
4901
4902 If l_open_act_item_flag then
4903
4904 --
4905 -- There is no desination requirement defined for the option that
4906 -- doesn't allow dpnts. Write a DD action item.
4907 --
4908 -- process the action item
4909 --
4910 process_action_item
4911 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4912 ,p_actn_typ_id => l_actn_typ_id
4913 ,p_cmpltd_dt => l_cmpltd_dt
4914 ,p_object_version_number => l_object_version_number
4915 ,p_effective_date => p_effective_date
4916 ,p_rqd_data_found => FALSE
4917 ,p_rqd_flag => l_rqd_flag
4918 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4919 ,p_post_rslt_flag => p_post_rslt_flag
4920 ,p_business_group_id => p_business_group_id
4921 ,p_datetrack_mode => p_datetrack_mode
4922 ,p_rslt_object_version_number => p_rslt_object_version_number);
4923 --
4924 -- Since the action item was opened/reopened, set the flag to TRUE and
4925 -- also the p_hack flag to 'N' so that the calling procedure knows
4926 -- that action items were actually written and this not to fool it.
4927 --
4928 p_dd_actn_item_open := TRUE;
4929 p_hack := 'N';
4930 --
4931 -- Also, delete all other "dependent" action items that might exist for
4932 -- the prtt_enrt_rslt_id.
4933 --
4934 if g_debug then
4935 hr_utility.set_location('Deleting other dpnt actn items', 10);
4936 end if;
4937 --
4938 for actn_item_rec in c_other_dpnt_actn_items loop
4939 --
4940 delete_action_item
4941 (p_prtt_enrt_actn_id => actn_item_rec.prtt_enrt_actn_id
4942 ,p_object_version_number => actn_item_rec.object_version_number
4943 ,p_business_group_id => p_business_group_id
4944 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4945 ,p_rslt_object_version_number => p_rslt_object_version_number
4946 ,p_effective_date => p_effective_date
4947 ,p_datetrack_mode => hr_api.g_zap
4948 ,p_post_rslt_flag => p_post_rslt_flag);
4949 --
4950 end loop;
4951 else
4952 --
4953 -- The option does not allow designation of any dependents. Don't write
4954 -- any DD action items.
4955 --
4956 --
4957 -- Set the parameter to TRUE and the hack flag to 'Y' so that the
4958 -- calling procedure does not check for dpnt missing info.
4959 --
4960 p_dd_actn_item_open := TRUE;
4961 p_hack := 'Y';
4962 --
4963 End if;
4964 --
4965 else
4966 --
4967 if g_debug then
4968 hr_utility.set_location('Dpnts designated', 10);
4969 end if;
4970 --
4971 -- Dependents found. Set the out parameter.
4972 --
4973 p_dd_actn_item_open := FALSE;
4974 --
4975 -- If a DD action item was found, we need to complete it. Set the
4976 -- p_rqd_data_found flag to TRUE so that the process_action_item can
4977 -- close the DD action item.
4978 --
4979 process_action_item
4980 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4981 ,p_actn_typ_id => l_actn_typ_id
4982 ,p_cmpltd_dt => l_cmpltd_dt
4983 ,p_object_version_number => l_object_version_number
4984 ,p_effective_date => p_effective_date
4985 ,p_rqd_data_found => TRUE
4986 ,p_rqd_flag => l_rqd_flag
4987 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4988 ,p_post_rslt_flag => p_post_rslt_flag
4989 ,p_business_group_id => p_business_group_id
4990 ,p_datetrack_mode => p_datetrack_mode
4991 ,p_rslt_object_version_number => p_rslt_object_version_number);
4992 end if;
4993 --
4994 close c_dpnt_dsgn;
4995 --
4996 end if;
4997 --
4998 if g_debug then
4999 hr_utility.set_location('Leaving ' ||l_proc,10);
5000 end if;
5001 --
5002 exception
5003 when others then
5004 if g_debug then
5005 hr_utility.set_location('Exception Raised '||l_proc, 10);
5006 end if;
5007 p_rslt_object_version_number := l_rslt_object_version_number ;
5008 p_dd_actn_item_open := null;
5009 p_hack := null;
5010
5011 raise;
5012 --
5013 end determine_dpnt_actn_items;
5014 --
5015 -- ----------------------------------------------------------------------------
5016 -- |-----------------< complete_dependent_designation >-----------------------|
5017 -- ----------------------------------------------------------------------------
5018 --
5019 procedure complete_dependent_designation
5020 (p_prtt_enrt_rslt_id in number
5021 ,p_effective_date in date
5022 ,p_business_group_id in number
5023 ,p_datetrack_mode in varchar2 default hr_api.g_correction
5024 ,p_post_rslt_flag in varchar2 default 'Y'
5025 ,p_dsgn_cd in varchar2
5026 ,p_rslt_object_version_number in out nocopy number
5027 ,p_dpnt_actn_warning in out nocopy boolean) is
5028 --
5029 -- this procedure determines if desginated dependents meet all the criteria
5030 -- to complete an open DD action item. The participant can change plans to
5031 -- where designation requirements such as the minimum number of dependents or
5032 -- maximum number of dependents has changed. If a participant changes option
5033 -- within a plan they are required to re-designate their dependents so this is
5034 -- only relevent for a 'plan' change.
5035 --
5036 l_proc varchar2(80) ;
5037 --
5038 l_meets_rqmt varchar2(1) := 'Y';
5039 l_actn_typ_id number(15);
5040 l_cmpltd_dt date;
5041 l_object_version_number number;
5042 l_prtt_enrt_actn_id ben_prtt_enrt_actn_f.prtt_enrt_actn_id%type;
5043 l_rslt_object_version_number number(15);
5044 l_dpnt_actn_warning boolean ;
5045 --
5046 --
5047 -- look for dsgn rqmt records that have no group code. These indicate
5048 -- a general mininum (and/or maximum) number of dpnts that can be
5049 -- designated for this comp object.
5050 --
5051 cursor c_min_no_grp is
5052 select mn_dpnts_rqd_num
5053 from ben_prtt_enrt_rslt_f perslt,
5054 ben_dsgn_rqmt_f drq
5055 where perslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5056 and perslt.prtt_enrt_rslt_stat_cd is null
5057 and drq.dsgn_typ_cd = 'DPNT'
5058 and drq.grp_rlshp_cd is null
5059 and (nvl(drq.pl_id,0) = perslt.pl_id
5060 or
5061 nvl(drq.oipl_id,0) = perslt.oipl_id
5062 or
5063 nvl(drq.opt_id,0) = (select o.opt_id
5064 from ben_oipl_f o
5065 where o.oipl_id = perslt.oipl_id
5066 and p_effective_date
5067 between o.effective_start_date
5068 and o.effective_end_date)
5069 )
5070 and drq.business_group_id = p_business_group_id
5071 and p_effective_date between drq.effective_start_date
5072 and drq.effective_end_date
5073 and perslt.business_group_id = p_business_group_id
5074 and p_effective_date between perslt.effective_start_date
5075 and perslt.effective_end_date;
5076 --
5077 l_min_no_grp c_min_no_grp%rowtype;
5078 --
5079 cursor c_num_of_dpnts is
5080 select count(1) cnt
5081 from ben_elig_cvrd_dpnt_f ecd,
5082 ben_per_in_ler pil
5083 where p_prtt_enrt_rslt_id = ecd.prtt_enrt_rslt_id
5084 and ecd.cvg_strt_dt is not null
5085 and nvl(ecd.cvg_thru_dt, hr_api.g_eot) = hr_api.g_eot
5086 and ecd.business_group_id = p_business_group_id
5087 and p_effective_date between ecd.effective_start_date
5088 and ecd.effective_end_date
5089 and pil.per_in_ler_id=ecd.per_in_ler_id
5090 and pil.business_group_id=p_business_group_id
5091 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
5092 --
5093 l_num_of_dpnts c_num_of_dpnts%rowtype;
5094 --
5095 -- Select 'x' where there are dsgn rqmts for specific contact types
5096 -- and we don't have the minimum number of that contact type
5097 -- designated.
5098 --
5099 cursor c_min_typ is
5100 select distinct 'X' -- mn_dpnts_rqd_num
5101 from ben_prtt_enrt_rslt_f perslt,
5102 ben_dsgn_rqmt_f drq
5103 where perslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5104 and drq.dsgn_typ_cd = 'DPNT'
5105 and drq.grp_rlshp_cd is not null
5106 and perslt.prtt_enrt_rslt_stat_cd is null
5107 and (nvl(drq.pl_id,0) = perslt.pl_id
5108 or
5109 nvl(drq.oipl_id,0) = perslt.oipl_id
5110 or
5111 nvl(drq.opt_id,0) = (select o.opt_id
5112 from ben_oipl_f o
5113 where o.oipl_id = perslt.oipl_id
5114 and p_effective_date
5115 between o.effective_start_date
5116 and o.effective_end_date)
5117 )
5118 and drq.business_group_id = p_business_group_id
5119 and p_effective_date between drq.effective_start_date
5120 and drq.effective_end_date
5121 and perslt.business_group_id = p_business_group_id
5122 and p_effective_date between perslt.effective_start_date
5123 and perslt.effective_end_date
5124 and mn_dpnts_rqd_num >
5125 (select count(1)
5126 from ben_elig_cvrd_dpnt_f ecd,
5127 per_contact_relationships pcr,
5128 ben_per_in_ler pil
5129 where ecd.prtt_enrt_rslt_id = perslt.prtt_enrt_rslt_id
5130 and ecd.cvg_strt_dt is not null
5131 and nvl(ecd.cvg_thru_dt, hr_api.g_eot) = hr_api.g_eot
5132 and ecd.business_group_id = p_business_group_id
5133 and p_effective_date between
5134 ecd.effective_start_date and ecd.effective_end_date
5135 and perslt.person_id = pcr.person_id
5136 and ecd.dpnt_person_id = pcr.contact_person_id
5137 and pcr.business_group_id = p_business_group_id
5138 and pcr.contact_type in
5139 (select drrt.rlshp_typ_cd
5140 from ben_dsgn_rqmt_rlshp_typ drrt
5141 where drrt.dsgn_rqmt_id = drq.dsgn_rqmt_id)
5142 and pil.per_in_ler_id=ecd.per_in_ler_id
5143 and pil.business_group_id=p_business_group_id
5144 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT'));
5145 --
5146 l_min_typ c_min_typ%rowtype;
5147 l_rqd_flag varchar2(30);
5148 --
5149 begin
5150 --
5151 if g_debug then
5152 l_proc := g_package||'.complete_dependent_designation';
5153 hr_utility.set_location ('Entering '||l_proc,10);
5154 end if;
5155 --
5156 l_rslt_object_version_number :=p_rslt_object_version_number;
5157 l_dpnt_actn_warning :=p_dpnt_actn_warning ;
5158
5159 --
5160 -- Check the total number of dpnts designated. See if it's less
5161 -- than the minimum number of dpnts of any contact type. There
5162 -- should only be one rqmt record with no group code for this
5163 -- comp object, so no need for a loop.
5164 --
5165 open c_min_no_grp;
5166 fetch c_min_no_grp into l_min_no_grp;
5167 --
5168 if c_min_no_grp%FOUND and
5169 nvl(l_min_no_grp.mn_dpnts_rqd_num,0) > 0 then
5170 --
5171 open c_num_of_dpnts;
5172 fetch c_num_of_dpnts into l_num_of_dpnts;
5173 --
5174 if l_num_of_dpnts.cnt < l_min_no_grp.mn_dpnts_rqd_num then
5175 -- create action item for additional dpnts needed.
5176 l_meets_rqmt := 'N';
5177 end if;
5178 --
5179 close c_num_of_dpnts;
5180 --
5181 end if;
5182 --
5183 close c_min_no_grp;
5184 --
5185 if g_debug then
5186 hr_utility.set_location ('After c_min_no_grp '||l_proc,20);
5187 end if;
5188 --
5189 -- Check the other dsgn rqmts. If there are any rows returned from
5190 -- this cursor, then the person must designate more dependents of
5191 -- some contact type.
5192 --
5193 open c_min_typ;
5194 fetch c_min_typ into l_min_typ;
5195 --
5196 if c_min_typ%FOUND then
5197 -- create action item for additional dpnts needed.
5198 l_meets_rqmt := 'N';
5199 end if;
5200 --
5201 close c_min_typ;
5202 --
5203 if g_debug then
5204 hr_utility.set_location ('After c_min_typ '||l_proc,30);
5205 end if;
5206 --
5207 --
5208 -- find DDADDNL action item, if it exists.
5209 --
5210 l_actn_typ_id := get_actn_typ_id
5211 (p_type_cd => 'DDADDNL'
5212 ,p_business_group_id => p_business_group_id);
5213 --
5214 get_prtt_enrt_actn_id
5215 (p_actn_typ_id => l_actn_typ_id
5216 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5217 ,p_effective_date => p_effective_date
5218 ,p_business_group_id => p_business_group_id
5219 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
5220 ,p_cmpltd_dt => l_cmpltd_dt
5221 ,p_object_version_number => l_object_version_number);
5222 --
5223 if g_debug then
5224 hr_utility.set_location ('After get_prtt_enrt_actn_id call '||l_proc,30);
5225 end if;
5226 --
5227 if p_dsgn_cd = 'R' then
5228 l_rqd_flag := 'Y';
5229 else
5230 l_rqd_flag := 'N';
5231 end if;
5232 --
5233 if l_meets_rqmt = 'Y' then
5234 --
5235 if g_debug then
5236 hr_utility.set_location('Meets addnl dpnt rqmts', 10);
5237 end if;
5238 --
5239 -- they meet the minimum number of dpnts, call process-action-item with
5240 -- rqd-data 'true'
5241 --
5242 process_action_item
5243 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
5244 ,p_actn_typ_id => l_actn_typ_id
5245 ,p_cmpltd_dt => l_cmpltd_dt
5246 ,p_object_version_number => l_object_version_number
5247 ,p_effective_date => p_effective_date
5248 ,p_rqd_data_found => TRUE
5249 ,p_rqd_flag => l_rqd_flag
5250 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5251 ,p_post_rslt_flag => p_post_rslt_flag
5252 ,p_business_group_id => p_business_group_id
5253 ,p_datetrack_mode => p_datetrack_mode
5254 ,p_rslt_object_version_number => p_rslt_object_version_number);
5255 --
5256 elsif l_meets_rqmt = 'N' then
5257 --
5258 if g_debug then
5259 hr_utility.set_location('Does not meet rqmts', 10);
5260 end if;
5261 --
5262 --
5263 -- Doesn't meet requirements. set rqd-data 'FALSE'
5264 --
5265 process_action_item
5266 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
5267 ,p_actn_typ_id => l_actn_typ_id
5268 ,p_cmpltd_dt => l_cmpltd_dt
5269 ,p_object_version_number => l_object_version_number
5270 ,p_effective_date => p_effective_date
5271 ,p_rqd_data_found => FALSE
5272 ,p_rqd_flag => l_rqd_flag
5273 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5274 ,p_post_rslt_flag => p_post_rslt_flag
5275 ,p_business_group_id => p_business_group_id
5276 ,p_datetrack_mode => p_datetrack_mode
5277 ,p_rslt_object_version_number => p_rslt_object_version_number);
5278 --
5279 end if;
5280 --
5281 -- Pass a warning back to the calling proc only if the requirements are not
5282 -- met and the incoming value was FALSE.
5283 --
5284 if l_meets_rqmt = 'N' and p_dpnt_actn_warning = FALSE then
5285 p_dpnt_actn_warning := TRUE;
5286 end if;
5287 --
5288 if g_debug then
5289 hr_utility.set_location ('Leaving ' ||l_proc,90);
5290 end if;
5291 --
5292 exception
5293 when others then
5294 if g_debug then
5295 hr_utility.set_location('Exception Raised '||l_proc, 99);
5296 end if;
5297 p_rslt_object_version_number := l_rslt_object_version_number;
5298 p_dpnt_actn_warning := l_dpnt_actn_warning ;
5299 raise;
5300 --
5301 end complete_dependent_designation;
5302 --
5303 -- ----------------------------------------------------------------------------
5304 -- |----------------------< process_dpnt_actn_items >-------------------------|
5305 -- ----------------------------------------------------------------------------
5306 --
5307 procedure process_dpnt_actn_items
5308 (p_validate in boolean default FALSE
5309 ,p_prtt_enrt_rslt_id in number
5310 ,p_effective_date in date
5311 ,p_business_group_id in number
5312 ,p_datetrack_mode in varchar2 default hr_api.g_correction
5313 ,p_post_rslt_flag in varchar2 default 'Y'
5314 ,p_rslt_object_version_number in out nocopy number
5315 ,p_suspend_flag in out nocopy varchar2
5316 ,p_dpnt_actn_warning out nocopy boolean
5317 --Bug No 4525608 to capture the certification required warning
5318 ,p_ctfn_actn_warning out nocopy boolean) is
5319 --End Bug 4525608
5320 --
5321 l_proc varchar2(80);
5322 l_rslt_object_version_number number(15);
5323 l_suspend_flag varchar2(15);
5324
5325 --
5326 l_dd_actn_item_open boolean := FALSE; -- flag is set to TRUE if a DD actn item
5327 -- is written/opened.
5328 l_dpnt_actn_warning boolean := FALSE;
5329
5330 --Bug No 4525608 Addtional local parameter
5331 l_ctfn_actn_warning boolean := FALSE;
5332 --End Bug 4525608
5333
5334 l_hack varchar2(1) := 'N';
5335 l_allws_flag varchar2(30);
5336 l_dsgn_cd varchar2(30);
5337
5338 cursor c_chc_flags is
5339 select epe.alws_dpnt_dsgn_flag, epe.dpnt_dsgn_cd
5340 from ben_prtt_enrt_rslt_f pen,
5341 ben_elig_per_elctbl_chc epe,
5342 ben_per_in_ler pil
5343 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5344 and pen.prtt_enrt_rslt_stat_cd is null
5345 and p_effective_date between
5346 pen.effective_start_date and pen.effective_end_date
5347 -- Join by comp object not result_id
5348 and nvl(pen.pgm_id,-1)=nvl(epe.pgm_id,-1)
5349 and pen.pl_id=epe.pl_id
5350 and epe.bnft_prvdr_pool_id is null -- Bug 2389261 exclude these records
5351 and nvl(pen.oipl_id,-1)=nvl(epe.oipl_id,-1)
5352 -- and pen.prtt_enrt_rslt_id = epe.prtt_enrt_rslt_id
5353 and pen.per_in_ler_id = epe.per_in_ler_id
5354 and epe.business_group_id = p_business_group_id
5355 and pil.per_in_ler_id = epe.per_in_ler_id
5356 and pil.business_group_id = p_business_group_id
5357 and pil.per_in_ler_stat_cd not in ('VOIDD', 'BCKDT');
5358 --
5359 begin
5360 --
5361 g_debug := hr_utility.debug_enabled;
5362 if g_debug then
5363 l_proc := g_package||'.process_dpnt_actn_items';
5364 hr_utility.set_location ('Entering '||l_proc,10);
5365 end if;
5366 --
5367 l_rslt_object_version_number :=p_rslt_object_version_number;
5368 l_suspend_flag :=p_suspend_flag ;
5369
5370
5371 -- Issue a savepoint if operating in validate only mode
5372 --
5373 savepoint process_dpnt_actn_items;
5374 --
5375 open c_chc_flags;
5376 fetch c_chc_flags into l_allws_flag, l_dsgn_cd;
5377 if c_chc_flags%notfound then
5378 l_allws_flag := 'N';
5379 l_dsgn_cd := 'O';
5380 end if;
5381 close c_chc_flags;
5382 --
5383 -- BUG:3248711: Since epe.alws_dpnt_dsgn_flag = 'N' (LE doesn't allow dpnt dsgn)
5384 -- and yet epe.dpnt_dsgn_cd = 'R' (Dpnt Dsgn is Required)
5385 -- In this case.. we'll have to show the the message that 'Dpnt design is pending'
5386 -- and also suspend the plan. Hence the or-condition (l_dsgn_cd = 'R') as been added
5387 -- to below if-condition
5388
5389 if ( (l_allws_flag = 'Y') or (l_dsgn_cd = 'R') ) then
5390
5391 determine_dpnt_actn_items
5392 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5393 ,p_rslt_object_version_number => p_rslt_object_version_number
5394 ,p_effective_date => p_effective_date
5395 ,p_business_group_id => p_business_group_id
5396 ,p_datetrack_mode => p_datetrack_mode
5397 ,p_post_rslt_flag => p_post_rslt_flag
5398 ,p_allws_flag => l_allws_flag
5399 ,p_dsgn_cd => l_dsgn_cd
5400 ,p_dd_actn_item_open => l_dd_actn_item_open
5401 ,p_hack => l_hack);
5402 --
5403 if l_dd_actn_item_open = FALSE then
5404 --
5405 -- The following is executed only if a DD action item was not written, i.e.
5406 -- dependents were found
5407 --
5408 determine_dpnt_miss_actn_items
5409 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5410 ,p_effective_date => p_effective_date
5411 ,p_business_group_id => p_business_group_id
5412 ,p_datetrack_mode => p_datetrack_mode
5413 ,p_post_rslt_flag => p_post_rslt_flag
5414 ,p_rslt_object_version_number => p_rslt_object_version_number
5415 ,p_dpnt_actn_warning => l_dpnt_actn_warning);
5416 --
5417 complete_dependent_designation
5418 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5419 ,p_effective_date => p_effective_date
5420 ,p_business_group_id => p_business_group_id
5421 ,p_datetrack_mode => p_datetrack_mode
5422 ,p_post_rslt_flag => p_post_rslt_flag
5423 ,p_dsgn_cd => l_dsgn_cd
5424 ,p_rslt_object_version_number => p_rslt_object_version_number
5425 ,p_dpnt_actn_warning => l_dpnt_actn_warning);
5426 --
5427 --Bug No 4525608
5428 --Passed additional parameter p_ctfn_actn_warning
5429 --to capture the certification action warning
5430 determine_other_actn_items
5431 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5432 ,p_rslt_object_version_number => p_rslt_object_version_number
5433 ,p_effective_date => p_effective_date
5434 ,p_post_rslt_flag => p_post_rslt_flag
5435 ,p_business_group_id => p_business_group_id
5436 ,p_validate => FALSE
5437 ,p_datetrack_mode => p_datetrack_mode
5438 ,p_suspend_flag => l_suspend_flag
5439 ,p_ctfn_actn_warning => l_ctfn_actn_warning);
5440 --End Bug 4525608
5441 --
5442 else
5443 --
5444 -- l_dd_actn_item_open is TRUE. Set l_dpnt_actn_warning to TRUE to indicate
5445 -- that an action item has been written or reopened
5446 --
5447 if l_hack = 'Y' then
5448 -- This indicates that the l_dd_actn_item_open was set to TRUE only to
5449 -- fool this process to not check for dependent mising items and no
5450 -- DD action item was written. Set the l_dpnt_actn_warning to FALSE
5451 --
5452 l_dpnt_actn_warning := FALSE;
5453 else
5454 l_dpnt_actn_warning := TRUE;
5455 end if;
5456 --
5457 end if;
5458 --
5459 end if; -- allws_dpnt_flag = 'Y'
5460 --
5461 p_dpnt_actn_warning := l_dpnt_actn_warning;
5462
5463 --Bug No 4525608 capture the certification required action item warning
5464 p_ctfn_actn_warning := l_ctfn_actn_warning;
5465 -- End Bug No 4525608
5466
5467 --
5468 if p_validate then
5469 raise hr_api.validate_enabled;
5470 end if;
5471 --
5472 if g_debug then
5473 hr_utility.set_location ('Leaving '||l_proc, 10);
5474 end if;
5475 --
5476 exception
5477 --
5478 when hr_api.validate_enabled
5479 then
5480 rollback to process_dpnt_actn_items;
5481 --
5482 if g_debug then
5483 hr_utility.set_location(' Leaving:'||l_proc, 10);
5484 end if;
5485 --
5486 when others then
5487 if g_debug then
5488 hr_utility.set_location('Exception Raised '||l_proc, 10);
5489 end if;
5490
5491 p_rslt_object_version_number := l_rslt_object_version_number ;
5492 p_suspend_flag := l_suspend_flag ;
5493 p_dpnt_actn_warning := null ;
5494
5495 --Bug No 4525608 when any exception
5496 p_ctfn_actn_warning := null ;
5497 --End Bug No 4525608
5498
5499 raise;
5500 --
5501 end process_dpnt_actn_items;
5502 --
5503 procedure check_ctfn_prvdd
5504 (p_prtt_enrt_rslt_id in number
5505 ,p_effective_date in date
5506 ,p_business_group_id in number
5507 ,p_enrt_ctfn_typ_cd in varchar2
5508 ,p_oipl_id in number
5509 ,p_rqd_flag in varchar2
5510 ,p_pl_id in number
5511 ,p_per_in_ler_id in number
5512 ,p_bnft_amt in number
5513 ,p_ctfn_determine_cd in varchar2
5514 ,p_crntly_enrd_flag in varchar2
5515 ,p_enrt_r_bnft_ctfn_cd in varchar2 default null -- Bug 5887665
5516 ,p_ctfn_prvdd out nocopy boolean) is
5517 --
5518 --Determine the level of the certification
5519 --
5520 cursor c_pl_ctfn ( p_pl_id number,
5521 p_per_in_ler_id number,
5522 p_effective_date date,
5523 p_enrt_ctfn_typ_cd varchar2 ) is
5524 select 'Y'
5525 from ben_ler_rqrs_enrt_ctfn_f lre,
5526 ben_ler_enrt_ctfn_f lec,
5527 ben_per_in_ler pil
5528 where lre.pl_id = p_pl_id
5529 and pil.per_in_ler_id = p_per_in_ler_id
5530 and lre.ler_id = pil.ler_id
5531 and p_effective_date between lre.effective_start_date
5532 and lre.effective_end_date
5533 and p_effective_date between lec.effective_start_date
5534 and lec.effective_end_date
5535 and lec.ler_rqrs_enrt_ctfn_id = lre.ler_rqrs_enrt_ctfn_id
5536 and lec.enrt_ctfn_typ_cd = p_enrt_ctfn_typ_cd
5537 union
5538 select 'Y'
5539 from ben_enrt_ctfn_f ec
5540 where ec.pl_id = p_pl_id
5541 and p_effective_date between ec.effective_start_date
5542 and ec.effective_end_date
5543 and ec.enrt_ctfn_typ_cd = p_enrt_ctfn_typ_cd ;
5544 --
5545 --Determine if currently enrolled at the plan level
5546 --
5547 /* ikasire
5548 Bug 4454990 See the details below. Keep in mind that this happens before the
5549 delete enrollment call from election information.
5550 So these are the following cases we need to keep in mind. If you see issues
5551 please do add the example here so that the future developer won't intruduce another
5552 regression.
5553
5554 Here is the status of the records when this procedure is being called
5555
5556 LE1 LE2
5557
5558 |------------------------------------|---------------------------------------------
5559
5560 Case 1: Continuing in the same enrollment
5561 OldOipl OldOipl
5562 OldPIL NewPIL
5563 OldPEN OldPEN
5564 CTD EOT
5565 EED EOT
5566
5567 Case 2: Continuing in the same enrollment save and then change with new option again
5568
5569 OldOipl OldOipl
5570 OldPIL NewPIL
5571 OldPEN OldPEN
5572 CTD EOT
5573 EED EOT
5574 [the data will change once the delete enrollment is called]
5575 NewOipl
5576 NewPIL
5577 NewPEN
5578 CTD EOT
5579 EED EOT
5580
5581 Case 3: Replace the enrollment with a new Plan Option
5582
5583 OldOipl OldOipl
5584 OldPIL OldPIL [Important]
5585 OldPEN OldPEN
5586 CTD EOT
5587 EED EOT
5588 [the data will change once the delete enrollment is called]
5589 NewOipl
5590 NewPIL
5591 NewPEN
5592 CTD EOT
5593 EED EOT
5594
5595 Case 4: delete the current enrollment and enroll in a new one later
5596
5597 OldOipl OldOipl
5598 OldPIL NewPIL
5599 OldPEN OldPEN
5600 CTD Date will be filled in
5601 EED EOT
5602 [the data will change once the delete enrollment is called]
5603 NewOipl
5604 NewPIL
5605 NewPEN
5606 CTD EOT
5607 EED EOT
5608
5609 */
5610
5611 cursor c_current_pl_enrollment (p_prtt_enrt_rslt_id number) is
5612 select 'Y'
5613 from ben_prtt_enrt_rslt_f pen,
5614 ben_prtt_enrt_rslt_f pen2
5615 where pen2.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5616 and nvl(pen2.rplcs_sspndd_rslt_id,-999) <> pen.prtt_enrt_rslt_id --NO Interim
5617 and pen2.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')
5618 and pen2.pl_id = pen.pl_id
5619 and pen2.person_id = pen.person_id
5620 and pen.sspndd_flag = 'N'
5621 and (
5622 ( pen2.per_in_ler_id = pen.per_in_ler_id and
5623 ( pen.enrt_cvg_thru_dt <> to_date('31-12-4712','dd-mm-yyyy') or
5624 ( (-- pen.prtt_enrt_rslt_id <> pen2.prtt_enrt_rslt_id and
5625 exists (select 'x' from ben_elig_per_elctbl_chc epe,
5626 ben_prtt_enrt_rslt_f pen3
5627 where epe.per_in_ler_id = pen.per_in_ler_id and
5628 epe.pl_id = pen.pl_id and
5629 ( epe.pgm_id = pen.pgm_id or pen.pgm_id is null) and
5630 ( epe.oipl_id = pen.oipl_id or pen.oipl_id is null) and
5631 epe.crntly_enrd_flag = 'Y' and
5632 epe.elctbl_flag = 'Y' and
5633 epe.bnft_prvdr_pool_id is null and
5634 pen3.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id and
5635 pen3.prtt_enrt_rslt_stat_cd is null and
5636 pen3.sspndd_flag = 'N' and
5637 pen3.effective_end_date = pen.effective_start_date - 1
5638 )
5639 ) and
5640 pen.enrt_cvg_thru_dt = to_date('31-12-4712','dd-mm-yyyy')
5641 )
5642 ) and
5643 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')
5644 )
5645 or
5646 ( pen.enrt_cvg_thru_dt = to_date('31-12-4712','dd-mm-yyyy') and
5647 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy') and
5648 pen.per_in_ler_id <> pen2.per_in_ler_id
5649 )
5650 )
5651 and pen2.prtt_enrt_rslt_stat_cd is null
5652 and pen.prtt_enrt_rslt_stat_cd is null ;
5653 --
5654 --Current Option enrollment
5655 --
5656 cursor c_current_oipl_enrollment (p_prtt_enrt_rslt_id number) is
5657 select 'Y'
5658 from ben_prtt_enrt_rslt_f pen,
5659 ben_prtt_enrt_rslt_f pen2
5660 where pen2.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5661 and nvl(pen2.rplcs_sspndd_rslt_id,-999) <> pen.prtt_enrt_rslt_id --NO Interim
5662 and pen2.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')
5663 and pen2.pl_id = pen.pl_id
5664 and pen2.oipl_id = pen.oipl_id
5665 and pen2.person_id = pen.person_id
5666 and pen.sspndd_flag = 'N'
5667 and (
5668 ( pen2.per_in_ler_id = pen.per_in_ler_id and
5669 ( pen.enrt_cvg_thru_dt <> to_date('31-12-4712','dd-mm-yyyy') or
5670 ( (-- pen.prtt_enrt_rslt_id <> pen2.prtt_enrt_rslt_id or
5671 exists (select 'x' from ben_elig_per_elctbl_chc epe,
5672 ben_prtt_enrt_rslt_f pen3
5673 where epe.per_in_ler_id = pen2.per_in_ler_id and
5674 epe.pl_id = pen2.pl_id and
5675 ( epe.pgm_id = pen2.pgm_id or pen2.pgm_id is null) and
5676 ( epe.oipl_id = pen2.oipl_id ) and
5677 epe.crntly_enrd_flag = 'Y' and
5678 epe.elctbl_flag = 'Y' and
5679 epe.bnft_prvdr_pool_id is null and
5680 pen3.prtt_enrt_rslt_id = pen2.prtt_enrt_rslt_id and
5681 pen3.prtt_enrt_rslt_stat_cd is null and
5682 pen3.sspndd_flag = 'N' and
5683 pen3.effective_end_date = pen2.effective_start_date - 1
5684 )
5685 ) and
5686 pen.enrt_cvg_thru_dt = to_date('31-12-4712','dd-mm-yyyy')
5687 )
5688 ) and
5689 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')
5690 )
5691 or
5692 ( pen.enrt_cvg_thru_dt = to_date('31-12-4712','dd-mm-yyyy') and
5693 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy') and
5694 pen.per_in_ler_id <> pen2.per_in_ler_id
5695 )
5696 )
5697 and pen2.prtt_enrt_rslt_stat_cd is null
5698 and pen.prtt_enrt_rslt_stat_cd is null ;
5699 --
5700 --End Determine the level of the certification
5701 --
5702
5703 --
5704 -- Bug 5965415 : Updated the cursor to check if any certification received in past
5705 -- for the same plan-option (and not based on pen_id as it changes
5706 -- when coverage amount changes)
5707 --
5708 cursor c_ctfn_prvdd (p_prtt_enrt_rslt_id number) is
5709 select null
5710 from ben_prtt_enrt_ctfn_prvdd_f pcs
5711 where pcs.prtt_enrt_rslt_id in
5712 (select distinct(pen1.prtt_enrt_rslt_id) from ben_prtt_enrt_rslt_f pen1, ben_prtt_enrt_rslt_f pen2
5713 where pen2.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5714 and pen1.person_id = pen2.person_id
5715 and pen1.prtt_enrt_rslt_stat_cd is null
5716 and pen2.prtt_enrt_rslt_stat_cd is null
5717 and pen1.pl_id = pen2.pl_id
5718 and pen1.per_in_ler_id <> pen2.per_in_ler_id
5719 and nvl(pen2.oipl_id,0) = nvl(pen1.oipl_id,0)
5720 and pen1.enrt_cvg_thru_dt >= pen1.effective_start_date
5721 and pen1.enrt_cvg_strt_dt <= pen1.enrt_cvg_thru_dt
5722 and pen2.enrt_cvg_thru_dt = to_date('4712/12/31','rrrr/mm/dd')
5723 and p_effective_date between pen2.effective_start_date and
5724 pen2.effective_end_date
5725 and pen1.orgnl_enrt_dt = pen2.orgnl_enrt_dt)
5726 and pcs.ENRT_CTFN_TYP_CD = p_enrt_ctfn_typ_cd
5727 and pcs.ENRT_CTFN_RECD_DT is not null
5728 and pcs.enrt_ctfn_rqd_flag = 'Y'
5729 and pcs.ENRT_R_BNFT_CTFN_CD = nvl(p_enrt_r_bnft_ctfn_cd,'ENRT') -- Bug 5887665
5730 ---Bug 7417593
5731 /* and p_effective_date between pcs.effective_start_date and
5732 pcs.effective_end_date*/
5733 and p_effective_date > pcs.enrt_ctfn_recd_dt
5734 ---Bug 7417593
5735 ;
5736 --
5737 cursor c_ctfn_prvdd2 (p_prtt_enrt_rslt_id number) is
5738 select null
5739 from ben_prtt_enrt_ctfn_prvdd_f pcs
5740 where pcs.prtt_enrt_rslt_id in
5741 (select distinct(pen1.prtt_enrt_rslt_id) from ben_prtt_enrt_rslt_f pen1, ben_prtt_enrt_rslt_f pen2
5742 where pen2.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5743 and pen1.person_id = pen2.person_id
5744 and pen1.prtt_enrt_rslt_stat_cd is null
5745 and pen2.prtt_enrt_rslt_stat_cd is null
5746 and pen1.pl_id = pen2.pl_id
5747 and pen1.per_in_ler_id <> pen2.per_in_ler_id
5748 and nvl(pen2.oipl_id,0) = nvl(pen1.oipl_id,0)
5749 and pen1.enrt_cvg_thru_dt >= pen1.effective_start_date
5750 and pen1.enrt_cvg_strt_dt <= pen1.enrt_cvg_thru_dt
5751 and pen2.enrt_cvg_thru_dt = to_date('4712/12/31','rrrr/mm/dd')
5752 and p_effective_date between pen2.effective_start_date and
5753 pen2.effective_end_date
5754 and pen1.orgnl_enrt_dt = pen2.orgnl_enrt_dt)
5755 and pcs.ENRT_CTFN_RECD_DT is not null
5756 and pcs.ENRT_R_BNFT_CTFN_CD = nvl(p_enrt_r_bnft_ctfn_cd,'ENRT') -- Bug 5887665
5757 and pcs.enrt_ctfn_rqd_flag = 'N'
5758 and exists (select null from ben_prtt_enrt_ctfn_prvdd_f pcs2
5759 where pcs2.prtt_enrt_rslt_id = pcs.prtt_enrt_rslt_id
5760 and pcs2.ENRT_CTFN_TYP_CD = p_enrt_ctfn_typ_cd
5761 and p_effective_date between pcs2.effective_start_date and
5762 pcs2.effective_end_date)
5763 and p_effective_date between pcs.effective_start_date and
5764 pcs.effective_end_date;
5765 --
5766 -- End Bug 5965415
5767 --
5768 cursor c_prtt_enrt_rslt (p_prtt_enrt_rslt_id number) is
5769 select pen.prtt_enrt_rslt_id
5770 from ben_prtt_enrt_rslt_f pen,
5771 ben_prtt_enrt_rslt_f pen2
5772 where pen2.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5773 -- and pen2.bnft_amt is null -- Bug 5887665 Need to call this code for benefit level certifications as well
5774 and pen2.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')
5775 and pen2.pl_id = pen.pl_id
5776 and pen2.person_id = pen.person_id
5777 and ((pen2.per_in_ler_id = pen.per_in_ler_id and
5778 pen2.oipl_id <> pen.oipl_id and -- Bug 5887665 Only in same LE we need to chk if option is changed
5779 pen.enrt_cvg_thru_dt <> to_date('31-12-4712','dd-mm-yyyy') and
5780 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')) or
5781 (pen.enrt_cvg_thru_dt = to_date('31-12-4712','dd-mm-yyyy') and
5782 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy') and -----Bug 7417474
5783 pen2.oipl_id = pen.oipl_id)) ----Bug 7417474
5784 and pen2.prtt_enrt_rslt_stat_cd is null
5785 and pen.prtt_enrt_rslt_stat_cd is null;
5786 --
5787 cursor c_ler_rstrn(p_effective_date date,
5788 p_per_in_ler_id number,
5789 p_pl_id number) is
5790 select rstrn.cvg_incr_r_decr_only_cd
5791 from ben_ler_bnft_rstrn_f rstrn,
5792 ben_per_in_ler pil
5793 where rstrn.ler_id = pil.ler_id
5794 and rstrn.pl_id = p_pl_id
5795 and pil.per_in_ler_id = p_per_in_ler_id
5796 and p_effective_date
5797 between rstrn.effective_start_date
5798 and rstrn.effective_end_date;
5799 --
5800 cursor c_pl_rstrn (p_effective_date date,
5801 p_pl_id number) is
5802 select pln.cvg_incr_r_decr_only_cd,
5803 pln.bnft_or_option_rstrctn_cd
5804 from ben_pl_f pln
5805 where pln.pl_id = p_pl_id
5806 and p_effective_date
5807 between pln.effective_start_date
5808 and pln.effective_end_date;
5809 --
5810 cursor c_prev_enrollment (p_prtt_enrt_rslt_id number) is
5811 select pen.bnft_amt
5812 from ben_prtt_enrt_rslt_f pen,
5813 ben_prtt_enrt_rslt_f pen2
5814 where pen2.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5815 and pen2.bnft_amt <> pen.bnft_amt
5816 and pen2.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')
5817 and pen2.pl_id = pen.pl_id
5818 and pen2.person_id = pen.person_id
5819 and ((pen2.per_in_ler_id = pen.per_in_ler_id and
5820 pen.enrt_cvg_thru_dt <> to_date('31-12-4712','dd-mm-yyyy') and
5821 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')) or
5822 (pen.enrt_cvg_thru_dt = to_date('31-12-4712','dd-mm-yyyy') and
5823 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')))
5824 and pen2.prtt_enrt_rslt_stat_cd is null
5825 and pen.prtt_enrt_rslt_stat_cd is null;
5826 --
5827 cursor c_new_dependent (p_prtt_enrt_rslt_id number) is
5828 select 'Y'
5829 from ben_elig_cvrd_dpnt_f egd
5830 where egd.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5831 and egd.per_in_ler_id = p_per_in_ler_id
5832 and egd.cvg_thru_dt = hr_api.g_eot
5833 and not exists (select null
5834 from ben_elig_cvrd_dpnt_f egd2
5835 where egd.elig_cvrd_dpnt_id = egd2.elig_cvrd_dpnt_id
5836 and egd.dpnt_person_id = egd2.dpnt_person_id
5837 and egd2.per_in_ler_id <> p_per_in_ler_id);
5838 --
5839 l_prtt_enrt_rslt_id number;
5840 l_ctfn_prvdd boolean := false;
5841 l_dummy varchar2(30) ;
5842 l_cvg_incr_code varchar2(240);
5843 l_old_amt number;
5844 l_bnft_or_option_rstrctn_cd VARCHAR2(30);
5845 l_cvg_incr_code_pln varchar(30);
5846
5847 --
5848 Begin
5849 --
5850 hr_utility.set_location('Entering - Check certification prvdd',10);
5851 --
5852 hr_utility.set_location('ctfn_determine_cd'||p_ctfn_determine_cd,11);
5853 hr_utility.set_location('enrt_ctfn_typ_cd'||p_enrt_ctfn_typ_cd,11);
5854 hr_utility.set_location('prtt_enrt_rslt_id'||p_prtt_enrt_rslt_id,11);
5855 hr_utility.set_location('enrt_r_bnft_ctfn_cd'||p_enrt_r_bnft_ctfn_cd,11);
5856 --bug#3748133
5857 /*
5858 if p_crntly_enrd_flag = 'Y' and p_ctfn_determine_cd = 'ENRFT' then
5859 if p_bnft_amt = 0 then
5860 l_ctfn_prvdd := TRUE;
5861 else
5862 --
5863 open c_prev_enrollment (p_prtt_enrt_rslt_id);
5864 fetch c_prev_enrollment into l_old_amt;
5865 close c_prev_enrollment;
5866 --
5867 if l_old_amt = p_bnft_amt then
5868 l_ctfn_prvdd := TRUE;
5869 end if;
5870 end if;
5871 end if;
5872 */
5873 --
5874 --BUG 4454990 Multiple Changes. See bug for the expected functionality
5875 --
5876 if p_ctfn_determine_cd = 'ENRFT' then
5877 --Check if the certification is defined at the plan level
5878 --If defined at the plan level, then need to see the previous enrollment in
5879 --any option in plan. If the ctfn is not defined at the plan level just check
5880 --for the currently enrolled
5881 --
5882 hr_utility.set_location(' p_ctfn_determine_cd = '||p_ctfn_determine_cd,122);
5883 --
5884 open c_pl_ctfn(p_pl_id,p_per_in_ler_id,p_effective_date,p_enrt_ctfn_typ_cd);
5885 fetch c_pl_ctfn into l_dummy;
5886 if c_pl_ctfn%found then
5887 --
5888 hr_utility.set_location(' Plan Level Cert',122);
5889 --
5890 open c_current_pl_enrollment(p_prtt_enrt_rslt_id);
5891 --
5892 fetch c_current_pl_enrollment into l_dummy;
5893 if c_current_pl_enrollment%found then
5894 hr_utility.set_location(' Plan Level - Currently Enrolled in',122);
5895 l_ctfn_prvdd := TRUE;
5896 end if;
5897 --
5898 close c_current_pl_enrollment;
5899 --
5900 elsif p_crntly_enrd_flag = 'Y' and p_oipl_id is not null then
5901 --
5902 hr_utility.set_location(' Option Level -',123);
5903 --Now we need to check if the previous enrollment was unsuspeded or not
5904 open c_current_oipl_enrollment(p_prtt_enrt_rslt_id);
5905 --
5906 fetch c_current_oipl_enrollment into l_dummy;
5907 if c_current_oipl_enrollment%found then
5908 hr_utility.set_location(' Option in Plan Level - Currently Enrolled in',122);
5909 l_ctfn_prvdd := TRUE;
5910 end if;
5911 --
5912 close c_current_oipl_enrollment;
5913 --
5914 else
5915 hr_utility.set_location('Not Currently Enrolled in- why here ', 123);
5916 end if;
5917 close c_pl_ctfn ;
5918 end if;
5919 --
5920 if not l_ctfn_prvdd and p_ctfn_determine_cd = 'ENRNP' then
5921 --
5922 if p_rqd_flag = 'Y' then
5923 open c_ctfn_prvdd (p_prtt_enrt_rslt_id);
5924 fetch c_ctfn_prvdd into l_dummy;
5925 if c_ctfn_prvdd%found then
5926 l_ctfn_prvdd := TRUE;
5927 end if;
5928 close c_ctfn_prvdd;
5929 --
5930 else
5931 --
5932 open c_ctfn_prvdd2 (p_prtt_enrt_rslt_id);
5933 fetch c_ctfn_prvdd2 into l_dummy;
5934 if c_ctfn_prvdd2%found then
5935 l_ctfn_prvdd := TRUE;
5936 end if;
5937 close c_ctfn_prvdd2;
5938 --
5939 end if;
5940 --
5941 end if;
5942 --
5943 if not l_ctfn_prvdd and p_oipl_id is not null and
5944 p_ctfn_determine_cd = 'ENRNP'then
5945 --
5946 hr_utility.set_location('different opt',12);
5947 open c_prtt_enrt_rslt(p_prtt_enrt_rslt_id);
5948 fetch c_prtt_enrt_rslt into l_prtt_enrt_rslt_id;
5949 close c_prtt_enrt_rslt;
5950 --
5951 hr_utility.set_location('Prtt result Id'||l_prtt_enrt_rslt_id,13);
5952 if l_prtt_enrt_rslt_id is not null then
5953 --
5954 if p_rqd_flag = 'Y' then
5955 hr_utility.set_location('inside',11);
5956 open c_ctfn_prvdd(l_prtt_enrt_rslt_id);
5957 fetch c_ctfn_prvdd into l_dummy;
5958 if c_ctfn_prvdd%found then
5959 l_ctfn_prvdd := TRUE;
5960 end if;
5961 close c_ctfn_prvdd;
5962 --
5963 else
5964 --
5965 open c_ctfn_prvdd2(l_prtt_enrt_rslt_id);
5966 fetch c_ctfn_prvdd2 into l_dummy;
5967 if c_ctfn_prvdd2%found then
5968 hr_utility.set_location('True',14);
5969 l_ctfn_prvdd := TRUE;
5970 end if;
5971 close c_ctfn_prvdd2;
5972 --
5973 end if;
5974 end if;
5975 end if;
5976 if not l_ctfn_prvdd and p_ctfn_determine_cd = 'ENRDP' then
5977 if p_crntly_enrd_flag = 'Y' then
5978 --check any new dependents designated
5979 l_dummy := null;
5980 open c_new_dependent(p_prtt_enrt_rslt_id);
5981 fetch c_new_dependent into l_dummy;
5982 close c_new_dependent;
5983 if l_dummy = 'Y' then
5984 l_ctfn_prvdd := FALSE;
5985 else
5986 l_ctfn_prvdd := TRUE;
5987 end if;
5988 else
5989 l_ctfn_prvdd := TRUE;
5990 end if;
5991 --
5992 end if;
5993 --
5994 --
5995 if not l_ctfn_prvdd and
5996 (p_ctfn_determine_cd is null or p_ctfn_determine_cd = 'ENRAT') then
5997 --check for increase/decrease certification -bug#3590524
5998 open c_ler_rstrn (p_effective_date, p_per_in_ler_id, p_pl_id);
5999 fetch c_ler_rstrn into l_cvg_incr_code;
6000 close c_ler_rstrn;
6001 --
6002 --if l_cvg_incr_code is null then
6003 open c_pl_rstrn (p_effective_date, p_pl_id);
6004 fetch c_pl_rstrn into l_cvg_incr_code_pln, l_bnft_or_option_rstrctn_cd;
6005 close c_pl_rstrn;
6006 --end if;
6007 l_cvg_incr_code := NVL(l_cvg_incr_code, l_cvg_incr_code_pln);
6008 --
6009 if l_cvg_incr_code is not null then
6010 --
6011 -- new enrollment
6012 --
6013 if (NVL(l_bnft_or_option_rstrctn_cd,'BNFT') = 'BNFT') then -- 5736589
6014 --
6015 if (p_crntly_enrd_flag is null or p_crntly_enrd_flag = 'N') then -- 3806262
6016 l_ctfn_prvdd := TRUE;
6017 else
6018 --only if the enrollment is new then certication is required
6019 open c_prev_enrollment (p_prtt_enrt_rslt_id);
6020 fetch c_prev_enrollment into l_old_amt;
6021 close c_prev_enrollment;
6022 if l_old_amt is null then
6023 l_ctfn_prvdd := TRUE;
6024 elsif l_cvg_incr_code = 'DECRCTF' and p_bnft_amt > l_old_amt then
6025 l_ctfn_prvdd := TRUE;
6026 elsif l_cvg_incr_code = 'INCRCTF' and p_bnft_amt < l_old_amt then
6027 l_ctfn_prvdd := TRUE;
6028 end if;
6029 end if;
6030 --
6031 end if; -- 5736589
6032 --
6033 end if;
6034 end if;
6035 p_ctfn_prvdd := l_ctfn_prvdd;
6036 --
6037 if p_ctfn_prvdd then
6038 hr_utility.set_location('Leaving Check Ctfn Prvdd TRUE',13);
6039 else
6040 hr_utility.set_location('Leaving Check Ctfn Prvdd FALSE',14);
6041 end if;
6042 --
6043 end;
6044
6045
6046 -- ----------------------------------------------------------------------------
6047 -- |--------------------< determine_other_actn_items >------------------------|
6048 -- ----------------------------------------------------------------------------
6049 --
6050 procedure determine_other_actn_items
6051 (p_prtt_enrt_rslt_id in number
6052 ,p_effective_date in date
6053 ,p_business_group_id in number
6054 ,p_validate in boolean default FALSE
6055 ,p_enrt_bnft_id in number default NULL
6056 ,p_datetrack_mode in varchar2 default hr_api.g_correction
6057 ,p_post_rslt_flag in varchar2 default 'Y'
6058 ,p_rslt_object_version_number in out nocopy number
6059 ,p_suspend_flag in out nocopy varchar2
6060 ,p_ctfn_actn_warning out nocopy boolean) is
6061 --
6062 -- this procedure determines all other enrollment action items that need to
6063 -- be written. We are checking the participant enrollment results looking for
6064 -- certifications, ENRTCTFN, and required specific rates.
6065 --
6066 l_proc varchar2(80) := g_package||'.determine_other_actn_items';
6067 l_meets_rqmt varchar2(3);
6068 l_actn_typ_id number(15);
6069 l_prtt_enrt_ctfn_prvdd_id number(15);
6070 l_cmpltd_dt date;
6071 l_object_version_number number;
6072 l_prtt_enrt_actn_id number(15);
6073 l_datetrack_mode varchar2(30);
6074 l_enrt_exist varchar2(1);
6075
6076 l_rslt_object_version_number number(15);
6077 l_suspend_flag varchar2(15);
6078
6079
6080 --
6081 cursor c_epe is
6082 select epe.ctfn_rqd_flag,
6083 epe.elig_per_elctbl_chc_id,
6084 epe.crntly_enrd_flag,
6085 epe.per_in_ler_id,
6086 epe.pl_id,
6087 nvl(pen.bnft_amt, 0) bnft_amt,
6088 pen.oipl_id
6089 from ben_prtt_enrt_rslt_f pen,
6090 ben_elig_per_elctbl_chc epe,
6091 ben_per_in_ler pil
6092 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6093 and pen.prtt_enrt_rslt_stat_cd is null
6094 and p_effective_date between
6095 pen.effective_start_date and pen.effective_end_date
6096 -- join by comp object
6097 and nvl(pen.pgm_id,-1)=nvl(epe.pgm_id,-1)
6098 and pen.pl_id=epe.pl_id
6099 and epe.bnft_prvdr_pool_id is null -- Bug 2389261 exclude these records
6100 and nvl(pen.oipl_id,-1)=nvl(epe.oipl_id,-1)
6101 -- and pen.prtt_enrt_rslt_id = epe.prtt_enrt_rslt_id
6102 and pen.per_in_ler_id = epe.per_in_ler_id
6103 and epe.business_group_id = p_business_group_id
6104 and pil.per_in_ler_id = epe.per_in_ler_id
6105 and pil.business_group_id = p_business_group_id
6106 and pil.per_in_ler_stat_cd not in ('VOIDD', 'BCKDT');
6107 --
6108 l_epe c_epe%rowtype;
6109 --
6110 cursor c_ecc1(v_elig_per_elctbl_chc_id number) is
6111 select ecc.rqd_flag,
6112 ecc.enrt_ctfn_typ_cd,
6113 ecc.SUSP_IF_CTFN_NOT_PRVD_FLAG,
6114 ecc.ctfn_determine_cd
6115 from ben_elctbl_chc_ctfn ecc
6116 where ecc.elig_per_elctbl_chc_id = v_elig_per_elctbl_chc_id
6117 -- jcarpent added line below for bug 1488666
6118 and ecc.enrt_bnft_id is null
6119 and ecc.business_group_id = p_business_group_id;
6120 --
6121 cursor c_enrt_bnft is
6122 select enb.ctfn_rqd_flag,
6123 nvl(enb.entr_val_at_enrt_flag, 'N') entr_val_at_enrt_flag,
6124 mx_wout_ctfn_val,
6125 cvg_mlt_cd
6126 from ben_enrt_bnft enb
6127 where enb.enrt_bnft_id = p_enrt_bnft_id
6128 and enb.business_group_id = p_business_group_id;
6129 --
6130 l_enrt_bnft c_enrt_bnft%rowtype;
6131 --
6132 cursor c_ecc2(v_enrt_bnft_id number,
6133 v_elig_per_elctbl_chc_id number) is
6134 select ecc.rqd_flag,
6135 ecc.enrt_ctfn_typ_cd,
6136 ecc.SUSP_IF_CTFN_NOT_PRVD_FLAG,
6137 ecc.ctfn_determine_cd
6138 from ben_elctbl_chc_ctfn ecc
6139 where ecc.enrt_bnft_id = v_enrt_bnft_id
6140 and ecc.elig_per_elctbl_chc_id = v_elig_per_elctbl_chc_id
6141 and ecc.business_group_id = p_business_group_id;
6142 --
6143 cursor c_enrt_ctfn(v_prtt_enrt_actn_id number) is
6144 select pec.prtt_enrt_ctfn_prvdd_id,
6145 pec.enrt_ctfn_recd_dt,
6146 pec.object_version_number
6147 from ben_prtt_enrt_ctfn_prvdd_f pec
6148 where pec.prtt_enrt_actn_id = v_prtt_enrt_actn_id
6149 and pec.enrt_r_bnft_ctfn_cd = 'BNFT'
6150 and pec.business_group_id = p_business_group_id
6151 and p_effective_date between pec.effective_start_date
6152 and pec.effective_end_date;
6153 l_enrt_ctfn c_enrt_ctfn%rowtype;
6154 --
6155 -- Bug No 4241743
6156 cursor c_enrt_actn ( p_actn_typ_id number
6157 ,p_prtt_enrt_rslt_id number
6158 ,p_effective_date date
6159 ,p_business_group_id number)
6160 is
6161 select pea.prtt_enrt_actn_id,
6162 pea.per_in_ler_id
6163 from ben_prtt_enrt_actn_f pea,
6164 ben_per_in_ler pil
6165 where pea.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6166 and pea.actn_typ_id = p_actn_typ_id
6167 and pea.pl_bnf_id is null
6168 and pea.elig_cvrd_dpnt_id is null
6169 and pea.per_in_ler_id = pil.per_in_ler_id
6170 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
6171 and pea.business_group_id = p_business_group_id
6172 and p_effective_date between pea.effective_start_date
6173 and pea.effective_end_date ;
6174 l_enrt_actn c_enrt_actn%rowtype;
6175 --
6176 l_write_new_ctfn boolean := TRUE;
6177 l_ctfn_prvdd boolean ;
6178 l_actn_exists varchar2(10) := 'N'; -- Bug No 4241743
6179 --
6180 -- Bug 5887665
6181 --
6182 cursor c_ler_rstrn(p_effective_date date,
6183 p_per_in_ler_id number,
6184 p_pl_id number) is
6185 select rstrn.cvg_incr_r_decr_only_cd
6186 from ben_ler_bnft_rstrn_f rstrn,
6187 ben_per_in_ler pil
6188 where rstrn.ler_id = pil.ler_id
6189 and rstrn.pl_id = p_pl_id
6190 and pil.per_in_ler_id = p_per_in_ler_id
6191 and p_effective_date
6192 between rstrn.effective_start_date
6193 and rstrn.effective_end_date;
6194 --
6195 cursor c_pl_rstrn (p_effective_date date,
6196 p_pl_id number) is
6197 select pln.cvg_incr_r_decr_only_cd,
6198 pln.bnft_or_option_rstrctn_cd
6199 from ben_pl_f pln
6200 where pln.pl_id = p_pl_id
6201 and p_effective_date
6202 between pln.effective_start_date
6203 and pln.effective_end_date;
6204 --
6205 l_bnft_or_option_rstrctn_cd VARCHAR2(30);
6206 l_cvg_incr_code_pln varchar(30);
6207 l_cvg_incr_code varchar2(240);
6208 --
6209 -- End Bug 5887665
6210 --
6211 begin
6212 --
6213 g_debug := hr_utility.debug_enabled;
6214 if g_debug then
6215 hr_utility.set_location ('Entering '||l_proc,10);
6216 end if;
6217 --
6218 l_rslt_object_version_number :=p_rslt_object_version_number ;
6219 l_suspend_flag :=p_suspend_flag ;
6220
6221 --
6222 savepoint determine_other_actn_items;
6223 --
6224 -- Get elig_per_elctbl_chc id
6225 --
6226 open c_epe;
6227 fetch c_epe into l_epe;
6228 --
6229 if c_epe%notfound then
6230 close c_epe;
6231 /* Bug 2386000 When you run the close action items process after due date
6232 when enrollment was originally suspended due to the BOD certification
6233 requirement (for example) the enrollment might already be end dated
6234 as part of calls from bepenapi delete_enrollment and this may fail.
6235 Instead let us return without doing anything if this cursor doesnot
6236 return any records */
6237 -- fnd_message.set_name('BEN', 'BEN_91578_BENACPRM_EPE_NF');
6238 -- fnd_message.set_token('PROC',l_proc);
6239 -- fnd_message.set_token('PRTT_ENRT_RSLT_ID',to_char(p_prtt_enrt_rslt_id));
6240 -- fnd_message.set_token('EFFECTIVE_DATE',p_effective_date);
6241 -- fnd_message.set_token('BUSINESS_GROUP_ID',to_char(p_business_group_id));
6242 -- fnd_message.raise_error;
6243 if g_debug then
6244 hr_utility.set_location('Enrollment already ended/ZAPed by another process ',22);
6245 end if;
6246 return ;
6247 else
6248 close c_epe;
6249 end if;
6250 --
6251 l_actn_typ_id := get_actn_typ_id
6252 (p_type_cd => 'ENRTCTFN'
6253 ,p_business_group_id => p_business_group_id);
6254 --
6255 /* get_prtt_enrt_actn_id
6256 (p_actn_typ_id => l_actn_typ_id,
6257 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
6258 p_effective_date => p_effective_date,
6259 p_business_group_id => p_business_group_id,
6260 p_prtt_enrt_actn_id => l_prtt_enrt_actn_id,
6261 p_cmpltd_dt => l_cmpltd_dt,
6262 p_object_version_number => l_object_version_number); */ -- Commented for 4241743
6263 --
6264 hr_utility.set_location('CTFN rqd flag '||l_epe.ctfn_rqd_flag,9);
6265 if l_epe.ctfn_rqd_flag = 'Y' then
6266 --
6267 if g_debug then
6268 hr_utility.set_location('CTFN rqd flag is Y', 10);
6269 hr_utility.set_location('l_actn_exists '||l_actn_exists,10);
6270 end if;
6271 -- Bug No 4241743
6272 l_prtt_enrt_actn_id := null;
6273 open c_enrt_actn
6274 (p_actn_typ_id => l_actn_typ_id,
6275 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
6276 p_effective_date => p_effective_date,
6277 p_business_group_id => p_business_group_id
6278 );
6279 loop
6280 fetch c_enrt_actn into l_enrt_actn;
6281 exit when c_enrt_actn%notfound;
6282 l_prtt_enrt_actn_id := l_enrt_actn.prtt_enrt_actn_id;
6283 if l_epe.per_in_ler_id = l_enrt_actn.per_in_ler_id then
6284 hr_utility.set_location('Actn Id '||l_prtt_enrt_actn_id||'found in per_in_ler_id '||l_enrt_actn.per_in_ler_id,12);
6285 l_actn_exists := 'Y';
6286 exit;
6287 end if;
6288 end loop;
6289 close c_enrt_actn;
6290 hr_utility.set_location('After loop l_actn_exists '||l_actn_exists,12);
6291 --
6292 -- Loop through the certifications that might exist for the eltbl chc and
6293 -- write required certifications to the prtt_enrt_ctfn_prvdd table
6294 --
6295 -- Bug No 4241743 Added l_actn_exists check in if condition
6296 if (l_prtt_enrt_actn_id is null or l_actn_exists = 'N') then
6297 --
6298 for l_ecc in c_ecc1(l_epe.elig_per_elctbl_chc_id) loop
6299 --
6300 check_ctfn_prvdd
6301 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6302 ,p_effective_date => p_effective_date
6303 ,p_business_group_id => p_business_group_id
6304 ,p_enrt_ctfn_typ_cd => l_ecc.enrt_ctfn_typ_cd
6305 ,p_oipl_id => l_epe.oipl_id
6306 ,p_rqd_flag => l_ecc.rqd_flag
6307 ,p_pl_id => l_epe.pl_id
6308 ,p_per_in_ler_id => l_epe.per_in_ler_id
6309 ,p_bnft_amt => l_epe.bnft_amt
6310 ,p_ctfn_determine_cd => l_ecc.ctfn_determine_cd
6311 ,p_crntly_enrd_flag => l_epe.crntly_enrd_flag
6312 ,p_ctfn_prvdd => l_ctfn_prvdd);
6313 --
6314 -- Bug No 4241743 Added l_actn_exists check in if condition
6315 if ((l_prtt_enrt_actn_id is null or l_actn_exists = 'N') and not l_ctfn_prvdd) then
6316 --
6317 hr_utility.set_location('write action ',12);
6318 write_new_action_item
6319 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6320 ,p_rslt_object_version_number => p_rslt_object_version_number
6321 ,p_actn_typ_id => l_actn_typ_id
6322 ,p_rqd_flag => l_ecc.SUSP_IF_CTFN_NOT_PRVD_FLAG --'Y'
6323 ,p_effective_date => p_effective_date
6324 ,p_post_rslt_flag => p_post_rslt_flag
6325 ,p_business_group_id => p_business_group_id
6326 ,p_object_version_number => l_object_version_number
6327 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id);
6328 --
6329 p_ctfn_actn_warning := true;
6330 end if;
6331 --
6332 if not l_ctfn_prvdd then
6333 --
6334 write_new_prtt_ctfn_prvdd_item
6335 (p_rqd_flag => l_ecc.rqd_flag
6336 ,p_enrt_ctfn_typ_cd => l_ecc.enrt_ctfn_typ_cd
6337 ,p_enrt_r_bnft_ctfn_cd => 'ENRT'
6338 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6339 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
6340 ,p_effective_date => p_effective_date
6341 ,p_business_group_id => p_business_group_id
6342 ,p_object_version_number => l_object_version_number
6343 ,p_prtt_enrt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
6344 --
6345 end if;
6346 --
6347 end loop;
6348 --
6349 end if;
6350 --
6351 end if;
6352 --
6353 -- If an enrt_bnft_id was passed we need to check if the enrollment benefit
6354 -- needs any certifications.
6355 --
6356 if p_enrt_bnft_id is not null then
6357 --
6358 open c_enrt_bnft;
6359 fetch c_enrt_bnft into l_enrt_bnft;
6360 --
6361 if c_enrt_bnft%notfound then
6362 close c_enrt_bnft;
6363 fnd_message.set_name('BEN', 'BEN_91580_BENACPRM_ENB_NF');
6364 fnd_message.set_token('PROC',l_proc);
6365 fnd_message.set_token('ENRT_BNFT_ID',to_char(p_enrt_bnft_id));
6366 fnd_message.set_token('BUSINESS_GROUP_ID',to_char(p_business_group_id));
6367 fnd_message.set_token('EFFECTIVE_DATE',p_effective_date);
6368 fnd_message.raise_error;
6369 else
6370 close c_enrt_bnft;
6371 if g_debug then
6372 hr_utility.set_location('c_enrt_bnft found', 10);
6373 end if;
6374 end if;
6375 --
6376 -- Check if there are any ENRTCTFN action items and certifications that
6377 -- already exist. There may be a need to delete them if the enrt bnft record
6378 -- was changed from a one that requires ctfn to a one that doesn't.
6379 --
6380 get_prtt_enrt_actn_id
6381 (p_actn_typ_id => l_actn_typ_id
6382 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6383 ,p_effective_date => p_effective_date
6384 ,p_business_group_id => p_business_group_id
6385 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
6386 ,p_cmpltd_dt => l_cmpltd_dt
6387 ,p_object_version_number => l_object_version_number);
6388 --
6389 -- swjain - This code seems to be redundant as l_prtt_enrt_actn_id won't be not null
6390 -- in any case. Need to review this part of code.
6391 --
6392 if (l_prtt_enrt_actn_id is not null) then
6393 --
6394 -- Delete all certifications of type 'BNFT' for the action item
6395 --
6396 If p_datetrack_mode = hr_api.g_zap then
6397 l_datetrack_mode := hr_api.g_zap;
6398 Elsif p_datetrack_mode = hr_api.g_delete then
6399 l_datetrack_mode := hr_api.g_delete;
6400 Elsif p_datetrack_mode = hr_api.g_correction then
6401 l_datetrack_mode := hr_api.g_zap;
6402 Elsif p_datetrack_mode = hr_api.g_update then
6403 l_datetrack_mode := hr_api.g_delete;
6404 Else
6405 l_datetrack_mode := hr_api.g_delete;
6406 End if;
6407 --
6408 for l_enrt_ctfn in c_enrt_ctfn(l_prtt_enrt_actn_id) loop
6409 --
6410 if l_enrt_ctfn.enrt_ctfn_recd_dt = null then
6411 l_write_new_ctfn := TRUE;
6412 delete_prtt_ctfn_prvdd
6413 (p_prtt_enrt_ctfn_prvdd_id => l_enrt_ctfn.prtt_enrt_ctfn_prvdd_id
6414 ,p_object_version_number => l_enrt_ctfn.object_version_number
6415 ,p_effective_date => p_effective_date
6416 ,p_datetrack_mode => l_datetrack_mode);
6417 else
6418 l_write_new_ctfn := FALSE;
6419 end if;
6420 --
6421 end loop;
6422 --
6423 end if;
6424
6425 -- write the ctfn's only if the flag is 'Y' AND if the cvg amt was
6426 -- enterable, the entered amt was more than the mx_wout_ctfn_val.Bug 1249901
6427 hr_utility.set_location('Benefit amount '||l_epe.bnft_amt,11);
6428 --
6429 open c_ler_rstrn (p_effective_date, l_epe.per_in_ler_id, l_epe.pl_id);
6430 fetch c_ler_rstrn into l_cvg_incr_code;
6431 close c_ler_rstrn;
6432 --
6433 --if l_cvg_incr_code is null then
6434 open c_pl_rstrn (p_effective_date, l_epe.pl_id);
6435 fetch c_pl_rstrn into l_cvg_incr_code_pln, l_bnft_or_option_rstrctn_cd;
6436 close c_pl_rstrn;
6437 --end if;
6438 l_cvg_incr_code := NVL(l_cvg_incr_code, l_cvg_incr_code_pln);
6439 --
6440 if l_enrt_bnft.ctfn_rqd_flag = 'Y'
6441 and (l_epe.bnft_amt > nvl(l_enrt_bnft.mx_wout_ctfn_val, 0) or
6442 (l_bnft_or_option_rstrctn_cd = 'BNFT' and l_cvg_incr_code = 'DECRCTF')) then
6443 --
6444 -- swjain -- No need for other conditions. Also for 'DECRCTF' codes, no need to chk if
6445 -- bnft_amt > l_enrt_bnft.mx_wout_ctfn_val
6446 --
6447 /* and ((l_enrt_bnft.entr_val_at_enrt_flag = 'N' or
6448 l_enrt_bnft.entr_val_at_enrt_flag = 'Y'or l_enrt_bnft.cvg_mlt_cd in ('ERL')) */
6449 --
6450 -- Bug 3183266 : For flat range l_enrt_bnft.mx_wout_ctfn_val will be null
6451 --
6452 if g_debug then
6453 hr_utility.set_location('CTFN rqd flag is Y', 10);
6454 end if;
6455 --
6456 -- Loop through the certifications that might exist for the eltbl chc and
6457 -- write required certifications to the prtt_enrt_ctfn_prvdd table
6458 --
6459 for l_ecc in c_ecc2(p_enrt_bnft_id
6460 ,l_epe.elig_per_elctbl_chc_id) loop
6461 --
6462 -- Bug 5887665 - Even for coverage ctfns, we need to see the suspended codes, and
6463 -- then create action items and ctfns accordingly
6464 --
6465 check_ctfn_prvdd
6466 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6467 ,p_effective_date => p_effective_date
6468 ,p_business_group_id => p_business_group_id
6469 ,p_enrt_ctfn_typ_cd => l_ecc.enrt_ctfn_typ_cd
6470 ,p_oipl_id => l_epe.oipl_id
6471 ,p_rqd_flag => l_ecc.rqd_flag
6472 ,p_pl_id => l_epe.pl_id
6473 ,p_per_in_ler_id => l_epe.per_in_ler_id
6474 ,p_bnft_amt => l_epe.bnft_amt
6475 ,p_ctfn_determine_cd => l_ecc.ctfn_determine_cd
6476 ,p_crntly_enrd_flag => l_epe.crntly_enrd_flag
6477 ,p_enrt_r_bnft_ctfn_cd => 'BNFT'
6478 ,p_ctfn_prvdd => l_ctfn_prvdd);
6479 --
6480 if (l_prtt_enrt_actn_id is null and not l_ctfn_prvdd) then
6481 --
6482 write_new_action_item
6483 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6484 ,p_rslt_object_version_number => p_rslt_object_version_number
6485 ,p_actn_typ_id => l_actn_typ_id
6486 ,p_rqd_flag => l_ecc.SUSP_IF_CTFN_NOT_PRVD_FLAG --'Y'
6487 ,p_effective_date => p_effective_date
6488 ,p_post_rslt_flag => p_post_rslt_flag
6489 ,p_business_group_id => p_business_group_id
6490 ,p_object_version_number => l_object_version_number
6491 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id);
6492 --
6493 p_ctfn_actn_warning := true;
6494 --
6495 end if;
6496 --
6497 if (not l_ctfn_prvdd and (l_prtt_enrt_actn_id is null or
6498 (l_prtt_enrt_actn_id is not null and l_write_new_ctfn))) then
6499 --
6500 write_new_prtt_ctfn_prvdd_item
6501 (p_rqd_flag => l_ecc.rqd_flag
6502 ,p_enrt_ctfn_typ_cd => l_ecc.enrt_ctfn_typ_cd
6503 ,p_enrt_r_bnft_ctfn_cd => 'BNFT'
6504 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6505 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
6506 ,p_effective_date => p_effective_date
6507 ,p_business_group_id => p_business_group_id
6508 ,p_object_version_number => l_object_version_number
6509 ,p_prtt_enrt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
6510 --
6511 end if;
6512 --
6513 end loop;
6514 --
6515 end if; -- ctfn_rqd_flag
6516 --
6517 end if; -- p_enrt_bnft_id
6518 --
6519 if p_validate then
6520 raise hr_api.validate_enabled;
6521 end if;
6522 --
6523 if g_debug then
6524 hr_utility.set_location ('Leaving ' ||l_proc,10);
6525 end if;
6526 --
6527 exception
6528 --
6529 when hr_api.validate_enabled
6530 then
6531 rollback to determine_other_actn_items;
6532 if g_debug then
6533 hr_utility.set_location ('Leaving ' ||l_proc,10);
6534 end if;
6535 --
6536 when others then
6537 if g_debug then
6538 hr_utility.set_location('Exception Raised '||l_proc, 10);
6539 end if;
6540 raise;
6541 --
6542 end determine_other_actn_items;
6543 --
6544 -- ----------------------------------------------------------------------------
6545 -- |--------------------< determine_pcp_dpnt_actn_items >------------------------|
6546 -- ----------------------------------------------------------------------------
6547 --
6548 procedure determine_pcp_dpnt_actn_items
6549 (p_prtt_enrt_rslt_id in number
6550 ,p_effective_date in date
6551 ,p_business_group_id in number
6552 ,p_elig_cvrd_dpnt_id in number
6553 ,p_validate in boolean default FALSE
6554 ,p_datetrack_mode in varchar2 default hr_api.g_correction
6555 ,p_post_rslt_flag in varchar2 default 'Y'
6556 ,p_pcp_dpnt_dsgn_cd in varchar2
6557 ,p_rslt_object_version_number in out nocopy number
6558 ,p_suspend_flag in out nocopy varchar2
6559 ,p_pcp_dpnt_actn_warning out nocopy boolean) is
6560 --
6561 l_proc varchar2(80) ;
6562 l_actn_typ_id number(15);
6563 l_prtt_enrt_ctfn_prvdd_id number(15);
6564 l_cmpltd_dt date;
6565 l_datetrack_mode varchar2(30);
6566 l_pcp_dpnt_actn_warning boolean := FALSE;
6567 l_dummy varchar2(30);
6568 l_prtt_enrt_actn_id number(15);
6569 l_object_version_number number;
6570 l_rqd_flag varchar2(30);
6571 l_rqd_data_found boolean := FALSE;
6572
6573 l_rslt_object_version_number number(15);
6574 l_suspend_flag varchar2(20);
6575
6576
6577 cursor c_prmry_care_actn is
6578 select 'x'
6579 from ben_prmry_care_prvdr_f pf,
6580 ben_elig_cvrd_dpnt_f ecd
6581 where pf.elig_cvrd_dpnt_id = ecd.elig_cvrd_dpnt_id
6582 -- and ecd.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id bug 1421978
6583 and ecd.elig_cvrd_dpnt_id = p_elig_cvrd_dpnt_id
6584 and pf.business_group_id = p_business_group_id
6585 and ecd.business_group_id = p_business_group_id
6586 and p_effective_date between ecd.effective_start_date
6587 and ecd.effective_end_date
6588 and p_effective_date between pf.effective_start_date
6589 and pf.effective_end_date;
6590 --
6591 begin
6592 --
6593 if g_debug then
6594 l_proc := g_package||'.determine_pcp_dpnt_actn_items';
6595 hr_utility.set_location ('Entering '||l_proc,10);
6596 end if;
6597 --
6598 l_rslt_object_version_number := p_rslt_object_version_number ;
6599 l_suspend_flag := p_suspend_flag ;
6600
6601 -- Issue a savepoint if operating in validate only mode
6602 --
6603 savepoint determine_pcp_dpnt_actn_items;
6604 --
6605 if p_pcp_dpnt_dsgn_cd = 'R' then
6606 l_rqd_flag := 'Y';
6607 else
6608 l_rqd_flag := 'N';
6609 end if;
6610 --
6611 if g_debug then
6612 hr_utility.set_location('pcp dpnt dsgn rqd flag : ' || l_rqd_flag || ' ' ||
6613 l_proc, 20);
6614 end if;
6615 --
6616 -- As the only modification happening in the code is for rqd_flag = 'Y',
6617 -- restrict the code execution only when it's on.
6618 --
6619 if l_rqd_flag = 'Y' then
6620 open c_prmry_care_actn;
6621 fetch c_prmry_care_actn into l_dummy;
6622 if c_prmry_care_actn%notfound then
6623 l_rqd_data_found := FALSE;
6624 if g_debug then
6625 hr_utility.set_location('c_prmry_care_actn notfound' , 90 );
6626 end if;
6627 elsif c_prmry_care_actn%found then
6628 l_rqd_data_found := TRUE;
6629 if g_debug then
6630 hr_utility.set_location('c_prmry_care_actn found' , 91 );
6631 end if;
6632 end if;
6633 close c_prmry_care_actn;
6634 --
6635 if g_debug then
6636 hr_utility.set_location('PCPDPNT action item ', 30);
6637 end if;
6638 --
6639 l_actn_typ_id := get_actn_typ_id
6640 (p_type_cd => 'PCPDPNT'
6641 ,p_business_group_id => p_business_group_id);
6642 --
6643 if g_debug then
6644 hr_utility.set_location ('Entering get_prtt_enrt_actn_id ' , 101);
6645 end if;
6646 get_prtt_enrt_actn_id
6647 (p_actn_typ_id => l_actn_typ_id,
6648 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
6649 p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id,
6650 p_effective_date => p_effective_date,
6651 p_business_group_id => p_business_group_id,
6652 p_prtt_enrt_actn_id => l_prtt_enrt_actn_id,
6653 p_cmpltd_dt => l_cmpltd_dt,
6654 p_object_version_number => l_object_version_number);
6655
6656 --
6657 if (l_prtt_enrt_actn_id IS NULL and
6658 l_rqd_data_found = FALSE) then
6659 l_pcp_dpnt_actn_warning := TRUE;
6660 elsif l_prtt_enrt_actn_id IS NOT NULL and
6661 l_rqd_data_found = TRUE and
6662 l_cmpltd_dt IS NULL then
6663 --
6664 if g_debug then
6665 hr_utility.set_location ('Case 1 ',102);
6666 end if;
6667 -- Existing open action item but we now have required data. Close the open
6668 -- action item by setting cmpltd_dt field
6669 --
6670 l_pcp_dpnt_actn_warning := FALSE;
6671 elsif l_prtt_enrt_actn_id IS NOT NULL and
6672 l_rqd_data_found = FALSE and
6673 l_cmpltd_dt IS NOT NULL then
6674 --
6675 -- Found a closed action item. But required data is missing. Reopen item
6676 --
6677 if g_debug then
6678 hr_utility.set_location ('Case2 ',103);
6679 end if;
6680 l_pcp_dpnt_actn_warning := TRUE;
6681 else
6682 if g_debug then
6683 hr_utility.set_location ('Case3 ',104);
6684 end if;
6685 l_pcp_dpnt_actn_warning := FALSE;
6686 end if;
6687 -- process the action item
6688 --
6689 process_action_item
6690 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
6691 ,p_actn_typ_id => l_actn_typ_id
6692 ,p_cmpltd_dt => l_cmpltd_dt
6693 ,p_object_version_number => l_object_version_number
6694 ,p_effective_date => p_effective_date
6695 ,p_rqd_data_found => l_rqd_data_found
6696 ,p_rqd_flag => l_rqd_flag
6697 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6698 ,p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id --bug 1421978
6699 ,p_post_rslt_flag => p_post_rslt_flag
6700 ,p_business_group_id => p_business_group_id
6701 ,p_datetrack_mode => p_datetrack_mode
6702 ,p_rslt_object_version_number => p_rslt_object_version_number);
6703 --
6704 end if; -- rqd_flag = 'Y'
6705 --
6706 p_pcp_dpnt_actn_warning := l_pcp_dpnt_actn_warning;
6707 if p_validate then
6708 raise hr_api.validate_enabled;
6709 end if;
6710 --
6711 if g_debug then
6712 hr_utility.set_location ('Leaving '||l_proc, 10);
6713 end if;
6714 --
6715
6716 exception
6717 --
6718 when hr_api.validate_enabled
6719 then
6720 rollback to determine_pcp_dpnt_actn_items;
6721 --
6722 if g_debug then
6723 hr_utility.set_location(' Leaving:'||l_proc, 10);
6724 end if;
6725 --
6726 when others then
6727 if g_debug then
6728 hr_utility.set_location('Exception Raised '||l_proc, 10);
6729 end if;
6730 p_rslt_object_version_number := l_rslt_object_version_number;
6731 p_suspend_flag := l_suspend_flag ;
6732 p_pcp_dpnt_actn_warning := null ;
6733
6734 raise;
6735 --
6736 end determine_pcp_dpnt_actn_items;
6737 --
6738 -- ----------------------------------------------------------------------------
6739 -- |--------------------< determine_pcp_actn_items >--------------------------|
6740 -- ----------------------------------------------------------------------------
6741 --
6742 procedure determine_pcp_actn_items
6743 (p_prtt_enrt_rslt_id in number
6744 ,p_effective_date in date
6745 ,p_business_group_id in number
6746 ,p_validate in boolean default FALSE
6747 ,p_datetrack_mode in varchar2 default hr_api.g_correction
6748 ,p_post_rslt_flag in varchar2 default 'Y'
6749 ,p_pcp_dsgn_cd in varchar2
6750 ,p_rslt_object_version_number in out nocopy number
6751 ,p_suspend_flag in out nocopy varchar2
6752 ,p_pcp_actn_warning out nocopy boolean) is
6753 --
6754 l_proc varchar2(80) ;
6755 l_actn_typ_id number(15);
6756 l_prtt_enrt_ctfn_prvdd_id number(15);
6757 l_cmpltd_dt date;
6758 l_datetrack_mode varchar2(30);
6759 l_pcp_actn_warning boolean := FALSE;
6760 l_dummy varchar2(30);
6761 l_prtt_enrt_actn_id number(15);
6762 l_object_version_number number;
6763 l_rqd_flag varchar2(30);
6764 l_rqd_data_found boolean := FALSE;
6765
6766 l_rslt_object_version_number number(15);
6767 l_suspend_flag varchar2(20);
6768
6769 cursor c_prmry_care_actn is
6770 select 'x'
6771 from ben_prmry_care_prvdr_f pf
6772 where pf.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6773 and pf.business_group_id = p_business_group_id
6774 and p_effective_date between pf.effective_start_date
6775 and pf.effective_end_date;
6776 --
6777 begin
6778 --
6779 if g_debug then
6780 l_proc := g_package||'.determine_pcp_actn_items';
6781 hr_utility.set_location ('Entering '||l_proc,10);
6782 end if;
6783 --
6784
6785 l_rslt_object_version_number := p_rslt_object_version_number ;
6786 l_suspend_flag := p_suspend_flag ;
6787
6788 -- Issue a savepoint if operating in validate only mode
6789 --
6790 savepoint determine_pcp_actn_items;
6791 --
6792 if p_pcp_dsgn_cd = 'R' then
6793 l_rqd_flag := 'Y';
6794 else
6795 l_rqd_flag := 'N';
6796 end if;
6797 --
6798 if g_debug then
6799 hr_utility.set_location('pcp dsgn rqd flag : ' || l_rqd_flag || ' ' ||
6800 l_proc, 20);
6801 end if;
6802 --
6803 -- As the only modification happening in the code is for rqd_flag = 'Y',
6804 -- restrict the code execution only when it's on.
6805 --
6806 if l_rqd_flag = 'Y' then
6807 open c_prmry_care_actn;
6808 fetch c_prmry_care_actn into l_dummy;
6809 if c_prmry_care_actn%notfound then
6810 l_rqd_data_found := FALSE;
6811 elsif c_prmry_care_actn%found then
6812 l_rqd_data_found := TRUE;
6813 end if;
6814 close c_prmry_care_actn;
6815 --
6816 if g_debug then
6817 hr_utility.set_location('PCPPRTT action item ', 30);
6818 end if;
6819 --
6820 l_actn_typ_id := get_actn_typ_id
6821 (p_type_cd => 'PCPPRTT'
6822 ,p_business_group_id => p_business_group_id);
6823 --
6824 get_prtt_enrt_actn_id
6825 (p_actn_typ_id => l_actn_typ_id,
6826 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
6827 p_effective_date => p_effective_date,
6828 p_business_group_id => p_business_group_id,
6829 p_prtt_enrt_actn_id => l_prtt_enrt_actn_id,
6830 p_cmpltd_dt => l_cmpltd_dt,
6831 p_object_version_number => l_object_version_number);
6832
6833 --
6834 if (l_prtt_enrt_actn_id IS NULL and
6835 l_rqd_data_found = FALSE) then
6836 l_pcp_actn_warning := TRUE;
6837 if g_debug then
6838 hr_utility.set_location ('Leaving '||'TRUE', 11);
6839 end if;
6840 elsif l_prtt_enrt_actn_id IS NOT NULL and
6841 l_rqd_data_found = TRUE and
6842 l_cmpltd_dt IS NULL then
6843 --
6844 -- Existing open action item but we now have required data. Close the open
6845 -- action item by setting cmpltd_dt field
6846 --
6847 if g_debug then
6848 hr_utility.set_location ('Leaving '||'FALSE', 12);
6849 end if;
6850 l_pcp_actn_warning := FALSE;
6851 elsif l_prtt_enrt_actn_id IS NOT NULL and
6852 l_rqd_data_found = FALSE and
6853 l_cmpltd_dt IS NOT NULL then
6854 --
6855 -- Found a closed action item. But required data is missing. Reopen item
6856 --
6857 if g_debug then
6858 hr_utility.set_location ('Leaving '||'TRUE', 13);
6859 end if;
6860 l_pcp_actn_warning := TRUE;
6861 else
6862 if g_debug then
6863 hr_utility.set_location ('Leaving '||'FALSE', 14);
6864 end if;
6865 l_pcp_actn_warning := FALSE;
6866 end if;
6867 -- process the action item
6868 --
6869 process_action_item
6870 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
6871 ,p_actn_typ_id => l_actn_typ_id
6872 ,p_cmpltd_dt => l_cmpltd_dt
6873 ,p_object_version_number => l_object_version_number
6874 ,p_effective_date => p_effective_date
6875 ,p_rqd_data_found => l_rqd_data_found
6876 ,p_rqd_flag => l_rqd_flag
6877 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6878 ,p_post_rslt_flag => p_post_rslt_flag
6879 ,p_business_group_id => p_business_group_id
6880 ,p_datetrack_mode => p_datetrack_mode
6881 ,p_rslt_object_version_number => p_rslt_object_version_number);
6882 --
6883 end if; -- rqd_flag = 'Y'
6884 --
6885 p_pcp_actn_warning := l_pcp_actn_warning;
6886 if p_validate then
6887 raise hr_api.validate_enabled;
6888 end if;
6889 --
6890 if g_debug then
6891 hr_utility.set_location ('Leaving '||l_proc, 10);
6892 end if;
6893 --
6894
6895 exception
6896 --
6897 when hr_api.validate_enabled
6898 then
6899 rollback to determine_pcp_actn_items;
6900 --
6901 if g_debug then
6902 hr_utility.set_location(' Leaving:'||l_proc, 10);
6903 end if;
6904 --
6905 when others then
6906 if g_debug then
6907 hr_utility.set_location('Exception Raised '||l_proc, 10);
6908 end if;
6909
6910 p_rslt_object_version_number := l_rslt_object_version_number;
6911 p_suspend_flag := l_suspend_flag ;
6912 p_pcp_actn_warning := null ;
6913
6914 raise;
6915 --
6916 end determine_pcp_actn_items;
6917
6918
6919 -- ----------------------------------------------------------------------------
6920 -- |--------------------< process_pcp_dpnt_actn_items >------------------------|
6921 -- ----------------------------------------------------------------------------
6922 --
6923 procedure process_pcp_dpnt_actn_items
6924 (p_validate in boolean default FALSE
6925 ,p_prtt_enrt_rslt_id in number
6926 ,p_effective_date in date
6927 ,p_business_group_id in number
6928 ,p_datetrack_mode in varchar2 default hr_api.g_correction
6929 ,p_post_rslt_flag in varchar2 default 'Y'
6930 ,p_rslt_object_version_number in out nocopy number
6931 ,p_suspend_flag in out nocopy varchar2
6932 ,p_pcp_dpnt_actn_warning out nocopy boolean) is
6933 --
6934 l_proc varchar2(80);
6935
6936 l_rslt_object_version_number number(15);
6937 l_suspend_flag varchar2(20);
6938
6939
6940 --
6941 --this procedure determines whether the result correspoding to dependent
6942 -- designation has pcp_dpnt_dsgn_cd turned on.if it's on we need to create
6943 -- an action item and suspend the result during dependent designation.
6944 --
6945 l_pcp_dpnt_dsgn_cd varchar2(30) := null;
6946 l_elig_cvrd_dpnt_id ben_elig_cvrd_dpnt_f.elig_cvrd_dpnt_id%TYPE;
6947 l_pcp_dpnt_actn_warning boolean := FALSE;
6948
6949 cursor c_pcp_dpnt_cd_oipl is
6950 select cop.pcp_dpnt_dsgn_cd,
6951 ecd.elig_cvrd_dpnt_id
6952 from ben_prtt_enrt_rslt_f pen,
6953 ben_elig_cvrd_dpnt_f ecd,
6954 ben_oipl_f cop
6955 where cop.oipl_id = pen.oipl_id
6956 and pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6957 and pen.prtt_enrt_rslt_id = ecd.prtt_enrt_rslt_id
6958 and ecd.cvg_strt_dt is not null
6959 and nvl(ecd.cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
6960 and pen.business_group_id = p_business_group_id
6961 and cop.business_group_id = p_business_group_id
6962 and ecd.business_group_id = p_business_group_id
6963 and p_effective_date between ecd.effective_start_date
6964 and ecd.effective_end_date
6965 and p_effective_date between cop.effective_start_date
6966 and cop.effective_end_date
6967 and p_effective_date between pen.effective_start_date
6968 and pen.effective_end_date
6969 and cop.pcp_dpnt_dsgn_cd is not null ;
6970 -- added the cop.pcp_dpnt_dsgn_cd is not null condition bug 1421978
6971 --
6972 cursor c_pcp_dpnt_cd is
6973 select pcp.pcp_dpnt_dsgn_cd ,
6974 ecd.elig_cvrd_dpnt_id
6975 from ben_prtt_enrt_rslt_f pen,
6976 ben_elig_cvrd_dpnt_f ecd,
6977 ben_pl_pcp pcp
6978 where pcp.pl_id = pen.pl_id
6979 and pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6980 and pen.prtt_enrt_rslt_id = ecd.prtt_enrt_rslt_id
6981 and ecd.cvg_strt_dt is not null
6982 and nvl(ecd.cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
6983 and pen.business_group_id = p_business_group_id
6984 and pcp.business_group_id = p_business_group_id
6985 and p_effective_date between ecd.effective_start_date
6986 and ecd.effective_end_date
6987 and p_effective_date between pen.effective_start_date
6988 and pen.effective_end_date;
6989 --
6990 begin
6991 --
6992 g_debug := hr_utility.debug_enabled;
6993 if g_debug then
6994 l_proc := g_package||'.process_pcp_dpnt_actn_items';
6995 hr_utility.set_location ('Entering '||l_proc,10);
6996 end if;
6997 if g_debug then
6998 hr_utility.set_location ('Entering rslt id '||to_char(p_prtt_enrt_rslt_id),11);
6999 end if;
7000 --
7001 --
7002
7003 l_rslt_object_version_number := p_rslt_object_version_number ;
7004 l_suspend_flag := p_suspend_flag ;
7005
7006
7007
7008 -- Issue a savepoint if operating in validate only mode
7009 --
7010 savepoint process_pcp_dpnt_actn_items;
7011 --
7012
7013 open c_pcp_dpnt_cd_oipl;
7014 fetch c_pcp_dpnt_cd_oipl into l_pcp_dpnt_dsgn_cd,l_elig_cvrd_dpnt_id;
7015 if c_pcp_dpnt_cd_oipl%notfound then
7016 close c_pcp_dpnt_cd_oipl;
7017 open c_pcp_dpnt_cd;
7018 fetch c_pcp_dpnt_cd into l_pcp_dpnt_dsgn_cd,l_elig_cvrd_dpnt_id;
7019 if c_pcp_dpnt_cd%notfound then
7020 close c_pcp_dpnt_cd;
7021 if g_debug then
7022 hr_utility.set_location('pcp not required ' , 298);
7023 end if;
7024 return;
7025 else
7026 loop
7027 if g_debug then
7028 hr_utility.set_location('l_pcp_dpnt_dsgn_cd '||l_pcp_dpnt_dsgn_cd , 299);
7029 end if;
7030 if g_debug then
7031 hr_utility.set_location('l_elig_cvrd_dpnt_id '||l_elig_cvrd_dpnt_id, 299);
7032 end if;
7033 determine_pcp_dpnt_actn_items
7034 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7035 ,p_elig_cvrd_dpnt_id => l_elig_cvrd_dpnt_id
7036 ,p_effective_date => p_effective_date
7037 ,p_business_group_id => p_business_group_id
7038 ,p_datetrack_mode => p_datetrack_mode
7039 ,p_post_rslt_flag => p_post_rslt_flag
7040 ,p_pcp_dpnt_dsgn_cd => l_pcp_dpnt_dsgn_cd
7041 ,p_rslt_object_version_number => p_rslt_object_version_number
7042 ,p_suspend_flag => p_suspend_flag
7043 ,p_pcp_dpnt_actn_warning => l_pcp_dpnt_actn_warning);
7044 --
7045 fetch c_pcp_dpnt_cd into l_pcp_dpnt_dsgn_cd,l_elig_cvrd_dpnt_id;
7046 exit when c_pcp_dpnt_cd%notfound ;
7047 end loop ;
7048 --
7049 close c_pcp_dpnt_cd;
7050 --
7051 end if;
7052 else
7053 if g_debug then
7054 hr_utility.set_location('l_pcp_dpnt_dsgn_cd '||l_pcp_dpnt_dsgn_cd , 399);
7055 end if;
7056 loop
7057 --
7058 determine_pcp_dpnt_actn_items
7059 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7060 ,p_elig_cvrd_dpnt_id => l_elig_cvrd_dpnt_id
7061 ,p_effective_date => p_effective_date
7062 ,p_business_group_id => p_business_group_id
7063 ,p_datetrack_mode => p_datetrack_mode
7064 ,p_post_rslt_flag => p_post_rslt_flag
7065 ,p_pcp_dpnt_dsgn_cd => l_pcp_dpnt_dsgn_cd
7066 ,p_rslt_object_version_number => p_rslt_object_version_number
7067 ,p_suspend_flag => p_suspend_flag
7068 ,p_pcp_dpnt_actn_warning => l_pcp_dpnt_actn_warning);
7069 --
7070 fetch c_pcp_dpnt_cd_oipl into l_pcp_dpnt_dsgn_cd,l_elig_cvrd_dpnt_id;
7071 exit when c_pcp_dpnt_cd_oipl%notfound ;
7072 end loop;
7073 --
7074 close c_pcp_dpnt_cd_oipl;
7075 --
7076 end if;
7077 --
7078 p_pcp_dpnt_actn_warning := l_pcp_dpnt_actn_warning;
7079 --
7080 if p_validate then
7081 raise hr_api.validate_enabled;
7082 end if;
7083 --
7084 if g_debug then
7085 hr_utility.set_location ('Leaving '||l_proc, 10);
7086 end if;
7087 --
7088 exception
7089 --
7090 when hr_api.validate_enabled
7091 then
7092 rollback to process_pcp_dpnt_actn_items;
7093 --
7094 if g_debug then
7095 hr_utility.set_location(' Leaving:'||l_proc, 10);
7096 end if;
7097 --
7098 when others then
7099 if g_debug then
7100 hr_utility.set_location('Exception Raised '||l_proc, 10);
7101 end if;
7102
7103 p_rslt_object_version_number := l_rslt_object_version_number ;
7104 p_suspend_flag := l_suspend_flag ;
7105 p_pcp_dpnt_actn_warning := null ;
7106
7107 raise;
7108 --
7109 end process_pcp_dpnt_actn_items;
7110 --
7111 -- ----------------------------------------------------------------------------
7112 -- |--------------------< process_pcp_actn_items >------------------------|
7113 -- ----------------------------------------------------------------------------
7114 --
7115 procedure process_pcp_actn_items
7116 (p_validate in boolean default FALSE
7117 ,p_prtt_enrt_rslt_id in number
7118 ,p_effective_date in date
7119 ,p_business_group_id in number
7120 ,p_datetrack_mode in varchar2 default hr_api.g_correction
7121 ,p_post_rslt_flag in varchar2 default 'Y'
7122 ,p_rslt_object_version_number in out nocopy number
7123 ,p_suspend_flag in out nocopy varchar2
7124 ,p_pcp_actn_warning out nocopy boolean) is
7125 --
7126 l_proc varchar2(80);
7127
7128 l_rslt_object_version_number number(15);
7129 l_suspend_flag varchar2(20);
7130
7131 --
7132 -- this procedure determines if the plan in the result has pcp_dsgn_cd on
7133 -- if it's on we need to write an action item and suspend the result
7134 l_pcp_dsgn_cd varchar2(30) := null;
7135 l_pcp_actn_warning boolean := FALSE;
7136
7137 cursor c_pcp_cd_oipl is
7138 select cop.pcp_dsgn_cd
7139 from ben_prtt_enrt_rslt_f perf,
7140 ben_oipl_f cop
7141 where cop.oipl_id = perf.oipl_id
7142 and perf.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
7143 and perf.business_group_id = p_business_group_id
7144 and cop.business_group_id = p_business_group_id
7145 and p_effective_date between cop.effective_start_date
7146 and cop.effective_end_date
7147 and p_effective_date between perf.effective_start_date
7148 and perf.effective_end_date
7149 and cop.pcp_dsgn_cd is not null ;
7150 -- added the cop.pcp_dsgn_cd is not null condition bug 1421978
7151 cursor c_pcp_cd is
7152 select pcp.pcp_dsgn_cd
7153 from ben_prtt_enrt_rslt_f perf,
7154 ben_pl_pcp pcp
7155 where pcp.pl_id = perf.pl_id
7156 and perf.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
7157 and perf.business_group_id = p_business_group_id
7158 and pcp.business_group_id = p_business_group_id
7159 and p_effective_date between perf.effective_start_date
7160 and perf.effective_end_date;
7161 --
7162 begin
7163 --
7164 g_debug := hr_utility.debug_enabled;
7165 if g_debug then
7166 l_proc := g_package||'.process_pcp_actn_items';
7167 hr_utility.set_location ('Entering '||l_proc,10);
7168 end if;
7169 --
7170 l_rslt_object_version_number := p_rslt_object_version_number ;
7171 l_suspend_flag := p_suspend_flag ;
7172
7173 -- Issue a savepoint if operating in validate only mode
7174 --
7175 savepoint process_pcp_actn_items;
7176 --
7177 open c_pcp_cd_oipl;
7178 fetch c_pcp_cd_oipl into l_pcp_dsgn_cd;
7179 if c_pcp_cd_oipl%notfound then
7180 close c_pcp_cd_oipl;
7181 open c_pcp_cd;
7182 fetch c_pcp_cd into l_pcp_dsgn_cd;
7183 if c_pcp_cd%notfound then
7184 close c_pcp_cd;
7185 return;
7186 else
7187 close c_pcp_cd;
7188 if g_debug then
7189 hr_utility.set_location('l_pcp_dsgn_cd '||l_pcp_dsgn_cd , 198);
7190 end if;
7191 if g_debug then
7192 hr_utility.set_location('p_prtt_enrt_rslt_id '||p_prtt_enrt_rslt_id ,198);
7193 end if;
7194
7195 determine_pcp_actn_items
7196 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7197 ,p_effective_date => p_effective_date
7198 ,p_business_group_id => p_business_group_id
7199 ,p_datetrack_mode => p_datetrack_mode
7200 ,p_post_rslt_flag => p_post_rslt_flag
7201 ,p_pcp_dsgn_cd => l_pcp_dsgn_cd
7202 ,p_rslt_object_version_number => p_rslt_object_version_number
7203 ,p_suspend_flag => p_suspend_flag
7204 ,p_pcp_actn_warning => l_pcp_actn_warning);
7205 end if;
7206 else
7207 close c_pcp_cd_oipl;
7208 if g_debug then
7209 hr_utility.set_location('l_pcp_dsgn_cd '||l_pcp_dsgn_cd , 199);
7210 end if;
7211 if g_debug then
7212 hr_utility.set_location('p_prtt_enrt_rslt_id '||p_prtt_enrt_rslt_id ,199);
7213 end if;
7214
7215 determine_pcp_actn_items
7216 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7217 ,p_effective_date => p_effective_date
7218 ,p_business_group_id => p_business_group_id
7219 ,p_datetrack_mode => p_datetrack_mode
7220 ,p_post_rslt_flag => p_post_rslt_flag
7221 ,p_pcp_dsgn_cd => l_pcp_dsgn_cd
7222 ,p_rslt_object_version_number => p_rslt_object_version_number
7223 ,p_suspend_flag => p_suspend_flag
7224 ,p_pcp_actn_warning => l_pcp_actn_warning);
7225 end if;
7226 --
7227 p_pcp_actn_warning := l_pcp_actn_warning;
7228 --
7229 if p_validate then
7230 raise hr_api.validate_enabled;
7231 end if;
7232 --
7233 if g_debug then
7234 hr_utility.set_location ('Leaving '||l_proc, 10);
7235 end if;
7236 --
7237 exception
7238 --
7239 when hr_api.validate_enabled
7240 then
7241 rollback to process_pcp_actn_items;
7242 --
7243 if g_debug then
7244 hr_utility.set_location(' Leaving:'||l_proc, 10);
7245 end if;
7246 --
7247 when others then
7248 if g_debug then
7249 hr_utility.set_location('Exception Raised '||l_proc, 10);
7250 end if;
7251
7252 p_rslt_object_version_number := l_rslt_object_version_number ;
7253 p_suspend_flag := l_suspend_flag ;
7254 p_pcp_actn_warning := null;
7255
7256 raise;
7257 --
7258 end process_pcp_actn_items;
7259 --
7260 -- ----------------------------------------------------------------------------
7261 -- |---------------------------< check_bnf_ttee >-----------------------------|
7262 -- ----------------------------------------------------------------------------
7263 --
7264 function check_bnf_ttee
7265 (p_pl_bnf_id in number
7266 ,p_effective_date in date
7267 ,p_business_group_id in number)
7268 return boolean is
7269 --
7270 -- This routine will check if designated brneficiary is over the age 18 and
7271 -- will return FALSE if under 18 and TRUE if over 18
7272 --
7273 l_proc varchar2(80) ;
7274 --
7275 cursor c_bnf_age is
7276 select round
7277 (trunc
7278 (months_between(p_effective_date, per.date_of_birth))/ 12
7279 ) bnf_age,
7280 pb.ttee_person_id
7281 from per_all_people_f per,
7282 ben_pl_bnf_f pb
7283 where pb.pl_bnf_id = p_pl_bnf_id
7284 and per.person_id = pb.bnf_person_id
7285 and per.business_group_id = p_business_group_id
7286 and p_effective_date between per.effective_start_date
7287 and per.effective_end_date;
7288 --
7289 l_bnf_age c_bnf_age%rowtype;
7290 --
7291 --
7292 begin
7293 --
7294 if g_debug then
7295 l_proc := g_package||'.check_bnf_ttee';
7296 hr_utility.set_location ('Entering '||l_proc,10);
7297 end if;
7298 --
7299 open c_bnf_age;
7300 fetch c_bnf_age into l_bnf_age;
7301 close c_bnf_age;
7302 --
7303 if g_debug then
7304 hr_utility.set_location ('Leaving ' ||l_proc,10);
7305 end if;
7306 --
7307 if (l_bnf_age.bnf_age IS NOT NULL and
7308 l_bnf_age.bnf_age >= 18)
7309 OR
7310 (l_bnf_age.bnf_age is not null and
7311 l_bnf_age.bnf_age < 18 and
7312 l_bnf_age.ttee_person_id is not null) then
7313 return TRUE;
7314 elsif l_bnf_age.bnf_age is not null and
7315 l_bnf_age.bnf_age < 18 and
7316 l_bnf_age.ttee_person_id is null then
7317 return FALSE;
7318 end if;
7319 --
7320 exception
7321 when others then
7322 if g_debug then
7323 hr_utility.set_location('Exception Raised '||l_proc, 10);
7324 end if;
7325 raise;
7326 --
7327 end check_bnf_ttee;
7328 --
7329 -- ----------------------------------------------------------------------------
7330 -- |--------------------------< check_bnf_ctfn >------------------------------|
7331 -- ----------------------------------------------------------------------------
7332 --
7333 function check_bnf_ctfn
7334 (p_prtt_enrt_actn_id in number
7335 ,p_pl_bnf_id in number
7336 ,p_effective_date in date)
7337 return boolean is
7338 --
7339 -- This function checks for certifications for an enrollment result.
7340 -- Check if certifications were provided. For this beneficiary check
7341 -- if the bnf_ctfn_rqd_flag is 'Y' then write action item
7342 -- if the bnf_ctfn_recd_dt IS NULL. The bnf_ctfn_recd_dt is filled in via
7343 -- a form interface.
7344 --
7345 l_required number;
7346 l_optional number;
7347 l_open_required number;
7348 l_open_optional number;
7349 l_return boolean;
7350 --
7351 l_proc varchar2(80) ;
7352 --
7353 begin
7354 --
7355 g_debug := hr_utility.debug_enabled;
7356 if g_debug then
7357 l_proc := g_package||'.check_bnf_ctfn';
7358 hr_utility.set_location ('Entering '||l_proc,10);
7359 end if;
7360 --
7361 get_ctfn_count
7362 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
7363 ,p_pl_bnf_id => p_pl_bnf_id
7364 ,p_effective_date => p_effective_date
7365 ,p_required_count => l_required
7366 ,p_optional_count => l_optional
7367 ,p_open_required_count => l_open_required
7368 ,p_open_optional_count => l_open_optional);
7369 --
7370 l_return := check_ctfn(p_required_count => l_required
7371 ,p_optional_count => l_optional
7372 ,p_open_required_count => l_open_required
7373 ,p_open_optional_count => l_open_optional);
7374 --
7375 if g_debug then
7376 hr_utility.set_location ('Leaving '||l_proc,10);
7377 end if;
7378 --
7379 return l_return;
7380 --
7381 exception
7382 --
7383 when others then
7384 if g_debug then
7385 hr_utility.set_location('Exception Raised '||l_proc, 10);
7386 end if;
7387 raise;
7388 --
7389 end check_bnf_ctfn;
7390 --
7391 -- ----------------------------------------------------------------------------
7392 -- |-------------------< check_bnf_actn_item_dfnd >----------------------------|
7393 -- ----------------------------------------------------------------------------
7394 --
7395 function check_bnf_actn_item_dfnd
7396 (p_pl_id number
7397 ,p_actn_type_cd varchar2
7398 ,p_business_group_id number
7399 ,p_effective_date date)
7400 return boolean is
7401 --
7402 -- Bug 1169240 - checking the popl_actn_typ table to see if action item defined
7403 -- This check is being done because the flags in ben_pl_f table are not getting
7404 -- updated when enrollment action items are attached to a plan . This was noticed
7405 -- for beneficiary related action types.
7406 --
7407 cursor c_bnf_actn_item is
7408 select null
7409 from ben_popl_actn_typ_f pat,
7410 ben_actn_typ eat
7411 where pat.pl_id = p_pl_id
7412 and pat.actn_typ_id = eat.actn_typ_id
7413 and eat.type_cd = p_actn_type_cd
7414 and pat.business_group_id = p_business_group_id
7415 and p_effective_date between
7416 pat.effective_start_date and pat.effective_end_date ;
7417 --
7418 l_dummy char ;
7419 l_exists boolean ;
7420 --
7421 l_proc varchar2(80) ;
7422 --
7423 begin
7424 --
7425 if g_debug then
7426 l_proc := g_package||'.check_bnf_actn_item_dfnd' ;
7427 hr_utility.set_location ('Entering '||l_proc,10);
7428 end if;
7429 --
7430 open c_bnf_actn_item ;
7431 fetch c_bnf_actn_item into l_dummy;
7432 --
7433 if c_bnf_actn_item%FOUND then
7434 --
7435 l_exists := TRUE;
7436 --
7437 else
7438 --
7439 l_exists := FALSE;
7440 --
7441 end if;
7442 --
7443 close c_bnf_actn_item;
7444 --
7445 if g_debug then
7446 hr_utility.set_location ('Leaving '||l_proc,10);
7447 end if;
7448 --
7449 return l_exists;
7450 --
7451 end check_bnf_actn_item_dfnd ;
7452 --
7453 -- ----------------------------------------------------------------------------
7454 -- |----------------------< write_new_bnf_ctfn_item >-------------------------|
7455 -- ----------------------------------------------------------------------------
7456 --
7457 procedure write_new_bnf_ctfn_item
7458 (p_pl_bnf_id in number
7459 ,p_prtt_enrt_actn_id in number
7460 ,p_bnf_ctfn_typ_cd in varchar2
7461 ,p_bnf_ctfn_rqd_flag in varchar2
7462 ,p_effective_date in date
7463 ,p_business_group_id in number
7464 ,p_object_version_number out nocopy number
7465 ,p_pl_bnf_ctfn_prvdd_id out nocopy number) is
7466 --
7467 -- this procedure writes a beneficiary certification to
7468 -- ben_pl_bnf_ctfn_prvdd_f
7469 --
7470 l_proc varchar2(80);
7471 l_effective_start_date date;
7472 l_effective_end_date date;
7473 --
7474 begin
7475 --
7476 if g_debug then
7477 l_proc := g_package||'.write_new_bnf_ctfn_item';
7478 hr_utility.set_location ('Entering '||l_proc,10);
7479 end if;
7480 --
7481 -- write a new record for each beneficiary certification item
7482 --
7483 ben_pl_bnf_ctfn_prvdd_api.create_pl_bnf_ctfn_prvdd
7484 (p_pl_bnf_id => p_pl_bnf_id
7485 ,p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
7486 ,p_bnf_ctfn_typ_cd => p_bnf_ctfn_typ_cd
7487 ,p_bnf_ctfn_rqd_flag => p_bnf_ctfn_rqd_flag
7488 ,p_effective_date => p_effective_date
7489 ,p_business_group_id => p_business_group_id
7490 ,p_object_version_number => p_object_version_number
7491 ,p_effective_start_date => l_effective_start_date
7492 ,p_effective_end_date => l_effective_end_date
7493 ,p_pl_bnf_ctfn_prvdd_id => p_pl_bnf_ctfn_prvdd_id);
7494 --
7495 if g_debug then
7496 hr_utility.set_location ('Leaving '||l_proc, 10);
7497 end if;
7498 --
7499 exception
7500 /* we could have duplicates already here from prior run */
7501 when others then
7502 if g_debug then
7503 hr_utility.set_location('Exception Raised '||l_proc, 10);
7504 end if;
7505
7506 p_object_version_number := null ;
7507 p_pl_bnf_ctfn_prvdd_id := null;
7508
7509 raise;
7510 --
7511 end write_new_bnf_ctfn_item;
7512 --
7513 -- ----------------------------------------------------------------------------
7514 -- |-------------------< determine_bnf_miss_actn_items >----------------------|
7515 -- ----------------------------------------------------------------------------
7516 --
7517 procedure determine_bnf_miss_actn_items
7518 (p_prtt_enrt_rslt_id in number
7519 ,p_effective_date in date
7520 ,p_business_group_id in number
7521 ,p_datetrack_mode in varchar2 default hr_api.g_correction
7522 ,p_post_rslt_flag in varchar2 default 'Y'
7523 ,p_rslt_object_version_number in out nocopy number
7524 ,p_bnf_actn_warning out nocopy boolean) is
7525 --
7526 -- This procedure determines if a designated beneficiary has missing info like
7527 -- DOB, SSN, ADRS, CTFN, TTEE that is required to complete an enrollment and
7528 -- writes action items if required data is missing.
7529 --
7530 l_proc varchar2(80) ;
7531 --
7532 l_bnf_dsgn_cd varchar2(30);
7533 l_rqd_data_found boolean;
7534 l_prtt_enrt_ctfn_prvdd_id number;
7535 l_outputs ff_exec.outputs_t;
7536 l_bnf_actn_warning boolean := FALSE;
7537 l_actn_typ_id number(15);
7538 l_prtt_enrt_actn_id number(15);
7539 l_cmpltd_dt date;
7540 l_object_version_number number(15);
7541 l_pl_bnf_ctfn_prvdd_id number;
7542 l_dob_found boolean;
7543 l_dummy varchar2(30);
7544 l_ctfn_defined boolean := FALSE;
7545 l_person_id number;
7546 l_rslt_object_version_number number(15) ;
7547
7548 --
7549 --
7550 -- Cursor to retrieve certifications defined for a plan and for the bnf
7551 -- person's contact_type.
7552 --
7553 cursor c_ctfns(v_bnf_person_id number, v_pl_id number, v_person_id number) is
7554 select pl.lack_ctfn_sspnd_enrt_flag ctflag,
7555 pl.bnf_ctfn_typ_cd ctcvgcd,
7556 pl.ctfn_rqd_when_rl ctrrl,
7557 pl.rqd_flag rqd_flag,
7558 pl.rlshp_typ_cd ctrlshcd,
7559 pl.bnf_typ_cd, pl.pl_id
7560 from ben_pl_bnf_ctfn_f pl
7561 where pl.bnf_ctfn_typ_cd <> 'NSC'
7562 and pl.pl_id = v_pl_id
7563 and (pl.rlshp_typ_cd is null or
7564 pl.rlshp_typ_cd in (select contact_type
7565 from per_contact_relationships
7566 where contact_person_id = v_bnf_person_id
7567 and person_id = v_person_id
7568 and business_group_id = p_business_group_id
7569 and p_effective_date
7570 between nvl(date_start, p_effective_date)
7571 and nvl(date_end, hr_api.g_eot)))
7572 and pl.business_group_id = p_business_group_id
7573 and p_effective_date between
7574 pl.effective_start_date and pl.effective_end_date;
7575 --
7576 cursor c_ctfns_exist(v_pl_bnf_id number) is
7577 select 's'
7578 from ben_pl_bnf_ctfn_prvdd_f
7579 where pl_bnf_id = v_pl_bnf_id
7580 and p_effective_date between effective_start_date
7581 and effective_end_date
7582 and business_group_id = p_business_group_id;
7583 --
7584 cursor c_dsgn_bnf is
7585 select pbd.pl_bnf_id,
7586 pbd.bnf_person_id
7587 from ben_pl_bnf_f pbd,
7588 ben_per_in_ler pil
7589 where pbd.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
7590 and pbd.dsgn_strt_dt is not null
7591 and nvl(pbd.dsgn_thru_dt, hr_api.g_eot) = hr_api.g_eot
7592 and pbd.business_group_id = p_business_group_id
7593 and p_effective_date between pbd.effective_start_date
7594 and pbd.effective_end_date
7595 and pil.per_in_ler_id=pbd.per_in_ler_id
7596 and pil.business_group_id=p_business_group_id
7597 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
7598 -- Check fo DOB, SSN, ADDRESS only for person beneficiaries
7599 -- and not for Organization Beneficiaries
7600 and pbd.bnf_person_id is not null; -- Bug : 3854556
7601 --
7602 cursor c_ctfn_defined(v_bnf_person_id number,
7603 v_person_id number,
7604 p_pl_id number) is
7605 select 's'
7606 from ben_pl_bnf_ctfn_f
7607 where bnf_ctfn_typ_cd <> 'NSC'
7608 and pl_id = p_pl_id
7609 and (bnf_typ_cd is null or bnf_typ_cd = 'P')
7610 and (rlshp_typ_cd is null
7611 or
7612 rlshp_typ_cd in (select contact_type
7613 from per_contact_relationships
7614 where contact_person_id = v_bnf_person_id
7615 and person_id = v_person_id
7616 and business_group_id = p_business_group_id
7617 and p_effective_date
7618 between nvl(date_start, p_effective_date)
7619 and nvl(date_end, hr_api.g_eot)))
7620 and business_group_id = p_business_group_id
7621 and p_effective_date between effective_start_date
7622 and effective_end_date;
7623 cursor c_person_id is
7624 select person_id,
7625 pl_id
7626 from ben_prtt_enrt_rslt_f
7627 where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id;
7628 --
7629 l_bnf_actn_typ_dfnd boolean; -- bug 1169240
7630 l_rqd_flag varchar2(1);
7631 l_pl_id number;
7632 --
7633 -- start bug 5667528
7634 cursor c_pen_info is
7635 SELECT pen.pgm_id, pen.pl_id, pen.pl_typ_id, pen.oipl_id, pen.ler_id,
7636 pen.person_id, pen.business_group_id
7637 FROM ben_prtt_enrt_rslt_f pen
7638 WHERE pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
7639 AND p_effective_date BETWEEN pen.effective_start_date
7640 AND pen.effective_end_date;
7641 --
7642 pen_info_rec c_pen_info%ROWTYPE;
7643 --
7644 cursor c_asg(v_person_id in number) is
7645 SELECT asg.assignment_id, asg.organization_id
7646 FROM per_all_assignments_f asg
7647 WHERE asg.person_id = v_person_id
7648 AND asg.assignment_type <> 'C'
7649 AND asg.primary_flag = 'Y'
7650 AND p_effective_date BETWEEN asg.effective_start_date
7651 AND asg.effective_end_date;
7652 asg_rec c_asg%ROWTYPE;
7653 --
7654 cursor c_opt (v_oipl_id in number) is
7655 SELECT opt_id
7656 FROM ben_oipl_f oipl
7657 WHERE oipl.oipl_id = v_oipl_id
7658 AND oipl.business_group_id = p_business_group_id
7659 AND p_effective_date BETWEEN oipl.effective_start_date
7660 AND oipl.effective_end_date;
7661 opt_rec c_opt%ROWTYPE;
7662 --
7663 CURSOR c_curr_ovn_of_actn (c_prtt_enrt_actn_id NUMBER)
7664 IS
7665 SELECT object_version_number
7666 FROM ben_prtt_enrt_actn_f
7667 WHERE prtt_enrt_actn_id = c_prtt_enrt_actn_id
7668 AND business_group_id = p_business_group_id
7669 AND p_effective_date BETWEEN effective_start_date
7670 AND effective_end_date;
7671
7672 cursor c_act_name (v_actn_typ_id in number) is
7673 select tl.name actn_typ_name
7674 from ben_actn_typ typ,
7675 ben_actn_typ_tl tl
7676 where v_actn_typ_id = typ.actn_typ_id
7677 and typ.actn_typ_id = tl.actn_typ_id
7678 and tl.language = userenv('lang')
7679 and typ.type_cd <> 'BNF'
7680 and typ.type_cd like 'BNF%'
7681 and typ.business_group_id = p_business_group_id;
7682 --
7683 CURSOR c_plan_name(v_plan_id in number)
7684 IS
7685 SELECT pl.NAME
7686 FROM ben_pl_f pl
7687 WHERE pl.pl_id = v_plan_id
7688 AND p_effective_date BETWEEN pl.effective_start_date
7689 AND pl.effective_end_date;
7690
7691 plan_name_rec c_plan_name%ROWTYPE;
7692 l_act_name ben_actn_typ_tl.name%TYPE;
7693 l_message_name fnd_new_messages.message_name%TYPE := 'BEN_94108_BNF_ACT_ITEM';
7694 l_write_ctfn BOOLEAN;
7695 l_ff_ctfn_exits BOOLEAN;
7696 --
7697 -- end bug 5667528
7698 begin
7699 --
7700
7701 if g_debug then
7702 l_proc := g_package||'.determine_bnf_miss_actn_items';
7703 hr_utility.set_location ('Entering '||l_proc,10);
7704 end if;
7705 --
7706 l_rslt_object_version_number := p_rslt_object_version_number;
7707 --
7708 open c_person_id;
7709 fetch c_person_id into l_person_id, l_pl_id;
7710 close c_person_id;
7711 --
7712 -- get data from pl table.
7713 open g_bnf_pl(p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7714 ,p_effective_date => p_effective_date);
7715 fetch g_bnf_pl into g_bnf_pl_rec;
7716 close g_bnf_pl;
7717 --
7718 for l_dsgn_bnf in c_dsgn_bnf loop
7719 --
7720 -- date of birth action item
7721 --
7722 if g_debug then
7723 hr_utility.set_location('DOB action item ' || l_proc, 20);
7724 end if;
7725 --
7726 l_actn_typ_id := get_actn_typ_id
7727 (p_type_cd => 'BNFDOB'
7728 ,p_business_group_id => p_business_group_id);
7729 --
7730 -- bug 1169240
7731 --
7732 l_bnf_actn_typ_dfnd := check_bnf_actn_item_dfnd
7733 (p_pl_id => g_bnf_pl_rec.pl_id
7734 ,p_actn_type_cd => 'BNFDOB'
7735 ,p_business_group_id => p_business_group_id
7736 ,p_effective_date => p_effective_date);
7737 --
7738 -- end bug 1169240
7739 --
7740 get_prtt_enrt_actn_id
7741 (p_actn_typ_id => l_actn_typ_id
7742 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7743 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
7744 ,p_effective_date => p_effective_date
7745 ,p_business_group_id => p_business_group_id
7746 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
7747 ,p_cmpltd_dt => l_cmpltd_dt
7748 ,p_object_version_number => l_object_version_number);
7749 --
7750 if g_bnf_pl_rec.susp_if_bnf_dob_nt_prv_cd is not null or l_bnf_actn_typ_dfnd then --date of birth is required for plan
7751 --
7752 if g_debug then
7753 hr_utility.set_location('DOB rqd flag is Y', 10);
7754 end if;
7755 --
7756 --
7757 -- check if person has a date of birth entry
7758 --
7759 l_rqd_data_found := check_dob
7760 (p_person_id => l_dsgn_bnf.bnf_person_id
7761 ,p_effective_date => p_effective_date
7762 ,p_business_group_id => p_business_group_id);
7763 --
7764 if l_rqd_data_found = FALSE then
7765 l_bnf_actn_warning := TRUE;
7766 l_dob_found := FALSE;
7767 elsif l_rqd_data_found = TRUE then
7768 l_dob_found := TRUE;
7769 end if;
7770 --
7771 if g_bnf_pl_rec.susp_if_bnf_dob_nt_prv_cd = 'RQDS' then
7772 l_rqd_flag := 'Y';
7773 else
7774 l_rqd_flag := 'N';
7775 end if;
7776 --
7777 process_action_item
7778 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
7779 ,p_actn_typ_id => l_actn_typ_id
7780 ,p_cmpltd_dt => l_cmpltd_dt
7781 ,p_object_version_number => l_object_version_number
7782 ,p_effective_date => p_effective_date
7783 ,p_rqd_data_found => l_rqd_data_found
7784 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7785 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
7786 ,p_rqd_flag => l_rqd_flag --g_bnf_pl_rec.rqd
7787 ,p_post_rslt_flag => p_post_rslt_flag
7788 ,p_business_group_id => p_business_group_id
7789 ,p_datetrack_mode => p_datetrack_mode
7790 ,p_rslt_object_version_number => p_rslt_object_version_number);
7791 --
7792 else
7793 --
7794 if g_debug then
7795 hr_utility.set_location('DOB rqd flag is N', 10);
7796 end if;
7797 --
7798 -- bnf_dob_rqd_flag is 'N';
7799 -- if date_track mode is updating and designation at plan level
7800 -- delete action type of type BNFDOB
7801 --
7802 if l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE then
7803 --
7804 delete_action_item
7805 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
7806 ,p_object_version_number => l_object_version_number
7807 ,p_business_group_id => p_business_group_id
7808 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7809 ,p_rslt_object_version_number => p_rslt_object_version_number
7810 ,p_effective_date => p_effective_date
7811 ,p_datetrack_mode => p_datetrack_mode
7812 ,p_post_rslt_flag => p_post_rslt_flag);
7813 --
7814 else
7815 NULL; -- nothing to do at this time.
7816 end if;
7817 --
7818 end if; -- bnf_dob_rqd_flag
7819 --
7820 -- legislative code (social security number/national identifier) action item
7821 --
7822 if g_debug then
7823 hr_utility.set_location('SSN action item ' || l_proc, 35);
7824 end if;
7825 --
7826 l_actn_typ_id := get_actn_typ_id
7827 (p_type_cd => 'BNFSSN'
7828 ,p_business_group_id => p_business_group_id);
7829 --
7830 -- bug 1169240
7831 --
7832 l_bnf_actn_typ_dfnd := check_bnf_actn_item_dfnd
7833 (p_pl_id => g_bnf_pl_rec.pl_id
7834 ,p_actn_type_cd => 'BNFSSN'
7835 ,p_business_group_id => p_business_group_id
7836 ,p_effective_date => p_effective_date);
7837 --
7838 -- end bug 1169240
7839 --
7840 get_prtt_enrt_actn_id
7841 (p_actn_typ_id => l_actn_typ_id
7842 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7843 ,p_effective_date => p_effective_date
7844 ,p_business_group_id => p_business_group_id
7845 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
7846 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
7847 ,p_cmpltd_dt => l_cmpltd_dt
7848 ,p_object_version_number => l_object_version_number);
7849 --
7850 if g_bnf_pl_rec.susp_if_bnf_ssn_nt_prv_cd is not null or l_bnf_actn_typ_dfnd then --legislative id is rqd for plan
7851 --
7852 if g_debug then
7853 hr_utility.set_location('SSN rqd flag is Y', 10);
7854 end if;
7855 --
7856 -- check if person has a national identifier entry
7857 --
7858 l_rqd_data_found := check_legid
7859 (p_person_id => l_dsgn_bnf.bnf_person_id
7860 ,p_effective_date => p_effective_date
7861 ,p_business_group_id => p_business_group_id);
7862 --
7863 if l_rqd_data_found = FALSE then
7864 l_bnf_actn_warning := TRUE;
7865 end if;
7866 --
7867 if g_bnf_pl_rec.susp_if_bnf_ssn_nt_prv_cd = 'RQDS' then
7868 l_rqd_flag := 'Y';
7869 else
7870 l_rqd_flag := 'N';
7871 end if;
7872 --
7873 process_action_item
7874 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
7875 ,p_actn_typ_id => l_actn_typ_id
7876 ,p_cmpltd_dt => l_cmpltd_dt
7877 ,p_object_version_number => l_object_version_number
7878 ,p_effective_date => p_effective_date
7879 ,p_rqd_data_found => l_rqd_data_found
7880 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7881 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
7882 ,p_rqd_flag => l_rqd_flag --rqd
7883 ,p_post_rslt_flag => p_post_rslt_flag
7884 ,p_business_group_id => p_business_group_id
7885 ,p_datetrack_mode => p_datetrack_mode
7886 ,p_rslt_object_version_number => p_rslt_object_version_number);
7887 --
7888 else
7889 --
7890 if g_debug then
7891 hr_utility.set_location('SSN rqd flag is N', 10);
7892 end if;
7893 --
7894 -- bnf_legv_id_rqd_flag is 'N'
7895 -- if date_track mode is updating and designation at plan level
7896 -- delete action type of type BNFSSN.
7897 --
7898 if l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE then
7899 --
7900 delete_action_item
7901 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
7902 ,p_object_version_number => l_object_version_number
7903 ,p_business_group_id => p_business_group_id
7904 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7905 ,p_rslt_object_version_number => p_rslt_object_version_number
7906 ,p_effective_date => p_effective_date
7907 ,p_datetrack_mode => p_datetrack_mode
7908 ,p_post_rslt_flag => p_post_rslt_flag);
7909 --
7910 else
7911 NULL; -- nothing to do at this time.
7912 end if;
7913 --
7914 end if; -- bnf_legv_id_rqd_flag
7915 --
7916 -- address action item
7917 --
7918 l_actn_typ_id := get_actn_typ_id
7919 (p_type_cd => 'BNFADDR'
7920 ,p_business_group_id => p_business_group_id);
7921 --
7922 -- bug 1169240
7923 --
7924 l_bnf_actn_typ_dfnd := check_bnf_actn_item_dfnd
7925 (p_pl_id => g_bnf_pl_rec.pl_id
7926 ,p_actn_type_cd => 'BNFADDR'
7927 ,p_business_group_id => p_business_group_id
7928 ,p_effective_date => p_effective_date);
7929 --
7930 -- end bug 1169240
7931 --
7932 get_prtt_enrt_actn_id
7933 (p_actn_typ_id => l_actn_typ_id
7934 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7935 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
7936 ,p_effective_date => p_effective_date
7937 ,p_business_group_id => p_business_group_id
7938 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
7939 ,p_cmpltd_dt => l_cmpltd_dt
7940 ,p_object_version_number => l_object_version_number);
7941 --
7942 if g_bnf_pl_rec.susp_if_bnf_adr_nt_prv_cd is not null or l_bnf_actn_typ_dfnd then -- address is required for plan
7943 --
7944 if g_debug then
7945 hr_utility.set_location('ADDR rqd flag is Y', 10);
7946 end if;
7947 --
7948 -- check if person has an address
7949 --
7950 l_rqd_data_found := check_adrs
7951 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7952 ,p_dpnt_bnf_person_id => l_dsgn_bnf.bnf_person_id
7953 ,p_effective_date => p_effective_date
7954 ,p_business_group_id => p_business_group_id);
7955 --
7956 if l_rqd_data_found = FALSE then
7957 l_bnf_actn_warning := TRUE;
7958 end if;
7959 --
7960 if g_bnf_pl_rec.susp_if_bnf_adr_nt_prv_cd = 'RQDS' then
7961 l_rqd_flag := 'Y';
7962 else
7963 l_rqd_flag := 'N';
7964 end if;
7965 --
7966 process_action_item
7967 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
7968 ,p_actn_typ_id => l_actn_typ_id
7969 ,p_cmpltd_dt => l_cmpltd_dt
7970 ,p_object_version_number => l_object_version_number
7971 ,p_effective_date => p_effective_date
7972 ,p_rqd_data_found => l_rqd_data_found
7973 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7974 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
7975 ,p_rqd_flag => l_rqd_flag --g_bnf_pl_rec.rqd
7976 ,p_post_rslt_flag => p_post_rslt_flag
7977 ,p_business_group_id => p_business_group_id
7978 ,p_datetrack_mode => p_datetrack_mode
7979 ,p_rslt_object_version_number => p_rslt_object_version_number);
7980 --
7981 else
7982 --
7983 if g_debug then
7984 hr_utility.set_location('ADDR rqd flag is N', 10);
7985 end if;
7986 --
7987 -- bnf_adrs_rqd_flag is 'N'
7988 -- if date_track mode is updating and designation at plan level
7989 -- delete action type of type BNFADDR.
7990 --
7991 if l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE then
7992 --
7993 delete_action_item
7994 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
7995 ,p_object_version_number => l_object_version_number
7996 ,p_business_group_id => p_business_group_id
7997 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7998 ,p_rslt_object_version_number => p_rslt_object_version_number
7999 ,p_effective_date => p_effective_date
8000 ,p_datetrack_mode => p_datetrack_mode
8001 ,p_post_rslt_flag => p_post_rslt_flag);
8002 --
8003 else
8004 NULL; -- nothing to do at this time.
8005 end if;
8006 --
8007 end if; -- bnf_adrs_rqd_flag
8008 --
8009 -- trustee action item
8010 --
8011 l_actn_typ_id := get_actn_typ_id
8012 (p_type_cd => 'BNFTTEE'
8013 ,p_business_group_id => p_business_group_id);
8014 --
8015 -- bug 1169240
8016 --
8017 l_bnf_actn_typ_dfnd := check_bnf_actn_item_dfnd
8018 (p_pl_id => g_bnf_pl_rec.pl_id
8019 ,p_actn_type_cd => 'BNFTTEE'
8020 ,p_business_group_id => p_business_group_id
8021 ,p_effective_date => p_effective_date);
8022 --
8023 -- end bug 1169240
8024 --
8025 get_prtt_enrt_actn_id
8026 (p_actn_typ_id => l_actn_typ_id
8027 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8028 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8029 ,p_effective_date => p_effective_date
8030 ,p_business_group_id => p_business_group_id
8031 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8032 ,p_cmpltd_dt => l_cmpltd_dt
8033 ,p_object_version_number => l_object_version_number);
8034 --
8035 -- Check the trustee action item only if the DOB of beneficiary is present
8036 --
8037 if ( g_bnf_pl_rec.bnf_dsge_mnr_ttee_rqd_flag = 'Y' or l_bnf_actn_typ_dfnd ) and
8038 l_dob_found = TRUE then
8039 --
8040 if g_debug then
8041 hr_utility.set_location('TTEE rqd flag is Y and DOB found', 10);
8042 end if;
8043 --
8044 --
8045 -- check if the designated beneficiary is over age of 18
8046 --
8047 l_rqd_data_found := check_bnf_ttee
8048 (p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8049 ,p_effective_date => p_effective_date
8050 ,p_business_group_id => p_business_group_id);
8051 --
8052 if l_rqd_data_found = FALSE then
8053 -- designated beneficiary is a minor
8054 l_bnf_actn_warning := TRUE;
8055 --
8056 end if;
8057 --
8058 process_action_item
8059 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8060 ,p_actn_typ_id => l_actn_typ_id
8061 ,p_cmpltd_dt => l_cmpltd_dt
8062 ,p_object_version_number => l_object_version_number
8063 ,p_effective_date => p_effective_date
8064 ,p_rqd_data_found => l_rqd_data_found
8065 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8066 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8067 ,p_rqd_flag => g_bnf_pl_rec.rqd
8068 ,p_post_rslt_flag => p_post_rslt_flag
8069 ,p_business_group_id => p_business_group_id
8070 ,p_datetrack_mode => p_datetrack_mode
8071 ,p_rslt_object_version_number => p_rslt_object_version_number);
8072 --
8073 else
8074 --
8075 if g_debug then
8076 hr_utility.set_location('TTEE rqd flag is N or DOB not found', 10);
8077 end if;
8078 --
8079 -- bnf_dsge_mnr_ttee_rqd_flag is 'N'
8080 -- if date_track mode is updating and designation at plan level
8081 -- delete action type of type BNFTTEE.
8082 --
8083 if l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE then
8084 --
8085 delete_action_item
8086 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8087 ,p_object_version_number => l_object_version_number
8088 ,p_business_group_id => p_business_group_id
8089 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8090 ,p_rslt_object_version_number => p_rslt_object_version_number
8091 ,p_effective_date => p_effective_date
8092 ,p_datetrack_mode => p_datetrack_mode
8093 ,p_post_rslt_flag => p_post_rslt_flag);
8094 --
8095 else
8096 NULL; -- nothing to do at this time.
8097 end if;
8098 --
8099 end if; -- bnf_dsge_mnr_ttee_rqd_flag
8100 --
8101 --
8102 -- certification action item
8103 --
8104 l_actn_typ_id := get_actn_typ_id
8105 (p_type_cd => 'BNFCTFN'
8106 ,p_business_group_id => p_business_group_id);
8107 --
8108 -- bug 1169240
8109 --
8110 l_bnf_actn_typ_dfnd := check_bnf_actn_item_dfnd
8111 (p_pl_id => g_bnf_pl_rec.pl_id
8112 ,p_actn_type_cd => 'BNFCTFN'
8113 ,p_business_group_id => p_business_group_id
8114 ,p_effective_date => p_effective_date);
8115 --
8116 -- end bug 1169240
8117 --
8118 get_prtt_enrt_actn_id
8119 (p_actn_typ_id => l_actn_typ_id
8120 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8121 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8122 ,p_effective_date => p_effective_date
8123 ,p_business_group_id => p_business_group_id
8124 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8125 ,p_cmpltd_dt => l_cmpltd_dt
8126 ,p_object_version_number => l_object_version_number);
8127 --
8128 -- ******************************************************
8129 -- ****************Very Important************************
8130 -- The flag here says Beneficiary Certification Required,
8131 -- but in the form it says the opposite, No Ctfn Required.
8132 -- The name of this flag needs to be changed, so till this
8133 -- happens bear with the name and assume it to be something
8134 -- "bnf_no_ctfn_rqd_flag" (Column re-naming).
8135 -- *******************************************************
8136 --
8137 if g_bnf_pl_rec.bnf_ctfn_rqd_flag = 'N' or l_bnf_actn_typ_dfnd then
8138 --
8139 if g_debug then
8140 hr_utility.set_location('Ctfn rqd flag is N', 10);
8141 end if;
8142 --
8143 -- Certifications are required for the plan.
8144 -- Check if there are any certifications defined for the plan that are
8145 -- not of the Notarized Spousal Consent (NSC) type.
8146 --
8147 open c_ctfn_defined(l_dsgn_bnf.bnf_person_id,l_person_id, l_pl_id);
8148 fetch c_ctfn_defined into l_dummy;
8149 --
8150 if c_ctfn_defined%found then
8151 l_ctfn_defined := TRUE;
8152 else
8153 l_ctfn_defined := FALSE;
8154 end if;
8155 --
8156 close c_ctfn_defined;
8157 --
8158 -- If certifications were defined, then check to see if all the proper
8159 -- certifications were provided for the bnf person.
8160 --
8161 if l_ctfn_defined = TRUE then
8162 --
8163 if g_debug then
8164 hr_utility.set_location('Certifications defined', 10);
8165 end if;
8166 --
8167 l_rqd_data_found := check_bnf_ctfn
8168 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8169 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8170 ,p_effective_date => p_effective_date);
8171 --
8172 if l_rqd_data_found = FALSE then
8173 l_bnf_actn_warning := TRUE;
8174 end if;
8175 --
8176 process_action_item
8177 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8178 ,p_actn_typ_id => l_actn_typ_id
8179 ,p_cmpltd_dt => l_cmpltd_dt
8180 ,p_object_version_number => l_object_version_number
8181 ,p_effective_date => p_effective_date
8182 ,p_rqd_data_found => l_rqd_data_found
8183 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8184 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8185 ,p_rqd_flag => g_bnf_pl_rec.susp_if_ctfn_not_bnf_flag
8186 ,p_post_rslt_flag => p_post_rslt_flag
8187 ,p_business_group_id => p_business_group_id
8188 ,p_datetrack_mode => p_datetrack_mode
8189 ,p_rslt_object_version_number => p_rslt_object_version_number);
8190 --
8191 if l_rqd_data_found = FALSE then
8192 --
8193 if g_debug then
8194 hr_utility.set_location('Ctfn rqmts not met', 10);
8195 end if;
8196 --
8197 -- Ctfn rqmts are not met or no ctfns were found. Check if ctfns
8198 -- exist for the person in ben_pl_bnf_ctfn_prvdd_f.
8199 --
8200 open c_ctfns_exist(l_dsgn_bnf.pl_bnf_id);
8201 fetch c_ctfns_exist into l_dummy;
8202 --
8203 if c_ctfns_exist%notfound then
8204 --
8205 if g_debug then
8206 hr_utility.set_location('Person has no ctfns defined', 10);
8207 end if;
8208 --
8209 -- No ctfns exist for this person. Write new ctfns.
8210 --
8211 for l_ctfn_rec in c_ctfns(l_dsgn_bnf.bnf_person_id
8212 ,g_bnf_pl_rec.pl_id,l_person_id) loop
8213 --
8214 -- start bug 5667528
8215 l_write_ctfn := TRUE;
8216 l_ff_ctfn_exits := FALSE;
8217 hr_utility.set_location (' l_ctfn_rec.ctrrl ' || l_ctfn_rec.ctrrl,
8218 12.12
8219 );
8220
8221 IF l_ctfn_rec.ctrrl IS NOT NULL
8222 THEN
8223 OPEN c_pen_info;
8224
8225 FETCH c_pen_info
8226 INTO pen_info_rec;
8227
8228 CLOSE c_pen_info;
8229
8230 OPEN c_asg (pen_info_rec.person_id);
8231
8232 FETCH c_asg
8233 INTO asg_rec;
8234
8235 CLOSE c_asg;
8236
8237 OPEN c_opt (pen_info_rec.oipl_id);
8238
8239 FETCH c_opt
8240 INTO opt_rec;
8241
8242 CLOSE c_opt;
8243
8244 l_outputs :=
8245 benutils.formula
8246 (p_formula_id => l_ctfn_rec.ctrrl,
8247 p_pgm_id => pen_info_rec.pgm_id,
8248 p_pl_id => pen_info_rec.pl_id,
8249 p_pl_typ_id => pen_info_rec.pl_typ_id,
8250 p_opt_id => opt_rec.opt_id,
8251 p_ler_id => pen_info_rec.ler_id,
8252 p_business_group_id => pen_info_rec.business_group_id,
8253 p_assignment_id => asg_rec.assignment_id,
8254 p_organization_id => asg_rec.organization_id,
8255 p_effective_date => p_effective_date
8256 );
8257 hr_utility.set_location ( ' formula result '
8258 || l_outputs (l_outputs.FIRST).VALUE,
8259 12.12
8260 );
8261
8262 IF l_outputs (l_outputs.FIRST).VALUE <> 'Y'
8263 THEN
8264 l_write_ctfn := FALSE;
8265 hr_utility.set_location (' setting ctfn to false ', 12.12);
8266 END IF;
8267 END IF; -- end if l_ctfn_rec.ctrrl is not null
8268 IF l_write_ctfn = TRUE THEN
8269 l_ff_ctfn_exits := true;
8270 hr_utility.set_location(' writing certification ',12.12);
8271
8272 write_new_bnf_ctfn_item
8273 (p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8274 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8275 ,p_bnf_ctfn_typ_cd => l_ctfn_rec.ctcvgcd
8276 --,p_bnf_ctfn_rqd_flag => l_ctfn_rec.ctflag Bug 3196152
8277 ,p_bnf_ctfn_rqd_flag => l_ctfn_rec.rqd_flag
8278 ,p_effective_date => p_effective_date
8279 ,p_business_group_id => p_business_group_id
8280 ,p_object_version_number => l_object_version_number
8281 ,p_pl_bnf_ctfn_prvdd_id => l_pl_bnf_ctfn_prvdd_id);
8282 --
8283 END IF;
8284 end loop;
8285 --
8286 end if; -- ctfns_exist
8287 --
8288 close c_ctfns_exist;
8289 --
8290 end if; -- rqd_data_found
8291 --
8292 IF l_ff_ctfn_exits = FALSE
8293 THEN
8294 hr_utility.set_location
8295 ('Deleting enrollment action item when formula fails ',
8296 12.12
8297 );
8298
8299 OPEN c_curr_ovn_of_actn (l_prtt_enrt_actn_id);
8300
8301 FETCH c_curr_ovn_of_actn
8302 INTO l_object_version_number;
8303
8304 CLOSE c_curr_ovn_of_actn;
8305
8306 delete_action_item
8307 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id,
8308 p_object_version_number => l_object_version_number,
8309 p_business_group_id => p_business_group_id,
8310 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
8311 p_rslt_object_version_number => p_rslt_object_version_number,
8312 p_effective_date => p_effective_date,
8313 p_datetrack_mode => hr_api.g_zap,
8314 p_post_rslt_flag => p_post_rslt_flag
8315 );
8316
8317 -- we need to delete warning also that was created for this action item
8318 OPEN c_act_name (l_actn_typ_id);
8319
8320 FETCH c_act_name
8321 INTO l_act_name;
8322
8323 CLOSE c_act_name;
8324
8325 OPEN c_plan_name (pen_info_rec.pl_id);
8326
8327 FETCH c_plan_name
8328 INTO plan_name_rec;
8329
8330 CLOSE c_plan_name;
8331
8332 ben_warnings.delete_warnings
8333 (p_application_short_name => 'BEN',
8334 p_message_name => l_message_name,
8335 p_parma => l_act_name,
8336 p_parmb => plan_name_rec.NAME,
8337 p_person_id => pen_info_rec.person_id
8338 );
8339 END IF;
8340 -- end bug 5667528
8341 end if; -- ctfn_defined
8342 --
8343 else
8344 --
8345 -- bnf_ctfn_rqd_flag is 'Y'
8346 -- if date_track mode is updating and designation at plan level
8347 -- delete action type of type BNFCTFN.
8348 --
8349 if l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE then
8350 --
8351 delete_action_item
8352 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8353 ,p_object_version_number => l_object_version_number
8354 ,p_business_group_id => p_business_group_id
8355 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8356 ,p_rslt_object_version_number => p_rslt_object_version_number
8357 ,p_effective_date => p_effective_date
8358 ,p_datetrack_mode => p_datetrack_mode
8359 ,p_post_rslt_flag => p_post_rslt_flag);
8360 --
8361 end if;
8362 --
8363 end if; -- bnf_ctfn_rqd_flag
8364 --
8365 end loop; -- bnf loop
8366 --
8367 if g_debug then
8368 hr_utility.set_location ('Leaving '||l_proc,10);
8369 end if;
8370 --
8371 exception
8372 when others then
8373 if g_debug then
8374 hr_utility.set_location('Exception Raised '||l_proc, 10);
8375 end if;
8376
8377 p_rslt_object_version_number :=l_rslt_object_version_number ;
8378 p_bnf_actn_warning := null;
8379
8380 raise;
8381 --
8382 end determine_bnf_miss_actn_items;
8383 --
8384 -- ----------------------------------------------------------------------------
8385 -- |-----------------------< determine_bnf_actn_items >-----------------------|
8386 -- ----------------------------------------------------------------------------
8387 --
8388 procedure determine_bnf_actn_items
8389 (p_prtt_enrt_rslt_id in number
8390 ,p_effective_date in date
8391 ,p_business_group_id in number
8392 ,p_datetrack_mode in varchar2 default hr_api.g_correction
8393 ,p_post_rslt_flag in varchar2 default 'Y'
8394 ,p_rslt_object_version_number in out nocopy number
8395 ,p_bnf_actn_item_open out nocopy boolean
8396 ,p_hack out nocopy varchar2) is
8397 --
8398 -- this procedure determines if beneficiaries are required to complete
8399 -- enrollment. For an enrollment result check ben_pl_f.bnf_dsgn_cd
8400 -- if not NULL then a beneficiary is requested so write BNF action item.
8401 -- in additon if the bnf designation is 'R' required, suspend enrollment.
8402 -- or if designation 'O' optional, do not suspend.
8403 --
8404 cursor c_find_bnf is
8405 select pl_bnf_id
8406 from ben_pl_bnf_f,
8407 ben_per_in_ler pil
8408 where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
8409 and p_effective_date between
8410 effective_start_date and effective_end_date
8411 and pil.per_in_ler_id=ben_pl_bnf_f.per_in_ler_id
8412 and pil.business_group_id=p_business_group_id
8413 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
8414 --
8415 l_find_bnf c_find_bnf%rowtype;
8416 --
8417 -- Cursor to fetch bnf action items other than the BNF item. this will
8418 -- be used to delete all beneficiary action items after a BNF action item is
8419 -- written
8420 --
8421 cursor c_other_bnf_actn_items is
8422 select pea.prtt_enrt_actn_id,
8423 pea.object_version_number
8424 from ben_prtt_enrt_actn_f pea,
8425 ben_actn_typ typ,
8426 ben_per_in_ler pil
8427 where pea.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
8428 and pea.business_group_id = p_business_group_id
8429 and typ.type_cd <> 'BNF'
8430 and typ.type_cd like 'BNF%'
8431 and typ.business_group_id = p_business_group_id
8432 and pea.per_in_ler_id = pil.per_in_ler_id
8433 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
8434 and pea.actn_typ_id = typ.actn_typ_id
8435 and p_effective_date between pea.effective_start_date
8436 and pea.effective_end_date
8437 ;
8438 --
8439 l_actn_typ_id number;
8440 l_cmpltd_dt date;
8441 l_object_version_number number;
8442 l_prtt_enrt_actn_id number;
8443 l_bnf_found boolean;
8444 l_rslt_object_version_number number(15);
8445
8446 --
8447 bnf_dsgn_cd_null exception;
8448 --
8449 l_proc varchar2(80) ;
8450 --
8451 begin
8452 --
8453 if g_debug then
8454 l_proc := g_package||'.determine_bnf_actn_items';
8455 hr_utility.set_location ('Entering '||l_proc,10);
8456 end if;
8457 --
8458 l_rslt_object_version_number := p_rslt_object_version_number;
8459
8460 -- get data from pl table.
8461 open g_bnf_pl(p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8462 ,p_effective_date => p_effective_date);
8463 fetch g_bnf_pl into g_bnf_pl_rec;
8464 if g_bnf_pl_rec.rqd is null then
8465 -- if bnf_dsgn_cd is null, skip out of this procedure.
8466 close g_bnf_pl;
8467 raise bnf_dsgn_cd_null;
8468 end if;
8469 close g_bnf_pl;
8470 --
8471 -- Check if beneficiaries are designated.
8472 --
8473 open c_find_bnf;
8474 fetch c_find_bnf into l_find_bnf;
8475 --
8476 if c_find_bnf%found then
8477 l_bnf_found := TRUE;
8478 else
8479 l_bnf_found := FALSE;
8480 end if;
8481 --
8482 close c_find_bnf;
8483 --
8484 -- Get the actn type id for the BNF action item
8485 --
8486 l_actn_typ_id := get_actn_typ_id
8487 (p_type_cd => 'BNF'
8488 ,p_business_group_id => p_business_group_id);
8489 --
8490 -- Get the action item id if one exists
8491 --
8492 get_prtt_enrt_actn_id
8493 (p_actn_typ_id => l_actn_typ_id
8494 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8495 ,p_effective_date => p_effective_date
8496 ,p_business_group_id => p_business_group_id
8497 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8498 ,p_cmpltd_dt => l_cmpltd_dt
8499 ,p_object_version_number => l_object_version_number);
8500 --
8501 if l_bnf_found = FALSE then
8502 --
8503 if g_debug then
8504 hr_utility.set_location('Beneficiaries not designated', 10);
8505 end if;
8506 --
8507 --
8508 -- There are no beneficiaries designated
8509 --
8510 -- Set the p_rqd_data_found parameter to FALSE so that the procedure writes
8511 -- an action item
8512 --
8513 process_action_item
8514 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8515 ,p_actn_typ_id => l_actn_typ_id
8516 ,p_cmpltd_dt => l_cmpltd_dt
8517 ,p_object_version_number => l_object_version_number
8518 ,p_effective_date => p_effective_date
8519 ,p_rqd_data_found => FALSE
8520 ,p_rqd_flag => g_bnf_pl_rec.rqd
8521 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8522 ,p_post_rslt_flag => p_post_rslt_flag
8523 ,p_business_group_id => p_business_group_id
8524 ,p_datetrack_mode => p_datetrack_mode
8525 ,p_rslt_object_version_number => p_rslt_object_version_number);
8526 --
8527 p_bnf_actn_item_open := TRUE;
8528 --
8529 -- Set the hack flag to N so that the calling program knows that an action
8530 -- item was actually written
8531 --
8532 p_hack := 'N';
8533 --
8534 -- Delete all other beneficiary action items.
8535 --
8536 for actn_item_rec in c_other_bnf_actn_items loop
8537 --
8538 delete_action_item
8539 (p_prtt_enrt_actn_id => actn_item_rec.prtt_enrt_actn_id
8540 ,p_object_version_number => actn_item_rec.object_version_number
8541 ,p_business_group_id => p_business_group_id
8542 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8543 ,p_rslt_object_version_number => p_rslt_object_version_number
8544 ,p_effective_date => p_effective_date
8545 ,p_datetrack_mode => hr_api.g_zap
8546 ,p_post_rslt_flag => p_post_rslt_flag);
8547 --
8548 end loop;
8549 --
8550 else
8551 --
8552 -- Beneficiaries found
8553 --
8554 if g_debug then
8555 hr_utility.set_location('Beneficiaries found', 10);
8556 end if;
8557 --
8558 --
8559 -- Set the p_rqd_data_found = TRUE so that the proc below closes an open
8560 -- action item of type BNF, if found.
8561 --
8562 process_action_item
8563 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8564 ,p_actn_typ_id => l_actn_typ_id
8565 ,p_cmpltd_dt => l_cmpltd_dt
8566 ,p_object_version_number => l_object_version_number
8567 ,p_effective_date => p_effective_date
8568 ,p_rqd_data_found => TRUE
8569 ,p_rqd_flag => g_bnf_pl_rec.rqd
8570 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8571 ,p_post_rslt_flag => p_post_rslt_flag
8572 ,p_business_group_id => p_business_group_id
8573 ,p_datetrack_mode => p_datetrack_mode
8574 ,p_rslt_object_version_number => p_rslt_object_version_number);
8575 --
8576 p_bnf_actn_item_open := FALSE;
8577 p_hack := 'N';
8578 --
8579 end if;
8580 --
8581 if g_debug then
8582 hr_utility.set_location ('Leaving ' ||l_proc,10);
8583 end if;
8584 --
8585 exception
8586 --
8587 when bnf_dsgn_cd_null
8588 then
8589 -- Since designation of beneficiaries is not required for the plan, we don't
8590 -- have to write any action item. Set the out parameter so that the calling
8591 -- proc does not call determine_bnf_miss_actn_items. Also set the hack flag
8592 -- to Y so that the calling procedure knows that no action items were
8593 -- written.
8594 --
8595 p_bnf_actn_item_open := TRUE;
8596 p_hack := 'Y';
8597 --
8598 if g_debug then
8599 hr_utility.set_location('Bnf dsgn not specified.', 10);
8600 end if;
8601 if g_debug then
8602 hr_utility.set_location('Leaving : ' || l_proc, 10);
8603 end if;
8604 --
8605 when others then
8606 if g_debug then
8607 hr_utility.set_location('Exception Raised '||l_proc, 10);
8608 end if;
8609
8610 p_rslt_object_version_number :=l_rslt_object_version_number ;
8611 p_bnf_actn_item_open := null;
8612 p_hack := null ;
8613 raise;
8614 --
8615 end determine_bnf_actn_items;
8616 --
8617 -- ----------------------------------------------------------------------------
8618 -- |-----------------------< determine_additional_bnf >-----------------------|
8619 -- ----------------------------------------------------------------------------
8620 --
8621 procedure determine_additional_bnf
8622 (p_validate in boolean default FALSE
8623 ,p_prtt_enrt_rslt_id in number
8624 ,p_effective_date in date
8625 ,p_business_group_id in number
8626 ,p_datetrack_mode in varchar2 default hr_api.g_correction
8627 ,p_post_rslt_flag in varchar2 default 'Y'
8628 ,p_rslt_object_version_number in out nocopy number
8629 ,p_bnf_actn_warning in out nocopy boolean) is
8630 --
8631 -- This procedure is run after all beneficiaries have been designated. If an
8632 -- additonal beneficiary designation is needed an action item of type BNFADDNL
8633 -- is written. It also writes a BNFSCCTFN (spousal consent certification)
8634 -- aciton item when a prtt has designated a person other than his/her spouse
8635 -- as a primary beneficiary and spousal consent certification is required and
8636 -- has not been provided.
8637 --
8638 l_proc varchar2(80) ;
8639 l_actn_typ_id number;
8640 l_cmpltd_dt date;
8641 l_object_version_number number;
8642 l_prtt_enrt_actn_id number;
8643 l_prtt_enrt_ctfn_prvdd_id number;
8644 l_meets_rqmt boolean;
8645 l_outputs ff_exec.outputs_t;
8646 l_write_ctfn boolean := TRUE;
8647 l_bnf_actn_warning boolean := FALSE;
8648 l_rslt_object_version_number number(15);
8649
8650 l_dummy varchar2(30);
8651 --
8652 -- Cursor to compute the sum of the primary and contingent beneficiaries'
8653 -- designated percentages
8654 --
8655 cursor c_rslt is select
8656 rslt.pgm_id,
8657 rslt.pl_id,
8658 rslt.pl_typ_id,
8659 rslt.oipl_id,
8660 rslt.ler_id,
8661 rslt.person_id,
8662 rslt.business_group_id
8663 from ben_prtt_enrt_rslt_f rslt
8664 where rslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
8665 and p_effective_date between
8666 rslt.effective_start_date and rslt.effective_end_date;
8667
8668 l_rslt c_rslt%rowtype;
8669
8670 cursor c_opt is
8671 select oipl.opt_id
8672 from ben_oipl_f oipl
8673 where oipl.oipl_id = l_rslt.oipl_id
8674 and business_group_id = p_business_group_id
8675 and p_effective_date between
8676 oipl.effective_start_date and oipl.effective_end_date;
8677
8678 l_opt c_opt%rowtype;
8679
8680 cursor c_asg is
8681 select asg.assignment_id,asg.organization_id
8682 from per_all_assignments_f asg
8683 where asg.person_id = l_rslt.person_id
8684 and asg.assignment_type <> 'C'
8685 and asg.primary_flag = 'Y'
8686 and p_effective_date between
8687 asg.effective_start_date and asg.effective_end_date;
8688
8689 l_asg c_asg%rowtype;
8690
8691 cursor c_sum_bnf_pct is
8692 select prmry_cntngnt_cd cntgcd,
8693 sum(pct_dsgd_num) prcnt
8694 from ben_pl_bnf_f ,
8695 ben_per_in_ler pil
8696 where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
8697 and ben_pl_bnf_f.business_group_id = p_business_group_id
8698 and p_effective_date between
8699 ben_pl_bnf_f.effective_start_date and ben_pl_bnf_f.effective_end_date
8700 and pil.per_in_ler_id=ben_pl_bnf_f.per_in_ler_id
8701 and pil.business_group_id=p_business_group_id
8702 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
8703 group by prmry_cntngnt_cd;
8704 --
8705 l_sum_bnf_pct c_sum_bnf_pct%rowtype;
8706 --
8707 -- Cursor to pick up any NSC ctfns that may be defined for the plan and
8708 -- contact type.
8709 -- Bug 5461171 - Modified conditions. See Bug Closure for all scenarios
8710 -- satisfied by the cursor
8711 --
8712 CURSOR c_nsc_ctfn_pl (v_contact_type IN VARCHAR2, v_pl_id IN NUMBER)
8713 IS
8714 SELECT pcx.rqd_flag ctflag, pcx.bnf_ctfn_typ_cd ctcvgcd,
8715 pcx.ctfn_rqd_when_rl ctrrl, pcx.rlshp_typ_cd ctrlshcd,
8716 pcx.bnf_typ_cd, pcx.pl_id
8717 FROM ben_pl_bnf_ctfn_f pcx
8718 WHERE pcx.pl_id = v_pl_id
8719 AND ( ( NVL (pcx.bnf_typ_cd, 'O') = 'O'
8720 AND v_contact_type = 'O'
8721 AND pcx.rlshp_typ_cd IS NULL
8722 )
8723 OR -- Bug 5156111
8724 ( NVL (pcx.bnf_typ_cd, 'P') = 'P'
8725 AND NVL (pcx.rlshp_typ_cd, v_contact_type) = v_contact_type
8726 AND v_contact_type <> 'O'
8727 )
8728 )
8729 AND pcx.bnf_ctfn_typ_cd = 'NSC'
8730 AND pcx.business_group_id = p_business_group_id
8731 AND p_effective_date BETWEEN pcx.effective_start_date
8732 AND pcx.effective_end_date;
8733
8734 --
8735 -- check if the participant is married and the spouse the primary beneficiary
8736 --
8737 cursor c_spouse is
8738 select pcr.contact_type,
8739 plb.bnf_person_id,
8740 plb.pl_bnf_id,
8741 pl.pl_id
8742 from per_all_people_f per,
8743 per_contact_relationships pcr,
8744 ben_pl_f pl,
8745 ben_pl_bnf_f plb,
8746 ben_prtt_enrt_rslt_f pen,
8747 ben_per_in_ler pil
8748 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
8749 and pen.pl_id = pl.pl_id
8750 and pl.bnf_qdro_rl_apls_flag = 'Y'
8751 and pl.bnf_ctfn_rqd_flag = 'N' -- Flag is named incorrectly(opposite).
8752 and plb.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
8753 and plb.prmry_cntngnt_cd = 'PRIMY'
8754 and pcr.contact_person_id = plb.bnf_person_id
8755 and pcr.person_id = pen.person_id
8756 and per.person_id = pen.person_id
8757 and per.marital_status = 'M'
8758 and pcr.business_group_id = p_business_group_id
8759 and pen.business_group_id = p_business_group_id
8760 and p_effective_date between pen.effective_start_date
8761 and pen.effective_end_date
8762 and per.business_group_id = p_business_group_id
8763 and p_effective_date between per.effective_start_date
8764 and per.effective_end_date
8765 and pl.business_group_id = p_business_group_id
8766 and p_effective_date between pl.effective_start_date
8767 and pl.effective_end_date
8768 and plb.business_group_id = p_business_group_id
8769 and p_effective_date between plb.effective_start_date
8770 and plb.effective_end_date
8771 and p_effective_date between nvl(date_start, p_effective_date) -- bug 5362890
8772 and nvl(date_end, hr_api.g_eot)
8773 and pil.per_in_ler_id=plb.per_in_ler_id
8774 and pil.business_group_id=p_business_group_id
8775 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
8776 UNION -- Bug 5156111 : Added union clause
8777 select 'O',
8778 plb.organization_id,
8779 plb.pl_bnf_id,
8780 pl.pl_id
8781 from per_all_people_f per,
8782 hr_all_organization_units o,
8783 ben_pl_f pl,
8784 ben_pl_bnf_f plb,
8785 ben_prtt_enrt_rslt_f pen,
8786 ben_per_in_ler pil
8787 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
8788 and pen.pl_id = pl.pl_id
8789 and pl.bnf_qdro_rl_apls_flag = 'Y'
8790 and pl.bnf_may_dsgt_org_flag = 'Y'
8791 and pl.bnf_ctfn_rqd_flag = 'N' -- Flag is named incorrectly(opposite).
8792 and plb.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
8793 and plb.prmry_cntngnt_cd = 'PRIMY'
8794 and o.organization_id = plb.organization_id
8795 and per.person_id = pen.person_id
8796 and per.marital_status = 'M'
8797 and o.business_group_id = p_business_group_id
8798 and pen.business_group_id = p_business_group_id
8799 and p_effective_date between pen.effective_start_date
8800 and pen.effective_end_date
8801 and per.business_group_id = p_business_group_id
8802 and p_effective_date between per.effective_start_date
8803 and per.effective_end_date
8804 and pl.business_group_id = p_business_group_id
8805 and p_effective_date between pl.effective_start_date
8806 and pl.effective_end_date
8807 and plb.business_group_id = p_business_group_id
8808 and p_effective_date between o.date_from
8809 and nvl(o.date_to, p_effective_date)
8810 and pil.per_in_ler_id=plb.per_in_ler_id
8811 and pil.business_group_id=p_business_group_id
8812 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
8813
8814 --
8815 -- Cursor to check if the NSC ctfn has been provided.
8816 --
8817 cursor c_nsc_prvdd(v_pl_bnf_id number) is
8818 select 's'
8819 from ben_pl_bnf_ctfn_prvdd_f
8820 where pl_bnf_id = v_pl_bnf_id
8821 and bnf_ctfn_recd_dt is not null
8822 and business_group_id = p_business_group_id
8823 and p_effective_date between effective_start_date
8824 and effective_end_date;
8825
8826 begin
8827 --
8828 if g_debug then
8829 l_proc := g_package||'.determine_additional_bnf';
8830 hr_utility.set_location ('Entering '||l_proc,10);
8831 end if;
8832 --
8833
8834 l_rslt_object_version_number := p_rslt_object_version_number;
8835
8836 --
8837 if p_prtt_enrt_rslt_id is not null then
8838 open c_rslt;
8839 fetch c_rslt into l_rslt;
8840 close c_rslt;
8841
8842 -- get data from pl table.
8843 open g_bnf_pl(p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8844 ,p_effective_date => p_effective_date);
8845 fetch g_bnf_pl into g_bnf_pl_rec;
8846 close g_bnf_pl;
8847 end if;
8848
8849
8850 if l_rslt.person_id is not null then
8851 open c_asg;
8852 fetch c_asg into l_asg;
8853 close c_asg;
8854 end if;
8855
8856 l_meets_rqmt := TRUE;
8857 --
8858 open c_sum_bnf_pct;
8859 --
8860 -- Check if the sum total of the percentages is 100% for either primary or
8861 -- contingent beneficiaries. If not, then write an action item of type
8862 -- BNFADDNL for designating addtional beneficiaryies.
8863 --
8864 loop
8865 --
8866 fetch c_sum_bnf_pct into l_sum_bnf_pct;
8867 exit when c_sum_bnf_pct%notfound;
8868 --
8869 if l_sum_bnf_pct.prcnt < 100 then
8870 l_meets_rqmt := FALSE;
8871 end if;
8872 --
8873 end loop;
8874 --
8875 close c_sum_bnf_pct;
8876 --
8877 -- Check if an action item of type BNFADDNL exists.
8878 --
8879 l_actn_typ_id := get_actn_typ_id
8880 (p_type_cd => 'BNFADDNL'
8881 ,p_business_group_id => p_business_group_id);
8882 --
8883 get_prtt_enrt_actn_id
8884 (p_actn_typ_id => l_actn_typ_id
8885 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8886 ,p_effective_date => p_effective_date
8887 ,p_business_group_id => p_business_group_id
8888 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8889 ,p_cmpltd_dt => l_cmpltd_dt
8890 ,p_object_version_number => l_object_version_number);
8891 --
8892 if l_meets_rqmt = TRUE then
8893 --
8894 if g_debug then
8895 hr_utility.set_location('rqmts met for BNFADDNL', 10);
8896 end if;
8897 --
8898 -- Set the p_rqd_data_found = TRUE so that the procedure closes an open
8899 -- action item of type BNFADDNL, if found.
8900 --
8901 process_action_item
8902 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8903 ,p_actn_typ_id => l_actn_typ_id
8904 ,p_cmpltd_dt => l_cmpltd_dt
8905 ,p_object_version_number => l_object_version_number
8906 ,p_effective_date => p_effective_date
8907 ,p_rqd_data_found => TRUE
8908 ,p_rqd_flag => g_bnf_pl_rec.rqd
8909 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8910 ,p_post_rslt_flag => p_post_rslt_flag
8911 ,p_business_group_id => p_business_group_id
8912 ,p_datetrack_mode => p_datetrack_mode
8913 ,p_rslt_object_version_number => p_rslt_object_version_number);
8914 --
8915 else
8916 --
8917 if g_debug then
8918 hr_utility.set_location('rqmts not met for BNFADDNL', 10);
8919 end if;
8920
8921 --
8922 -- Requirements are not met. Set the p_rqd_data_found = FALSE so that the
8923 -- procedure reopens or writes a new action item of type BNFADDNL.
8924 --
8925 process_action_item
8926 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8927 ,p_actn_typ_id => l_actn_typ_id
8928 ,p_cmpltd_dt => l_cmpltd_dt
8929 ,p_object_version_number => l_object_version_number
8930 ,p_effective_date => p_effective_date
8931 ,p_rqd_data_found => FALSE
8932 ,p_rqd_flag => g_bnf_pl_rec.rqd
8933 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8934 ,p_post_rslt_flag => p_post_rslt_flag
8935 ,p_business_group_id => p_business_group_id
8936 ,p_datetrack_mode => p_datetrack_mode
8937 ,p_rslt_object_version_number => p_rslt_object_version_number);
8938 --
8939 end if;
8940 --
8941 --
8942 -- SPOUSAL CONSENT CERTIFICATTION
8943 --
8944 -- Check if the primary bnf is a spouse and if not, whether the plan requires
8945 -- a spousal consent ctfn.
8946 --
8947 for l_bnf_rec in c_spouse loop
8948 --
8949 -- Reset the enrt actn id for each new iteration.
8950 --
8951 l_prtt_enrt_actn_id := NULL;
8952 --
8953 if l_bnf_rec.contact_type <> 'S' then
8954 --
8955 -- The primary bnf is not a spouse.
8956 --
8957 if g_debug then
8958 hr_utility.set_location('Contact type ' || l_bnf_rec.contact_type ||
8959 ' is not a spouse', 10);
8960 end if;
8961 --
8962 -- Check if an BNFSCCTFN actn item already exists for the bnf.
8963 --
8964 l_actn_typ_id := get_actn_typ_id
8965 (p_type_cd => 'BNFSCCTFN'
8966 ,p_business_group_id => p_business_group_id);
8967 --
8968 get_prtt_enrt_actn_id
8969 (p_actn_typ_id => l_actn_typ_id
8970 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8971 ,p_pl_bnf_id => l_bnf_rec.pl_bnf_id
8972 ,p_effective_date => p_effective_date
8973 ,p_business_group_id => p_business_group_id
8974 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8975 ,p_cmpltd_dt => l_cmpltd_dt
8976 ,p_object_version_number => l_object_version_number);
8977 --
8978 -- Loop through sposal consent ctfns that are defined for this contact
8979 -- type and write to pl_bnf_ctfn_prvdd_f.
8980 --
8981 for l_nsc_ctfn_pl in c_nsc_ctfn_pl(l_bnf_rec.contact_type
8982 ,l_bnf_rec.pl_id) loop
8983 --
8984 -- We will be in this loop only if a ctfn is defined for this contact
8985 -- type. If the action item was not found earlier, we need to create
8986 -- one and then write ctfns into the ctfn_prvdd table.
8987 --
8988 if l_prtt_enrt_actn_id IS NULL then
8989 --
8990 -- no BNFSCCTFN action item yet so create a new entry
8991 --
8992 if g_debug then
8993 hr_utility.set_location('No BNFSCCTFN actn item.', 10);
8994 end if;
8995 --
8996 write_new_action_item
8997 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8998 ,p_rslt_object_version_number => p_rslt_object_version_number
8999 ,p_actn_typ_id => l_actn_typ_id
9000 ,p_pl_bnf_id => l_bnf_rec.pl_bnf_id
9001 ,p_rqd_flag => g_bnf_pl_rec.rqd
9002 ,p_effective_date => p_effective_date
9003 ,p_post_rslt_flag => p_post_rslt_flag
9004 ,p_business_group_id => p_business_group_id
9005 ,p_object_version_number => l_object_version_number
9006 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id);
9007 --
9008 l_write_ctfn := true;
9009 --
9010 if l_nsc_ctfn_pl.ctrrl IS NOT NULL then
9011 --
9012 if l_rslt.oipl_id is not null then
9013 open c_opt;
9014 fetch c_opt into l_opt;
9015 close c_opt;
9016 end if;
9017 --
9018 l_outputs := benutils.formula
9019 (p_formula_id => l_nsc_ctfn_pl.ctrrl
9020 ,p_pgm_id => NULL
9021 ,p_pl_id => l_nsc_ctfn_pl.pl_id
9022 ,p_pl_typ_id => l_rslt.pl_typ_id
9023 ,p_opt_id => l_opt.opt_id
9024 ,p_ler_id => l_rslt.ler_id
9025 ,p_business_group_id => l_rslt.business_group_id
9026 ,p_assignment_id => l_asg.assignment_id
9027 ,p_organization_id => l_asg.organization_id
9028 ,p_effective_date => p_effective_date);
9029 --
9030 if l_outputs(l_outputs.first).value <> 'Y' then
9031 l_write_ctfn := FALSE;
9032 end if;
9033 --
9034 end if;
9035 --
9036 if l_write_ctfn = TRUE then
9037 --
9038 write_new_bnf_ctfn_item
9039 (p_pl_bnf_id => l_bnf_rec.pl_bnf_id
9040 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
9041 ,p_bnf_ctfn_typ_cd => l_nsc_ctfn_pl.ctcvgcd
9042 ,p_bnf_ctfn_rqd_flag => l_nsc_ctfn_pl.ctflag
9043 ,p_effective_date => p_effective_date
9044 ,p_business_group_id => p_business_group_id
9045 ,p_object_version_number => l_object_version_number
9046 ,p_pl_bnf_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
9047 --
9048 end if; -- write_ctfn
9049 --
9050 end if; -- prtt_enrt_actn_id
9051 --
9052 end loop; -- inner loop
9053 --
9054 if l_prtt_enrt_actn_id IS NOT NULL then
9055 --
9056 -- A BNFSCCTFN action item was written in an earlier run. Check if the
9057 -- NSC ctfn has been provided and if yes, close the action item.
9058 --
9059 if g_debug then
9060 hr_utility.set_location('BNFSCCTFN actn item found', 10);
9061 end if;
9062 --
9063 open c_nsc_prvdd(l_bnf_rec.pl_bnf_id);
9064 fetch c_nsc_prvdd into l_dummy;
9065 --
9066 if c_nsc_prvdd%found then
9067 --
9068 -- Ctfn provided. Close action item.
9069 --
9070 if g_debug then
9071 hr_utility.set_location('SCCTFN provided. Close actn item.', 10);
9072 end if;
9073 --
9074 set_cmpltd_dt
9075 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
9076 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9077 ,p_rslt_object_version_number => p_rslt_object_version_number
9078 ,p_actn_typ_id => l_actn_typ_id
9079 ,p_rqd_flag => g_bnf_pl_rec.rqd
9080 ,p_effective_date => p_effective_date
9081 ,p_post_rslt_flag => p_post_rslt_flag
9082 ,p_business_group_id => p_business_group_id
9083 ,p_object_version_number => l_object_version_number
9084 ,p_open_close => 'CLOSE'
9085 ,p_datetrack_mode => p_datetrack_mode);
9086 --
9087 else
9088 --
9089 -- Ctfn not provided. Open action item if already closed.
9090 --
9091 if g_debug then
9092 hr_utility.set_location('CTFN not prvdd. Open actn item.', 10);
9093 end if;
9094 --
9095 if l_cmpltd_dt is null then
9096 set_cmpltd_dt
9097 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
9098 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9099 ,p_rslt_object_version_number => p_rslt_object_version_number
9100 ,p_actn_typ_id => l_actn_typ_id
9101 ,p_rqd_flag => g_bnf_pl_rec.rqd
9102 ,p_effective_date => p_effective_date
9103 ,p_post_rslt_flag => p_post_rslt_flag
9104 ,p_business_group_id => p_business_group_id
9105 ,p_object_version_number => l_object_version_number
9106 ,p_open_close => 'OPEN'
9107 ,p_datetrack_mode => p_datetrack_mode);
9108 --
9109 end if;
9110 --
9111 end if;
9112 --
9113 close c_nsc_prvdd;
9114 --
9115 end if; -- prtt_enrt_actn_id
9116 --
9117 end if; -- contact type <> 'S'
9118 --
9119 end loop; -- outer loop
9120 --
9121 if g_debug then
9122 hr_utility.set_location ('Leaving ' ||l_proc,10);
9123 end if;
9124 --
9125 exception
9126 when others then
9127 if g_debug then
9128 hr_utility.set_location('Exception Raised '||l_proc, 10);
9129 end if;
9130 p_rslt_object_version_number :=l_rslt_object_version_number ;
9131 p_bnf_actn_warning :=l_bnf_actn_warning ;
9132 raise;
9133 --
9134 end determine_additional_bnf;
9135 --
9136 -- ----------------------------------------------------------------------------
9137 -- |-----------------------< process_bnf_actn_items >-------------------------|
9138 -- ----------------------------------------------------------------------------
9139 --
9140 procedure process_bnf_actn_items
9141 (p_prtt_enrt_rslt_id in number
9142 ,p_effective_date in date
9143 ,p_business_group_id in number
9144 ,p_validate in boolean default FALSE
9145 ,p_datetrack_mode in varchar2 default hr_api.g_correction
9146 ,p_post_rslt_flag in varchar2 default 'Y'
9147 ,p_rslt_object_version_number in out nocopy number
9148 ,p_suspend_flag in out nocopy varchar2
9149 ,p_bnf_actn_warning out nocopy boolean) is
9150 --
9151 l_proc varchar2(80) ;
9152 --
9153 l_bnf_actn_item_open boolean := FALSE;
9154 l_bnf_actn_warning boolean := FALSE;
9155 l_hack varchar2(1) := 'N';
9156
9157 l_rslt_object_version_number number(15);
9158 l_suspend_flag varchar2(20);
9159
9160 --
9161 begin
9162 --
9163 g_debug := hr_utility.debug_enabled;
9164 if g_debug then
9165 l_proc := g_package || '.process_bnf_actn_items';
9166 hr_utility.set_location ('Entering '||l_proc,10);
9167 end if;
9168 --
9169
9170 l_rslt_object_version_number:= p_rslt_object_version_number ;
9171 l_suspend_flag := p_suspend_flag ;
9172
9173 --
9174 savepoint process_bnf_actn_items;
9175 --
9176 determine_bnf_actn_items
9177 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9178 ,p_rslt_object_version_number => p_rslt_object_version_number
9179 ,p_effective_date => p_effective_date
9180 ,p_business_group_id => p_business_group_id
9181 ,p_datetrack_mode => p_datetrack_mode
9182 ,p_post_rslt_flag => p_post_rslt_flag
9183 ,p_bnf_actn_item_open => l_bnf_actn_item_open
9184 ,p_hack => l_hack);
9185 --
9186 if l_bnf_actn_item_open = FALSE then
9187 --
9188 -- A BNF actn item was not written by the previous procedure. i.e. bnf's are
9189 -- designated. Determine missing bnf information
9190 --
9191 determine_bnf_miss_actn_items
9192 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9193 ,p_rslt_object_version_number => p_rslt_object_version_number
9194 ,p_effective_date => p_effective_date
9195 ,p_business_group_id => p_business_group_id
9196 ,p_datetrack_mode => p_datetrack_mode
9197 ,p_post_rslt_flag => p_post_rslt_flag
9198 ,p_bnf_actn_warning => l_bnf_actn_warning);
9199 --
9200 determine_additional_bnf
9201 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9202 ,p_rslt_object_version_number => p_rslt_object_version_number
9203 ,p_effective_date => p_effective_date
9204 ,p_business_group_id => p_business_group_id
9205 ,p_datetrack_mode => p_datetrack_mode
9206 ,p_post_rslt_flag => p_post_rslt_flag
9207 ,p_bnf_actn_warning => l_bnf_actn_warning);
9208 --
9209 else
9210 --
9211 -- l_bnf_actn_item_open is TRUE. Set the l_bnf_actn_warning flag.
9212 --
9213 if l_hack = 'Y' then
9214 -- This indicates that the l_bnf_actn_item_open was set to TRUE only to
9215 -- fool this process to not check for bnf missing items and no
9216 -- BNF action item was written. Set the l_dpnt_actn_warning to FALSE
9217 --
9218 l_bnf_actn_warning := FALSE;
9219 --
9220 else
9221 --
9222 -- A BNF actn item was actually written. Set the flag to TRUE.
9223 --
9224 l_bnf_actn_warning := TRUE;
9225 --
9226 end if;
9227 --
9228 end if;
9229 --
9230 p_bnf_actn_warning := l_bnf_actn_warning;
9231 --
9232 if p_validate then
9233 raise hr_api.validate_enabled;
9234 end if;
9235 --
9236 if g_debug then
9237 hr_utility.set_location ('Leaving '||l_proc, 10);
9238 end if;
9239 --
9240 exception
9241 --
9242 when hr_api.validate_enabled
9243 then
9244 --
9245 rollback to process_bnf_actn_items;
9246 if g_debug then
9247 hr_utility.set_location ('Leaving '||l_proc, 10);
9248 end if;
9249 --
9250 when others then
9251 if g_debug then
9252 hr_utility.set_location('Exception Raised '||l_proc, 10);
9253 end if;
9254
9255 p_rslt_object_version_number :=l_rslt_object_version_number ;
9256 p_suspend_flag :=l_suspend_flag ;
9257 p_bnf_actn_warning :=null;
9258
9259 raise;
9260 --
9261 end process_bnf_actn_items;
9262 --
9263 -- ----------------------------------------------------------------------------
9264 -- |-----------------------< determine_action_items >-------------------------|
9265 -- ----------------------------------------------------------------------------
9266 --
9267 procedure determine_action_items
9268 (p_prtt_enrt_rslt_id in number
9269 ,p_effective_date in date
9270 ,p_business_group_id in number
9271 ,p_validate in boolean default false
9272 ,p_enrt_bnft_id in number default null
9273 ,p_datetrack_mode in varchar2 default hr_api.g_correction
9274 ,p_post_rslt_flag in varchar2 default 'Y'
9275 ,p_rslt_object_version_number in out nocopy number
9276 ,p_suspend_flag out nocopy varchar2
9277 ,p_dpnt_actn_warning out nocopy boolean
9278 ,p_bnf_actn_warning out nocopy boolean
9279 ,p_ctfn_actn_warning out nocopy boolean
9280 ) is
9281 --
9282 -- this procedure is the main driver/entry point for action items
9283 -- determines if designated dependents and benficiaries meet all the criteria
9284 -- for PL, PGM, and PTIP where necessary.
9285 --
9286 l_proc varchar2(80) ;
9287 --
9288 l_suspend_flag varchar2(30) := 'N';
9289 l_dpnt_actn_warning boolean := FALSE;
9290 l_bnf_actn_warning boolean := FALSE;
9291 l_ctfn_actn_warning boolean := FALSE;
9292
9293 --Bug 4525608 New variable to handle the case when dependent details are
9294 -- provided and plan level certification has not been furnished
9295 -- this flag will be set when plan certification is not provided
9296 -- and dependent details are provided
9297 l_ctfn_actn_warning_o boolean := FALSE;
9298 --End Bug 4525608
9299
9300
9301 l_pcp_actn_warning boolean := FALSE;
9302 l_pcp_dpnt_actn_warning boolean := FALSE;
9303 l_pln_name ben_pl_f.name%type; -- UTF8 Change Bug 2254683
9304 l_person_id per_all_people_f.person_id%type;
9305 l_rslt_object_version_number number(15);
9306
9307 --
9308 -- Bug : 1857685
9309 --
9310 l_waive_flag varchar2(2) := 'N';
9311 l_pl_id ben_pl_f.pl_id%type;
9312 l_oipl_id ben_oipl_f.oipl_id%type;
9313 l_comp_lvl_cd ben_prtt_enrt_rslt_f.comp_lvl_cd%type;
9314
9315 --
9316 cursor c_waive_info_flag is
9317 select pen.pl_id, pen.oipl_id,pen.sspndd_flag --Bug 2228123 added sspndd_flag
9318 from ben_prtt_enrt_rslt_f pen
9319 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
9320 and pen.business_group_id = p_business_group_id
9321 and p_effective_date between pen.effective_start_date
9322 and pen.effective_end_date;
9323 --
9324 -- Bug 1857685 : Do not create dependents and beneficiaries for
9325 -- Waive plans and options
9326 --
9327 cursor c_waive_pl_flag is
9328 select pln.invk_dcln_prtn_pl_flag
9329 from ben_pl_f pln
9330 where pln.pl_id = l_pl_id
9331 and p_effective_date between
9332 pln.effective_start_date and pln.effective_end_date;
9333 --
9334 -- Bug : 1857685
9335 --
9336 cursor c_waive_opt_flag is
9337 select invk_wv_opt_flag
9338 from ben_opt_f opt,
9339 ben_oipl_f oipl
9340 where opt.opt_id = oipl.opt_id
9341 and oipl.oipl_id = l_oipl_id
9342 and p_effective_date between
9343 opt.effective_start_date and opt.effective_end_date
9344 and p_effective_date between
9345 oipl.effective_start_date and oipl.effective_end_date;
9346 --
9347 cursor c_info_for_msg is
9348 select pen.person_id,
9349 pln.name
9350 from ben_prtt_enrt_rslt_f pen
9351 ,ben_pl_f pln
9352 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
9353 and pen.pl_id= pln.pl_id
9354 and pen.business_group_id = p_business_group_id
9355 and pln.business_group_id = p_business_group_id
9356 and p_effective_date between pen.effective_start_date
9357 and pen.effective_end_date
9358 and p_effective_date between pln.effective_start_date
9359 and pln.effective_end_date;
9360
9361 l_message1 fnd_new_messages.message_name%type := 'BEN_92596_PRTTPCP_ERR';
9362 l_message2 fnd_new_messages.message_name%type := 'BEN_92597_DPNTPCP_ERR';
9363 --
9364 /*
9365 --BUG 3042379 Don't create action items for the interim
9366 --enrollment.
9367 cursor c_interim is
9368 select 'x'
9369 from ben_prtt_enrt_rslt_f pen
9370 where pen.rplcs_sspndd_rslt_id = p_prtt_enrt_rslt_id
9371 and p_effective_date between pen.effective_start_date
9372 and pen.effective_end_date
9373 and pen.prtt_enrt_rslt_stat_cd is null ;
9374 */
9375 --
9376 l_dummy varchar2(30);
9377 l_interim boolean := false ;
9378 --
9379 begin
9380 --
9381 g_debug := hr_utility.debug_enabled;
9382 if g_debug then
9383 l_proc := g_package||'.determine_action_items';
9384 hr_utility.set_location ('Entering '||l_proc,10);
9385 end if;
9386 --
9387 l_rslt_object_version_number :=p_rslt_object_version_number ;
9388
9389
9390 -- Issue a savepoint if operating in validation only mode
9391 --
9392 savepoint detemine_action_items;
9393 --BUG 3042379 Don't create action items for the interim
9394 --enrollment
9395 /*
9396 open c_interim;
9397 fetch c_interim into l_dummy;
9398 if c_interim%found then
9399 --
9400 l_interim := true ;
9401 --
9402 end if;
9403 close c_interim ;
9404 */
9405 --
9406 --Bug 4422667 The above commented condition doesnot work some times.
9407 --
9408 if ben_sspndd_enrollment.g_interim_flag = 'Y' then
9409 --
9410 l_interim := true;
9411 --
9412 end if;
9413 --
9414 -- Bug : 185768
9415 --
9416 if p_prtt_enrt_rslt_id is not null then
9417 open c_waive_info_flag;
9418 fetch c_waive_info_flag into l_pl_id, l_oipl_id,l_suspend_flag ; --Bug 2228123;
9419 close c_waive_info_flag;
9420 end if;
9421 --
9422 if l_oipl_id is null then
9423 --
9424 open c_waive_pl_flag;
9425 fetch c_waive_pl_flag into l_waive_flag;
9426 close c_waive_pl_flag;
9427 --
9428 else
9429 --
9430 open c_waive_opt_flag;
9431 fetch c_waive_opt_flag into l_waive_flag;
9432 close c_waive_opt_flag;
9433
9434 if g_debug then
9435 hr_utility.set_location ('waive_flag = '||l_waive_flag,9);
9436 end if;
9437
9438 --
9439 -- un comment the following code 3771346 /*
9440 if nvl(l_waive_flag, 'N') = 'N' then
9441 --
9442 -- Check at plan level.
9443 --
9444 open c_waive_pl_flag;
9445 fetch c_waive_pl_flag into l_waive_flag;
9446 close c_waive_pl_flag;
9447 --
9448 end if;
9449 --end 3771346 */
9450 end if;
9451
9452 if g_debug then
9453 hr_utility.set_location ('waive_flag = '||l_waive_flag,10);
9454 end if;
9455 --BUG 3042379 We don't need to process the action items for the
9456 --interim enrollment.
9457
9458 --
9459 -- Dependents
9460 --
9461 -- Bug : 185768
9462 -- If result is associated with waive plan or option do not create
9463 -- dependent or beneficiary action items.
9464 --
9465 -- BUG 3042379 Don't create action items for the interim
9466 if not l_interim then
9467 -- BUG 3042379 Don't create action items for the interim
9468 --
9469 if nvl(l_waive_flag, 'N') = 'N' then
9470 --
9471 process_dpnt_actn_items
9472 (p_validate => FALSE
9473 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9474 ,p_effective_date => p_effective_date
9475 ,p_business_group_id => p_business_group_id
9476 ,p_datetrack_mode => p_datetrack_mode
9477 ,p_post_rslt_flag => p_post_rslt_flag
9478 ,p_rslt_object_version_number => p_rslt_object_version_number
9479 ,p_suspend_flag => l_suspend_flag
9480 ,p_dpnt_actn_warning => l_dpnt_actn_warning
9481 --Bug No 4525608 to capture the plan level certification required warning
9482 ,p_ctfn_actn_warning => l_ctfn_actn_warning_o);
9483 -- End Bug 4525608
9484 --
9485 -- Beneficiaries
9486 --
9487 process_bnf_actn_items
9488 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9489 ,p_effective_date => p_effective_date
9490 ,p_business_group_id => p_business_group_id
9491 ,p_validate => FALSE
9492 ,p_datetrack_mode => p_datetrack_mode
9493 ,p_post_rslt_flag => p_post_rslt_flag
9494 ,p_rslt_object_version_number => p_rslt_object_version_number
9495 ,p_suspend_flag => l_suspend_flag
9496 ,p_bnf_actn_warning => l_bnf_actn_warning);
9497 --
9498 process_pcp_actn_items
9499 (p_validate => FALSE
9500 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9501 ,p_effective_date => p_effective_date
9502 ,p_business_group_id => p_business_group_id
9503 ,p_datetrack_mode => p_datetrack_mode
9504 ,p_post_rslt_flag => p_post_rslt_flag
9505 ,p_rslt_object_version_number => p_rslt_object_version_number
9506 ,p_suspend_flag => l_suspend_flag
9507 ,p_pcp_actn_warning => l_pcp_actn_warning);
9508 --
9509 process_pcp_dpnt_actn_items
9510 (p_validate => FALSE
9511 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9512 ,p_effective_date => p_effective_date
9513 ,p_business_group_id => p_business_group_id
9514 ,p_datetrack_mode => p_datetrack_mode
9515 ,p_post_rslt_flag => p_post_rslt_flag
9516 ,p_rslt_object_version_number => p_rslt_object_version_number
9517 ,p_suspend_flag => l_suspend_flag
9518 ,p_pcp_dpnt_actn_warning => l_pcp_dpnt_actn_warning);
9519 --
9520 end if;
9521 --
9522 -- Determine all other enrollment action items that need writing
9523 --
9524 determine_other_actn_items
9525 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9526 ,p_rslt_object_version_number => p_rslt_object_version_number
9527 ,p_effective_date => p_effective_date
9528 ,p_post_rslt_flag => p_post_rslt_flag
9529 ,p_business_group_id => p_business_group_id
9530 ,p_validate => FALSE
9531 ,p_enrt_bnft_id => p_enrt_bnft_id
9532 ,p_datetrack_mode => p_datetrack_mode
9533 ,p_suspend_flag => l_suspend_flag
9534 ,p_ctfn_actn_warning => l_ctfn_actn_warning);
9535
9536 --
9537 --
9538 -- Added by Anil --
9539 --
9540 /*fnd_file.put_line(fnd_file.log,'-->cwb_actn process_cwb_actn_items with the following parameters');
9541 fnd_file.put_line(fnd_file.log,'-->cwb_actn p_prtt_enrt_rslt_id '||p_prtt_enrt_rslt_id);
9542 fnd_file.put_line(fnd_file.log,'-->cwb_actn p_effective_date '||p_effective_date);
9543 fnd_file.put_line(fnd_file.log,'-->cwb_actn p_business_group_id '||p_business_group_id );
9544 fnd_file.put_line(fnd_file.log,'-->cwb_actn p_datetrack_mode '||p_datetrack_mode);
9545 fnd_file.put_line(fnd_file.log,'-->cwb_actn p_post_rslt_flag '||p_post_rslt_flag);
9546 fnd_file.put_line(fnd_file.log,'-->cwb_actn p_rslt_object_version_number'||p_rslt_object_version_number);
9547 fnd_file.put_line(fnd_file.log,'-->cwb_actn l_suspend_flag '||l_suspend_flag);
9548 fnd_file.put_line(fnd_file.log,'---------------------------------------------------------------------------');*/
9549 --
9550 process_cwb_actn_items
9551 (p_validate => FALSE
9552 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9553 ,p_effective_date => p_effective_date
9554 ,p_business_group_id => p_business_group_id
9555 ,p_datetrack_mode => p_datetrack_mode
9556 ,p_post_rslt_flag => p_post_rslt_flag
9557 ,p_rslt_object_version_number => p_rslt_object_version_number
9558 ,p_suspend_flag => l_suspend_flag);
9559 --
9560 -- BUG 3042379 Don't create action items for the interim
9561 else
9562 if g_debug then
9563 hr_utility.set_location ('Interim Enrt- No action item created PEN '||p_prtt_enrt_rslt_id,110);
9564 end if;
9565 end if ;
9566 -- BUG 3042379 Don't create action items for the interim
9567 --
9568 -- Set the warning flags
9569 --
9570 p_bnf_actn_warning := l_bnf_actn_warning;
9571 p_dpnt_actn_warning := l_dpnt_actn_warning;
9572
9573 -- Bug 4525608 set the certification required flag if any of the
9574 -- flags is true
9575 if l_ctfn_actn_warning or l_ctfn_actn_warning_o then
9576 p_ctfn_actn_warning := TRUE;
9577 end if;
9578 -- End Bug 4525608
9579
9580
9581 if l_pcp_actn_warning or l_pcp_dpnt_actn_warning then
9582
9583 if p_prtt_enrt_rslt_id is not null then
9584 open c_info_for_msg;
9585 fetch c_info_for_msg into l_person_id,l_pln_name;
9586 close c_info_for_msg;
9587 end if;
9588
9589 end if;
9590 --
9591 l_pln_name := substr(l_pln_name,1,60);
9592 if l_pcp_actn_warning then
9593 ben_warnings.load_warning
9594 (p_application_short_name => 'BEN',
9595 p_message_name => l_message1,
9596 p_parma => l_pln_name,
9597 p_person_id => l_person_id);
9598 end if;
9599 --
9600 if l_pcp_dpnt_actn_warning then
9601 ben_warnings.load_warning
9602 (p_application_short_name => 'BEN',
9603 p_message_name => l_message2,
9604 p_parma => l_pln_name,
9605 p_person_id => l_person_id);
9606 end if;
9607 --
9608 -- When in validation only mode raise the Validate_Enabled exception
9609 --
9610 if p_validate then
9611 raise hr_api.validate_enabled;
9612 end if;
9613 --
9614 p_suspend_flag := l_suspend_flag;
9615 --
9616 if g_debug then
9617 hr_utility.set_location ('Leaving ' ||l_proc,10);
9618 end if;
9619 --
9620 exception
9621 --
9622 when hr_api.validate_enabled
9623 then
9624 -- rollback to the savepoint
9625 --
9626 ROLLBACK TO determine_action_items;
9627 --
9628 when others then
9629 if g_debug then
9630 hr_utility.set_location('Exception Raised '||l_proc, 10);
9631 end if;
9632 p_rslt_object_version_number :=l_rslt_object_version_number ;
9633 p_suspend_flag :=l_suspend_flag ;
9634 p_ctfn_actn_warning := null ;
9635
9636 p_dpnt_actn_warning := null;
9637 p_bnf_actn_warning := null;
9638 p_ctfn_actn_warning := null;
9639 --
9640 raise; -- Bug 3105160
9641 --
9642 end determine_action_items;
9643 --
9644 end ben_enrollment_action_items;