DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_GVN_BUS

Source


4 -- ----------------------------------------------------------------------------
1 Package Body pqh_gvn_bus as
2 /* $Header: pqgvnrhi.pkb 115.3 2002/12/12 22:53:06 sgoyal noship $ */
3 --
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pqh_gvn_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_level_number_id             number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_level_number_id                      in number
22   ,p_associated_column1                   in varchar2 default null
23   ) is
24   --
25   -- Declare cursor
26   --
27   -- EDIT_HERE  In the following cursor statement add join(s) between
28   -- pqh_de_level_numbers and PER_BUSINESS_GROUPS
32   cursor csr_sec_grp is
29   -- so that the security_group_id for
30   -- the current business group context can be derived.
31   -- Remove this comment when the edit has been completed.
33     select pbg.security_group_id
34       from per_business_groups pbg
35          , pqh_de_level_numbers gvn
36       --   , EDIT_HERE table_name(s) 333
37      where gvn.level_number_id = p_level_number_id;
38       -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
39   --
40   -- Declare local variables
41   --
42   l_security_group_id number;
43   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
44   --
45 begin
46   --
47   hr_utility.set_location('Entering:'|| l_proc, 10);
48   --
49   -- Ensure that all the mandatory parameter are not null
50   --
51   hr_api.mandatory_arg_error
52     (p_api_name           => l_proc
53     ,p_argument           => 'level_number_id'
54     ,p_argument_value     => p_level_number_id
55     );
56   --
57   open csr_sec_grp;
58   fetch csr_sec_grp into l_security_group_id;
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,'LEVEL_NUMBER_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   end if;
81   --
82   hr_utility.set_location(' Leaving:'|| l_proc, 20);
83   --
84 end set_security_group_id;
85 --
86 --  ---------------------------------------------------------------------------
87 --  |---------------------< return_legislation_code >-------------------------|
88 --  ---------------------------------------------------------------------------
89 --
90 Function return_legislation_code
91   (p_level_number_id                      in     number
92   )
93   Return Varchar2 Is
94   --
95   -- Declare cursor
96   --
97   -- EDIT_HERE  In the following cursor statement add join(s) between
98   -- pqh_de_level_numbers and PER_BUSINESS_GROUPS
99   -- so that the legislation_code for
100   -- the current business group context can be derived.
101   -- Remove this comment when the edit has been completed.
102   cursor csr_leg_code is
103     select pbg.legislation_code
104       from per_business_groups     pbg
105          , pqh_de_level_numbers gvn
106       --   , EDIT_HERE table_name(s) 333
107      where gvn.level_number_id = p_level_number_id;
108       -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
109   --
110   -- Declare local variables
111   --
112   l_legislation_code  varchar2(150);
113   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
114   --
115 Begin
116   --
117   hr_utility.set_location('Entering:'|| l_proc, 10);
118   --
119   -- Ensure that all the mandatory parameter are not null
120   --
121   hr_api.mandatory_arg_error
122     (p_api_name           => l_proc
123     ,p_argument           => 'level_number_id'
124     ,p_argument_value     => p_level_number_id
125     );
126   --
127   if ( nvl(pqh_gvn_bus.g_level_number_id, hr_api.g_number)
128        = p_level_number_id) then
129     --
130     -- The legislation code has already been found with a previous
131     -- call to this function. Just return the value in the global
132     -- variable.
133     --
134     l_legislation_code := pqh_gvn_bus.g_legislation_code;
135     hr_utility.set_location(l_proc, 20);
136   else
137     --
138     -- The ID is different to the last call to this function
139     -- or this is the first call to this function.
140     --
141     open csr_leg_code;
142     fetch csr_leg_code into l_legislation_code;
143     --
144     if csr_leg_code%notfound then
145       --
146       -- The primary key is invalid therefore we must error
147       --
148       close csr_leg_code;
149       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
150       fnd_message.raise_error;
151     end if;
152     hr_utility.set_location(l_proc,30);
153     --
154     -- Set the global variables so the values are
155     -- available for the next call to this function.
156     --
157     close csr_leg_code;
158     pqh_gvn_bus.g_level_number_id             := p_level_number_id;
159     pqh_gvn_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
175 --   g_old_rec has been populated with details of the values currently in
172 --   not been updated. If an attribute has been updated an error is generated.
173 --
174 -- Pre Conditions:
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_effective_date               in date
194   ,p_rec in pqh_gvn_shd.g_rec_type
195   ) IS
196 --
197   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
198 
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 pqh_gvn_shd.api_updating
206       (p_level_number_id                   => p_rec.level_number_id
207       ,p_object_version_number             => p_rec.object_version_number
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 
216 IF nvl(p_rec.level_NUMBER, hr_api.g_varchar2) <>
217     nvl(pqh_gvn_shd.g_old_rec.level_NUMBER, hr_api.g_varchar2) THEN
218     hr_utility.set_message(8302, 'PQH_DE_NONUPD_LEVEL_NUMBER');
219       fnd_message.raise_error;
220 
221   END IF;
222   --
223   -- EDIT_HERE: Add checks to ensure non-updateable args have
224   --            not been updated.
225   --
226 End chk_non_updateable_args;
227 --
228 -- ----------------------------------------------------------------------------
229 -- |---------------------------< Chk_Unique_level_NUMBER >---------------------|
230 -- ----------------------------------------------------------------------------
231 Procedure Chk_Unique_level_NUMBER
232   (p_rec   in pqh_gvn_shd.g_rec_type) is
233 --
234 Cursor c_LEVEL_NUMBER is
235 Select  LEVEL_NUMBER
236   from  PQH_DE_LEVEL_NUMBERS
237  Where  LEVEL_NUMBER = p_rec.LEVEL_NUMBER;
238 
239 
240 l_LEVEL_NUMBER       PQH_DE_LEVEL_NUMBERS.LEVEL_NUMBER%TYPE;
241 l_proc               varchar2(72) := g_package || 'Unique_LEVEL_NUMBER';
242 
243 
244 Begin
245 
246 hr_utility.set_location(l_proc, 10);
247 Open c_LEVEL_NUMBER;
248 Fetch c_LEVEL_NUMBER into l_LEVEL_NUMBER;
249 If c_LEVEL_NUMBER%ROWCOUNT > 0 Then
250    hr_utility.set_message(8302, 'PQH_DE_DUPVAL_LVL_NUM');
251    Close c_LEVEL_NUMBER;
252    fnd_message.raise_error;
253  End If;
254  Close c_LEVEL_NUMBER;
255  Exception
256 when app_exception.application_exception then
257     if hr_multi_message.exception_add
258        (p_associated_column1 => 'PQH_DE_LEVEL_NUMBERS.LEVEL_NUMBER'
259        ) then
260       hr_utility.set_location(' Leaving:'||l_proc,60);
261       raise;
262     end if;
263   hr_utility.set_location(' Leaving:'||l_proc,70);
264 
265 End Chk_Unique_LEVEL_NUMBER;
266 -- ----------------------------------------------------------------------------
267 -- |---------------------------< Chk_WRKPLC_VLDTN_LVLNUMS >-------------------|
268 -- ----------------------------------------------------------------------------
269 Procedure Chk_WRKPLC_VLDTN_LVLNUMS
270  (p_rec  in pqh_gvn_shd.g_rec_type) is
271   l_proc  varchar2(72) := g_package||'Ckh_Delete';
272  Cursor Del is
273 select  '1' from PQH_DE_WRKPLC_VLDTN_LVLNUMS
274 where     LEVEL_NUMBER_ID  =  p_rec.LEVEL_NUMBER_ID ;
275 
276  l_Status Varchar2(1);
277 Begin
278 Open Del;
279 Fetch Del into l_Status;
280 If Del%Found Then
281    Close Del;
282    hr_utility.set_message(8302, 'PQH_WRKPLC_LVLNUM_PRE_DEL');
283    hr_utility.raise_error;
284 End If;
285 Close Del;
286 Exception
287 when app_exception.application_exception then
288     if hr_multi_message.exception_add
289        (p_associated_column1 => 'PQH_DE_WRKPLC_VLDTN_LVLNUMS.LEVEL_CODE_ID'
290        ) then
291       hr_utility.set_location(' Leaving:'||l_proc,60);
292       raise;
293     end if;
294   hr_utility.set_location(' Leaving:'||l_proc,70);
295 End Chk_WRKPLC_VLDTN_LVLNUMS;
299 Procedure Chk_delete
296 -- ----------------------------------------------------------------------------
297 -- |---------------------------< Chk_delete >---------------------------------|
298 -- ----------------------------------------------------------------------------
300  (p_rec  in pqh_gvn_shd.g_rec_type) is
301   l_proc  varchar2(72) := g_package||'Ckh_Delete';
302  Cursor Del is
303 select  '1' from PQH_DE_LEVEL_CODES
304 where    Level_number_id  = p_rec.level_NUMBER;
305 
306  l_Status Varchar2(1);
307 
308 Begin
309 Open Del;
310 Fetch Del into l_Status;
311 If Del%Found Then
312    Close Del;
313    hr_utility.set_message(8302, 'PQH_LEVEL_NUMBERS_PRE_DEL');
314    hr_utility.raise_error;
315 End If;
316 Close Del;
317 Exception
318 when app_exception.application_exception then
319     if hr_multi_message.exception_add
320        (p_associated_column1 => 'PQH_DE_LEVEL_NUMBERS.LEVEL_NUMBER'
321        ) then
322       hr_utility.set_location(' Leaving:'||l_proc,60);
323       raise;
324     end if;
325   hr_utility.set_location(' Leaving:'||l_proc,70);
326 End Chk_Delete;
327 -- ----------------------------------------------------------------------------
328 -- |---------------------------< insert_validate >----------------------------|
329 -- ----------------------------------------------------------------------------
330 Procedure insert_validate
331   (p_effective_date               in date
332   ,p_rec                          in pqh_gvn_shd.g_rec_type
333   ) is
334 --
335   l_proc  varchar2(72) := g_package||'insert_validate';
336 --
337 Begin
338   hr_utility.set_location('Entering:'||l_proc, 5);
339   --
340   -- Call all supporting business operations
341   --
342   --
343      Chk_Unique_LEVEL_NUMBER (P_Rec);
344 
345   -- EDIT_HERE: As this table does not have a mandatory business_group_id
346   -- column, ensure client_info is populated by calling a suitable
347   -- ???_???_bus.set_security_group_id procedure, or add one of the following
348   -- comments:
349   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
350   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
351   --
352   -- Validate Dependent Attributes
353   --
354   --
355   hr_utility.set_location(' Leaving:'||l_proc, 10);
356 End insert_validate;
357 --
358 -- ----------------------------------------------------------------------------
359 -- |---------------------------< update_validate >----------------------------|
360 -- ----------------------------------------------------------------------------
361 Procedure update_validate
362   (p_effective_date               in date
363   ,p_rec                          in pqh_gvn_shd.g_rec_type
364   ) is
365 --
366   l_proc  varchar2(72) := g_package||'update_validate';
367 --
368 Begin
369   hr_utility.set_location('Entering:'||l_proc, 5);
370   --
371   -- Call all supporting business operations
372   --
373   --
374      chk_non_updateable_args
375     (p_effective_date              => p_effective_date
376       ,p_rec                       => p_rec
377      );
378 
379   -- EDIT_HERE: As this table does not have a mandatory business_group_id
380   -- column, ensure client_info is populated by calling a suitable
381   -- ???_???_bus.set_security_group_id procedure, or add one of the following
382   -- comments:
383   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
384   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
385   --
386   -- Validate Dependent Attributes
387   --
388   chk_non_updateable_args
389     (p_effective_date              => p_effective_date
390       ,p_rec              => p_rec
391     );
392   --
393   --
394   hr_utility.set_location(' Leaving:'||l_proc, 10);
395 End update_validate;
396 --
397 -- ----------------------------------------------------------------------------
398 -- |---------------------------< delete_validate >----------------------------|
399 -- ----------------------------------------------------------------------------
400 Procedure delete_validate
401   (p_rec                          in pqh_gvn_shd.g_rec_type
402   ) is
403 --
404   l_proc  varchar2(72) := g_package||'delete_validate';
405 --
406 Begin
407   hr_utility.set_location('Entering:'||l_proc, 5);
408   --
409   -- Call all supporting business operations
410   --
411   Chk_delete(P_Rec);
412   Chk_WRKPLC_VLDTN_LVLNUMS(P_Rec);
413 
414   hr_utility.set_location(' Leaving:'||l_proc, 10);
415 End delete_validate;
416 --
417 end pqh_gvn_bus;