DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PCT_BUS

Source


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