DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_COLLECTIVE_AGREEMENT_API

Source


1 Package Body hr_collective_agreement_api as
2 /* $Header: hrcagapi.pkb 120.3 2008/04/03 09:48:25 brsinha noship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(33) := '  hr_collective_agreement_api.';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |-----------------------------< check_plan_years >-------------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 -- Description:
13 --
14 --   This procedure will check that there are 10 years of plan years on the
15 --   system, from the effective date. If there are not then this procedure
16 --   will create plans years by using the Benefits Plan Years API.
17 --
18 -- Prerequisites:
19 --   This is a private function and can only be called from the api.
20 --
21 -- In Parameters:
22 --
23 --   effective date
24 --   business group id
25 --   start of year date (01-JAN-XX)
26 --   end of year date (31-DEC-XX)
27 --   ten year date (Effective Date + 10 Years)
28 --
29 -- Post Success:
30 --   10 years worth of PLan Years exist on system.
31 --
32 -- Post Failure:
33 --   If the process fails a error message will be raised.
34 --
35 -- Developer Implementation Notes:
36 --   None.
37 --
38 -- Access Status:
39 --   Internal Development Use Only.
40 --
41 -- ----------------------------------------------------------------------------
42 --
43 PROCEDURE check_plan_years
44   (p_effective_date    IN DATE
45   ,p_business_group_id IN NUMBER
46   ,p_start_of_year     IN DATE
47   ,p_end_of_year       IN DATE
48   ,p_ten_year_date     IN DATE) IS
49   --
50   -- Delcare Local Variables
51   --
52   l_proc              VARCHAR2(72) := g_package||'check_plan_years';
53   l_start_of_year     DATE;
54   l_end_of_year       DATE;
55   l_pln_yr_start_date DATE;
56   l_pln_yr_end_date   DATE;
57   l_effective_date    DATE;
58   l_yr_perd_id       NUMBER;
59   l_yr_perd_ovn       NUMBER;
60   --
61   CURSOR csr_get_plan_years IS
62     SELECT start_date,
63 	       end_date
64 	  FROM ben_yr_perd
65 	 WHERE start_date = l_start_of_year
66 	   AND end_date   = l_end_of_year
67 	   AND business_group_id  = p_business_group_id;  --Bug fix:3648527
68   --
69 BEGIN
70   --
71   hr_utility.set_location('Entering : '||l_proc, 10);
72   --
73   l_effective_date := TRUNC(p_effective_Date);
74   l_start_of_year  := p_start_of_year;
75   l_end_of_year    := p_end_of_year;
76   --
77   WHILE l_end_of_year <= p_ten_year_date LOOP
78     --
79    	hr_utility.set_location(l_proc,20);
80 	   --
81 	   OPEN  csr_get_plan_years;
82 	   FETCH csr_get_plan_years INTO l_pln_yr_start_date,l_pln_yr_end_date;
83 	   --
84 	   IF csr_get_plan_years%NOTFOUND THEN
85 	     --
86 	     CLOSE csr_get_plan_years;
87 	     --
88 	     hr_utility.set_location(l_proc,30);
89 	     --
90 	     BEN_pgm_or_pl_yr_perd_API.create_pgm_or_pl_yr_perd
91         (p_validate              => FALSE
92         ,p_yr_perd_id            => l_yr_perd_id
93         ,p_perd_typ_cd           => 'CLNDR'
94         ,p_end_date              => l_end_of_year
95         ,p_start_date            => l_start_of_year
96         ,p_business_group_id     => p_business_group_id
97         ,p_object_version_number => l_yr_perd_ovn
98         ,p_effective_date        => l_effective_Date);
99       --
100    	ELSE
101 	     --
102    	  CLOSE csr_get_plan_years;
103 	     --
104 	   END IF;
105 	   --
106 	   -- Add 1 year to the start and end dates
107 	   --
108 	   l_start_of_year := ADD_MONTHS(l_start_of_year,12);
109 	   l_end_of_year   := ADD_MONTHS(l_end_of_year,12);
110 	   --
111   END LOOP;
112   --
113   hr_utility.set_location('Leaving :'|| l_proc, 999);
114   --
115 END check_plan_years;
116 --
117 -- ----------------------------------------------------------------------------
118 -- |----------------------------< attach_plan_years >-------------------------|
119 -- ----------------------------------------------------------------------------
120 --
121 -- Description:
122 --
123 --   This procedure will attach plan years to the plan created for the
124 --   collective agreement.
125 --
126 -- Prerequisites:
127 --   This is a private function and can only be called from the api.
128 --
129 -- In Parameters:
130 --
131 --   effective date
132 --   business group id
133 --   plan id
134 --
135 -- Post Success:
136 --   Plan Years attached to plan.
137 --
138 -- Post Failure:
139 --   If the process fails a error message will be raised.
140 --
141 -- Developer Implementation Notes:
142 --   None.
143 --
144 -- Access Status:
145 --   Internal Development Use Only.
146 --
147 -- ----------------------------------------------------------------------------
148 --
149 PROCEDURE attach_plan_years
150   (p_effective_date    IN DATE
151   ,p_business_group_id IN NUMBER
152   ,p_pl_id             IN NUMBER) IS
153   --
154   -- Delcare Local Variables
155   --
156   l_proc              VARCHAR2(72) := g_package||'attach_plan_years';
157   l_start_of_year     DATE;
158   l_end_of_year       DATE;
159   l_ten_year_date     DATE;
160   l_effective_date    DATE;
161   l_order_number      NUMBER;
162   l_popl_yr_perd_id   NUMBER;
163   l_pln_yr_ovn        NUMBER;
164   --
165   -- Declare Cursors
166   --
167   CURSOR csr_get_plan_years IS
168     SELECT yr_perd_id,
169 	   TRUNC(start_date) start_date,
170 	   TRUNC(end_date) end_date
171       FROM ben_yr_perd
172      WHERE business_group_id  = p_business_group_id  --Bug fix:3648527
173        AND end_date            <= l_ten_year_date
174      ORDER BY start_date ASC;
175   --
176 BEGIN
177  --
178 	hr_utility.set_location(l_proc, 40);
179  --
180 	l_order_number := 10;
181 	--
182 	l_effective_date := TRUNC(p_effective_date);
183 	--
184  l_start_of_year := trunc(l_effective_date,'YEAR');
185  l_end_of_year   := LAST_DAY(ADD_MONTHS(trunc(l_effective_date,'YEAR'),11));
186  l_ten_year_date := LAST_DAY(ADD_MONTHS(trunc(l_effective_date,'YEAR'),1190));
187  --
188 	-- Check to see if plan years exist for the next 100 years.
189 	-- If they do not then this procedure will create them.
190 	--
191 	check_plan_years(p_effective_date    => l_effective_date
192 	                ,p_business_group_id => p_business_group_id
193 				            	,p_start_of_year     => l_start_of_year
194 					            ,p_end_of_year       => l_end_of_year
195 					            ,p_ten_year_date     => l_ten_year_date);
196 	--
197  hr_utility.set_location(l_proc||'/'||l_start_of_year,50);
198 	hr_utility.set_location(l_proc||'/'||l_end_of_year,51);
199 	hr_utility.set_location(l_proc||'/'||l_ten_year_date,52);
200 	--
201 	-- Loop round all the plan years for the next 100 years
202 	--
203 	FOR csr_rec IN csr_get_plan_years LOOP
204 	  --
205 	  hr_utility.set_location(l_proc||'/'||csr_rec.yr_perd_id, 60);
206 	  hr_utility.set_location(l_proc||'/'||csr_rec.start_date,61);
207 	  hr_utility.set_location(l_proc||'/'||csr_rec.end_date,62);
208 	  --
209 	  -- If the plan year start and end dates match
210 	  -- the beginning and end of the year then attach them
211 	  -- to the plan.
212 	  --
213 	  IF csr_rec.start_date = l_start_of_year AND
214 	     csr_rec.end_date = l_end_of_year THEN
215 	    --
216 		   ben_popl_yr_perd_api.create_popl_yr_perd
217 	      (p_validate                    => FALSE
218 	      ,p_popl_yr_perd_id             => l_popl_yr_perd_id
219 	      ,p_yr_perd_id                  => csr_rec.yr_perd_id
220        ,p_business_group_id           => p_business_group_id
221 	      ,p_pl_id                       => p_pl_id
222 	      ,p_ordr_num                    => l_order_number
223   	    ,p_object_version_number       => l_pln_yr_ovn);
224 	    --
225 	    l_order_number := l_order_number + 10;
226 	   	--
227 	    -- Add 1 year to the start and end dates
228 	    --
229 	    l_start_of_year := ADD_MONTHS(l_start_of_year,12);
230 	    l_end_of_year   := ADD_MONTHS(l_end_of_year,12);
231 	    --
232    END IF;
233    --
234  END LOOP;
235  --
236 END attach_plan_years;
237 --
238 -- ----------------------------------------------------------------------------
239 -- |------------------------< create_collective_agreement >----------------------|
240 -- ----------------------------------------------------------------------------
241 --
242 procedure create_collective_agreement
243   (p_validate                       in  boolean   default false
244   ,p_collective_agreement_id        out nocopy number
245   ,p_effective_date                 in  date
246   ,p_business_group_id              in  number
247   ,p_object_version_number          out nocopy number
248   ,p_name                           in  varchar2
249   ,p_status                         in  varchar2
250   ,p_cag_number                     in  number    default null
251   ,p_description                    in  varchar2  default null
252   ,p_end_date                       in  date      default null
253   ,p_employer_organization_id       in  number    default null
254   ,p_employer_signatory             in  varchar2  default null
255   ,p_bargaining_organization_id     in  number    default null
256   ,p_bargaining_unit_signatory      in  varchar2  default null
257   ,p_jurisdiction                   in  varchar2  default null
258   ,p_authorizing_body               in  varchar2  default null
259   ,p_authorized_date                in  date      default null
260   ,p_cag_information_category       in  varchar2  default null
261   ,p_cag_information1               in  varchar2  default null
262   ,p_cag_information2               in  varchar2  default null
263   ,p_cag_information3               in  varchar2  default null
264   ,p_cag_information4               in  varchar2  default null
265   ,p_cag_information5               in  varchar2  default null
266   ,p_cag_information6               in  varchar2  default null
267   ,p_cag_information7               in  varchar2  default null
268   ,p_cag_information8               in  varchar2  default null
269   ,p_cag_information9               in  varchar2  default null
270   ,p_cag_information10              in  varchar2  default null
271   ,p_cag_information11              in  varchar2  default null
272   ,p_cag_information12              in  varchar2  default null
273   ,p_cag_information13              in  varchar2  default null
274   ,p_cag_information14              in  varchar2  default null
275   ,p_cag_information15              in  varchar2  default null
276   ,p_cag_information16              in  varchar2  default null
277   ,p_cag_information17              in  varchar2  default null
278   ,p_cag_information18              in  varchar2  default null
279   ,p_cag_information19              in  varchar2  default null
280   ,p_cag_information20              in  varchar2  default null
281   ,p_attribute_category             in  varchar2  default null
282   ,p_attribute1                     in  varchar2  default null
283   ,p_attribute2                     in  varchar2  default null
284   ,p_attribute3                     in  varchar2  default null
285   ,p_attribute4                     in  varchar2  default null
286   ,p_attribute5                     in  varchar2  default null
287   ,p_attribute6                     in  varchar2  default null
288   ,p_attribute7                     in  varchar2  default null
289   ,p_attribute8                     in  varchar2  default null
290   ,p_attribute9                     in  varchar2  default null
291   ,p_attribute10                    in  varchar2  default null
292   ,p_attribute11                    in  varchar2  default null
293   ,p_attribute12                    in  varchar2  default null
294   ,p_attribute13                    in  varchar2  default null
295   ,p_attribute14                    in  varchar2  default null
296   ,p_attribute15                    in  varchar2  default null
297   ,p_attribute16                    in  varchar2  default null
298   ,p_attribute17                    in  varchar2  default null
299   ,p_attribute18                    in  varchar2  default null
300   ,p_attribute19                    in  varchar2  default null
301   ,p_attribute20                    in  varchar2  default null
302   ) is
303   --
304   -- Declare cursors and local variables
305   --
306   l_collective_agreement_id per_collective_agreements.collective_agreement_id%TYPE;
307   l_proc varchar2(72) := g_package||'create_collective_agreement';
308   l_object_version_number per_collective_agreements.object_version_number%TYPE;
309   --
310   l_pl_id                NUMBER;
311   l_pl_ovn               NUMBER;
312   l_effective_date       DATE;
313   l_start_date           DATE;
314   l_effective_start_date DATE;
315   l_effective_end_date   DATE;
316   l_pl_typ_id            NUMBER;
317   l_pl_typ_ovn           NUMBER;
318   --
319   CURSOR csr_get_plan_type IS
320     SELECT pl_typ_id
321       FROM ben_pl_typ_f
322      WHERE name = 'Collective Agreement Plan Type'
323 	   AND business_group_id = p_business_group_id
324        AND l_effective_date BETWEEN effective_start_date
325                                 AND effective_end_date;
326   --
327 BEGIN
328   --
329   hr_utility.set_location('Entering:'|| l_proc, 10);
330   --
331   -- Issue a savepoint if operating in validation only mode
332   --
333   savepoint create_collective_agreement;
334   --
335   hr_utility.set_location(l_proc, 20);
336   --
337   --Truncate Date Parameters
338   --
339   l_effective_date := TRUNC(p_effective_date);
340   l_start_Date     := l_effective_Date;
341   --
342   -- Process Logic
343   --
344   begin
345     --
346     -- Start of API User Hook for the before hook of create_collective_agreement
347     --
348     hr_collective_agreement_bk1.create_collective_agreement_b
349       (p_business_group_id              =>  p_business_group_id
350       ,p_name                           =>  p_name
351 	  ,p_status                         =>  p_status
352       ,p_cag_number                     =>  p_cag_number
353       ,p_description                    =>  p_description
354       ,p_start_date                     =>  l_start_date
355       ,p_end_date                       =>  p_end_date
356       ,p_employer_organization_id       =>  p_employer_organization_id
357       ,p_employer_signatory             =>  p_employer_signatory
358       ,p_bargaining_organization_id     =>  p_bargaining_organization_id
359       ,p_bargaining_unit_signatory      =>  p_bargaining_unit_signatory
360       ,p_jurisdiction                   =>  p_jurisdiction
361       ,p_authorizing_body               =>  p_authorizing_body
362       ,p_authorized_date                =>  p_authorized_date
363       ,p_cag_information_category       =>  p_cag_information_category
364       ,p_cag_information1               =>  p_cag_information1
365       ,p_cag_information2               =>  p_cag_information2
366       ,p_cag_information3               =>  p_cag_information3
367       ,p_cag_information4               =>  p_cag_information4
368       ,p_cag_information5               =>  p_cag_information5
369       ,p_cag_information6               =>  p_cag_information6
370       ,p_cag_information7               =>  p_cag_information7
371       ,p_cag_information8               =>  p_cag_information8
372       ,p_cag_information9               =>  p_cag_information9
373       ,p_cag_information10              =>  p_cag_information10
374       ,p_cag_information11              =>  p_cag_information11
375       ,p_cag_information12              =>  p_cag_information12
376       ,p_cag_information13              =>  p_cag_information13
377       ,p_cag_information14              =>  p_cag_information14
378       ,p_cag_information15              =>  p_cag_information15
379       ,p_cag_information16              =>  p_cag_information16
380       ,p_cag_information17              =>  p_cag_information17
381       ,p_cag_information18              =>  p_cag_information18
382       ,p_cag_information19              =>  p_cag_information19
383       ,p_cag_information20              =>  p_cag_information20
384       ,p_attribute_category             =>  p_attribute_category
385       ,p_attribute1                     =>  p_attribute1
386       ,p_attribute2                     =>  p_attribute2
387       ,p_attribute3                     =>  p_attribute3
388       ,p_attribute4                     =>  p_attribute4
389       ,p_attribute5                     =>  p_attribute5
390       ,p_attribute6                     =>  p_attribute6
391       ,p_attribute7                     =>  p_attribute7
392       ,p_attribute8                     =>  p_attribute8
393       ,p_attribute9                     =>  p_attribute9
394       ,p_attribute10                    =>  p_attribute10
395       ,p_attribute11                    =>  p_attribute11
396       ,p_attribute12                    =>  p_attribute12
397       ,p_attribute13                    =>  p_attribute13
398       ,p_attribute14                    =>  p_attribute14
399       ,p_attribute15                    =>  p_attribute15
400       ,p_attribute16                    =>  p_attribute16
401       ,p_attribute17                    =>  p_attribute17
402       ,p_attribute18                    =>  p_attribute18
403       ,p_attribute19                    =>  p_attribute19
404       ,p_attribute20                    =>  p_attribute20
405       );
406   exception
407     when hr_api.cannot_find_prog_unit then
408       hr_api.cannot_find_prog_unit_error
409         (
410          p_module_name => 'CREATE_collective_agreement'
411         ,p_hook_type   => 'BP'
412         );
413     --
414     -- End of API User Hook for the before hook of create_collective_agreement
415     --
416   end;
417   --
418   -- Create a Plan for the Collective Agreement.
419   --
420   BEGIN
421     --
422 	hr_utility.set_location(l_proc, 30);
423 	--
424     OPEN  csr_get_plan_type;
425 	FETCH csr_get_plan_type INTO l_pl_typ_id;
426 	--
427 	-- Check to see if the Collective Agreement Plan Type exists
428 	-- if it does not then call the BEN Api's that will create
429 	-- a plan type.
430 	--
431 	IF csr_get_plan_type%NOTFOUND THEN
432 	  --
433 	  CLOSE csr_get_plan_type;
434 	  --
435 	  -- Create the plan type uses 01-JAN-1951 as the effective date.
436 	  -- This has been done so that we can create a plan that starts as early
437 	  -- as possible. The start_of_time was not used as the BEN lookups all
438 	  -- start from the 01-JAN-1951 so the create would fail if we used the
439 	  -- start of time.
440 	  --
441 	  ben_plan_type_api.create_plan_type
442         (p_validate                       => p_validate
443         ,p_pl_typ_id                      => l_pl_typ_id
444         ,p_effective_start_date           => l_effective_start_date
445         ,p_effective_end_date             => l_effective_end_date
446         ,p_name                           => 'Collective Agreement Plan Type'
447         ,p_opt_typ_cd                     => 'CAGR'
448 		,p_business_group_id              => p_business_group_id
449 		,p_no_mx_enrl_num_dfnd_flag       => 'N'
450         ,p_no_mn_enrl_num_dfnd_flag       => 'N'
451         ,p_object_version_number          => l_pl_typ_ovn
452         ,p_effective_date                 => TO_DATE('01-01-1951','DD-MM-YYYY'));
453 	  --
454 	  /*
455 	  hr_utility.set_message(800,'HR_289379_CAGR_PLAN_TYPE_INV');
456       hr_utility.raise_error; */
457 	--
458 	-- If a plan type already exists then just close the cursor
459 	--
460 	ELSE
461 	  --
462 	  CLOSE csr_get_plan_type;
463 	  --
464 	  hr_utility.set_location(l_proc, 35);
465 	  --
466 	END IF;
467    	--
468 	-- Create a Plan for the Collective Agreement
469 	--
470 	ben_plan_api.create_plan
471       (p_validate                     => p_validate
472       ,p_pl_id                        => l_pl_id
473       ,p_effective_start_date         => l_effective_start_date
474       ,p_effective_end_date           => l_effective_end_date
475       ,p_name                         => per_cagr_utility_pkg.plan_name
476       ,p_object_version_number        => l_pl_ovn
477       ,p_business_group_id            => p_business_group_id
478       ,p_effective_date               => l_effective_date
479 	  ,p_pl_typ_id                    => l_pl_typ_id
480 	  ,p_pl_cd                        => 'MYNTBPGM' -- May not be in a program,
481 	  ,p_pl_stat_cd                   => 'A');      -- Active);
482 	--
483     hr_utility.set_location(l_proc||'/'||l_pl_id, 40);
484 	--
485 	-- Once the plan has been created we need to attach the plan
486 	-- years to the plan. This procedure will firstly check that
487 	-- there are plan years available for the next 10 years. If
488 	-- there are not then plan years will be created. They then will
489 	-- be attached to the plan using the Benefit API.
490 	--
491 	attach_plan_years
492 	  (p_effective_date    => l_effective_date
493       ,p_business_group_id => p_business_group_id
494       ,p_pl_id             => l_pl_id);
495 	--
496   END;
497   --
498   per_cag_ins.ins
499     (p_collective_agreement_id       => l_collective_agreement_id
500     ,p_business_group_id             => p_business_group_id
501     ,p_object_version_number         => l_object_version_number
502     ,p_name                          => p_name
503 	,p_pl_id                         => l_pl_id
504 	,p_status                        => p_status
505     ,p_cag_number                    => p_cag_number
506     ,p_description                   => p_description
507     ,p_start_date                    => l_start_date
508     ,p_end_date                      => p_end_date
509     ,p_employer_organization_id      => p_employer_organization_id
510     ,p_employer_signatory            => p_employer_signatory
511     ,p_bargaining_organization_id    => p_bargaining_organization_id
512     ,p_bargaining_unit_signatory     => p_bargaining_unit_signatory
513     ,p_jurisdiction                  => p_jurisdiction
514     ,p_authorizing_body              => p_authorizing_body
515     ,p_authorized_date               => p_authorized_date
516     ,p_cag_information_category      => p_cag_information_category
517     ,p_cag_information1              => p_cag_information1
518     ,p_cag_information2              => p_cag_information2
519     ,p_cag_information3              => p_cag_information3
520     ,p_cag_information4              => p_cag_information4
521     ,p_cag_information5              => p_cag_information5
522     ,p_cag_information6              => p_cag_information6
523     ,p_cag_information7              => p_cag_information7
524     ,p_cag_information8              => p_cag_information8
525     ,p_cag_information9              => p_cag_information9
526     ,p_cag_information10             => p_cag_information10
527     ,p_cag_information11             => p_cag_information11
528     ,p_cag_information12             => p_cag_information12
529     ,p_cag_information13             => p_cag_information13
530     ,p_cag_information14             => p_cag_information14
531     ,p_cag_information15             => p_cag_information15
532     ,p_cag_information16             => p_cag_information16
533     ,p_cag_information17             => p_cag_information17
534     ,p_cag_information18             => p_cag_information18
535     ,p_cag_information19             => p_cag_information19
536     ,p_cag_information20             => p_cag_information20
537     ,p_attribute_category            => p_attribute_category
538     ,p_attribute1                    => p_attribute1
539     ,p_attribute2                    => p_attribute2
540     ,p_attribute3                    => p_attribute3
541     ,p_attribute4                    => p_attribute4
542     ,p_attribute5                    => p_attribute5
543     ,p_attribute6                    => p_attribute6
544     ,p_attribute7                    => p_attribute7
545     ,p_attribute8                    => p_attribute8
546     ,p_attribute9                    => p_attribute9
547     ,p_attribute10                   => p_attribute10
548     ,p_attribute11                   => p_attribute11
549     ,p_attribute12                   => p_attribute12
550     ,p_attribute13                   => p_attribute13
551     ,p_attribute14                   => p_attribute14
552     ,p_attribute15                   => p_attribute15
553     ,p_attribute16                   => p_attribute16
554     ,p_attribute17                   => p_attribute17
555     ,p_attribute18                   => p_attribute18
556     ,p_attribute19                   => p_attribute19
557     ,p_attribute20                   => p_attribute20
558     );
559   --
560   begin
561     --
562     -- Start of API User Hook for the after hook of create_collective_agreement
563     --
564     hr_collective_agreement_bk1.create_collective_agreement_a
565       (p_collective_agreement_id        =>  l_collective_agreement_id
566       ,p_business_group_id              =>  p_business_group_id
567       ,p_object_version_number          =>  l_object_version_number
568       ,p_name                           =>  p_name
569 	  ,p_status                         =>  p_status
570       ,p_cag_number                     =>  p_cag_number
571       ,p_description                    =>  p_description
572       ,p_start_date                     =>  l_start_date
573       ,p_end_date                       =>  p_end_date
574       ,p_employer_organization_id       =>  p_employer_organization_id
575       ,p_employer_signatory             =>  p_employer_signatory
576       ,p_bargaining_organization_id     =>  p_bargaining_organization_id
577       ,p_bargaining_unit_signatory      =>  p_bargaining_unit_signatory
578       ,p_jurisdiction                   =>  p_jurisdiction
579       ,p_authorizing_body               =>  p_authorizing_body
580       ,p_authorized_date                =>  p_authorized_date
581       ,p_cag_information_category       =>  p_cag_information_category
582       ,p_cag_information1               =>  p_cag_information1
583       ,p_cag_information2               =>  p_cag_information2
584       ,p_cag_information3               =>  p_cag_information3
585       ,p_cag_information4               =>  p_cag_information4
586       ,p_cag_information5               =>  p_cag_information5
587       ,p_cag_information6               =>  p_cag_information6
588       ,p_cag_information7               =>  p_cag_information7
589       ,p_cag_information8               =>  p_cag_information8
590       ,p_cag_information9               =>  p_cag_information9
591       ,p_cag_information10              =>  p_cag_information10
592       ,p_cag_information11              =>  p_cag_information11
593       ,p_cag_information12              =>  p_cag_information12
594       ,p_cag_information13              =>  p_cag_information13
595       ,p_cag_information14              =>  p_cag_information14
596       ,p_cag_information15              =>  p_cag_information15
597       ,p_cag_information16              =>  p_cag_information16
598       ,p_cag_information17              =>  p_cag_information17
599       ,p_cag_information18              =>  p_cag_information18
600       ,p_cag_information19              =>  p_cag_information19
601       ,p_cag_information20              =>  p_cag_information20
602       ,p_attribute_category             =>  p_attribute_category
603       ,p_attribute1                     =>  p_attribute1
604       ,p_attribute2                     =>  p_attribute2
605       ,p_attribute3                     =>  p_attribute3
606       ,p_attribute4                     =>  p_attribute4
607       ,p_attribute5                     =>  p_attribute5
608       ,p_attribute6                     =>  p_attribute6
609       ,p_attribute7                     =>  p_attribute7
610       ,p_attribute8                     =>  p_attribute8
611       ,p_attribute9                     =>  p_attribute9
612       ,p_attribute10                    =>  p_attribute10
613       ,p_attribute11                    =>  p_attribute11
614       ,p_attribute12                    =>  p_attribute12
615       ,p_attribute13                    =>  p_attribute13
616       ,p_attribute14                    =>  p_attribute14
617       ,p_attribute15                    =>  p_attribute15
618       ,p_attribute16                    =>  p_attribute16
619       ,p_attribute17                    =>  p_attribute17
620       ,p_attribute18                    =>  p_attribute18
621       ,p_attribute19                    =>  p_attribute19
622       ,p_attribute20                    =>  p_attribute20
623       );
624   exception
625     when hr_api.cannot_find_prog_unit then
626       hr_api.cannot_find_prog_unit_error
627         (p_module_name => 'CREATE_collective_agreement'
628         ,p_hook_type   => 'AP'
629         );
630     --
631     -- End of API User Hook for the after hook of create_collective_agreement
632     --
633   end;
634   --
635   hr_utility.set_location(l_proc, 60);
636   --
637   -- When in validation only mode raise the Validate_Enabled exception
638   --
639   if p_validate then
640     raise hr_api.validate_enabled;
641   end if;
642   --
643   -- Set all output arguments
644   --
645   p_collective_agreement_id := l_collective_agreement_id;
646   p_object_version_number := l_object_version_number;
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 create_collective_agreement;
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     p_collective_agreement_id := null;
664     p_object_version_number  := null;
665     hr_utility.set_location(' Leaving:'||l_proc, 80);
666     --
667   when others then
668     --
669     -- A validation or unexpected error has occured
670     --
671     -- Reset out params.Nocopy changes
672     p_collective_agreement_id := null;
673     p_object_version_number  := null;
674     ROLLBACK TO create_collective_agreement;
675     raise;
676     --
677 end create_collective_agreement;
678 -- ----------------------------------------------------------------------------
679 -- |------------------------< update_collective_agreement >--- ------------------|
680 -- ----------------------------------------------------------------------------
681 --
682 procedure update_collective_agreement
683   (p_validate                       in  boolean   default false
684   ,p_collective_agreement_id        in  number
685   ,p_business_group_id              in  number    default hr_api.g_number
686   ,p_object_version_number          in out nocopy number
687   ,p_name                           in  varchar2  default hr_api.g_varchar2
688   ,p_status                         in  varchar2  default hr_api.g_varchar2
689   ,p_cag_number                     in  number    default hr_api.g_number
690   ,p_description                    in  varchar2  default hr_api.g_varchar2
691   ,p_start_date                     in  date      default hr_api.g_date
692   ,p_end_date                       in  date      default hr_api.g_date
693   ,p_employer_organization_id       in  number    default hr_api.g_number
694   ,p_employer_signatory             in  varchar2  default hr_api.g_varchar2
695   ,p_bargaining_organization_id     in  number    default hr_api.g_number
696   ,p_bargaining_unit_signatory      in  varchar2  default hr_api.g_varchar2
697   ,p_jurisdiction                   in  varchar2  default hr_api.g_varchar2
698   ,p_authorizing_body               in  varchar2  default hr_api.g_varchar2
699   ,p_authorized_date                in  date      default hr_api.g_date
700   ,p_cag_information_category       in  varchar2  default hr_api.g_varchar2
701   ,p_cag_information1               in  varchar2  default hr_api.g_varchar2
702   ,p_cag_information2               in  varchar2  default hr_api.g_varchar2
703   ,p_cag_information3               in  varchar2  default hr_api.g_varchar2
704   ,p_cag_information4               in  varchar2  default hr_api.g_varchar2
705   ,p_cag_information5               in  varchar2  default hr_api.g_varchar2
706   ,p_cag_information6               in  varchar2  default hr_api.g_varchar2
707   ,p_cag_information7               in  varchar2  default hr_api.g_varchar2
708   ,p_cag_information8               in  varchar2  default hr_api.g_varchar2
709   ,p_cag_information9               in  varchar2  default hr_api.g_varchar2
710   ,p_cag_information10              in  varchar2  default hr_api.g_varchar2
711   ,p_cag_information11              in  varchar2  default hr_api.g_varchar2
712   ,p_cag_information12              in  varchar2  default hr_api.g_varchar2
713   ,p_cag_information13              in  varchar2  default hr_api.g_varchar2
714   ,p_cag_information14              in  varchar2  default hr_api.g_varchar2
715   ,p_cag_information15              in  varchar2  default hr_api.g_varchar2
716   ,p_cag_information16              in  varchar2  default hr_api.g_varchar2
717   ,p_cag_information17              in  varchar2  default hr_api.g_varchar2
718   ,p_cag_information18              in  varchar2  default hr_api.g_varchar2
719   ,p_cag_information19              in  varchar2  default hr_api.g_varchar2
720   ,p_cag_information20              in  varchar2  default hr_api.g_varchar2
721   ,p_attribute_category             in  varchar2  default hr_api.g_varchar2
722   ,p_attribute1                     in  varchar2  default hr_api.g_varchar2
723   ,p_attribute2                     in  varchar2  default hr_api.g_varchar2
724   ,p_attribute3                     in  varchar2  default hr_api.g_varchar2
725   ,p_attribute4                     in  varchar2  default hr_api.g_varchar2
726   ,p_attribute5                     in  varchar2  default hr_api.g_varchar2
727   ,p_attribute6                     in  varchar2  default hr_api.g_varchar2
728   ,p_attribute7                     in  varchar2  default hr_api.g_varchar2
729   ,p_attribute8                     in  varchar2  default hr_api.g_varchar2
730   ,p_attribute9                     in  varchar2  default hr_api.g_varchar2
731   ,p_attribute10                    in  varchar2  default hr_api.g_varchar2
732   ,p_attribute11                    in  varchar2  default hr_api.g_varchar2
733   ,p_attribute12                    in  varchar2  default hr_api.g_varchar2
734   ,p_attribute13                    in  varchar2  default hr_api.g_varchar2
735   ,p_attribute14                    in  varchar2  default hr_api.g_varchar2
736   ,p_attribute15                    in  varchar2  default hr_api.g_varchar2
737   ,p_attribute16                    in  varchar2  default hr_api.g_varchar2
738   ,p_attribute17                    in  varchar2  default hr_api.g_varchar2
739   ,p_attribute18                    in  varchar2  default hr_api.g_varchar2
740   ,p_attribute19                    in  varchar2  default hr_api.g_varchar2
741   ,p_attribute20                    in  varchar2  default hr_api.g_varchar2
742   ) is
743   --
744   -- Declare cursors and local variables
745   --
746   l_proc varchar2(72) := g_package||'update_collective_agreement';
747   l_object_version_number per_collective_agreements.object_version_number%TYPE;
748   l_temp_ovn    number;
749   --
750 begin
751   --
752   hr_utility.set_location('Entering:'|| l_proc, 10);
753   --
754   -- Issue a savepoint if operating in validation only mode
755   --
756   savepoint update_collective_agreement;
757   --
758   hr_utility.set_location(l_proc, 20);
759   --
760   -- Process Logic
761   --
762   l_object_version_number := p_object_version_number;
763   l_temp_ovn              := p_object_version_number;
764   --
765   begin
766     --
767     -- Start of API User Hook for the before hook of update_collective_agreement
768     --
769     hr_collective_agreement_bk2.update_collective_agreement_b
770       (
771        p_collective_agreement_id        =>  p_collective_agreement_id
772       ,p_business_group_id              =>  p_business_group_id
773       ,p_object_version_number          =>  p_object_version_number
774       ,p_name                           =>  p_name
775 	  ,p_status                         =>  p_status
776       ,p_cag_number                     =>  p_cag_number
777       ,p_description                    =>  p_description
778       ,p_start_date                     =>  p_start_date
779       ,p_end_date                       =>  p_end_date
780       ,p_employer_organization_id       =>  p_employer_organization_id
781       ,p_employer_signatory             =>  p_employer_signatory
782       ,p_bargaining_organization_id     =>  p_bargaining_organization_id
783       ,p_bargaining_unit_signatory      =>  p_bargaining_unit_signatory
784       ,p_jurisdiction                   =>  p_jurisdiction
785       ,p_authorizing_body               =>  p_authorizing_body
786       ,p_authorized_date                =>  p_authorized_date
787       ,p_cag_information_category       =>  p_cag_information_category
788       ,p_cag_information1               =>  p_cag_information1
789       ,p_cag_information2               =>  p_cag_information2
790       ,p_cag_information3               =>  p_cag_information3
791       ,p_cag_information4               =>  p_cag_information4
792       ,p_cag_information5               =>  p_cag_information5
793       ,p_cag_information6               =>  p_cag_information6
794       ,p_cag_information7               =>  p_cag_information7
795       ,p_cag_information8               =>  p_cag_information8
796       ,p_cag_information9               =>  p_cag_information9
797       ,p_cag_information10              =>  p_cag_information10
798       ,p_cag_information11              =>  p_cag_information11
799       ,p_cag_information12              =>  p_cag_information12
800       ,p_cag_information13              =>  p_cag_information13
801       ,p_cag_information14              =>  p_cag_information14
802       ,p_cag_information15              =>  p_cag_information15
803       ,p_cag_information16              =>  p_cag_information16
804       ,p_cag_information17              =>  p_cag_information17
805       ,p_cag_information18              =>  p_cag_information18
806       ,p_cag_information19              =>  p_cag_information19
807       ,p_cag_information20              =>  p_cag_information20
808       ,p_attribute_category             =>  p_attribute_category
809       ,p_attribute1                     =>  p_attribute1
810       ,p_attribute2                     =>  p_attribute2
811       ,p_attribute3                     =>  p_attribute3
812       ,p_attribute4                     =>  p_attribute4
813       ,p_attribute5                     =>  p_attribute5
814       ,p_attribute6                     =>  p_attribute6
815       ,p_attribute7                     =>  p_attribute7
816       ,p_attribute8                     =>  p_attribute8
817       ,p_attribute9                     =>  p_attribute9
818       ,p_attribute10                    =>  p_attribute10
819       ,p_attribute11                    =>  p_attribute11
820       ,p_attribute12                    =>  p_attribute12
821       ,p_attribute13                    =>  p_attribute13
822       ,p_attribute14                    =>  p_attribute14
823       ,p_attribute15                    =>  p_attribute15
824       ,p_attribute16                    =>  p_attribute16
825       ,p_attribute17                    =>  p_attribute17
826       ,p_attribute18                    =>  p_attribute18
827       ,p_attribute19                    =>  p_attribute19
828       ,p_attribute20                    =>  p_attribute20
829       );
830   exception
831     when hr_api.cannot_find_prog_unit then
832       p_object_version_number := l_temp_ovn;
833       hr_api.cannot_find_prog_unit_error
834         (p_module_name => 'UPDATE_collective_agreement'
835         ,p_hook_type   => 'BP'
836         );
837     --
838     -- End of API User Hook for the before hook of update_collective_agreement
839     --
840   end;
841   --
842   per_cag_upd.upd
843     (
844      p_collective_agreement_id       => p_collective_agreement_id
845     ,p_business_group_id             => p_business_group_id
846     ,p_object_version_number         => l_object_version_number
847     ,p_name                          => p_name
848 	,p_status                    => p_status
849     ,p_cag_number                    => p_cag_number
850     ,p_description                   => p_description
851     ,p_start_date                    => p_start_date
852     ,p_end_date                      => p_end_date
853     ,p_employer_organization_id      => p_employer_organization_id
854     ,p_employer_signatory            => p_employer_signatory
855     ,p_bargaining_organization_id    => p_bargaining_organization_id
856     ,p_bargaining_unit_signatory     => p_bargaining_unit_signatory
857     ,p_jurisdiction                  => p_jurisdiction
858     ,p_authorizing_body              => p_authorizing_body
859     ,p_authorized_date               => p_authorized_date
860     ,p_cag_information_category      => p_cag_information_category
861     ,p_cag_information1              => p_cag_information1
862     ,p_cag_information2              => p_cag_information2
863     ,p_cag_information3              => p_cag_information3
864     ,p_cag_information4              => p_cag_information4
865     ,p_cag_information5              => p_cag_information5
866     ,p_cag_information6              => p_cag_information6
867     ,p_cag_information7              => p_cag_information7
868     ,p_cag_information8              => p_cag_information8
869     ,p_cag_information9              => p_cag_information9
870     ,p_cag_information10             => p_cag_information10
871     ,p_cag_information11             => p_cag_information11
872     ,p_cag_information12             => p_cag_information12
873     ,p_cag_information13             => p_cag_information13
874     ,p_cag_information14             => p_cag_information14
875     ,p_cag_information15             => p_cag_information15
876     ,p_cag_information16             => p_cag_information16
877     ,p_cag_information17             => p_cag_information17
878     ,p_cag_information18             => p_cag_information18
879     ,p_cag_information19             => p_cag_information19
880     ,p_cag_information20             => p_cag_information20
881     ,p_attribute_category            => p_attribute_category
882     ,p_attribute1                    => p_attribute1
883     ,p_attribute2                    => p_attribute2
884     ,p_attribute3                    => p_attribute3
885     ,p_attribute4                    => p_attribute4
886     ,p_attribute5                    => p_attribute5
887     ,p_attribute6                    => p_attribute6
888     ,p_attribute7                    => p_attribute7
889     ,p_attribute8                    => p_attribute8
890     ,p_attribute9                    => p_attribute9
891     ,p_attribute10                   => p_attribute10
892     ,p_attribute11                   => p_attribute11
893     ,p_attribute12                   => p_attribute12
894     ,p_attribute13                   => p_attribute13
895     ,p_attribute14                   => p_attribute14
896     ,p_attribute15                   => p_attribute15
897     ,p_attribute16                   => p_attribute16
898     ,p_attribute17                   => p_attribute17
899     ,p_attribute18                   => p_attribute18
900     ,p_attribute19                   => p_attribute19
901     ,p_attribute20                   => p_attribute20
902     );
903   --
904   begin
905     --
906     -- Start of API User Hook for the after hook of update_collective_agreement
907     --
908     hr_collective_agreement_bk2.update_collective_agreement_a
909       (
910        p_collective_agreement_id        =>  p_collective_agreement_id
911       ,p_business_group_id              =>  p_business_group_id
912       ,p_object_version_number          =>  l_object_version_number
913       ,p_name                           =>  p_name
914 	  ,p_status                         =>  p_status
915       ,p_cag_number                     =>  p_cag_number
916       ,p_description                    =>  p_description
917       ,p_start_date                     =>  p_start_date
918       ,p_end_date                       =>  p_end_date
919       ,p_employer_organization_id       =>  p_employer_organization_id
920       ,p_employer_signatory             =>  p_employer_signatory
921       ,p_bargaining_organization_id     =>  p_bargaining_organization_id
922       ,p_bargaining_unit_signatory      =>  p_bargaining_unit_signatory
923       ,p_jurisdiction                   =>  p_jurisdiction
924       ,p_authorizing_body               =>  p_authorizing_body
925       ,p_authorized_date                =>  p_authorized_date
926       ,p_cag_information_category       =>  p_cag_information_category
927       ,p_cag_information1               =>  p_cag_information1
928       ,p_cag_information2               =>  p_cag_information2
929       ,p_cag_information3               =>  p_cag_information3
930       ,p_cag_information4               =>  p_cag_information4
931       ,p_cag_information5               =>  p_cag_information5
932       ,p_cag_information6               =>  p_cag_information6
933       ,p_cag_information7               =>  p_cag_information7
934       ,p_cag_information8               =>  p_cag_information8
935       ,p_cag_information9               =>  p_cag_information9
936       ,p_cag_information10              =>  p_cag_information10
937       ,p_cag_information11              =>  p_cag_information11
938       ,p_cag_information12              =>  p_cag_information12
939       ,p_cag_information13              =>  p_cag_information13
940       ,p_cag_information14              =>  p_cag_information14
941       ,p_cag_information15              =>  p_cag_information15
942       ,p_cag_information16              =>  p_cag_information16
943       ,p_cag_information17              =>  p_cag_information17
944       ,p_cag_information18              =>  p_cag_information18
945       ,p_cag_information19              =>  p_cag_information19
946       ,p_cag_information20              =>  p_cag_information20
947       ,p_attribute_category             =>  p_attribute_category
948       ,p_attribute1                     =>  p_attribute1
949       ,p_attribute2                     =>  p_attribute2
950       ,p_attribute3                     =>  p_attribute3
951       ,p_attribute4                     =>  p_attribute4
952       ,p_attribute5                     =>  p_attribute5
953       ,p_attribute6                     =>  p_attribute6
954       ,p_attribute7                     =>  p_attribute7
955       ,p_attribute8                     =>  p_attribute8
956       ,p_attribute9                     =>  p_attribute9
957       ,p_attribute10                    =>  p_attribute10
958       ,p_attribute11                    =>  p_attribute11
959       ,p_attribute12                    =>  p_attribute12
960       ,p_attribute13                    =>  p_attribute13
961       ,p_attribute14                    =>  p_attribute14
962       ,p_attribute15                    =>  p_attribute15
963       ,p_attribute16                    =>  p_attribute16
964       ,p_attribute17                    =>  p_attribute17
965       ,p_attribute18                    =>  p_attribute18
966       ,p_attribute19                    =>  p_attribute19
967       ,p_attribute20                    =>  p_attribute20
968       );
969   exception
970     when hr_api.cannot_find_prog_unit then
971       p_object_version_number := l_temp_ovn;
972       hr_api.cannot_find_prog_unit_error
973         (p_module_name => 'UPDATE_collective_agreement'
974         ,p_hook_type   => 'AP'
975         );
976     --
977     -- End of API User Hook for the after hook of update_collective_agreement
978     --
979   end;
980   --
981   hr_utility.set_location(l_proc, 60);
982   --
983   -- When in validation only mode raise the Validate_Enabled exception
984   --
985   if p_validate then
986     raise hr_api.validate_enabled;
987   end if;
988   --
989   -- Set all output arguments
990   --
991   p_object_version_number := l_object_version_number;
992   --
993   hr_utility.set_location(' Leaving:'||l_proc, 70);
994   --
995 exception
996   --
997   when hr_api.validate_enabled then
998     --
999     -- As the Validate_Enabled exception has been raised
1000     -- we must rollback to the savepoint
1001     --
1002     ROLLBACK TO update_collective_agreement;
1003     --
1004     -- Only set output warning arguments
1005     -- (Any key or derived arguments must be set to null
1006     -- when validation only mode is being used.)
1007     --
1008     hr_utility.set_location(' Leaving:'||l_proc, 80);
1009     --
1010   when others then
1011     --
1012     -- A validation or unexpected error has occured
1013     --
1014     -- Reset in out params. Nocopy changes.
1015     p_object_version_number := l_temp_ovn;
1016     ROLLBACK TO update_collective_agreement;
1017     raise;
1018     --
1019 end update_collective_agreement;
1020 -- ----------------------------------------------------------------------------
1021 -- |------------------------< delete_collective_agreement >----------------------|
1022 -- ----------------------------------------------------------------------------
1023 --
1024 procedure delete_collective_agreement
1025   (p_validate                       in  boolean  default false
1026   ,p_collective_agreement_id        in  number
1027   ,p_object_version_number          in out nocopy number
1028   ) is
1029   --
1030   -- Declare cursors and local variables
1031   --
1032   l_proc                  VARCHAR2(72) := g_package||'delete_collective_agreement';
1033   l_object_version_number per_collective_agreements.object_version_number%TYPE;
1034   l_pl_ovn                NUMBER;
1035   l_pl_id                 NUMBER;
1036   l_popl_ovn              NUMBER;
1037   l_dummy                 VARCHAR2(1);
1038   l_effective_date        DATE;
1039   l_start_date            DATE;
1040   l_end_date              DATE;
1041   --
1042   CURSOR csr_chk_for_entitlements IS
1043     SELECT 'x'
1044 	  FROM per_cagr_entitlements pce
1045 	 WHERE pce.collective_agreement_id = p_collective_agreement_id;
1046   --
1047   CURSOR csr_pln IS
1048     SELECT b.pl_id,
1049 	       b.object_version_number,
1050 		   cag.start_date
1051 	  FROM ben_pl_f b,
1052 	       per_collective_agreements cag
1053 	 WHERE b.pl_id = cag.pl_Id
1054 	   AND cag.collective_agreement_id = p_collective_agreement_id;
1055   --
1056   CURSOR csr_popl_yr IS
1057     SELECT pop.popl_yr_perd_id,
1058 		   pop.object_version_number
1059 	  FROM ben_popl_yr_perd pop
1060 	 WHERE pop.pl_id = l_pl_id;
1061   --
1062 begin
1063   --
1064   hr_utility.set_location('Entering:'|| l_proc, 10);
1065   --
1066   -- Issue a savepoint if operating in validation only mode
1067   --
1068   savepoint delete_collective_agreement;
1069   --
1070   hr_utility.set_location(l_proc, 20);
1071   --
1072   -- Process Logic
1073   --
1074   l_object_version_number := p_object_version_number;
1075   --
1076   --
1077   begin
1078     --
1079     -- Start of API User Hook for the before hook of delete_collective_agreement
1080     --
1081     hr_collective_agreement_bk3.delete_collective_agreement_b
1082       (p_collective_agreement_id        =>  p_collective_agreement_id
1083       ,p_object_version_number          =>  p_object_version_number);
1084 	--
1085   exception
1086     when hr_api.cannot_find_prog_unit then
1087       hr_api.cannot_find_prog_unit_error
1088         (p_module_name => 'DELETE_collective_agreement'
1089         ,p_hook_type   => 'BP'
1090         );
1091     --
1092     -- End of API User Hook for the before hook of delete_collective_agreement
1093     --
1094   end;
1095   --
1096   hr_utility.set_location(l_proc, 30);
1097   --
1098   -- Check that no entitlements exist before trying to
1099   -- delete the collective agreement.
1100   -- This check has been added in order to display a
1101   -- meaningful cagr error message. If this check was not
1102   -- performed and we tried to delete we would get a BEN error
1103   -- message (Options exist) which is meaningless in the context
1104   -- of a CAGR.
1105   --
1106   OPEN csr_chk_for_entitlements;
1107   FETCH csr_chk_for_entitlements INTO l_dummy;
1108   --
1109   IF csr_chk_for_entitlements%FOUND THEN
1110     --
1111     CLOSE csr_chk_for_entitlements;
1112     --
1113     hr_utility.set_message(800, 'HR_289398_ENTITLEMENTS_EXIST');
1114     hr_utility.raise_error;
1115     --
1116   ELSE
1117     --
1118 	CLOSE csr_chk_for_entitlements;
1119     --
1120   END IF;
1121   --
1122   -- Fetch the Plan and Plan Year information
1123   --
1124   OPEN csr_pln;
1125   FETCH csr_pln INTO l_pl_id,
1126                      l_pl_ovn,
1127 					 l_effective_date;
1128   --
1129   -- If A Plan exists then delete it and
1130   -- the link between plan years
1131   --
1132   IF csr_pln%FOUND THEN
1133     --
1134 	hr_utility.set_location(l_proc, 40);
1135 	savepoint validate_popl_yr;                                 -- Bug # 5405435
1136 	--
1137 	-- Loop Through all the plan years associated
1138 	-- to the the plan and delete them
1139 	--
1140     FOR c1 IN csr_popl_yr LOOP
1141 	  --
1142 	  hr_utility.set_location(l_proc||'/'||c1.popl_yr_perd_id, 50);
1143 	  --
1144 	  l_popl_ovn := c1.object_version_number;
1145 	  --
1146 	  -- Delete plan years link
1147 	  --
1148 	  ben_popl_yr_perd_api.delete_popl_yr_perd
1149         (p_validate                       => false		     -- Bug # 5405435
1150         ,p_popl_yr_perd_id                => c1.popl_yr_perd_id
1151         ,p_object_version_number          => l_popl_ovn);
1152 	 --
1153 	 -- when P_validate is called with value as 'True',
1154 	 -- the changes made by this API (because of it being
1155 	 -- called with p_validate => false), will be rolled
1156 	 -- back.
1157 	 --
1158     END LOOP;
1159 	--
1160 	-- Delete Plan
1161 	--
1162     ben_plan_api.delete_plan
1163       (p_validate                       => p_validate
1164       ,p_pl_id                          => l_pl_id
1165       ,p_effective_start_date           => l_start_date
1166       ,p_effective_end_date             => l_end_date
1167       ,p_object_version_number          => l_pl_ovn
1168       ,p_effective_date                 => l_effective_date
1169       ,p_datetrack_mode                 => 'ZAP');
1170     --
1171     IF p_validate then                                         -- Bug # 5405435
1172        ROLLBACK TO validate_popl_yr;
1173     END IF;
1174     --
1175   END IF;
1176   --
1177   CLOSE csr_pln;
1178   --
1179   per_cag_del.del
1180     (p_collective_agreement_id       => p_collective_agreement_id
1181     ,p_object_version_number         => l_object_version_number
1182     );
1183   --
1184   begin
1185     --
1186     -- Start of API User Hook for the after hook of delete_collective_agreement
1187     --
1188     hr_collective_agreement_bk3.delete_collective_agreement_a
1189       (
1190        p_collective_agreement_id        =>  p_collective_agreement_id
1191       ,p_object_version_number          =>  l_object_version_number
1192       );
1193   exception
1194     when hr_api.cannot_find_prog_unit then
1195       hr_api.cannot_find_prog_unit_error
1196         (p_module_name => 'DELETE_collective_agreement'
1197         ,p_hook_type   => 'AP'
1198         );
1199     --
1200     -- End of API User Hook for the after hook of delete_collective_agreement
1201     --
1202   end;
1203   --
1204   hr_utility.set_location(l_proc, 60);
1205   --
1206   -- When in validation only mode raise the Validate_Enabled exception
1207   --
1208   if p_validate then
1209     raise hr_api.validate_enabled;
1210   end if;
1211   --
1212   hr_utility.set_location(' Leaving:'||l_proc, 70);
1213   --
1214 exception
1215   --
1216   when hr_api.validate_enabled then
1217     --
1218     -- As the Validate_Enabled exception has been raised
1219     -- we must rollback to the savepoint
1220     --
1221     ROLLBACK TO delete_collective_agreement;
1222     --
1223     -- Only set output warning arguments
1224     -- (Any key or derived arguments must be set to null
1225     -- when validation only mode is being used.)
1226     -- Reset in out params.
1227     p_object_version_number := l_object_version_number;
1228     --
1229     --
1230   when others then
1231     --
1232     -- A validation or unexpected error has occured
1233     --
1234     -- Reset in out params.
1235     p_object_version_number := l_object_version_number;
1236     ROLLBACK TO delete_collective_agreement;
1237     raise;
1238     --
1239 end delete_collective_agreement;
1240 --
1241 -- ----------------------------------------------------------------------------
1242 -- |-------------------------------< lck >------------------------------------|
1243 -- ----------------------------------------------------------------------------
1244 --
1245 procedure lck
1246   (
1247    p_collective_agreement_id                   in     number
1248   ,p_object_version_number          in     number
1249   ) is
1250   --
1251   --
1252   -- Declare cursors and local variables
1253   --
1254   l_proc varchar2(72) := g_package||'lck';
1255   --
1256 begin
1257   --
1258   hr_utility.set_location('Entering:'|| l_proc, 10);
1259   --
1260   per_cag_shd.lck
1261     (
1262       p_collective_agreement_id                 => p_collective_agreement_id
1263      ,p_object_version_number      => p_object_version_number
1264     );
1265   --
1266   hr_utility.set_location(' Leaving:'||l_proc, 70);
1267   --
1268 end lck;
1269 --
1270 end hr_collective_agreement_api;