DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_BDT_BUS

Source


1 Package Body pay_bdt_bus as
2 /* $Header: pybdtrhi.pkb 120.3 2005/11/24 05:36 arashid noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_bdt_bus.';  -- Global package name
9 --
10 -- The following two global variables are only to be
11 -- used by the return_legislation_code function.
12 --
13 g_legislation_code            varchar2(150)  default null;
14 g_balance_dimension_id        number         default null;
15 g_language                    varchar2(4)    default null;
16 --
17 --  ---------------------------------------------------------------------------
18 --  |----------------------< set_security_group_id >--------------------------|
19 --  ---------------------------------------------------------------------------
20 --
21 Procedure set_security_group_id
22   (p_balance_dimension_id                 in number
23   ,p_associated_column1                   in varchar2 default null
24   ) is
25   --
26   -- Declare cursor. Note: this will fail if BUSINESS_GROUP_ID is NULL,
27   -- unlike the RETURN_LEGISLATION_CODE cursor.
28   --
29   cursor csr_sec_grp is
30     select pbg.security_group_id,
31            pbg.legislation_code
32       from per_business_groups_perf pbg
33          , pay_balance_dimensions pbd
34      where pbd.balance_dimension_id = p_balance_dimension_id
35        and pbg.business_group_id = pbd.business_group_id;
36   --
37   -- Declare local variables
38   --
39   l_security_group_id number;
40   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
41   l_legislation_code  varchar2(150);
42   --
43 begin
44   --
45   hr_utility.set_location('Entering:'|| l_proc, 10);
46   --
47   -- Ensure that all the mandatory parameter are not null
48   --
49   hr_api.mandatory_arg_error
50     (p_api_name           => l_proc
51     ,p_argument           => 'balance_dimension_id'
52     ,p_argument_value     => p_balance_dimension_id
53     );
54   --
55   --
56   open csr_sec_grp;
60   if csr_sec_grp%notfound then
57   fetch csr_sec_grp into l_security_group_id
58                        , l_legislation_code;
59   --
61      --
62      close csr_sec_grp;
63      --
64      -- The primary key is invalid therefore we must error
65      --
66      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
67      hr_multi_message.add
68        (p_associated_column1
69         => nvl(p_associated_column1,'BALANCE_DIMENSION_ID')
70        );
71      --
72   else
73     close csr_sec_grp;
74     --
75     -- Set the security_group_id in CLIENT_INFO
76     --
77     hr_api.set_security_group_id
78       (p_security_group_id => l_security_group_id
79       );
80     --
81     -- Set the sessions legislation context in HR_SESSION_DATA
82     --
83     hr_api.set_legislation_context(l_legislation_code);
84   end if;
85   --
86   hr_utility.set_location(' Leaving:'|| l_proc, 20);
87   --
88 end set_security_group_id;
89 --
90 --  ---------------------------------------------------------------------------
91 --  |---------------------< return_legislation_code >-------------------------|
92 --  ---------------------------------------------------------------------------
93 --
94 Function return_legislation_code
95   (p_balance_dimension_id                 in     number
96   ,p_language                             in     varchar2
97   )
98   Return Varchar2 Is
99   --
100   -- Declare cursor
101   cursor csr_leg_code is
102     select nvl(pbg.legislation_code, pbd.legislation_code)
103       from per_business_groups_perf pbg
104          , pay_balance_dimensions pbd
105      where pbd.balance_dimension_id = p_balance_dimension_id
106        and pbg.business_group_id (+)= pbd.business_group_id;
107   --
108   -- Declare local variables
109   --
110   l_legislation_code  varchar2(150);
111   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
112   --
113 Begin
114   --
115   hr_utility.set_location('Entering:'|| l_proc, 10);
116   --
117   -- Ensure that all the mandatory parameter are not null
118   --
119   hr_api.mandatory_arg_error
120     (p_api_name           => l_proc
121     ,p_argument           => 'balance_dimension_id'
122     ,p_argument_value     => p_balance_dimension_id
123     );
124   --
125   --
126   if (( nvl(pay_bdt_bus.g_balance_dimension_id, hr_api.g_number)
127        = p_balance_dimension_id)
128   and ( nvl(pay_bdt_bus.g_language, hr_api.g_varchar2)
129        = p_language)) then
130     --
131     -- The legislation code has already been found with a previous
132     -- call to this function. Just return the value in the global
133     -- variable.
134     --
135     l_legislation_code := pay_bdt_bus.g_legislation_code;
136     hr_utility.set_location(l_proc, 20);
137   else
138     --
139     -- The ID is different to the last call to this function
140     -- or this is the first call to this function.
141     --
142     open csr_leg_code;
143     fetch csr_leg_code into l_legislation_code;
144     --
145     if csr_leg_code%notfound then
146       --
147       -- The primary key is invalid therefore we must error
148       --
149       close csr_leg_code;
150       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
151       fnd_message.raise_error;
152     end if;
153     hr_utility.set_location(l_proc,30);
154     --
155     -- Set the global variables so the values are
156     -- available for the next call to this function.
157     --
158     close csr_leg_code;
159     pay_bdt_bus.g_balance_dimension_id        := p_balance_dimension_id;
160     pay_bdt_bus.g_language                    := p_language;
161     pay_bdt_bus.g_legislation_code  := l_legislation_code;
162   end if;
163   hr_utility.set_location(' Leaving:'|| l_proc, 40);
164   return l_legislation_code;
165 end return_legislation_code;
166 --
167 -- ----------------------------------------------------------------------------
168 -- |-----------------------< chk_non_updateable_args >------------------------|
169 -- ----------------------------------------------------------------------------
170 -- {Start Of Comments}
171 --
172 -- Description:
173 --   This procedure is used to ensure that non updateable attributes have
174 --   not been updated. If an attribute has been updated an error is generated.
175 --
176 -- Pre Conditions:
177 --   g_old_rec has been populated with details of the values currently in
178 --   the database.
179 --
180 -- In Arguments:
181 --   p_rec has been populated with the updated values the user would like the
182 --   record set to.
183 --
184 -- Post Success:
185 --   Processing continues if all the non updateable attributes have not
186 --   changed.
187 --
188 -- Post Failure:
189 --   An application error is raised if any of the non updatable attributes
190 --   have been altered.
191 --
192 -- {End Of Comments}
193 -- ----------------------------------------------------------------------------
194 Procedure chk_non_updateable_args
195   (p_rec in pay_bdt_shd.g_rec_type
196   ) IS
197 --
198   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
199 --
200 Begin
201   --
202   -- Only proceed with the validation if a row exists for the current
203   -- record in the HR Schema.
204   --
205   IF NOT pay_bdt_shd.api_updating
206       (p_balance_dimension_id              => p_rec.balance_dimension_id
207       ,p_language                          => p_rec.language
208       ) THEN
209      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
210      fnd_message.set_token('PROCEDURE ', l_proc);
211      fnd_message.set_token('STEP ', '5');
212      fnd_message.raise_error;
213   END IF;
214   --
215 End chk_non_updateable_args;
216 --
217 -- ----------------------------------------------------------------------------
218 -- |---------------------------< insert_validate >----------------------------|
219 -- ----------------------------------------------------------------------------
220 Procedure insert_validate
221   (p_rec                          in pay_bdt_shd.g_rec_type
222   ) is
223 --
224   l_proc  varchar2(72) := g_package||'insert_validate';
225 --
226 Begin
227   hr_utility.set_location('Entering:'||l_proc, 5);
228   --
229   -- Call all supporting business operations
230   --
231   -- Validate Dependent Attributes
232   --
233   --
234   hr_utility.set_location(' Leaving:'||l_proc, 10);
235 End insert_validate;
236 --
237 -- ----------------------------------------------------------------------------
238 -- |---------------------------< update_validate >----------------------------|
239 -- ----------------------------------------------------------------------------
240 Procedure update_validate
241   (p_rec                          in pay_bdt_shd.g_rec_type
242   ) is
243 --
244   l_proc  varchar2(72) := g_package||'update_validate';
245 --
246 Begin
247   hr_utility.set_location('Entering:'||l_proc, 5);
248   --
249   -- Call all supporting business operations
250   --
251   -- Validate Dependent Attributes
252   --
253   chk_non_updateable_args
254     (p_rec              => p_rec
255     );
256   --
257   --
258   hr_utility.set_location(' Leaving:'||l_proc, 10);
259 End update_validate;
260 --
261 -- ----------------------------------------------------------------------------
262 -- |---------------------------< delete_validate >----------------------------|
263 -- ----------------------------------------------------------------------------
264 Procedure delete_validate
265   (p_rec                          in pay_bdt_shd.g_rec_type
266   ) is
267 --
268   l_proc  varchar2(72) := g_package||'delete_validate';
269 --
270 Begin
271   hr_utility.set_location('Entering:'||l_proc, 5);
272   --
273   -- Call all supporting business operations
274   --
275   hr_utility.set_location(' Leaving:'||l_proc, 10);
276 End delete_validate;
277 --
278 end pay_bdt_bus;