DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_JBI_BUS

Source


1 Package Body irc_jbi_bus as
2 /* $Header: irjbirhi.pkb 120.0 2005/07/26 15:13:16 mbocutt noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  irc_jbi_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_party_id                    number         default null;
15 g_recruitment_activity_id     number         default null;
16 g_job_basket_item_id          number         default null;
17 --
18 -- ----------------------------------------------------------------------------
19 -- |-----------------------< chk_person_id >-----------------------------------|
20 -- ----------------------------------------------------------------------------
21 -- {Start Of Comments}
22 --
23 -- Description:
24 --   This procedure is used to ensure that mandatory parameters have been set.
25 --   If the person id is not found in per_all_people_f an error is generated.
26 --
27 -- Pre Conditions:
28 --   g_old_rec has been populated with details of the values currently in
29 --   the database.
30 --
31 -- In Arguments:
32 --   p_person_id
33 --   p_party_id
34 --   p_effective_date
35 --
36 -- Post Success:
37 --   Processing continues if the mandatory parameters have been set and the
38 --   specified person id exists.
39 --
40 -- Post Failure:
41 --   An application error is raised if the person id does not exist.
42 --
43 -- {End Of Comments}
44 -- ----------------------------------------------------------------------------
45 Procedure chk_person_id
46   (p_person_id      in irc_job_basket_items.person_id%type
47   ,p_party_id       in out nocopy irc_job_basket_items.party_id%type
48   ,p_effective_date in date
49   ) IS
50 --
51   l_proc     varchar2(72) := g_package || 'chk_person_id';
52   l_party_id irc_job_basket_items.party_id%type;
53   l_var varchar2(30);
54 --
55 --
56 --   Cursor to check that the person_id exists in PER_ALL_PEOPLE_F.
57 --
58 cursor csr_person_id is
59   select party_id
60       from per_all_people_f
61   where person_id = p_person_id
62     and p_effective_date between effective_start_date
63     and effective_end_date;
64 --
65 Begin
66 --
67   hr_utility.set_location(' Entering:'||l_proc,10);
68   --
69   --
70   -- Check if the person_id exists in PER_ALL_PEOPLE_F.
71   --
72   open csr_person_id;
73   fetch csr_person_id into l_party_id;
74   hr_utility.set_location(l_proc, 30);
75   if csr_person_id%notfound then
76     close csr_person_id;
77     fnd_message.set_name('PER','IRC_412157_PARTY_PERS_MISMTCH');
78     fnd_message.raise_error;
79   end if;
80   close csr_person_id;
81   if p_party_id is not null then
82     if p_party_id<>l_party_id then
83       fnd_message.set_name('PER','IRC_412033_RTM_INV_PARTY_ID');
84       fnd_message.raise_error;
85     end if;
86   else
87     p_party_id:=l_party_id;
88   end if;
89   --
90   hr_utility.set_location(' Leaving:'||l_proc,70);
91   exception
92   when app_exception.application_exception then
93     if hr_multi_message.exception_add
94          (p_associated_column1      => 'IRC_JOB_BASKET_ITEMS.PARTY_ID'
95          ) then
96       hr_utility.set_location(' Leaving:'|| l_proc, 80);
97       raise;
98     end if;
99     hr_utility.set_location(' Leaving:'|| l_proc, 90);
100 --
101 End chk_person_id;
102 --
103 -- ----------------------------------------------------------------------------
104 -- |--------------------< chk_recruitment_activity_id >-----------------------|
105 -- ----------------------------------------------------------------------------
106 --
107 Procedure chk_recruitment_activity_id(p_recruitment_activity_id in number) is
108 -- Cursor to check recruitment_activity_id exists in PER_RECRUITMENT_ACTIVITIES
109 cursor csr_recruitment_activity_id(p_recruitment_activity_id number) is
110 select 1
111 from per_recruitment_activities
112 where recruitment_activity_id = p_recruitment_activity_id;
113 l_proc varchar2(72) := g_package||'chk_recruitment_activity_id';
114 begin
115   --
116   hr_utility.set_location('Entering:'|| l_proc, 10);
117   --
118   open csr_recruitment_activity_id(p_recruitment_activity_id);
119   if csr_recruitment_activity_id%notfound then
120     close csr_recruitment_activity_id;
121     hr_utility.set_message(800,'IRC_412044_JBI_INV_REC_ACT_ID');
122     hr_utility.raise_error;
123   end if;
124   close csr_recruitment_activity_id;
125   --
126   hr_utility.set_location('Leaving:'|| l_proc, 20);
127 end;
128 --
129 -- ----------------------------------------------------------------------------
130 -- |---------------------------< chk_unique_item >----------------------------|
131 -- ----------------------------------------------------------------------------
132 --
133 Procedure chk_unique_item(p_job_basket_item_id    in    number) is
134 -- Cursor to check composite primary key is unique
135 cursor csr_unique_prim_key(p_job_basket_item_id number) is
136 select 1
137 from irc_job_basket_items
138 where
139      job_basket_item_id = p_job_basket_item_id;
140 
141 l_proc varchar2(72) := g_package||'chk_unique_item';
142 begin
143   --
144   hr_utility.set_location('Entering:'|| l_proc, 10);
145   --
146   open csr_unique_prim_key(p_job_basket_item_id);
147   if csr_unique_prim_key%found then
148     close csr_unique_prim_key;
149     hr_utility.set_message(800,'IRC_412043_JBI_INV_COMP_PK');
150     hr_utility.raise_error;
151   end if;
152   close csr_unique_prim_key;
153   --
154   hr_utility.set_location('Leaving:'|| l_proc, 20);
155 end;
156 --
157 --  ---------------------------------------------------------------------------
158 --  |----------------------< set_security_group_id >--------------------------|
159 --  ---------------------------------------------------------------------------
160 --
161 Procedure set_security_group_id
162   (p_job_basket_item_id              in number
163   ,p_recruitment_activity_id         in number
164   ) is
165   --
166   -- Declare cursor
167   --
168   cursor csr_sec_grp is
169     select pbg.security_group_id
170       from per_business_groups pbg,
171            per_recruitment_activities pra
172      where
173            pra.recruitment_activity_id = p_recruitment_activity_id
174        and pra.business_group_id       = pbg.business_group_id;
175   --
176   -- Declare local variables
177   --
178   l_security_group_id number;
179   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
180   --
181 begin
182   --
183   hr_utility.set_location('Entering:'|| l_proc, 10);
184   --
185   -- Ensure that all the mandatory parameter are not null
186   --
187   hr_api.mandatory_arg_error
188     (p_api_name           => l_proc
189     ,p_argument           => 'JOB_BASKET_ITEM_ID'
190     ,p_argument_value     => p_job_basket_item_id
191     );
192   hr_api.mandatory_arg_error
193     (p_api_name           => l_proc
194     ,p_argument           => 'recruitment_activity_id'
195     ,p_argument_value     => p_recruitment_activity_id
196     );
197   --
198   open csr_sec_grp;
199   fetch csr_sec_grp into l_security_group_id;
200   --
201   if csr_sec_grp%notfound then
202      --
203      close csr_sec_grp;
204      --
205      -- The primary key is invalid therefore we must error
206      --
207      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
208      fnd_message.raise_error;
209      --
210   end if;
211   close csr_sec_grp;
212   --
213   -- Set the security_group_id in CLIENT_INFO
214   --
215   hr_api.set_security_group_id
216     (p_security_group_id => l_security_group_id
217     );
218   --
219   hr_utility.set_location(' Leaving:'|| l_proc, 20);
220   --
221 end set_security_group_id;
222 --
223 --  ---------------------------------------------------------------------------
224 --  |---------------------< return_legislation_code >-------------------------|
225 --  ---------------------------------------------------------------------------
226 --
227 Function return_legislation_code
228   (p_job_basket_item_id   in     number
229   ) Return Varchar2 Is
230   --
231   -- Declare cursor
232   --
233   --
234   -- Declare local variables
235   --
236   l_legislation_code  varchar2(150);
237   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
238   --
239 Begin
240   --
241   hr_utility.set_location('Entering:'|| l_proc, 10);
242   --
243   -- Ensure that all the mandatory parameter are not null
244   --
245   hr_api.mandatory_arg_error
246     (p_api_name           => l_proc
247     ,p_argument           => 'JOB_BASKET_ITEM_ID'
248     ,p_argument_value     => p_job_basket_item_id
249     );
250   --
251 
252   hr_utility.set_location(' Leaving:'|| l_proc, 40);
253   return l_legislation_code;
254 end return_legislation_code;
255 
256 --
257 -- ----------------------------------------------------------------------------
258 -- |-----------------------< chk_non_updateable_args >------------------------|
259 -- ----------------------------------------------------------------------------
260 -- {Start Of Comments}
261 --
262 -- Description:
263 --   This procedure is used to ensure that non updateable attributes have
264 --   not been updated. If an attribute has been updated an error is generated.
265 --
266 -- Pre Conditions:
267 --   g_old_rec has been populated with details of the values currently in
268 --   the database.
269 --
270 -- In Arguments:
271 --   p_rec has been populated with the updated values the user would like the
272 --   record set to.
273 --
274 -- Post Success:
275 --   Processing continues if all the non updateable attributes have not
276 --   changed.
277 --
278 -- Post Failure:
279 --   An application error is raised if any of the non updatable attributes
280 --   have been altered.
281 --
282 -- {End Of Comments}
283 -- ----------------------------------------------------------------------------
284 Procedure chk_non_updateable_args
285   (p_effective_date               in date
286   ,p_rec in irc_jbi_shd.g_rec_type
287   ) IS
288 --
289   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
290   l_error    EXCEPTION;
291   l_argument varchar2(30);
292 --
293 Begin
294   --
295   -- Only proceed with the validation if a row exists for the current
296   -- record in the HR Schema.
297   --
298   IF NOT irc_jbi_shd.api_updating
299       (p_job_basket_item_id              => p_rec.job_basket_item_id
300       ,p_object_version_number           => p_rec.object_version_number
301       ) THEN
302      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
303      fnd_message.set_token('PROCEDURE ', l_proc);
304      fnd_message.set_token('STEP ', '5');
305      fnd_message.raise_error;
306   END IF;
307   EXCEPTION
308     WHEN l_error THEN
309        hr_api.argument_changed_error
310          (p_api_name => l_proc
311          ,p_argument => l_argument);
312     WHEN OTHERS THEN
313        RAISE;
314 End chk_non_updateable_args;
315 --
316 -- ----------------------------------------------------------------------------
317 -- |---------------------------< insert_validate >----------------------------|
318 -- ----------------------------------------------------------------------------
319 Procedure insert_validate
320   (p_effective_date               in date
321   ,p_rec                          in out nocopy irc_jbi_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   chk_person_id
332   (p_person_id =>p_rec.person_id
333   ,p_party_id => p_rec.party_id
334   ,p_effective_date=>p_effective_date
335   );
336   --
337   chk_recruitment_activity_id(p_rec.recruitment_activity_id);
338   --
339   --
340   chk_unique_item(p_rec.job_basket_item_id);
341   --
342   -- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
343   --
344   --
345   hr_utility.set_location(' Leaving:'||l_proc, 10);
346 End insert_validate;
347 --
348 -- ----------------------------------------------------------------------------
349 -- |---------------------------< update_validate >----------------------------|
350 -- ----------------------------------------------------------------------------
351 Procedure update_validate
352   (p_effective_date               in date
353   ,p_rec                          in irc_jbi_shd.g_rec_type
354   ) is
355 --
356   l_proc  varchar2(72) := g_package||'update_validate';
357 --
358 Begin
359   hr_utility.set_location('Entering:'||l_proc, 5);
360   --
361   -- Call all supporting business operations
362   --
363   --
364   hr_utility.set_location(' Leaving:'||l_proc, 10);
365 End update_validate;
366 --
367 -- ----------------------------------------------------------------------------
368 -- |---------------------------< delete_validate >----------------------------|
369 -- ----------------------------------------------------------------------------
370 Procedure delete_validate
371   (p_rec                          in irc_jbi_shd.g_rec_type
372   ) is
373 --
374   l_proc  varchar2(72) := g_package||'delete_validate';
375 --
376 Begin
377   hr_utility.set_location('Entering:'||l_proc, 5);
378   --
379   -- Call all supporting business operations
380   --
381   hr_utility.set_location(' Leaving:'||l_proc, 10);
382 End delete_validate;
383 --
384 end irc_jbi_bus;