DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PRTT_ENRT_ACTN_API

Source


1 Package Body ben_PRTT_ENRT_ACTN_api as
2 /* $Header: bepeaapi.pkb 120.7 2011/09/14 17:21:55 pvelvano noship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(33) := '  ben_PRTT_ENRT_ACTN_api.';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |---------------------------< suspend_rslt  >----------------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 procedure suspend_rslt
13   (p_prtt_enrt_rslt_id          in     number
14   ,p_effective_date             in     date
15   ,p_post_rslt_flag             in     varchar2
16   ,p_business_group_id          in     number
17   ,p_rslt_object_version_number in out nocopy number
18   ,p_validate                   in     boolean  default false
19   ,p_datetrack_mode             in     varchar2 default hr_api.g_correction)
20 is
21   --
22   -- check if a suspend action done already. If not suspend enrollment now.
23   --
24   l_package     varchar2(80) := g_package||'.suspend_rslt';
25   --
26   cursor c_suspend_enrl
27   is
28   select sspndd_flag
29     from ben_prtt_enrt_rslt_f perslt
30    where perslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
31      and perslt.prtt_enrt_rslt_stat_cd is null
32      and perslt.business_group_id = p_business_group_id
33      and p_effective_date between perslt.effective_start_date
34                               and perslt.effective_end_date;
35   --
36   l_suspend_enrl c_suspend_enrl%rowtype;
37 --
38 begin
39 --
40   hr_utility.set_location ('Entering '||l_package,10);
41   --
42   -- Check if the enrollment result is already suspended.
43   --
44   open c_suspend_enrl;
45   fetch c_suspend_enrl into l_suspend_enrl;
46   close c_suspend_enrl;
47   --
48   -- Bug#2151619 bypass suspend enrollment in backout process
49   if -- l_suspend_enrl.sspndd_flag <> 'Y' and --CFW
50      ben_back_out_life_event.g_backout_flag is null then
51     --
52     -- Not already suspended... so suspend enrt rslt.
53     --
54     ben_sspndd_enrollment.suspend_enrollment
55       (p_prtt_enrt_rslt_id     => p_prtt_enrt_rslt_id
56       ,p_effective_date        => p_effective_date
57       ,p_post_rslt_flag        => p_post_rslt_flag
58       ,p_business_group_id     => p_business_group_id
59       ,p_object_version_number => p_rslt_object_version_number
60       ,p_datetrack_mode        => p_datetrack_mode);
61     --
62   end if;
63   --
64   hr_utility.set_location ('Leaving ' ||l_package,10);
65 --
66 end suspend_rslt;
67 --
68 -- ----------------------------------------------------------------------------
69 -- |---------------------------< unsuspend_rslt  >----------------------------|
70 -- ----------------------------------------------------------------------------
71 --
72 procedure unsuspend_rslt
73   (p_prtt_enrt_rslt_id          in     number
74   ,p_effective_date             in     date
75   ,p_post_rslt_flag             in     varchar2
76   ,p_business_group_id          in     number
77   ,p_rslt_object_version_number in out nocopy number
78   ,p_validate                   in     boolean  default false
79   ,p_datetrack_mode             in     varchar2 default hr_api.g_correction
80   ,p_cmpltd_dt                  in     date default null )
81 is
82   --
83   -- check if possible to unsuspend action items for this participant.
84   -- ie. there should be no open action items with a rqd_flag = 'Y'.
85   --
86   l_package     varchar2(80) := g_package||'.unsuspend_rslt';
87   --
88   cursor c_suspend_enrl
89   is
90   select sspndd_flag
91     from ben_prtt_enrt_rslt_f perslt
92    where perslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
93      and perslt.prtt_enrt_rslt_stat_cd is null
94      and perslt.business_group_id = p_business_group_id
95      and p_effective_date between perslt.effective_start_date
96                               and perslt.effective_end_date;
97   --
98   l_suspend_enrl c_suspend_enrl%rowtype;
99   --
100   --bug#5621152
101   cursor c_cmpltd_actn
102   is
103   select 'X'
104     from ben_prtt_enrt_actn_f act,
105          ben_per_in_ler pil
106    where act.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
107      and act.per_in_ler_id = pil.per_in_ler_id
108      and pil.per_in_ler_stat_cd not in ('VOIDD', 'BCKDT')
109      and act.rqd_flag = 'Y'
110      and act.cmpltd_dt IS NULL
111      and act.business_group_id = p_business_group_id
112      and p_effective_date between act.effective_start_date
113                               and act.effective_end_date;
114   --
115   l_cmpltd_actn c_cmpltd_actn%rowtype;
116 --
117 begin
118 --
119   hr_utility.set_location ('Entering '||l_package,10);
120   --
121   open c_suspend_enrl;
122   fetch c_suspend_enrl into l_suspend_enrl;
123   close c_suspend_enrl;
124   --
125   if l_suspend_enrl.sspndd_flag = 'Y' then
126     --
127     -- enrollment suspended, now check for the existance of any required
128     -- action items that are not yet complete
129     --
130     open c_cmpltd_actn;
131     fetch c_cmpltd_actn into l_cmpltd_actn;
132     --
133     if c_cmpltd_actn%notfound then
134       -- No open required action items exist. Ok to unsuspend enrollment.
135       close c_cmpltd_actn;
136       --
137       ben_sspndd_enrollment.unsuspend_enrollment
138         (p_prtt_enrt_rslt_id     => p_prtt_enrt_rslt_id
139         ,p_effective_date        => p_effective_date
140         ,p_post_rslt_flag        => p_post_rslt_flag
141         ,p_business_group_id     => p_business_group_id
142         ,p_object_version_number => p_rslt_object_version_number
143         ,p_datetrack_mode        => p_datetrack_mode
144         ,p_cmpltd_dt             => p_cmpltd_dt );
145       --
146     else
147       --
148       -- Open required action items exist. Cannot unsuspend enrollment result.
149       --
150       close c_cmpltd_actn;
151       --
152     end if;
153     --
154   else
155     NULL; -- Enrollment already unsuspended.
156   end if;
157   --
158   hr_utility.set_location ('Leaving ' ||l_package,10);
159   --
160 end unsuspend_rslt;
161 --
162 -- ----------------------------------------------------------------------------
163 -- |--------------------------< create_PRTT_ENRT_ACTN >-----------------------|
164 -- ----------------------------------------------------------------------------
165 --
166 -- THIS PROCEDURE WAS DUPLICATED.  ONE HAS PER-IN-LER-ID THE OTHER DOESN'T.
167 -- CHANGE BOTH PROCEDURES IF MAKING A CHANGE.
168 --
169 procedure create_PRTT_ENRT_ACTN
170   (p_validate                       in     boolean   default false
171   ,p_effective_date                 in     date
172   ,p_post_rslt_flag                 in     varchar2  default 'N'
173   ,p_cmpltd_dt                      in     date      default null
174   ,p_due_dt                         in     date      default null
175   ,p_rqd_flag                       in     varchar2  default 'Y'
176   ,p_prtt_enrt_rslt_id              in     number    default null
177   ,p_per_in_ler_id              in     number
178   ,p_rslt_object_version_number     in out nocopy number
179   ,p_actn_typ_id                    in     number    default null
180   ,p_elig_cvrd_dpnt_id              in     number    default null
181   ,p_pl_bnf_id                      in     number    default null
182   ,p_business_group_id              in     number    default null
183   ,p_pea_attribute_category         in     varchar2  default null
184   ,p_pea_attribute1                 in     varchar2  default null
185   ,p_pea_attribute2                 in     varchar2  default null
186   ,p_pea_attribute3                 in     varchar2  default null
187   ,p_pea_attribute4                 in     varchar2  default null
188   ,p_pea_attribute5                 in     varchar2  default null
189   ,p_pea_attribute6                 in     varchar2  default null
190   ,p_pea_attribute7                 in     varchar2  default null
191   ,p_pea_attribute8                 in     varchar2  default null
192   ,p_pea_attribute9                 in     varchar2  default null
193   ,p_pea_attribute10                in     varchar2  default null
194   ,p_pea_attribute11                in     varchar2  default null
195   ,p_pea_attribute12                in     varchar2  default null
196   ,p_pea_attribute13                in     varchar2  default null
197   ,p_pea_attribute14                in     varchar2  default null
198   ,p_pea_attribute15                in     varchar2  default null
199   ,p_pea_attribute16                in     varchar2  default null
200   ,p_pea_attribute17                in     varchar2  default null
201   ,p_pea_attribute18                in     varchar2  default null
202   ,p_pea_attribute19                in     varchar2  default null
203   ,p_pea_attribute20                in     varchar2  default null
204   ,p_pea_attribute21                in     varchar2  default null
205   ,p_pea_attribute22                in     varchar2  default null
206   ,p_pea_attribute23                in     varchar2  default null
207   ,p_pea_attribute24                in     varchar2  default null
208   ,p_pea_attribute25                in     varchar2  default null
209   ,p_pea_attribute26                in     varchar2  default null
210   ,p_pea_attribute27                in     varchar2  default null
211   ,p_pea_attribute28                in     varchar2  default null
212   ,p_pea_attribute29                in     varchar2  default null
213   ,p_pea_attribute30                in     varchar2  default null
214   ,p_gnrt_cm                        in     boolean   default true
215   ,p_object_version_number             out nocopy number
216   ,p_prtt_enrt_actn_id                 out nocopy number
217   ,p_effective_start_date              out nocopy date
218   ,p_effective_end_date                out nocopy date
219   )
220 is
221   --
222   -- Declare cursors and local variables
223   --
224   cursor c_prtt_enrt_rslt is
225     select person_id
226           ,ler_id
227           ,pgm_id
228           ,pl_id
229           ,pl_typ_id
230     from ben_prtt_enrt_rslt_f
231     where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
232     and   prtt_enrt_rslt_stat_cd is null
233     and p_effective_date between
234     effective_start_date and effective_end_date;
235   --
236   l_person_id     ben_prtt_enrt_rslt_f.person_id%TYPE;
237   l_ler_id        ben_prtt_enrt_rslt_f.ler_id%TYPE;
238   l_pl_id         ben_prtt_enrt_rslt_f.pl_id%TYPE;
239   l_pl_typ_id     ben_prtt_enrt_rslt_f.pl_typ_id%TYPE;
240   l_pgm_id        ben_prtt_enrt_rslt_f.pgm_id%TYPE;
241   l_prtt_enrt_actn_id ben_prtt_enrt_actn_f.prtt_enrt_actn_id%TYPE;
242   l_effective_start_date ben_prtt_enrt_actn_f.effective_start_date%TYPE;
243   l_effective_end_date ben_prtt_enrt_actn_f.effective_end_date%TYPE;
244   l_proc varchar2(72) := g_package||'create_PRTT_ENRT_ACTN';
245   l_object_version_number ben_prtt_enrt_actn_f.object_version_number%TYPE;
246   --
247 begin
248   --
249   hr_utility.set_location('Entering:'|| l_proc, 10);
250   --
251   -- Issue a savepoint if operating in validation only mode
252   --
253   savepoint create_PRTT_ENRT_ACTN;
254   --
255   hr_utility.set_location(l_proc, 20);
256   --
257   -- Process Logic
258   --
259   begin
260     --
261     -- Start of API User Hook for the before hook of create_PRTT_ENRT_ACTN
262     --
263     ben_PRTT_ENRT_ACTN_bk1.create_PRTT_ENRT_ACTN_b
264       (p_cmpltd_dt                      =>  p_cmpltd_dt
265       ,p_due_dt                         =>  p_due_dt
266       ,p_rqd_flag                       =>  p_rqd_flag
267       ,p_prtt_enrt_rslt_id              =>  p_prtt_enrt_rslt_id
268       ,p_per_in_ler_id              =>  p_per_in_ler_id
269       ,p_actn_typ_id                    =>  p_actn_typ_id
270       ,p_elig_cvrd_dpnt_id              =>  p_elig_cvrd_dpnt_id
271       ,p_pl_bnf_id                      =>  p_pl_bnf_id
272       ,p_pea_attribute_category         =>  p_pea_attribute_category
273       ,p_business_group_id              =>  p_business_group_id
274       ,p_pea_attribute1                 =>  p_pea_attribute1
275       ,p_pea_attribute2                 =>  p_pea_attribute2
276       ,p_pea_attribute3                 =>  p_pea_attribute3
277       ,p_pea_attribute4                 =>  p_pea_attribute4
278       ,p_pea_attribute5                 =>  p_pea_attribute5
279       ,p_pea_attribute6                 =>  p_pea_attribute6
280       ,p_pea_attribute7                 =>  p_pea_attribute7
281       ,p_pea_attribute8                 =>  p_pea_attribute8
282       ,p_pea_attribute9                 =>  p_pea_attribute9
283       ,p_pea_attribute10                =>  p_pea_attribute10
284       ,p_pea_attribute11                =>  p_pea_attribute11
285       ,p_pea_attribute12                =>  p_pea_attribute12
286       ,p_pea_attribute13                =>  p_pea_attribute13
287       ,p_pea_attribute14                =>  p_pea_attribute14
288       ,p_pea_attribute15                =>  p_pea_attribute15
289       ,p_pea_attribute16                =>  p_pea_attribute16
290       ,p_pea_attribute17                =>  p_pea_attribute17
291       ,p_pea_attribute18                =>  p_pea_attribute18
292       ,p_pea_attribute19                =>  p_pea_attribute19
293       ,p_pea_attribute20                =>  p_pea_attribute20
294       ,p_pea_attribute21                =>  p_pea_attribute21
295       ,p_pea_attribute22                =>  p_pea_attribute22
296       ,p_pea_attribute23                =>  p_pea_attribute23
297       ,p_pea_attribute24                =>  p_pea_attribute24
298       ,p_pea_attribute25                =>  p_pea_attribute25
299       ,p_pea_attribute26                =>  p_pea_attribute26
300       ,p_pea_attribute27                =>  p_pea_attribute27
301       ,p_pea_attribute28                =>  p_pea_attribute28
302       ,p_pea_attribute29                =>  p_pea_attribute29
303       ,p_pea_attribute30                =>  p_pea_attribute30
304       ,p_effective_date                 => trunc(p_effective_date)
305       );
306   exception
307     when hr_api.cannot_find_prog_unit then
308       hr_api.cannot_find_prog_unit_error
309         (
310          p_module_name => 'CREATE_PRTT_ENRT_ACTN'
311         ,p_hook_type   => 'BP'
312         );
313     --
314     -- End of API User Hook for the before hook of create_PRTT_ENRT_ACTN
315     --
316   end;
317   --
318   ben_pea_ins.ins
319     (
320      p_prtt_enrt_actn_id             => l_prtt_enrt_actn_id
321     ,p_effective_start_date          => l_effective_start_date
322     ,p_effective_end_date            => l_effective_end_date
323     ,p_cmpltd_dt                     => p_cmpltd_dt
324     ,p_due_dt                        => p_due_dt
325     ,p_rqd_flag                      => p_rqd_flag
326     ,p_prtt_enrt_rslt_id             => p_prtt_enrt_rslt_id
327     ,p_per_in_ler_id             => p_per_in_ler_id
328     ,p_actn_typ_id                   => p_actn_typ_id
329     ,p_elig_cvrd_dpnt_id             => p_elig_cvrd_dpnt_id
330     ,p_pl_bnf_id                     => p_pl_bnf_id
331     ,p_business_group_id             => p_business_group_id
332     ,p_pea_attribute_category        => p_pea_attribute_category
333     ,p_pea_attribute1                => p_pea_attribute1
334     ,p_pea_attribute2                => p_pea_attribute2
335     ,p_pea_attribute3                => p_pea_attribute3
336     ,p_pea_attribute4                => p_pea_attribute4
337     ,p_pea_attribute5                => p_pea_attribute5
338     ,p_pea_attribute6                => p_pea_attribute6
339     ,p_pea_attribute7                => p_pea_attribute7
340     ,p_pea_attribute8                => p_pea_attribute8
341     ,p_pea_attribute9                => p_pea_attribute9
342     ,p_pea_attribute10               => p_pea_attribute10
343     ,p_pea_attribute11               => p_pea_attribute11
344     ,p_pea_attribute12               => p_pea_attribute12
345     ,p_pea_attribute13               => p_pea_attribute13
346     ,p_pea_attribute14               => p_pea_attribute14
347     ,p_pea_attribute15               => p_pea_attribute15
348     ,p_pea_attribute16               => p_pea_attribute16
349     ,p_pea_attribute17               => p_pea_attribute17
350     ,p_pea_attribute18               => p_pea_attribute18
351     ,p_pea_attribute19               => p_pea_attribute19
352     ,p_pea_attribute20               => p_pea_attribute20
353     ,p_pea_attribute21               => p_pea_attribute21
354     ,p_pea_attribute22               => p_pea_attribute22
355     ,p_pea_attribute23               => p_pea_attribute23
356     ,p_pea_attribute24               => p_pea_attribute24
357     ,p_pea_attribute25               => p_pea_attribute25
358     ,p_pea_attribute26               => p_pea_attribute26
359     ,p_pea_attribute27               => p_pea_attribute27
360     ,p_pea_attribute28               => p_pea_attribute28
361     ,p_pea_attribute29               => p_pea_attribute29
362     ,p_pea_attribute30               => p_pea_attribute30
363     ,p_object_version_number         => l_object_version_number
364     ,p_effective_date                => trunc(p_effective_date)
365     );
366   --
367   begin
368     --
369     -- Start of API User Hook for the after hook of create_PRTT_ENRT_ACTN
370     --
371     ben_PRTT_ENRT_ACTN_bk1.create_PRTT_ENRT_ACTN_a
372       (
373        p_prtt_enrt_actn_id              =>  l_prtt_enrt_actn_id
374       ,p_effective_start_date           =>  l_effective_start_date
375       ,p_effective_end_date             =>  l_effective_end_date
376       ,p_cmpltd_dt                      =>  p_cmpltd_dt
377       ,p_due_dt                         =>  p_due_dt
378       ,p_rqd_flag                       =>  p_rqd_flag
379       ,p_prtt_enrt_rslt_id              =>  p_prtt_enrt_rslt_id
380       ,p_per_in_ler_id              =>  p_per_in_ler_id
381       ,p_actn_typ_id                    =>  p_actn_typ_id
382       ,p_elig_cvrd_dpnt_id              =>  p_elig_cvrd_dpnt_id
383       ,p_pl_bnf_id                      =>  p_pl_bnf_id
384       ,p_business_group_id              =>  p_business_group_id
385       ,p_pea_attribute_category         =>  p_pea_attribute_category
386       ,p_pea_attribute1                 =>  p_pea_attribute1
387       ,p_pea_attribute2                 =>  p_pea_attribute2
388       ,p_pea_attribute3                 =>  p_pea_attribute3
389       ,p_pea_attribute4                 =>  p_pea_attribute4
390       ,p_pea_attribute5                 =>  p_pea_attribute5
391       ,p_pea_attribute6                 =>  p_pea_attribute6
392       ,p_pea_attribute7                 =>  p_pea_attribute7
393       ,p_pea_attribute8                 =>  p_pea_attribute8
394       ,p_pea_attribute9                 =>  p_pea_attribute9
395       ,p_pea_attribute10                =>  p_pea_attribute10
396       ,p_pea_attribute11                =>  p_pea_attribute11
397       ,p_pea_attribute12                =>  p_pea_attribute12
398       ,p_pea_attribute13                =>  p_pea_attribute13
399       ,p_pea_attribute14                =>  p_pea_attribute14
400       ,p_pea_attribute15                =>  p_pea_attribute15
401       ,p_pea_attribute16                =>  p_pea_attribute16
402       ,p_pea_attribute17                =>  p_pea_attribute17
403       ,p_pea_attribute18                =>  p_pea_attribute18
404       ,p_pea_attribute19                =>  p_pea_attribute19
405       ,p_pea_attribute20                =>  p_pea_attribute20
406       ,p_pea_attribute21                =>  p_pea_attribute21
407       ,p_pea_attribute22                =>  p_pea_attribute22
408       ,p_pea_attribute23                =>  p_pea_attribute23
409       ,p_pea_attribute24                =>  p_pea_attribute24
410       ,p_pea_attribute25                =>  p_pea_attribute25
411       ,p_pea_attribute26                =>  p_pea_attribute26
412       ,p_pea_attribute27                =>  p_pea_attribute27
413       ,p_pea_attribute28                =>  p_pea_attribute28
414       ,p_pea_attribute29                =>  p_pea_attribute29
415       ,p_pea_attribute30                =>  p_pea_attribute30
416       ,p_object_version_number          =>  l_object_version_number
417       ,p_effective_date                 => trunc(p_effective_date)
418       );
419   exception
420     when hr_api.cannot_find_prog_unit then
421       hr_api.cannot_find_prog_unit_error
422         (p_module_name => 'CREATE_PRTT_ENRT_ACTN'
423         ,p_hook_type   => 'AP'
424         );
425     --
426     -- End of API User Hook for the after hook of create_PRTT_ENRT_ACTN
427     --
428   end;
429   --
430   hr_utility.set_location(l_proc, 60);
431   --
432   p_prtt_enrt_actn_id := l_prtt_enrt_actn_id;
433   p_effective_start_date := l_effective_start_date;
434   p_effective_end_date := l_effective_end_date;
435   p_object_version_number := l_object_version_number;
436   --
437   -- if action item is required, suspend the enrollment
438   -- if setting cmpltd_dt to NULL try to unsuspend if
439   -- cmpltd_dt is getting a value
440   --
441   if p_rqd_flag = 'Y' then
442     if p_cmpltd_dt is NULL then
443       suspend_rslt
444         (p_prtt_enrt_rslt_id          => p_prtt_enrt_rslt_id
445         ,p_post_rslt_flag             => p_post_rslt_flag
446         ,p_effective_date             => p_effective_date
447         ,p_business_group_id          => p_business_group_id
448         ,p_rslt_object_version_number => p_rslt_object_version_number
449         ,p_validate                   => p_validate
450         ,p_datetrack_mode             => hr_api.g_correction);
451       --
452     else
453       --
454       unsuspend_rslt
455         (p_prtt_enrt_rslt_id          => p_prtt_enrt_rslt_id
456         ,p_post_rslt_flag             => p_post_rslt_flag
457         ,p_effective_date             => p_effective_date
458         ,p_business_group_id          => p_business_group_id
459         ,p_rslt_object_version_number => p_rslt_object_version_number
460         ,p_validate                   => p_validate
461         ,p_datetrack_mode             => hr_api.g_correction
462         ,p_cmpltd_dt                  => p_cmpltd_dt );
463     --
464     end if;
465   end if;
466   --
467   if p_gnrt_cm then
468     open c_prtt_enrt_rslt;
469     fetch c_prtt_enrt_rslt into l_person_id
470                                ,l_ler_id
471                                ,l_pgm_id
472                                ,l_pl_id
473                                ,l_pl_typ_id;
474     if c_prtt_enrt_rslt%notfound then
475       close c_prtt_enrt_rslt;
476       fnd_message.set_name('BEN','BEN_91916_ENRT_TABLE_NOT_FOUND');
477       fnd_message.set_token('TABLE','BEN_PRTT_ENRT_RSLT_F');
478       fnd_message.raise_error;
479     end if;
480     close c_prtt_enrt_rslt;
481     --
482     --  Generate Communications
483     --
484     ben_generate_communications.main
485       (p_person_id             => l_person_id
486       ,p_ler_id                => l_ler_id
487       -- CWB Changes.
488       ,p_per_in_ler_id         => p_per_in_ler_id
489       ,p_prtt_enrt_actn_id     => l_prtt_enrt_actn_id
490       ,p_pgm_id                => l_pgm_id
491       ,p_pl_id                 => l_pl_id
492       ,p_pl_typ_id             => l_pl_typ_id
493       ,p_actn_typ_id           => p_actn_typ_id
494       ,p_business_group_id     => p_business_group_id
495       ,p_proc_cd1              => 'ACTNCREATED'
496       ,p_effective_date        => p_effective_date);
497   end if;
498   --
499   -- When in validation only mode raise the Validate_Enabled exception
500   --
501   if p_validate then
502     raise hr_api.validate_enabled;
503   end if;
504   --
505   -- Set all output arguments
506   --
507   hr_utility.set_location(' Leaving:'||l_proc, 70);
508   --
509 exception
510   --
511   when hr_api.validate_enabled
512   then
513     --
514     -- As the Validate_Enabled exception has been raised
515     -- we must rollback to the savepoint
516     --
517     ROLLBACK TO create_PRTT_ENRT_ACTN;
518     --
519     -- Only set output warning arguments
520     -- (Any key or derived arguments must be set to null
521     -- when validation only mode is being used.)
522     --
523     p_prtt_enrt_actn_id := null;
524     p_effective_start_date := null;
525     p_effective_end_date := null;
526     p_object_version_number  := null;
527     hr_utility.set_location(' Leaving:'||l_proc, 80);
528     --
529   when others then
530     --
531     -- A validation or unexpected error has occured
532     --
533     ROLLBACK TO create_PRTT_ENRT_ACTN;
534     raise;
535     --
536 end create_PRTT_ENRT_ACTN;
537 --
538 -- ----------------------------------------------------------------------------
539 -- |--------------------------< create_PRTT_ENRT_ACTN >-----------------------|
540 -- ----------------------------------------------------------------------------
541 --
542 --
543 -- THIS PROCEDURE WAS DUPLICATED.  ONE HAS PER-IN-LER-ID THE OTHER DOESN'T.
544 -- CHANGE BOTH PROCEDURES IF MAKING A CHANGE.
545 --
546 procedure create_PRTT_ENRT_ACTN
547   (p_validate                       in     boolean   default false
548   ,p_effective_date                 in     date
549   ,p_post_rslt_flag                 in     varchar2  default 'N'
550   ,p_cmpltd_dt                      in     date      default null
551   ,p_due_dt                         in     date      default null
552   ,p_rqd_flag                       in     varchar2  default 'Y'
553   ,p_prtt_enrt_rslt_id              in     number    default null
554   ,p_rslt_object_version_number     in out nocopy number
555   ,p_actn_typ_id                    in     number    default null
556   ,p_elig_cvrd_dpnt_id              in     number    default null
557   ,p_pl_bnf_id                      in     number    default null
558   ,p_business_group_id              in     number    default null
559   ,p_pea_attribute_category         in     varchar2  default null
560   ,p_pea_attribute1                 in     varchar2  default null
561   ,p_pea_attribute2                 in     varchar2  default null
562   ,p_pea_attribute3                 in     varchar2  default null
563   ,p_pea_attribute4                 in     varchar2  default null
564   ,p_pea_attribute5                 in     varchar2  default null
565   ,p_pea_attribute6                 in     varchar2  default null
566   ,p_pea_attribute7                 in     varchar2  default null
567   ,p_pea_attribute8                 in     varchar2  default null
568   ,p_pea_attribute9                 in     varchar2  default null
569   ,p_pea_attribute10                in     varchar2  default null
570   ,p_pea_attribute11                in     varchar2  default null
571   ,p_pea_attribute12                in     varchar2  default null
572   ,p_pea_attribute13                in     varchar2  default null
573   ,p_pea_attribute14                in     varchar2  default null
574   ,p_pea_attribute15                in     varchar2  default null
575   ,p_pea_attribute16                in     varchar2  default null
576   ,p_pea_attribute17                in     varchar2  default null
577   ,p_pea_attribute18                in     varchar2  default null
578   ,p_pea_attribute19                in     varchar2  default null
579   ,p_pea_attribute20                in     varchar2  default null
580   ,p_pea_attribute21                in     varchar2  default null
581   ,p_pea_attribute22                in     varchar2  default null
582   ,p_pea_attribute23                in     varchar2  default null
583   ,p_pea_attribute24                in     varchar2  default null
584   ,p_pea_attribute25                in     varchar2  default null
585   ,p_pea_attribute26                in     varchar2  default null
586   ,p_pea_attribute27                in     varchar2  default null
587   ,p_pea_attribute28                in     varchar2  default null
588   ,p_pea_attribute29                in     varchar2  default null
589   ,p_pea_attribute30                in     varchar2  default null
590   ,p_gnrt_cm                        in     boolean   default true
591   ,p_object_version_number             out nocopy number
592   ,p_prtt_enrt_actn_id                 out nocopy number
593   ,p_effective_start_date              out nocopy date
594   ,p_effective_end_date                out nocopy date
595   )
596 is
597   --
598   -- Declare cursors and local variables
599   --
600   cursor c_prtt_enrt_rslt is
601     select person_id
602           ,ler_id
603           ,pgm_id
604           ,pl_id
605           ,pl_typ_id
606           ,per_in_ler_id
607     from ben_prtt_enrt_rslt_f
608     where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
609     and   prtt_enrt_rslt_stat_cd is null
610     and p_effective_date between
611     effective_start_date and effective_end_date;
612   --
613   l_person_id     ben_prtt_enrt_rslt_f.person_id%TYPE;
614   l_ler_id        ben_prtt_enrt_rslt_f.ler_id%TYPE;
615   l_pl_id         ben_prtt_enrt_rslt_f.pl_id%TYPE;
616   l_pl_typ_id     ben_prtt_enrt_rslt_f.pl_typ_id%TYPE;
617   l_pgm_id        ben_prtt_enrt_rslt_f.pgm_id%TYPE;
618   l_prtt_enrt_actn_id ben_prtt_enrt_actn_f.prtt_enrt_actn_id%TYPE;
619   l_effective_start_date ben_prtt_enrt_actn_f.effective_start_date%TYPE;
620   l_effective_end_date ben_prtt_enrt_actn_f.effective_end_date%TYPE;
621   l_proc varchar2(72) := g_package||'create_PRTT_ENRT_ACTN';
622   l_object_version_number ben_prtt_enrt_actn_f.object_version_number%TYPE;
623   l_per_in_ler_id number;
624   --
625 begin
626   --
627   hr_utility.set_location('Entering:'|| l_proc, 10);
628   --
629   -- Issue a savepoint if operating in validation only mode
630   --
631   savepoint create_PRTT_ENRT_ACTN;
632   --
633   hr_utility.set_location(l_proc, 20);
634   --
635   -- Process Logic
636   --
637   begin
638     open c_prtt_enrt_rslt;
639     fetch c_prtt_enrt_rslt into l_person_id
640                                ,l_ler_id
641                                ,l_pgm_id
642                                ,l_pl_id
643                                ,l_pl_typ_id
644                                ,l_per_in_ler_id;
645     if c_prtt_enrt_rslt%notfound then
646       close c_prtt_enrt_rslt;
647       fnd_message.set_name('BEN','BEN_91916_ENRT_TABLE_NOT_FOUND');
648       fnd_message.set_token('TABLE','BEN_PRTT_ENRT_RSLT_F');
649       fnd_message.raise_error;
650     end if;
651     close c_prtt_enrt_rslt;
652     --
653     -- Start of API User Hook for the before hook of create_PRTT_ENRT_ACTN
654     --
655     ben_PRTT_ENRT_ACTN_bk1.create_PRTT_ENRT_ACTN_b
656       (p_cmpltd_dt                      =>  p_cmpltd_dt
657       ,p_due_dt                         =>  p_due_dt
658       ,p_rqd_flag                       =>  p_rqd_flag
659       ,p_prtt_enrt_rslt_id              =>  p_prtt_enrt_rslt_id
660       ,p_per_in_ler_id              =>  l_per_in_ler_id
661       ,p_actn_typ_id                    =>  p_actn_typ_id
662       ,p_elig_cvrd_dpnt_id              =>  p_elig_cvrd_dpnt_id
663       ,p_pl_bnf_id                      =>  p_pl_bnf_id
664       ,p_pea_attribute_category         =>  p_pea_attribute_category
665       ,p_business_group_id              =>  p_business_group_id
666       ,p_pea_attribute1                 =>  p_pea_attribute1
667       ,p_pea_attribute2                 =>  p_pea_attribute2
668       ,p_pea_attribute3                 =>  p_pea_attribute3
669       ,p_pea_attribute4                 =>  p_pea_attribute4
670       ,p_pea_attribute5                 =>  p_pea_attribute5
671       ,p_pea_attribute6                 =>  p_pea_attribute6
672       ,p_pea_attribute7                 =>  p_pea_attribute7
673       ,p_pea_attribute8                 =>  p_pea_attribute8
674       ,p_pea_attribute9                 =>  p_pea_attribute9
675       ,p_pea_attribute10                =>  p_pea_attribute10
676       ,p_pea_attribute11                =>  p_pea_attribute11
677       ,p_pea_attribute12                =>  p_pea_attribute12
678       ,p_pea_attribute13                =>  p_pea_attribute13
679       ,p_pea_attribute14                =>  p_pea_attribute14
680       ,p_pea_attribute15                =>  p_pea_attribute15
681       ,p_pea_attribute16                =>  p_pea_attribute16
682       ,p_pea_attribute17                =>  p_pea_attribute17
683       ,p_pea_attribute18                =>  p_pea_attribute18
684       ,p_pea_attribute19                =>  p_pea_attribute19
685       ,p_pea_attribute20                =>  p_pea_attribute20
686       ,p_pea_attribute21                =>  p_pea_attribute21
687       ,p_pea_attribute22                =>  p_pea_attribute22
688       ,p_pea_attribute23                =>  p_pea_attribute23
689       ,p_pea_attribute24                =>  p_pea_attribute24
690       ,p_pea_attribute25                =>  p_pea_attribute25
691       ,p_pea_attribute26                =>  p_pea_attribute26
692       ,p_pea_attribute27                =>  p_pea_attribute27
693       ,p_pea_attribute28                =>  p_pea_attribute28
694       ,p_pea_attribute29                =>  p_pea_attribute29
695       ,p_pea_attribute30                =>  p_pea_attribute30
696       ,p_effective_date                 => trunc(p_effective_date)
697       );
698   exception
699     when hr_api.cannot_find_prog_unit then
700       hr_api.cannot_find_prog_unit_error
701         (
702          p_module_name => 'CREATE_PRTT_ENRT_ACTN'
703         ,p_hook_type   => 'BP'
704         );
705     --
706     -- End of API User Hook for the before hook of create_PRTT_ENRT_ACTN
707     --
708   end;
709   --
710   ben_pea_ins.ins
711     (
712      p_prtt_enrt_actn_id             => l_prtt_enrt_actn_id
713     ,p_effective_start_date          => l_effective_start_date
714     ,p_effective_end_date            => l_effective_end_date
715     ,p_cmpltd_dt                     => p_cmpltd_dt
716     ,p_due_dt                        => p_due_dt
717     ,p_rqd_flag                      => p_rqd_flag
718     ,p_prtt_enrt_rslt_id             => p_prtt_enrt_rslt_id
719     ,p_per_in_ler_id             => l_per_in_ler_id
720     ,p_actn_typ_id                   => p_actn_typ_id
721     ,p_elig_cvrd_dpnt_id             => p_elig_cvrd_dpnt_id
722     ,p_pl_bnf_id                     => p_pl_bnf_id
723     ,p_business_group_id             => p_business_group_id
724     ,p_pea_attribute_category        => p_pea_attribute_category
725     ,p_pea_attribute1                => p_pea_attribute1
726     ,p_pea_attribute2                => p_pea_attribute2
727     ,p_pea_attribute3                => p_pea_attribute3
728     ,p_pea_attribute4                => p_pea_attribute4
729     ,p_pea_attribute5                => p_pea_attribute5
730     ,p_pea_attribute6                => p_pea_attribute6
731     ,p_pea_attribute7                => p_pea_attribute7
732     ,p_pea_attribute8                => p_pea_attribute8
733     ,p_pea_attribute9                => p_pea_attribute9
734     ,p_pea_attribute10               => p_pea_attribute10
735     ,p_pea_attribute11               => p_pea_attribute11
736     ,p_pea_attribute12               => p_pea_attribute12
737     ,p_pea_attribute13               => p_pea_attribute13
738     ,p_pea_attribute14               => p_pea_attribute14
739     ,p_pea_attribute15               => p_pea_attribute15
740     ,p_pea_attribute16               => p_pea_attribute16
741     ,p_pea_attribute17               => p_pea_attribute17
742     ,p_pea_attribute18               => p_pea_attribute18
743     ,p_pea_attribute19               => p_pea_attribute19
744     ,p_pea_attribute20               => p_pea_attribute20
745     ,p_pea_attribute21               => p_pea_attribute21
746     ,p_pea_attribute22               => p_pea_attribute22
747     ,p_pea_attribute23               => p_pea_attribute23
748     ,p_pea_attribute24               => p_pea_attribute24
749     ,p_pea_attribute25               => p_pea_attribute25
750     ,p_pea_attribute26               => p_pea_attribute26
751     ,p_pea_attribute27               => p_pea_attribute27
752     ,p_pea_attribute28               => p_pea_attribute28
753     ,p_pea_attribute29               => p_pea_attribute29
754     ,p_pea_attribute30               => p_pea_attribute30
755     ,p_object_version_number         => l_object_version_number
756     ,p_effective_date                => trunc(p_effective_date)
757     );
758   --
759   begin
760     --
761     -- Start of API User Hook for the after hook of create_PRTT_ENRT_ACTN
762     --
763     ben_PRTT_ENRT_ACTN_bk1.create_PRTT_ENRT_ACTN_a
764       (
765        p_prtt_enrt_actn_id              =>  l_prtt_enrt_actn_id
766       ,p_effective_start_date           =>  l_effective_start_date
767       ,p_effective_end_date             =>  l_effective_end_date
768       ,p_cmpltd_dt                      =>  p_cmpltd_dt
769       ,p_due_dt                         =>  p_due_dt
770       ,p_rqd_flag                       =>  p_rqd_flag
771       ,p_prtt_enrt_rslt_id              =>  p_prtt_enrt_rslt_id
772       ,p_per_in_ler_id              =>  l_per_in_ler_id
773       ,p_actn_typ_id                    =>  p_actn_typ_id
774       ,p_elig_cvrd_dpnt_id              =>  p_elig_cvrd_dpnt_id
775       ,p_pl_bnf_id                      =>  p_pl_bnf_id
776       ,p_business_group_id              =>  p_business_group_id
777       ,p_pea_attribute_category         =>  p_pea_attribute_category
778       ,p_pea_attribute1                 =>  p_pea_attribute1
779       ,p_pea_attribute2                 =>  p_pea_attribute2
780       ,p_pea_attribute3                 =>  p_pea_attribute3
781       ,p_pea_attribute4                 =>  p_pea_attribute4
782       ,p_pea_attribute5                 =>  p_pea_attribute5
783       ,p_pea_attribute6                 =>  p_pea_attribute6
784       ,p_pea_attribute7                 =>  p_pea_attribute7
785       ,p_pea_attribute8                 =>  p_pea_attribute8
786       ,p_pea_attribute9                 =>  p_pea_attribute9
787       ,p_pea_attribute10                =>  p_pea_attribute10
788       ,p_pea_attribute11                =>  p_pea_attribute11
789       ,p_pea_attribute12                =>  p_pea_attribute12
790       ,p_pea_attribute13                =>  p_pea_attribute13
791       ,p_pea_attribute14                =>  p_pea_attribute14
792       ,p_pea_attribute15                =>  p_pea_attribute15
793       ,p_pea_attribute16                =>  p_pea_attribute16
794       ,p_pea_attribute17                =>  p_pea_attribute17
795       ,p_pea_attribute18                =>  p_pea_attribute18
796       ,p_pea_attribute19                =>  p_pea_attribute19
797       ,p_pea_attribute20                =>  p_pea_attribute20
798       ,p_pea_attribute21                =>  p_pea_attribute21
799       ,p_pea_attribute22                =>  p_pea_attribute22
800       ,p_pea_attribute23                =>  p_pea_attribute23
801       ,p_pea_attribute24                =>  p_pea_attribute24
802       ,p_pea_attribute25                =>  p_pea_attribute25
803       ,p_pea_attribute26                =>  p_pea_attribute26
804       ,p_pea_attribute27                =>  p_pea_attribute27
805       ,p_pea_attribute28                =>  p_pea_attribute28
806       ,p_pea_attribute29                =>  p_pea_attribute29
807       ,p_pea_attribute30                =>  p_pea_attribute30
808       ,p_object_version_number          =>  l_object_version_number
809       ,p_effective_date                 => trunc(p_effective_date)
810       );
811   exception
812     when hr_api.cannot_find_prog_unit then
813       hr_api.cannot_find_prog_unit_error
814         (p_module_name => 'CREATE_PRTT_ENRT_ACTN'
815         ,p_hook_type   => 'AP'
816         );
817     --
818     -- End of API User Hook for the after hook of create_PRTT_ENRT_ACTN
819     --
820   end;
821   --
822   hr_utility.set_location(l_proc, 60);
823   --
824   p_prtt_enrt_actn_id := l_prtt_enrt_actn_id;
825   p_effective_start_date := l_effective_start_date;
826   p_effective_end_date := l_effective_end_date;
827   p_object_version_number := l_object_version_number;
828   --
829   -- if action item is required, suspend the enrollment
830   -- if setting cmpltd_dt to NULL try to unsuspend if
831   -- cmpltd_dt is getting a value
832   --
833   if p_rqd_flag = 'Y' then
834     if p_cmpltd_dt is NULL then
835       suspend_rslt
836         (p_prtt_enrt_rslt_id          => p_prtt_enrt_rslt_id
837         ,p_post_rslt_flag             => p_post_rslt_flag
838         ,p_effective_date             => p_effective_date
839         ,p_business_group_id          => p_business_group_id
840         ,p_rslt_object_version_number => p_rslt_object_version_number
841         ,p_validate                   => p_validate
842         ,p_datetrack_mode             => hr_api.g_correction);
843       --
844     else
845       --
846       unsuspend_rslt
847         (p_prtt_enrt_rslt_id          => p_prtt_enrt_rslt_id
848         ,p_post_rslt_flag             => p_post_rslt_flag
849         ,p_effective_date             => p_effective_date
850         ,p_business_group_id          => p_business_group_id
851         ,p_rslt_object_version_number => p_rslt_object_version_number
852         ,p_validate                   => p_validate
853         ,p_datetrack_mode             => hr_api.g_correction
854         ,p_cmpltd_dt                  => p_cmpltd_dt);
855     --
856     end if;
857   end if;
858   --
859   if p_gnrt_cm then
860     --
861     --  Generate Communications
862     --
863     ben_generate_communications.main
864       (p_person_id             => l_person_id
865       ,p_ler_id                => l_ler_id
866       -- CWB Changes.
867       ,p_per_in_ler_id         => l_per_in_ler_id
868       ,p_prtt_enrt_actn_id     => l_prtt_enrt_actn_id
869       ,p_pgm_id                => l_pgm_id
870       ,p_pl_id                 => l_pl_id
871       ,p_pl_typ_id             => l_pl_typ_id
872       ,p_actn_typ_id           => p_actn_typ_id
873       ,p_business_group_id     => p_business_group_id
874       ,p_proc_cd1              => 'ACTNCREATED'
875       ,p_effective_date        => p_effective_date);
876   end if;
877   --
878   -- When in validation only mode raise the Validate_Enabled exception
879   --
880   if p_validate then
881     raise hr_api.validate_enabled;
882   end if;
883   --
884   -- Set all output arguments
885   --
886   hr_utility.set_location(' Leaving:'||l_proc, 70);
887   --
888 exception
889   --
890   when hr_api.validate_enabled
891   then
892     --
893     -- As the Validate_Enabled exception has been raised
894     -- we must rollback to the savepoint
895     --
896     ROLLBACK TO create_PRTT_ENRT_ACTN;
897     --
898     -- Only set output warning arguments
899     -- (Any key or derived arguments must be set to null
900     -- when validation only mode is being used.)
901     --
902     p_prtt_enrt_actn_id := null;
903     p_effective_start_date := null;
904     p_effective_end_date := null;
905     p_object_version_number  := null;
906     hr_utility.set_location(' Leaving:'||l_proc, 80);
907     --
908   when others then
909     --
910     -- A validation or unexpected error has occured
911     --
912     ROLLBACK TO create_PRTT_ENRT_ACTN;
913     raise;
914     --
915 end create_PRTT_ENRT_ACTN;
916 --
917 -- ----------------------------------------------------------------------------
918 -- |--------------------------< update_PRTT_ENRT_ACTN >-----------------------|
919 -- ----------------------------------------------------------------------------
920 --
921 --
922 -- THIS PROCEDURE WAS DUPLICATED.  ONE HAS PER-IN-LER-ID THE OTHER DOESN'T.
923 -- CHANGE BOTH PROCEDURES IF MAKING A CHANGE.
924 --
925 procedure update_PRTT_ENRT_ACTN
926   (p_validate                       in  boolean   default false
927   ,p_post_rslt_flag                 in  varchar2  default 'N'
928   ,p_prtt_enrt_actn_id              in  number
929   ,p_effective_start_date           out nocopy date
930   ,p_effective_end_date             out nocopy date
931   ,p_cmpltd_dt                      in  date      default hr_api.g_date
932   ,p_due_dt                         in  date      default hr_api.g_date
933   ,p_rqd_flag                       in  varchar2  default hr_api.g_varchar2
934   ,p_prtt_enrt_rslt_id              in  number    default hr_api.g_number
935   ,p_per_in_ler_id                  in  number
936   ,p_rslt_object_version_number     in out nocopy number
937   ,p_actn_typ_id                    in  number    default hr_api.g_number
938   ,p_elig_cvrd_dpnt_id              in  number    default hr_api.g_number
939   ,p_pl_bnf_id                      in  number    default hr_api.g_number
940   ,p_business_group_id              in  number    default hr_api.g_number
941   ,p_pea_attribute_category         in  varchar2  default hr_api.g_varchar2
942   ,p_pea_attribute1                 in  varchar2  default hr_api.g_varchar2
943   ,p_pea_attribute2                 in  varchar2  default hr_api.g_varchar2
944   ,p_pea_attribute3                 in  varchar2  default hr_api.g_varchar2
945   ,p_pea_attribute4                 in  varchar2  default hr_api.g_varchar2
946   ,p_pea_attribute5                 in  varchar2  default hr_api.g_varchar2
947   ,p_pea_attribute6                 in  varchar2  default hr_api.g_varchar2
948   ,p_pea_attribute7                 in  varchar2  default hr_api.g_varchar2
949   ,p_pea_attribute8                 in  varchar2  default hr_api.g_varchar2
950   ,p_pea_attribute9                 in  varchar2  default hr_api.g_varchar2
951   ,p_pea_attribute10                in  varchar2  default hr_api.g_varchar2
952   ,p_pea_attribute11                in  varchar2  default hr_api.g_varchar2
953   ,p_pea_attribute12                in  varchar2  default hr_api.g_varchar2
954   ,p_pea_attribute13                in  varchar2  default hr_api.g_varchar2
955   ,p_pea_attribute14                in  varchar2  default hr_api.g_varchar2
956   ,p_pea_attribute15                in  varchar2  default hr_api.g_varchar2
957   ,p_pea_attribute16                in  varchar2  default hr_api.g_varchar2
958   ,p_pea_attribute17                in  varchar2  default hr_api.g_varchar2
959   ,p_pea_attribute18                in  varchar2  default hr_api.g_varchar2
960   ,p_pea_attribute19                in  varchar2  default hr_api.g_varchar2
961   ,p_pea_attribute20                in  varchar2  default hr_api.g_varchar2
962   ,p_pea_attribute21                in  varchar2  default hr_api.g_varchar2
963   ,p_pea_attribute22                in  varchar2  default hr_api.g_varchar2
964   ,p_pea_attribute23                in  varchar2  default hr_api.g_varchar2
965   ,p_pea_attribute24                in  varchar2  default hr_api.g_varchar2
966   ,p_pea_attribute25                in  varchar2  default hr_api.g_varchar2
967   ,p_pea_attribute26                in  varchar2  default hr_api.g_varchar2
968   ,p_pea_attribute27                in  varchar2  default hr_api.g_varchar2
969   ,p_pea_attribute28                in  varchar2  default hr_api.g_varchar2
970   ,p_pea_attribute29                in  varchar2  default hr_api.g_varchar2
971   ,p_pea_attribute30                in  varchar2  default hr_api.g_varchar2
972   ,p_gnrt_cm                        in  boolean   default true
973   ,p_object_version_number          in out nocopy number
974   ,p_effective_date                 in  date
975   ,p_datetrack_mode                 in  varchar2
976   ) is
977   --
978   -- Declare cursors and local variables
979   --
980   cursor c_pea is
981      select pea.effective_start_date,
982             pea.cmpltd_dt
983      from   ben_prtt_enrt_actn_f pea
984      where  pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
985      and    pea.business_group_id = p_business_group_id
986      and    p_effective_date between
987             pea.effective_start_date and pea.effective_end_date;
988   --
989   l_pea          c_pea%rowtype;
990   --
991   cursor c_pcm is
992      select pcm.per_cm_id,
993             pcm.object_version_number
994      from   ben_per_cm_f pcm
995      where  pcm.prtt_enrt_actn_id = p_prtt_enrt_actn_id
996      and    pcm.business_group_id = p_business_group_id
997      and    p_effective_date between
998             pcm.effective_start_date and pcm.effective_end_date;
999   --
1000   cursor c_prtt_enrt_rslt is
1001     select person_id
1002           ,ler_id
1003           ,pgm_id
1004           ,pl_id
1005           ,pl_typ_id
1006     from ben_prtt_enrt_rslt_f
1007     where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
1008     and   prtt_enrt_rslt_stat_cd is null
1009     and p_effective_date between
1010     effective_start_date and effective_end_date;
1011   --
1012   l_person_id     ben_prtt_enrt_rslt_f.person_id%TYPE;
1013   l_ler_id        ben_prtt_enrt_rslt_f.ler_id%TYPE;
1014   l_pl_id         ben_prtt_enrt_rslt_f.pl_id%TYPE;
1015   l_pl_typ_id     ben_prtt_enrt_rslt_f.pl_typ_id%TYPE;
1016   l_pgm_id        ben_prtt_enrt_rslt_f.pgm_id%TYPE;
1017   --
1018   l_proc varchar2(72) := g_package||'update_PRTT_ENRT_ACTN';
1019   l_object_version_number ben_prtt_enrt_actn_f.object_version_number%TYPE;
1020   l_effective_start_date ben_prtt_enrt_actn_f.effective_start_date%TYPE;
1021   l_effective_end_date ben_prtt_enrt_actn_f.effective_end_date%TYPE;
1022   l_pcm_effective_start_date date;
1023   l_pcm_effective_end_date   date;
1024   --
1025 begin
1026   --
1027   hr_utility.set_location('Entering:'|| l_proc, 10);
1028   --
1029   -- Issue a savepoint if operating in validation only mode
1030   --
1031   savepoint update_PRTT_ENRT_ACTN;
1032   --
1033   hr_utility.set_location(l_proc, 20);
1034   --
1035   -- Get the completed date and effective start date before the update.
1036   --
1037   open  c_pea;
1038   fetch c_pea into l_pea;
1039   close c_pea;
1040   --
1041   -- Process Logic
1042   --
1043   l_object_version_number := p_object_version_number;
1044   --
1045   begin
1046     --
1047     -- Start of API User Hook for the before hook of update_PRTT_ENRT_ACTN
1048     --
1049     ben_PRTT_ENRT_ACTN_bk2.update_PRTT_ENRT_ACTN_b
1050       (
1051        p_prtt_enrt_actn_id              =>  p_prtt_enrt_actn_id
1052       ,p_cmpltd_dt                      =>  p_cmpltd_dt
1053       ,p_due_dt                         =>  p_due_dt
1054       ,p_rqd_flag                       =>  p_rqd_flag
1055       ,p_prtt_enrt_rslt_id              =>  p_prtt_enrt_rslt_id
1056       ,p_per_in_ler_id                  =>  p_per_in_ler_id
1057       ,p_actn_typ_id                    =>  p_actn_typ_id
1058       ,p_elig_cvrd_dpnt_id              =>  p_elig_cvrd_dpnt_id
1059       ,p_pl_bnf_id                      =>  p_pl_bnf_id
1060       ,p_business_group_id              =>  p_business_group_id
1061       ,p_pea_attribute_category         =>  p_pea_attribute_category
1062       ,p_pea_attribute1                 =>  p_pea_attribute1
1063       ,p_pea_attribute2                 =>  p_pea_attribute2
1064       ,p_pea_attribute3                 =>  p_pea_attribute3
1065       ,p_pea_attribute4                 =>  p_pea_attribute4
1066       ,p_pea_attribute5                 =>  p_pea_attribute5
1067       ,p_pea_attribute6                 =>  p_pea_attribute6
1068       ,p_pea_attribute7                 =>  p_pea_attribute7
1069       ,p_pea_attribute8                 =>  p_pea_attribute8
1070       ,p_pea_attribute9                 =>  p_pea_attribute9
1071       ,p_pea_attribute10                =>  p_pea_attribute10
1072       ,p_pea_attribute11                =>  p_pea_attribute11
1073       ,p_pea_attribute12                =>  p_pea_attribute12
1074       ,p_pea_attribute13                =>  p_pea_attribute13
1075       ,p_pea_attribute14                =>  p_pea_attribute14
1076       ,p_pea_attribute15                =>  p_pea_attribute15
1077       ,p_pea_attribute16                =>  p_pea_attribute16
1078       ,p_pea_attribute17                =>  p_pea_attribute17
1079       ,p_pea_attribute18                =>  p_pea_attribute18
1080       ,p_pea_attribute19                =>  p_pea_attribute19
1081       ,p_pea_attribute20                =>  p_pea_attribute20
1082       ,p_pea_attribute21                =>  p_pea_attribute21
1083       ,p_pea_attribute22                =>  p_pea_attribute22
1084       ,p_pea_attribute23                =>  p_pea_attribute23
1085       ,p_pea_attribute24                =>  p_pea_attribute24
1086       ,p_pea_attribute25                =>  p_pea_attribute25
1087       ,p_pea_attribute26                =>  p_pea_attribute26
1088       ,p_pea_attribute27                =>  p_pea_attribute27
1089       ,p_pea_attribute28                =>  p_pea_attribute28
1090       ,p_pea_attribute29                =>  p_pea_attribute29
1091       ,p_pea_attribute30                =>  p_pea_attribute30
1092       ,p_object_version_number          =>  p_object_version_number
1093     ,p_effective_date                      => trunc(p_effective_date)
1094     ,p_datetrack_mode                      => p_datetrack_mode
1095       );
1096   exception
1097     when hr_api.cannot_find_prog_unit then
1098       hr_api.cannot_find_prog_unit_error
1099         (p_module_name => 'UPDATE_PRTT_ENRT_ACTN'
1100         ,p_hook_type   => 'BP'
1101         );
1102     --
1103     -- End of API User Hook for the before hook of update_PRTT_ENRT_ACTN
1104     --
1105   end;
1106   --
1107   ben_pea_upd.upd
1108     (
1109      p_prtt_enrt_actn_id             => p_prtt_enrt_actn_id
1110     ,p_effective_start_date          => l_effective_start_date
1111     ,p_effective_end_date            => l_effective_end_date
1112     ,p_cmpltd_dt                     => p_cmpltd_dt
1113     ,p_due_dt                        => p_due_dt
1114     ,p_rqd_flag                      => p_rqd_flag
1115     ,p_prtt_enrt_rslt_id             => p_prtt_enrt_rslt_id
1116     ,p_per_in_ler_id                 => p_per_in_ler_id
1117     ,p_actn_typ_id                   => p_actn_typ_id
1118     ,p_elig_cvrd_dpnt_id             => p_elig_cvrd_dpnt_id
1119     ,p_pl_bnf_id                     => p_pl_bnf_id
1120     ,p_business_group_id             => p_business_group_id
1121     ,p_pea_attribute_category        => p_pea_attribute_category
1122     ,p_pea_attribute1                => p_pea_attribute1
1123     ,p_pea_attribute2                => p_pea_attribute2
1124     ,p_pea_attribute3                => p_pea_attribute3
1125     ,p_pea_attribute4                => p_pea_attribute4
1126     ,p_pea_attribute5                => p_pea_attribute5
1127     ,p_pea_attribute6                => p_pea_attribute6
1128     ,p_pea_attribute7                => p_pea_attribute7
1129     ,p_pea_attribute8                => p_pea_attribute8
1130     ,p_pea_attribute9                => p_pea_attribute9
1131     ,p_pea_attribute10               => p_pea_attribute10
1132     ,p_pea_attribute11               => p_pea_attribute11
1133     ,p_pea_attribute12               => p_pea_attribute12
1134     ,p_pea_attribute13               => p_pea_attribute13
1135     ,p_pea_attribute14               => p_pea_attribute14
1136     ,p_pea_attribute15               => p_pea_attribute15
1137     ,p_pea_attribute16               => p_pea_attribute16
1138     ,p_pea_attribute17               => p_pea_attribute17
1139     ,p_pea_attribute18               => p_pea_attribute18
1140     ,p_pea_attribute19               => p_pea_attribute19
1141     ,p_pea_attribute20               => p_pea_attribute20
1142     ,p_pea_attribute21               => p_pea_attribute21
1143     ,p_pea_attribute22               => p_pea_attribute22
1144     ,p_pea_attribute23               => p_pea_attribute23
1145     ,p_pea_attribute24               => p_pea_attribute24
1146     ,p_pea_attribute25               => p_pea_attribute25
1147     ,p_pea_attribute26               => p_pea_attribute26
1148     ,p_pea_attribute27               => p_pea_attribute27
1149     ,p_pea_attribute28               => p_pea_attribute28
1150     ,p_pea_attribute29               => p_pea_attribute29
1151     ,p_pea_attribute30               => p_pea_attribute30
1152     ,p_object_version_number         => l_object_version_number
1153     ,p_effective_date                => trunc(p_effective_date)
1154     ,p_datetrack_mode                => p_datetrack_mode
1155     );
1156   --
1157   begin
1158     --
1159     -- Start of API User Hook for the after hook of update_PRTT_ENRT_ACTN
1160     --
1161     ben_PRTT_ENRT_ACTN_bk2.update_PRTT_ENRT_ACTN_a
1162       (
1163        p_prtt_enrt_actn_id              =>  p_prtt_enrt_actn_id
1164       ,p_effective_start_date           =>  l_effective_start_date
1165       ,p_effective_end_date             =>  l_effective_end_date
1166       ,p_cmpltd_dt                      =>  p_cmpltd_dt
1167       ,p_due_dt                         =>  p_due_dt
1168       ,p_rqd_flag                       =>  p_rqd_flag
1169       ,p_prtt_enrt_rslt_id              =>  p_prtt_enrt_rslt_id
1170       ,p_per_in_ler_id                  =>  p_per_in_ler_id
1171       ,p_actn_typ_id                    =>  p_actn_typ_id
1172       ,p_elig_cvrd_dpnt_id              =>  p_elig_cvrd_dpnt_id
1173       ,p_pl_bnf_id                      =>  p_pl_bnf_id
1174       ,p_business_group_id              =>  p_business_group_id
1175       ,p_pea_attribute_category         =>  p_pea_attribute_category
1176       ,p_pea_attribute1                 =>  p_pea_attribute1
1177       ,p_pea_attribute2                 =>  p_pea_attribute2
1178       ,p_pea_attribute3                 =>  p_pea_attribute3
1179       ,p_pea_attribute4                 =>  p_pea_attribute4
1180       ,p_pea_attribute5                 =>  p_pea_attribute5
1181       ,p_pea_attribute6                 =>  p_pea_attribute6
1182       ,p_pea_attribute7                 =>  p_pea_attribute7
1183       ,p_pea_attribute8                 =>  p_pea_attribute8
1184       ,p_pea_attribute9                 =>  p_pea_attribute9
1185       ,p_pea_attribute10                =>  p_pea_attribute10
1186       ,p_pea_attribute11                =>  p_pea_attribute11
1187       ,p_pea_attribute12                =>  p_pea_attribute12
1188       ,p_pea_attribute13                =>  p_pea_attribute13
1189       ,p_pea_attribute14                =>  p_pea_attribute14
1190       ,p_pea_attribute15                =>  p_pea_attribute15
1191       ,p_pea_attribute16                =>  p_pea_attribute16
1192       ,p_pea_attribute17                =>  p_pea_attribute17
1193       ,p_pea_attribute18                =>  p_pea_attribute18
1194       ,p_pea_attribute19                =>  p_pea_attribute19
1195       ,p_pea_attribute20                =>  p_pea_attribute20
1196       ,p_pea_attribute21                =>  p_pea_attribute21
1197       ,p_pea_attribute22                =>  p_pea_attribute22
1198       ,p_pea_attribute23                =>  p_pea_attribute23
1199       ,p_pea_attribute24                =>  p_pea_attribute24
1200       ,p_pea_attribute25                =>  p_pea_attribute25
1201       ,p_pea_attribute26                =>  p_pea_attribute26
1202       ,p_pea_attribute27                =>  p_pea_attribute27
1203       ,p_pea_attribute28                =>  p_pea_attribute28
1204       ,p_pea_attribute29                =>  p_pea_attribute29
1205       ,p_pea_attribute30                =>  p_pea_attribute30
1206       ,p_object_version_number          =>  l_object_version_number
1207       ,p_effective_date                     => trunc(p_effective_date)
1208       ,p_datetrack_mode                     => p_datetrack_mode
1209       );
1210   exception
1211     when hr_api.cannot_find_prog_unit then
1212       hr_api.cannot_find_prog_unit_error
1213         (p_module_name => 'UPDATE_PRTT_ENRT_ACTN'
1214         ,p_hook_type   => 'AP'
1215         );
1216     --
1217     -- End of API User Hook for the after hook of update_PRTT_ENRT_ACTN
1218     --
1219   end;
1220   --
1221   hr_utility.set_location(l_proc, 60);
1222   --
1223   -- Set all output arguments
1224   --
1225   p_object_version_number := l_object_version_number;
1226   p_effective_start_date := l_effective_start_date;
1227   p_effective_end_date := l_effective_end_date;
1228   --
1229   -- suspend the enrollment if setting cmpltd_dt to NULL
1230   -- do not suspend if cmpltd_dt is getting a value
1231   -- instead if cmpltd_dt not null check if all others are also
1232   -- completed and if allcmpltd_dt for this participant are not null
1233   -- then unsuspend the enrollment
1234   --
1235   if p_rqd_flag = 'Y' then
1236     if p_cmpltd_dt is NULL then
1237     --
1238       suspend_rslt
1239         (p_prtt_enrt_rslt_id          => p_prtt_enrt_rslt_id
1240         ,p_post_rslt_flag             => p_post_rslt_flag
1241         ,p_effective_date             => p_effective_date
1242         ,p_business_group_id          => p_business_group_id
1243         ,p_rslt_object_version_number => p_rslt_object_version_number
1244         ,p_validate                   => p_validate
1245         ,p_datetrack_mode             => p_datetrack_mode);
1246     --
1247     else
1248     --
1249       unsuspend_rslt
1250         (p_prtt_enrt_rslt_id          => p_prtt_enrt_rslt_id
1251         ,p_post_rslt_flag             => p_post_rslt_flag
1252         ,p_effective_date             => p_effective_date
1253         ,p_business_group_id          => p_business_group_id
1254         ,p_rslt_object_version_number => p_rslt_object_version_number
1255         ,p_validate                   => p_validate
1256         ,p_datetrack_mode             => p_datetrack_mode
1257         ,p_cmpltd_dt                  => p_cmpltd_dt );
1258     --
1259     end if;
1260    end if;
1261   --
1262   if p_gnrt_cm then
1263     if p_cmpltd_dt is not null then
1264       --
1265       if l_pea.cmpltd_dt is null and
1266          l_pea.effective_start_date = p_effective_date then
1267          --
1268          -- Action Item completed and started on the same day.
1269          --
1270          -- Delete communications for the action item as the action item just
1271          -- started and ended. The communications got generated due to the
1272          -- way we handle action items.
1273          --
1274          for l_pcm in c_pcm loop
1275             --
1276             ben_per_cm_api.delete_per_cm
1277                  (p_per_cm_id             => l_pcm.per_cm_id,
1278                   p_effective_start_date  => l_pcm_effective_start_date,
1279                   p_effective_end_date    => l_pcm_effective_end_date,
1280                   p_object_version_number => l_pcm.object_version_number,
1281                   p_effective_date        => p_effective_date,
1282                   p_datetrack_mode        => hr_api.g_zap);
1283             --
1284          end loop;
1285          --
1286       else
1287          --
1288          open c_prtt_enrt_rslt;
1289          fetch c_prtt_enrt_rslt into l_person_id
1290                                     ,l_ler_id
1291                                     ,l_pgm_id
1292                                     ,l_pl_id
1293                                     ,l_pl_typ_id;
1294          if c_prtt_enrt_rslt%notfound then
1295            close c_prtt_enrt_rslt;
1296            fnd_message.set_name('BEN','BEN_91916_ENRT_TABLE_NOT_FOUND');
1297            fnd_message.set_token('TABLE','BEN_PRTT_ENRT_RSLT_F');
1298            fnd_message.raise_error;
1299          end if;
1300          close c_prtt_enrt_rslt;
1301          --
1302          --  Generate Communications
1303          --
1304          ben_generate_communications.main
1305            (p_person_id             => l_person_id
1306            ,p_ler_id                => l_ler_id
1307            -- CWB Changes
1308            ,p_per_in_ler_id         => p_per_in_ler_id
1309            ,p_prtt_enrt_actn_id     => p_prtt_enrt_actn_id
1310            ,p_pgm_id                => l_pgm_id
1311            ,p_pl_id                 => l_pl_id
1312            ,p_pl_typ_id             => l_pl_typ_id
1313            ,p_actn_typ_id           => p_actn_typ_id
1314            ,p_business_group_id     => p_business_group_id
1315            ,p_proc_cd1              => 'ACTNCMPL'
1316            ,p_effective_date        => p_effective_date);
1317          --
1318       end if;
1319       --
1320     end if;
1321     --
1322   end if;
1323   --
1324   -- When in validation only mode raise the Validate_Enabled exception
1325   --
1326   if p_validate then
1327     raise hr_api.validate_enabled;
1328   end if;
1329   --
1330   hr_utility.set_location(' Leaving:'||l_proc, 70);
1331   --
1332 exception
1333   --
1334   when hr_api.validate_enabled then
1335     --
1336     -- As the Validate_Enabled exception has been raised
1337     -- we must rollback to the savepoint
1338     --
1339     ROLLBACK TO update_PRTT_ENRT_ACTN;
1340     --
1341     -- Only set output warning arguments
1342     -- (Any key or derived arguments must be set to null
1343     -- when validation only mode is being used.)
1344     --
1345     p_effective_start_date := null;
1346     p_effective_end_date := null;
1347     hr_utility.set_location(' Leaving:'||l_proc, 80);
1348     --
1349   when others then
1350     --
1351     -- A validation or unexpected error has occured
1352     --
1353     ROLLBACK TO update_PRTT_ENRT_ACTN;
1354     p_object_version_number := l_object_version_number;
1355     p_effective_start_date := null;
1356     p_effective_end_date := null;
1357 
1358     raise;
1359     --
1360 end update_PRTT_ENRT_ACTN;
1361 --
1362 -- ----------------------------------------------------------------------------
1363 -- |--------------------------< update_PRTT_ENRT_ACTN >-----------------------|
1364 -- ----------------------------------------------------------------------------
1365 --
1366 --
1367 -- THIS PROCEDURE WAS DUPLICATED.  ONE HAS PER-IN-LER-ID THE OTHER DOESN'T.
1368 -- CHANGE BOTH PROCEDURES IF MAKING A CHANGE.
1369 --
1370 procedure update_PRTT_ENRT_ACTN
1371   (p_validate                       in  boolean   default false
1372   ,p_post_rslt_flag                 in  varchar2  default 'N'
1373   ,p_prtt_enrt_actn_id              in  number
1374   ,p_effective_start_date           out nocopy date
1375   ,p_effective_end_date             out nocopy date
1376   ,p_cmpltd_dt                      in  date      default hr_api.g_date
1377   ,p_due_dt                         in  date      default hr_api.g_date
1378   ,p_rqd_flag                       in  varchar2  default hr_api.g_varchar2
1379   ,p_prtt_enrt_rslt_id              in  number    default hr_api.g_number
1380   ,p_rslt_object_version_number     in out nocopy number
1381   ,p_actn_typ_id                    in  number    default hr_api.g_number
1382   ,p_elig_cvrd_dpnt_id              in  number    default hr_api.g_number
1383   ,p_pl_bnf_id                      in  number    default hr_api.g_number
1384   ,p_business_group_id              in  number    default hr_api.g_number
1385   ,p_pea_attribute_category         in  varchar2  default hr_api.g_varchar2
1386   ,p_pea_attribute1                 in  varchar2  default hr_api.g_varchar2
1387   ,p_pea_attribute2                 in  varchar2  default hr_api.g_varchar2
1388   ,p_pea_attribute3                 in  varchar2  default hr_api.g_varchar2
1389   ,p_pea_attribute4                 in  varchar2  default hr_api.g_varchar2
1390   ,p_pea_attribute5                 in  varchar2  default hr_api.g_varchar2
1391   ,p_pea_attribute6                 in  varchar2  default hr_api.g_varchar2
1392   ,p_pea_attribute7                 in  varchar2  default hr_api.g_varchar2
1393   ,p_pea_attribute8                 in  varchar2  default hr_api.g_varchar2
1394   ,p_pea_attribute9                 in  varchar2  default hr_api.g_varchar2
1395   ,p_pea_attribute10                in  varchar2  default hr_api.g_varchar2
1396   ,p_pea_attribute11                in  varchar2  default hr_api.g_varchar2
1397   ,p_pea_attribute12                in  varchar2  default hr_api.g_varchar2
1398   ,p_pea_attribute13                in  varchar2  default hr_api.g_varchar2
1399   ,p_pea_attribute14                in  varchar2  default hr_api.g_varchar2
1400   ,p_pea_attribute15                in  varchar2  default hr_api.g_varchar2
1401   ,p_pea_attribute16                in  varchar2  default hr_api.g_varchar2
1402   ,p_pea_attribute17                in  varchar2  default hr_api.g_varchar2
1403   ,p_pea_attribute18                in  varchar2  default hr_api.g_varchar2
1404   ,p_pea_attribute19                in  varchar2  default hr_api.g_varchar2
1405   ,p_pea_attribute20                in  varchar2  default hr_api.g_varchar2
1406   ,p_pea_attribute21                in  varchar2  default hr_api.g_varchar2
1407   ,p_pea_attribute22                in  varchar2  default hr_api.g_varchar2
1408   ,p_pea_attribute23                in  varchar2  default hr_api.g_varchar2
1409   ,p_pea_attribute24                in  varchar2  default hr_api.g_varchar2
1410   ,p_pea_attribute25                in  varchar2  default hr_api.g_varchar2
1411   ,p_pea_attribute26                in  varchar2  default hr_api.g_varchar2
1412   ,p_pea_attribute27                in  varchar2  default hr_api.g_varchar2
1413   ,p_pea_attribute28                in  varchar2  default hr_api.g_varchar2
1414   ,p_pea_attribute29                in  varchar2  default hr_api.g_varchar2
1415   ,p_pea_attribute30                in  varchar2  default hr_api.g_varchar2
1416   ,p_gnrt_cm                        in  boolean   default true
1417   ,p_object_version_number          in out nocopy number
1418   ,p_effective_date                 in  date
1419   ,p_datetrack_mode                 in  varchar2
1420   ) is
1421   --
1422   -- Declare cursors and local variables
1423   --
1424   cursor c_pea is
1425      select pea.effective_start_date,
1426             pea.cmpltd_dt
1427      from   ben_prtt_enrt_actn_f pea
1428      where  pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1429      and    pea.business_group_id = p_business_group_id
1430      and    p_effective_date between
1431             pea.effective_start_date and pea.effective_end_date;
1432   --
1433   l_pea          c_pea%rowtype;
1434   --
1435   cursor c_pcm is
1436      select pcm.per_cm_id,
1437             pcm.object_version_number
1438      from   ben_per_cm_f pcm
1439      where  pcm.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1440      and    pcm.business_group_id = p_business_group_id
1441      and    p_effective_date between
1442             pcm.effective_start_date and pcm.effective_end_date;
1443   --
1444   cursor c_prtt_enrt_rslt is
1445     select person_id
1446           ,ler_id
1447           ,pgm_id
1448           ,pl_id
1449           ,pl_typ_id
1450           ,per_in_ler_id
1451     from ben_prtt_enrt_rslt_f
1452     where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
1453     and   prtt_enrt_rslt_stat_cd is null
1454     and p_effective_date between
1455     effective_start_date and effective_end_date;
1456   --
1457   l_person_id     ben_prtt_enrt_rslt_f.person_id%TYPE;
1458   l_ler_id        ben_prtt_enrt_rslt_f.ler_id%TYPE;
1459   l_pl_id         ben_prtt_enrt_rslt_f.pl_id%TYPE;
1460   l_pl_typ_id     ben_prtt_enrt_rslt_f.pl_typ_id%TYPE;
1461   l_pgm_id        ben_prtt_enrt_rslt_f.pgm_id%TYPE;
1462   l_per_in_ler_id ben_prtt_enrt_rslt_f.per_in_ler_id%TYPE;
1463   --
1464   l_proc varchar2(72) := g_package||'update_PRTT_ENRT_ACTN';
1465   l_object_version_number ben_prtt_enrt_actn_f.object_version_number%TYPE;
1466   l_effective_start_date ben_prtt_enrt_actn_f.effective_start_date%TYPE;
1467   l_effective_end_date ben_prtt_enrt_actn_f.effective_end_date%TYPE;
1468   l_pcm_effective_start_date date;
1469   l_pcm_effective_end_date   date;
1470   --
1471 begin
1472   --
1473   hr_utility.set_location('Entering:'|| l_proc, 10);
1474   --
1475   -- Issue a savepoint if operating in validation only mode
1476   --
1477   savepoint update_PRTT_ENRT_ACTN;
1478   --
1479   hr_utility.set_location(l_proc, 20);
1480   --
1481   -- Get the completed date and effective start date before the update.
1482   --
1483   open  c_pea;
1484   fetch c_pea into l_pea;
1485   close c_pea;
1486   --
1487   -- Process Logic
1488   --
1489   l_object_version_number := p_object_version_number;
1490   --
1491   begin
1492     open c_prtt_enrt_rslt;
1493     fetch c_prtt_enrt_rslt into l_person_id
1494                                ,l_ler_id
1495                                ,l_pgm_id
1496                                ,l_pl_id
1497                                ,l_pl_typ_id
1498                                ,l_per_in_ler_id;
1499     if c_prtt_enrt_rslt%notfound then
1500       close c_prtt_enrt_rslt;
1501       fnd_message.set_name('BEN','BEN_91916_ENRT_TABLE_NOT_FOUND');
1502       fnd_message.set_token('TABLE','BEN_PRTT_ENRT_RSLT_F');
1503       fnd_message.raise_error;
1504     end if;
1505     close c_prtt_enrt_rslt;
1506     --
1507     -- Start of API User Hook for the before hook of update_PRTT_ENRT_ACTN
1508     --
1509     ben_PRTT_ENRT_ACTN_bk2.update_PRTT_ENRT_ACTN_b
1510       (
1511        p_prtt_enrt_actn_id              =>  p_prtt_enrt_actn_id
1512       ,p_cmpltd_dt                      =>  p_cmpltd_dt
1513       ,p_due_dt                         =>  p_due_dt
1514       ,p_rqd_flag                       =>  p_rqd_flag
1515       ,p_prtt_enrt_rslt_id              =>  p_prtt_enrt_rslt_id
1516       ,p_per_in_ler_id              =>  l_per_in_ler_id
1517       ,p_actn_typ_id                    =>  p_actn_typ_id
1518       ,p_elig_cvrd_dpnt_id              =>  p_elig_cvrd_dpnt_id
1519       ,p_pl_bnf_id                      =>  p_pl_bnf_id
1520       ,p_business_group_id              =>  p_business_group_id
1521       ,p_pea_attribute_category         =>  p_pea_attribute_category
1522       ,p_pea_attribute1                 =>  p_pea_attribute1
1523       ,p_pea_attribute2                 =>  p_pea_attribute2
1524       ,p_pea_attribute3                 =>  p_pea_attribute3
1525       ,p_pea_attribute4                 =>  p_pea_attribute4
1526       ,p_pea_attribute5                 =>  p_pea_attribute5
1527       ,p_pea_attribute6                 =>  p_pea_attribute6
1528       ,p_pea_attribute7                 =>  p_pea_attribute7
1529       ,p_pea_attribute8                 =>  p_pea_attribute8
1530       ,p_pea_attribute9                 =>  p_pea_attribute9
1531       ,p_pea_attribute10                =>  p_pea_attribute10
1532       ,p_pea_attribute11                =>  p_pea_attribute11
1533       ,p_pea_attribute12                =>  p_pea_attribute12
1534       ,p_pea_attribute13                =>  p_pea_attribute13
1535       ,p_pea_attribute14                =>  p_pea_attribute14
1536       ,p_pea_attribute15                =>  p_pea_attribute15
1537       ,p_pea_attribute16                =>  p_pea_attribute16
1538       ,p_pea_attribute17                =>  p_pea_attribute17
1539       ,p_pea_attribute18                =>  p_pea_attribute18
1540       ,p_pea_attribute19                =>  p_pea_attribute19
1541       ,p_pea_attribute20                =>  p_pea_attribute20
1542       ,p_pea_attribute21                =>  p_pea_attribute21
1543       ,p_pea_attribute22                =>  p_pea_attribute22
1544       ,p_pea_attribute23                =>  p_pea_attribute23
1545       ,p_pea_attribute24                =>  p_pea_attribute24
1546       ,p_pea_attribute25                =>  p_pea_attribute25
1547       ,p_pea_attribute26                =>  p_pea_attribute26
1548       ,p_pea_attribute27                =>  p_pea_attribute27
1549       ,p_pea_attribute28                =>  p_pea_attribute28
1550       ,p_pea_attribute29                =>  p_pea_attribute29
1551       ,p_pea_attribute30                =>  p_pea_attribute30
1552       ,p_object_version_number          =>  p_object_version_number
1553     ,p_effective_date                      => trunc(p_effective_date)
1554     ,p_datetrack_mode                      => p_datetrack_mode
1555       );
1556   exception
1557     when hr_api.cannot_find_prog_unit then
1558       hr_api.cannot_find_prog_unit_error
1559         (p_module_name => 'UPDATE_PRTT_ENRT_ACTN'
1560         ,p_hook_type   => 'BP'
1561         );
1562     --
1563     -- End of API User Hook for the before hook of update_PRTT_ENRT_ACTN
1564     --
1565   end;
1566   --
1567   ben_pea_upd.upd
1568     (
1569      p_prtt_enrt_actn_id             => p_prtt_enrt_actn_id
1570     ,p_effective_start_date          => l_effective_start_date
1571     ,p_effective_end_date            => l_effective_end_date
1572     ,p_cmpltd_dt                     => p_cmpltd_dt
1573     ,p_due_dt                        => p_due_dt
1574     ,p_rqd_flag                      => p_rqd_flag
1575     ,p_prtt_enrt_rslt_id             => p_prtt_enrt_rslt_id
1576     ,p_per_in_ler_id             => l_per_in_ler_id
1577     ,p_actn_typ_id                   => p_actn_typ_id
1578     ,p_elig_cvrd_dpnt_id             => p_elig_cvrd_dpnt_id
1579     ,p_pl_bnf_id                     => p_pl_bnf_id
1580     ,p_business_group_id             => p_business_group_id
1581     ,p_pea_attribute_category        => p_pea_attribute_category
1582     ,p_pea_attribute1                => p_pea_attribute1
1583     ,p_pea_attribute2                => p_pea_attribute2
1584     ,p_pea_attribute3                => p_pea_attribute3
1585     ,p_pea_attribute4                => p_pea_attribute4
1586     ,p_pea_attribute5                => p_pea_attribute5
1587     ,p_pea_attribute6                => p_pea_attribute6
1588     ,p_pea_attribute7                => p_pea_attribute7
1589     ,p_pea_attribute8                => p_pea_attribute8
1590     ,p_pea_attribute9                => p_pea_attribute9
1591     ,p_pea_attribute10               => p_pea_attribute10
1592     ,p_pea_attribute11               => p_pea_attribute11
1593     ,p_pea_attribute12               => p_pea_attribute12
1594     ,p_pea_attribute13               => p_pea_attribute13
1595     ,p_pea_attribute14               => p_pea_attribute14
1596     ,p_pea_attribute15               => p_pea_attribute15
1597     ,p_pea_attribute16               => p_pea_attribute16
1598     ,p_pea_attribute17               => p_pea_attribute17
1599     ,p_pea_attribute18               => p_pea_attribute18
1600     ,p_pea_attribute19               => p_pea_attribute19
1601     ,p_pea_attribute20               => p_pea_attribute20
1602     ,p_pea_attribute21               => p_pea_attribute21
1603     ,p_pea_attribute22               => p_pea_attribute22
1604     ,p_pea_attribute23               => p_pea_attribute23
1605     ,p_pea_attribute24               => p_pea_attribute24
1606     ,p_pea_attribute25               => p_pea_attribute25
1607     ,p_pea_attribute26               => p_pea_attribute26
1608     ,p_pea_attribute27               => p_pea_attribute27
1609     ,p_pea_attribute28               => p_pea_attribute28
1610     ,p_pea_attribute29               => p_pea_attribute29
1611     ,p_pea_attribute30               => p_pea_attribute30
1612     ,p_object_version_number         => l_object_version_number
1613     ,p_effective_date                => trunc(p_effective_date)
1614     ,p_datetrack_mode                => p_datetrack_mode
1615     );
1616   --
1617   begin
1618     --
1619     -- Start of API User Hook for the after hook of update_PRTT_ENRT_ACTN
1620     --
1621     ben_PRTT_ENRT_ACTN_bk2.update_PRTT_ENRT_ACTN_a
1622       (
1623        p_prtt_enrt_actn_id              =>  p_prtt_enrt_actn_id
1624       ,p_effective_start_date           =>  l_effective_start_date
1625       ,p_effective_end_date             =>  l_effective_end_date
1626       ,p_cmpltd_dt                      =>  p_cmpltd_dt
1627       ,p_due_dt                         =>  p_due_dt
1628       ,p_rqd_flag                       =>  p_rqd_flag
1629       ,p_prtt_enrt_rslt_id              =>  p_prtt_enrt_rslt_id
1630       ,p_per_in_ler_id              =>  l_per_in_ler_id
1631       ,p_actn_typ_id                    =>  p_actn_typ_id
1632       ,p_elig_cvrd_dpnt_id              =>  p_elig_cvrd_dpnt_id
1633       ,p_pl_bnf_id                      =>  p_pl_bnf_id
1634       ,p_business_group_id              =>  p_business_group_id
1635       ,p_pea_attribute_category         =>  p_pea_attribute_category
1636       ,p_pea_attribute1                 =>  p_pea_attribute1
1637       ,p_pea_attribute2                 =>  p_pea_attribute2
1638       ,p_pea_attribute3                 =>  p_pea_attribute3
1639       ,p_pea_attribute4                 =>  p_pea_attribute4
1640       ,p_pea_attribute5                 =>  p_pea_attribute5
1641       ,p_pea_attribute6                 =>  p_pea_attribute6
1642       ,p_pea_attribute7                 =>  p_pea_attribute7
1643       ,p_pea_attribute8                 =>  p_pea_attribute8
1644       ,p_pea_attribute9                 =>  p_pea_attribute9
1645       ,p_pea_attribute10                =>  p_pea_attribute10
1646       ,p_pea_attribute11                =>  p_pea_attribute11
1647       ,p_pea_attribute12                =>  p_pea_attribute12
1648       ,p_pea_attribute13                =>  p_pea_attribute13
1649       ,p_pea_attribute14                =>  p_pea_attribute14
1650       ,p_pea_attribute15                =>  p_pea_attribute15
1651       ,p_pea_attribute16                =>  p_pea_attribute16
1652       ,p_pea_attribute17                =>  p_pea_attribute17
1653       ,p_pea_attribute18                =>  p_pea_attribute18
1654       ,p_pea_attribute19                =>  p_pea_attribute19
1655       ,p_pea_attribute20                =>  p_pea_attribute20
1656       ,p_pea_attribute21                =>  p_pea_attribute21
1657       ,p_pea_attribute22                =>  p_pea_attribute22
1658       ,p_pea_attribute23                =>  p_pea_attribute23
1659       ,p_pea_attribute24                =>  p_pea_attribute24
1660       ,p_pea_attribute25                =>  p_pea_attribute25
1661       ,p_pea_attribute26                =>  p_pea_attribute26
1662       ,p_pea_attribute27                =>  p_pea_attribute27
1663       ,p_pea_attribute28                =>  p_pea_attribute28
1664       ,p_pea_attribute29                =>  p_pea_attribute29
1665       ,p_pea_attribute30                =>  p_pea_attribute30
1666       ,p_object_version_number          =>  l_object_version_number
1667       ,p_effective_date                     => trunc(p_effective_date)
1668       ,p_datetrack_mode                     => p_datetrack_mode
1669       );
1670   exception
1671     when hr_api.cannot_find_prog_unit then
1672       hr_api.cannot_find_prog_unit_error
1673         (p_module_name => 'UPDATE_PRTT_ENRT_ACTN'
1674         ,p_hook_type   => 'AP'
1675         );
1676     --
1677     -- End of API User Hook for the after hook of update_PRTT_ENRT_ACTN
1678     --
1679   end;
1680   --
1681   hr_utility.set_location(l_proc, 60);
1682   --
1683   -- Set all output arguments
1684   --
1685   p_object_version_number := l_object_version_number;
1686   p_effective_start_date := l_effective_start_date;
1687   p_effective_end_date := l_effective_end_date;
1688   --
1689   -- suspend the enrollment if setting cmpltd_dt to NULL
1690   -- do not suspend if cmpltd_dt is getting a value
1691   -- instead if cmpltd_dt not null check if all others are also
1692   -- completed and if allcmpltd_dt for this participant are not null
1693   -- then unsuspend the enrollment
1694   --
1695   if p_rqd_flag = 'Y' then
1696     if p_cmpltd_dt is NULL then
1697     --
1698       suspend_rslt
1699         (p_prtt_enrt_rslt_id          => p_prtt_enrt_rslt_id
1700         ,p_post_rslt_flag             => p_post_rslt_flag
1701         ,p_effective_date             => p_effective_date
1702         ,p_business_group_id          => p_business_group_id
1703         ,p_rslt_object_version_number => p_rslt_object_version_number
1704         ,p_validate                   => p_validate
1705         ,p_datetrack_mode             => p_datetrack_mode);
1706     --
1707     else
1708     --
1709       unsuspend_rslt
1710         (p_prtt_enrt_rslt_id          => p_prtt_enrt_rslt_id
1711         ,p_post_rslt_flag             => p_post_rslt_flag
1712         ,p_effective_date             => p_effective_date
1713         ,p_business_group_id          => p_business_group_id
1714         ,p_rslt_object_version_number => p_rslt_object_version_number
1715         ,p_validate                   => p_validate
1716         ,p_datetrack_mode             => p_datetrack_mode
1717         ,p_cmpltd_dt                  => p_cmpltd_dt );
1718     --
1719     end if;
1720    end if;
1721   --
1722   if p_gnrt_cm then
1723     if p_cmpltd_dt is not null then
1724       --
1725       if l_pea.cmpltd_dt is null and
1726          l_pea.effective_start_date = p_effective_date then
1727          --
1728          -- Action Item completed and started on the same day.
1729          --
1730          -- Delete communications for the action item as the action item just
1731          -- started and ended. The communications got generated due to the
1732          -- way we handle action items.
1733          --
1734          for l_pcm in c_pcm loop
1735             --
1736             ben_per_cm_api.delete_per_cm
1737                  (p_per_cm_id             => l_pcm.per_cm_id,
1738                   p_effective_start_date  => l_pcm_effective_start_date,
1739                   p_effective_end_date    => l_pcm_effective_end_date,
1740                   p_object_version_number => l_pcm.object_version_number,
1741                   p_effective_date        => p_effective_date,
1742                   p_datetrack_mode        => hr_api.g_zap);
1743             --
1744          end loop;
1745          --
1746       else
1747          --
1748          --  Generate Communications
1749          --
1750          ben_generate_communications.main
1751            (p_person_id             => l_person_id
1752            ,p_ler_id                => l_ler_id
1753            -- CWB Changes
1754            ,p_per_in_ler_id         => l_per_in_ler_id
1755            ,p_prtt_enrt_actn_id     => p_prtt_enrt_actn_id
1756            ,p_pgm_id                => l_pgm_id
1757            ,p_pl_id                 => l_pl_id
1758            ,p_pl_typ_id             => l_pl_typ_id
1759            ,p_actn_typ_id           => p_actn_typ_id
1760            ,p_business_group_id     => p_business_group_id
1761            ,p_proc_cd1              => 'ACTNCMPL'
1762            ,p_effective_date        => p_effective_date);
1763          --
1764       end if;
1765       --
1766     end if;
1767     --
1768   end if;
1769   --
1770   -- When in validation only mode raise the Validate_Enabled exception
1771   --
1772   if p_validate then
1773     raise hr_api.validate_enabled;
1774   end if;
1775   --
1776   hr_utility.set_location(' Leaving:'||l_proc, 70);
1777   --
1778 exception
1779   --
1780   when hr_api.validate_enabled then
1781     --
1782     -- As the Validate_Enabled exception has been raised
1783     -- we must rollback to the savepoint
1784     --
1785     ROLLBACK TO update_PRTT_ENRT_ACTN;
1786     --
1787     -- Only set output warning arguments
1788     -- (Any key or derived arguments must be set to null
1789     -- when validation only mode is being used.)
1790     --
1791     p_effective_start_date := null;
1792     p_effective_end_date := null;
1793     hr_utility.set_location(' Leaving:'||l_proc, 80);
1794     --
1795   when others then
1796     --
1797     -- A validation or unexpected error has occured
1798     --
1799     ROLLBACK TO update_PRTT_ENRT_ACTN;
1800     p_object_version_number := l_object_version_number;
1801     p_effective_start_date := null;
1802     p_effective_end_date := null;
1803 
1804     raise;
1805     --
1806 end update_PRTT_ENRT_ACTN;
1807 -- ----------------------------------------------------------------------------
1808 -- |------------------------< delete_PRTT_ENRT_ACTN >----------------------|
1809 -- ----------------------------------------------------------------------------
1810 --
1811 procedure delete_PRTT_ENRT_ACTN
1812   (p_validate                       in     boolean  default false
1813   ,p_prtt_enrt_actn_id              in     number
1814   ,p_business_group_id              in     number
1815   ,p_effective_date                 in     date
1816   ,p_datetrack_mode                 in     varchar2
1817   ,p_object_version_number          in out nocopy number
1818   ,p_prtt_enrt_rslt_id              in     number
1819   ,p_rslt_object_version_number     in out nocopy number
1820   ,p_post_rslt_flag                 in     varchar2 default 'N'
1821   ,p_unsuspend_enrt_flag            in     varchar2 default 'Y'
1822   ,p_gnrt_cm                        in     boolean default true
1823   ,p_effective_start_date              out nocopy date
1824   ,p_effective_end_date                out nocopy date
1825   )
1826 is
1827   --
1828   -- Declare cursors and local variables
1829   --
1830   -- Cursor to find dpnt ctfns.
1831   --
1832   cursor c_dpnt_ctfns
1833   is
1834   select cvrd_dpnt_ctfn_prvdd_id,
1835          object_version_number,
1836          effective_start_date,
1837          effective_end_date
1838     from ben_cvrd_dpnt_ctfn_prvdd_f
1839    where prtt_enrt_actn_id = p_prtt_enrt_actn_id
1840      and business_group_id = p_business_group_id
1841      and p_effective_date between effective_start_date
1842                               and effective_end_date;
1843   --
1844   -- Cursor to find bnf ctfns.
1845   --
1846   cursor c_bnf_ctfns
1847   is
1848   select pl_bnf_ctfn_prvdd_id,
1849          object_version_number,
1850          effective_start_date,
1851          effective_end_date
1852     from ben_pl_bnf_ctfn_prvdd_f
1853    where prtt_enrt_actn_id = p_prtt_enrt_actn_id
1854      and business_group_id = p_business_group_id
1855      and p_effective_date between effective_start_date
1856                               and effective_end_date;
1857   --
1858   -- Cursor to find enrt ctfns.
1859   --
1860   cursor c_enrt_ctfns
1861   is
1862   select prtt_enrt_ctfn_prvdd_id,
1863          object_version_number,
1864          effective_start_date,
1865          effective_end_date
1866     from ben_prtt_enrt_ctfn_prvdd_f
1867    where prtt_enrt_actn_id = p_prtt_enrt_actn_id
1868      and business_group_id = p_business_group_id
1869      and p_effective_date between effective_start_date
1870                               and effective_end_date;
1871   --
1872   -- Cursor to find person communications.
1873   --
1874   cursor c_per_cm
1875   is
1876   select per_cm_id,
1877          object_version_number,
1878          effective_start_date,
1879          effective_end_date
1880     from ben_per_cm_f
1881    where prtt_enrt_actn_id = p_prtt_enrt_actn_id
1882      and business_group_id = p_business_group_id
1883      and p_effective_date between effective_start_date
1884                               and effective_end_date;
1885   --
1886   --
1887   l_proc varchar2(72) := g_package||'delete_PRTT_ENRT_ACTN';
1888   l_object_version_number ben_prtt_enrt_actn_f.object_version_number%TYPE;
1889   l_effective_start_date ben_prtt_enrt_actn_f.effective_start_date%TYPE;
1890   l_effective_end_date ben_prtt_enrt_actn_f.effective_end_date%TYPE;
1891   --
1892 begin
1893   --
1894   hr_utility.set_location('Entering:'|| l_proc, 10);
1895   --
1896 
1897   -- Issue a savepoint if operating in validation only mode
1898   --
1899   savepoint delete_PRTT_ENRT_ACTN;
1900   --
1901   hr_utility.set_location(l_proc, 20);
1902   --
1903   -- Process Logic
1904   --
1905   l_object_version_number := p_object_version_number;
1906   --
1907   --
1908   begin
1909     --
1910     -- Start of API User Hook for the before hook of delete_PRTT_ENRT_ACTN
1911     --
1912     ben_PRTT_ENRT_ACTN_bk3.delete_PRTT_ENRT_ACTN_b
1913       (p_prtt_enrt_actn_id              =>  p_prtt_enrt_actn_id
1914       ,p_object_version_number          =>  p_object_version_number
1915       ,p_effective_date                 => trunc(p_effective_date)
1916       ,p_datetrack_mode                 => p_datetrack_mode);
1917     --
1918   exception
1919     --
1920     when hr_api.cannot_find_prog_unit then
1921       hr_api.cannot_find_prog_unit_error
1922         (p_module_name => 'DELETE_PRTT_ENRT_ACTN'
1923         ,p_hook_type   => 'BP');
1924     --
1925     -- End of API User Hook for the before hook of delete_PRTT_ENRT_ACTN
1926     --
1927   end;
1928   --
1929   --Bug 5693086
1930   if p_datetrack_mode = hr_api.g_delete_next_change or p_datetrack_mode = hr_api.g_future_change then
1931   --
1932   ben_pea_del.del
1933     (p_prtt_enrt_actn_id             => p_prtt_enrt_actn_id
1934     ,p_effective_start_date          => l_effective_start_date
1935     ,p_effective_end_date            => l_effective_end_date
1936     ,p_object_version_number         => l_object_version_number
1937     ,p_effective_date                => p_effective_date
1938     ,p_datetrack_mode                => p_datetrack_mode);
1939   --
1940   begin
1941     --
1942     -- Start of API User Hook for the after hook of delete_PRTT_ENRT_ACTN
1943     --
1944     ben_PRTT_ENRT_ACTN_bk3.delete_PRTT_ENRT_ACTN_a
1945       (p_prtt_enrt_actn_id              =>  p_prtt_enrt_actn_id
1946       ,p_effective_start_date           =>  l_effective_start_date
1947       ,p_effective_end_date             =>  l_effective_end_date
1948       ,p_object_version_number          =>  l_object_version_number
1949       ,p_effective_date                 => trunc(p_effective_date)
1950       ,p_datetrack_mode                 => p_datetrack_mode);
1951     --
1952   exception
1953     --
1954     when hr_api.cannot_find_prog_unit then
1955       hr_api.cannot_find_prog_unit_error
1956         (p_module_name => 'DELETE_PRTT_ENRT_ACTN'
1957         ,p_hook_type   => 'AP');
1958     --
1959     -- End of API User Hook for the after hook of delete_PRTT_ENRT_ACTN
1960     --
1961   end;
1962    --
1963   end if;
1964   --Bug 5693086
1965 
1966   -- First delete all the children of the action item being deleted.
1967   --
1968   -- Delete dpnt ctfns.
1969   --
1970   for l_rec in c_dpnt_ctfns loop
1971     --
1972     -- Do not datetrack delete the row, if it is already end-dated.
1973     --
1974     if (p_datetrack_mode = hr_api.g_delete and
1975         l_rec.effective_end_date > p_effective_date) or
1976         p_datetrack_mode <> hr_api.g_delete then
1977       --
1978       ben_cvrd_dpnt_ctfn_prvdd_api.delete_cvrd_dpnt_ctfn_prvdd
1979         (p_validate                => FALSE
1980         ,p_cvrd_dpnt_ctfn_prvdd_id => l_rec.cvrd_dpnt_ctfn_prvdd_id
1981         ,p_effective_start_date    => l_rec.effective_start_date
1982         ,p_effective_end_date      => l_rec.effective_end_date
1983         ,p_object_version_number   => l_rec.object_version_number
1984         ,p_business_group_id       => p_business_group_id
1985         ,p_effective_date          => p_effective_date
1986         ,p_datetrack_mode          => p_datetrack_mode
1987         ,p_check_actions           => 'N'
1988         ,p_called_from             => 'bepeaapi' );
1989       --
1990     end if;
1991     --
1992   end loop;
1993   --
1994   -- Delete bnf ctfns.
1995   --
1996   for l_rec in c_bnf_ctfns loop
1997     --
1998     -- Do not datetrack delete the row, if it is already end-dated.
1999     --
2000     if (p_datetrack_mode = hr_api.g_delete and
2001         l_rec.effective_end_date > p_effective_date) or
2002         p_datetrack_mode <> hr_api.g_delete then
2003       --
2004       ben_pl_bnf_ctfn_prvdd_api.delete_pl_bnf_ctfn_prvdd
2005         (p_validate                => FALSE
2006         ,p_pl_bnf_ctfn_prvdd_id    => l_rec.pl_bnf_ctfn_prvdd_id
2007         ,p_effective_start_date    => l_rec.effective_start_date
2008         ,p_effective_end_date      => l_rec.effective_end_date
2009         ,p_object_version_number   => l_rec.object_version_number
2010         ,p_business_group_id       => p_business_group_id
2011         ,p_effective_date          => p_effective_date
2012         ,p_datetrack_mode          => p_datetrack_mode
2013         ,p_check_actions           => 'N');
2014       --
2015     end if;
2016     --
2017   end loop;
2018   --
2019   -- Delete enrt ctfns.
2020   --
2021   for l_rec in c_enrt_ctfns loop
2022     --
2023     -- Do not datetrack delete the row, if it is already end-dated.
2024     --
2025     if (p_datetrack_mode = hr_api.g_delete and
2026        /* l_rec.effective_end_date > p_effective_date) or */
2027           l_rec.effective_end_date >= p_effective_date) or  --Bug 8304294
2028         p_datetrack_mode <> hr_api.g_delete then
2029       --
2030       ben_prtt_enrt_ctfn_prvdd_api.delete_prtt_enrt_ctfn_prvdd
2031         (p_validate                => FALSE
2032         ,p_prtt_enrt_ctfn_prvdd_id => l_rec.prtt_enrt_ctfn_prvdd_id
2033         ,p_effective_start_date    => l_rec.effective_start_date
2034         ,p_effective_end_date      => l_rec.effective_end_date
2035         ,p_object_version_number   => l_rec.object_version_number
2036         ,p_effective_date          => p_effective_date
2037         ,p_datetrack_mode          => p_datetrack_mode
2038         ,p_check_actions           => 'N');
2039       --
2040     end if;
2041     --
2042   end loop;
2043   --
2044   -- Delete person communications.
2045   --
2046   for l_rec in c_per_cm loop
2047     --
2048     -- 5040268 : Do not datetrack delete PER_CM% rows, if already deleted.
2049     if (p_datetrack_mode = hr_api.g_delete and
2050         l_rec.effective_end_date > p_effective_date) or
2051         p_datetrack_mode <> hr_api.g_delete then
2052         --
2053 	/* Bug 12976985: When Life Event is backedout, Participant action item will be reopened in
2054 	delete future change mode for the previous LE. But since communication is not end dated,
2055 	calling the api in that mode will cause error to be thrown*/
2056 	if(p_datetrack_mode = hr_api.g_future_change
2057            and l_rec.effective_end_date = hr_api.g_eot) then
2058                  null;
2059         else
2060 		ben_per_cm_api.delete_per_cm
2061 		  (p_validate              => FALSE
2062 		  ,p_per_cm_id             => l_rec.per_cm_id
2063 		  ,p_effective_start_date  => l_rec.effective_start_date
2064 		  ,p_effective_end_date    => l_rec.effective_end_date
2065 		  ,p_object_version_number => l_rec.object_version_number
2066 		  ,p_effective_date        => p_effective_date
2067 		  ,p_datetrack_mode        => p_datetrack_mode);
2068 	end if;
2069           --
2070     end if;
2071     --
2072   end loop;
2073   --
2074   -- Call the action item row handler to delete the row.
2075   --
2076   --Bug 5693086
2077   if p_datetrack_mode <> hr_api.g_delete_next_change and p_datetrack_mode <> hr_api.g_future_change then
2078   --
2079   ben_pea_del.del
2080     (p_prtt_enrt_actn_id             => p_prtt_enrt_actn_id
2081     ,p_effective_start_date          => l_effective_start_date
2082     ,p_effective_end_date            => l_effective_end_date
2083     ,p_object_version_number         => l_object_version_number
2084     ,p_effective_date                => p_effective_date
2085     ,p_datetrack_mode                => p_datetrack_mode);
2086   --
2087   begin
2088     --
2089     -- Start of API User Hook for the after hook of delete_PRTT_ENRT_ACTN
2090     --
2091     ben_PRTT_ENRT_ACTN_bk3.delete_PRTT_ENRT_ACTN_a
2092       (p_prtt_enrt_actn_id              =>  p_prtt_enrt_actn_id
2093       ,p_effective_start_date           =>  l_effective_start_date
2094       ,p_effective_end_date             =>  l_effective_end_date
2095       ,p_object_version_number          =>  l_object_version_number
2096       ,p_effective_date                 => trunc(p_effective_date)
2097       ,p_datetrack_mode                 => p_datetrack_mode);
2098     --
2099   exception
2100     --
2101     when hr_api.cannot_find_prog_unit then
2102       hr_api.cannot_find_prog_unit_error
2103         (p_module_name => 'DELETE_PRTT_ENRT_ACTN'
2104         ,p_hook_type   => 'AP');
2105     --
2106     -- End of API User Hook for the after hook of delete_PRTT_ENRT_ACTN
2107     --
2108   end;
2109   --
2110   end if;
2111   --
2112   --Bug 5693086
2113   hr_utility.set_location(l_proc, 60);
2114   --
2115   -- If the calling procedure requests that the enrollment result be unsuspended
2116   -- then unsuspend the enrollment result.
2117   --
2118   if p_unsuspend_enrt_flag = 'Y' then
2119     --
2120     unsuspend_rslt
2121       (p_prtt_enrt_rslt_id          => p_prtt_enrt_rslt_id
2122       ,p_post_rslt_flag             => p_post_rslt_flag
2123       ,p_effective_date             => p_effective_date
2124       ,p_business_group_id          => p_business_group_id
2125       ,p_rslt_object_version_number => p_rslt_object_version_number
2126       ,p_validate                   => p_validate
2127       ,p_datetrack_mode             => p_datetrack_mode);
2128     --
2129   end if;
2130   --
2131   -- When in validation only mode raise the Validate_Enabled exception
2132   --
2133   if p_validate then
2134     raise hr_api.validate_enabled;
2135   end if;
2136   --
2137   hr_utility.set_location(' Leaving:'||l_proc, 70);
2138   --
2139 exception
2140   --
2141   when hr_api.validate_enabled then
2142     --
2143     -- As the Validate_Enabled exception has been raised
2144     -- we must rollback to the savepoint
2145     --
2146     ROLLBACK TO delete_PRTT_ENRT_ACTN;
2147     --
2148     -- Only set output warning arguments
2149     -- (Any key or derived arguments must be set to null
2150     -- when validation only mode is being used.)
2151     --
2152     --
2153   when others then
2154     --
2155     -- A validation or unexpected error has occured
2156     --
2157     ROLLBACK TO delete_PRTT_ENRT_ACTN;
2158     p_object_version_number := l_object_version_number;
2159     p_effective_start_date := null;
2160     p_effective_end_date := null;
2161 
2162     raise;
2163     --
2164 end delete_PRTT_ENRT_ACTN;
2165 --
2166 -- ----------------------------------------------------------------------------
2167 -- |-------------------------------< lck >------------------------------------|
2168 -- ----------------------------------------------------------------------------
2169 --
2170 procedure lck
2171   (
2172    p_prtt_enrt_actn_id                   in     number
2173   ,p_object_version_number          in     number
2174   ,p_effective_date                 in     date
2175   ,p_datetrack_mode                 in     varchar2
2176   ,p_validation_start_date          out nocopy    date
2177   ,p_validation_end_date            out nocopy    date
2178   ) is
2179   --
2180   --
2181   -- Declare cursors and local variables
2182   --
2183   l_proc varchar2(72) := g_package||'lck';
2184   l_validation_start_date date;
2185   l_validation_end_date date;
2186   --
2187 begin
2188   --
2189   hr_utility.set_location('Entering:'|| l_proc, 10);
2190   --
2191   ben_pea_shd.lck
2192     (
2193       p_prtt_enrt_actn_id                 => p_prtt_enrt_actn_id
2194      ,p_validation_start_date      => l_validation_start_date
2195      ,p_validation_end_date        => l_validation_end_date
2196      ,p_object_version_number      => p_object_version_number
2197      ,p_effective_date             => p_effective_date
2198      ,p_datetrack_mode             => p_datetrack_mode
2199     );
2200   --
2201   hr_utility.set_location(' Leaving:'||l_proc, 70);
2202   --
2203 end lck;
2204 --
2205 end ben_PRTT_ENRT_ACTN_api;