DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_TCP_BUS

Source


1 Package Body hr_tcp_bus as
2 /* $Header: hrtcprhi.pkb 120.1 2011/04/28 11:07:08 sidsaxen ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hr_tcp_bus.';  -- Global package name
9 --
13 g_legislation_code             varchar2(150)  default null;
10 -- The following two global variables are only to be
11 -- used by the return_legislation_code function.
12 --
14 g_template_item_context_page_i number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_template_item_context_page_i         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_page_i         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           ,hr_template_item_context_pages tcp
55      where tmp.form_template_id = tim.form_template_id
56        and tim.template_item_id = tic.template_item_id
57        and tic.template_item_context_id = tcp.template_item_context_id
58        and tcp.template_item_context_page_id = p_template_item_context_page_i;
59   --
60   -- Declare local variables
61   --
62   l_legislation_code  varchar2(150);
63   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
64   --
65 Begin
66   --
67   hr_utility.set_location('Entering:'|| l_proc, 10);
68   --
69   -- Ensure that all the mandatory parameter are not null
70   --
71   hr_api.mandatory_arg_error
72     (p_api_name           => l_proc
73     ,p_argument           => 'template_item_context_page_id'
74     ,p_argument_value     => p_template_item_context_page_i
75     );
76   --
77   if ( nvl(hr_tcp_bus.g_template_item_context_page_i, hr_api.g_number)
78        = p_template_item_context_page_i) then
79     --
80     -- The legislation code has already been found with a previous
81     -- call to this function. Just return the value in the global
82     -- variable.
83     --
84     l_legislation_code := hr_tcp_bus.g_legislation_code;
85     hr_utility.set_location(l_proc, 20);
86   else
87     --
88     -- The ID is different to the last call to this function
89     -- or this is the first call to this function.
90     --
91     open csr_leg_code;
92     fetch csr_leg_code into l_legislation_code;
93     --
94     if csr_leg_code%notfound then
95       --
96       -- The primary key is invalid therefore we must error
97       --
98       close csr_leg_code;
99       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
100       fnd_message.raise_error;
101     end if;
102     hr_utility.set_location(l_proc,30);
103     --
104     -- Set the global variables so the values are
105     -- available for the next call to this function.
106     --
107     close csr_leg_code;
108     hr_tcp_bus.g_template_item_context_page_i := p_template_item_context_page_i;
109     hr_tcp_bus.g_legislation_code := l_legislation_code;
110   end if;
111   hr_utility.set_location(' Leaving:'|| l_proc, 40);
112   return l_legislation_code;
113 end return_legislation_code;
114 --
115 -- ----------------------------------------------------------------------------
116 -- |-----------------------< chk_non_updateable_args >------------------------|
117 -- ----------------------------------------------------------------------------
118 -- {Start Of Comments}
119 --
120 -- Description:
121 --   This procedure is used to ensure that non updateable attributes have
122 --   not been updated. If an attribute has been updated an error is generated.
123 --
124 -- Pre Conditions:
125 --   g_old_rec has been populated with details of the values currently in
126 --   the database.
127 --
128 -- In Arguments:
129 --   p_rec has been populated with the updated values the user would like the
130 --   record set to.
131 --
132 -- Post Success:
133 --   Processing continues if all the non updateable attributes have not
134 --   changed.
135 --
136 -- Post Failure:
137 --   An application error is raised if any of the non updatable attributes
138 --   have been altered.
139 --
140 -- {End Of Comments}
141 -- ----------------------------------------------------------------------------
142 Procedure chk_non_updateable_args
143   (p_rec in hr_tcp_shd.g_rec_type
144   ) IS
145 --
146   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
147   l_error    EXCEPTION;
148   l_argument varchar2(30);
149 --
150 Begin
151   --
152   -- Only proceed with the validation if a row exists for the current
153   -- record in the HR Schema.
154   --
155   IF NOT hr_tcp_shd.api_updating
159      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
156       (p_template_item_context_page_i         => p_rec.template_item_context_page_id
157       ,p_object_version_number                => p_rec.object_version_number
158       ) THEN
160      fnd_message.set_token('PROCEDURE ', l_proc);
161      fnd_message.set_token('STEP ', '5');
162      fnd_message.raise_error;
163   END IF;
164   --
165   IF (nvl(p_rec.template_item_context_id,hr_api.g_number) <>
166       nvl(hr_tcp_shd.g_old_rec.template_item_context_id,hr_api.g_number)
167      ) THEN
168      l_argument := 'template_item_context_id';
169      RAISE l_error;
170   END IF;
171   --
172   IF (nvl(p_rec.template_tab_page_id,hr_api.g_number) <>
173       nvl(hr_tcp_shd.g_old_rec.template_tab_page_id,hr_api.g_number)
174      ) THEN
175      l_argument := 'template_tab_page_id';
176      RAISE l_error;
177   END IF;
178   --
179   EXCEPTION
180     WHEN l_error THEN
181        hr_api.argument_changed_error
182          (p_api_name => l_proc
183          ,p_argument => l_argument);
184     WHEN OTHERS THEN
185        RAISE;
186 End chk_non_updateable_args;
187 --
188 -- ----------------------------------------------------------------------------
189 -- |---------------------< chk_template_item_context_id >---------------------|
190 -- ----------------------------------------------------------------------------
191 Procedure chk_template_item_context_id
192   (p_template_item_context_page_i in     number
193   ,p_object_version_number        in     number
194   ,p_template_item_context_id     in     number
195   ) is
196   --
197   l_proc                         varchar2(72) := g_package || 'chk_template_item_context_id';
198   l_api_updating                 boolean;
199   --
200 Begin
201   hr_utility.set_location('Entering:'||l_proc, 10);
202   --
203   -- Check value has been passed
204   --
205   hr_api.mandatory_arg_error
206     (p_api_name                     => l_proc
207     ,p_argument                     => 'template_item_context_id'
208     ,p_argument_value               => p_template_item_context_id
209     );
210   --
211   hr_utility.set_location('Leaving:'||l_proc, 100);
212 End chk_template_item_context_id;
213 --
214 -- ----------------------------------------------------------------------------
215 -- |-----------------------< chk_template_tab_page_id >-----------------------|
216 -- ----------------------------------------------------------------------------
217 Procedure chk_template_tab_page_id
218   (p_template_item_context_page_i in     number
219   ,p_object_version_number        in     number
220   ,p_template_tab_page_id         in     number
221   ) is
222   --
223   l_proc                         varchar2(72) := g_package || 'chk_template_tab_page_id';
224   l_api_updating                 boolean;
225   --
226 Begin
227   hr_utility.set_location('Entering:'||l_proc, 10);
228   --
229   -- Check value has been passed
230   --
231   hr_api.mandatory_arg_error
232     (p_api_name                     => l_proc
233     ,p_argument                     => 'template_tab_page_id'
234     ,p_argument_value               => p_template_tab_page_id
235     );
236   --
237   hr_utility.set_location('Leaving:'||l_proc, 100);
238 End chk_template_tab_page_id;
239 --
240 -- ----------------------------------------------------------------------------
241 -- |-----------------------< chk_context_and_tab_page >-----------------------|
242 -- ----------------------------------------------------------------------------
243 Procedure chk_context_and_tab_page
244   (p_template_item_context_page_i in     number
245   ,p_object_version_number        in     number
246   ,p_template_item_context_id     in     number
247   ,p_template_tab_page_id         in     number
248   ) is
249   --
250   cursor csr_template_item_context is
251     select tim.form_template_id
252       from hr_template_items_b tim
253           ,hr_template_item_contexts_b tic
254      where tim.template_item_id = tic.template_item_id
255        and tic.template_item_context_id = p_template_item_context_id;
256   --
257   cursor csr_template_tab_page is
258     select twn.form_template_id
259       from hr_template_windows_b twn
260           ,hr_template_canvases_b tcn
261           ,hr_template_tab_pages_b ttp
262      where twn.template_window_id = tcn.template_window_id
263        and tcn.template_canvas_id = ttp.template_canvas_id
264        and ttp.template_tab_page_id = p_template_tab_page_id;
265   --
266   cursor csr_tab_stacked_canvas is
267     select null
268       from hr_template_tab_pages_b ttp
269           ,hr_form_tab_stacked_canvases fs2
270           ,hr_form_tab_stacked_canvases fs1
271           ,hr_form_items_b fim
272           ,hr_template_items_b tim
273           ,hr_template_item_contexts_b tic
274      where p_template_tab_page_id = ttp.template_tab_page_id
275        and ttp.form_tab_page_id = fs2.form_tab_page_id
276        and fs2.form_canvas_id = fs1.form_canvas_id
277        and fs1.form_tab_page_id = fim.form_tab_page_id
278        and fim.form_item_id = tim.form_item_id
279        and tim.template_item_id = tic.template_item_id
280        and tic.template_item_context_id = p_template_item_context_id;
281   --
282   l_proc                         varchar2(72) := g_package || 'chk_context_and_tab_page';
283   l_api_updating                 boolean;
284   l_context_template_id          number;
285   l_tab_page_template_id         number;
286   l_dummy                        varchar2(1);
287   --
288 Begin
289   hr_utility.set_location('Entering:'||l_proc, 10);
290   --
291   l_api_updating := hr_tcp_shd.api_updating
295   hr_utility.set_location(l_proc,20);
292     (p_template_item_context_page_i => p_template_item_context_page_i
293     ,p_object_version_number        => p_object_version_number
294     );
296   --
297   -- Only proceed with SQL validation if absolutely necessary
298   --
299   if (  (   l_api_updating
300         and (  nvl(hr_tcp_shd.g_old_rec.template_item_context_id,hr_api.g_number) <>
301                nvl(p_template_item_context_id,hr_api.g_number)
302             or nvl(hr_tcp_shd.g_old_rec.template_tab_page_id,hr_api.g_number) <>
303                nvl(p_template_tab_page_id,hr_api.g_number)))
304      or (NOT l_api_updating)) then
305     --
306     hr_utility.set_location(l_proc,30);
307     --
308     open csr_template_item_context;
309     fetch csr_template_item_context into l_context_template_id;
310     if csr_template_item_context%notfound then
311       close csr_template_item_context;
312       fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
313       fnd_message.set_token('PROCEDURE', l_proc);
314       fnd_message.set_token('STEP','10');
315       fnd_message.raise_error;
316     end if;
317     close csr_template_item_context;
318     --
319     open csr_template_tab_page;
320     fetch csr_template_tab_page into l_tab_page_template_id;
321     if csr_template_tab_page%notfound then
322       close csr_template_tab_page;
323       fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
324       fnd_message.set_token('PROCEDURE', l_proc);
325       fnd_message.set_token('STEP','20');
326       fnd_message.raise_error;
327     end if;
328     close csr_template_tab_page;
329     --
330     hr_utility.set_location(l_proc,40);
331     --
332     -- Check context and tab page reference the same template
333     --
334     if nvl(l_context_template_id,hr_api.g_number) <>
335        nvl(l_tab_page_template_id,hr_api.g_number) then
336       fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
337       fnd_message.set_token('PROCEDURE', l_proc);
338       fnd_message.set_token('STEP','30');
339       fnd_message.raise_error;
340     end if;
341     --
342     hr_utility.set_location(l_proc,50);
343     --
344     -- Check context and tab page reference the same tab stacked canvas
345     --
346     open csr_tab_stacked_canvas;
347     fetch csr_tab_stacked_canvas into l_dummy;
348     if csr_tab_stacked_canvas%notfound then
349       close csr_tab_stacked_canvas;
350       fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
351       fnd_message.set_token('PROCEDURE', l_proc);
352       fnd_message.set_token('STEP','40');
353       fnd_message.raise_error;
354     end if;
355     close csr_tab_stacked_canvas;
356     --
357   end if;
358   --
359   hr_utility.set_location('Leaving:'||l_proc, 100);
360 End chk_context_and_tab_page;
361 --
362 -- ----------------------------------------------------------------------------
363 -- |------------------------------< chk_delete >------------------------------|
364 -- ----------------------------------------------------------------------------
365 Procedure chk_delete
366   (p_rec                          in hr_tcp_shd.g_rec_type
367   ) is
368 --
369   l_proc  varchar2(72) := g_package||'chk_delete';
370 --
371 Begin
372   hr_utility.set_location('Entering:'||l_proc, 5);
373   --
374   -- No additional validation required
375   --
376   null;
377   --
378   hr_utility.set_location(' Leaving:'||l_proc, 10);
379 End chk_delete;
380 --
381 -- ----------------------------------------------------------------------------
382 -- |---------------------------< insert_validate >----------------------------|
383 -- ----------------------------------------------------------------------------
384 Procedure insert_validate
385   (p_rec                          in hr_tcp_shd.g_rec_type
386   ) is
387 --
388   l_proc  varchar2(72) := g_package||'insert_validate';
389 --
390 Begin
391   hr_utility.set_location('Entering:'||l_proc, 5);
392   --
393   -- Call all supporting business operations
394   -- No business group context.  HR_STANDARD_LOOKUPS used for validation.
395   --
396   chk_template_item_context_id
397     (p_template_item_context_page_i => p_rec.template_item_context_page_id
398     ,p_object_version_number        => p_rec.object_version_number
399     ,p_template_item_context_id     => p_rec.template_item_context_id
400     );
401   --
402   chk_template_tab_page_id
403     (p_template_item_context_page_i => p_rec.template_item_context_page_id
404     ,p_object_version_number        => p_rec.object_version_number
405     ,p_template_tab_page_id         => p_rec.template_tab_page_id
406     );
407   --
408   chk_context_and_tab_page
409     (p_template_item_context_page_i => p_rec.template_item_context_page_id
410     ,p_object_version_number        => p_rec.object_version_number
411     ,p_template_item_context_id     => p_rec.template_item_context_id
412     ,p_template_tab_page_id         => p_rec.template_tab_page_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_tcp_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_context_id
438     (p_template_item_context_page_i => p_rec.template_item_context_page_id
439     ,p_object_version_number        => p_rec.object_version_number
440     ,p_template_item_context_id     => p_rec.template_item_context_id
441     );
442   --
443   chk_template_tab_page_id
444     (p_template_item_context_page_i => p_rec.template_item_context_page_id
445     ,p_object_version_number        => p_rec.object_version_number
446     ,p_template_tab_page_id         => p_rec.template_tab_page_id
447     );
448   --
449   chk_context_and_tab_page
450     (p_template_item_context_page_i => p_rec.template_item_context_page_id
451     ,p_object_version_number        => p_rec.object_version_number
452     ,p_template_item_context_id     => p_rec.template_item_context_id
453     ,p_template_tab_page_id         => p_rec.template_tab_page_id
454     );
455   --
456   hr_utility.set_location(' Leaving:'||l_proc, 10);
457 End update_validate;
458 --
459 -- ----------------------------------------------------------------------------
460 -- |---------------------------< delete_validate >----------------------------|
461 -- ----------------------------------------------------------------------------
462 Procedure delete_validate
463   (p_rec                          in hr_tcp_shd.g_rec_type
464   ) is
465 --
466   l_proc  varchar2(72) := g_package||'delete_validate';
467 --
468 Begin
469   hr_utility.set_location('Entering:'||l_proc, 5);
470   --
471   -- Call all supporting business operations
472   --
473   chk_delete
474     (p_rec                          => p_rec
475     );
476   --
477   hr_utility.set_location(' Leaving:'||l_proc, 10);
478 End delete_validate;
479 --
480 end hr_tcp_bus;