DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_TIC_BUS

Source


1 Package Body hr_tic_bus as
2 /* $Header: hrticrhi.pkb 120.1 2011/04/28 10:57:06 sidsaxen ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hr_tic_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_template_item_context_id    number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_template_item_context_id             in number
22   ) is
23   --
24   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
25   --
26 begin
27   --
28   hr_utility.set_location('Entering:'|| l_proc, 10);
29   --
30   -- No business group context. Security group is not applicable.
31   --
32   null;
33   --
34   hr_utility.set_location(' Leaving:'|| l_proc, 20);
35   --
36 end set_security_group_id;
37 --
38 --  ---------------------------------------------------------------------------
39 --  |---------------------< return_legislation_code >-------------------------|
40 --  ---------------------------------------------------------------------------
41 --
42 Function return_legislation_code
43   (p_template_item_context_id             in     number
44   )
45   Return Varchar2 Is
46   --
47   -- Declare cursor
48   --
49   cursor csr_leg_code is
50     select tmp.legislation_code
51       from hr_form_templates_b tmp
52           ,hr_template_items_b tim
53           ,hr_template_item_contexts_b tic
54      where tmp.form_template_id = tim.form_template_id
55        and tim.template_item_id = tic.template_item_id
56        and tic.template_item_context_id = p_template_item_context_id;
57   --
58   -- Declare local variables
59   --
60   l_legislation_code  varchar2(150);
61   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
62   --
63 Begin
64   --
65   hr_utility.set_location('Entering:'|| l_proc, 10);
66   --
67   -- Ensure that all the mandatory parameter are not null
68   --
69   hr_api.mandatory_arg_error
70     (p_api_name           => l_proc
71     ,p_argument           => 'template_item_context_id'
72     ,p_argument_value     => p_template_item_context_id
73     );
74   --
75   if ( nvl(hr_tic_bus.g_template_item_context_id, hr_api.g_number)
76        = p_template_item_context_id) then
77     --
78     -- The legislation code has already been found with a previous
79     -- call to this function. Just return the value in the global
80     -- variable.
81     --
82     l_legislation_code := hr_tic_bus.g_legislation_code;
83     hr_utility.set_location(l_proc, 20);
84   else
85     --
86     -- The ID is different to the last call to this function
87     -- or this is the first call to this function.
88     --
89     open csr_leg_code;
90     fetch csr_leg_code into l_legislation_code;
91     --
92     if csr_leg_code%notfound then
93       --
94       -- The primary key is invalid therefore we must error
95       --
96       close csr_leg_code;
97       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
98       fnd_message.raise_error;
99     end if;
100     hr_utility.set_location(l_proc,30);
101     --
102     -- Set the global variables so the values are
103     -- available for the next call to this function.
104     --
105     close csr_leg_code;
106     hr_tic_bus.g_template_item_context_id := p_template_item_context_id;
107     hr_tic_bus.g_legislation_code  := l_legislation_code;
108   end if;
109   hr_utility.set_location(' Leaving:'|| l_proc, 40);
110   return l_legislation_code;
111 end return_legislation_code;
112 --
113 -- ----------------------------------------------------------------------------
114 -- |-----------------------< chk_non_updateable_args >------------------------|
115 -- ----------------------------------------------------------------------------
116 -- {Start Of Comments}
117 --
118 -- Description:
119 --   This procedure is used to ensure that non updateable attributes have
120 --   not been updated. If an attribute has been updated an error is generated.
121 --
122 -- Pre Conditions:
123 --   g_old_rec has been populated with details of the values currently in
124 --   the database.
125 --
126 -- In Arguments:
127 --   p_rec has been populated with the updated values the user would like the
128 --   record set to.
129 --
130 -- Post Success:
131 --   Processing continues if all the non updateable attributes have not
132 --   changed.
133 --
134 -- Post Failure:
135 --   An application error is raised if any of the non updatable attributes
136 --   have been altered.
137 --
138 -- {End Of Comments}
139 -- ----------------------------------------------------------------------------
140 Procedure chk_non_updateable_args
141   (p_rec in hr_tic_shd.g_rec_type
142   ) IS
143 --
144   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
145   l_error    EXCEPTION;
146   l_argument varchar2(30);
147 --
148 Begin
149   --
150   -- Only proceed with the validation if a row exists for the current
151   -- record in the HR Schema.
152   --
153   IF NOT hr_tic_shd.api_updating
154       (p_template_item_context_id             => p_rec.template_item_context_id
155       ,p_object_version_number                => p_rec.object_version_number
156       ) THEN
157      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
158      fnd_message.set_token('PROCEDURE ', l_proc);
159      fnd_message.set_token('STEP ', '5');
160      fnd_message.raise_error;
161   END IF;
162   --
163   IF (nvl(p_rec.template_item_id,hr_api.g_number) <>
164       nvl(hr_tic_shd.g_old_rec.template_item_id,hr_api.g_number)
165      ) THEN
166      l_argument := 'template_item_id';
167      RAISE l_error;
168   END IF;
169   --
170   IF (nvl(p_rec.context_type,hr_api.g_varchar2) <>
171       nvl(hr_tic_shd.g_old_rec.context_type,hr_api.g_varchar2)
172      ) THEN
173      l_argument := 'context_type';
174      RAISE l_error;
175   END IF;
176   --
177   IF (nvl(p_rec.item_context_id,hr_api.g_number) <>
178       nvl(hr_tic_shd.g_old_rec.item_context_id,hr_api.g_number)
179      ) THEN
180      l_argument := 'item_context_id';
181      RAISE l_error;
182   END IF;
183   --
184   EXCEPTION
185     WHEN l_error THEN
186        hr_api.argument_changed_error
187          (p_api_name => l_proc
188          ,p_argument => l_argument);
189     WHEN OTHERS THEN
190        RAISE;
191 End chk_non_updateable_args;
192 --
193 -- ----------------------------------------------------------------------------
194 -- |-------------------------< chk_template_item_id >-------------------------|
195 -- ----------------------------------------------------------------------------
196 Procedure chk_template_item_id
197   (p_template_item_context_id     in     number
198   ,p_object_version_number        in     number
199   ,p_template_item_id             in     number
200   ) is
201   --
202   l_proc                         varchar2(72) := g_package || 'chk_template_item_id';
203   l_api_updating                 boolean;
204   --
205 Begin
206   hr_utility.set_location('Entering:'||l_proc, 10);
207   --
208   -- Check value has been passed
209   --
210   hr_api.mandatory_arg_error
211     (p_api_name                     => l_proc
212     ,p_argument                     => 'template_item_id'
213     ,p_argument_value               => p_template_item_id
214     );
215   --
216   hr_utility.set_location('Leaving:'||l_proc, 100);
217 End chk_template_item_id;
218 --
219 -- ----------------------------------------------------------------------------
220 -- |-------------------------< chk_context_type >-------------------------|
221 -- ----------------------------------------------------------------------------
222 Procedure chk_context_type
223   (p_template_item_context_id     in     number
224   ,p_object_version_number        in     number
225   ,p_context_type                 in     varchar2
226   ) is
227   --
228   l_proc                         varchar2(72) := g_package || 'chk_context_type';
229   l_api_updating                 boolean;
230   --
231 Begin
232   hr_utility.set_location('Entering:'||l_proc, 10);
233   --
234   -- Check value has been passed
235   --
236   hr_api.mandatory_arg_error
237     (p_api_name                     => l_proc
238     ,p_argument                     => 'context_type'
239     ,p_argument_value               => p_context_type
240     );
241   --
242   hr_utility.set_location('Leaving:'||l_proc, 100);
243 End chk_context_type;
244 --
245 -- ----------------------------------------------------------------------------
246 -- |-------------------------< chk_item_context_id >-------------------------|
247 -- ----------------------------------------------------------------------------
248 Procedure chk_item_context_id
249   (p_template_item_context_id     in     number
250   ,p_object_version_number        in     number
251   ,p_item_context_id              in     number
252   ) is
253   --
254   l_proc                         varchar2(72) := g_package || 'chk_item_context_id';
255   l_api_updating                 boolean;
256   --
257 Begin
258   hr_utility.set_location('Entering:'||l_proc, 10);
259   --
260   -- Check value has been passed
261   --
262   hr_api.mandatory_arg_error
263     (p_api_name                     => l_proc
264     ,p_argument                     => 'item_context_id'
265     ,p_argument_value               => p_item_context_id
266     );
267   --
268   hr_utility.set_location('Leaving:'||l_proc, 100);
269 End chk_item_context_id;
270 --
271 -- ----------------------------------------------------------------------------
272 -- |---------------------------< chk_item_and_context >-----------------------|
273 -- ----------------------------------------------------------------------------
274 Procedure chk_item_and_context
275   (p_template_item_context_id     in number
276   ,p_object_version_number        in number
277   ,p_template_item_id             in number
278   ,p_item_context_id              in number
279   ) is
280   --
281   CURSOR csr_item_contexts
282     (p_item_context_id              in number
283     )
284   IS
285     SELECT ifs.id_flex_structure_code
286           ,icx.segment1
287           ,icx.segment2
288       FROM fnd_id_flex_structures ifs
289           ,hr_item_contexts icx
290      WHERE ifs.application_id = 800
291        AND ifs.id_flex_code = 'ICX'
292        AND ifs.id_flex_num = icx.id_flex_num
293        AND icx.item_context_id = p_item_context_id;
294   l_item_context                 csr_item_contexts%rowtype;
295   --
296   CURSOR csr_template_item_contexts
297     (p_template_item_id             in number
298     ,p_template_item_context_id     in number
299     )
300   IS
301     SELECT ifs.id_flex_structure_code
302           ,icx.segment1
303           ,icx.segment2
304       FROM fnd_id_flex_structures ifs
305           ,hr_item_contexts icx
306           ,hr_template_item_contexts_b tic
307      WHERE ifs.application_id = 800
308        AND ifs.id_flex_code = 'ICX'
309        AND ifs.id_flex_num = icx.id_flex_num
310        AND icx.item_context_id = tic.item_context_id
311        AND tic.template_item_id = p_template_item_id
312        AND (  p_template_item_context_id IS NULL
313            OR tic.template_item_context_id <> p_template_item_context_id);
314   --
315   l_proc                         varchar2(71) := g_package || 'chk_item_and_context';
316   l_api_updating                 boolean;
317   --
318 Begin
319   hr_utility.set_location('Entering:'||l_proc, 10);
320   --
321   -- Retrieve context for specific item context
322   --
323   OPEN csr_item_contexts
324     (p_item_context_id => p_item_context_id
325     );
326   FETCH csr_item_contexts INTO l_item_context;
327   CLOSE csr_item_contexts;
328   --
329   hr_utility.set_location(l_proc, 20);
330   --
331   -- Compare with contexts already defined for the same item
332   --
333   FOR l_template_item_context IN csr_template_item_contexts
334     (p_template_item_id         => p_template_item_id
335     ,p_template_item_context_id => p_template_item_context_id
336     )
337   LOOP
338     IF    (l_template_item_context.id_flex_structure_code <> l_item_context.id_flex_structure_code)
339     THEN
340       fnd_message.set_name('PER', 'HR_52650_TIC_DIFFERENT_CONTEXT');
341       fnd_message.raise_error;
342     ELSIF (l_template_item_context.id_flex_structure_code IN ('DFLEX','KFLEX'))
343     THEN
344       IF (  (l_template_item_context.segment1 <> l_item_context.segment1)
345          OR (l_template_item_context.segment2 <> l_item_context.segment2) )
346       THEN
347         fnd_message.set_name('PER', 'HR_52650_TIC_DIFFERENT_CONTEXT');
348         fnd_message.raise_error;
349       END IF;
350     END IF;
351   END LOOP;
352   --
353   hr_utility.set_location('Leaving:'||l_proc, 100);
354 End chk_item_and_context;
355 --
356 -- ----------------------------------------------------------------------------
357 -- |------------------------------< chk_delete >------------------------------|
358 -- ----------------------------------------------------------------------------
359 Procedure chk_delete
360   (p_rec                          in hr_tic_shd.g_rec_type
361   ) is
362 --
363   l_proc  varchar2(72) := g_package||'chk_delete';
364 --
365 Begin
366   hr_utility.set_location('Entering:'||l_proc, 5);
367   --
368   -- No additional validation required
369   --
370   null;
371   --
372   hr_utility.set_location(' Leaving:'||l_proc, 10);
373 End chk_delete;
374 --
375 -- ----------------------------------------------------------------------------
376 -- |---------------------------< insert_validate >----------------------------|
377 -- ----------------------------------------------------------------------------
378 Procedure insert_validate
379   (p_rec                          in hr_tic_shd.g_rec_type
380   ) is
381 --
382   l_proc  varchar2(72) := g_package||'insert_validate';
383 --
384 Begin
385   hr_utility.set_location('Entering:'||l_proc, 5);
386   --
387   -- Call all supporting business operations
388   -- No business group context.  HR_STANDARD_LOOKUPS used for validation.
389   --
390   chk_template_item_id
391     (p_template_item_context_id     => p_rec.template_item_context_id
392     ,p_object_version_number        => p_rec.object_version_number
393     ,p_template_item_id             => p_rec.template_item_id
394     );
395   --
396   chk_context_type
397     (p_template_item_context_id     => p_rec.template_item_context_id
398     ,p_object_version_number        => p_rec.object_version_number
399     ,p_context_type                 => p_rec.context_type
400     );
401   --
402   chk_item_context_id
403     (p_template_item_context_id     => p_rec.template_item_context_id
404     ,p_object_version_number        => p_rec.object_version_number
405     ,p_item_context_id              => p_rec.item_context_id
406     );
407   --
408   chk_item_and_context
409     (p_template_item_context_id     => p_rec.template_item_context_id
410     ,p_object_version_number        => p_rec.object_version_number
411     ,p_item_context_id              => p_rec.item_context_id
412     ,p_template_item_id             => p_rec.template_item_id
413     );
414   --
415   hr_utility.set_location(' Leaving:'||l_proc, 10);
416 End insert_validate;
417 --
418 -- ----------------------------------------------------------------------------
419 -- |---------------------------< update_validate >----------------------------|
420 -- ----------------------------------------------------------------------------
421 Procedure update_validate
422   (p_rec                          in hr_tic_shd.g_rec_type
423   ) is
424 --
425   l_proc  varchar2(72) := g_package||'update_validate';
426 --
427 Begin
428   hr_utility.set_location('Entering:'||l_proc, 5);
429   --
430   -- Call all supporting business operations
431   -- No business group context.  HR_STANDARD_LOOKUPS used for validation.
432   --
433   chk_non_updateable_args
434     (p_rec                          => p_rec
435     );
436   --
437   chk_template_item_id
438     (p_template_item_context_id     => p_rec.template_item_context_id
439     ,p_object_version_number        => p_rec.object_version_number
440     ,p_template_item_id             => p_rec.template_item_id
441     );
442   --
443   chk_context_type
444     (p_template_item_context_id     => p_rec.template_item_context_id
445     ,p_object_version_number        => p_rec.object_version_number
446     ,p_context_type                 => p_rec.context_type
447     );
448   --
449   chk_item_context_id
450     (p_template_item_context_id     => p_rec.template_item_context_id
451     ,p_object_version_number        => p_rec.object_version_number
452     ,p_item_context_id              => p_rec.item_context_id
453     );
454   --
455   chk_item_and_context
456     (p_template_item_context_id     => p_rec.template_item_context_id
457     ,p_object_version_number        => p_rec.object_version_number
458     ,p_item_context_id              => p_rec.item_context_id
459     ,p_template_item_id             => p_rec.template_item_id
460     );
461    --
462   hr_utility.set_location(' Leaving:'||l_proc, 10);
463 End update_validate;
464 --
465 -- ----------------------------------------------------------------------------
466 -- |---------------------------< delete_validate >----------------------------|
467 -- ----------------------------------------------------------------------------
468 Procedure delete_validate
469   (p_rec                          in hr_tic_shd.g_rec_type
470   ) is
471 --
472   l_proc  varchar2(72) := g_package||'delete_validate';
473 --
474 Begin
475   hr_utility.set_location('Entering:'||l_proc, 5);
476   --
477   -- Call all supporting business operations
478   --
479   chk_delete
480     (p_rec                          => p_rec
481     );
482   --
483   hr_utility.set_location(' Leaving:'||l_proc, 10);
484 End delete_validate;
485 --
486 end hr_tic_bus;