DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_CHA_BUS

Source


1 Package Body ota_cha_bus as
2 /* $Header: otcharhi.pkb 120.3 2006/03/06 02:27 rdola noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ota_cha_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_chat_id                     number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_chat_id                              in number
22   ,p_associated_column1                   in varchar2 default null
23   ) is
24   --
25   -- Declare cursor
26   --
27   cursor csr_sec_grp is
28     select pbg.security_group_id,
29            pbg.legislation_code
30       from per_business_groups_perf pbg
31          , ota_chats_b cha
32      where cha.chat_id = p_chat_id
33        and pbg.business_group_id = cha.business_group_id;
34   --
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           => 'chat_id'
50     ,p_argument_value     => p_chat_id
51     );
52   --
53   open csr_sec_grp;
54   fetch csr_sec_grp into l_security_group_id
55                        , l_legislation_code;
56   --
57   if csr_sec_grp%notfound then
58      --
59      close csr_sec_grp;
60      --
61      -- The primary key is invalid therefore we must error
62      --
63      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
64      hr_multi_message.add
65        (p_associated_column1
66         => nvl(p_associated_column1,'CHAT_ID')
67        );
68      --
69   else
70     close csr_sec_grp;
71     --
72     -- Set the security_group_id in CLIENT_INFO
73     --
74     hr_api.set_security_group_id
75       (p_security_group_id => l_security_group_id
76       );
77     --
78     -- Set the sessions legislation context in HR_SESSION_DATA
79     --
80     hr_api.set_legislation_context(l_legislation_code);
81   end if;
82   --
83   hr_utility.set_location(' Leaving:'|| l_proc, 20);
84   --
85 end set_security_group_id;
86 --
87 --  ---------------------------------------------------------------------------
88 --  |---------------------< return_legislation_code >-------------------------|
89 --  ---------------------------------------------------------------------------
90 --
91 Function return_legislation_code
92   (p_chat_id                              in     number
93   )
94   Return Varchar2 Is
95   --
96   -- Declare cursor
97   --
98  cursor csr_leg_code is
99     select pbg.legislation_code
100       from per_business_groups_perf pbg
101          , ota_chats_b cha
102      where cha.chat_id = p_chat_id
103        and pbg.business_group_id = cha.business_group_id;
104   --
105   -- Declare local variables
106   --
107   l_legislation_code  varchar2(150);
108   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
109   --
110 Begin
111   --
112   hr_utility.set_location('Entering:'|| l_proc, 10);
113   --
114   -- Ensure that all the mandatory parameter are not null
115   --
116   hr_api.mandatory_arg_error
117     (p_api_name           => l_proc
118     ,p_argument           => 'chat_id'
119     ,p_argument_value     => p_chat_id
120     );
121   --
122   if ( nvl(ota_cha_bus.g_chat_id, hr_api.g_number)
123        = p_chat_id) then
124     --
125     -- The legislation code has already been found with a previous
126     -- call to this function. Just return the value in the global
127     -- variable.
128     --
129     l_legislation_code := ota_cha_bus.g_legislation_code;
130     hr_utility.set_location(l_proc, 20);
131   else
132     --
133     -- The ID is different to the last call to this function
134     -- or this is the first call to this function.
135     --
136     open csr_leg_code;
137     fetch csr_leg_code into l_legislation_code;
138     --
139     if csr_leg_code%notfound then
140       --
141       -- The primary key is invalid therefore we must error
142       --
143       close csr_leg_code;
144       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
145       fnd_message.raise_error;
146     end if;
147     hr_utility.set_location(l_proc,30);
148     --
149     -- Set the global variables so the values are
150     -- available for the next call to this function.
151     --
152     close csr_leg_code;
153     ota_cha_bus.g_chat_id                     := p_chat_id;
154     ota_cha_bus.g_legislation_code  := l_legislation_code;
155   end if;
156   hr_utility.set_location(' Leaving:'|| l_proc, 40);
157   return l_legislation_code;
158 end return_legislation_code;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |-----------------------< chk_non_updateable_args >------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 --   This procedure is used to ensure that non updateable attributes have
167 --   not been updated. If an attribute has been updated an error is generated.
168 --
169 -- Pre Conditions:
170 --   g_old_rec has been populated with details of the values currently in
171 --   the database.
172 --
173 -- In Arguments:
174 --   p_rec has been populated with the updated values the user would like the
175 --   record set to.
176 --
177 -- Post Success:
178 --   Processing continues if all the non updateable attributes have not
179 --   changed.
180 --
181 -- Post Failure:
182 --   An application error is raised if any of the non updatable attributes
183 --   have been altered.
184 --
185 -- {End Of Comments}
186 -- ----------------------------------------------------------------------------
187 Procedure chk_non_updateable_args
188   (p_effective_date               in date
189   ,p_rec in ota_cha_shd.g_rec_type
190   ) IS
191 --
192   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
193 --
194 Begin
195   --
196   -- Only proceed with the validation if a row exists for the current
197   -- record in the HR Schema.
198   --
199   IF NOT ota_cha_shd.api_updating
200       (p_chat_id                           => p_rec.chat_id
201       ,p_object_version_number             => p_rec.object_version_number
202       ) THEN
203      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
204      fnd_message.set_token('PROCEDURE ', l_proc);
205      fnd_message.set_token('STEP ', '5');
206      fnd_message.raise_error;
207   END IF;
208   --
209   -- EDIT_HERE: Add checks to ensure non-updateable args have
210   --            not been updated.
211   --
212 End chk_non_updateable_args;
213 --
214 --
215 -- BUG#4654544
216 -- ----------------------------------------------------------------------------
217 -- |--------------------------< chk_category_start_end_dates  >----------------|
218 -- ----------------------------------------------------------------------------
219 --
220 -- PUBLIC
221 -- Description:
222 --   Validates the startdate and enddate with respect to category dates.
223 --
224 Procedure chk_category_start_end_dates
225   (p_chat_id            in            number
226   ,p_start_date                   in            date
227   ,p_end_date                     in            date
228   )  is
229   --
230   -- Declare cursors and local variables
231   --
232   -- Cursor to get value if parent category is already exits in child hierarchy of base category
233 
234   CURSOR csr_cat_start_end_date is
235     select
236           ctu.start_date_active,
237           ctu.end_date_active
238         from
239           ota_category_usages ctu,
240           ota_chat_obj_inclusions coi
241         where
242           ctu.category_usage_id = coi.object_id
243           and coi.primary_flag= 'Y'
244           and coi.chat_id = p_chat_id;
245  --
246  -- Variables for API Boolean parameters
247  --
248   l_proc                 varchar2(72) := g_package ||'chk_category_start_end_dates';
249   l_cat_start_date        date;
250   l_cat_end_date          date;
251 
252 Begin
253   hr_utility.set_location(' Entering:' || l_proc,10);
254   --
255   IF hr_multi_message.no_exclusive_error
256           (p_check_column1   => 'OTA_CHATS_B.START_DATE_ACTIVE'
257           ,p_check_column2   => 'OTA_CHATS_B.END_DATE_ACTIVE'
258           ,p_associated_column1   => 'OTA_CHATS_B.START_DATE_ACTIVE'
259           ,p_associated_column2   => 'OTA_CHATS_B.END_DATE_ACTIVE'
260         ) THEN
261      --
262      OPEN csr_cat_start_end_date;
263      FETCH csr_cat_start_end_date into l_cat_start_date, l_cat_end_date;
264 
265      IF csr_cat_start_end_date%FOUND  THEN
266         CLOSE csr_cat_start_end_date;
267 
268         IF ( l_cat_start_date > p_start_date
269              or nvl(l_cat_end_date,hr_api.g_eot) < nvl(p_end_date,hr_api.g_eot)
270            ) THEN
271           --
272           fnd_message.set_name      ( 'OTA','OTA_443833_CHT_OUT_OF_CAT_DATE');
273 	  fnd_message.raise_error;
274           --
275         End IF;
276      ELSE
277          CLOSE csr_cat_start_end_date;
278 
279      End IF;
280   End IF;
281   --
282   hr_utility.set_location(' Leaving:' || l_proc,10);
283 Exception
284   when app_exception.application_exception then
285     IF hr_multi_message.exception_add
286                  (p_associated_column1   => 'OTA_CHATS_B.START_DATE_ACTIVE'
287                  ,p_associated_column2   => 'OTA_CHATS_B.END_DATE_ACTIVE'
288                  ) THEN
289        hr_utility.set_location(' Leaving:'|| l_proc,20);
290        raise;
291     END IF;
292 
293     hr_utility.set_location(' Leaving:'|| l_proc,30);
294   --
295 End chk_category_start_end_dates;
296 --
297 -- ----------------------------------------------------------------------------
298 -- -------------------------< check_timezone >-----------------------------
299 -- ----------------------------------------------------------------------------
300 --
301 -- Procedure to check timezone of a chat
302 --
303 --
304 PROCEDURE check_timezone(p_timezone IN VARCHAR2)
305 IS
306    l_timezone_id NUMBER := ota_timezone_util.get_timezone_id(p_timezone);
307 BEGIN
308    IF l_timezone_id IS NULL THEN
309       fnd_message.set_name('OTA','OTA_443982_TIMEZONE_ERROR');
310       fnd_message.set_token('OBJECT_TYPE',ota_utility.get_lookup_meaning('OTA_OBJECT_TYPE','CHT',810));
311       fnd_message.raise_error;
312    END IF;
313 END check_timezone;
314 --
315 --
316 -- ----------------------------------------------------------------------------
317 -- |---------------------------< insert_validate >----------------------------|
318 -- ----------------------------------------------------------------------------
319 Procedure insert_validate
320   (p_effective_date               in date
321   ,p_rec                          in ota_cha_shd.g_rec_type
322   ) is
323 --
324   l_proc  varchar2(72) := g_package||'insert_validate';
325 --
326 Begin
327   hr_utility.set_location('Entering:'||l_proc, 5);
328   --
329   -- Call all supporting business operations
330   --
331   hr_api.validate_bus_grp_id
332     (p_business_group_id => p_rec.business_group_id
333     ,p_associated_column1 => ota_cha_shd.g_tab_nam
334                               || '.BUSINESS_GROUP_ID');
335   --
336   -- After validating the set of important attributes,
337   -- if Multiple Message detection is enabled and at least
338   -- one error has been found then abort further validation.
339   --
340   hr_multi_message.end_validation_set;
341   --
342   -- Validate Dependent Attributes
343   --
344   --
345   check_timezone(p_rec.timezone_code);
346   hr_utility.set_location(' Leaving:'||l_proc, 10);
347 End insert_validate;
348 --
349 -- ----------------------------------------------------------------------------
350 -- |---------------------------< update_validate >----------------------------|
351 -- ----------------------------------------------------------------------------
352 Procedure update_validate
353   (p_effective_date               in date
354   ,p_rec                          in ota_cha_shd.g_rec_type
355   ) is
356 --
357   l_proc  varchar2(72) := g_package||'update_validate';
358 --
359 Begin
360   hr_utility.set_location('Entering:'||l_proc, 5);
361   --
362   -- Call all supporting business operations
363   --
364   hr_api.validate_bus_grp_id
365     (p_business_group_id => p_rec.business_group_id
366     ,p_associated_column1 => ota_cha_shd.g_tab_nam
367                               || '.BUSINESS_GROUP_ID');
368   --
369   -- After validating the set of important attributes,
370   -- if Multiple Message detection is enabled and at least
371   -- one error has been found then abort further validation.
372   --
373   hr_multi_message.end_validation_set;
374   --
375   -- Validate Dependent Attributes
376   --
377   chk_non_updateable_args
378     (p_effective_date              => p_effective_date
379       ,p_rec              => p_rec
380     );
381   --
382   --
383   chk_category_start_end_dates(p_chat_id =>p_rec.chat_id,p_start_date =>p_rec.start_date_active,p_end_date =>p_rec.end_date_active );
384 
385   IF p_rec.timezone_code <> hr_api.g_varchar2 THEN
386      check_timezone(p_rec.timezone_code);
387   END IF;
388 --
389  --
390   hr_utility.set_location(' Leaving:'||l_proc, 10);
391 End update_validate;
392 --
393 -- ----------------------------------------------------------------------------
394 -- |---------------------------< delete_validate >----------------------------|
395 -- ----------------------------------------------------------------------------
396 Procedure delete_validate
397   (p_rec                          in ota_cha_shd.g_rec_type
398   ) is
399 --
400   l_proc  varchar2(72) := g_package||'delete_validate';
401 --
402 Begin
403   hr_utility.set_location('Entering:'||l_proc, 5);
404   --
405   -- Call all supporting business operations
406   --
407   hr_utility.set_location(' Leaving:'||l_proc, 10);
408 End delete_validate;
409 --
410 end ota_cha_bus;