DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_CSR_BUS

Source


1 Package Body ben_csr_bus as
2 /* $Header: becsrrhi.pkb 115.4 2002/12/16 17:34:51 glingapp ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_csr_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_css_rltd_per_per_in_ler_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 --   css_rltd_per_per_in_ler_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_css_rltd_per_per_in_ler_id(p_css_rltd_per_per_in_ler_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_css_rltd_per_per_in_ler_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_csr_shd.api_updating
49     (p_effective_date              => p_effective_date,
50      p_css_rltd_per_per_in_ler_id  => p_css_rltd_per_per_in_ler_id,
51      p_object_version_number       => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_css_rltd_per_per_in_ler_id,hr_api.g_number)
55      <>  ben_csr_shd.g_old_rec.css_rltd_per_per_in_ler_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_csr_shd.constraint_error('BEN_CSS_RLTD_PER_PER_IN_LE_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_css_rltd_per_per_in_ler_id is not null then
66       --
67       -- raise error as PK is not null
68       --
69       ben_csr_shd.constraint_error('BEN_CSS_RLTD_PER_PER_IN_LE_PK');
70       --
71     end if;
72     --
73   end if;
74   --
75   hr_utility.set_location('Leaving:'||l_proc, 10);
76   --
77 End chk_css_rltd_per_per_in_ler_id;
78 -- ----------------------------------------------------------------------------
79 -- |------< chk_ordr_to_prcs_num >------|
80 -- ----------------------------------------------------------------------------
81 --
82 -- Description
83 --   This procedure is used to check that the Sequence Number field is unique.
84 --
85 -- Pre Conditions
86 --   None.
87 --
88 -- In Parameters
89 --   css_rltd_per_per_in_ler_id PK of record being inserted or updated.
90 --   ordr_to_prcs_num Sequence Number (Order to Process) of record being inserted
91 --                    or updated.
92 --   business_group_id business_group
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 --   Errors handled by the procedure
101 --
102 -- Access Status
103 --   Internal table handler use only.
104 --
105 Procedure chk_ordr_to_prcs_num
106                   (p_css_rltd_per_per_in_ler_id  in number,
107                    p_ordr_to_prcs_num      in number,
108                    p_ler_id                in number,
109                    p_effective_date        in date,
110                    p_validation_start_date   in date,
111                    p_validation_end_date     in date,
112                    p_business_group_id     in number,
113                    p_object_version_number in number) is
114 
115 -- Cursor selects non-unique sequence numbers
116 -- Note, we are allowing records with different keys to have the same
117 -- sequence value as long as the two records are not 'effective' at any
118 -- one time.
119 CURSOR l_csr_csr (p_css_rltd_per_per_in_ler_id             number
120                  ,p_ordr_to_prcs_num   number
121                  ,p_ler_id             number
122                  ,p_business_group_id  number
123                  ,p_validation_start_date date
124                  ,p_validation_end_date   date) IS
125     SELECT  css_rltd_per_per_in_ler_id
126     FROM    ben_css_rltd_per_per_in_ler
127     WHERE   css_rltd_per_per_in_ler_id <>
128                 nvl(p_css_rltd_per_per_in_ler_id, hr_api.g_number)
129     AND     business_group_id + 0  = p_business_group_id
130     AND     ordr_to_prcs_num       = nvl(p_ordr_to_prcs_num,hr_api.g_number)
131     AND     ler_id                 = p_ler_id
132     AND     p_validation_start_date <= effective_end_date
133     AND     p_validation_end_date   >= effective_start_date;
134 
135   --
136   l_db_csr_row   l_csr_csr%rowtype;
137   l_proc         varchar2(72) := g_package||'chk_ordr_to_prcs_num';
138   l_api_updating boolean;
139   --
140 Begin
141   --
142   hr_utility.set_location('Entering:'||l_proc, 5);
143   --
144   l_api_updating := ben_csr_shd.api_updating
145     (p_css_rltd_per_per_in_ler_id  => p_css_rltd_per_per_in_ler_id,
146      p_effective_date              => p_effective_date,
147      p_object_version_number       => p_object_version_number);
148 
149   if (l_api_updating
150      and nvl(p_ordr_to_prcs_num,hr_api.g_number)
151      <>  ben_csr_shd.g_old_rec.ordr_to_prcs_num
152      or not l_api_updating) then
153 
154      open l_csr_csr
155              (p_css_rltd_per_per_in_ler_id  => p_css_rltd_per_per_in_ler_id
156              ,p_ordr_to_prcs_num   => p_ordr_to_prcs_num
157              ,p_ler_id             => p_ler_id
158              ,p_business_group_id  => p_business_group_id
159              ,p_validation_start_date     => p_validation_start_date
160              ,p_validation_end_date       => p_validation_end_date) ;
161      fetch l_csr_csr into l_db_csr_row;
162      if l_csr_csr%found then
163         close l_csr_csr;
164         --
165         -- raise error as there is another record in database with same sequence number.
166         --
167         ben_csr_shd.constraint_error('BEN_CSS_RLTD_PER_PER_IN_LER_UK2');
168      end if;
169     close l_csr_csr;
170 
171   end if;
172   --
173   hr_utility.set_location('Leaving:'||l_proc, 10);
174   --
175 End chk_ordr_to_prcs_num;
176 -- ----------------------------------------------------------------------------
177 -- |------< chk_rsltg_ler_id >------|
178 -- ----------------------------------------------------------------------------
179 --
180 -- Description
181 --   This procedure is used to check that the Resulting Life Event is unique.
182 --
183 -- Pre Conditions
184 --   None.
185 --
186 -- In Parameters
187 --   css_rltd_per_per_in_ler_id PK of record being inserted or updated.
188 --   rsltg_ler_id Resulting Life Event of record being inserted
189 --                    or updated.
190 --   business_group_id business_group
191 --   object_version_number Object version number of record being
192 --                         inserted or updated.
193 --
194 -- Post Success
195 --   Processing continues
196 --
197 -- Post Failure
198 --   Errors handled by the procedure
199 --
200 -- Access Status
201 --   Internal table handler use only.
202 --
203 Procedure chk_rsltg_ler_id
204                   (p_css_rltd_per_per_in_ler_id  in number,
205                    p_rsltg_ler_id          in number,
206                    p_ler_id                in number,
207                    p_effective_date        in date,
208                    p_validation_start_date   in date,
209                    p_validation_end_date     in date,
210                    p_business_group_id     in number,
211                    p_object_version_number in number) is
212 
213 -- Note, we are allowing records with different keys to have the same
214 -- rsltg_ler_id value as long as the two records are not 'effective' at any
215 -- one time.
216 CURSOR l_csr_csr (p_css_rltd_per_per_in_ler_id             number
217                  ,p_rsltg_ler_id       number
218                  ,p_ler_id             number
219                  ,p_business_group_id  number
220                  ,p_validation_start_date date
221                  ,p_validation_end_date   date) IS
222     SELECT  css_rltd_per_per_in_ler_id
223     FROM    ben_css_rltd_per_per_in_ler
224     WHERE   css_rltd_per_per_in_ler_id <>
225                 nvl(p_css_rltd_per_per_in_ler_id, hr_api.g_number)
226     AND     business_group_id + 0  = p_business_group_id
227     AND     rsltg_ler_id           = p_rsltg_ler_id
228     AND     ler_id                 = p_ler_id
229     AND     p_validation_start_date <= effective_end_date
230     AND     p_validation_end_date   >= effective_start_date;
231 
232   --
233   l_db_csr_row   l_csr_csr%rowtype;
234   l_proc         varchar2(72) := g_package||'chk_rsltg_ler_id';
235   l_api_updating boolean;
236   --
237 Begin
238   --
239   hr_utility.set_location('Entering:'||l_proc, 5);
240   --
241   l_api_updating := ben_csr_shd.api_updating
242     (p_css_rltd_per_per_in_ler_id  => p_css_rltd_per_per_in_ler_id,
243      p_effective_date              => p_effective_date,
244      p_object_version_number       => p_object_version_number);
245 
246   if (l_api_updating
247      and nvl(p_rsltg_ler_id,hr_api.g_number)
248      <>  ben_csr_shd.g_old_rec.rsltg_ler_id
249      or not l_api_updating) then
250 
251      open l_csr_csr
252              (p_css_rltd_per_per_in_ler_id  => p_css_rltd_per_per_in_ler_id
253              ,p_rsltg_ler_id       => p_rsltg_ler_id
254              ,p_ler_id             => p_ler_id
255              ,p_business_group_id  => p_business_group_id
256              ,p_validation_start_date     => p_validation_start_date
257              ,p_validation_end_date       => p_validation_end_date) ;
258      fetch l_csr_csr into l_db_csr_row;
259      if l_csr_csr%found then
260         close l_csr_csr;
261         --
262         -- raise error as there is another record in database with same
263         -- Life Event
264         --
265         ben_csr_shd.constraint_error('BEN_CSS_RLTD_PER_PER_IN_LER_UK3');
266      end if;
267     close l_csr_csr;
268 
269   end if;
270   --
271   hr_utility.set_location('Leaving:'||l_proc, 10);
272   --
273 End chk_rsltg_ler_id;
274 --
275 -- ----------------------------------------------------------------------------
276 -- |--------------------------< dt_update_validate >--------------------------|
277 -- ----------------------------------------------------------------------------
278 -- {Start Of Comments}
279 --
280 -- Description:
281 --   This procedure is used for referential integrity of datetracked
282 --   parent entities when a datetrack update operation is taking place
283 --   and where there is no cascading of update defined for this entity.
284 --
285 -- Prerequisites:
286 --   This procedure is called from the update_validate.
287 --
288 -- In Parameters:
289 --
290 -- Post Success:
291 --   Processing continues.
292 --
293 -- Post Failure:
294 --
295 -- Developer Implementation Notes:
296 --   This procedure should not need maintenance unless the HR Schema model
297 --   changes.
298 --
299 -- Access Status:
300 --   Internal Row Handler Use Only.
301 --
302 -- {End Of Comments}
303 -- ----------------------------------------------------------------------------
304 Procedure dt_update_validate
305             (p_ler_id                     in number default hr_api.g_number,
306              p_rsltg_ler_id               in number default hr_api.g_number,
307 	       p_datetrack_mode		      in varchar2,
308              p_validation_start_date      in date,
309 	       p_validation_end_date	      in date) Is
310 --
311   l_proc	    varchar2(72) := g_package||'dt_update_validate';
312   l_integrity_error Exception;
313   l_table_name	    all_tables.table_name%TYPE;
314 --
315 Begin
316   hr_utility.set_location('Entering:'||l_proc, 5);
317   --
318   -- Ensure that the p_datetrack_mode argument is not null
319   --
320   hr_api.mandatory_arg_error
321     (p_api_name       => l_proc,
322      p_argument       => 'datetrack_mode',
323      p_argument_value => p_datetrack_mode);
324   --
325   -- Only perform the validation if the datetrack update mode is valid
326   --
327   If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
328     --
329     --
330     -- Ensure the arguments are not null
331     --
332     hr_api.mandatory_arg_error
333       (p_api_name       => l_proc,
334        p_argument       => 'validation_start_date',
335        p_argument_value => p_validation_start_date);
336     --
337     hr_api.mandatory_arg_error
338       (p_api_name       => l_proc,
339        p_argument       => 'validation_end_date',
340        p_argument_value => p_validation_end_date);
341     --
342     If ((nvl(p_ler_id, hr_api.g_number) <> hr_api.g_number) and
343       NOT (dt_api.check_min_max_dates
344             (p_base_table_name => 'ben_ler_f',
345              p_base_key_column => 'ler_id',
346              p_base_key_value  => p_ler_id,
347              p_from_date       => p_validation_start_date,
348              p_to_date         => p_validation_end_date)))  Then
349       l_table_name := 'ben_ler_f';
350       Raise l_integrity_error;
351     End If;
352     --
353     -- if the ler_id and rsltg_ler_id are the same, there is no need to call
354     -- the date track api with both values.
355     if p_ler_id = p_rsltg_ler_id then
356        null;
357     elsif ((nvl(p_rsltg_ler_id, hr_api.g_number) <> hr_api.g_number) and
358       NOT (dt_api.check_min_max_dates
359             (p_base_table_name => 'ben_ler_f',
360              p_base_key_column => 'ler_id',
361              p_base_key_value  => p_rsltg_ler_id,
362              p_from_date       => p_validation_start_date,
363              p_to_date         => p_validation_end_date)))  Then
364       l_table_name := 'ben_ler_f';
365       Raise l_integrity_error;
366     End If;
367     --
368   End If;
369   --
370   hr_utility.set_location(' Leaving:'||l_proc, 10);
371 Exception
372   When l_integrity_error Then
373     --
374     -- A referential integrity check was violated therefore
375     -- we must error
376     --
377     ben_utility.parent_integrity_error(p_table_name => l_table_name);
378   When Others Then
379     --
380     -- An unhandled or unexpected error has occurred which
381     -- we must report
382     --
383     fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
384     fnd_message.set_token('PROCEDURE', l_proc);
385     fnd_message.set_token('STEP','15');
386     fnd_message.raise_error;
387 End dt_update_validate;
388 --
389 -- ----------------------------------------------------------------------------
390 -- |--------------------------< dt_delete_validate >--------------------------|
391 -- ----------------------------------------------------------------------------
392 -- {Start Of Comments}
393 --
394 -- Description:
395 --   This procedure is used for referential integrity of datetracked
399 --   datetracked child rows exist between the validation start and end
396 --   child entities when either a datetrack DELETE or ZAP is in operation
397 --   and where there is no cascading of delete defined for this entity.
398 --   For the datetrack mode of DELETE or ZAP we must ensure that no
400 --   dates.
401 --
402 -- Prerequisites:
403 --   This procedure is called from the delete_validate.
404 --
405 -- In Parameters:
406 --
407 -- Post Success:
408 --   Processing continues.
409 --
410 -- Post Failure:
411 --   If a row exists by determining the returning Boolean value from the
412 --   generic dt_api.rows_exist function then we must supply an error via
413 --   the use of the local exception handler l_rows_exist.
414 --
415 -- Developer Implementation Notes:
416 --   This procedure should not need maintenance unless the HR Schema model
417 --   changes.
418 --
419 -- Access Status:
420 --   Internal Row Handler Use Only.
421 --
422 -- {End Of Comments}
423 -- ----------------------------------------------------------------------------
424 Procedure dt_delete_validate
425             (p_css_rltd_per_per_in_ler_id		in number,
426              p_datetrack_mode		in varchar2,
427 	     p_validation_start_date	in date,
428 	     p_validation_end_date	in date) Is
429 --
430   l_proc	varchar2(72) 	:= g_package||'dt_delete_validate';
431   l_rows_exist	Exception;
432   l_table_name	all_tables.table_name%TYPE;
433 --
434 Begin
435   hr_utility.set_location('Entering:'||l_proc, 5);
436   --
437   -- Ensure that the p_datetrack_mode argument is not null
438   --
439   hr_api.mandatory_arg_error
440     (p_api_name       => l_proc,
441      p_argument       => 'datetrack_mode',
442      p_argument_value => p_datetrack_mode);
443   --
444   -- Only perform the validation if the datetrack mode is either
445   -- DELETE or ZAP
446   --
447   If (p_datetrack_mode = 'DELETE' or
448       p_datetrack_mode = 'ZAP') then
449     --
450     --
451     -- Ensure the arguments are not null
452     --
453     hr_api.mandatory_arg_error
454       (p_api_name       => l_proc,
455        p_argument       => 'validation_start_date',
456        p_argument_value => p_validation_start_date);
457     --
458     hr_api.mandatory_arg_error
459       (p_api_name       => l_proc,
460        p_argument       => 'validation_end_date',
461        p_argument_value => p_validation_end_date);
462     --
463     hr_api.mandatory_arg_error
464       (p_api_name       => l_proc,
465        p_argument       => 'css_rltd_per_per_in_ler_id',
466        p_argument_value => p_css_rltd_per_per_in_ler_id);
467     --
468     --
469     --
470   End If;
471   --
472   hr_utility.set_location(' Leaving:'||l_proc, 10);
473 Exception
474   When l_rows_exist Then
475     --
476     -- A referential integrity check was violated therefore
477     -- we must error
478     --
479     ben_utility.child_exists_error(p_table_name => l_table_name);
480   When Others Then
481     --
482     -- An unhandled or unexpected error has occurred which
483     -- we must report
484     --
485     fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
486     fnd_message.set_token('PROCEDURE', l_proc);
487     fnd_message.set_token('STEP','15');
488     fnd_message.raise_error;
489 End dt_delete_validate;
490 --
491 -- ----------------------------------------------------------------------------
492 -- |---------------------------< insert_validate >----------------------------|
493 -- ----------------------------------------------------------------------------
494 Procedure insert_validate
495 	(p_rec 			 in ben_csr_shd.g_rec_type,
496 	 p_effective_date	 in date,
497 	 p_datetrack_mode	 in varchar2,
498 	 p_validation_start_date in date,
499 	 p_validation_end_date	 in date) is
500 --
501   l_proc	varchar2(72) := g_package||'insert_validate';
502 --
503 Begin
504   hr_utility.set_location('Entering:'||l_proc, 5);
505   --
506   -- Call all supporting business operations
507   --
508   --
509   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
510   --
511   chk_css_rltd_per_per_in_ler_id
512   (p_css_rltd_per_per_in_ler_id          => p_rec.css_rltd_per_per_in_ler_id,
513    p_effective_date        => p_effective_date,
514    p_object_version_number => p_rec.object_version_number);
515   --
516   chk_ordr_to_prcs_num
517   (p_css_rltd_per_per_in_ler_id  => p_rec.css_rltd_per_per_in_ler_id,
518    p_ordr_to_prcs_num      => p_rec.ordr_to_prcs_num,
519    p_ler_id                => p_rec.ler_id,
520    p_business_group_id     => p_rec.business_group_id,
521    p_effective_date        => p_effective_date,
522    p_validation_start_date => p_validation_start_date,
523    p_validation_end_date   => p_validation_end_date,
524    p_object_version_number => p_rec.object_version_number);
525   --
526   chk_rsltg_ler_id
527   (p_css_rltd_per_per_in_ler_id  => p_rec.css_rltd_per_per_in_ler_id,
528    p_rsltg_ler_id          => p_rec.rsltg_ler_id,
529    p_ler_id                => p_rec.ler_id,
530    p_business_group_id     => p_rec.business_group_id,
531    p_effective_date        => p_effective_date,
532    p_validation_start_date => p_validation_start_date,
533    p_validation_end_date   => p_validation_end_date,
534    p_object_version_number => p_rec.object_version_number);
535   --
536   hr_utility.set_location(' Leaving:'||l_proc, 10);
537 End insert_validate;
538 --
539 -- ----------------------------------------------------------------------------
540 -- |---------------------------< update_validate >----------------------------|
541 -- ----------------------------------------------------------------------------
542 Procedure update_validate
543 	(p_rec 			 in ben_csr_shd.g_rec_type,
544 	 p_effective_date	 in date,
545 	 p_datetrack_mode	 in varchar2,
549   l_proc	varchar2(72) := g_package||'update_validate';
546 	 p_validation_start_date in date,
547 	 p_validation_end_date	 in date) is
548 --
550 --
551 Begin
552   hr_utility.set_location('Entering:'||l_proc, 5);
553   --
554   -- Call all supporting business operations
555   --
556   --
557   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
558   --
559   chk_css_rltd_per_per_in_ler_id
560   (p_css_rltd_per_per_in_ler_id          => p_rec.css_rltd_per_per_in_ler_id,
561    p_effective_date        => p_effective_date,
562    p_object_version_number => p_rec.object_version_number);
563   --
564   chk_ordr_to_prcs_num
565   (p_css_rltd_per_per_in_ler_id  => p_rec.css_rltd_per_per_in_ler_id,
566    p_ordr_to_prcs_num      => p_rec.ordr_to_prcs_num,
567    p_ler_id                => p_rec.ler_id,
568    p_business_group_id     => p_rec.business_group_id,
569    p_effective_date        => p_effective_date,
570    p_validation_start_date => p_validation_start_date,
571    p_validation_end_date   => p_validation_end_date,
572    p_object_version_number => p_rec.object_version_number);
573   --
574   chk_rsltg_ler_id
575   (p_css_rltd_per_per_in_ler_id  => p_rec.css_rltd_per_per_in_ler_id,
576    p_rsltg_ler_id          => p_rec.rsltg_ler_id,
577    p_ler_id                => p_rec.ler_id,
578    p_business_group_id     => p_rec.business_group_id,
579    p_effective_date        => p_effective_date,
580    p_validation_start_date => p_validation_start_date,
581    p_validation_end_date   => p_validation_end_date,
582    p_object_version_number => p_rec.object_version_number);
583   --
584   -- Call the datetrack update integrity operation
585   --
586   dt_update_validate
587     (p_ler_id                        => p_rec.ler_id,
588      p_rsltg_ler_id                  => p_rec.rsltg_ler_id,
589      p_datetrack_mode                => p_datetrack_mode,
590      p_validation_start_date	       => p_validation_start_date,
591      p_validation_end_date	       => p_validation_end_date);
592   --
593   hr_utility.set_location(' Leaving:'||l_proc, 10);
594 End update_validate;
595 --
596 -- ----------------------------------------------------------------------------
597 -- |---------------------------< delete_validate >----------------------------|
598 -- ----------------------------------------------------------------------------
599 Procedure delete_validate
600 	(p_rec 			 in ben_csr_shd.g_rec_type,
601 	 p_effective_date	 in date,
602 	 p_datetrack_mode	 in varchar2,
603 	 p_validation_start_date in date,
604 	 p_validation_end_date	 in date) is
605 --
606   l_proc	varchar2(72) := g_package||'delete_validate';
607 --
608 Begin
609   hr_utility.set_location('Entering:'||l_proc, 5);
610   --
611   -- Call all supporting business operations
612   --
613   dt_delete_validate
614     (p_datetrack_mode		=> p_datetrack_mode,
615      p_validation_start_date	=> p_validation_start_date,
616      p_validation_end_date	=> p_validation_end_date,
617      p_css_rltd_per_per_in_ler_id		=> p_rec.css_rltd_per_per_in_ler_id);
618   --
619   hr_utility.set_location(' Leaving:'||l_proc, 10);
620 End delete_validate;
621 --
622 --
623 --  ---------------------------------------------------------------------------
624 --  |---------------------< return_legislation_code >-------------------------|
625 --  ---------------------------------------------------------------------------
626 --
627 function return_legislation_code
628   (p_css_rltd_per_per_in_ler_id in number) return varchar2 is
629   --
630   -- Declare cursor
631   --
632   cursor csr_leg_code is
633     select a.legislation_code
634     from   per_business_groups a,
635            ben_css_rltd_per_per_in_ler_f b
636     where b.css_rltd_per_per_in_ler_id      = p_css_rltd_per_per_in_ler_id
637     and   a.business_group_id = b.business_group_id;
638   --
639   -- Declare local variables
640   --
641   l_legislation_code  varchar2(150);
642   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
643   --
644 begin
645   --
646   hr_utility.set_location('Entering:'|| l_proc, 10);
647   --
648   -- Ensure that all the mandatory parameter are not null
649   --
650   hr_api.mandatory_arg_error(p_api_name       => l_proc,
651                              p_argument       => 'css_rltd_per_per_in_ler_id',
652                              p_argument_value => p_css_rltd_per_per_in_ler_id);
653   --
654   open csr_leg_code;
655     --
656     fetch csr_leg_code into l_legislation_code;
657     --
658     if csr_leg_code%notfound then
659       --
660       close csr_leg_code;
661       --
662       -- The primary key is invalid therefore we must error
663       --
664       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
665       fnd_message.raise_error;
666       --
667     end if;
668     --
669   close csr_leg_code;
670   --
671   hr_utility.set_location(' Leaving:'|| l_proc, 20);
672   --
673   return l_legislation_code;
674   --
675 end return_legislation_code;
676 --
677 end ben_csr_bus;