DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_TKT_BUS

Source


1 Package Body pqh_tkt_bus as
2 /* $Header: pqtktrhi.pkb 115.4 2002/12/12 21:44:06 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pqh_tkt_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_tatigkeit_detail_id         number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_tatigkeit_detail_id                  in number
22   ,p_associated_column1                   in varchar2 default null
23   ) is
24   --
25   -- Declare cursor
26   --
27   -- EDIT_HERE  In the following cursor statement add join(s) between
28   -- pqh_de_tatigkeit_details and PER_BUSINESS_GROUPS
29   -- so that the security_group_id for
30   -- the current business group context can be derived.
31   -- Remove this comment when the edit has been completed.
32   cursor csr_sec_grp is
33     select pbg.security_group_id
34       from per_business_groups pbg
35          , pqh_de_tatigkeit_details tkt
36       --   , EDIT_HERE table_name(s) 333
37      where tkt.tatigkeit_detail_id = p_tatigkeit_detail_id;
38       -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
39   --
40   -- Declare local variables
41   --
42   l_security_group_id number;
43   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
44   --
45 begin
46   --
47   hr_utility.set_location('Entering:'|| l_proc, 10);
48   --
49   -- Ensure that all the mandatory parameter are not null
50   --
51   hr_api.mandatory_arg_error
52     (p_api_name           => l_proc
53     ,p_argument           => 'tatigkeit_detail_id'
54     ,p_argument_value     => p_tatigkeit_detail_id
55     );
56   --
57   open csr_sec_grp;
58   fetch csr_sec_grp into l_security_group_id;
59   --
60   if csr_sec_grp%notfound then
61      --
62      close csr_sec_grp;
63      --
64      -- The primary key is invalid therefore we must error
65      --
66      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
67      hr_multi_message.add
68        (p_associated_column1
69         => nvl(p_associated_column1,'TATIGKEIT_DETAIL_ID')
70        );
71      --
72   else
73     close csr_sec_grp;
74     --
75     -- Set the security_group_id in CLIENT_INFO
76     --
77     hr_api.set_security_group_id
78       (p_security_group_id => l_security_group_id
79       );
80   end if;
81   --
82   hr_utility.set_location(' Leaving:'|| l_proc, 20);
83   --
84 end set_security_group_id;
85 --
86 --  ---------------------------------------------------------------------------
87 --  |---------------------< return_legislation_code >-------------------------|
88 --  ---------------------------------------------------------------------------
89 --
90 Function return_legislation_code
91   (p_tatigkeit_detail_id                  in     number
92   )
93   Return Varchar2 Is
94   --
95   -- Declare cursor
96   --
97   -- EDIT_HERE  In the following cursor statement add join(s) between
98   -- pqh_de_tatigkeit_details and PER_BUSINESS_GROUPS
99   -- so that the legislation_code for
100   -- the current business group context can be derived.
101   -- Remove this comment when the edit has been completed.
102   cursor csr_leg_code is
103     select pbg.legislation_code
104       from per_business_groups     pbg
105          , pqh_de_tatigkeit_details tkt
106       --   , EDIT_HERE table_name(s) 333
107      where tkt.tatigkeit_detail_id = p_tatigkeit_detail_id;
108       -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
109   --
110   -- Declare local variables
111   --
112   l_legislation_code  varchar2(150);
113   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
114   --
115 Begin
116   --
117   hr_utility.set_location('Entering:'|| l_proc, 10);
118   --
119   -- Ensure that all the mandatory parameter are not null
120   --
121   hr_api.mandatory_arg_error
122     (p_api_name           => l_proc
123     ,p_argument           => 'tatigkeit_detail_id'
124     ,p_argument_value     => p_tatigkeit_detail_id
125     );
126   --
127   if ( nvl(pqh_tkt_bus.g_tatigkeit_detail_id, hr_api.g_number)
128        = p_tatigkeit_detail_id) 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 := pqh_tkt_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     pqh_tkt_bus.g_tatigkeit_detail_id         := p_tatigkeit_detail_id;
159     pqh_tkt_bus.g_legislation_code  := l_legislation_code;
160   end if;
161   hr_utility.set_location(' Leaving:'|| l_proc, 40);
162   return l_legislation_code;
163 end return_legislation_code;
164 --
165 -- ----------------------------------------------------------------------------
166 -- |-----------------------< chk_non_updateable_args >------------------------|
167 -- ----------------------------------------------------------------------------
168 -- {Start Of Comments}
169 --
170 -- Description:
171 --   This procedure is used to ensure that non updateable attributes have
172 --   not been updated. If an attribute has been updated an error is generated.
173 --
174 -- Pre Conditions:
175 --   g_old_rec has been populated with details of the values currently in
176 --   the database.
177 --
178 -- In Arguments:
179 --   p_rec has been populated with the updated values the user would like the
180 --   record set to.
181 --
182 -- Post Success:
183 --   Processing continues if all the non updateable attributes have not
184 --   changed.
185 --
186 -- Post Failure:
187 --   An application error is raised if any of the non updatable attributes
188 --   have been altered.
189 --
190 -- {End Of Comments}
191 -- ----------------------------------------------------------------------------
192 Procedure chk_non_updateable_args
193   (p_effective_date               in date
194   ,p_rec in pqh_tkt_shd.g_rec_type
195   ) IS
196 --
197   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
198 
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 pqh_tkt_shd.api_updating
206       (p_tatigkeit_detail_id               => p_rec.tatigkeit_detail_id
207       ,p_object_version_number             => p_rec.object_version_number
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 IF nvl(p_rec.TATIGKEIT_NUMBER, hr_api.g_varchar2) <>
219     nvl(pqh_tkt_shd.g_old_rec.TATIGKEIT_NUMBER, hr_api.g_varchar2) THEN
220     hr_utility.set_message(8302, 'PQH_DE_NONUPD_TATIGKEIT_NUMBER');
221       fnd_message.raise_error;
222      END IF;
223 
224 End chk_non_updateable_args;
225 -- ----------------------------------------------------------------------------
226 -- |-----------------------< chk_delete >-------------------------------------|
227 -- ----------------------------------------------------------------------------
228 Procedure Chk_delete
229  (p_rec  in pqh_tkt_shd.g_rec_type) is
230   l_proc  varchar2(72) := g_package||'Ckh_Delete';
231  Cursor Del is
232 select  '1' from per_gen_hierarchy_nodes
233 where    NODE_TYPE  = 'OPR_JOB_DTLS'
234 and      entity_id  = p_rec.TATIGKEIT_NUMBER;
235  l_Status Varchar2(1);
236 Begin
237 Open Del;
238 Fetch Del into l_Status;
239 If Del%Found Then
240    Close Del;
241    hr_utility.set_message(8302, 'PQH_TKTDTLS_PRE_DEL');
242    hr_utility.raise_error;
243 End If;
244 Close Del;
245 Exception
246 when app_exception.application_exception then
247     if hr_multi_message.exception_add
248        (p_associated_column1 => 'PQH_DE_TATIGKEIT_DETAILS.TATIGKEIT_NUMBER'
249        ) then
250       hr_utility.set_location(' Leaving:'||l_proc,60);
251       raise;
252     end if;
253   hr_utility.set_location(' Leaving:'||l_proc,70);
254 End Chk_Delete;
255 -- ----------------------------------------------------------------------------
256 -- |-----------------------< Chk_Unique_TATIGKEIT_NUMBER >---------------------|
257 -- ----------------------------------------------------------------------------
258 Procedure Chk_Unique_TATIGKEIT_NUMBER
259   (p_rec   in pqh_tkt_shd.g_rec_type) is
260 --
261 Cursor c_TATIGKEIT_NUMBER is
262 Select  TATIGKEIT_NUMBER
263   from  PQH_DE_TATIGKEIT_DETAILS
264  Where  TATIGKEIT_NUMBER = p_rec.TATIGKEIT_NUMBER;
265 l_TATIGKEIT_NUMBER PQH_DE_TATIGKEIT_DETAILS.TATIGKEIT_NUMBER%TYPE;
266 l_proc     varchar2(72) := g_package || 'Unique_TATIGKEIT_NUMBER';
267 Begin
268 hr_utility.set_location(l_proc, 10);
269 Open c_TATIGKEIT_NUMBER;
270 Fetch c_TATIGKEIT_NUMBER into l_TATIGKEIT_NUMBER;
271 If c_TATIGKEIT_NUMBER%ROWCOUNT > 0 Then
272    hr_utility.set_message(8302, 'PQH_DE_DUPVAL_tkt_Dtls');
273    Close c_TATIGKEIT_NUMBER;
274    fnd_message.raise_error;
275 End If;
276 Close c_TATIGKEIT_NUMBER;
277 Exception
278 when app_exception.application_exception then
279     if hr_multi_message.exception_add
280        (p_associated_column1 => 'PQH_DE_TATIGKEIT_DETAILS.TATIGKEIT_NUMBER'
281        ) then
282       hr_utility.set_location(' Leaving:'||l_proc,60);
283       raise;
284     end if;
285   hr_utility.set_location(' Leaving:'||l_proc,70);
286 End Chk_Unique_TATIGKEIT_NUMBER;
287 
288 
289 -- ----------------------------------------------------------------------------
290 -- |-----------------------< Chk_Unique_Description >-------------------------|
291 -- ----------------------------------------------------------------------------
292 Procedure Chk_Unique_Description
293   (p_rec   in pqh_tkt_shd.g_rec_type) is
294 --
295 Cursor c_Description is
296 Select  Description
297   from  PQH_DE_TATIGKEIT_DETAILS
298  Where  Description = p_rec.Description;
299   l_Description PQH_DE_TATIGKEIT_DETAILS.Description%TYPE;
300   l_proc     varchar2(72) := g_package || 'Unique_Description';
301 Begin
302 hr_utility.set_location(l_proc, 10);
303 Open c_Description;
304 Fetch c_Description into l_Description;
305 If c_Description%ROWCOUNT > 0 Then
306    hr_utility.set_message(8302, 'PQH_DE_DUPVAL_Description');
307    Close c_Description;
308    fnd_message.raise_error;
309 End If;
310 Close c_Description;
311 Exception
312 when app_exception.application_exception then
313     if hr_multi_message.exception_add
314        (p_associated_column1 => 'PQH_DE_TATIGKEIT_DETAILS.Description'
315        ) then
316       hr_utility.set_location(' Leaving:'||l_proc,60);
317       raise;
318     end if;
319   hr_utility.set_location(' Leaving:'||l_proc,70);
320 End Chk_Unique_Description;
321 
322 
323 
324 
325 -- ----------------------------------------------------------------------------
326 --
327 -- ----------------------------------------------------------------------------
328 -- |---------------------------< insert_validate >----------------------------|
329 -- ----------------------------------------------------------------------------
330 Procedure insert_validate
331   (p_effective_date               in date
332   ,p_rec                          in pqh_tkt_shd.g_rec_type
333   ) is
334 --
335   l_proc  varchar2(72) := g_package||'insert_validate';
336 --
337 Begin
338   hr_utility.set_location('Entering:'||l_proc, 5);
339   --
340   -- Call all supporting business operations
341   --
342   --
343   Chk_Unique_TATIGKEIT_NUMBER (P_Rec);
344 Chk_Unique_Description(P_Rec);
345 
346   -- EDIT_HERE: As this table does not have a mandatory business_group_id
347   -- column, ensure client_info is populated by calling a suitable
348   -- ???_???_bus.set_security_group_id procedure, or add one of the following
349   -- comments:
350   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
351   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
352   --
353   -- Validate Dependent Attributes
354   --
355   --
356   hr_utility.set_location(' Leaving:'||l_proc, 10);
357 End insert_validate;
358 --
359 -- ----------------------------------------------------------------------------
360 -- |---------------------------< update_validate >----------------------------|
361 -- ----------------------------------------------------------------------------
362 Procedure update_validate
363   (p_effective_date               in date
364   ,p_rec                          in pqh_tkt_shd.g_rec_type
365   ) is
366 --
367   l_proc  varchar2(72) := g_package||'update_validate';
368 --
369 Begin
370   hr_utility.set_location('Entering:'||l_proc, 5);
371   --
372   -- Call all supporting business operations
373   --
374   --
375    --   Chk_Unique_TATIGKEIT_NUMBER (P_Rec);
376    Chk_Unique_Description(P_Rec);
377 
378 
379   -- EDIT_HERE: As this table does not have a mandatory business_group_id
380   -- column, ensure client_info is populated by calling a suitable
381   -- ???_???_bus.set_security_group_id procedure, or add one of the following
382   -- comments:
383   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
384   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
385   --
386   -- Validate Dependent Attributes
387   --
388   chk_non_updateable_args
389     (p_effective_date              => p_effective_date
390       ,p_rec              	   => p_rec
391     );
392   --
393   --
394   hr_utility.set_location(' Leaving:'||l_proc, 10);
395 End update_validate;
396 --
397 -- ----------------------------------------------------------------------------
398 -- |---------------------------< delete_validate >----------------------------|
399 -- ----------------------------------------------------------------------------
400 Procedure delete_validate
401   (p_rec                          in pqh_tkt_shd.g_rec_type
402   ) is
403 --
404   l_proc  varchar2(72) := g_package||'delete_validate';
405 --
406 Begin
407   hr_utility.set_location('Entering:'||l_proc, 5);
408   --
409   -- Call all supporting business operations
410   --
411    Chk_delete(P_Rec);
412    hr_utility.set_location(' Leaving:'||l_proc, 10);
413 End delete_validate;
414 --
415 end pqh_tkt_bus;