DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BMI_BUS

Source


1 Package Body ben_bmi_bus as
2 /* $Header: bebmirhi.pkb 115.5 2002/12/09 12:38:22 lakrish ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_bmi_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_batch_commu_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 --   batch_commu_id PK of record being inserted or updated.
24 --   object_version_number Object version number of record being
25 --                         inserted or updated.
26 --
27 -- Post Success
28 --   Processing continues
29 --
30 -- Post Failure
31 --   Errors handled by the procedure
32 --
33 -- Access Status
34 --   Internal table handler use only.
35 --
36 Procedure chk_batch_commu_id(p_batch_commu_id                in number,
37                            p_object_version_number       in number) is
38   --
39   l_proc         varchar2(72) := g_package||'chk_batch_commu_id';
40   l_api_updating boolean;
41   --
42 Begin
43   --
44   hr_utility.set_location('Entering:'||l_proc, 5);
45   --
46   l_api_updating := ben_bmi_shd.api_updating
47     (p_batch_commu_id                => p_batch_commu_id,
48      p_object_version_number       => p_object_version_number);
49   --
50   if (l_api_updating
51      and nvl(p_batch_commu_id,hr_api.g_number)
52      <>  ben_bmi_shd.g_old_rec.batch_commu_id) then
53     --
54     -- raise error as PK has changed
55     --
56     ben_bmi_shd.constraint_error('BATCH_COMMU_INFO_PK');
57     --
58   elsif not l_api_updating then
59     --
60     -- check if PK is null
61     --
62     if p_batch_commu_id is not null then
63       --
64       -- raise error as PK is not null
65       --
66       ben_bmi_shd.constraint_error('BATCH_COMMU_INFO_PK');
67       --
68     end if;
69     --
70   end if;
71   --
72   hr_utility.set_location('Leaving:'||l_proc, 10);
73   --
74 End chk_batch_commu_id;
75 --
76 --
77 -- ----------------------------------------------------------------------------
78 -- |---------------------------< insert_validate >----------------------------|
79 -- ----------------------------------------------------------------------------
80 Procedure insert_validate(p_rec in ben_bmi_shd.g_rec_type) is
81 --
82   l_proc  varchar2(72) := g_package||'insert_validate';
83 --
84 Begin
85   hr_utility.set_location('Entering:'||l_proc, 5);
86   --
87   -- Call all supporting business operations
88   --
89   --
90   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
91   --
92   chk_batch_commu_id
93   (p_batch_commu_id          => p_rec.batch_commu_id,
94    p_object_version_number => p_rec.object_version_number);
95   --
96   hr_utility.set_location(' Leaving:'||l_proc, 10);
97 End insert_validate;
98 --
99 -- ----------------------------------------------------------------------------
100 -- |---------------------------< update_validate >----------------------------|
101 -- ----------------------------------------------------------------------------
102 Procedure update_validate(p_rec in ben_bmi_shd.g_rec_type) is
103 --
104   l_proc  varchar2(72) := g_package||'update_validate';
105 --
106 Begin
107   hr_utility.set_location('Entering:'||l_proc, 5);
108   --
109   -- Call all supporting business operations
110   --
111   --
112   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
113   --
114   chk_batch_commu_id
115   (p_batch_commu_id          => p_rec.batch_commu_id,
116    p_object_version_number => p_rec.object_version_number);
117   --
118   hr_utility.set_location(' Leaving:'||l_proc, 10);
119 End update_validate;
120 --
121 -- ----------------------------------------------------------------------------
122 -- |---------------------------< delete_validate >----------------------------|
123 -- ----------------------------------------------------------------------------
124 Procedure delete_validate(p_rec in ben_bmi_shd.g_rec_type) is
125 --
126   l_proc  varchar2(72) := g_package||'delete_validate';
127 --
128 Begin
129   hr_utility.set_location('Entering:'||l_proc, 5);
130   --
131   -- Call all supporting business operations
132   --
133   hr_utility.set_location(' Leaving:'||l_proc, 10);
134 End delete_validate;
135 --
136 --
137 --  ---------------------------------------------------------------------------
138 --  |---------------------< return_legislation_code >-------------------------|
139 --  ---------------------------------------------------------------------------
140 --
141 function return_legislation_code
142   (p_batch_commu_id in number) return varchar2 is
143   --
144   -- Declare cursor
145   --
146   cursor csr_leg_code is
147     select a.legislation_code
148     from   per_business_groups a,
149            ben_batch_commu_info b
150     where b.batch_commu_id      = p_batch_commu_id
151     and   a.business_group_id = b.business_group_id;
152   --
153   -- Declare local variables
154   --
155   l_legislation_code  varchar2(150);
156   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
157   --
158 begin
159   --
160   hr_utility.set_location('Entering:'|| l_proc, 10);
161   --
162   -- Ensure that all the mandatory parameter are not null
163   --
164   hr_api.mandatory_arg_error(p_api_name       => l_proc,
165                              p_argument       => 'batch_commu_id',
166                              p_argument_value => p_batch_commu_id);
167   --
168   open csr_leg_code;
169     --
170     fetch csr_leg_code into l_legislation_code;
171     --
172     if csr_leg_code%notfound then
173       --
174       close csr_leg_code;
175       --
176       -- The primary key is invalid therefore we must error
177       --
178       hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
179       hr_utility.raise_error;
180       --
181     end if;
182     --
183   close csr_leg_code;
184   --
185   hr_utility.set_location(' Leaving:'|| l_proc, 20);
186   --
187   return l_legislation_code;
188   --
189 end return_legislation_code;
190 --
191 end ben_bmi_bus;