DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_TBC_BUS

Source


1 Package Body pay_tbc_bus as
2 /* $Header: pytbcrhi.pkb 120.0 2005/05/29 09:00 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_tbc_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_category_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_category_id                  in number
23   ,p_associated_column1                   in varchar2 default null
24   ) is
25   --
26   -- Declare cursor
27 
28     cursor csr_sec_grp is
29     select pbg.security_group_id,
30            pbg.legislation_code
31       from per_business_groups_perf pbg
32          , pay_balance_categories_f_tl tbc
33          , pay_balance_categories_f pbc
34      where tbc.balance_category_id = p_balance_category_id
35      and pbg.business_group_id = pbc.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_category_id'
52     ,p_argument_value     => p_balance_category_id
53     );
54   --
55   --
56   open csr_sec_grp;
57   fetch csr_sec_grp into l_security_group_id
58                        , l_legislation_code;
59   --
60   if csr_sec_grp%notfound then
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_CATEGORY_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_category_id                  in     number
96   ,p_language                             in     varchar2
97   )
98   Return Varchar2 Is
99   --
100   -- Declare cursor
101   --
102   cursor csr_leg_code is
103     select pbg.legislation_code
104       from per_business_groups_perf     pbg
105          , pay_balance_categories_f_tl tbc
106          , pay_balance_categories_f pbc
107      where tbc.balance_category_id = p_balance_category_id
108        and tbc.language = p_language
109        and pbg.business_group_id = pbc.business_group_id;
110   --
111   -- Declare local variables
112   --
113   l_legislation_code  varchar2(150);
114   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
115   --
116 Begin
117   --
118   hr_utility.set_location('Entering:'|| l_proc, 10);
119   --
120   -- Ensure that all the mandatory parameter are not null
121   --
122   hr_api.mandatory_arg_error
123     (p_api_name           => l_proc
124     ,p_argument           => 'balance_category_id'
125     ,p_argument_value     => p_balance_category_id
126     );
127   --
128   --
129   if (( nvl(pay_tbc_bus.g_balance_category_id, hr_api.g_number)
130        = p_balance_category_id)
131   and ( nvl(pay_tbc_bus.g_language, hr_api.g_varchar2)
132        = p_language)) then
133     --
134     -- The legislation code has already been found with a previous
135     -- call to this function. Just return the value in the global
136     -- variable.
137     --
138     l_legislation_code := pay_tbc_bus.g_legislation_code;
139     hr_utility.set_location(l_proc, 20);
140   else
141     --
142     -- The ID is different to the last call to this function
143     -- or this is the first call to this function.
144     --
145     open csr_leg_code;
146     fetch csr_leg_code into l_legislation_code;
147     --
148     if csr_leg_code%notfound then
149       --
150       -- The primary key is invalid therefore we must error
151       --
152       close csr_leg_code;
153       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
154       fnd_message.raise_error;
155     end if;
156     hr_utility.set_location(l_proc,30);
157     --
158     -- Set the global variables so the values are
159     -- available for the next call to this function.
160     --
161     close csr_leg_code;
162     pay_tbc_bus.g_balance_category_id         := p_balance_category_id;
163     pay_tbc_bus.g_language                    := p_language;
164     pay_tbc_bus.g_legislation_code  := l_legislation_code;
165   end if;
166   hr_utility.set_location(' Leaving:'|| l_proc, 40);
167   return l_legislation_code;
168 end return_legislation_code;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |-----------------------< chk_non_updateable_args >------------------------|
172 -- ----------------------------------------------------------------------------
173 -- {Start Of Comments}
174 --
175 -- Description:
176 --   This procedure is used to ensure that non updateable attributes have
177 --   not been updated. If an attribute has been updated an error is generated.
178 --
179 -- Pre Conditions:
180 --   g_old_rec has been populated with details of the values currently in
181 --   the database.
182 --
183 -- In Arguments:
184 --   p_rec has been populated with the updated values the user would like the
185 --   record set to.
186 --
187 -- Post Success:
188 --   Processing continues if all the non updateable attributes have not
189 --   changed.
190 --
191 -- Post Failure:
192 --   An application error is raised if any of the non updatable attributes
193 --   have been altered.
194 --
195 -- {End Of Comments}
196 -- ----------------------------------------------------------------------------
197 Procedure chk_non_updateable_args
198   (p_rec in pay_tbc_shd.g_rec_type
199   ) IS
200 --
201   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
202 --
203 Begin
204   --
205   -- Only proceed with the validation if a row exists for the current
206   -- record in the HR Schema.
207   --
208   IF NOT pay_tbc_shd.api_updating
209       (p_balance_category_id               => p_rec.balance_category_id
210       ,p_language                          => p_rec.language
211       ) THEN
212      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
213      fnd_message.set_token('PROCEDURE ', l_proc);
214      fnd_message.set_token('STEP ', '5');
215      fnd_message.raise_error;
216   END IF;
217   --
218 End chk_non_updateable_args;
219 --
220 -- ----------------------------------------------------------------------------
221 -- |---------------------------< insert_validate >----------------------------|
222 -- ----------------------------------------------------------------------------
223 Procedure insert_validate
224   (p_rec                          in pay_tbc_shd.g_rec_type
225   ) is
226 --
227   l_proc  varchar2(72) := g_package||'insert_validate';
228 --
229 Begin
230   hr_utility.set_location('Entering:'||l_proc, 5);
231   --
232   -- Call all supporting business operations
233   --
234   -- Validate Dependent Attributes
235   --
236   --
237   hr_utility.set_location(' Leaving:'||l_proc, 10);
238 End insert_validate;
239 --
240 -- ----------------------------------------------------------------------------
241 -- |---------------------------< update_validate >----------------------------|
242 -- ----------------------------------------------------------------------------
243 Procedure update_validate
244   (p_rec                          in pay_tbc_shd.g_rec_type
245   ) is
246 --
247   l_proc  varchar2(72) := g_package||'update_validate';
248 --
249 Begin
250   hr_utility.set_location('Entering:'||l_proc, 5);
251   --
252   -- Call all supporting business operations
253   --
254   -- Validate Dependent Attributes
255   --
256   chk_non_updateable_args
257     (p_rec              => p_rec
258     );
259   --
260   --
261   hr_utility.set_location(' Leaving:'||l_proc, 10);
262 End update_validate;
263 --
264 -- ----------------------------------------------------------------------------
265 -- |---------------------------< delete_validate >----------------------------|
266 -- ----------------------------------------------------------------------------
267 Procedure delete_validate
268   (p_rec                          in pay_tbc_shd.g_rec_type
269   ) is
270 --
271   l_proc  varchar2(72) := g_package||'delete_validate';
272 --
273 Begin
274   hr_utility.set_location('Entering:'||l_proc, 5);
275   --
276   -- Call all supporting business operations
277   --
278   hr_utility.set_location(' Leaving:'||l_proc, 10);
279 End delete_validate;
280 --
281 end pay_tbc_bus;