DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_ATC_BUS

Source


4 -- ----------------------------------------------------------------------------
1 Package Body hxc_atc_bus as
2 /* $Header: hxcatcrhi.pkb 120.2 2005/09/23 08:06:56 sechandr noship $ */
3 --
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hxc_atc_bus.';  -- Global package name
9 g_debug	   boolean	:= hr_utility.debug_enabled;
10 --
11 -- The following two global variables are only to be
12 -- used by the return_legislation_code function.
13 --
14 g_legislation_code            varchar2(150)  default null;
15 g_alias_type_component_id     number         default null;
16 --
17 --  ---------------------------------------------------------------------------
18 --  |----------------------< set_security_group_id >--------------------------|
19 --  ---------------------------------------------------------------------------
20 --
21 Procedure set_security_group_id
22   (p_alias_type_component_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       from per_business_groups pbg
31          , hxc_alias_type_components atc
32      where atc.alias_type_component_id = p_alias_type_component_id;
33   --
34   -- Declare local variables
35   --
36   l_security_group_id number;
37   l_proc              varchar2(72);
38   --
39 begin
40   --
44 	hr_utility.set_location('Entering:'|| l_proc, 10);
41   g_debug :=hr_utility.debug_enabled;
42   if g_debug then
43 	l_proc  :=  g_package||'set_security_group_id';
45   end if;
46   --
47   -- Ensure that all the mandatory parameter are not null
48   --
49   hr_api.mandatory_arg_error
50     (p_api_name           => l_proc
51     ,p_argument           => 'alias_type_component_id'
52     ,p_argument_value     => p_alias_type_component_id
53     );
54   --
55   open csr_sec_grp;
56   fetch csr_sec_grp into l_security_group_id;
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,'ALIAS_TYPE_COMPONENT_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   end if;
79   --
80   if g_debug then
81 	hr_utility.set_location(' Leaving:'|| l_proc, 20);
82   end if;
83   --
84 end set_security_group_id;
85 --
86 --  ---------------------------------------------------------------------------
87 --  |---------------------< return_legislation_code >-------------------------|
88 --  ---------------------------------------------------------------------------
89 --
90 Function return_legislation_code
91   (p_alias_type_component_id              in     number
92   )
93   Return Varchar2 Is
94   --
95   -- Declare cursor
96   --
97   cursor csr_leg_code is
98     select pbg.legislation_code
99       from per_business_groups     pbg
100          , hxc_alias_type_components atc
101      where atc.alias_type_component_id = p_alias_type_component_id;
102   --
103   -- Declare local variables
104   --
105   l_legislation_code  varchar2(150);
106   l_proc              varchar2(72);
107   --
108 Begin
109   --
110   g_debug:=hr_utility.debug_enabled;
111   if g_debug then
112 	  l_proc:=  g_package||'return_legislation_code';
113 	  hr_utility.set_location('Entering:'|| l_proc, 10);
114   end if;
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           => 'alias_type_component_id'
121     ,p_argument_value     => p_alias_type_component_id
122     );
123   --
124   if ( nvl(hxc_atc_bus.g_alias_type_component_id, hr_api.g_number)
125        = p_alias_type_component_id) then
126     --
127     -- The legislation code has already been found with a previous
128     -- call to this function. Just return the value in the global
129     -- variable.
130     --
131     l_legislation_code := hxc_atc_bus.g_legislation_code;
132     if g_debug then
133 	hr_utility.set_location(l_proc, 20);
134     end if;
135   else
136     --
137     -- The ID is different to the last call to this function
138     -- or this is the first call to this function.
139     --
140     open csr_leg_code;
141     fetch csr_leg_code into l_legislation_code;
142     --
143     if csr_leg_code%notfound then
144       --
145       -- The primary key is invalid therefore we must error
146       --
147       close csr_leg_code;
148       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
149       fnd_message.raise_error;
150     end if;
151     if g_debug then
152 	hr_utility.set_location(l_proc,30);
153     end if;
154     --
155     -- Set the global variables so the values are
156     -- available for the next call to this function.
157     --
158     close csr_leg_code;
159     hxc_atc_bus.g_alias_type_component_id     := p_alias_type_component_id;
160     hxc_atc_bus.g_legislation_code  := l_legislation_code;
161   end if;
162   if g_debug then
163 	hr_utility.set_location(' Leaving:'|| l_proc, 40);
164   end if;
165   return l_legislation_code;
166 end return_legislation_code;
167 --
168 -- ----------------------------------------------------------------------------
169 -- |-----------------------< chk_non_updateable_args >------------------------|
170 -- ----------------------------------------------------------------------------
171 -- {Start Of Comments}
172 --
173 -- Description:
174 --   This procedure is used to ensure that non updateable attributes have
175 --   not been updated. If an attribute has been updated an error is generated.
176 --
177 -- Pre Conditions:
178 --   g_old_rec has been populated with details of the values currently in
179 --   the database.
180 --
181 -- In Arguments:
182 --   p_rec has been populated with the updated values the user would like the
183 --   record set to.
184 --
185 -- Post Success:
186 --   Processing continues if all the non updateable attributes have not
187 --   changed.
188 --
189 -- Post Failure:
190 --   An application error is raised if any of the non updatable attributes
191 --   have been altered.
192 --
193 -- {End Of Comments}
194 -- ----------------------------------------------------------------------------
195 Procedure chk_non_updateable_args
196   (p_rec in hxc_atc_shd.g_rec_type
197   ) IS
198 --
199   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
200 --
201 Begin
202   --
203   -- Only proceed with the validation if a row exists for the current
204   -- record in the HR Schema.
205   --
206   IF NOT hxc_atc_shd.api_updating
207       (p_alias_type_component_id           => p_rec.alias_type_component_id
208       ,p_object_version_number             => p_rec.object_version_number
209       ) THEN
210      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
211      fnd_message.set_token('PROCEDURE ', l_proc);
212      fnd_message.set_token('STEP ', '5');
213      fnd_message.raise_error;
214   END IF;
215   --
216 End chk_non_updateable_args;
217 --
218 -------------------------------------------------------------------------------
219 -- |-------------------------<chk_dup_comb>---------------------------------------|
220 -------------------------------------------------------------------------------
221 Procedure chk_dup_comb (p_alias_type_id hxc_alias_type_components.alias_type_id%TYPE,
222 		p_alias_type_component_id hxc_alias_type_components.alias_type_component_id%TYPE,
223 			p_mapping_component_id hxc_alias_type_components.mapping_component_id%TYPE) is
224 Cursor csr_chk_atc IS
225 select 'error'
226 from sys.dual
227 where exists(
228 	     select 'x'
229 	     from hxc_alias_type_components hac
230 	     where hac.alias_type_id = p_alias_type_id AND
231 		   hac.mapping_component_id  = p_mapping_component_id AND
232 		   hac.alias_type_component_id <> nvl(p_alias_type_component_id,-999)
233 	     );
234 
235 l_error varchar2(5) := NULL;
236 begin
237 
238 if g_debug then
239 	hr_utility.trace('Entering chk_dup_atc');
240 end if;
241 --
242    OPEN csr_chk_atc;
243    FETCH csr_chk_atc into l_error;
244    close csr_chk_atc;
245 
246 
247 IF l_error IS NOT NULL
248 THEN
249 --
250       hr_utility.set_message(809,'HXC_ALT_MAP_DUP');-- 'A mapping component can have only one component name associated with it');
251       hr_utility.raise_error;
252 --
253 END IF;
254 l_error := '';
255 if g_debug then
256 	hr_utility.trace('Leaving chk_dup_atc');
257 end if;
258 
259 end chk_dup_comb;
260 
261 -------------------------------------------------------------------------------
262 -- |-------------------------<chk_dup_comb_ins>---------------------------------------|
263 -------------------------------------------------------------------------------
264 Procedure chk_dup_comb_ins (p_alias_type_id hxc_alias_type_components.alias_type_id%TYPE,
265 			p_mapping_component_id hxc_alias_type_components.mapping_component_id%TYPE) is
266 Cursor csr_chk_atc IS
267 select 'error'
268 from sys.dual
269 where exists(
270 	     select 'x'
271 	     from hxc_alias_type_components hac
272 	     where hac.alias_type_id = p_alias_type_id AND
273 		   hac.mapping_component_id  = p_mapping_component_id
274 	     );
275 
276 l_error varchar2(5) := NULL;
277 begin
278 
279 if g_debug then
280 	hr_utility.trace('Entering chk_dup_atc');
281 end if;
282 --
283    OPEN csr_chk_atc;
284    FETCH csr_chk_atc into l_error;
285    close csr_chk_atc;
286 
287 
288 IF l_error IS NOT NULL
289 THEN
290 --
291       hr_utility.set_message(809,'HXC_ALT_MAP_DUP');-- 'A mapping component can have only one component name associated with it');
292       hr_utility.raise_error;
293 --
294 END IF;
295 l_error := '';
296 if g_debug then
297 	hr_utility.trace('Leaving chk_dup_atc');
298 end if;
299 
300 end chk_dup_comb_ins;
301 -- ----------------------------------------------------------------------------
302 -- |---------------------------< insert_validate >----------------------------|
303 -- ----------------------------------------------------------------------------
304 Procedure insert_validate
305   (p_rec                          in hxc_atc_shd.g_rec_type
306   ) is
307 --
308   l_proc  varchar2(72);
309 --
310 Begin
311   g_debug:=hr_utility.debug_enabled;
312   if g_debug then
313 	l_proc := g_package||'insert_validate';
314 	hr_utility.set_location('Entering:'||l_proc, 5);
315   end if;
316   --
317   -- Call all supporting business operations
318   -- Validate Dependent Attributes
319   --
320   --
321   chk_dup_comb (p_rec.alias_type_id,
322 		p_rec.alias_type_component_id,
323 		p_rec.mapping_component_id
324 		);
325   if g_debug then
326 	hr_utility.set_location(' Leaving:'||l_proc, 10);
327   end if;
328 End insert_validate;
329 --
330 -- ----------------------------------------------------------------------------
331 -- |---------------------------< update_validate >----------------------------|
332 -- ----------------------------------------------------------------------------
333 Procedure update_validate
334   (p_rec                          in hxc_atc_shd.g_rec_type
335   ) is
336 --
337   l_proc  varchar2(72);
338 --
339 Begin
340   g_debug:=hr_utility.debug_enabled;
341   if g_debug then
342 	 l_proc:= g_package||'update_validate';
343 	 hr_utility.set_location('Entering:'||l_proc, 5);
344   end if;
345   --
346   -- Call all supporting business operations
347   --
348   -- Validate Dependent Attributes
349   --
350   chk_non_updateable_args
351     (p_rec              => p_rec
352     );
353   --
354   --
355   chk_dup_comb (p_rec.alias_type_id,
356 		p_rec.alias_type_component_id,
357 		p_rec.mapping_component_id
358 		);
359   if g_debug then
360 	hr_utility.set_location(' Leaving:'||l_proc, 10);
361   end if;
362 End update_validate;
363 
364 -------------------------------------------------------------------------------
365 -- |-------------------------<chk_fk_realation>---------------------------------------|
366 -------------------------------------------------------------------------------
367 
368 -- ----------------------------------------------------------------------------
369 -- |---------------------------< delete_validate >----------------------------|
370 -- ----------------------------------------------------------------------------
371 Procedure delete_validate
372   (p_rec                          in hxc_atc_shd.g_rec_type
373   ) is
374 --
375   l_proc  varchar2(72);
376 --
377 Begin
378   g_debug:=hr_utility.debug_enabled;
379   if g_debug then
380 	l_proc := g_package||'delete_validate';
381 	hr_utility.set_location('Entering:'||l_proc, 5);
382   end if;
383   --
384   -- Call all supporting business operations
385   --
386   if g_debug then
387 	hr_utility.set_location(' Leaving:'||l_proc, 10);
388   end if;
389 End delete_validate;
390 --
391 end hxc_atc_bus;