DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_RTC_BUS

Source


1 Package Body hxc_rtc_bus as
2 /* $Header: hxcrtcrhi.pkb 120.2 2005/09/23 08:51:07 nissharm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hxc_rtc_bus.';  -- Global package name
9 
10 g_debug boolean := hr_utility.debug_enabled;
11 --
12 -- The following two global variables are only to be
13 -- used by the return_legislation_code function.
14 --
15 g_legislation_code            varchar2(150)  default null;
16 g_retrieval_rule_comp_id      number         default null;
17 --
18 --  ---------------------------------------------------------------------------
19 --  |----------------------< set_security_group_id >--------------------------|
20 --  ---------------------------------------------------------------------------
21 --
22 Procedure set_security_group_id
23   (p_retrieval_rule_comp_id               in number
24   ) is
25   --
26   -- Declare cursor
27   --
28   -- EDIT_HERE  In the following cursor statement add join(s) between
29   -- hxc_retrieval_rule_comps and PER_BUSINESS_GROUPS
30   -- so that the security_group_id for
31   -- the current business group context can be derived.
32   -- Remove this comment when the edit has been completed.
33   cursor csr_sec_grp is
34     select pbg.security_group_id
35       from per_business_groups pbg
36          , hxc_retrieval_rule_comps rtc
37       --   , EDIT_HERE table_name(s) 333
38      where rtc.retrieval_rule_comp_id = p_retrieval_rule_comp_id;
39       -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
40   --
41   -- Declare local variables
42   --
43   l_security_group_id number;
44   l_proc              varchar2(72);
45   --
46 begin
47   g_debug := hr_utility.debug_enabled;
48 
49   --
50   if g_debug then
51   	l_proc  :=  g_package||'set_security_group_id';
52   	hr_utility.set_location('Entering:'|| l_proc, 10);
53   end if;
54   --
55   -- Ensure that all the mandatory parameter are not null
56   --
57   hr_api.mandatory_arg_error
58     (p_api_name           => l_proc
59     ,p_argument           => 'retrieval_rule_comp_id'
60     ,p_argument_value     => p_retrieval_rule_comp_id
61     );
62   --
63   open csr_sec_grp;
64   fetch csr_sec_grp into l_security_group_id;
65   --
66   if csr_sec_grp%notfound then
67      --
68      close csr_sec_grp;
69      --
70      -- The primary key is invalid therefore we must error
71      --
72      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
73      fnd_message.raise_error;
74      --
75   end if;
76   close csr_sec_grp;
77   --
78   -- Set the security_group_id in CLIENT_INFO
79   --
80   hr_api.set_security_group_id
81     (p_security_group_id => l_security_group_id
82     );
83   --
84   if g_debug then
85   	hr_utility.set_location(' Leaving:'|| l_proc, 20);
86   end if;
87   --
88 end set_security_group_id;
89 --
90 --  ---------------------------------------------------------------------------
91 --  |---------------------< return_legislation_code >-------------------------|
92 --  ---------------------------------------------------------------------------
93 --
94 Function return_legislation_code
95   (p_retrieval_rule_comp_id               in     number
96   )
97   Return Varchar2 Is
98   --
99   -- Declare cursor
100   --
101   -- EDIT_HERE  In the following cursor statement add join(s) between
102   -- hxc_retrieval_rule_comps and PER_BUSINESS_GROUPS
103   -- so that the legislation_code for
104   -- the current business group context can be derived.
105   -- Remove this comment when the edit has been completed.
106   cursor csr_leg_code is
107     select pbg.legislation_code
108       from per_business_groups     pbg
109          , hxc_retrieval_rule_comps rtc
110       --   , EDIT_HERE table_name(s) 333
111      where rtc.retrieval_rule_comp_id = p_retrieval_rule_comp_id;
112       -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
113   --
114   -- Declare local variables
115   --
116   l_legislation_code  varchar2(150);
117   l_proc              varchar2(72);
118   --
119 Begin
120   g_debug := hr_utility.debug_enabled;
121 
122   --
123   if g_debug then
124   	l_proc :=  g_package||'return_legislation_code';
128   -- Ensure that all the mandatory parameter are not null
125   	hr_utility.set_location('Entering:'|| l_proc, 10);
126   end if;
127   --
129   --
130   hr_api.mandatory_arg_error
131     (p_api_name           => l_proc
132     ,p_argument           => 'retrieval_rule_comp_id'
133     ,p_argument_value     => p_retrieval_rule_comp_id
134     );
135   --
136   if ( nvl(hxc_rtc_bus.g_retrieval_rule_comp_id, hr_api.g_number)
137        = p_retrieval_rule_comp_id) then
138     --
139     -- The legislation code has already been found with a previous
140     -- call to this function. Just return the value in the global
141     -- variable.
142     --
143     l_legislation_code := hxc_rtc_bus.g_legislation_code;
144     if g_debug then
145     	hr_utility.set_location(l_proc, 20);
146     end if;
147   else
148     --
149     -- The ID is different to the last call to this function
150     -- or this is the first call to this function.
151     --
152     open csr_leg_code;
153     fetch csr_leg_code into l_legislation_code;
154     --
155     if csr_leg_code%notfound then
156       --
157       -- The primary key is invalid therefore we must error
158       --
159       close csr_leg_code;
160       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
161       fnd_message.raise_error;
162     end if;
163     if g_debug then
164     	hr_utility.set_location(l_proc,30);
165     end if;
166     --
167     -- Set the global variables so the values are
168     -- available for the next call to this function.
169     --
170     close csr_leg_code;
171     hxc_rtc_bus.g_retrieval_rule_comp_id:= p_retrieval_rule_comp_id;
172     hxc_rtc_bus.g_legislation_code  := l_legislation_code;
173   end if;
174   if g_debug then
175   	hr_utility.set_location(' Leaving:'|| l_proc, 40);
176   end if;
177   return l_legislation_code;
178 end return_legislation_code;
179 --
180 -- ----------------------------------------------------------------------------
181 -- |-----------------------< chk_non_updateable_args >------------------------|
182 -- ----------------------------------------------------------------------------
183 -- {Start Of Comments}
184 --
185 -- Description:
186 --   This procedure is used to ensure that non updateable attributes have
187 --   not been updated. If an attribute has been updated an error is generated.
188 --
189 -- Pre Conditions:
190 --   g_old_rec has been populated with details of the values currently in
191 --   the database.
192 --
193 -- In Arguments:
194 --   p_rec has been populated with the updated values the user would like the
195 --   record set to.
196 --
197 -- Post Success:
198 --   Processing continues if all the non updateable attributes have not
199 --   changed.
200 --
201 -- Post Failure:
202 --   An application error is raised if any of the non updatable attributes
203 --   have been altered.
204 --
205 -- {End Of Comments}
206 -- ----------------------------------------------------------------------------
207 Procedure chk_non_updateable_args
208   (p_effective_date               in date
209   ,p_rec in hxc_rtc_shd.g_rec_type
210   ) IS
211 --
212   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
213   l_error    EXCEPTION;
214   l_argument varchar2(30);
215 --
216 Begin
217   --
218   -- Only proceed with the validation if a row exists for the current
219   -- record in the HR Schema.
220   --
221   IF NOT hxc_rtc_shd.api_updating
222       (p_retrieval_rule_comp_id               => p_rec.retrieval_rule_comp_id
223       ,p_object_version_number                => p_rec.object_version_number
224       ) THEN
225      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
226      fnd_message.set_token('PROCEDURE ', l_proc);
227      fnd_message.set_token('STEP ', '5');
228      fnd_message.raise_error;
229   END IF;
230   --
231   -- EDIT_HERE: Add checks to ensure non-updateable args have
232   --            not been updated.
233   --
234   EXCEPTION
235     WHEN l_error THEN
236        hr_api.argument_changed_error
237          (p_api_name => l_proc
238          ,p_argument => l_argument);
239     WHEN OTHERS THEN
240        RAISE;
241 End chk_non_updateable_args;
242 --
243 -- ----------------------------------------------------------------------------
244 -- |-----------------------------< chk_application >--------------------------|
245 -- ----------------------------------------------------------------------------
246 -- {Start Of Comments}
247 --
248 -- Description:
249 -- This procedure ensures that a valid and a unique rule is associated with an
250 -- application i.e.,only one row per application is enterable
251 --
252 -- Pre Conditions:
253 --   None
254 --
255 -- In Arguments:
256 --   retrieval_rule_id
257 --   time_recipient_id
258 --   object_version_number
259 --
260 -- Post Success:
261 --   Processing continues if a rule does not exist for the application
262 --
263 -- Post Failure:
264 --   An application error is raised if a rule already exists for an application
265 --
266 -- {End Of Comments}
267 -- ----------------------------------------------------------------------------
268 Procedure chk_application
269   (
270    p_retrieval_rule_id     in hxc_retrieval_rule_comps.retrieval_rule_id%TYPE,
271    p_time_recipient_id     in hxc_retrieval_rule_comps.time_recipient_id%TYPE,
272    p_object_version_number in hxc_retrieval_rule_comps.object_version_number%TYPE
273   ) IS
274 --
275   l_proc  varchar2(72);
276 --
277 -- cursor to check that not more than one rule is entered per application
278 --
279 CURSOR  csr_chk_application IS
280 SELECT 'error'
281 FROM    sys.dual
282 WHERE EXISTS (
283         SELECT  'x'
284         FROM    hxc_retrieval_rule_comps rtc
285         WHERE   rtc.time_recipient_id = p_time_recipient_id
286         AND     rtc.retrieval_rule_id = p_retrieval_rule_id
287         AND     rtc.object_version_number <> NVL(p_object_version_number, -1) );
288 --
289  l_error varchar2(5) := NULL;
290 --
291 BEGIN
292   g_debug := hr_utility.debug_enabled;
293 
294   if g_debug then
295   	l_proc := g_package||'chk_application';
296   	hr_utility.set_location('Entering:'||l_proc, 5);
297   end if;
298 --
299 -- Raise an error if the rule is not unique
300 --
301   OPEN  csr_chk_application;
302   FETCH csr_chk_application INTO l_error;
303   CLOSE csr_chk_application;
304 --
305 IF l_error IS NOT NULL
306 THEN
307 --
308       hr_utility.set_message(809, 'HXC_0088_RTC_APL_RULE_EXISTS');
309       hr_utility.raise_error;
310 --
311 END IF;
312 --
313   if g_debug then
314   	hr_utility.set_location('Leaving:'||l_proc, 10);
315   end if;
316 --
317 END chk_application;
318 --
319 -- ----------------------------------------------------------------------------
320 -- |---------------------------< insert_validate >----------------------------|
321 -- ----------------------------------------------------------------------------
322 Procedure insert_validate
323   (p_effective_date               in date
324   ,p_rec                          in hxc_rtc_shd.g_rec_type
325   ) is
326 --
327   l_proc  varchar2(72);
328 --
329 Begin
330   g_debug := hr_utility.debug_enabled;
331 
332   if g_debug then
333   	l_proc := g_package||'insert_validate';
334   	hr_utility.set_location('Entering:'||l_proc, 5);
335   	--
336   	-- Call all supporting business operations
337   	--
338   	hr_utility.set_location('Processing:'||l_proc, 10);
339   end if;
340   --
341     chk_application ( p_retrieval_rule_id     => p_rec.retrieval_rule_id,
342                       p_time_recipient_id     => p_rec.time_recipient_id,
343                       p_object_version_number => p_rec.object_version_number );
344   --
345   if g_debug then
346   	hr_utility.set_location(' Leaving:'||l_proc, 10);
347   end if;
348   --
349   -- EDIT_HERE: As this table does not have a mandatory business_group_id
350   -- column, ensure client_info is populated by calling a suitable
351   -- ???_???_bus.set_security_group_id procedure, or add one of the following
352   -- comments:
353   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
354   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
355   --
356   --
357   if g_debug then
358   	hr_utility.set_location(' Leaving:'||l_proc, 10);
359   end if;
360 End insert_validate;
361 --
362 -- ----------------------------------------------------------------------------
363 -- |---------------------------< update_validate >----------------------------|
364 -- ----------------------------------------------------------------------------
365 Procedure update_validate
366   (p_effective_date               in date
367   ,p_rec                          in hxc_rtc_shd.g_rec_type
368   ) is
369 --
370   l_proc  varchar2(72);
371 --
372 Begin
373   g_debug := hr_utility.debug_enabled;
374 
375   if g_debug then
376   	l_proc := g_package||'update_validate';
377   	hr_utility.set_location('Entering:'||l_proc, 5);
378   	--
379   	-- Call all supporting business operations
380   	--
381   	hr_utility.set_location('Processing:'||l_proc, 10);
382   end if;
383   --
384    chk_application ( p_retrieval_rule_id     => p_rec.retrieval_rule_id,
385                      p_time_recipient_id     => p_rec.time_recipient_id,
386                      p_object_version_number => p_rec.object_version_number );
387   --
388   if g_debug then
389   	hr_utility.set_location(' Leaving:'||l_proc, 10);
390   end if;
391   --
392   -- EDIT_HERE: As this table does not have a mandatory business_group_id
393   -- column, ensure client_info is populated by calling a suitable
394   -- ???_???_bus.set_security_group_id procedure, or add one of the following
395   -- comments:
396   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
397   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
398   --
399   chk_non_updateable_args
400     (p_effective_date              => p_effective_date
401       ,p_rec              => p_rec
402     );
403   --
404   --
405   if g_debug then
406   	hr_utility.set_location(' Leaving:'||l_proc, 10);
407   end if;
408 End update_validate;
409 --
410 -- ----------------------------------------------------------------------------
411 -- |---------------------------< delete_validate >----------------------------|
412 -- ----------------------------------------------------------------------------
413 Procedure delete_validate
414   (p_rec                          in hxc_rtc_shd.g_rec_type
415   ) is
416 --
417   l_proc  varchar2(72);
418 --
419 Begin
420   g_debug := hr_utility.debug_enabled;
421 
422   if g_debug then
423   	l_proc := g_package||'delete_validate';
424   	hr_utility.set_location('Entering:'||l_proc, 5);
425   	--
426   	-- Call all supporting business operations
427   	--
428   	hr_utility.set_location(' Leaving:'||l_proc, 10);
429   end if;
430 End delete_validate;
431 --
432 end hxc_rtc_bus;