1 Package Body pqh_opl_bus as
2 /* $Header: pqoplrhi.pkb 115.4 2002/12/03 00:09:31 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_opl_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_operation_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_operation_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_operations 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_operations opl
36 -- , EDIT_HERE table_name(s) 333
37 where opl.operation_id = p_operation_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 => 'operation_id'
54 ,p_argument_value => p_operation_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,'OPERATION_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_operation_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_operations 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_operations opl
106 -- , EDIT_HERE table_name(s) 333
107 where opl.operation_id = p_operation_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 => 'operation_id'
124 ,p_argument_value => p_operation_id
125 );
126 --
127 if ( nvl(pqh_opl_bus.g_operation_id, hr_api.g_number)
128 = p_operation_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_opl_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_opl_bus.g_operation_id := p_operation_id;
159 pqh_opl_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_opl_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_opl_shd.api_updating
206 (p_operation_id => p_rec.operation_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.OPERATION_NUMBER, hr_api.g_varchar2) <>
219 nvl(pqh_opl_shd.g_old_rec.OPERATION_NUMBER, hr_api.g_varchar2) THEN
220 hr_utility.set_message(8302, 'PQH_DE_NONUPD_OPERATION_NUMBER');
221 fnd_message.raise_error;
222 END IF;
223
224 End chk_non_updateable_args;
225 --
226 -- ----------------------------------------------------------------------------
227 -- |---------------------------< Chk_delete >---------------------------------|
228 -- ----------------------------------------------------------------------------
229 Procedure Chk_delete
230 (p_rec in pqh_opl_shd.g_rec_type) is
231 l_proc varchar2(72) := g_package||'Ckh_Delete';
232 Cursor Del is
233 select '1' from per_gen_hierarchy_nodes
234 where NODE_TYPE = 'OPR_OPTS'
235 and entity_id = p_rec.OPERATION_NUMBER;
236 l_Status Varchar2(1);
237 Begin
238 Open Del;
239 Fetch Del into l_Status;
240 If Del%Found Then
241 Close Del;
242 hr_utility.set_message(8302, 'PQH_OPRTNS_PRE_DEL');
243 hr_utility.raise_error;
244 End If;
245 Close Del;
246 Exception
247 when app_exception.application_exception then
248 if hr_multi_message.exception_add
249 (p_associated_column1 => 'PQH_DE_OPERATIONS.OPERATION_NUMBER'
250 ) then
251 hr_utility.set_location(' Leaving:'||l_proc,60);
252 raise;
253 end if;
254 hr_utility.set_location(' Leaving:'||l_proc,70);
255 End Chk_Delete;
256
257 -- ----------------------------------------------------------------------------
258 -- |-----------------------< Chk_Unique_Description >-------------------------|
259 -- ----------------------------------------------------------------------------
260 Procedure Chk_Unique_Description
261 (p_rec in pqh_opl_shd.g_rec_type) is
262 --
263 Cursor c_Description is
264 Select Description
265 from PQH_DE_OPERATIONS
266 Where Description = p_rec.Description;
267 l_Description PQH_DE_OPERATIONS.Description%TYPE;
268 l_proc varchar2(72) := g_package || 'Unique_Description';
269 Begin
270 hr_utility.set_location(l_proc, 10);
271 Open c_Description;
272 Fetch c_Description into l_Description;
273 If c_Description%ROWCOUNT > 0 Then
274 hr_utility.set_message(8302, 'PQH_DE_DUPVAL_Description');
275 Close c_Description;
276 fnd_message.raise_error;
277 End If;
278 Close c_Description;
279 Exception
280 when app_exception.application_exception then
281 if hr_multi_message.exception_add
282 (p_associated_column1 => 'PQH_DE_OPERATIONS.Description'
283 ) then
284 hr_utility.set_location(' Leaving:'||l_proc,60);
285 raise;
286 end if;
287 hr_utility.set_location(' Leaving:'||l_proc,70);
288 End Chk_Unique_Description;
289 -- ----------------------------------------------------------------------------
290 -- |-----------------------< Chk_Unique_OPERATION_NUMBER >--------------------|
291 -- ----------------------------------------------------------------------------
292 Procedure Chk_Unique_OPERATION_NUMBER
293 (p_rec in pqh_opl_shd.g_rec_type) is
294 --
295 Cursor c_OPERATION_NUMBER is
296 Select OPERATION_NUMBER
297 from PQH_DE_OPERATIONS
298 Where OPERATION_NUMBER = p_rec.OPERATION_NUMBER;
299 l_OPERATION_NUMBER PQH_DE_OPERATIONS.OPERATION_NUMBER%TYPE;
300 l_proc varchar2(72) := g_package || 'Unique_OPERATION_NUMBER';
301 Begin
302 hr_utility.set_location(l_proc, 10);
303 Open c_OPERATION_NUMBER;
304 Fetch c_OPERATION_NUMBER into l_OPERATION_NUMBER;
305 If c_OPERATION_NUMBER%ROWCOUNT > 0 Then
306 hr_utility.set_message(8302, 'PQH_DE_DUPVAL_OPERATIONS');
307 Close c_OPERATION_NUMBER;
308 fnd_message.raise_error;
309 End If;
310 Close c_OPERATION_NUMBER;
311 Exception
312 when app_exception.application_exception then
313 if hr_multi_message.exception_add
314 (p_associated_column1 => 'PQH_DE_OPERATIONS.OPERATION_NUMBER'
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_OPERATION_NUMBER;
321 -- ----------------------------------------------------------------------------
322 -- |---------------------------< insert_validate >----------------------------|
323 -- ----------------------------------------------------------------------------
324 Procedure insert_validate
325 (p_effective_date in date
326 ,p_rec in pqh_opl_shd.g_rec_type
327 ) is
328 --
329 l_proc varchar2(72) := g_package||'insert_validate';
330 --
331 Begin
332 hr_utility.set_location('Entering:'||l_proc, 5);
333 --
334 -- Call all supporting business operations
335 --
336 --
337 Chk_Unique_OPERATION_NUMBER (P_Rec);
338 Chk_Unique_Description(P_Rec);
339
340 -- EDIT_HERE: As this table does not have a mandatory business_group_id
341 -- column, ensure client_info is populated by calling a suitable
342 -- ???_???_bus.set_security_group_id procedure, or add one of the following
343 -- comments:
344 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
345 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
346 --
347 -- Validate Dependent Attributes
348 --
349 --
350 hr_utility.set_location(' Leaving:'||l_proc, 10);
351 End insert_validate;
352 --
353 -- ----------------------------------------------------------------------------
354 -- |---------------------------< update_validate >----------------------------|
355 -- ----------------------------------------------------------------------------
356 Procedure update_validate
357 (p_effective_date in date
358 ,p_rec in pqh_opl_shd.g_rec_type
359 ) is
360 --
361 l_proc varchar2(72) := g_package||'update_validate';
362 --
363 Begin
364 hr_utility.set_location('Entering:'||l_proc, 5);
365 --
366 -- Call all supporting business operations
367 --
368 --
369 -- Chk_Unique_OPERATION_NUMBER (P_Rec);
370 Chk_Unique_Description(P_Rec);
371 -- EDIT_HERE: As this table does not have a mandatory business_group_id
372 -- column, ensure client_info is populated by calling a suitable
373 -- ???_???_bus.set_security_group_id procedure, or add one of the following
374 -- comments:
375 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
376 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
377 --
378 -- Validate Dependent Attributes
379 --
380 chk_non_updateable_args
381 (p_effective_date => p_effective_date
382 ,p_rec => p_rec
383 );
384 --
385 --
386 hr_utility.set_location(' Leaving:'||l_proc, 10);
387 End update_validate;
388 --
389 -- ----------------------------------------------------------------------------
390 -- |---------------------------< delete_validate >----------------------------|
391 -- ----------------------------------------------------------------------------
392 Procedure delete_validate
393 (p_rec in pqh_opl_shd.g_rec_type
394 ) is
395 --
396 l_proc varchar2(72) := g_package||'delete_validate';
397 --
398 Begin
399 hr_utility.set_location('Entering:'||l_proc, 5);
400 --
401 -- Call all supporting business operations
402 --
403 Chk_delete(P_Rec);
404 hr_utility.set_location(' Leaving:'||l_proc, 10);
405 End delete_validate;
406 --
407 end pqh_opl_bus;