DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_CGN_BUS

Source


1 Package Body pqh_cgn_bus as
2 /* $Header: pqcgnrhi.pkb 115.7 2002/11/27 04:43:27 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pqh_cgn_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_case_group_id               number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_case_group_id                        in number
22   ,p_associated_column1                   in varchar2 default null
23   ) is
24   --
25   -- Declare cursor
26   --
27   cursor csr_sec_grp is
28     select pbg.security_group_id
29       from per_business_groups pbg
30          , pqh_de_case_groups cgn
31      where cgn.case_group_id     = p_case_group_id
32        and pbg.business_group_id = cgn.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   --
39 begin
40   --
41   hr_utility.set_location('Entering:'|| l_proc, 10);
42   --
43   -- Ensure that all the mandatory parameter are not null
44   --
45   hr_api.mandatory_arg_error
46     (p_api_name           => l_proc
47     ,p_argument           => 'case_group_id'
48     ,p_argument_value     => p_case_group_id
49     );
50   --
51   open csr_sec_grp;
52   fetch csr_sec_grp into l_security_group_id;
53   --
54   if csr_sec_grp%notfound then
55      --
56      close csr_sec_grp;
57      --
58      -- The primary key is invalid therefore we must error
59      --
60      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
61      hr_multi_message.add
62        (p_associated_column1
63         => nvl(p_associated_column1,'CASE_GROUP_ID')
64        );
65      --
66   else
67     close csr_sec_grp;
68     --
69     -- Set the security_group_id in CLIENT_INFO
70     --
71     hr_api.set_security_group_id
72       (p_security_group_id => l_security_group_id
73       );
74   end if;
75   --
76   hr_utility.set_location(' Leaving:'|| l_proc, 20);
77   --
78 end set_security_group_id;
79 --
80 --  ---------------------------------------------------------------------------
81 --  |---------------------< return_legislation_code >-------------------------|
82 --  ---------------------------------------------------------------------------
83 --
84 Function return_legislation_code
85   (p_case_group_id                        in     number
86   )
87   Return Varchar2 Is
88   --
89   -- Declare cursor
90   --
91   cursor csr_leg_code is
92     select pbg.legislation_code
93       from per_business_groups pbg
94          , pqh_de_case_groups cgn
95      where cgn.case_group_id = p_case_group_id
96        and pbg.business_group_id (+) = cgn.business_group_id;
97   --
98   -- Declare local variables
99   --
100   l_legislation_code  varchar2(150);
101   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
102   --
103 Begin
104   --
105   hr_utility.set_location('Entering:'|| l_proc, 10);
106   --
107   -- Ensure that all the mandatory parameter are not null
108   --
109   hr_api.mandatory_arg_error
110     (p_api_name           => l_proc
111     ,p_argument           => 'case_group_id'
112     ,p_argument_value     => p_case_group_id
113     );
114   --
115   if ( nvl(pqh_cgn_bus.g_case_group_id, hr_api.g_number)
116        = p_case_group_id) then
117     --
118     -- The legislation code has already been found with a previous
119     -- call to this function. Just return the value in the global
120     -- variable.
121     --
122     l_legislation_code := pqh_cgn_bus.g_legislation_code;
123     hr_utility.set_location(l_proc, 20);
124   else
125     --
126     -- The ID is different to the last call to this function
127     -- or this is the first call to this function.
128     --
129     open csr_leg_code;
130     fetch csr_leg_code into l_legislation_code;
131     --
132     if csr_leg_code%notfound then
133       --
134       -- The primary key is invalid therefore we must error
135       --
136       close csr_leg_code;
137       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
138       fnd_message.raise_error;
139     end if;
140     hr_utility.set_location(l_proc,30);
141     --
142     -- Set the global variables so the values are
143     -- available for the next call to this function.
144     --
145     close csr_leg_code;
146     pqh_cgn_bus.g_case_group_id               := p_case_group_id;
147     pqh_cgn_bus.g_legislation_code            := l_legislation_code;
148   end if;
149   hr_utility.set_location(' Leaving:'|| l_proc, 40);
150   return l_legislation_code;
151 end return_legislation_code;
152 --
153 -- ----------------------------------------------------------------------------
154 -- |-----------------------< chk_non_updateable_args >------------------------|
155 -- ----------------------------------------------------------------------------
156 -- {Start Of Comments}
157 --
158 -- Description:
159 --   This procedure is used to ensure that non updateable attributes have
160 --   not been updated. If an attribute has been updated an error is generated.
161 --
162 -- Pre Conditions:
163 --   g_old_rec has been populated with details of the values currently in
164 --   the database.
165 --
166 -- In Arguments:
167 --   p_rec has been populated with the updated values the user would like the
168 --   record set to.
169 --
170 -- Post Success:
171 --   Processing continues if all the non updateable attributes have not
172 --   changed.
173 --
174 -- Post Failure:
175 --   An application error is raised if any of the non updatable attributes
176 --   have been altered.
177 --
178 -- {End Of Comments}
179 -- ----------------------------------------------------------------------------
180 Procedure chk_non_updateable_args
181   (p_effective_date               in date
182   ,p_rec in pqh_cgn_shd.g_rec_type
183   ) IS
184 --
185   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
186 --
187 Begin
188   --
189   -- Only proceed with the validation if a row exists for the current
190   -- record in the HR Schema.
191   --
192   IF NOT pqh_cgn_shd.api_updating
193       (p_case_group_id                     => p_rec.case_group_id
194       ,p_object_version_number             => p_rec.object_version_number
195       ) THEN
196      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
197      fnd_message.set_token('PROCEDURE ', l_proc);
198      fnd_message.set_token('STEP ', '5');
199      fnd_message.raise_error;
200   END IF;
201   --
202   -- EDIT_HERE: Add checks to ensure non-updateable args have
203   --            not been updated.
204 
205 
206 
207 IF nvl(p_rec.CASE_GROUP_NUMBER, hr_api.g_varchar2) <>
208     nvl(pqh_cgn_shd.g_old_rec.CASE_GROUP_NUMBER, hr_api.g_varchar2) THEN
209       hr_utility.set_message(8302, 'PQH_DE_CSGRP_NUMBER');
210       fnd_message.raise_error;
211     END IF;
212 
213 
214   --
215 End chk_non_updateable_args;
216 --
217 -- ----------------------------------------------------------------------------
218 -- |-----------------------< Chk_ADVANCEMENT_TO >--------------------------|
219 -- ----------------------------------------------------------------------------
220 
221 Procedure Chk_ADVANCEMENT_TO
222   (p_rec   in pqh_cgn_shd.g_rec_type) is
223 --
224 Cursor c_case_group_NUMBER is
225 Select  case_group_NUMBER
226   from  PQH_DE_case_groupS
227  Where  case_group_NUMBER = p_rec.ADVANCEMENT_TO;
228 
229 l_case_group_NUMBER PQH_DE_case_groupS.case_group_NUMBER%TYPE;
230 l_proc     varchar2(72) := g_package || 'Chk_case_group_NUMBER';
231 Begin
232 hr_utility.set_location(l_proc, 10);
233 Open c_case_group_NUMBER;
234 Fetch c_case_group_NUMBER into l_case_group_NUMBER;
235 If c_case_group_NUMBER%ROWCOUNT = 0 Then
236    hr_utility.set_message(8302, 'PQH_DE_NO_EXIST_CASE_GROUP');
237    Close c_case_group_NUMBER;
238    fnd_message.raise_error;
239 End If;
240 Close c_case_group_NUMBER;
241 Exception
242 when app_exception.application_exception then
243     if hr_multi_message.exception_add
244        (p_associated_column1 => 'PQH_DE_case_groupS.ADVANCEMENT_TO'
245        ) then
246       hr_utility.set_location(' Leaving:'||l_proc,60);
247       raise;
248     end if;
249   hr_utility.set_location(' Leaving:'||l_proc,70);
250 End Chk_ADVANCEMENT_TO;
251 --
252 -- ----------------------------------------------------------------------------
253 -- |-----------------------< Chk_delete >--------------------------------------|
254 -- ----------------------------------------------------------------------------
255 Procedure Chk_delete
256  (p_rec  in pqh_cgn_shd.g_rec_type) is
257   l_proc  varchar2(72) := g_package||'Ckh_Delete';
258  Cursor Del is
259 
260  Select  '1'
261   from per_gen_hierarchy_nodes a, pqh_de_case_groups b
262 where    NODE_TYPE  = 'CASE_GROUP'
263 and      a. entity_id    = b.CASE_GROUP_NUMBER
264 and      b.CASE_GROUP_id= p_rec.CASE_GROUP_id;
265 
266  l_Status Varchar2(1);
267 Begin
268 Open Del;
269 Fetch Del into l_Status;
270 If Del%Found Then
271    Close Del;
272    hr_utility.set_message(8302,'PQH_CASE_GROUP_PRE_DEL');
273    hr_utility.raise_error;
274 End If;
275 Close Del;
276 Exception
277 when app_exception.application_exception then
278     if hr_multi_message.exception_add
279        (p_associated_column1 => 'PQH_DE_CASE_GROUPS.CASE_GROUP_NUMBER'
280        ) then
281       hr_utility.set_location(' Leaving:'||l_proc,60);
282       raise;
283     end if;
284   hr_utility.set_location(' Leaving:'||l_proc,70);
285 End Chk_Delete;
286 -- ----------------------------------------------------------------------------
287 -- |-----------------------< Chk_Unique_case_group_NUMBER >------------------|
288 -- ----------------------------------------------------------------------------
289 
290 Procedure Chk_Unique_case_group_NUMBER
291   (p_rec   in pqh_cgn_shd.g_rec_type) is
292 --
293 Cursor c_case_group_NUMBER is
294 Select  '1'
295   from  PQH_DE_case_groupS
296  Where  case_group_NUMBER = p_rec.case_group_NUMBER
297    and  description       = p_rec.description;
298 L_status Varchar2(1);
299 l_proc     varchar2(1000) := g_package || 'Unique_cg_NUMBER';
300 Begin
301 hr_utility.set_location(l_proc, 10);
302 Open c_case_group_NUMBER;
303 Fetch c_case_group_NUMBER into L_status;
304 If c_case_group_NUMBER%found  Then
305    hr_utility.set_message(8302, 'PQH_DE_CASE_GROUP_DUP');
306    Close c_case_group_NUMBER;
307    fnd_message.raise_error;
308 End If;
309 Close c_case_group_NUMBER;
310 Exception
311 when app_exception.application_exception then
312     if hr_multi_message.exception_add
313        (p_associated_column1 => 'PQH_DE_case_groupS.case_group_NUMBER'
314        ) then
315       hr_utility.set_location(' Leaving:'||l_proc,60);
316       raise;
317     end if;
318   hr_utility.set_location(' Leaving:'||l_proc,70);
319 End Chk_Unique_case_group_NUMBER;
320 
321 
322 -- ----------------------------------------------------------------------------
323 -- |---------------------------< insert_validate >----------------------------|
324 -- ----------------------------------------------------------------------------
325 Procedure insert_validate
326   (p_effective_date               in date
327   ,p_rec                          in pqh_cgn_shd.g_rec_type
328   ) is
329 --
330   l_proc  varchar2(72) := g_package||'insert_validate';
331 --
332 Begin
333   hr_utility.set_location('Entering:'||l_proc, 5);
334   --
335   -- Call all supporting business operations
336   --
337   -- EDIT_HERE: The following call to hr_api.validate_bus_grp_id
338   -- will only be valid when the business_group_id is not null.
339   -- As this column is defined as optional on the table then
340   -- different logic will be required to handle the null case.
341   -- If this is a start-up data entity then:
342   --    a) add code to stop null values being processed by this
343   --       row handler
344   -- If this is not a start-up data entity then either:
345   --    b) ignore the security_group_id value held in
346   --       client_info.  This includes performing lookup
347   --       validation against the HR_STANDARD_LOOKUPS view.
348   -- or c) (less likely) ensure the correct security_group_id
349   --       value is set in client_info.
350   -- Remove this comment when the edit has been completed.
351   -- Validate Important Attributes
352 
353 If p_rec.business_group_id is not null then
354   hr_api.validate_bus_grp_id
355     (p_business_group_id => p_rec.business_group_id
356     ,p_associated_column1 => pqh_cgn_shd.g_tab_nam
357                               || '.BUSINESS_GROUP_ID');
358 end if;
359 
360   --
361   -- After validating the set of important attributes,
362   -- if Multiple Message detection is enabled and at least
363   -- one error has been found then abort further validation.
364   --
365   Chk_Unique_case_group_NUMBER (P_Rec);
366 
367 
368   hr_multi_message.end_validation_set;
369   --
370   -- Validate Dependent Attributes
371   --
372   --
373   hr_utility.set_location(' Leaving:'||l_proc, 10);
374 End insert_validate;
375 --
376 -- ----------------------------------------------------------------------------
377 -- |---------------------------< update_validate >----------------------------|
378 -- ----------------------------------------------------------------------------
379 Procedure update_validate
380   (p_effective_date               in date
381   ,p_rec                          in pqh_cgn_shd.g_rec_type
382   ) is
383 --
384   l_proc  varchar2(72) := g_package||'update_validate';
385 --
386 Begin
387   hr_utility.set_location('Entering:'||l_proc, 5);
388   --
389   -- Call all supporting business operations
390   --
391   -- EDIT_HERE: The following call to hr_api.validate_bus_grp_id
392   -- will only be valid when the business_group_id is not null.
393   -- As this column is defined as optional on the table then
394   -- different logic will be required to handle the null case.
395   -- If this is a start-up data entity then:
396   --    a) add code to stop null values being processed by this
397   --       row handler
398   -- If this is not a start-up data entity then either:
399   --    b) ignore the security_group_id value held in
400   --       client_info.  This includes performing lookup
401   --       validation against the HR_STANDARD_LOOKUPS view.
402   -- or c) (less likely) ensure the correct security_group_id
403   --       value is set in client_info.
404   -- Remove this comment when the edit has been completed.
405   -- Validate Important Attributes
406 If p_rec.business_group_id is not null then
407   hr_api.validate_bus_grp_id
408     (p_business_group_id => p_rec.business_group_id
409     ,p_associated_column1 => pqh_cgn_shd.g_tab_nam
410                               || '.BUSINESS_GROUP_ID');
411 end if;
412 
413 
414 
415 
416   --
417   -- After validating the set of important attributes,
418   -- if Multiple Message detection is enabled and at least
419   -- one error has been found then abort further validation.
420   --
421   hr_multi_message.end_validation_set;
422 
423 
424 
425   --
426   -- Validate Dependent Attributes
427   --
428   chk_non_updateable_args
429     (p_effective_date              => p_effective_date
430       ,p_rec              => p_rec
431     );
432 
433 
434   --
435   --
436   hr_utility.set_location(' Leaving:'||l_proc, 10);
437 End update_validate;
438 --
439 -- ----------------------------------------------------------------------------
440 -- |---------------------------< delete_validate >----------------------------|
441 -- ----------------------------------------------------------------------------
442 Procedure delete_validate
443   (p_rec                          in pqh_cgn_shd.g_rec_type
444   ) is
445 --
446   l_proc  varchar2(72) := g_package||'delete_validate';
447 --
448 Begin
449   hr_utility.set_location('Entering:'||l_proc, 5);
450   --
451   -- Call all supporting business operations
452   --
453   Chk_delete(P_Rec);
454   hr_utility.set_location(' Leaving:'||l_proc, 10);
455 End delete_validate;
456 --
457 end pqh_cgn_bus;