DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_LKR_BUS

Source


1 Package Body hxc_lkr_bus as
2 /* $Header: hxclockrulesrhi.pkb 120.2 2005/09/23 07:58:43 nissharm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hxc_lkr_bus.';  -- Global package name
9 
10 g_debug boolean := hr_utility.debug_enabled;
11 --
12 -- The following two global variables are only to be
13 -- used by the return_legislation_code function.
14 --
15 g_legislation_code            varchar2(150)  default null;
16 g_locker_type_owner_id        number         default null;
17 g_locker_type_requestor_id    number         default null;
18 --
19 --  ---------------------------------------------------------------------------
20 --  |----------------------< set_security_group_id >--------------------------|
21 --  ---------------------------------------------------------------------------
22 --
23 Procedure set_security_group_id
24   (p_locker_type_owner_id                 in number
25   ,p_locker_type_requestor_id             in number
26   ) is
27   --
28   -- Declare cursor
29   --
30   -- EDIT_HERE  In the following cursor statement add join(s) between
31   -- hxc_locking_rules and PER_BUSINESS_GROUPS_PERF
32   -- so that the security_group_id for
33   -- the current business group context can be derived.
34   -- Remove this comment when the edit has been completed.
35   cursor csr_sec_grp is
36     select pbg.security_group_id
37       from per_business_groups_perf pbg
38          , hxc_locking_rules lkr
39       --   , EDIT_HERE table_name(s) 333
40      where lkr.locker_type_owner_id = p_locker_type_owner_id
41        and lkr.locker_type_requestor_id = p_locker_type_requestor_id;
42       -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
43   --
44   -- Declare local variables
45   --
46   l_security_group_id number;
47   l_proc              varchar2(72);
48   l_legislation_code  varchar2(150);
49   --
50 begin
51   g_debug := hr_utility.debug_enabled;
52 
53   --
54   if g_debug then
55   	l_proc :=  g_package||'set_security_group_id';
56   	hr_utility.set_location('Entering:'|| l_proc, 10);
57   end if;
58   --
59   -- Ensure that all the mandatory parameter are not null
60   --
61   hr_api.mandatory_arg_error
62     (p_api_name           => l_proc
63     ,p_argument           => 'locker_type_owner_id'
64     ,p_argument_value     => p_locker_type_owner_id
65     );
66   hr_api.mandatory_arg_error
67     (p_api_name           => l_proc
68     ,p_argument           => 'locker_type_requestor_id'
69     ,p_argument_value     => p_locker_type_requestor_id
70     );
71   --
72   open csr_sec_grp;
73   fetch csr_sec_grp into l_security_group_id;
74 
75   --
76   if csr_sec_grp%notfound then
77      --
78      close csr_sec_grp;
79      --
80      -- The primary key is invalid therefore we must error
81      --
82      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
83      --
84   else
85     close csr_sec_grp;
86     --
87     -- Set the security_group_id in CLIENT_INFO
88     --
89     hr_api.set_security_group_id
90       (p_security_group_id => l_security_group_id
91       );
92     --
93     -- Set the sessions legislation context in HR_SESSION_DATA
94     --
95   end if;
96   --
97   if g_debug then
98   	hr_utility.set_location(' Leaving:'|| l_proc, 20);
99   end if;
100   --
101 end set_security_group_id;
102 --
103 --  ---------------------------------------------------------------------------
104 --  |---------------------< return_legislation_code >-------------------------|
105 --  ---------------------------------------------------------------------------
106 --
107 Function return_legislation_code
108   (p_locker_type_owner_id                 in     number
109   ,p_locker_type_requestor_id             in     number
110   )
111   Return Varchar2 Is
112   --
113   -- Declare cursor
114   --
115   -- EDIT_HERE  In the following cursor statement add join(s) between
116   -- hxc_locking_rules and PER_BUSINESS_GROUPS_PERF
117   -- so that the legislation_code for
118   -- the current business group context can be derived.
119   -- Remove this comment when the edit has been completed.
120   cursor csr_leg_code is
121     select pbg.legislation_code
122       from per_business_groups_perf     pbg
123          , hxc_locking_rules lkr
124       --   , EDIT_HERE table_name(s) 333
125      where lkr.locker_type_owner_id = p_locker_type_owner_id
126        and lkr.locker_type_requestor_id = p_locker_type_requestor_id;
127       -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
128   --
129   -- Declare local variables
130   --
131   l_legislation_code  varchar2(150);
132   l_proc              varchar2(72);
133   --
134 Begin
135   g_debug := hr_utility.debug_enabled;
136 
137   --
138   if g_debug then
139   	l_proc :=  g_package||'return_legislation_code';
140   	hr_utility.set_location('Entering:'|| l_proc, 10);
141   end if;
142   --
143   -- Ensure that all the mandatory parameter are not null
144   --
145   hr_api.mandatory_arg_error
146     (p_api_name           => l_proc
147     ,p_argument           => 'locker_type_owner_id'
148     ,p_argument_value     => p_locker_type_owner_id
149     );
150   hr_api.mandatory_arg_error
151     (p_api_name           => l_proc
152     ,p_argument           => 'locker_type_requestor_id'
153     ,p_argument_value     => p_locker_type_requestor_id
154     );
155   --
156   if (( nvl(hxc_lkr_bus.g_locker_type_owner_id, hr_api.g_number)
157        = p_locker_type_owner_id)
158   and ( nvl(hxc_lkr_bus.g_locker_type_requestor_id, hr_api.g_number)
159        = p_locker_type_requestor_id)) then
160     --
161     -- The legislation code has already been found with a previous
162     -- call to this function. Just return the value in the global
163     -- variable.
164     --
165     l_legislation_code := hxc_lkr_bus.g_legislation_code;
166     if g_debug then
167     	hr_utility.set_location(l_proc, 20);
168     end if;
169   else
170     --
171     -- The ID is different to the last call to this function
172     -- or this is the first call to this function.
173     --
174     open csr_leg_code;
175     fetch csr_leg_code into l_legislation_code;
176     --
177     if csr_leg_code%notfound then
178       --
179       -- The primary key is invalid therefore we must error
180       --
181       close csr_leg_code;
182       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
183       fnd_message.raise_error;
184     end if;
185     if g_debug then
186     	hr_utility.set_location(l_proc,30);
187     end if;
188     --
189     -- Set the global variables so the values are
190     -- available for the next call to this function.
191     --
192     close csr_leg_code;
193     hxc_lkr_bus.g_locker_type_owner_id        := p_locker_type_owner_id;
194     hxc_lkr_bus.g_locker_type_requestor_id    := p_locker_type_requestor_id;
195     hxc_lkr_bus.g_legislation_code  := l_legislation_code;
196   end if;
197   if g_debug then
198   	hr_utility.set_location(' Leaving:'|| l_proc, 40);
199   end if;
200   return l_legislation_code;
201 end return_legislation_code;
202 --
203 -- ----------------------------------------------------------------------------
204 -- |-----------------------< chk_non_updateable_args >------------------------|
205 -- ----------------------------------------------------------------------------
206 -- {Start Of Comments}
207 --
208 -- Description:
209 --   This procedure is used to ensure that non updateable attributes have
210 --   not been updated. If an attribute has been updated an error is generated.
211 --
212 -- Pre Conditions:
213 --   g_old_rec has been populated with details of the values currently in
214 --   the database.
215 --
216 -- In Arguments:
217 --   p_rec has been populated with the updated values the user would like the
218 --   record set to.
219 --
220 -- Post Success:
221 --   Processing continues if all the non updateable attributes have not
222 --   changed.
223 --
224 -- Post Failure:
225 --   An application error is raised if any of the non updatable attributes
226 --   have been altered.
227 --
228 -- {End Of Comments}
229 -- ----------------------------------------------------------------------------
230 Procedure chk_non_updateable_args
231   (p_rec in hxc_lkr_shd.g_rec_type
232   ) IS
233 --
234   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
235 --
236 Begin
237   --
238   -- Only proceed with the validation if a row exists for the current
239   -- record in the HR Schema.
240   --
241   IF NOT hxc_lkr_shd.api_updating
242       (p_locker_type_owner_id              => p_rec.locker_type_owner_id
243       ,p_locker_type_requestor_id          => p_rec.locker_type_requestor_id
244       ) THEN
245      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
246      fnd_message.set_token('PROCEDURE ', l_proc);
247      fnd_message.set_token('STEP ', '5');
248      fnd_message.raise_error;
249   END IF;
250   --
251   -- EDIT_HERE: Add checks to ensure non-updateable args have
252   --            not been updated.
253   --
254 End chk_non_updateable_args;
255 -- ----------------------------------------------------------------------------
256 -- |-----------------------< chk_owner_requestor_id >-------------------------|
257 -- ----------------------------------------------------------------------------
258 -- {Start Of Comments}
259 --
260 -- Description:
261 --   This procedure ensures a valid owner and requestor ID combination
262 --
263 -- Pre Conditions:
264 --   None
265 --
266 -- In Arguments:
267 --   name
268 --   object_version_number
269 --   timecard_field
270 --
271 -- Post Success:
272 --   Processing continues if the owner and requester ID combination is not existing
273 --
274 -- Post Failure:
275 --   An application error is raised if the owner,requestor combination ID is not valid
276 --
277 -- {End Of Comments}
278 -- ----------------------------------------------------------------------------
279 Procedure chk_owner_requestor_id
280   (
281    p_owner_id      	   in hxc_locking_rules.locker_type_owner_id%TYPE
282   ,p_requestor_id      	   in hxc_locking_rules.locker_type_requestor_id%TYPE
283   ) IS
284 --
285   l_proc  varchar2(72);
286 --
287 -- cursor to check if the owner ID and requestor ID are not existing
288 --
289 CURSOR  csr_chk_id IS
290 SELECT 'error'
291 FROM    hxc_locking_rules
292 WHERE   locker_type_owner_id = p_owner_id
293 AND     locker_type_requestor_id = p_requestor_id;
294 
295 
296 l_dup_id varchar2(5) := NULL;
297 
298 BEGIN
299   g_debug := hr_utility.debug_enabled;
300 
301   if g_debug then
302   	l_proc := g_package||'chk_locker_process_type';
303   	hr_utility.set_location('Entering:'||l_proc, 5);
304   end if;
305 
306 -- check that the combination of ID has been entered
307 
308 IF p_owner_id IS NULL THEN
309       hr_utility.set_message(809, 'HXC_OWNER_ID_REQUIRED');
310       hr_utility.raise_error;
311 END IF;
312 
313 IF p_requestor_id IS NULL THEN
314       hr_utility.set_message(809, 'HXC_REQUESTOR_ID_REQUIRED');
315       hr_utility.raise_error;
316 END IF;
317 
318   if g_debug then
319   	hr_utility.set_location('Processing:'||l_proc, 10);
320   end if;
321 
322 -- check that the name is unique
323 
324   OPEN  csr_chk_id;
325   FETCH csr_chk_id INTO l_dup_id;
326   CLOSE csr_chk_id;
327 --
328 IF l_dup_id IS NOT NULL THEN
329       hr_utility.set_message(809, 'HXC_OWNER_REQUESTOR_EXISTS');
330       hr_utility.raise_error;
331 END IF;
332 
333   if g_debug then
334   	hr_utility.set_location('Leaving:'||l_proc, 20);
335   end if;
336 
337 END chk_owner_requestor_id;
338 --
339 -- ----------------------------------------------------------------------------
340 -- |---------------------------< insert_validate >----------------------------|
341 -- ----------------------------------------------------------------------------
342 Procedure insert_validate
343   (p_rec                          in hxc_lkr_shd.g_rec_type
344   ) is
345 --
346   l_proc  varchar2(72);
347 --
348 Begin
349   g_debug := hr_utility.debug_enabled;
350 
351   if g_debug then
352   	l_proc := g_package||'insert_validate';
353   	hr_utility.set_location('Entering:'||l_proc, 5);
354   end if;
355 
356   chk_owner_requestor_id
357   (p_owner_id      	=>p_rec.locker_type_owner_id
358   ,p_requestor_id	=>p_rec.locker_type_requestor_id
359   );
360 
361   --
362   -- Call all supporting business operations
363   --
364   --
365   -- EDIT_HERE: As this table does not have a mandatory business_group_id
366   -- column, ensure client_info is populated by calling a suitable
367   -- ???_???_bus.set_security_group_id procedure, or add one of the following
368   -- comments:
369   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
370   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
371   --
372   -- Validate Dependent Attributes
373   --
374   --
375   if g_debug then
376   	hr_utility.set_location(' Leaving:'||l_proc, 10);
377   end if;
378 End insert_validate;
379 --
380 -- ----------------------------------------------------------------------------
381 -- |---------------------------< update_validate >----------------------------|
382 -- ----------------------------------------------------------------------------
383 Procedure update_validate
384   (p_rec                          in hxc_lkr_shd.g_rec_type
385   ) is
386 --
387   l_proc  varchar2(72);
388 --
389 Begin
390   g_debug := hr_utility.debug_enabled;
391 
392   if g_debug then
393   	l_proc := g_package||'update_validate';
394   	hr_utility.set_location('Entering:'||l_proc, 5);
395   end if;
396 
397   --
398   -- Call all supporting business operations
399   --
400   --
401   -- EDIT_HERE: As this table does not have a mandatory business_group_id
402   -- column, ensure client_info is populated by calling a suitable
403   -- ???_???_bus.set_security_group_id procedure, or add one of the following
404   -- comments:
405   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
406   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
407   --
408   -- Validate Dependent Attributes
409   --
410   chk_non_updateable_args
411     (p_rec              => p_rec
412     );
413   --
414   --
415   if g_debug then
416   	hr_utility.set_location(' Leaving:'||l_proc, 10);
417   end if;
418 End update_validate;
419 --
420 -- ----------------------------------------------------------------------------
421 -- |---------------------------< delete_validate >----------------------------|
422 -- ----------------------------------------------------------------------------
423 Procedure delete_validate
424   (p_rec                          in hxc_lkr_shd.g_rec_type
425   ) is
426 --
427   l_proc  varchar2(72);
428 --
429 Begin
430   g_debug := hr_utility.debug_enabled;
431 
432   if g_debug then
433   	l_proc := g_package||'delete_validate';
434   	hr_utility.set_location('Entering:'||l_proc, 5);
435   end if;
436   null;
437   --
438   -- Call all supporting business operations
439   --
440   if g_debug then
441   	hr_utility.set_location(' Leaving:'||l_proc, 10);
442   end if;
443 End delete_validate;
444 --
445 end hxc_lkr_bus;