DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_OPG_BUS

Source


1 Package Body pqh_opg_bus as
2 /* $Header: pqopgrhi.pkb 115.1 2002/12/03 00:09:11 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pqh_opg_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_operation_group_id          number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_operation_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_operation_groups opg
31      where opg.operation_group_id = p_operation_group_id
32        and pbg.business_group_id = opg.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           => 'operation_group_id'
48     ,p_argument_value     => p_operation_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,'OPERATION_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_operation_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_operation_groups opg
95      where opg.operation_group_id = p_operation_group_id
96        and pbg.business_group_id (+) = opg.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           => 'operation_group_id'
112     ,p_argument_value     => p_operation_group_id
113     );
114   --
115   if ( nvl(pqh_opg_bus.g_operation_group_id, hr_api.g_number)
116        = p_operation_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_opg_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_opg_bus.g_operation_group_id          := p_operation_group_id;
147     pqh_opg_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_opg_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_opg_shd.api_updating
193       (p_operation_group_id                => p_rec.operation_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 IF nvl(p_rec.operation_Group_CODE, hr_api.g_varchar2) <>
203     nvl(pqh_opg_shd.g_old_rec.operation_Group_CODE, hr_api.g_varchar2) THEN
204       hr_utility.set_message(8302, 'PQH_DE_NONUPD_OPGRP_CODE');
205       fnd_message.raise_error;
206     END IF;
207 
208 
209   --
210   -- EDIT_HERE: Add checks to ensure non-updateable args have
211   --            not been updated.
212   --
213 End chk_non_updateable_args;
214 
215 -- ----------------------------------------------------------------------------
216 -- |-----------------------< Chk_Unique_Description >-------------------------|
217 -- ----------------------------------------------------------------------------
218 Procedure Chk_Unique_Description
219   (p_rec   in pqh_opg_shd.g_rec_type) is
220 --
221 Cursor c_Description is
222 Select  Description
223   from  PQH_DE_OPERATION_groups
224  Where  Description = p_rec.Description;
225   l_Description pqh_de_operation_groups.Description%TYPE;
226   l_proc     varchar2(72) := g_package || 'Unique_Description';
227 Begin
228 hr_utility.set_location(l_proc, 10);
229 Open c_Description;
230 Fetch c_Description into l_Description;
231 If c_Description%ROWCOUNT > 0 Then
232    hr_utility.set_message(8302, 'PQH_DE_DUPVAL_Description');
233    Close c_Description;
234    fnd_message.raise_error;
235 End If;
236 Close c_Description;
237 Exception
238 when app_exception.application_exception then
239     if hr_multi_message.exception_add
240        (p_associated_column1 => 'pqh_de_operation_groups.Description'
241        ) then
242       hr_utility.set_location(' Leaving:'||l_proc,60);
243       raise;
244     end if;
245   hr_utility.set_location(' Leaving:'||l_proc,70);
246 End Chk_Unique_Description;
247 
248 
249 -- ----------------------------------------------------------------------------
250 -- |-----------------------< Chk_Unique_opg_Group_CODE >-----------------------|
251 -- ----------------------------------------------------------------------------
252 
253 Procedure Chk_Unique_opg_Group_CODE
254   (p_rec   in pqh_opg_shd.g_rec_type) is
255 --
256 Cursor c_operation_Group_CODE is
257 Select  '1'
258   from  PQH_DE_OPERATION_groupS
259  Where  operation_Group_CODE = p_rec.operation_Group_CODE;
260 L_status Varchar2(1);
261 l_proc     varchar2(1000) := g_package || 'Unique_OPG_NUMBER';
262 Begin
263 hr_utility.set_location(l_proc, 10);
264 Open c_operation_Group_CODE;
265 Fetch c_operation_Group_CODE into L_status;
266 If c_operation_Group_CODE%found  Then
267    hr_utility.set_message(8302, 'PQH_DE_OPG_GROUP_DUP');
268    Close c_operation_Group_CODE;
269    fnd_message.raise_error;
270 End If;
271 Close c_operation_Group_CODE;
272 Exception
273 when app_exception.application_exception then
274     if hr_multi_message.exception_add
275        (p_associated_column1 => 'PQH_DE_OPERATION_groupS.operation_Group_CODE'
276        ) then
277       hr_utility.set_location(' Leaving:'||l_proc,60);
278       raise;
279     end if;
280   hr_utility.set_location(' Leaving:'||l_proc,70);
281 End Chk_Unique_opg_Group_CODE;
282 
283 
284 --
285 -- ----------------------------------------------------------------------------
286 -- |---------------------------< insert_validate >----------------------------|
287 -- ----------------------------------------------------------------------------
288 Procedure insert_validate
289   (p_effective_date               in date
290   ,p_rec                          in pqh_opg_shd.g_rec_type
291   ) is
292 --
293   l_proc  varchar2(72) := g_package||'insert_validate';
294 --
295 Begin
296   hr_utility.set_location('Entering:'||l_proc, 5);
297   --
298   -- Call all supporting business operations
299   --
300   -- EDIT_HERE: The following call to hr_api.validate_bus_grp_id
301   -- will only be valid when the business_group_id is not null.
302   -- As this column is defined as optional on the table then
303   -- different logic will be required to handle the null case.
304   -- If this is a start-up data entity then:
305   --    a) add code to stop null values being processed by this
306   --       row handler
307   -- If this is not a start-up data entity then either:
308   --    b) ignore the security_group_id value held in
309   --       client_info.  This includes performing lookup
310   --       validation against the HR_STANDARD_LOOKUPS view.
311   -- or c) (less likely) ensure the correct security_group_id
312   --       value is set in client_info.
313   -- Remove this comment when the edit has been completed.
314   -- Validate Important Attributes
315 
316 
317 If p_rec.business_group_id is not null then
318  hr_api.validate_bus_grp_id
319   (p_business_group_id => p_rec.business_group_id
320    ,p_associated_column1 => pqh_opg_shd.g_tab_nam
321                              || '.BUSINESS_GROUP_ID');
322 end if ;
323   --
324   -- After validating the set of important attributes,
325   -- if Multiple Message detection is enabled and at least
326   -- one error has been found then abort further validation.
327   --
328 
329   hr_multi_message.end_validation_set;
330  Chk_Unique_opg_Group_CODE(p_rec);
331 Chk_Unique_Description(p_rec);
332 
333 
334 
335   --
336   -- Validate Dependent Attributes
337   --
338   --
339   hr_utility.set_location(' Leaving:'||l_proc, 10);
340 End insert_validate;
341 --
342 -- ----------------------------------------------------------------------------
343 -- |---------------------------< update_validate >----------------------------|
344 -- ----------------------------------------------------------------------------
345 Procedure update_validate
346   (p_effective_date               in date
347   ,p_rec                          in pqh_opg_shd.g_rec_type
348   ) is
349 --
350   l_proc  varchar2(72) := g_package||'update_validate';
351 --
352 Begin
353   hr_utility.set_location('Entering:'||l_proc, 5);
354   --
355   -- Call all supporting business operations
356   --
357   -- EDIT_HERE: The following call to hr_api.validate_bus_grp_id
358   -- will only be valid when the business_group_id is not null.
359   -- As this column is defined as optional on the table then
360   -- different logic will be required to handle the null case.
361   -- If this is a start-up data entity then:
362   --    a) add code to stop null values being processed by this
363   --       row handler
364   -- If this is not a start-up data entity then either:
365   --    b) ignore the security_group_id value held in
366   --       client_info.  This includes performing lookup
367   --       validation against the HR_STANDARD_LOOKUPS view.
368   -- or c) (less likely) ensure the correct security_group_id
369   --       value is set in client_info.
370   -- Remove this comment when the edit has been completed.
371   -- Validate Important Attributes
372  If p_rec.business_group_id is not null then
373   hr_api.validate_bus_grp_id
374    (p_business_group_id => p_rec.business_group_id
375    ,p_associated_column1 => pqh_opg_shd.g_tab_nam
376                              || '.BUSINESS_GROUP_ID');
377  end if ;
378 
379   --
380   -- After validating the set of important attributes,
381   -- if Multiple Message detection is enabled and at least
382   -- one error has been found then abort further validation.
383   --
384 
385  hr_multi_message.end_validation_set;
386  Chk_Unique_opg_Group_CODE(p_rec);
387  Chk_Unique_Description(p_rec);
388   --
389   -- Validate Dependent Attributes
390   --
391   chk_non_updateable_args
392     (p_effective_date              => p_effective_date
393       ,p_rec                      => p_rec
394     );
395   --
396   --
397   hr_utility.set_location(' Leaving:'||l_proc, 10);
398 End update_validate;
399 --
400 -- ----------------------------------------------------------------------------
401 -- |---------------------------< delete_validate >----------------------------|
402 -- ----------------------------------------------------------------------------
403 Procedure delete_validate
404   (p_rec                          in pqh_opg_shd.g_rec_type
405   ) is
406 --
407   l_proc  varchar2(72) := g_package||'delete_validate';
408 --
409 Begin
410   hr_utility.set_location('Entering:'||l_proc, 5);
411   --
412   -- Call all supporting business operations
413   --
414   hr_utility.set_location(' Leaving:'||l_proc, 10);
415 End delete_validate;
416 --
417 end pqh_opg_bus;