DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_PDC_BUS

Source


1 Package Body hr_pdc_bus as
2 /* $Header: hrpdcrhi.pkb 120.1 2005/09/27 06:23 adhunter noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_pdc_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_person_deplymt_contact_id   number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |---------------------< return_legislation_code >-------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Function return_legislation_code
21   (p_person_deplymt_contact_id            in     number
22   )
23   Return Varchar2 Is
24   --
25   -- Declare cursor
26   --
27   cursor csr_leg_code is
28     select pbg.legislation_code
29       from per_business_groups_perf     pbg
30          , hr_person_deplymt_contacts pdc
31          , hr_person_deployments pdt
32      where pdc.person_deplymt_contact_id = p_person_deplymt_contact_id
33        and pdc.person_deployment_id = pdt.person_deployment_id
34        and pbg.business_group_id = pdt.to_business_group_id;
35   --
36   -- Declare local variables
37   --
38   l_legislation_code  varchar2(150);
39   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
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           => 'person_deplymt_contact_id'
50     ,p_argument_value     => p_person_deplymt_contact_id
51     );
52   --
53   if ( nvl(hr_pdc_bus.g_person_deplymt_contact_id, hr_api.g_number)
54        = p_person_deplymt_contact_id) then
55     --
56     -- The legislation code has already been found with a previous
57     -- call to this function. Just return the value in the global
58     -- variable.
59     --
60     l_legislation_code := hr_pdc_bus.g_legislation_code;
61     hr_utility.set_location(l_proc, 20);
62   else
63     --
64     -- The ID is different to the last call to this function
65     -- or this is the first call to this function.
66     --
67     open csr_leg_code;
68     fetch csr_leg_code into l_legislation_code;
69     --
70     if csr_leg_code%notfound then
71       --
72       -- The primary key is invalid therefore we must error
73       --
74       close csr_leg_code;
75       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
76       fnd_message.raise_error;
77     end if;
78     hr_utility.set_location(l_proc,30);
79     --
80     -- Set the global variables so the values are
81     -- available for the next call to this function.
82     --
83     close csr_leg_code;
84     hr_pdc_bus.g_person_deplymt_contact_id   := p_person_deplymt_contact_id;
85     hr_pdc_bus.g_legislation_code  := l_legislation_code;
86   end if;
87   hr_utility.set_location(' Leaving:'|| l_proc, 40);
88   return l_legislation_code;
89 end return_legislation_code;
90 --
91 -- ----------------------------------------------------------------------------
92 -- |-----------------------< chk_non_updateable_args >------------------------|
93 -- ----------------------------------------------------------------------------
94 -- {Start Of Comments}
95 --
96 -- Description:
97 --   This procedure is used to ensure that non updateable attributes have
98 --   not been updated. If an attribute has been updated an error is generated.
99 --
100 -- Pre Conditions:
101 --   g_old_rec has been populated with details of the values currently in
102 --   the database.
103 --
104 -- In Arguments:
105 --   p_rec has been populated with the updated values the user would like the
106 --   record set to.
107 --
108 -- Post Success:
109 --   Processing continues if all the non updateable attributes have not
110 --   changed.
111 --
112 -- Post Failure:
113 --   An application error is raised if any of the non updatable attributes
114 --   have been altered.
115 --
116 -- {End Of Comments}
117 -- ----------------------------------------------------------------------------
118 Procedure chk_non_updateable_args
119   (p_rec in hr_pdc_shd.g_rec_type
120   ) IS
121 --
122   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
123   l_error       exception;
124   l_argument    varchar2(30);
125 --
126 Begin
127   --
128   hr_utility.set_location('Entering:'|| l_proc,10);
129   --
130   -- Only proceed with the validation if a row exists for the current
131   -- record in the HR Schema.
132   --
133   IF NOT hr_pdc_shd.api_updating
134       (p_person_deplymt_contact_id         => p_rec.person_deplymt_contact_id
135       ,p_object_version_number             => p_rec.object_version_number
136       ) THEN
137      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
138      fnd_message.set_token('PROCEDURE ', l_proc);
139      fnd_message.set_token('STEP ', '5');
140      fnd_message.raise_error;
141   END IF;
142   --
143   hr_utility.set_location (l_proc, 20);
144   --
145   if nvl(p_rec.person_deployment_id,hr_api.g_number)
146         <> nvl(hr_pdc_shd.g_old_rec.person_deployment_id,hr_api.g_number) then
147      l_argument := 'person_deployment_id';
148      raise l_error;
149   end if;
150   --
151   if nvl(p_rec.contact_relationship_id,hr_api.g_number)
152         <> nvl(hr_pdc_shd.g_old_rec.contact_relationship_id,hr_api.g_number) then
153      l_argument := 'contact_relationship_id';
154      raise l_error;
155   end if;
156   --
157   hr_utility.set_location(' Leaving : '|| l_proc, 30);
158   --
159   exception
160     when l_error then
161        hr_api.argument_changed_error
162          (p_api_name => l_proc
163          ,p_argument => l_argument);
164     when others then
165        raise;
166 End chk_non_updateable_args;
167 --
168 --  ---------------------------------------------------------------------------
169 --  |------------------------< chk_person_deployment_id >---------------------|
170 --  ---------------------------------------------------------------------------
171 --
172 --  Desciption:
173 --    This procedures validates that the person deployment id exists on the
174 --    HR_PERSON_DEPLOYMENTS table
175 --
176 --  Pre-conditions :
177 --    None
178 --
179 --  In Parameters :
180 --    p_person_deployment_id
181 --
182 --  Post Success :
183 --    Processing continues if the person deployment id is valid
184 --
185 --  Post Failure :
186 --    An application error will be raised and processing is terminated if the
187 --    person deployment id is invalid
188 --
189 --  Access Status :
190 --    Internal Row Handler Use only.
191 --
192 -- {End of Comments}
193 --
194 -- ---------------------------------------------------------------------------
195 Procedure chk_person_deployment_id
196   (p_person_deployment_id in hr_person_deplymt_eits.person_deployment_id%type
197   ) is
198   --
199   l_proc        varchar2(72) := g_package||'chk_person_deployment_id';
200   l_dummy       number;
201   --
202   cursor csr_deployment is
203   select 1
204   from hr_person_deployments
205   where person_deployment_id = p_person_deployment_id;
206   --
207 begin
208   hr_utility.set_location('Entering:'||l_proc, 10);
209   --
210   -- Check mandatory parameters have been set
211   --
212   hr_api.mandatory_arg_error
213     (
214      p_api_name         => l_proc,
215      p_argument         => 'person_deployment_id',
216      p_argument_value   => p_person_deployment_id
217     );
218   --
219   open csr_deployment;
220   fetch csr_deployment into l_dummy;
221   if csr_deployment%notfound then
222      close csr_deployment;
223      fnd_message.set_name('PER','HR_44609_DPL_NOT_EXIST');
224      fnd_message.raise_error;
225   else
226      close csr_deployment;
227   end if;
228   --
229   hr_utility.set_location('Leaving:'||l_proc, 20);
230 end chk_person_deployment_id;
231 --
232 --  ---------------------------------------------------------------------------
233 --  |------------------------< chk_contact_relationship_id >------------------|
234 --  ---------------------------------------------------------------------------
235 --
236 --  Desciption:
237 --    This procedures validates that the personcontact relationship id exists on the
238 --    PER_CONTACT_RELATIONSHIPS table
239 --
240 --  Pre-conditions :
241 --    None
242 --
243 --  In Parameters :
244 --    p_contact_relationship_id
245 --
246 --  Post Success :
247 --    Processing continues if the contact relationship id is valid
248 --
249 --  Post Failure :
250 --    An application error will be raised and processing is terminated if the
251 --    contact relationship is invalid
252 --
253 --  Access Status :
254 --    Internal Row Handler Use only.
255 --
256 -- {End of Comments}
257 --
258 -- ---------------------------------------------------------------------------
259 Procedure chk_contact_relationship_id
260   (p_contact_relationship_id  in  hr_person_deplymt_contacts.contact_relationship_id%type
261   ,p_person_deployment_id     in  hr_person_deplymt_contacts.person_deployment_id%type
262   ) is
263   --
264   l_proc        varchar2(72) := g_package||'chk_person_extra_info_id';
265   l_dummy       number;
266   --
267   cursor csr_contact_rel is
268   select 1
269   from per_contact_relationships
270   where contact_relationship_id = p_contact_relationship_id;
271   --
272   cursor csr_check_person is
273   select ctr.person_id
274   from   per_contact_relationships ctr,
275          hr_person_deployments pdt
276   where  pdt.person_deployment_id = p_person_deployment_id
277   and    ctr.contact_relationship_id = p_contact_relationship_id
278   and    pdt.from_person_id = ctr.person_id;
279   --
280 begin
281   hr_utility.set_location('Entering:'||l_proc, 10);
282   --
283   -- Check mandatory parameters have been set
284   --
285   hr_api.mandatory_arg_error
286     (
287      p_api_name         => l_proc,
288      p_argument         => 'person_deployment_id',
289      p_argument_value   => p_person_deployment_id
290     );
291   --
292   hr_api.mandatory_arg_error
293     (
294      p_api_name         => l_proc,
295      p_argument         => 'contact_relationship_id',
296      p_argument_value   => p_contact_relationship_id
297     );
298   --
299   open csr_contact_rel;
300   fetch csr_contact_rel into l_dummy;
301   if csr_contact_rel%found then
302      close csr_contact_rel;
303      --
304      open csr_check_person;
305      fetch csr_check_person into l_dummy;
306      if csr_check_person%notfound then
307         close csr_check_person;
308         --
309         fnd_message.set_name('PER','HR_449610_PDC_WRONG_PERSON');
310         fnd_message.raise_error;
311      else         --relationship does not belong to right person
312         close csr_check_person;
313      end if;
314   else       --relationship does not exist
315       close csr_contact_rel;
316       --
317       fnd_message.set_name('PER','HR_449611_PDC_REL_NOT_EXIST');
318       fnd_message.raise_error;
319   end if;
320   --
321 end chk_contact_relationship_id;
322 --
323 -- ----------------------------------------------------------------------------
324 -- |---------------------------< insert_validate >----------------------------|
325 -- ----------------------------------------------------------------------------
326 Procedure insert_validate
327   (p_rec                          in hr_pdc_shd.g_rec_type
328   ) is
329 --
330   l_proc  varchar2(72) := g_package||'insert_validate';
331 --
332 Begin
333   hr_utility.set_location('Entering:'||l_proc, 5);
334   --
335   -- Call all supporting business operations
336   --
337   -- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS
338 
339   -- Validate Dependent Attributes
340   --
341   hr_pdc_bus.chk_person_deployment_id
342     (p_person_deployment_id   =>   p_rec.person_deployment_id);
343   --
344   hr_pdc_bus.chk_contact_relationship_id
345     (p_contact_relationship_id =>   p_rec.contact_relationship_id
346     ,p_person_deployment_id    =>   p_rec.person_deployment_id);
347   --
348   --
349   hr_utility.set_location(' Leaving:'||l_proc, 10);
350 End insert_validate;
351 --
352 -- ----------------------------------------------------------------------------
353 -- |---------------------------< update_validate >----------------------------|
354 -- ----------------------------------------------------------------------------
355 Procedure update_validate
356   (p_rec                          in hr_pdc_shd.g_rec_type
357   ) is
358 --
359   l_proc  varchar2(72) := g_package||'update_validate';
360 --
361 Begin
362   hr_utility.set_location('Entering:'||l_proc, 5);
363   --
364   -- Call all supporting business operations
365   --
366   -- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS
367   --
368   -- Validate Dependent Attributes
369   --
370   chk_non_updateable_args
371     (p_rec              => p_rec
372     );
373   --
374   --
375   hr_utility.set_location(' Leaving:'||l_proc, 10);
376 End update_validate;
377 --
378 -- ----------------------------------------------------------------------------
379 -- |---------------------------< delete_validate >----------------------------|
380 -- ----------------------------------------------------------------------------
381 Procedure delete_validate
382   (p_rec                          in hr_pdc_shd.g_rec_type
383   ) is
384 --
385   l_proc  varchar2(72) := g_package||'delete_validate';
386 --
387 Begin
388   hr_utility.set_location('Entering:'||l_proc, 5);
389   --
390   -- Call all supporting business operations
391   --
392   hr_utility.set_location(' Leaving:'||l_proc, 10);
393 End delete_validate;
394 --
395 end hr_pdc_bus;