DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_TCN_BUS

Source


1 Package Body hr_tcn_bus as
2 /* $Header: hrtcnrhi.pkb 115.5 2002/12/03 10:00:59 raranjan noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hr_tcn_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_canvas_id          number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_template_canvas_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_canvas_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_windows_b twn
53           ,hr_template_canvases_b tcn
54      where tmp.form_template_id = twn.form_template_id
55        and twn.template_window_id = tcn.template_window_id
56        and tcn.template_canvas_id = p_template_canvas_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_canvas_id'
72     ,p_argument_value     => p_template_canvas_id
73     );
74   --
75   if ( nvl(hr_tcn_bus.g_template_canvas_id, hr_api.g_number)
76        = p_template_canvas_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_tcn_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_tcn_bus.g_template_canvas_id:= p_template_canvas_id;
107     hr_tcn_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_tcn_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_tcn_shd.api_updating
154       (p_template_canvas_id                   => p_rec.template_canvas_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.form_canvas_id,hr_api.g_number) <>
164       nvl(hr_tcn_shd.g_old_rec.form_canvas_id,hr_api.g_number)
165      ) THEN
166      l_argument := 'form_canvas_id';
167      RAISE l_error;
168   END IF;
169   --
170   IF (nvl(p_rec.template_window_id,hr_api.g_number) <>
171       nvl(hr_tcn_shd.g_old_rec.template_window_id,hr_api.g_number)
172      ) THEN
173      l_argument := 'template_window_id';
174      RAISE l_error;
175   END IF;
176   --
177   EXCEPTION
178     WHEN l_error THEN
179        hr_api.argument_changed_error
180          (p_api_name => l_proc
181          ,p_argument => l_argument);
182     WHEN OTHERS THEN
183        RAISE;
184 End chk_non_updateable_args;
185 --
186 -- ----------------------------------------------------------------------------
187 -- |--------------------------< chk_form_canvas_id >--------------------------|
188 -- ----------------------------------------------------------------------------
189 Procedure chk_form_canvas_id
190   (p_template_canvas_id           in     number
191   ,p_object_version_number        in     number
192   ,p_form_canvas_id               in     number
193   ) is
194   --
195   cursor csr_form_canvas is
196     select fcn.canvas_type
197       from hr_form_canvases_b fcn
198      where fcn.form_canvas_id = p_form_canvas_id;
199   --
200   l_proc                         varchar2(72) := g_package || 'chk_form_canvas_id';
201   l_api_updating                 boolean;
202   l_canvas_type                  varchar2(30);
203   --
204 Begin
205   hr_utility.set_location('Entering:'||l_proc, 10);
206   --
207   l_api_updating := hr_tcn_shd.api_updating
208     (p_template_canvas_id           => p_template_canvas_id
209     ,p_object_version_number        => p_object_version_number
210     );
211   hr_utility.set_location(l_proc,20);
212   --
213   -- Only proceed with SQL validation if absolutely necessary
214   --
215   if (  (   l_api_updating
216         and nvl(hr_fcn_shd.g_old_rec.form_canvas_id,hr_api.g_number) <>
217             nvl(p_form_canvas_id,hr_api.g_number))
218      or (NOT l_api_updating)) then
219     --
220     hr_utility.set_location(l_proc,30);
221     --
222     -- Check value has been passed
223     --
224     hr_api.mandatory_arg_error
225       (p_api_name                     => l_proc
226       ,p_argument                     => 'form_canvas_id'
227       ,p_argument_value               => p_form_canvas_id
228       );
229     --
230     -- Check canvas is of type CONTENT or TAB
231     --
232     open csr_form_canvas;
233     fetch csr_form_canvas into l_canvas_type;
234     if csr_form_canvas%notfound then
235       close csr_form_canvas;
236       fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
237       fnd_message.set_token('PROCEDURE', l_proc);
238       fnd_message.set_token('STEP','10');
239       fnd_message.raise_error;
240     end if;
241     close csr_form_canvas;
242     --
243 /*
244     if l_canvas_type not in ('CONTENT','TAB') then
245       fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
246       fnd_message.set_token('PROCEDURE', l_proc);
247       fnd_message.set_token('STEP','20');
248       fnd_message.raise_error;
249     end if;
250 */
251     --
252   end if;
253   --
254   hr_utility.set_location('Leaving:'||l_proc, 100);
255 End chk_form_canvas_id;
256 --
257 -- ----------------------------------------------------------------------------
258 -- |------------------------< chk_template_window_id >------------------------|
259 -- ----------------------------------------------------------------------------
260 Procedure chk_template_window_id
261   (p_template_canvas_id           in     number
262   ,p_object_version_number        in     number
263   ,p_template_window_id           in     number
264   ) is
265   --
266   l_proc                         varchar2(72) := g_package || 'chk_template_window_id';
267   l_api_updating                 boolean;
268   --
269 Begin
270   hr_utility.set_location('Entering:'||l_proc, 10);
271   --
272   -- Check value has been passed
273   --
274   hr_api.mandatory_arg_error
275     (p_api_name                     => l_proc
276     ,p_argument                     => 'template_window_id'
277     ,p_argument_value               => p_template_window_id
278     );
279   --
280   hr_utility.set_location('Leaving:'||l_proc, 100);
281 End chk_template_window_id;
282 --
283 -- ----------------------------------------------------------------------------
284 -- |-------------------------< chk_canvas_and_window >------------------------|
285 -- ----------------------------------------------------------------------------
286 Procedure chk_canvas_and_window
287   (p_template_canvas_id           in     number
288   ,p_object_version_number        in     number
289   ,p_form_canvas_id               in     number
290   ,p_template_window_id           in     number
291   ) is
292   --
293   cursor csr_form_canvas is
294     select fcn.form_window_id
295       from hr_form_canvases_b fcn
296      where fcn.form_canvas_id = p_form_canvas_id;
297   --
298   cursor csr_template_window is
299     select twn.form_window_id
300       from hr_template_windows_b twn
301      where twn.template_window_id = p_template_window_id;
302   --
303   l_proc                         varchar2(72) := g_package || 'chk_canvas_and_window';
304   l_api_updating                 boolean;
305   l_canvas_window_id             number;
306   l_window_window_id             number;
307   --
308 Begin
309   hr_utility.set_location('Entering:'||l_proc, 10);
310   --
311   l_api_updating := hr_tcn_shd.api_updating
312     (p_template_canvas_id           => p_template_canvas_id
313     ,p_object_version_number        => p_object_version_number
314     );
315   hr_utility.set_location(l_proc,20);
316   --
317   -- Only proceed with SQL validation if absolutely necessary
318   --
319   if (  (   l_api_updating
320         and (  nvl(hr_tcn_shd.g_old_rec.form_canvas_id,hr_api.g_number) <>
321                nvl(p_form_canvas_id,hr_api.g_number)
322             or nvl(hr_tcn_shd.g_old_rec.template_window_id,hr_api.g_number) <>
323                nvl(p_template_window_id,hr_api.g_number)))
324      or (NOT l_api_updating)) then
325     --
326     hr_utility.set_location(l_proc,30);
327     --
328     -- Check form canvas and template window reference the same form window
329     --
330     open csr_form_canvas;
331     fetch csr_form_canvas into l_canvas_window_id;
332     if csr_form_canvas%notfound then
333       close csr_form_canvas;
334       fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
335       fnd_message.set_token('PROCEDURE', l_proc);
336       fnd_message.set_token('STEP','10');
337       fnd_message.raise_error;
338     end if;
339     close csr_form_canvas;
340     --
341     open csr_template_window;
342     fetch csr_template_window into l_window_window_id;
343     if csr_template_window%notfound then
344       close csr_template_window;
345       fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
346       fnd_message.set_token('PROCEDURE', l_proc);
347       fnd_message.set_token('STEP','20');
348       fnd_message.raise_error;
349     end if;
350     close csr_template_window;
351     --
352     hr_utility.set_location(l_proc,40);
353     --
354     if nvl(l_canvas_window_id,hr_api.g_number) <>
355        nvl(l_window_window_id,hr_api.g_number) then
356       fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
360     end if;
357       fnd_message.set_token('PROCEDURE', l_proc);
358       fnd_message.set_token('STEP','30');
359       fnd_message.raise_error;
361     --
362   end if;
363   --
364   hr_utility.set_location('Leaving:'||l_proc, 100);
365 End chk_canvas_and_window;
366 --
367 -- ----------------------------------------------------------------------------
368 -- |------------------------------< chk_delete >------------------------------|
369 -- ----------------------------------------------------------------------------
370 Procedure chk_delete
371   (p_rec                          in hr_tcn_shd.g_rec_type
372   ) is
373 --
374   l_proc  varchar2(72) := g_package||'chk_delete';
375 --
376 Begin
377   hr_utility.set_location('Entering:'||l_proc, 5);
378   --
379   -- No additional validation required
380   --
381   null;
382   --
383   hr_utility.set_location(' Leaving:'||l_proc, 10);
384 End chk_delete;
385 --
386 -- ----------------------------------------------------------------------------
387 -- |---------------------------< insert_validate >----------------------------|
388 -- ----------------------------------------------------------------------------
389 Procedure insert_validate
390   (p_rec                          in hr_tcn_shd.g_rec_type
391   ) is
392 --
393   l_proc  varchar2(72) := g_package||'insert_validate';
394 --
395 Begin
396   hr_utility.set_location('Entering:'||l_proc, 5);
397   --
398   -- Call all supporting business operations
399   -- No business group context.  HR_STANDARD_LOOKUPS used for validation.
400   --
401   chk_form_canvas_id
402     (p_template_canvas_id           => p_rec.template_canvas_id
403     ,p_object_version_number        => p_rec.object_version_number
404     ,p_form_canvas_id               => p_rec.form_canvas_id
405     );
406   --
407   chk_template_window_id
408     (p_template_canvas_id           => p_rec.template_canvas_id
409     ,p_object_version_number        => p_rec.object_version_number
410     ,p_template_window_id           => p_rec.template_window_id
411     );
412   --
413   chk_canvas_and_window
414     (p_template_canvas_id           => p_rec.template_canvas_id
415     ,p_object_version_number        => p_rec.object_version_number
416     ,p_form_canvas_id               => p_rec.form_canvas_id
417     ,p_template_window_id           => p_rec.template_window_id
418     );
419   --
420   hr_utility.set_location(' Leaving:'||l_proc, 10);
421 End insert_validate;
422 --
423 -- ----------------------------------------------------------------------------
424 -- |---------------------------< update_validate >----------------------------|
425 -- ----------------------------------------------------------------------------
426 Procedure update_validate
427   (p_rec                          in hr_tcn_shd.g_rec_type
428   ) is
429 --
430   l_proc  varchar2(72) := g_package||'update_validate';
431 --
432 Begin
433   hr_utility.set_location('Entering:'||l_proc, 5);
434   --
435   -- Call all supporting business operations
436   -- No business group context.  HR_STANDARD_LOOKUPS used for validation.
437   --
438   chk_non_updateable_args
439     (p_rec                          => p_rec
440     );
441   --
442   chk_form_canvas_id
443     (p_template_canvas_id           => p_rec.template_canvas_id
444     ,p_object_version_number        => p_rec.object_version_number
445     ,p_form_canvas_id               => p_rec.form_canvas_id
446     );
447   --
448   chk_template_window_id
449     (p_template_canvas_id           => p_rec.template_canvas_id
450     ,p_object_version_number        => p_rec.object_version_number
451     ,p_template_window_id           => p_rec.template_window_id
452     );
453   --
454   chk_canvas_and_window
455     (p_template_canvas_id           => p_rec.template_canvas_id
456     ,p_object_version_number        => p_rec.object_version_number
457     ,p_form_canvas_id               => p_rec.form_canvas_id
458     ,p_template_window_id           => p_rec.template_window_id
459     );
460   --
461   hr_utility.set_location(' Leaving:'||l_proc, 10);
462 End update_validate;
463 --
464 -- ----------------------------------------------------------------------------
465 -- |---------------------------< delete_validate >----------------------------|
466 -- ----------------------------------------------------------------------------
467 Procedure delete_validate
468   (p_rec                          in hr_tcn_shd.g_rec_type
469   ) is
470 --
471   l_proc  varchar2(72) := g_package||'delete_validate';
472 --
473 Begin
474   hr_utility.set_location('Entering:'||l_proc, 5);
475   --
476   -- Call all supporting business operations
477   --
478   chk_delete
479     (p_rec                          => p_rec
480     );
481   --
482   hr_utility.set_location(' Leaving:'||l_proc, 10);
483 End delete_validate;
484 --
485 end hr_tcn_bus;