DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PLAN_TYPE_OPTION_TYPE_API

Source


1 Package Body ben_plan_type_option_type_api as
2 /* $Header: beponapi.pkb 120.0 2005/05/28 10:56:01 appldev noship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(33) := '  ben_plan_type_option_type_api.';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |------------------------< create_plan_type_option_type >----------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 procedure create_plan_type_option_type
13   (p_validate                       in  boolean   default false
14   ,p_pl_typ_opt_typ_id              out nocopy number
15   ,p_effective_start_date           out nocopy date
16   ,p_effective_end_date             out nocopy date
17   ,p_pl_typ_opt_typ_cd              in  varchar2  default null
18   ,p_opt_id                         in  number    default null
19   ,p_pl_typ_id                      in  number    default null
20   ,p_business_group_id              in  number    default null
21   ,p_legislation_code         in  varchar2  default null
22   ,p_legislation_subgroup         in  varchar2  default null
23   ,p_pon_attribute_category         in  varchar2  default null
24   ,p_pon_attribute1                 in  varchar2  default null
25   ,p_pon_attribute2                 in  varchar2  default null
26   ,p_pon_attribute3                 in  varchar2  default null
27   ,p_pon_attribute4                 in  varchar2  default null
28   ,p_pon_attribute5                 in  varchar2  default null
29   ,p_pon_attribute6                 in  varchar2  default null
30   ,p_pon_attribute7                 in  varchar2  default null
31   ,p_pon_attribute8                 in  varchar2  default null
32   ,p_pon_attribute9                 in  varchar2  default null
33   ,p_pon_attribute10                in  varchar2  default null
34   ,p_pon_attribute11                in  varchar2  default null
35   ,p_pon_attribute12                in  varchar2  default null
36   ,p_pon_attribute13                in  varchar2  default null
37   ,p_pon_attribute14                in  varchar2  default null
38   ,p_pon_attribute15                in  varchar2  default null
39   ,p_pon_attribute16                in  varchar2  default null
40   ,p_pon_attribute17                in  varchar2  default null
41   ,p_pon_attribute18                in  varchar2  default null
42   ,p_pon_attribute19                in  varchar2  default null
43   ,p_pon_attribute20                in  varchar2  default null
44   ,p_pon_attribute21                in  varchar2  default null
45   ,p_pon_attribute22                in  varchar2  default null
46   ,p_pon_attribute23                in  varchar2  default null
47   ,p_pon_attribute24                in  varchar2  default null
48   ,p_pon_attribute25                in  varchar2  default null
49   ,p_pon_attribute26                in  varchar2  default null
50   ,p_pon_attribute27                in  varchar2  default null
51   ,p_pon_attribute28                in  varchar2  default null
52   ,p_pon_attribute29                in  varchar2  default null
53   ,p_pon_attribute30                in  varchar2  default null
54   ,p_object_version_number          out nocopy number
55   ,p_effective_date                 in  date
56   ) is
57   --
58   -- Declare cursors and local variables
59   --
60   l_pl_typ_opt_typ_id ben_pl_typ_opt_typ_f.pl_typ_opt_typ_id%TYPE;
61   l_effective_start_date ben_pl_typ_opt_typ_f.effective_start_date%TYPE;
62   l_effective_end_date ben_pl_typ_opt_typ_f.effective_end_date%TYPE;
63   l_proc varchar2(72) := g_package||'create_plan_type_option_type';
64   l_object_version_number ben_pl_typ_opt_typ_f.object_version_number%TYPE;
65   --
66 
67   --  to find the cwb plan type for updating the  group plan
68 
69   cursor c_opt  is
70     select  opt.Group_opt_id ,
71             opt.object_version_number
72       from ben_opt_f opt
73            where  opt.opt_id = p_opt_id
74              and  p_effective_date between
75                   opt.effective_start_date and opt.effective_end_date ;
76 
77   cursor c_ptp  is
78     select  ptp.opt_typ_cd
79       from ben_pl_typ_f  ptp
80            where  ptp.pl_typ_id  = p_pl_typ_id
81              and  p_effective_date between
82                   ptp.effective_start_date and ptp.effective_end_date ;
83 
84   l_group_opt_id ben_opt_f.Group_opt_id%type ;
85   l_opt_typ_cd   ben_pl_typ_f.opt_typ_cd%type ;
86   l_opt_ovn      number ;
87   l_eff_st_dt    date   ;
88   l_eff_end_dt   date   ;
89 
90 begin
91   --
92   hr_utility.set_location('Entering:'|| l_proc, 10);
93   --
94   -- Issue a savepoint if operating in validation only mode
95   --
96   savepoint create_plan_type_option_type;
97   --
98   hr_utility.set_location(l_proc, 20);
99   --
100   -- Process Logic
101   --
102   begin
103     --
104     -- Start of API User Hook for the before hook of create_plan_type_option_type
105     --
106     ben_plan_type_option_type_bk1.create_plan_type_option_type_b
107       (
108        p_pl_typ_opt_typ_cd              =>  p_pl_typ_opt_typ_cd
109       ,p_opt_id                         =>  p_opt_id
110       ,p_pl_typ_id                      =>  p_pl_typ_id
111       ,p_business_group_id              =>  p_business_group_id
112       ,p_legislation_code         =>  p_legislation_code
113       ,p_legislation_subgroup         =>  p_legislation_subgroup
114       ,p_pon_attribute_category         =>  p_pon_attribute_category
115       ,p_pon_attribute1                 =>  p_pon_attribute1
116       ,p_pon_attribute2                 =>  p_pon_attribute2
117       ,p_pon_attribute3                 =>  p_pon_attribute3
118       ,p_pon_attribute4                 =>  p_pon_attribute4
119       ,p_pon_attribute5                 =>  p_pon_attribute5
120       ,p_pon_attribute6                 =>  p_pon_attribute6
121       ,p_pon_attribute7                 =>  p_pon_attribute7
122       ,p_pon_attribute8                 =>  p_pon_attribute8
123       ,p_pon_attribute9                 =>  p_pon_attribute9
124       ,p_pon_attribute10                =>  p_pon_attribute10
125       ,p_pon_attribute11                =>  p_pon_attribute11
126       ,p_pon_attribute12                =>  p_pon_attribute12
127       ,p_pon_attribute13                =>  p_pon_attribute13
128       ,p_pon_attribute14                =>  p_pon_attribute14
129       ,p_pon_attribute15                =>  p_pon_attribute15
130       ,p_pon_attribute16                =>  p_pon_attribute16
131       ,p_pon_attribute17                =>  p_pon_attribute17
132       ,p_pon_attribute18                =>  p_pon_attribute18
133       ,p_pon_attribute19                =>  p_pon_attribute19
134       ,p_pon_attribute20                =>  p_pon_attribute20
135       ,p_pon_attribute21                =>  p_pon_attribute21
136       ,p_pon_attribute22                =>  p_pon_attribute22
137       ,p_pon_attribute23                =>  p_pon_attribute23
138       ,p_pon_attribute24                =>  p_pon_attribute24
139       ,p_pon_attribute25                =>  p_pon_attribute25
140       ,p_pon_attribute26                =>  p_pon_attribute26
141       ,p_pon_attribute27                =>  p_pon_attribute27
142       ,p_pon_attribute28                =>  p_pon_attribute28
143       ,p_pon_attribute29                =>  p_pon_attribute29
144       ,p_pon_attribute30                =>  p_pon_attribute30
145       ,p_effective_date                 => trunc(p_effective_date)
146       );
147   exception
148     when hr_api.cannot_find_prog_unit then
149       hr_api.cannot_find_prog_unit_error
150         (
151          p_module_name => 'CREATE_plan_type_option_type'
152         ,p_hook_type   => 'BP'
153         );
154     --
155     -- End of API User Hook for the before hook of create_plan_type_option_type
156     --
157   end;
158   --
159   ben_pon_ins.ins
160     (
161      p_pl_typ_opt_typ_id             => l_pl_typ_opt_typ_id
162     ,p_effective_start_date          => l_effective_start_date
163     ,p_effective_end_date            => l_effective_end_date
164     ,p_pl_typ_opt_typ_cd             => p_pl_typ_opt_typ_cd
165     ,p_opt_id                        => p_opt_id
166     ,p_pl_typ_id                     => p_pl_typ_id
167     ,p_business_group_id             => p_business_group_id
168     ,p_legislation_code        => p_legislation_code
169     ,p_legislation_subgroup        => p_legislation_subgroup
170     ,p_pon_attribute_category        => p_pon_attribute_category
171     ,p_pon_attribute1                => p_pon_attribute1
172     ,p_pon_attribute2                => p_pon_attribute2
173     ,p_pon_attribute3                => p_pon_attribute3
174     ,p_pon_attribute4                => p_pon_attribute4
175     ,p_pon_attribute5                => p_pon_attribute5
176     ,p_pon_attribute6                => p_pon_attribute6
177     ,p_pon_attribute7                => p_pon_attribute7
178     ,p_pon_attribute8                => p_pon_attribute8
179     ,p_pon_attribute9                => p_pon_attribute9
180     ,p_pon_attribute10               => p_pon_attribute10
181     ,p_pon_attribute11               => p_pon_attribute11
182     ,p_pon_attribute12               => p_pon_attribute12
183     ,p_pon_attribute13               => p_pon_attribute13
184     ,p_pon_attribute14               => p_pon_attribute14
185     ,p_pon_attribute15               => p_pon_attribute15
186     ,p_pon_attribute16               => p_pon_attribute16
187     ,p_pon_attribute17               => p_pon_attribute17
188     ,p_pon_attribute18               => p_pon_attribute18
189     ,p_pon_attribute19               => p_pon_attribute19
190     ,p_pon_attribute20               => p_pon_attribute20
191     ,p_pon_attribute21               => p_pon_attribute21
192     ,p_pon_attribute22               => p_pon_attribute22
193     ,p_pon_attribute23               => p_pon_attribute23
194     ,p_pon_attribute24               => p_pon_attribute24
195     ,p_pon_attribute25               => p_pon_attribute25
196     ,p_pon_attribute26               => p_pon_attribute26
197     ,p_pon_attribute27               => p_pon_attribute27
198     ,p_pon_attribute28               => p_pon_attribute28
199     ,p_pon_attribute29               => p_pon_attribute29
200     ,p_pon_attribute30               => p_pon_attribute30
201     ,p_object_version_number         => l_object_version_number
202     ,p_effective_date                => trunc(p_effective_date)
203     );
204   --
205   begin
206     --
207     -- Start of API User Hook for the after hook of create_plan_type_option_type
208     --
209     ben_plan_type_option_type_bk1.create_plan_type_option_type_a
210       (
211        p_pl_typ_opt_typ_id              =>  l_pl_typ_opt_typ_id
212       ,p_effective_start_date           =>  l_effective_start_date
213       ,p_effective_end_date             =>  l_effective_end_date
214       ,p_pl_typ_opt_typ_cd              =>  p_pl_typ_opt_typ_cd
215       ,p_opt_id                         =>  p_opt_id
216       ,p_pl_typ_id                      =>  p_pl_typ_id
217       ,p_business_group_id              =>  p_business_group_id
218       ,p_legislation_code         =>  p_legislation_code
219       ,p_legislation_subgroup         =>  p_legislation_subgroup
220       ,p_pon_attribute_category         =>  p_pon_attribute_category
221       ,p_pon_attribute1                 =>  p_pon_attribute1
222       ,p_pon_attribute2                 =>  p_pon_attribute2
223       ,p_pon_attribute3                 =>  p_pon_attribute3
224       ,p_pon_attribute4                 =>  p_pon_attribute4
225       ,p_pon_attribute5                 =>  p_pon_attribute5
226       ,p_pon_attribute6                 =>  p_pon_attribute6
227       ,p_pon_attribute7                 =>  p_pon_attribute7
228       ,p_pon_attribute8                 =>  p_pon_attribute8
229       ,p_pon_attribute9                 =>  p_pon_attribute9
230       ,p_pon_attribute10                =>  p_pon_attribute10
231       ,p_pon_attribute11                =>  p_pon_attribute11
232       ,p_pon_attribute12                =>  p_pon_attribute12
233       ,p_pon_attribute13                =>  p_pon_attribute13
234       ,p_pon_attribute14                =>  p_pon_attribute14
235       ,p_pon_attribute15                =>  p_pon_attribute15
236       ,p_pon_attribute16                =>  p_pon_attribute16
237       ,p_pon_attribute17                =>  p_pon_attribute17
238       ,p_pon_attribute18                =>  p_pon_attribute18
239       ,p_pon_attribute19                =>  p_pon_attribute19
240       ,p_pon_attribute20                =>  p_pon_attribute20
241       ,p_pon_attribute21                =>  p_pon_attribute21
242       ,p_pon_attribute22                =>  p_pon_attribute22
243       ,p_pon_attribute23                =>  p_pon_attribute23
244       ,p_pon_attribute24                =>  p_pon_attribute24
245       ,p_pon_attribute25                =>  p_pon_attribute25
246       ,p_pon_attribute26                =>  p_pon_attribute26
247       ,p_pon_attribute27                =>  p_pon_attribute27
248       ,p_pon_attribute28                =>  p_pon_attribute28
249       ,p_pon_attribute29                =>  p_pon_attribute29
250       ,p_pon_attribute30                =>  p_pon_attribute30
251       ,p_object_version_number          =>  l_object_version_number
252       ,p_effective_date                      => trunc(p_effective_date)
253       );
254   exception
255     when hr_api.cannot_find_prog_unit then
256       hr_api.cannot_find_prog_unit_error
257         (p_module_name => 'CREATE_plan_type_option_type'
258         ,p_hook_type   => 'AP'
259         );
260     --
261     -- End of API User Hook for the after hook of create_plan_type_option_type
262     --
263   end;
264   --
265   hr_utility.set_location(l_proc, 60);
266   --
267 
268    hr_utility.set_location(l_proc, 60);
269   -- when the  plan type is CWB and  the group_id is null then
270   -- update the group  id
271   open c_ptp ;
272   fetch c_ptp into l_opt_typ_cd ;
273   close c_ptp ;
274   hr_utility.set_location('OPT TYP CD '|| l_opt_typ_cd , 60);
275   if l_opt_typ_cd = 'CWB' then
276      open c_opt ;
277      fetch c_opt
278       into l_group_opt_id ,
279             l_opt_ovn ;
280      close c_opt ;
281      hr_utility.set_location(' l_group_opt_id '||  l_group_opt_id , 60);
282      if l_group_opt_id is null then
283          BEN_option_definition_API.update_option_definition
284                            (p_validate => FALSE
285                            ,p_OPT_ID => p_opt_id
286                            ,p_EFFECTIVE_START_DATE => l_eff_st_dt
287                            ,p_EFFECTIVE_END_DATE   => l_eff_end_dt
288                            ,p_group_opt_id         => p_opt_id
289                            ,p_OBJECT_VERSION_NUMBER=> l_opt_ovn
290                            ,p_effective_date       => p_effective_date
291                            ,p_datetrack_mode =>  'CORRECTION'
292                           );
293      end if ;
294   end if ;
295 
296   -- When in validation only mode raise the Validate_Enabled exception
297   --
298   if p_validate then
299     raise hr_api.validate_enabled;
300   end if;
301   --
302   -- Set all output arguments
303   --
304   p_pl_typ_opt_typ_id := l_pl_typ_opt_typ_id;
305   p_effective_start_date := l_effective_start_date;
306   p_effective_end_date := l_effective_end_date;
307   p_object_version_number := l_object_version_number;
308   --
309   hr_utility.set_location(' Leaving:'||l_proc, 70);
310   --
311 exception
312   --
313   when hr_api.validate_enabled then
314     --
315     -- As the Validate_Enabled exception has been raised
316     -- we must rollback to the savepoint
317     --
318     ROLLBACK TO create_plan_type_option_type;
319     --
320     -- Only set output warning arguments
321     -- (Any key or derived arguments must be set to null
322     -- when validation only mode is being used.)
323     --
324     p_pl_typ_opt_typ_id := null;
325     p_effective_start_date := null;
326     p_effective_end_date := null;
327     p_object_version_number  := null;
328     hr_utility.set_location(' Leaving:'||l_proc, 80);
329     --
330   when others then
331     --
332     -- A validation or unexpected error has occured
333     --
334     ROLLBACK TO create_plan_type_option_type;
335     /* Inserted for nocopy changes */
336     p_pl_typ_opt_typ_id := null;
337     p_effective_start_date := null;
338     p_effective_end_date := null;
339     p_object_version_number  := null;
340     raise;
341     --
342 end create_plan_type_option_type;
343 -- ----------------------------------------------------------------------------
344 -- |------------------------< update_plan_type_option_type >--- ------------------|
345 -- ----------------------------------------------------------------------------
346 --
347 procedure update_plan_type_option_type
348   (p_validate                       in  boolean   default false
349   ,p_pl_typ_opt_typ_id              in  number
350   ,p_effective_start_date           out nocopy date
351   ,p_effective_end_date             out nocopy date
352   ,p_pl_typ_opt_typ_cd              in  varchar2  default hr_api.g_varchar2
353   ,p_opt_id                         in  number    default hr_api.g_number
354   ,p_pl_typ_id                      in  number    default hr_api.g_number
355   ,p_business_group_id              in  number    default hr_api.g_number
356   ,p_legislation_code         in  varchar2  default hr_api.g_varchar2
357   ,p_legislation_subgroup         in  varchar2  default hr_api.g_varchar2
358   ,p_pon_attribute_category         in  varchar2  default hr_api.g_varchar2
359   ,p_pon_attribute1                 in  varchar2  default hr_api.g_varchar2
360   ,p_pon_attribute2                 in  varchar2  default hr_api.g_varchar2
361   ,p_pon_attribute3                 in  varchar2  default hr_api.g_varchar2
362   ,p_pon_attribute4                 in  varchar2  default hr_api.g_varchar2
363   ,p_pon_attribute5                 in  varchar2  default hr_api.g_varchar2
364   ,p_pon_attribute6                 in  varchar2  default hr_api.g_varchar2
365   ,p_pon_attribute7                 in  varchar2  default hr_api.g_varchar2
366   ,p_pon_attribute8                 in  varchar2  default hr_api.g_varchar2
367   ,p_pon_attribute9                 in  varchar2  default hr_api.g_varchar2
368   ,p_pon_attribute10                in  varchar2  default hr_api.g_varchar2
369   ,p_pon_attribute11                in  varchar2  default hr_api.g_varchar2
370   ,p_pon_attribute12                in  varchar2  default hr_api.g_varchar2
371   ,p_pon_attribute13                in  varchar2  default hr_api.g_varchar2
372   ,p_pon_attribute14                in  varchar2  default hr_api.g_varchar2
373   ,p_pon_attribute15                in  varchar2  default hr_api.g_varchar2
374   ,p_pon_attribute16                in  varchar2  default hr_api.g_varchar2
375   ,p_pon_attribute17                in  varchar2  default hr_api.g_varchar2
376   ,p_pon_attribute18                in  varchar2  default hr_api.g_varchar2
377   ,p_pon_attribute19                in  varchar2  default hr_api.g_varchar2
378   ,p_pon_attribute20                in  varchar2  default hr_api.g_varchar2
379   ,p_pon_attribute21                in  varchar2  default hr_api.g_varchar2
380   ,p_pon_attribute22                in  varchar2  default hr_api.g_varchar2
381   ,p_pon_attribute23                in  varchar2  default hr_api.g_varchar2
382   ,p_pon_attribute24                in  varchar2  default hr_api.g_varchar2
383   ,p_pon_attribute25                in  varchar2  default hr_api.g_varchar2
384   ,p_pon_attribute26                in  varchar2  default hr_api.g_varchar2
385   ,p_pon_attribute27                in  varchar2  default hr_api.g_varchar2
386   ,p_pon_attribute28                in  varchar2  default hr_api.g_varchar2
387   ,p_pon_attribute29                in  varchar2  default hr_api.g_varchar2
388   ,p_pon_attribute30                in  varchar2  default hr_api.g_varchar2
389   ,p_object_version_number          in out nocopy number
390   ,p_effective_date                 in  date
391   ,p_datetrack_mode                 in  varchar2
392   ) is
393   --
394   -- Declare cursors and local variables
395   --
396   l_proc varchar2(72) := g_package||'update_plan_type_option_type';
397   l_object_version_number ben_pl_typ_opt_typ_f.object_version_number%TYPE;
398   l_effective_start_date ben_pl_typ_opt_typ_f.effective_start_date%TYPE;
399   l_effective_end_date ben_pl_typ_opt_typ_f.effective_end_date%TYPE;
400   --  to find the cwb plan type for updating the  group plan
401 
402   cursor c_opt  is
403     select  opt.Group_opt_id ,
404             opt.object_version_number
405       from ben_opt_f opt
406            where  opt.opt_id = p_opt_id
407              and  p_effective_date between
408                   opt.effective_start_date and opt.effective_end_date ;
409 
410   cursor c_ptp  is
411     select  ptp.opt_typ_cd
412       from ben_pl_typ_f  ptp
413            where  ptp.pl_typ_id  = p_pl_typ_id
414              and  p_effective_date between
415                   ptp.effective_start_date and ptp.effective_end_date ;
416 
417   l_group_opt_id ben_opt_f.Group_opt_id%type ;
418   l_opt_typ_cd   ben_pl_typ_f.opt_typ_cd%type ;
419   l_opt_ovn      number ;
420   l_eff_st_dt    date   ;
421   l_eff_end_dt   date   ;
422 
423 begin
424   --
425   hr_utility.set_location('Entering:'|| l_proc, 10);
426   --
427   -- Issue a savepoint if operating in validation only mode
428   --
429   savepoint update_plan_type_option_type;
430   --
431   hr_utility.set_location(l_proc, 20);
432   --
433   -- Process Logic
434   --
435   l_object_version_number := p_object_version_number;
436   --
437   begin
438     --
439     -- Start of API User Hook for the before hook of update_plan_type_option_type
440     --
441     ben_plan_type_option_type_bk2.update_plan_type_option_type_b
442       (
443        p_pl_typ_opt_typ_id              =>  p_pl_typ_opt_typ_id
444       ,p_pl_typ_opt_typ_cd              =>  p_pl_typ_opt_typ_cd
445       ,p_opt_id                         =>  p_opt_id
446       ,p_pl_typ_id                      =>  p_pl_typ_id
447       ,p_business_group_id              =>  p_business_group_id
448       ,p_legislation_code         =>  p_legislation_code
449       ,p_legislation_subgroup         =>  p_legislation_subgroup
450       ,p_pon_attribute_category         =>  p_pon_attribute_category
451       ,p_pon_attribute1                 =>  p_pon_attribute1
452       ,p_pon_attribute2                 =>  p_pon_attribute2
453       ,p_pon_attribute3                 =>  p_pon_attribute3
454       ,p_pon_attribute4                 =>  p_pon_attribute4
455       ,p_pon_attribute5                 =>  p_pon_attribute5
456       ,p_pon_attribute6                 =>  p_pon_attribute6
457       ,p_pon_attribute7                 =>  p_pon_attribute7
458       ,p_pon_attribute8                 =>  p_pon_attribute8
459       ,p_pon_attribute9                 =>  p_pon_attribute9
460       ,p_pon_attribute10                =>  p_pon_attribute10
461       ,p_pon_attribute11                =>  p_pon_attribute11
462       ,p_pon_attribute12                =>  p_pon_attribute12
463       ,p_pon_attribute13                =>  p_pon_attribute13
464       ,p_pon_attribute14                =>  p_pon_attribute14
465       ,p_pon_attribute15                =>  p_pon_attribute15
466       ,p_pon_attribute16                =>  p_pon_attribute16
467       ,p_pon_attribute17                =>  p_pon_attribute17
468       ,p_pon_attribute18                =>  p_pon_attribute18
469       ,p_pon_attribute19                =>  p_pon_attribute19
470       ,p_pon_attribute20                =>  p_pon_attribute20
471       ,p_pon_attribute21                =>  p_pon_attribute21
472       ,p_pon_attribute22                =>  p_pon_attribute22
473       ,p_pon_attribute23                =>  p_pon_attribute23
474       ,p_pon_attribute24                =>  p_pon_attribute24
475       ,p_pon_attribute25                =>  p_pon_attribute25
476       ,p_pon_attribute26                =>  p_pon_attribute26
477       ,p_pon_attribute27                =>  p_pon_attribute27
478       ,p_pon_attribute28                =>  p_pon_attribute28
479       ,p_pon_attribute29                =>  p_pon_attribute29
480       ,p_pon_attribute30                =>  p_pon_attribute30
481       ,p_object_version_number          =>  p_object_version_number
482     ,p_effective_date                      => trunc(p_effective_date)
483     ,p_datetrack_mode                      => p_datetrack_mode
484       );
485   exception
486     when hr_api.cannot_find_prog_unit then
487       hr_api.cannot_find_prog_unit_error
488         (p_module_name => 'UPDATE_plan_type_option_type'
489         ,p_hook_type   => 'BP'
490         );
491     --
492     -- End of API User Hook for the before hook of update_plan_type_option_type
493     --
494   end;
495   --
496   ben_pon_upd.upd
497     (
498      p_pl_typ_opt_typ_id             => p_pl_typ_opt_typ_id
499     ,p_effective_start_date          => l_effective_start_date
500     ,p_effective_end_date            => l_effective_end_date
501     ,p_pl_typ_opt_typ_cd             => p_pl_typ_opt_typ_cd
502     ,p_opt_id                        => p_opt_id
503     ,p_pl_typ_id                     => p_pl_typ_id
504     ,p_business_group_id             => p_business_group_id
505     ,p_legislation_code        => p_legislation_code
506     ,p_legislation_subgroup        => p_legislation_subgroup
507     ,p_pon_attribute_category        => p_pon_attribute_category
508     ,p_pon_attribute1                => p_pon_attribute1
509     ,p_pon_attribute2                => p_pon_attribute2
510     ,p_pon_attribute3                => p_pon_attribute3
511     ,p_pon_attribute4                => p_pon_attribute4
512     ,p_pon_attribute5                => p_pon_attribute5
513     ,p_pon_attribute6                => p_pon_attribute6
514     ,p_pon_attribute7                => p_pon_attribute7
515     ,p_pon_attribute8                => p_pon_attribute8
516     ,p_pon_attribute9                => p_pon_attribute9
517     ,p_pon_attribute10               => p_pon_attribute10
518     ,p_pon_attribute11               => p_pon_attribute11
519     ,p_pon_attribute12               => p_pon_attribute12
520     ,p_pon_attribute13               => p_pon_attribute13
521     ,p_pon_attribute14               => p_pon_attribute14
522     ,p_pon_attribute15               => p_pon_attribute15
523     ,p_pon_attribute16               => p_pon_attribute16
524     ,p_pon_attribute17               => p_pon_attribute17
525     ,p_pon_attribute18               => p_pon_attribute18
526     ,p_pon_attribute19               => p_pon_attribute19
527     ,p_pon_attribute20               => p_pon_attribute20
528     ,p_pon_attribute21               => p_pon_attribute21
529     ,p_pon_attribute22               => p_pon_attribute22
530     ,p_pon_attribute23               => p_pon_attribute23
531     ,p_pon_attribute24               => p_pon_attribute24
532     ,p_pon_attribute25               => p_pon_attribute25
533     ,p_pon_attribute26               => p_pon_attribute26
534     ,p_pon_attribute27               => p_pon_attribute27
535     ,p_pon_attribute28               => p_pon_attribute28
536     ,p_pon_attribute29               => p_pon_attribute29
537     ,p_pon_attribute30               => p_pon_attribute30
538     ,p_object_version_number         => l_object_version_number
539     ,p_effective_date                => trunc(p_effective_date)
540     ,p_datetrack_mode                => p_datetrack_mode
541     );
542   --
543   begin
544     --
545     -- Start of API User Hook for the after hook of update_plan_type_option_type
546     --
547     ben_plan_type_option_type_bk2.update_plan_type_option_type_a
548       (
549        p_pl_typ_opt_typ_id              =>  p_pl_typ_opt_typ_id
550       ,p_effective_start_date           =>  l_effective_start_date
551       ,p_effective_end_date             =>  l_effective_end_date
552       ,p_pl_typ_opt_typ_cd              =>  p_pl_typ_opt_typ_cd
553       ,p_opt_id                         =>  p_opt_id
554       ,p_pl_typ_id                      =>  p_pl_typ_id
555       ,p_business_group_id              =>  p_business_group_id
556       ,p_legislation_code         =>  p_legislation_code
557       ,p_legislation_subgroup         =>  p_legislation_subgroup
558       ,p_pon_attribute_category         =>  p_pon_attribute_category
559       ,p_pon_attribute1                 =>  p_pon_attribute1
560       ,p_pon_attribute2                 =>  p_pon_attribute2
561       ,p_pon_attribute3                 =>  p_pon_attribute3
562       ,p_pon_attribute4                 =>  p_pon_attribute4
563       ,p_pon_attribute5                 =>  p_pon_attribute5
564       ,p_pon_attribute6                 =>  p_pon_attribute6
565       ,p_pon_attribute7                 =>  p_pon_attribute7
566       ,p_pon_attribute8                 =>  p_pon_attribute8
567       ,p_pon_attribute9                 =>  p_pon_attribute9
568       ,p_pon_attribute10                =>  p_pon_attribute10
569       ,p_pon_attribute11                =>  p_pon_attribute11
570       ,p_pon_attribute12                =>  p_pon_attribute12
571       ,p_pon_attribute13                =>  p_pon_attribute13
572       ,p_pon_attribute14                =>  p_pon_attribute14
573       ,p_pon_attribute15                =>  p_pon_attribute15
574       ,p_pon_attribute16                =>  p_pon_attribute16
575       ,p_pon_attribute17                =>  p_pon_attribute17
576       ,p_pon_attribute18                =>  p_pon_attribute18
577       ,p_pon_attribute19                =>  p_pon_attribute19
578       ,p_pon_attribute20                =>  p_pon_attribute20
579       ,p_pon_attribute21                =>  p_pon_attribute21
580       ,p_pon_attribute22                =>  p_pon_attribute22
581       ,p_pon_attribute23                =>  p_pon_attribute23
582       ,p_pon_attribute24                =>  p_pon_attribute24
583       ,p_pon_attribute25                =>  p_pon_attribute25
584       ,p_pon_attribute26                =>  p_pon_attribute26
585       ,p_pon_attribute27                =>  p_pon_attribute27
586       ,p_pon_attribute28                =>  p_pon_attribute28
587       ,p_pon_attribute29                =>  p_pon_attribute29
588       ,p_pon_attribute30                =>  p_pon_attribute30
589       ,p_object_version_number          =>  l_object_version_number
590       ,p_effective_date                     => trunc(p_effective_date)
591       ,p_datetrack_mode                     => p_datetrack_mode
592       );
593   exception
594     when hr_api.cannot_find_prog_unit then
595       hr_api.cannot_find_prog_unit_error
596         (p_module_name => 'UPDATE_plan_type_option_type'
597         ,p_hook_type   => 'AP'
598         );
599     --
600     -- End of API User Hook for the after hook of update_plan_type_option_type
601     --
602   end;
603   --
604   hr_utility.set_location(l_proc, 60);
605   -- when the  plan type is CWB and  the group_id is null then
606   -- update the group  id
607   open c_ptp ;
608   fetch c_ptp into l_opt_typ_cd ;
609   close c_ptp ;
610   hr_utility.set_location('OPT TYP CD '|| l_opt_typ_cd , 60);
611   if l_opt_typ_cd = 'CWB' then
612      open c_opt ;
613      fetch c_opt
614       into l_group_opt_id ,
615             l_opt_ovn ;
616      close c_opt ;
617      hr_utility.set_location(' l_group_opt_id '||  l_group_opt_id , 60);
618      if l_group_opt_id is null then
619          BEN_option_definition_API.update_option_definition
620                            (p_validate => FALSE
621                            ,p_OPT_ID => p_opt_id
622                            ,p_EFFECTIVE_START_DATE => l_eff_st_dt
623                            ,p_EFFECTIVE_END_DATE   => l_eff_end_dt
624                            ,p_group_opt_id         =>  p_opt_id
625                            ,p_OBJECT_VERSION_NUMBER=> l_opt_ovn
626                            ,p_effective_date       => p_effective_date
627                            ,p_datetrack_mode =>  'CORRECTION'
628                           );
629      end if ;
630   end if ;
631 
632 
633 
634 
635 
636   -- When in validation only mode raise the Validate_Enabled exception
637   --
638   if p_validate then
639     raise hr_api.validate_enabled;
640   end if;
641   --
642   -- Set all output arguments
643   --
644   p_object_version_number := l_object_version_number;
645   p_effective_start_date := l_effective_start_date;
646   p_effective_end_date := l_effective_end_date;
647   --
648   hr_utility.set_location(' Leaving:'||l_proc, 70);
649   --
650 exception
651   --
652   when hr_api.validate_enabled then
653     --
654     -- As the Validate_Enabled exception has been raised
655     -- we must rollback to the savepoint
656     --
657     ROLLBACK TO update_plan_type_option_type;
658     --
659     -- Only set output warning arguments
660     -- (Any key or derived arguments must be set to null
661     -- when validation only mode is being used.)
662     --
663     hr_utility.set_location(' Leaving:'||l_proc, 80);
664     --
665   when others then
666     --
667     -- A validation or unexpected error has occured
668     --
669     ROLLBACK TO update_plan_type_option_type;
670     /* Inserted for nocopy changes */
671     p_object_version_number := l_object_version_number;
672     p_effective_start_date := null;
673     p_effective_end_date := null;
674     raise;
675     --
676 end update_plan_type_option_type;
677 -- ----------------------------------------------------------------------------
678 -- |------------------------< delete_plan_type_option_type >----------------------|
679 -- ----------------------------------------------------------------------------
680 --
681 procedure delete_plan_type_option_type
682   (p_validate                       in  boolean  default false
683   ,p_pl_typ_opt_typ_id              in  number
684   ,p_effective_start_date           out nocopy date
685   ,p_effective_end_date             out nocopy date
686   ,p_object_version_number          in out nocopy number
687   ,p_effective_date                 in  date
688   ,p_datetrack_mode                 in  varchar2
689   ) is
690   --
691   -- Declare cursors and local variables
692   --
693     cursor c1 is
694   	select opt.opt_id, opt.object_version_number
695 	from ben_pl_typ_opt_typ_f pon, ben_opt_f opt
696 	where pon.opt_id = opt.opt_id
697 	and pon.pl_typ_opt_typ_id = p_pl_typ_opt_typ_id
698 	and p_effective_date between pon.effective_start_date and pon.effective_end_date
699 	and p_effective_date between opt.effective_start_date and opt.effective_end_date;
700   --
701   cursor c2 (p_opt_id in number) is
702 	select count(*)
703 	from ben_pl_typ_opt_typ_f
704 	where pl_typ_opt_typ_cd = 'CWB'
705 	and opt_id = p_opt_id
706 	and p_effective_date between effective_start_date and effective_end_date;
707   --
708   l_opt_id number;
709   l_count_cwb_pl_typ number;
710   l_opt_OVN number;
711   --
712   l_proc varchar2(72) := g_package||'update_plan_type_option_type';
713   l_object_version_number ben_pl_typ_opt_typ_f.object_version_number%TYPE;
714   l_effective_start_date ben_pl_typ_opt_typ_f.effective_start_date%TYPE;
715   l_effective_end_date ben_pl_typ_opt_typ_f.effective_end_date%TYPE;
716   --
717 begin
718   --
719   hr_utility.set_location('Entering:'|| l_proc, 10);
720   --
721   -- Issue a savepoint if operating in validation only mode
722   --
723   savepoint delete_plan_type_option_type;
724   --
725   hr_utility.set_location(l_proc, 20);
726   --
727   -- Process Logic
728   --
729   l_object_version_number := p_object_version_number;
730   --
731   --Bug : 3453791
732   open c1;
733   fetch c1 into l_opt_id, l_opt_OVN;
734   close c1;
735   --Bug : 3453791
736   --
737   begin
738     --
739     -- Start of API User Hook for the before hook of delete_plan_type_option_type
740     --
741     ben_plan_type_option_type_bk3.delete_plan_type_option_type_b
742       (
743        p_pl_typ_opt_typ_id              =>  p_pl_typ_opt_typ_id
744       ,p_object_version_number          =>  p_object_version_number
745     ,p_effective_date                      => trunc(p_effective_date)
746     ,p_datetrack_mode                      => p_datetrack_mode
747       );
748   exception
749     when hr_api.cannot_find_prog_unit then
750       hr_api.cannot_find_prog_unit_error
751         (p_module_name => 'DELETE_plan_type_option_type'
752         ,p_hook_type   => 'BP'
753         );
754     --
755     -- End of API User Hook for the before hook of delete_plan_type_option_type
756     --
757   end;
758   --
759   ben_pon_del.del
760     (
761      p_pl_typ_opt_typ_id             => p_pl_typ_opt_typ_id
762     ,p_effective_start_date          => l_effective_start_date
763     ,p_effective_end_date            => l_effective_end_date
764     ,p_object_version_number         => l_object_version_number
765     ,p_effective_date                => p_effective_date
766     ,p_datetrack_mode                => p_datetrack_mode
767     );
768   --
769   begin
770     --
771     -- Start of API User Hook for the after hook of delete_plan_type_option_type
772     --
773     ben_plan_type_option_type_bk3.delete_plan_type_option_type_a
774       (
775        p_pl_typ_opt_typ_id              =>  p_pl_typ_opt_typ_id
776       ,p_effective_start_date           =>  l_effective_start_date
777       ,p_effective_end_date             =>  l_effective_end_date
778       ,p_object_version_number          =>  l_object_version_number
779     ,p_effective_date                      => trunc(p_effective_date)
780     ,p_datetrack_mode                      => p_datetrack_mode
781       );
782   exception
783     when hr_api.cannot_find_prog_unit then
784       hr_api.cannot_find_prog_unit_error
785         (p_module_name => 'DELETE_plan_type_option_type'
786         ,p_hook_type   => 'AP'
787         );
788     --
789     -- End of API User Hook for the after hook of delete_plan_type_option_type
790     --
791   end;
792   --
793   hr_utility.set_location(l_proc, 60);
794   --
795   -- When in validation only mode raise the Validate_Enabled exception
796   --
797   if p_validate then
798     raise hr_api.validate_enabled;
799   end if;
800   --
801   --
802   --Bug : 3453791
803   --
804   open c2(l_opt_id);
805   fetch c2 into l_count_cwb_pl_typ;
806   close c2;
807   --
808   if l_count_cwb_pl_typ = 0 then
809   -- If the plan type being deleted is the last CWB plan type associated with the option
810   -- then make group_option_id in ben_opt_f as null
811   --
812 	update ben_opt_f
813 	set group_opt_id = null
814 	where opt_id = l_opt_id
815 	and p_effective_date between effective_start_date and effective_end_date;
816   end if;
817   --
818   --Bug : 3453791
819   --
820   hr_utility.set_location(' Leaving:'||l_proc, 70);
821   --
822 exception
823   --
824   when hr_api.validate_enabled then
825     --
826     -- As the Validate_Enabled exception has been raised
827     -- we must rollback to the savepoint
828     --
829     ROLLBACK TO delete_plan_type_option_type;
830     --
831     -- Only set output warning arguments
832     -- (Any key or derived arguments must be set to null
833     -- when validation only mode is being used.)
834     --
835     p_effective_start_date := null;
836     p_effective_end_date := null;
837     --
838   when others then
839     --
840     -- A validation or unexpected error has occured
841     --
842     ROLLBACK TO delete_plan_type_option_type;
843     /* Inserted for nocopy changes */
844     p_object_version_number := l_object_version_number;
845     p_effective_start_date := null;
846     p_effective_end_date := null;
847     raise;
848     --
849 end delete_plan_type_option_type;
850 --
851 -- ----------------------------------------------------------------------------
852 -- |-------------------------------< lck >------------------------------------|
853 -- ----------------------------------------------------------------------------
854 --
855 procedure lck
856   (
857    p_pl_typ_opt_typ_id                   in     number
858   ,p_object_version_number          in     number
859   ,p_effective_date                 in     date
860   ,p_datetrack_mode                 in     varchar2
861   ,p_validation_start_date          out nocopy    date
862   ,p_validation_end_date            out nocopy    date
863   ) is
864   --
865   --
866   -- Declare cursors and local variables
867   --
868   l_proc varchar2(72) := g_package||'lck';
869   l_validation_start_date date;
870   l_validation_end_date date;
871   --
872 begin
873   --
874   hr_utility.set_location('Entering:'|| l_proc, 10);
875   --
876   ben_pon_shd.lck
877     (
878       p_pl_typ_opt_typ_id                 => p_pl_typ_opt_typ_id
879      ,p_validation_start_date      => l_validation_start_date
880      ,p_validation_end_date        => l_validation_end_date
881      ,p_object_version_number      => p_object_version_number
882      ,p_effective_date             => p_effective_date
883      ,p_datetrack_mode             => p_datetrack_mode
884     );
885   --
886   hr_utility.set_location(' Leaving:'||l_proc, 70);
887   --
888 end lck;
889 --
890 end ben_plan_type_option_type_api;