4 -- ----------------------------------------------------------------------------
1 Package Body pqh_rmn_bus as
2 /* $Header: pqrmnrhi.pkb 120.0 2005/05/29 02:33 appldev noship $ */
3 --
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_rmn_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_rate_matrix_node_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_rate_matrix_node_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 pbg.legislation_code
30 from per_business_groups_perf pbg
31 , pqh_rate_matrix_nodes rmn
32 where rmn.rate_matrix_node_id = p_rate_matrix_node_id
33 and pbg.business_group_id (+) = rmn.business_group_id;
34 --
35 -- Declare local variables
36 --
37 l_security_group_id number;
38 l_proc varchar2(72) := g_package||'set_security_group_id';
39 l_legislation_code varchar2(150);
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 => 'rate_matrix_node_id'
50 ,p_argument_value => p_rate_matrix_node_id
51 );
52 --
53 open csr_sec_grp;
57 if csr_sec_grp%notfound then
54 fetch csr_sec_grp into l_security_group_id
55 , l_legislation_code;
56 --
58 --
59 close csr_sec_grp;
60 --
61 -- The primary key is invalid therefore we must error
62 --
63 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
64 hr_multi_message.add
65 (p_associated_column1
66 => nvl(p_associated_column1,'RATE_MATRIX_NODE_ID')
67 );
68 --
69 else
70 close csr_sec_grp;
71 --
72 -- Set the security_group_id in CLIENT_INFO
73 --
74 hr_api.set_security_group_id
75 (p_security_group_id => l_security_group_id
76 );
77 --
78 -- Set the sessions legislation context in HR_SESSION_DATA
79 --
80 hr_api.set_legislation_context(l_legislation_code);
81 end if;
82 --
83 hr_utility.set_location(' Leaving:'|| l_proc, 20);
84 --
85 end set_security_group_id;
86 --
87 -- ---------------------------------------------------------------------------
88 -- |---------------------< return_legislation_code >-------------------------|
89 -- ---------------------------------------------------------------------------
90 --
91 Function return_legislation_code
92 (p_rate_matrix_node_id in number
93 )
94 Return Varchar2 Is
95 --
96 -- Declare cursor
97 --
98 cursor csr_leg_code is
99 select pbg.legislation_code
100 from per_business_groups_perf pbg
101 , pqh_rate_matrix_nodes rmn
102 where rmn.rate_matrix_node_id = p_rate_matrix_node_id
103 and pbg.business_group_id (+) = rmn.business_group_id;
104 --
105 -- Declare local variables
106 --
107 l_legislation_code varchar2(150);
108 l_proc varchar2(72) := g_package||'return_legislation_code';
109 --
110 Begin
111 --
112 hr_utility.set_location('Entering:'|| l_proc, 10);
113 --
114 -- Ensure that all the mandatory parameter are not null
115 --
116 hr_api.mandatory_arg_error
117 (p_api_name => l_proc
118 ,p_argument => 'rate_matrix_node_id'
119 ,p_argument_value => p_rate_matrix_node_id
120 );
121 --
122 if ( nvl(pqh_rmn_bus.g_rate_matrix_node_id, hr_api.g_number)
123 = p_rate_matrix_node_id) then
124 --
125 -- The legislation code has already been found with a previous
126 -- call to this function. Just return the value in the global
127 -- variable.
128 --
129 l_legislation_code := pqh_rmn_bus.g_legislation_code;
130 hr_utility.set_location(l_proc, 20);
131 else
132 --
133 -- The ID is different to the last call to this function
134 -- or this is the first call to this function.
135 --
136 open csr_leg_code;
137 fetch csr_leg_code into l_legislation_code;
138 --
139 if csr_leg_code%notfound then
140 --
141 -- The primary key is invalid therefore we must error
142 --
143 close csr_leg_code;
144 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
145 fnd_message.raise_error;
146 end if;
147 hr_utility.set_location(l_proc,30);
148 --
149 -- Set the global variables so the values are
150 -- available for the next call to this function.
151 --
152 close csr_leg_code;
153 pqh_rmn_bus.g_rate_matrix_node_id := p_rate_matrix_node_id;
154 pqh_rmn_bus.g_legislation_code := l_legislation_code;
155 end if;
156 hr_utility.set_location(' Leaving:'|| l_proc, 40);
157 return l_legislation_code;
158 end return_legislation_code;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |-----------------------< chk_non_updateable_args >------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 -- This procedure is used to ensure that non updateable attributes have
167 -- not been updated. If an attribute has been updated an error is generated.
168 --
169 -- Pre Conditions:
170 -- g_old_rec has been populated with details of the values currently in
171 -- the database.
172 --
173 -- In Arguments:
174 -- p_rec has been populated with the updated values the user would like the
175 -- record set to.
176 --
177 -- Post Success:
178 -- Processing continues if all the non updateable attributes have not
179 -- changed.
180 --
181 -- Post Failure:
182 -- An application error is raised if any of the non updatable attributes
183 -- have been altered.
184 --
185 -- {End Of Comments}
186 -- ----------------------------------------------------------------------------
187 Procedure chk_non_updateable_args
188 (p_rec in pqh_rmn_shd.g_rec_type
189 ) IS
190 --
191 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
192 --
193 Begin
194 --
195 -- Only proceed with the validation if a row exists for the current
196 -- record in the HR Schema.
197 --
198 IF NOT pqh_rmn_shd.api_updating
199 (p_rate_matrix_node_id => p_rec.rate_matrix_node_id
200 ,p_object_version_number => p_rec.object_version_number
201 ) THEN
202 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
203 fnd_message.set_token('PROCEDURE ', l_proc);
204 fnd_message.set_token('STEP ', '5');
205 fnd_message.raise_error;
209 -- not been updated.
206 END IF;
207 --
208 -- EDIT_HERE: Add checks to ensure non-updateable args have
210 --
211 if nvl(p_rec.business_group_id, hr_api.g_number) <>
212 nvl(pqh_rmn_shd.g_old_rec.business_group_id
213 ,hr_api.g_number
214 ) then
215 hr_api.argument_changed_error
216 (p_api_name => l_proc
217 ,p_argument => 'BUSINESS_GROUP_ID'
218 ,p_base_table => pqh_rmn_shd.g_tab_nam
219 );
220 end if;
221 --
222 End chk_non_updateable_args;
223 --
224 -- ----------------------------------------------------------------------------
225 -- |----------------------< chk_startup_action >------------------------------|
226 -- ----------------------------------------------------------------------------
227 --
228 -- Description:
229 -- This procedure will check that the current action is allowed according
230 -- to the current startup mode.
231 --
232 -- ----------------------------------------------------------------------------
233 PROCEDURE chk_startup_action
234 (p_insert IN boolean
235 ,p_business_group_id IN number
236 ,p_legislation_code IN varchar2
237 ,p_legislation_subgroup IN varchar2 DEFAULT NULL) IS
238 --
239 BEGIN
240 --
241 -- Call the supporting procedure to check startup mode
242 -- EDIT_HERE: The following call should be edited if certain types of rows
243 -- are not permitted.
244 IF (p_insert) THEN
245 hr_startup_data_api_support.chk_startup_action
246 (p_generic_allowed => TRUE
247 ,p_startup_allowed => TRUE
248 ,p_user_allowed => TRUE
249 ,p_business_group_id => p_business_group_id
250 ,p_legislation_code => p_legislation_code
251 ,p_legislation_subgroup => p_legislation_subgroup
252 );
253 ELSE
254 hr_startup_data_api_support.chk_upd_del_startup_action
255 (p_generic_allowed => TRUE
256 ,p_startup_allowed => TRUE
257 ,p_user_allowed => TRUE
258 ,p_business_group_id => p_business_group_id
259 ,p_legislation_code => p_legislation_code
260 ,p_legislation_subgroup => p_legislation_subgroup
261 );
262 END IF;
263 --
264 END chk_startup_action;
265 --
266 -- ----------------------------------------------------------------------------
267 -- |---------------------------< insert_validate >----------------------------|
268 -- ----------------------------------------------------------------------------
269 Procedure insert_validate
270 (p_rec in pqh_rmn_shd.g_rec_type
271 ) is
272 --
273 l_proc varchar2(72) := g_package||'insert_validate';
274 --
275 Begin
276 hr_utility.set_location('Entering:'||l_proc, 5);
277 --
278 -- Call all supporting business operations
279 --
280 --
281 chk_startup_action(true
282 ,p_rec.business_group_id
283 ,p_rec.legislation_code
284 );
285 IF hr_startup_data_api_support.g_startup_mode
286 NOT IN ('GENERIC','STARTUP') THEN
287 --
288 -- Validate Important Attributes
289 --
290 hr_api.validate_bus_grp_id
291 (p_business_group_id => p_rec.business_group_id
292 ,p_associated_column1 => pqh_rmn_shd.g_tab_nam
293 || '.BUSINESS_GROUP_ID');
294 --
295 -- after validating the set of important attributes,
296 -- if Multiple Message Detection is enabled and at least
297 -- one error has been found then abort further validation.
298 --
299 hr_multi_message.end_validation_set;
300 END IF;
301 --
302 --
303 -- Validate Dependent Attributes
304 --
305 --
306 hr_utility.set_location(' Leaving:'||l_proc, 10);
307 End insert_validate;
308 --
309 -- ----------------------------------------------------------------------------
310 -- |---------------------------< update_validate >----------------------------|
311 -- ----------------------------------------------------------------------------
312 Procedure update_validate
313 (p_rec in pqh_rmn_shd.g_rec_type
314 ) is
315 --
316 l_proc varchar2(72) := g_package||'update_validate';
317 --
318 Begin
319 hr_utility.set_location('Entering:'||l_proc, 5);
320 --
321 -- Call all supporting business operations
322 --
323 --
324 chk_startup_action(false
325 ,p_rec.business_group_id
326 ,p_rec.legislation_code
327 );
328 IF hr_startup_data_api_support.g_startup_mode
329 NOT IN ('GENERIC','STARTUP') THEN
330 --
331 -- Validate Important Attributes
332 --
333 hr_api.validate_bus_grp_id
334 (p_business_group_id => p_rec.business_group_id
335 ,p_associated_column1 => pqh_rmn_shd.g_tab_nam
336 || '.BUSINESS_GROUP_ID');
337 --
338 -- After validating the set of important attributes,
339 -- if Multiple Message Detection is enabled and at least
340 -- one error has been found then abort further validation.
341 --
342 hr_multi_message.end_validation_set;
343 END IF;
344 --
345 --
346 -- Validate Dependent Attributes
347 --
348 chk_non_updateable_args
349 (p_rec => p_rec
350 );
351 --
352 --
353 hr_utility.set_location(' Leaving:'||l_proc, 10);
354 End update_validate;
355 --
356 -- ----------------------------------------------------------------------------
357 -- |---------------------------< delete_validate >----------------------------|
358 -- ----------------------------------------------------------------------------
359 Procedure delete_validate
360 (p_rec in pqh_rmn_shd.g_rec_type
361 ) is
362 --
363 l_proc varchar2(72) := g_package||'delete_validate';
364 --
365 Begin
366 hr_utility.set_location('Entering:'||l_proc, 5);
367 --
368 --
369 chk_startup_action(false
370 ,pqh_rmn_shd.g_old_rec.business_group_id
371 ,pqh_rmn_shd.g_old_rec.legislation_code
372 );
373 IF hr_startup_data_api_support.g_startup_mode
374 NOT IN ('GENERIC','STARTUP') THEN
375 --
376 -- Validate Important Attributes
377 --
378 --
379 -- After validating the set of important attributes,
380 -- if Multiple Message Detection is enabled and at least
381 -- one error has been found then abort further validation.
382 --
383 hr_multi_message.end_validation_set;
384 END IF;
385 --
386 -- Call all supporting business operations
387 --
388 hr_utility.set_location(' Leaving:'||l_proc, 10);
389 End delete_validate;
390 --
391 end pqh_rmn_bus;