DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_CTT_BUS

Source


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