DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_DOA_BUS

Source


1 Package Body pqh_doa_bus as
2 /* $Header: pqdoarhi.pkb 115.0 2003/01/06 09:20:29 svorugan noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pqh_doa_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_document_attribute_id       number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_document_attribute_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       from per_business_groups pbg
30          , pqh_document_attributes_f doa
31           ,pqh_txn_category_attributes ptca
32           ,pqh_transaction_categories ptc
33         where doa.document_attribute_id = p_document_attribute_id
34            and doa.attribute_id = ptca.attribute_id
35            and ptca.transaction_category_id = ptc.transaction_category_id
36            and pbg.business_group_id = ptc.business_group_id;
37   --
38   -- Declare local variables
39   --
40   l_security_group_id number;
41   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
42   --
43 begin
44   --
45   hr_utility.set_location('Entering:'|| l_proc, 10);
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           => 'document_attribute_id'
52     ,p_argument_value     => p_document_attribute_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,'DOCUMENT_ATTRIBUTE_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   hr_utility.set_location(' Leaving:'|| l_proc, 20);
81   --
82 end set_security_group_id;
83 --
84 --  ---------------------------------------------------------------------------
85 --  |---------------------< return_legislation_code >-------------------------|
86 --  ---------------------------------------------------------------------------
87 --
91   Return Varchar2 Is
88 Function return_legislation_code
89   (p_document_attribute_id                in     number
90   )
92   --
93   -- Declare cursor
94   --
95   cursor csr_leg_code is
96     select pbg.legislation_code
97       from per_business_groups     pbg
98          , pqh_document_attributes_f doa
99          ,pqh_txn_category_attributes ptca
100          ,pqh_transaction_categories ptc
101          where doa.document_attribute_id = p_document_attribute_id
102            and doa.attribute_id = ptca.attribute_id
103            and ptca.transaction_category_id = ptc.transaction_category_id
104            and pbg.business_group_id = ptc.business_group_id;
105 --
106   -- Declare local variables
107   --
108   l_legislation_code  varchar2(150);
109   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
110   --
111 Begin
112   --
113   hr_utility.set_location('Entering:'|| l_proc, 10);
114   --
115   -- Ensure that all the mandatory parameter are not null
116   --
117   hr_api.mandatory_arg_error
118     (p_api_name           => l_proc
119     ,p_argument           => 'document_attribute_id'
120     ,p_argument_value     => p_document_attribute_id
121     );
122   --
123   if ( nvl(pqh_doa_bus.g_document_attribute_id, hr_api.g_number)
124        = p_document_attribute_id) then
125     --
126     -- The legislation code has already been found with a previous
127     -- call to this function. Just return the value in the global
128     -- variable.
129     --
130     l_legislation_code := pqh_doa_bus.g_legislation_code;
131     hr_utility.set_location(l_proc, 20);
132   else
133     --
134     -- The ID is different to the last call to this function
135     -- or this is the first call to this function.
136     --
137     open csr_leg_code;
138     fetch csr_leg_code into l_legislation_code;
139     --
140     if csr_leg_code%notfound then
141       --
142       -- The primary key is invalid therefore we must error
143       --
144       close csr_leg_code;
145       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
146       fnd_message.raise_error;
147     end if;
148     hr_utility.set_location(l_proc,30);
149     --
150     -- Set the global variables so the values are
151     -- available for the next call to this function.
152     --
153     close csr_leg_code;
154     pqh_doa_bus.g_document_attribute_id       := p_document_attribute_id;
155     pqh_doa_bus.g_legislation_code  := l_legislation_code;
156   end if;
157   hr_utility.set_location(' Leaving:'|| l_proc, 40);
158   return l_legislation_code;
159 end return_legislation_code;
160 --
161 -- ----------------------------------------------------------------------------
162 -- |-----------------------< chk_non_updateable_args >------------------------|
163 -- ----------------------------------------------------------------------------
164 -- {Start Of Comments}
165 --
166 -- Description:
167 --   This procedure is used to ensure that non updateable attributes have
168 --   not been updated. If an attribute has been updated an error is generated.
169 --
170 -- Pre Conditions:
171 --   g_old_rec has been populated with details of the values currently in
172 --   the database.
173 --
174 -- In Arguments:
175 --   p_rec has been populated with the updated values the user would like the
176 --   record set to.
177 --
178 -- Post Success:
179 --   Processing continues if all the non updateable attributes have not
180 --   changed.
181 --
182 -- Post Failure:
183 --   An application error is raised if any of the non updatable attributes
184 --   have been altered.
185 --
186 -- {End Of Comments}
187 -- ----------------------------------------------------------------------------
188 Procedure chk_non_updateable_args
189   (p_effective_date  in date
190   ,p_rec             in pqh_doa_shd.g_rec_type
191   ) IS
192 --
193   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
194 --
195 Begin
196   --
197   -- Only proceed with the validation if a row exists for the current
198   -- record in the HR Schema.
199   --
200   IF NOT pqh_doa_shd.api_updating
201       (p_document_attribute_id            => p_rec.document_attribute_id
202       ,p_effective_date                   => p_effective_date
203       ,p_object_version_number            => p_rec.object_version_number
204       ) THEN
205      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
206      fnd_message.set_token('PROCEDURE ', l_proc);
207      fnd_message.set_token('STEP ', '5');
208      fnd_message.raise_error;
209   END IF;
210   --
211   -- EDIT_HERE: Add checks to ensure non-updateable args have
212   --            not been updated.
213   --
214 End chk_non_updateable_args;
215 --
216 -- ----------------------------------------------------------------------------
217 -- |--------------------------< dt_update_validate >--------------------------|
218 -- ----------------------------------------------------------------------------
219 -- {Start Of Comments}
220 --
221 -- Description:
222 --   This procedure is used for referential integrity of datetracked
223 --   parent entities when a datetrack update operation is taking place
224 --   and where there is no cascading of update defined for this entity.
225 --
226 -- Prerequisites:
227 --   This procedure is called from the update_validate.
228 --
229 -- In Parameters:
230 --
231 -- Post Success:
235 --
232 --   Processing continues.
233 --
234 -- Post Failure:
236 -- Developer Implementation Notes:
237 --   This procedure should not need maintenance unless the HR Schema model
238 --   changes.
239 --
240 -- Access Status:
241 --   Internal Row Handler Use Only.
242 --
243 -- {End Of Comments}
244 -- ----------------------------------------------------------------------------
245 Procedure dt_update_validate
246   (p_datetrack_mode                in varchar2
247   ,p_validation_start_date         in date
248   ,p_validation_end_date           in date
249   ) Is
250 --
251   l_proc  varchar2(72) := g_package||'dt_update_validate';
252 --
253 Begin
254   --
255   -- Ensure that the p_datetrack_mode argument is not null
256   --
257   hr_api.mandatory_arg_error
258     (p_api_name       => l_proc
259     ,p_argument       => 'datetrack_mode'
260     ,p_argument_value => p_datetrack_mode
261     );
262   --
263   -- Mode will be valid, as this is checked at the start of the upd.
264   --
265   -- Ensure the arguments are not null
266   --
267   hr_api.mandatory_arg_error
268     (p_api_name       => l_proc
269     ,p_argument       => 'validation_start_date'
270     ,p_argument_value => p_validation_start_date
271     );
272   --
273   hr_api.mandatory_arg_error
274     (p_api_name       => l_proc
275     ,p_argument       => 'validation_end_date'
276     ,p_argument_value => p_validation_end_date
277     );
278   --
279     --
280   --
281 Exception
282   When Others Then
283     --
284     -- An unhandled or unexpected error has occurred which
285     -- we must report
286     --
287     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
288     fnd_message.set_token('PROCEDURE', l_proc);
289     fnd_message.set_token('STEP','15');
290     fnd_message.raise_error;
291 End dt_update_validate;
292 --
293 -- ----------------------------------------------------------------------------
294 -- |--------------------------< dt_delete_validate >--------------------------|
295 -- ----------------------------------------------------------------------------
296 -- {Start Of Comments}
297 --
298 -- Description:
299 --   This procedure is used for referential integrity of datetracked
300 --   child entities when either a datetrack DELETE or ZAP is in operation
301 --   and where there is no cascading of delete defined for this entity.
302 --   For the datetrack mode of DELETE or ZAP we must ensure that no
303 --   datetracked child rows exist between the validation start and end
304 --   dates.
305 --
306 -- Prerequisites:
307 --   This procedure is called from the delete_validate.
308 --
309 -- In Parameters:
310 --
311 -- Post Success:
312 --   Processing continues.
313 --
314 -- Post Failure:
315 --   If a row exists by determining the returning Boolean value from the
316 --   generic dt_api.rows_exist function then we must supply an error via
317 --   the use of the local exception handler l_rows_exist.
318 --
319 -- Developer Implementation Notes:
320 --   This procedure should not need maintenance unless the HR Schema model
321 --   changes.
322 --
323 -- Access Status:
324 --   Internal Row Handler Use Only.
325 --
326 -- {End Of Comments}
327 -- ----------------------------------------------------------------------------
328 Procedure dt_delete_validate
329   (p_document_attribute_id            in number
330   ,p_datetrack_mode                   in varchar2
331   ,p_validation_start_date            in date
332   ,p_validation_end_date              in date
333   ) Is
334 --
335   l_proc        varchar2(72)    := g_package||'dt_delete_validate';
336 --
337 Begin
338   --
339   -- Ensure that the p_datetrack_mode argument is not null
340   --
341   hr_api.mandatory_arg_error
342     (p_api_name       => l_proc
343     ,p_argument       => 'datetrack_mode'
344     ,p_argument_value => p_datetrack_mode
345     );
346   --
347   -- Only perform the validation if the datetrack mode is either
348   -- DELETE or ZAP
349   --
350   If (p_datetrack_mode = hr_api.g_delete or
351       p_datetrack_mode = hr_api.g_zap) then
352     --
353     --
354     -- Ensure the arguments are not null
355     --
356     hr_api.mandatory_arg_error
357       (p_api_name       => l_proc
358       ,p_argument       => 'validation_start_date'
359       ,p_argument_value => p_validation_start_date
360       );
361     --
362     hr_api.mandatory_arg_error
363       (p_api_name       => l_proc
364       ,p_argument       => 'validation_end_date'
365       ,p_argument_value => p_validation_end_date
366       );
367     --
368     hr_api.mandatory_arg_error
369       (p_api_name       => l_proc
370       ,p_argument       => 'document_attribute_id'
371       ,p_argument_value => p_document_attribute_id
372       );
373     --
374   --
375     --
376   End If;
377   --
378 Exception
379   When Others Then
380     --
381     -- An unhandled or unexpected error has occurred which
382     -- we must report
383     --
384     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
385     fnd_message.set_token('PROCEDURE', l_proc);
386     fnd_message.set_token('STEP','15');
387     fnd_message.raise_error;
388   --
389 End dt_delete_validate;
390 --
391 -- ----------------------------------------------------------------------------
392 -- |---------------------------< insert_validate >----------------------------|
393 -- ----------------------------------------------------------------------------
394 Procedure insert_validate
395   (p_rec                   in pqh_doa_shd.g_rec_type
396   ,p_effective_date        in date
397   ,p_datetrack_mode        in varchar2
398   ,p_validation_start_date in date
399   ,p_validation_end_date   in date
400   ) is
401 --
402   l_proc        varchar2(72) := g_package||'insert_validate';
403 --
404 Begin
405   hr_utility.set_location('Entering:'||l_proc, 5);
406   --
407   -- Call all supporting business operations
408   --
409   --
410   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
411   --
412   --
413   hr_utility.set_location(' Leaving:'||l_proc, 10);
414 End insert_validate;
415 --
416 -- ----------------------------------------------------------------------------
417 -- |---------------------------< update_validate >----------------------------|
418 -- ----------------------------------------------------------------------------
419 Procedure update_validate
420   (p_rec                     in pqh_doa_shd.g_rec_type
421   ,p_effective_date          in date
422   ,p_datetrack_mode          in varchar2
423   ,p_validation_start_date   in date
424   ,p_validation_end_date     in date
425   ) is
426 --
427   l_proc        varchar2(72) := g_package||'update_validate';
428 --
429 Begin
430   hr_utility.set_location('Entering:'||l_proc, 5);
431   --
432   -- Call all supporting business operations
433   --
434   --
435   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
436   --
437   -- Call the datetrack update integrity operation
438   --
439   dt_update_validate
440     (p_datetrack_mode                 => p_datetrack_mode
441     ,p_validation_start_date          => p_validation_start_date
442     ,p_validation_end_date            => p_validation_end_date
443     );
444   --
445   chk_non_updateable_args
446     (p_effective_date  => p_effective_date
447     ,p_rec             => p_rec
448     );
449   --
450   --
451   hr_utility.set_location(' Leaving:'||l_proc, 10);
452 End update_validate;
453 --
454 -- ----------------------------------------------------------------------------
455 -- |---------------------------< delete_validate >----------------------------|
456 -- ----------------------------------------------------------------------------
457 Procedure delete_validate
458   (p_rec                    in pqh_doa_shd.g_rec_type
459   ,p_effective_date         in date
460   ,p_datetrack_mode         in varchar2
461   ,p_validation_start_date  in date
462   ,p_validation_end_date    in date
463   ) is
464 --
465   l_proc        varchar2(72) := g_package||'delete_validate';
466 --
467 Begin
468   hr_utility.set_location('Entering:'||l_proc, 5);
469   --
470   -- Call all supporting business operations
471   --
472   dt_delete_validate
473     (p_datetrack_mode                   => p_datetrack_mode
474     ,p_validation_start_date            => p_validation_start_date
475     ,p_validation_end_date              => p_validation_end_date
476     ,p_document_attribute_id            => p_rec.document_attribute_id
477     );
478   --
479   hr_utility.set_location(' Leaving:'||l_proc, 10);
480 End delete_validate;
481 --
482 end pqh_doa_bus;