DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_CTT_BUS

Source


1 Package Body ben_ctt_bus as
2 /* $Header: becttrhi.pkb 115.7 2002/12/16 17:35:13 glingapp ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_ctt_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |---------------------------< chk_cm_typ_trgr_id >-------------------------|
12 -- ----------------------------------------------------------------------------
13 --
14 -- Description
15 --   This procedure is used to check that the primary key for the table
16 --   is created properly. It should be null on insert and
17 --   should not be able to be updated.
18 --
19 -- Pre Conditions
20 --   None.
21 --
22 -- In Parameters
23 --   cm_typ_trgr_id PK of record being inserted or updated.
24 --   effective_date Effective Date of session
25 --   object_version_number Object version number of record being
26 --                         inserted or updated.
27 --
28 -- Post Success
29 --   Processing continues
30 --
31 -- Post Failure
32 --   Errors handled by the procedure
33 --
34 -- Access Status
35 --   Internal table handler use only.
36 --
37 Procedure chk_cm_typ_trgr_id(p_cm_typ_trgr_id              in number,
38                              p_effective_date              in date,
39                              p_object_version_number       in number) is
40   --
41   l_proc         varchar2(72) := g_package||'chk_cm_typ_trgr_id';
42   l_api_updating boolean;
43   --
44 Begin
45   --
46   hr_utility.set_location('Entering:'||l_proc, 5);
47   --
48   l_api_updating := ben_ctt_shd.api_updating
49     (p_effective_date              => p_effective_date,
50      p_cm_typ_trgr_id              => p_cm_typ_trgr_id,
51      p_object_version_number       => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_cm_typ_trgr_id,hr_api.g_number)
55      <>  ben_ctt_shd.g_old_rec.cm_typ_trgr_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_ctt_shd.constraint_error('BEN_CM_TYP_TRGR_F_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_cm_typ_trgr_id is not null then
66       --
67       -- raise error as PK is not null
68       --
69       ben_ctt_shd.constraint_error('BEN_CM_TYP_TRGR_F_PK');
70       --
71     end if;
72     --
73   end if;
74   --
75   hr_utility.set_location('Leaving:'||l_proc, 10);
76   --
77 End chk_cm_typ_trgr_id;
78 --
79 -- ----------------------------------------------------------------------------
80 -- |-------------------------< chk_cm_typ_trgr_rl >---------------------------|
81 -- ----------------------------------------------------------------------------
82 --
83 -- Description
84 --   This procedure is used to check that the Formula Rule is valid.
85 --
86 -- Pre Conditions
87 --   None.
88 --
89 -- In Parameters
90 --   cm_typ_trgr_id PK of record being inserted or updated.
91 --   cm_typ_trgr_rl Value of formula rule id.
92 --   effective_date effective date
93 --   object_version_number Object version number of record being
94 --                         inserted or updated.
95 --
96 -- Post Success
97 --   Processing continues
98 --
99 -- Post Failure
100 --   Error handled by procedure
101 --
102 -- Access Status
103 --   Internal table handler use only.
104 --
105 Procedure chk_cm_typ_trgr_rl(p_cm_typ_trgr_id              in number,
106                              p_cm_typ_trgr_rl              in number,
107                              p_effective_date              in date,
108                              p_business_group_id           in number,
109                              p_object_version_number       in number) is
110   --
111   l_proc         varchar2(72) := g_package||'chk_cm_typ_trgr_rl';
112   l_api_updating boolean;
113   --
114 Begin
115   --
116   hr_utility.set_location('Entering:'||l_proc, 5);
117   --
118   l_api_updating := ben_ctt_shd.api_updating
119     (p_cm_typ_trgr_id              => p_cm_typ_trgr_id,
120      p_effective_date              => p_effective_date,
121      p_object_version_number       => p_object_version_number);
122   --
123   if (l_api_updating
124       and nvl(p_cm_typ_trgr_rl,hr_api.g_number)
125       <> ben_ctt_shd.g_old_rec.cm_typ_trgr_rl
126       or not l_api_updating)
127       and p_cm_typ_trgr_rl is not null then
128     --
129     -- check if value of formula rule is valid.
130     --
131     if not benutils.formula_exists
132          (p_formula_id        => p_cm_typ_trgr_rl,
133           p_formula_type_id   => -312,
134           p_business_group_id => p_business_group_id,
135           p_effective_date    => p_effective_date) then
136       --
137       fnd_message.set_name('BEN','BEN_91471_FORMULA_NOT_FOUND');
138       fnd_message.set_token('ID',p_cm_typ_trgr_rl);
139       fnd_message.set_token('TYPE_ID',-312);
140       fnd_message.raise_error;
141       --
142     end if;
143     --
144   end if;
145   --
146   hr_utility.set_location('Leaving:'||l_proc,10);
147   --
148 end chk_cm_typ_trgr_rl;
149 --
150 -- ----------------------------------------------------------------------------
151 -- |--------------------------< dt_update_validate >--------------------------|
152 -- ----------------------------------------------------------------------------
153 -- {Start Of Comments}
154 --
155 -- Description:
156 --   This procedure is used for referential integrity of datetracked
157 --   parent entities when a datetrack update operation is taking place
158 --   and where there is no cascading of update defined for this entity.
159 --
160 -- Prerequisites:
161 --   This procedure is called from the update_validate.
162 --
163 -- In Parameters:
164 --
165 -- Post Success:
166 --   Processing continues.
167 --
168 -- Post Failure:
169 --
170 -- Developer Implementation Notes:
171 --   This procedure should not need maintenance unless the HR Schema model
172 --   changes.
173 --
174 -- Access Status:
175 --   Internal Row Handler Use Only.
176 --
177 -- {End Of Comments}
178 -- ----------------------------------------------------------------------------
179 Procedure dt_update_validate
180             (p_cm_typ_id                     in number default hr_api.g_number,
181 	     p_datetrack_mode		     in varchar2,
182              p_validation_start_date	     in date,
183 	     p_validation_end_date	     in date) Is
184 --
185   l_proc	    varchar2(72) := g_package||'dt_update_validate';
186   l_integrity_error Exception;
187   l_table_name	    all_tables.table_name%TYPE;
188 --
189 Begin
190   hr_utility.set_location('Entering:'||l_proc, 5);
191   --
192   -- Ensure that the p_datetrack_mode argument is not null
193   --
194   hr_api.mandatory_arg_error
195     (p_api_name       => l_proc,
196      p_argument       => 'datetrack_mode',
197      p_argument_value => p_datetrack_mode);
198   --
199   -- Only perform the validation if the datetrack update mode is valid
200   --
201   If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
202     --
203     --
204     -- Ensure the arguments are not null
205     --
206     hr_api.mandatory_arg_error
207       (p_api_name       => l_proc,
208        p_argument       => 'validation_start_date',
209        p_argument_value => p_validation_start_date);
210     --
211     hr_api.mandatory_arg_error
212       (p_api_name       => l_proc,
213        p_argument       => 'validation_end_date',
214        p_argument_value => p_validation_end_date);
215     --
216     If ((nvl(p_cm_typ_id, hr_api.g_number) <> hr_api.g_number) and
217       NOT (dt_api.check_min_max_dates
218             (p_base_table_name => 'ben_cm_typ_f',
219              p_base_key_column => 'cm_typ_id',
220              p_base_key_value  => p_cm_typ_id,
221              p_from_date       => p_validation_start_date,
222              p_to_date         => p_validation_end_date)))  Then
223       l_table_name := 'ben_cm_typ_f';
224       Raise l_integrity_error;
225     End If;
226     --
227   End If;
228   --
229   hr_utility.set_location(' Leaving:'||l_proc, 10);
230 Exception
231   When l_integrity_error Then
232     --
233     -- A referential integrity check was violated therefore
234     -- we must error
235     --
236     ben_utility.parent_integrity_error(p_table_name => l_table_name);
237   When Others Then
238     --
239     -- An unhandled or unexpected error has occurred which
240     -- we must report
241     --
242     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
243     hr_utility.set_message_token('PROCEDURE', l_proc);
244     hr_utility.set_message_token('STEP','15');
245     hr_utility.raise_error;
246 End dt_update_validate;
247 --
248 -- ----------------------------------------------------------------------------
249 -- |--------------------------< dt_delete_validate >--------------------------|
250 -- ----------------------------------------------------------------------------
251 -- {Start Of Comments}
252 --
253 -- Description:
254 --   This procedure is used for referential integrity of datetracked
255 --   child entities when either a datetrack DELETE or ZAP is in operation
256 --   and where there is no cascading of delete defined for this entity.
257 --   For the datetrack mode of DELETE or ZAP we must ensure that no
258 --   datetracked child rows exist between the validation start and end
259 --   dates.
260 --
261 -- Prerequisites:
262 --   This procedure is called from the delete_validate.
263 --
264 -- In Parameters:
265 --
266 -- Post Success:
267 --   Processing continues.
268 --
269 -- Post Failure:
270 --   If a row exists by determining the returning Boolean value from the
271 --   generic dt_api.rows_exist function then we must supply an error via
272 --   the use of the local exception handler l_rows_exist.
273 --
274 -- Developer Implementation Notes:
275 --   This procedure should not need maintenance unless the HR Schema model
276 --   changes.
277 --
278 -- Access Status:
279 --   Internal Row Handler Use Only.
280 --
281 -- {End Of Comments}
282 -- ----------------------------------------------------------------------------
283 Procedure dt_delete_validate
284             (p_cm_typ_trgr_id		in number,
285              p_datetrack_mode		in varchar2,
286 	     p_validation_start_date	in date,
287 	     p_validation_end_date	in date) Is
288 --
289   l_proc	varchar2(72) 	:= g_package||'dt_delete_validate';
290   l_rows_exist	Exception;
291   l_table_name	all_tables.table_name%TYPE;
292 --
293 Begin
294   hr_utility.set_location('Entering:'||l_proc, 5);
295   --
296   -- Ensure that the p_datetrack_mode argument is not null
297   --
298   hr_api.mandatory_arg_error
299     (p_api_name       => l_proc,
300      p_argument       => 'datetrack_mode',
301      p_argument_value => p_datetrack_mode);
302   --
303   -- Only perform the validation if the datetrack mode is either
304   -- DELETE or ZAP
305   --
306   If (p_datetrack_mode = 'DELETE' or
307       p_datetrack_mode = 'ZAP') then
308     --
309     --
310     -- Ensure the arguments are not null
311     --
312     hr_api.mandatory_arg_error
313       (p_api_name       => l_proc,
314        p_argument       => 'validation_start_date',
315        p_argument_value => p_validation_start_date);
316     --
317     hr_api.mandatory_arg_error
318       (p_api_name       => l_proc,
319        p_argument       => 'validation_end_date',
320        p_argument_value => p_validation_end_date);
321     --
322     hr_api.mandatory_arg_error
323       (p_api_name       => l_proc,
324        p_argument       => 'cm_typ_trgr_id',
325        p_argument_value => p_cm_typ_trgr_id);
326     --
327     --
328     --
329   End If;
330   --
331   hr_utility.set_location(' Leaving:'||l_proc, 10);
332 Exception
333   When l_rows_exist Then
334     --
335     -- A referential integrity check was violated therefore
336     -- we must error
337     --
338     ben_utility.child_exists_error(p_table_name => l_table_name);
339   When Others Then
340     --
341     -- An unhandled or unexpected error has occurred which
342     -- we must report
343     --
344     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
345     hr_utility.set_message_token('PROCEDURE', l_proc);
346     hr_utility.set_message_token('STEP','15');
347     hr_utility.raise_error;
348 End dt_delete_validate;
349 --
350 -- ----------------------------------------------------------------------------
351 -- |---------------------------< insert_validate >----------------------------|
352 -- ----------------------------------------------------------------------------
353 Procedure insert_validate
354 	(p_rec 			 in ben_ctt_shd.g_rec_type,
355 	 p_effective_date	 in date,
356 	 p_datetrack_mode	 in varchar2,
357 	 p_validation_start_date in date,
358 	 p_validation_end_date	 in date) is
359 --
360   l_proc	varchar2(72) := g_package||'insert_validate';
361 --
362 Begin
363   hr_utility.set_location('Entering:'||l_proc, 5);
364   --
365   -- Call all supporting business operations
366   --
367   --
368   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
369   --
370   chk_cm_typ_trgr_id
371   (p_cm_typ_trgr_id          => p_rec.cm_typ_trgr_id,
372    p_effective_date        => p_effective_date,
373    p_object_version_number => p_rec.object_version_number);
374   --
375   chk_cm_typ_trgr_rl
376   (p_cm_typ_trgr_id        => p_rec.cm_typ_trgr_id,
377    p_cm_typ_trgr_rl        => p_rec.cm_typ_trgr_rl,
378    p_effective_date        => p_effective_date,
379    p_business_group_id     => p_rec.business_group_id,
380    p_object_version_number => p_rec.object_version_number);
381   --
382   hr_utility.set_location(' Leaving:'||l_proc, 10);
383 End insert_validate;
384 --
385 -- ----------------------------------------------------------------------------
386 -- |---------------------------< update_validate >----------------------------|
387 -- ----------------------------------------------------------------------------
388 Procedure update_validate
389 	(p_rec 			 in ben_ctt_shd.g_rec_type,
390 	 p_effective_date	 in date,
391 	 p_datetrack_mode	 in varchar2,
392 	 p_validation_start_date in date,
393 	 p_validation_end_date	 in date) is
394 --
395   l_proc	varchar2(72) := g_package||'update_validate';
396 --
397 Begin
398   hr_utility.set_location('Entering:'||l_proc, 5);
399   --
400   -- Call all supporting business operations
401   --
402   --
403   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
404   --
405   chk_cm_typ_trgr_id
406   (p_cm_typ_trgr_id        => p_rec.cm_typ_trgr_id,
407    p_effective_date        => p_effective_date,
408    p_object_version_number => p_rec.object_version_number);
409   --
410   chk_cm_typ_trgr_rl
411   (p_cm_typ_trgr_id        => p_rec.cm_typ_trgr_id,
412    p_cm_typ_trgr_rl        => p_rec.cm_typ_trgr_rl,
413    p_effective_date        => p_effective_date,
414    p_business_group_id     => p_rec.business_group_id,
415    p_object_version_number => p_rec.object_version_number);
416   --
417   -- Call the datetrack update integrity operation
418   --
419   dt_update_validate
420     (p_cm_typ_id                     => p_rec.cm_typ_id,
421      p_datetrack_mode                => p_datetrack_mode,
422      p_validation_start_date	     => p_validation_start_date,
423      p_validation_end_date	     => p_validation_end_date);
424   --
425   hr_utility.set_location(' Leaving:'||l_proc, 10);
426 End update_validate;
427 --
428 -- ----------------------------------------------------------------------------
429 -- |---------------------------< delete_validate >----------------------------|
430 -- ----------------------------------------------------------------------------
431 Procedure delete_validate
432 	(p_rec 			 in ben_ctt_shd.g_rec_type,
433 	 p_effective_date	 in date,
434 	 p_datetrack_mode	 in varchar2,
435 	 p_validation_start_date in date,
436 	 p_validation_end_date	 in date) is
437 --
438   l_proc	varchar2(72) := g_package||'delete_validate';
439 --
440 Begin
441   hr_utility.set_location('Entering:'||l_proc, 5);
442   --
443   -- Call all supporting business operations
444   --
445   dt_delete_validate
446     (p_datetrack_mode		=> p_datetrack_mode,
447      p_validation_start_date	=> p_validation_start_date,
448      p_validation_end_date	=> p_validation_end_date,
449      p_cm_typ_trgr_id		=> p_rec.cm_typ_trgr_id);
450   --
451   hr_utility.set_location(' Leaving:'||l_proc, 10);
452 End delete_validate;
453 --
454 --
455 --  ---------------------------------------------------------------------------
456 --  |---------------------< return_legislation_code >-------------------------|
457 --  ---------------------------------------------------------------------------
458 --
459 function return_legislation_code
460   (p_cm_typ_trgr_id in number) return varchar2 is
461   --
462   -- Declare cursor
463   --
464   cursor csr_leg_code is
465     select a.legislation_code
466     from   per_business_groups a,
467            ben_cm_typ_trgr_f b
468     where b.cm_typ_trgr_id      = p_cm_typ_trgr_id
469     and   a.business_group_id = b.business_group_id;
470   --
471   -- Declare local variables
472   --
473   l_legislation_code  varchar2(150);
474   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
475   --
476 begin
477   --
478   hr_utility.set_location('Entering:'|| l_proc, 10);
479   --
480   -- Ensure that all the mandatory parameter are not null
481   --
482   hr_api.mandatory_arg_error(p_api_name       => l_proc,
483                              p_argument       => 'cm_typ_trgr_id',
484                              p_argument_value => p_cm_typ_trgr_id);
485   --
486   open csr_leg_code;
487     --
488     fetch csr_leg_code into l_legislation_code;
489     --
490     if csr_leg_code%notfound then
491       --
492       close csr_leg_code;
493       --
494       -- The primary key is invalid therefore we must error
495       --
496       hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
497       hr_utility.raise_error;
498       --
499     end if;
500     --
501   close csr_leg_code;
502   --
503   hr_utility.set_location(' Leaving:'|| l_proc, 20);
504   --
505   return l_legislation_code;
506   --
507 end return_legislation_code;
508 --
509 end ben_ctt_bus;