DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_SFT_BUS

Source


1 Package Body hr_sft_bus as
2 /* $Header: hrsftrhi.pkb 115.4 2003/10/23 01:45:00 bsubrama noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_sft_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_source_form_template_id     number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_source_form_template_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_source_form_template_id              in     number
44   )
45   Return Varchar2 Is
46   --
47   l_legislation_code  varchar2(150);
48   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
49   --
50 Begin
51   --
52   hr_utility.set_location('Entering:'|| l_proc, 10);
53   --
54   -- Legislation code not available for source form templates
55   --
56   l_legislation_code := null;
57   --
58   hr_utility.set_location(' Leaving:'|| l_proc, 40);
59   return l_legislation_code;
60 end return_legislation_code;
61 --
62 -- ----------------------------------------------------------------------------
63 -- |-----------------------< chk_non_updateable_args >------------------------|
64 -- ----------------------------------------------------------------------------
65 -- {Start Of Comments}
66 --
67 -- Description:
68 --   This procedure is used to ensure that non updateable attributes have
69 --   not been updated. If an attribute has been updated an error is generated.
70 --
71 -- Pre Conditions:
72 --   g_old_rec has been populated with details of the values currently in
73 --   the database.
74 --
75 -- In Arguments:
76 --   p_rec has been populated with the updated values the user would like the
77 --   record set to.
78 --
79 -- Post Success:
80 --   Processing continues if all the non updateable attributes have not
81 --   changed.
82 --
83 -- Post Failure:
84 --   An application error is raised if any of the non updatable attributes
85 --   have been altered.
86 --
87 -- {End Of Comments}
88 -- ----------------------------------------------------------------------------
89 Procedure chk_non_updateable_args
90   (p_rec in hr_sft_shd.g_rec_type
91   ) IS
92 --
93   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
94   l_error    EXCEPTION;
95   l_argument varchar2(30);
96 --
97 Begin
98   --
99   -- Only proceed with the validation if a row exists for the current
100   -- record in the HR Schema.
101   --
102   IF NOT hr_sft_shd.api_updating
103       (p_source_form_template_id              => p_rec.source_form_template_id
104       ,p_object_version_number                => p_rec.object_version_number
105       ) THEN
106      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
107      fnd_message.set_token('PROCEDURE ', l_proc);
108      fnd_message.set_token('STEP ', '5');
109      fnd_message.raise_error;
110   END IF;
111   --
112   IF (nvl(p_rec.form_template_id_from,hr_api.g_number) <>
113       nvl(hr_sft_shd.g_old_rec.form_template_id_from,hr_api.g_number)
114      ) THEN
115      l_argument := 'form_template_id_from';
116      RAISE l_error;
117   END IF;
118   --
119   IF (nvl(p_rec.form_template_id_to,hr_api.g_number) <>
120       nvl(hr_sft_shd.g_old_rec.form_template_id_to,hr_api.g_number)
121      ) THEN
122      l_argument := 'form_template_id_to';
123      RAISE l_error;
124   END IF;
125   --
126   EXCEPTION
127     WHEN l_error THEN
128        hr_api.argument_changed_error
129          (p_api_name => l_proc
130          ,p_argument => l_argument);
131     WHEN OTHERS THEN
132        RAISE;
133 End chk_non_updateable_args;
134 --
135 -- ----------------------------------------------------------------------------
136 -- |----------------------< chk_form_template_id_from >-----------------------|
137 -- ----------------------------------------------------------------------------
138 Procedure chk_form_template_id_from
139   (p_source_form_template_id      in number
140   ,p_form_template_id_from        in number
141   ) is
142 --
143   l_proc                         varchar2(72) := g_package || 'chk_form_template_id_from';
144   l_api_updating                 boolean;
145 --
146 Begin
147   hr_utility.set_location('Entering:'||l_proc, 5);
148   --
149   -- No additional validation required
150   --
151   null;
152   --
153   hr_utility.set_location(' Leaving:'||l_proc, 10);
154 End chk_form_template_id_from;
155 --
156 -- ----------------------------------------------------------------------------
157 -- |-----------------------< chk_form_template_id_to >------------------------|
158 -- ----------------------------------------------------------------------------
159 Procedure chk_form_template_id_to
160   (p_source_form_template_id      in number
161   ,p_form_template_id_to          in number
162   ) is
163 --
164   l_proc                         varchar2(72) := g_package || 'chk_form_template_id_to';
165   l_api_updating                 boolean;
166 --
167 Begin
168   hr_utility.set_location('Entering:'||l_proc, 5);
169   --
170   -- Check value has been passed
171   --
172   hr_api.mandatory_arg_error
173     (p_api_name           => l_proc
174     ,p_argument           => 'form_template_id_to'
175     ,p_argument_value     => p_form_template_id_to
176     );
177   --
178   hr_utility.set_location(' Leaving:'||l_proc, 10);
179 End chk_form_template_id_to;
180 --
181 -- ----------------------------------------------------------------------------
182 -- |--------------------------< chk_form_templates >--------------------------|
183 -- ----------------------------------------------------------------------------
184 Procedure chk_form_templates
185   (p_source_form_template_id      in number
186   ,p_object_version_number        in number
187   ,p_form_template_id_from        in number
188   ,p_form_template_id_to          in number
189   ) is
190 --
191   cursor csr_form_template
192     (p_form_template_id             in number
193     ) is
194     select tmp.application_id
195           ,tmp.form_id
196       from hr_form_templates_b tmp
197      where tmp.form_template_id = p_form_template_id;
198 --
199   l_proc                         varchar2(72) := g_package || 'chk_form_templates';
200   l_api_updating                 boolean;
201   l_from_application_id          number;
202   l_from_form_id                 number;
203   l_to_application_id            number;
204   l_to_form_id                   number;
205 --
206 Begin
207   hr_utility.set_location('Entering:'||l_proc, 5);
208   --
209   l_api_updating := hr_sft_shd.api_updating
210     (p_source_form_template_id      => p_source_form_template_id
211     ,p_object_version_number        => p_object_version_number
212     );
213   hr_utility.set_location(l_proc,20);
214   --
215   -- Only proceed with SQL validation if absolutely necessary
216   --
217   if (  (   l_api_updating
218         and (  nvl(hr_sft_shd.g_old_rec.form_template_id_from,hr_api.g_number) <>
219                nvl(p_form_template_id_from,hr_api.g_number)
220             or nvl(hr_sft_shd.g_old_rec.form_template_id_to,hr_api.g_number) <>
221                nvl(p_form_template_id_to,hr_api.g_number)))
222      or (NOT l_api_updating)) then
223     --
224     hr_utility.set_location(l_proc,30);
225     --
226     -- From and to templates must not be equal
227     --
228     if nvl(p_form_template_id_from,hr_api.g_number) = nvl(p_form_template_id_to,hr_api.g_number) then
229       fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
230       fnd_message.set_token('PROCEDURE', l_proc);
231       fnd_message.set_token('STEP','10');
232       fnd_message.raise_error;
233     end if;
234     --
235     -- If both templates are specified they must reference the same form
236     --
237     if p_form_template_id_from is not null and p_form_template_id_to is not null then
238       --
239       open csr_form_template(p_form_template_id_from);
240       fetch csr_form_template into l_from_application_id, l_from_form_id;
241       if csr_form_template%notfound then
242         close csr_form_template;
243         fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
244         fnd_message.set_token('PROCEDURE', l_proc);
245         fnd_message.set_token('STEP','20');
246         fnd_message.raise_error;
247       end if;
248       close csr_form_template;
249       --
250       open csr_form_template(p_form_template_id_to);
251       fetch csr_form_template into l_to_application_id, l_to_form_id;
252       if csr_form_template%notfound then
253         close csr_form_template;
254         fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
255         fnd_message.set_token('PROCEDURE', l_proc);
256         fnd_message.set_token('STEP','30');
257         fnd_message.raise_error;
258       end if;
259       close csr_form_template;
260       --
261       if   nvl(l_from_application_id,hr_api.g_number) <> nvl(l_to_application_id,hr_api.g_number)
262         or nvl(l_from_form_id,hr_api.g_number) <> nvl(l_to_form_id,hr_api.g_number) then
263         fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
264         fnd_message.set_token('PROCEDURE', l_proc);
265         fnd_message.set_token('STEP','40');
266         fnd_message.raise_error;
267       end if;
268       --
269     end if;
270     --
271   end if;
272   --
273   hr_utility.set_location(' Leaving:'||l_proc, 10);
274 End chk_form_templates;
275 --
276 -- ----------------------------------------------------------------------------
277 -- |------------------------------< chk_delete >------------------------------|
278 -- ----------------------------------------------------------------------------
279 Procedure chk_delete
280   (p_rec                          in hr_sft_shd.g_rec_type
281   ) is
282 --
283   l_proc  varchar2(72) := g_package||'chk_delete';
284 --
285 Begin
286   hr_utility.set_location('Entering:'||l_proc, 5);
287   --
288   -- No additional validation required
289   --
290   null;
291   --
292   hr_utility.set_location(' Leaving:'||l_proc, 10);
293 End chk_delete;
294 --
295 -- ----------------------------------------------------------------------------
296 -- |---------------------------< insert_validate >----------------------------|
297 -- ----------------------------------------------------------------------------
298 Procedure insert_validate
299   (p_rec                          in hr_sft_shd.g_rec_type
300   ) is
301 --
302   l_proc  varchar2(72) := g_package||'insert_validate';
303 --
304 Begin
305   hr_utility.set_location('Entering:'||l_proc, 5);
306   --
307   -- Call all supporting business operations
308   -- No business group context.  HR_STANDARD_LOOKUPS used for validation.
309   --
310   chk_form_template_id_from
311     (p_source_form_template_id      => p_rec.source_form_template_id
312     ,p_form_template_id_from        => p_rec.form_template_id_from
313     );
314   --
315   chk_form_template_id_to
316     (p_source_form_template_id      => p_rec.source_form_template_id
317     ,p_form_template_id_to          => p_rec.form_template_id_to
318     );
319   --
320   chk_form_templates
321     (p_source_form_template_id      => p_rec.source_form_template_id
322     ,p_object_version_number        => p_rec.object_version_number
323     ,p_form_template_id_from        => p_rec.form_template_id_from
324     ,p_form_template_id_to          => p_rec.form_template_id_to
325     );
326   --
327   hr_utility.set_location(' Leaving:'||l_proc, 10);
328 End insert_validate;
329 --
330 -- ----------------------------------------------------------------------------
331 -- |---------------------------< update_validate >----------------------------|
332 -- ----------------------------------------------------------------------------
333 Procedure update_validate
334   (p_rec                          in hr_sft_shd.g_rec_type
335   ) is
336 --
337   l_proc  varchar2(72) := g_package||'update_validate';
338 --
339 Begin
340   hr_utility.set_location('Entering:'||l_proc, 5);
341   --
342   -- Call all supporting business operations
343   -- No business group context.  HR_STANDARD_LOOKUPS used for validation.
344   --
345   chk_non_updateable_args
346     (p_rec                          => p_rec
347     );
348   --
349   chk_form_template_id_from
350     (p_source_form_template_id      => p_rec.source_form_template_id
351     ,p_form_template_id_from        => p_rec.form_template_id_from
352     );
353   --
354   chk_form_template_id_to
355     (p_source_form_template_id      => p_rec.source_form_template_id
356     ,p_form_template_id_to          => p_rec.form_template_id_to
357     );
358   --
359   chk_form_templates
360     (p_source_form_template_id      => p_rec.source_form_template_id
361     ,p_object_version_number        => p_rec.object_version_number
362     ,p_form_template_id_from        => p_rec.form_template_id_from
363     ,p_form_template_id_to          => p_rec.form_template_id_to
364     );
365   --
366   hr_utility.set_location(' Leaving:'||l_proc, 10);
367 End update_validate;
368 --
369 -- ----------------------------------------------------------------------------
370 -- |---------------------------< delete_validate >----------------------------|
371 -- ----------------------------------------------------------------------------
372 Procedure delete_validate
373   (p_rec                          in hr_sft_shd.g_rec_type
374   ) is
375 --
376   l_proc  varchar2(72) := g_package||'delete_validate';
377 --
378 Begin
379   hr_utility.set_location('Entering:'||l_proc, 5);
380   --
381   -- Call all supporting business operations
382   --
383   chk_delete
384     (p_rec                          => p_rec
385     );
386   --
387   hr_utility.set_location(' Leaving:'||l_proc, 10);
388 End delete_validate;
389 --
390 end hr_sft_bus;