DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_HWR_BUS

Source


4 -- ----------------------------------------------------------------------------
1 Package Body ben_hwr_bus as
2 /* $Header: behwrrhi.pkb 120.2 2006/03/30 23:55:04 gsehgal noship $ */
3 --
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_hwr_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_hrs_wkd_in_perd_rt_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 --   hrs_wkd_in_perd_rt_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_hrs_wkd_in_perd_rt_id(p_hrs_wkd_in_perd_rt_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_hrs_wkd_in_perd_rt_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_hwr_shd.api_updating
49     (p_effective_date              => p_effective_date,
50      p_hrs_wkd_in_perd_rt_id                => p_hrs_wkd_in_perd_rt_id,
51      p_object_version_number       => p_object_version_number);
52   --
53   if (l_api_updating
54      and nvl(p_hrs_wkd_in_perd_rt_id,hr_api.g_number)
55      <>  ben_hwr_shd.g_old_rec.hrs_wkd_in_perd_rt_id) then
56     --
57     -- raise error as PK has changed
58     --
59     ben_hwr_shd.constraint_error('BEN_HRS_WORKED_IN_PERD_RT_PK');
60     --
61   elsif not l_api_updating then
62     --
63     -- check if PK is null
64     --
65     if p_hrs_wkd_in_perd_rt_id is not null then
66       --
67       -- raise error as PK is not null
68       --
69       ben_hwr_shd.constraint_error('BEN_HRS_WORKED_IN_PERD_RT_PK');
70       --
71     end if;
72     --
73   end if;
74   --
75   hr_utility.set_location('Leaving:'||l_proc, 10);
76   --
77 End chk_hrs_wkd_in_perd_rt_id;
78 --
79 -- ----------------------------------------------------------------------------
80 -- |------< chk_hrs_wkd_in_perd_fctr_id >------|
81 -- ----------------------------------------------------------------------------
82 --
83 -- Description
84 --   This procedure checks that a referenced foreign key actually exists
85 --   in the referenced table.
86 --
87 -- Pre-Conditions
88 --   None.
89 --
90 -- In Parameters
91 --   p_hrs_wkd_in_perd_rt_id PK
92 --   p_hrs_wkd_in_perd_fctr_id ID of FK column
93 --   p_effective_date session date
94 --   p_object_version_number object version number
95 --
96 -- Post Success
97 --   Processing continues
98 --
99 -- Post Failure
100 --   Error raised.
101 --
102 -- Access Status
103 --   Internal table handler use only.
104 --
105 Procedure chk_hrs_wkd_in_perd_fctr_id (p_hrs_wkd_in_perd_rt_id          in number,
106                             p_hrs_wkd_in_perd_fctr_id          in number,
107                             p_effective_date        in date,
108                             p_object_version_number in number) is
109   --
110   l_proc         varchar2(72) := g_package||'chk_hrs_wkd_in_perd_fctr_id';
111   l_api_updating boolean;
112   l_dummy        varchar2(1);
113   --
114   cursor c1 is
115     select null
116     from   ben_hrs_wkd_in_perd_fctr a
117     where  a.hrs_wkd_in_perd_fctr_id = p_hrs_wkd_in_perd_fctr_id;
118   --
119 Begin
120   --
121   hr_utility.set_location('Entering:'||l_proc,5);
122   --
123   l_api_updating := ben_hwr_shd.api_updating
124      (p_hrs_wkd_in_perd_rt_id            => p_hrs_wkd_in_perd_rt_id,
125       p_effective_date          => p_effective_date,
126       p_object_version_number   => p_object_version_number);
127   --
128   if (l_api_updating
129      and nvl(p_hrs_wkd_in_perd_fctr_id,hr_api.g_number)
130      <> nvl(ben_hwr_shd.g_old_rec.hrs_wkd_in_perd_fctr_id,hr_api.g_number)
131      or not l_api_updating) and
132      p_hrs_wkd_in_perd_fctr_id is not null then
133     --
134     -- check if hrs_wkd_in_perd_fctr_id value exists in ben_hrs_wkd_in_perd_fctr table
135     --
136     open c1;
137       --
138       fetch c1 into l_dummy;
139       if c1%notfound then
140         --
141         close c1;
142         --
143         -- raise error as FK does not relate to PK in ben_hrs_wkd_in_perd_fctr
144         -- table.
145         --
146         ben_hwr_shd.constraint_error('BEN_HRS_WORKED_IN_PERD_RT_FK1');
147         --
148       end if;
149       --
150     close c1;
151     --
152   end if;
153   --
154   hr_utility.set_location('Leaving:'||l_proc,10);
155   --
159 -- ----------------------------------------------------------------------------
156 End chk_hrs_wkd_in_perd_fctr_id;
157 -- ----------------------------------------------------------------------------
158 -- |------< chk_dup_record >------|
160 --
161 -- Description
162 --   This procedure is used to check that there is no duplicate record
163 --
164 -- Pre Conditions
165 --   None.
166 --
167 -- In Parameters
168 --   p_hrs_wkd_in_perd_rt_id PK of record being inserted or updated.
169 --   p_hrs_wkd_in_perd_fctr_id Value of FK
170 --   p_vrbl_rt_prfl_id	     FK of the record
171 --   p_effective_date 	     effective date
172 --   p_object_version_number Object version number of record being
173 --                           inserted or updated.
174 --   p_business_group_id     business_group_id of the record
175 --   p_validation_start_date validation_start_date of record
176 --   p_validation_end_date   validation_end_date of record
177 --
178 -- Post Success
179 --   Processing continues
180 --
181 -- Post Failure
182 --   Error handled by procedure
183 --
184 -- Access Status
185 --   Internal table handler use only.
186 --
187 Procedure chk_dup_record
191 		      p_effective_date        in date,
188 		     (p_hrs_wkd_in_perd_rt_id   in number,
189 		      p_hrs_wkd_in_perd_fctr_id in number,
190 		      p_vrbl_rt_prfl_id	      in number,
192 		      p_object_version_number in number,
193 		      p_business_group_id     in number,
194 		      p_validation_start_date in date,
195 		      p_validation_end_date   in date )
196 is
197 --
198 l_proc         varchar2(72) := g_package||'chk_dup_record';
199 l_api_updating boolean;
200 l_exists       varchar2(1);
201 --
202 cursor c_dup is
203 select null
204 from ben_hrs_wkd_in_perd_rt_f
205 where hrs_wkd_in_perd_fctr_id = p_hrs_wkd_in_perd_fctr_id
206 and vrbl_rt_prfl_id = p_vrbl_rt_prfl_id
207 and hrs_wkd_in_perd_rt_id <> nvl(p_hrs_wkd_in_perd_rt_id,hr_api.g_number)
208 and business_group_id + 0 = p_business_group_id
209 and p_validation_start_date <= effective_end_date
210 and p_validation_end_date >= effective_start_date;
211 --
212 BEGIN
213 --
214   hr_utility.set_location('Entering:'||l_proc, 5);
215   --
216   l_api_updating := ben_hwr_shd.api_updating
217     (p_hrs_wkd_in_perd_rt_id       => p_hrs_wkd_in_perd_rt_id,
218      p_effective_date              => p_effective_date,
219      p_object_version_number       => p_object_version_number);
220   --
221   if (l_api_updating
222       and p_hrs_wkd_in_perd_fctr_id <> nvl(ben_hwr_shd.g_old_rec.hrs_wkd_in_perd_fctr_id,hr_api.g_number)
223       or not l_api_updating) then
224 
225 	open c_dup;
226 	fetch c_dup into l_exists;
227 	if c_dup%found then
228 		close c_dup;
229 		--
230 		-- raise error as this Hours Worked in Period criteria already exists for this profile
231 		--
232 		fnd_message.set_name('BEN', 'BEN_92992_DUPS_ROW');
233 		fnd_message.set_token('VAR1','Hours Worked in Period criteria',TRUE);
234 		fnd_message.set_token('VAR2','Variable Rate Profile',TRUE);
235 		fnd_message.raise_error;
236 		--
237 	end if;
238 	close c_dup;
239 	--
240   end if;
241   hr_utility.set_location('Leaving:'||l_proc,10);
242   --
243 END chk_dup_record;
244 
245 --
246 -- |--------------------< chk_duplicate_ordr_num >----------------------------|
247 -- ----------------------------------------------------------------------------
248 --
249 -- Description
250 --
251 -- Pre Conditions
252 --   None.
253 --
254 -- In Parameters
255 --    p_vrbl_rt_prfl_id
256 --    p_ordr_num
257 --    p_effective_date
258 --    p_business_group_id
259 --
260 -- Post Success
261 --   Processing continues
262 --
263 -- Post Failure
264 --   Errors handled by the procedure
265 --
266 -- Access Status
267 --   Internal table handler use only.
268 --
269 -- ----------------------------------------------------------------------------
270 procedure chk_duplicate_ordr_num
271           (p_vrbl_rt_prfl_id in number
272            ,p_ordr_num in number
273            ,p_validation_start_date in date
274 	   ,p_validation_end_date in date
275            ,p_business_group_id in number
276            ,p_hrs_wkd_in_perd_rt_id in number)
277 is
278    l_proc   varchar2(72) := g_package||' chk_duplicate_ordr_num ';
279    l_dummy    char(1);
280    cursor c1 is select null
281                   from ben_hrs_wkd_in_perd_rt_f
282                  where vrbl_rt_prfl_id = p_vrbl_rt_prfl_id
283 		 -- CHANGED for Bug 5078478 .. commented the previous query and added new one
284                  --  and p_hrs_wkd_in_perd_rt_id <> nvl(p_hrs_wkd_in_perd_rt_id,-1)
288 		   and p_validation_start_date <= effective_end_date
285 		   and hrs_wkd_in_perd_rt_id <> nvl(p_hrs_wkd_in_perd_rt_id,-1)
286                    --and p_effective_date between effective_start_date
287                    --                         and effective_end_date
289 		   and p_validation_end_date >= effective_start_date
290                    and business_group_id + 0 = p_business_group_id
291                    and ordr_num = p_ordr_num;
292 --
293 Begin
294    hr_utility.set_location('Entering:'||l_proc, 5);
295 
296    --
297    open c1;
298    fetch c1 into l_dummy;
299    --
300    if c1%found then
301       fnd_message.set_name('BEN','BEN_91001_SEQ_NOT_UNIQUE');
302       fnd_message.raise_error;
303    end if;
304    close c1;
305    --
306    hr_utility.set_location('Leaving:'||l_proc, 15);
307 End chk_duplicate_ordr_num;
308 
309 --
310 -- ----------------------------------------------------------------------------
311 -- |------< chk_excld_flag >------|
312 -- ----------------------------------------------------------------------------
313 --
314 -- Description
315 --   This procedure is used to check that the lookup value is valid.
316 --
317 -- Pre Conditions
318 --   None.
319 --
320 -- In Parameters
321 --   hrs_wkd_in_perd_rt_id PK of record being inserted or updated.
322 --   excld_flag Value of lookup code.
323 --   effective_date effective date
324 --   object_version_number Object version number of record being
325 --                         inserted or updated.
326 --
327 -- Post Success
328 --   Processing continues
329 --
330 -- Post Failure
331 --   Error handled by procedure
332 --
333 -- Access Status
334 --   Internal table handler use only.
335 --
336 Procedure chk_excld_flag(p_hrs_wkd_in_perd_rt_id                in number,
337                             p_excld_flag               in varchar2,
338                             p_effective_date              in date,
339                             p_object_version_number       in number) is
340   --
341   l_proc         varchar2(72) := g_package||'chk_excld_flag';
342   l_api_updating boolean;
343   --
344 Begin
345   --
346   hr_utility.set_location('Entering:'||l_proc, 5);
347   --
348   l_api_updating := ben_hwr_shd.api_updating
349     (p_hrs_wkd_in_perd_rt_id                => p_hrs_wkd_in_perd_rt_id,
350      p_effective_date              => p_effective_date,
351      p_object_version_number       => p_object_version_number);
352   --
353   if (l_api_updating
354       and p_excld_flag
355       <> nvl(ben_hwr_shd.g_old_rec.excld_flag,hr_api.g_varchar2)
356       or not l_api_updating) then
357     --
358     -- check if value of lookup falls within lookup type.
359     --
360     --
361     if hr_api.not_exists_in_hr_lookups
362           (p_lookup_type    => 'YES_NO',
363            p_lookup_code    => p_excld_flag,
364            p_effective_date => p_effective_date) then
365       --
366       -- raise error as does not exist as lookup
367       --
368       hr_utility.set_message(801,'HR_LOOKUP_DOES_NOT_EXIST');
369       hr_utility.raise_error;
370       --
371     end if;
372     --
373   end if;
374   --
375   hr_utility.set_location('Leaving:'||l_proc,10);
376   --
377 end chk_excld_flag;
378 --
379 -- ----------------------------------------------------------------------------
380 -- |-------------------< chk_hrs_wkd_in_perd_fctr_id >------------------------|
381 -- ----------------------------------------------------------------------------
382 --
383 -- Description
384 --   This procedure is used to check that the foreign key for the table
385 --   is created properly. a corresponding record should exist in the
386 --   BEN_HRS_WKD_IN_PERD_FCTR table.
387 --
388 -- Pre Conditions
389 --   None.
390 --
391 -- In Parameters
392 --   hrs_wkd_in_perd_fctr_id FK of pointing to BEN_HRS_WKD_IN_PERD_FCTR tables.
393 --   business_group_id or record being inserted or updated
394 --
395 -- Post Success
396 --   Processing continues
397 --
398 -- Post Failure
399 --   Errors handled by the procedure
400 --
401 -- Access Status
402 --   Internal table handler use only.
403 --
404 Procedure chk_hrs_wkd_in_perd_fctr_id(p_hrs_wkd_in_perd_fctr_id in number,
405                                       p_business_group_id   in number) is
406   --
407   l_proc         varchar2(72) := g_package||'chk_hrs_wkd_in_perd_fctr_id';
408   l_dummy        varchar2(1);
409   cursor c1 is select  null
410                from    BEN_HRS_WKD_IN_PERD_FCTR
414 
411                where   hrs_wkd_in_perd_fctr_id = p_hrs_wkd_in_perd_fctr_id
412                and     business_group_id = p_business_group_id;
413   --
415 Begin
416   --
417   hr_utility.set_location('Entering:'||l_proc, 5);
418   --
419   if p_hrs_wkd_in_perd_fctr_id is not null then
420      open c1;
421      fetch c1 into l_dummy;
422      if c1%notfound then
423         hr_utility.set_message(801,'Hrs_Wkd_NotExist');
424         hr_utility.raise_error;
425      end if;
426      close c1;
427   end if;
428   --
429   hr_utility.set_location('Leaving:'||l_proc, 10);
430   --
431 End  chk_hrs_wkd_in_perd_fctr_id;
432 --
433 -- ----------------------------------------------------------------------------
434 -- |--------------------------< dt_update_validate >--------------------------|
435 -- ----------------------------------------------------------------------------
436 -- {Start Of Comments}
437 --
438 -- Description:
439 --   This procedure is used for referential integrity of datetracked
440 --   parent entities when a datetrack update operation is taking place
441 --   and where there is no cascading of update defined for this entity.
442 --
443 -- Prerequisites:
444 --   This procedure is called from the update_validate.
445 --
446 -- In Parameters:
447 --
448 -- Post Success:
449 --   Processing continues.
450 --
451 -- Post Failure:
452 --
453 -- Developer Implementation Notes:
454 --   This procedure should not need maintenance unless the HR Schema model
455 --   changes.
456 --
457 -- Access Status:
458 --   Internal Row Handler Use Only.
459 --
460 -- {End Of Comments}
461 -- ----------------------------------------------------------------------------
462 Procedure dt_update_validate
463             (p_vrbl_rt_prfl_id               in number default hr_api.g_number,
464 	     p_datetrack_mode		     in varchar2,
465              p_validation_start_date	     in date,
466 	     p_validation_end_date	     in date) Is
467 --
468   l_proc	    varchar2(72) := g_package||'dt_update_validate';
469   l_integrity_error Exception;
470   l_table_name	    all_tables.table_name%TYPE;
471 --
472 Begin
473   hr_utility.set_location('Entering:'||l_proc, 5);
474   --
475   -- Ensure that the p_datetrack_mode argument is not null
476   --
477   hr_api.mandatory_arg_error
478     (p_api_name       => l_proc,
479      p_argument       => 'datetrack_mode',
480      p_argument_value => p_datetrack_mode);
481   --
482   -- Only perform the validation if the datetrack update mode is valid
483   --
484   If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
485     --
486     --
487     -- Ensure the arguments are not null
488     --
489     hr_api.mandatory_arg_error
490       (p_api_name       => l_proc,
491        p_argument       => 'validation_start_date',
492        p_argument_value => p_validation_start_date);
493     --
494     hr_api.mandatory_arg_error
495       (p_api_name       => l_proc,
496        p_argument       => 'validation_end_date',
497        p_argument_value => p_validation_end_date);
498     --
499     If ((nvl(p_vrbl_rt_prfl_id, hr_api.g_number) <> hr_api.g_number) and
500       NOT (dt_api.check_min_max_dates
501             (p_base_table_name => 'ben_vrbl_rt_prfl_f',
502              p_base_key_column => 'vrbl_rt_prfl_id',
503              p_base_key_value  => p_vrbl_rt_prfl_id,
504              p_from_date       => p_validation_start_date,
505              p_to_date         => p_validation_end_date)))  Then
506       l_table_name := 'ben_vrbl_rt_prfl_f';
507       Raise l_integrity_error;
508     End If;
509     --
510   End If;
511   --
512   hr_utility.set_location(' Leaving:'||l_proc, 10);
513 Exception
514   When l_integrity_error Then
515     --
516     -- A referential integrity check was violated therefore
517     -- we must error
518     --
519        ben_utility.parent_integrity_error (p_table_name => l_table_name);
520     --
521   When Others Then
522     --
523     -- An unhandled or unexpected error has occurred which
524     -- we must report
525     --
526     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
527     hr_utility.set_message_token('PROCEDURE', l_proc);
528     hr_utility.set_message_token('STEP','15');
529     hr_utility.raise_error;
530 End dt_update_validate;
531 --
532 -- ----------------------------------------------------------------------------
533 -- |--------------------------< dt_delete_validate >--------------------------|
534 -- ----------------------------------------------------------------------------
535 -- {Start Of Comments}
536 --
537 -- Description:
538 --   This procedure is used for referential integrity of datetracked
539 --   child entities when either a datetrack DELETE or ZAP is in operation
540 --   and where there is no cascading of delete defined for this entity.
541 --   For the datetrack mode of DELETE or ZAP we must ensure that no
542 --   datetracked child rows exist between the validation start and end
543 --   dates.
544 --
545 -- Prerequisites:
546 --   This procedure is called from the delete_validate.
547 --
548 -- In Parameters:
549 --
550 -- Post Success:
551 --   Processing continues.
552 --
553 -- Post Failure:
554 --   If a row exists by determining the returning Boolean value from the
555 --   generic dt_api.rows_exist function then we must supply an error via
559 --   This procedure should not need maintenance unless the HR Schema model
556 --   the use of the local exception handler l_rows_exist.
557 --
558 -- Developer Implementation Notes:
560 --   changes.
561 --
562 -- Access Status:
563 --   Internal Row Handler Use Only.
564 --
565 -- {End Of Comments}
566 -- ----------------------------------------------------------------------------
567 Procedure dt_delete_validate
568             (p_hrs_wkd_in_perd_rt_id		in number,
569              p_datetrack_mode		in varchar2,
570 	     p_validation_start_date	in date,
571 	     p_validation_end_date	in date) Is
572 --
573   l_proc	varchar2(72) 	:= g_package||'dt_delete_validate';
574   l_rows_exist	Exception;
575   l_table_name	all_tables.table_name%TYPE;
576 --
577 Begin
578   hr_utility.set_location('Entering:'||l_proc, 5);
579   --
580   -- Ensure that the p_datetrack_mode argument is not null
581   --
582   hr_api.mandatory_arg_error
583     (p_api_name       => l_proc,
584      p_argument       => 'datetrack_mode',
585      p_argument_value => p_datetrack_mode);
586   --
587   -- Only perform the validation if the datetrack mode is either
588   -- DELETE or ZAP
589   --
590   If (p_datetrack_mode = 'DELETE' or
591       p_datetrack_mode = 'ZAP') then
592     --
593     --
594     -- Ensure the arguments are not null
595     --
596     hr_api.mandatory_arg_error
597       (p_api_name       => l_proc,
598        p_argument       => 'validation_start_date',
599        p_argument_value => p_validation_start_date);
600     --
601     hr_api.mandatory_arg_error
602       (p_api_name       => l_proc,
603        p_argument       => 'validation_end_date',
604        p_argument_value => p_validation_end_date);
605     --
606     hr_api.mandatory_arg_error
607       (p_api_name       => l_proc,
608        p_argument       => 'hrs_wkd_in_perd_rt_id',
609        p_argument_value => p_hrs_wkd_in_perd_rt_id);
610     --
611     --
612     --
613   End If;
614   --
615   hr_utility.set_location(' Leaving:'||l_proc, 10);
616 Exception
617   When l_rows_exist Then
618     --
619     -- A referential integrity check was violated therefore
620     -- we must error
621     --
622     hr_utility.set_message(801, 'HR_7215_DT_CHILD_EXISTS');
623     hr_utility.set_message_token('TABLE_NAME', l_table_name);
624     hr_utility.raise_error;
625   When Others Then
626     --
627     -- An unhandled or unexpected error has occurred which
628     -- we must report
629     --
630     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
631     hr_utility.set_message_token('PROCEDURE', l_proc);
632     hr_utility.set_message_token('STEP','15');
633     hr_utility.raise_error;
634 End dt_delete_validate;
635 --
636 -- ----------------------------------------------------------------------------
637 -- |---------------------------< insert_validate >----------------------------|
638 -- ----------------------------------------------------------------------------
639 Procedure insert_validate
640 	(p_rec 			 in ben_hwr_shd.g_rec_type,
641 	 p_effective_date	 in date,
642 	 p_datetrack_mode	 in varchar2,
643 	 p_validation_start_date in date,
644 	 p_validation_end_date	 in date) is
645 --
646   l_proc	varchar2(72) := g_package||'insert_validate';
647 --
648 Begin
649   hr_utility.set_location('Entering:'||l_proc, 5);
650   --
651   -- Call all supporting business operations
652   --
653   --
654   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
655   --
656   chk_hrs_wkd_in_perd_rt_id
657   (p_hrs_wkd_in_perd_rt_id          => p_rec.hrs_wkd_in_perd_rt_id,
658    p_effective_date        => p_effective_date,
659    p_object_version_number => p_rec.object_version_number);
660   --
661   chk_hrs_wkd_in_perd_fctr_id
662   (p_hrs_wkd_in_perd_rt_id          => p_rec.hrs_wkd_in_perd_rt_id,
663    p_hrs_wkd_in_perd_fctr_id          => p_rec.hrs_wkd_in_perd_fctr_id,
664    p_effective_date        => p_effective_date,
665    p_object_version_number => p_rec.object_version_number);
666   --
667   chk_dup_record
668   (p_hrs_wkd_in_perd_rt_id => p_rec.hrs_wkd_in_perd_rt_id,
669    p_hrs_wkd_in_perd_fctr_id => p_rec.hrs_wkd_in_perd_fctr_id,
670    p_vrbl_rt_prfl_id	   => p_rec.vrbl_rt_prfl_id,
671    p_effective_date        => p_effective_date,
672    p_object_version_number => p_rec.object_version_number,
673    p_business_group_id     => p_rec.business_group_id,
674    p_validation_start_date => p_validation_start_date,
675    p_validation_end_date   => p_validation_end_date);
676   --
677   chk_excld_flag
678   (p_hrs_wkd_in_perd_rt_id          => p_rec.hrs_wkd_in_perd_rt_id,
679    p_excld_flag         => p_rec.excld_flag,
680    p_effective_date        => p_effective_date,
681    p_object_version_number => p_rec.object_version_number);
682   --
683   chk_hrs_wkd_in_perd_fctr_id
684   (p_hrs_wkd_in_perd_fctr_id => p_rec.hrs_wkd_in_perd_fctr_id,
685    p_business_group_id       => p_rec.business_group_id);
686   --
687 chk_duplicate_ordr_num
688           (p_vrbl_rt_prfl_id      => p_rec.vrbl_rt_prfl_id
689            ,p_ordr_num            => p_rec.ordr_num
690            ,p_validation_start_date => p_validation_start_date
691 	   ,p_validation_end_date => p_validation_end_date
692            ,p_business_group_id   => p_rec.business_group_id
693            ,p_hrs_wkd_in_perd_rt_id => p_rec.hrs_wkd_in_perd_rt_id);
694 --
695   hr_utility.set_location(' Leaving:'||l_proc, 10);
696 End insert_validate;
697 --
701 Procedure update_validate
698 -- ----------------------------------------------------------------------------
699 -- |---------------------------< update_validate >----------------------------|
700 -- ----------------------------------------------------------------------------
702 	(p_rec 			 in ben_hwr_shd.g_rec_type,
703 	 p_effective_date	 in date,
704 	 p_datetrack_mode	 in varchar2,
705 	 p_validation_start_date in date,
706 	 p_validation_end_date	 in date) is
707 --
708   l_proc	varchar2(72) := g_package||'update_validate';
709 --
710 Begin
711   hr_utility.set_location('Entering:'||l_proc, 5);
712   --
713   -- Call all supporting business operations
714   --
715   --
716   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
717   --
718   chk_hrs_wkd_in_perd_rt_id
719   (p_hrs_wkd_in_perd_rt_id          => p_rec.hrs_wkd_in_perd_rt_id,
720    p_effective_date        => p_effective_date,
721    p_object_version_number => p_rec.object_version_number);
722   --
723   chk_hrs_wkd_in_perd_fctr_id
724   (p_hrs_wkd_in_perd_rt_id          => p_rec.hrs_wkd_in_perd_rt_id,
725    p_hrs_wkd_in_perd_fctr_id          => p_rec.hrs_wkd_in_perd_fctr_id,
726    p_effective_date        => p_effective_date,
727    p_object_version_number => p_rec.object_version_number);
728   --
729   chk_dup_record
730   (p_hrs_wkd_in_perd_rt_id => p_rec.hrs_wkd_in_perd_rt_id,
731    p_hrs_wkd_in_perd_fctr_id => p_rec.hrs_wkd_in_perd_fctr_id,
732    p_vrbl_rt_prfl_id	   => p_rec.vrbl_rt_prfl_id,
733    p_effective_date        => p_effective_date,
734    p_object_version_number => p_rec.object_version_number,
735    p_business_group_id     => p_rec.business_group_id,
736    p_validation_start_date => p_validation_start_date,
737    p_validation_end_date   => p_validation_end_date);
738   --
739   chk_excld_flag
740   (p_hrs_wkd_in_perd_rt_id => p_rec.hrs_wkd_in_perd_rt_id,
741    p_excld_flag            => p_rec.excld_flag,
742    p_effective_date        => p_effective_date,
743    p_object_version_number => p_rec.object_version_number);
744   --
745   chk_hrs_wkd_in_perd_fctr_id
746   (p_hrs_wkd_in_perd_fctr_id => p_rec.hrs_wkd_in_perd_fctr_id,
747    p_business_group_id       => p_rec.business_group_id);
748   --
749   -- Call the datetrack update integrity operation
750   --
751   dt_update_validate
752     (
753      p_datetrack_mode                => p_datetrack_mode,
754      p_validation_start_date	     => p_validation_start_date,
755      p_validation_end_date	     => p_validation_end_date);
756   --
757 chk_duplicate_ordr_num
758           (p_vrbl_rt_prfl_id      => p_rec.vrbl_rt_prfl_id
759            ,p_ordr_num            => p_rec.ordr_num
760            ,p_validation_start_date => p_validation_start_date
761 	   ,p_validation_end_date => p_validation_end_date
762            ,p_business_group_id   => p_rec.business_group_id
763            ,p_hrs_wkd_in_perd_rt_id => p_rec.hrs_wkd_in_perd_rt_id);
764 --
765   hr_utility.set_location(' Leaving:'||l_proc, 10);
766 End update_validate;
767 --
768 -- ----------------------------------------------------------------------------
769 -- |---------------------------< delete_validate >----------------------------|
770 -- ----------------------------------------------------------------------------
771 Procedure delete_validate
772 	(p_rec 			 in ben_hwr_shd.g_rec_type,
773 	 p_effective_date	 in date,
774 	 p_datetrack_mode	 in varchar2,
775 	 p_validation_start_date in date,
776 	 p_validation_end_date	 in date) is
777 --
778   l_proc	varchar2(72) := g_package||'delete_validate';
779 --
780 Begin
781   hr_utility.set_location('Entering:'||l_proc, 5);
782   --
783   -- Call all supporting business operations
784   --
785   dt_delete_validate
786     (p_datetrack_mode		=> p_datetrack_mode,
787      p_validation_start_date	=> p_validation_start_date,
788      p_validation_end_date	=> p_validation_end_date,
789      p_hrs_wkd_in_perd_rt_id		=> p_rec.hrs_wkd_in_perd_rt_id);
790   --
791   hr_utility.set_location(' Leaving:'||l_proc, 10);
792 End delete_validate;
793 --
794 --
795 --  ---------------------------------------------------------------------------
796 --  |---------------------< return_legislation_code >-------------------------|
797 --  ---------------------------------------------------------------------------
798 --
799 function return_legislation_code
800   (p_hrs_wkd_in_perd_rt_id in number) return varchar2 is
801   --
802   -- Declare cursor
803   --
804   cursor csr_leg_code is
805     select a.legislation_code
806     from   per_business_groups a,
807            ben_hrs_wkd_in_perd_rt_f b
808     where b.hrs_wkd_in_perd_rt_id      = p_hrs_wkd_in_perd_rt_id
809     and   a.business_group_id = b.business_group_id;
810   --
811   -- Declare local variables
812   --
813   l_legislation_code  varchar2(150);
814   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
815   --
816 begin
817   --
818   hr_utility.set_location('Entering:'|| l_proc, 10);
819   --
820   -- Ensure that all the mandatory parameter are not null
821   --
822   hr_api.mandatory_arg_error(p_api_name       => l_proc,
823                              p_argument       => 'hrs_wkd_in_perd_rt_id',
824                              p_argument_value => p_hrs_wkd_in_perd_rt_id);
825   --
826   open csr_leg_code;
827     --
828     fetch csr_leg_code into l_legislation_code;
829     --
830     if csr_leg_code%notfound then
831       --
832       close csr_leg_code;
833       --
834       -- The primary key is invalid therefore we must error
835       --
836       hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
837       hr_utility.raise_error;
838       --
839     end if;
843   hr_utility.set_location(' Leaving:'|| l_proc, 20);
840     --
841   close csr_leg_code;
842   --
844   --
845   return l_legislation_code;
846   --
847 end return_legislation_code;
848 --
849 end ben_hwr_bus;