1 Package Body psp_erd_bus as
2 /* $Header: PSPEDRHB.pls 120.2 2006/01/25 01:49 dpaudel noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' psp_erd_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_effort_report_detail_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_effort_report_detail_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 -- psp_eff_report_details and PER_BUSINESS_GROUPS_PERF
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 pbg.legislation_code
35 from per_business_groups_perf pbg
36 , psp_eff_report_details erd
37 , psp_eff_reports per
38 where erd.effort_report_detail_id = p_effort_report_detail_id
39 and erd.effort_report_id = per.effort_report_id
40 and pbg.business_group_id = per.business_group_id ;
41
42 --
43 -- Declare local variables
44 --
45 l_security_group_id number;
46 l_proc varchar2(72) := g_package||'set_security_group_id';
47 l_legislation_code varchar2(150);
48 --
49 begin
50 --
51 hr_utility.set_location('Entering:'|| l_proc, 10);
52 --
53 -- Ensure that all the mandatory parameter are not null
54 --
55 hr_api.mandatory_arg_error
56 (p_api_name => l_proc
57 ,p_argument => 'effort_report_detail_id'
58 ,p_argument_value => p_effort_report_detail_id
59 );
60 --
61 open csr_sec_grp;
62 fetch csr_sec_grp into l_security_group_id
63 , l_legislation_code;
64 --
65 if csr_sec_grp%notfound then
66 --
67 close csr_sec_grp;
68 --
69 -- The primary key is invalid therefore we must error
70 --
71 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
72 hr_multi_message.add
73 (p_associated_column1
74 => nvl(p_associated_column1,'EFFORT_REPORT_DETAIL_ID')
75 );
76 --
77 else
78 close csr_sec_grp;
79 --
80 -- Set the security_group_id in CLIENT_INFO
81 --
82 hr_api.set_security_group_id
83 (p_security_group_id => l_security_group_id
84 );
85 --
86 -- Set the sessions legislation context in HR_SESSION_DATA
87 --
88 hr_api.set_legislation_context(l_legislation_code);
89 end if;
90 --
91 hr_utility.set_location(' Leaving:'|| l_proc, 20);
92 --
93 end set_security_group_id;
94 --
95 -- ---------------------------------------------------------------------------
96 -- |---------------------< return_legislation_code >-------------------------|
97 -- ---------------------------------------------------------------------------
98 --
99 Function return_legislation_code
100 (p_effort_report_detail_id in number
101 )
102 Return Varchar2 Is
103 --
104 -- Declare cursor
105 --
106 -- EDIT_HERE In the following cursor statement add join(s) between
107 -- psp_eff_report_details and PER_BUSINESS_GROUPS_PERF
108 -- so that the legislation_code for
109 -- the current business group context can be derived.
110 -- Remove this comment when the edit has been completed.
111 cursor csr_leg_code is
112 select pbg.legislation_code
113 from per_business_groups_perf pbg
114 , psp_eff_report_details erd
115 , psp_eff_reports per
116 where erd.effort_report_detail_id = p_effort_report_detail_id
117 and erd.effort_report_id = per.effort_report_id
118 and pbg.business_group_id = per.business_group_id ;
119 --
120 -- Declare local variables
121 --
122 l_legislation_code varchar2(150);
123 l_proc varchar2(72) := g_package||'return_legislation_code';
124 --
125 Begin
126 --
127 hr_utility.set_location('Entering:'|| l_proc, 10);
128 --
129 -- Ensure that all the mandatory parameter are not null
130 --
131 hr_api.mandatory_arg_error
132 (p_api_name => l_proc
133 ,p_argument => 'effort_report_detail_id'
134 ,p_argument_value => p_effort_report_detail_id
135 );
136 --
137 if ( nvl(psp_erd_bus.g_effort_report_detail_id, hr_api.g_number)
138 = p_effort_report_detail_id) then
139 --
140 -- The legislation code has already been found with a previous
141 -- call to this function. Just return the value in the global
142 -- variable.
143 --
144 l_legislation_code := psp_erd_bus.g_legislation_code;
145 hr_utility.set_location(l_proc, 20);
146 else
147 --
148 -- The ID is different to the last call to this function
149 -- or this is the first call to this function.
150 --
151 open csr_leg_code;
152 fetch csr_leg_code into l_legislation_code;
153 --
154 if csr_leg_code%notfound then
155 --
156 -- The primary key is invalid therefore we must error
157 --
158 close csr_leg_code;
159 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
160 fnd_message.raise_error;
161 end if;
162 hr_utility.set_location(l_proc,30);
163 --
164 -- Set the global variables so the values are
165 -- available for the next call to this function.
166 --
167 close csr_leg_code;
168 psp_erd_bus.g_effort_report_detail_id := p_effort_report_detail_id;
169 psp_erd_bus.g_legislation_code := l_legislation_code;
170 end if;
171 hr_utility.set_location(' Leaving:'|| l_proc, 40);
172 return l_legislation_code;
173 end return_legislation_code;
174 --
175 -- ----------------------------------------------------------------------------
176 -- |------------------------------< chk_df >----------------------------------|
177 -- ----------------------------------------------------------------------------
178 --
179 -- Description:
180 -- Validates all the Descriptive Flexfield values.
181 --
182 -- Prerequisites:
183 -- All other columns have been validated. Must be called as the
184 -- last step from insert_validate and update_validate.
185 --
186 -- In Arguments:
187 -- p_rec
188 --
189 -- Post Success:
190 -- If the Descriptive Flexfield structure column and data values are
191 -- all valid this procedure will end normally and processing will
192 -- continue.
193 --
194 -- Post Failure:
195 -- If the Descriptive Flexfield structure column value or any of
196 -- the data values are invalid then an application error is raised as
197 -- a PL/SQL exception.
198 --
199 -- Access Status:
200 -- Internal Row Handler Use Only.
201 --
202 -- ----------------------------------------------------------------------------
203 procedure chk_df
204 (p_rec in psp_erd_shd.g_rec_type
205 ) is
206 --
207 l_proc varchar2(72) := g_package || 'chk_df';
208 --
209 begin
210 hr_utility.set_location('Entering:'||l_proc,10);
211 --
212 if ((p_rec.effort_report_detail_id is not null) and (
213 nvl(psp_erd_shd.g_old_rec.attribute1, hr_api.g_varchar2) <>
214 nvl(p_rec.attribute1, hr_api.g_varchar2) or
215 nvl(psp_erd_shd.g_old_rec.attribute2, hr_api.g_varchar2) <>
216 nvl(p_rec.attribute2, hr_api.g_varchar2) or
217 nvl(psp_erd_shd.g_old_rec.attribute3, hr_api.g_varchar2) <>
218 nvl(p_rec.attribute3, hr_api.g_varchar2) or
219 nvl(psp_erd_shd.g_old_rec.attribute4, hr_api.g_varchar2) <>
220 nvl(p_rec.attribute4, hr_api.g_varchar2) or
221 nvl(psp_erd_shd.g_old_rec.attribute5, hr_api.g_varchar2) <>
222 nvl(p_rec.attribute5, hr_api.g_varchar2) or
223 nvl(psp_erd_shd.g_old_rec.attribute6, hr_api.g_varchar2) <>
224 nvl(p_rec.attribute6, hr_api.g_varchar2) or
225 nvl(psp_erd_shd.g_old_rec.attribute7, hr_api.g_varchar2) <>
226 nvl(p_rec.attribute7, hr_api.g_varchar2) or
227 nvl(psp_erd_shd.g_old_rec.attribute8, hr_api.g_varchar2) <>
228 nvl(p_rec.attribute8, hr_api.g_varchar2) or
229 nvl(psp_erd_shd.g_old_rec.attribute9, hr_api.g_varchar2) <>
230 nvl(p_rec.attribute9, hr_api.g_varchar2) or
231 nvl(psp_erd_shd.g_old_rec.attribute10, hr_api.g_varchar2) <>
232 nvl(p_rec.attribute10, hr_api.g_varchar2) ))
233 or (p_rec.effort_report_detail_id is null) then
234 --
235 -- Only execute the validation if absolutely necessary:
236 -- a) During update, the structure column value or any
237 -- of the attribute values have actually changed.
238 -- b) During insert.
239 --
240 hr_dflex_utility.ins_or_upd_descflex_attribs
241 (p_appl_short_name => 'PSP'
242 ,p_descflex_name => 'EDIT_HERE: Enter descflex name'
243 ,p_attribute_category => 'EDIT_HERE: Attribute category col'
244 ,p_attribute1_name => 'ATTRIBUTE1'
245 ,p_attribute1_value => p_rec.attribute1
246 ,p_attribute2_name => 'ATTRIBUTE2'
247 ,p_attribute2_value => p_rec.attribute2
248 ,p_attribute3_name => 'ATTRIBUTE3'
249 ,p_attribute3_value => p_rec.attribute3
250 ,p_attribute4_name => 'ATTRIBUTE4'
251 ,p_attribute4_value => p_rec.attribute4
252 ,p_attribute5_name => 'ATTRIBUTE5'
253 ,p_attribute5_value => p_rec.attribute5
254 ,p_attribute6_name => 'ATTRIBUTE6'
255 ,p_attribute6_value => p_rec.attribute6
256 ,p_attribute7_name => 'ATTRIBUTE7'
257 ,p_attribute7_value => p_rec.attribute7
258 ,p_attribute8_name => 'ATTRIBUTE8'
259 ,p_attribute8_value => p_rec.attribute8
260 ,p_attribute9_name => 'ATTRIBUTE9'
261 ,p_attribute9_value => p_rec.attribute9
262 ,p_attribute10_name => 'ATTRIBUTE10'
263 ,p_attribute10_value => p_rec.attribute10
264 );
265 end if;
266 --
267 hr_utility.set_location(' Leaving:'||l_proc,20);
268 end chk_df;
269 --
270 -- ----------------------------------------------------------------------------
271 -- |-----------------------< chk_non_updateable_args >------------------------|
272 -- ----------------------------------------------------------------------------
273 -- {Start Of Comments}
274 --
275 -- Description:
276 -- This procedure is used to ensure that non updateable attributes have
277 -- not been updated. If an attribute has been updated an error is generated.
278 --
279 -- Pre Conditions:
280 -- g_old_rec has been populated with details of the values currently in
281 -- the database.
282 --
283 -- In Arguments:
284 -- p_rec has been populated with the updated values the user would like the
285 -- record set to.
286 --
287 -- Post Success:
288 -- Processing continues if all the non updateable attributes have not
289 -- changed.
290 --
291 -- Post Failure:
292 -- An application error is raised if any of the non updatable attributes
293 -- have been altered.
294 --
295 -- {End Of Comments}
296 -- ----------------------------------------------------------------------------
297 Procedure chk_non_updateable_args
298 (p_rec in psp_erd_shd.g_rec_type
299 ) IS
300 --
301 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
302 --
303 Begin
304 --
305 -- Only proceed with the validation if a row exists for the current
306 -- record in the HR Schema.
307 --
308 IF NOT psp_erd_shd.api_updating
309 (p_effort_report_detail_id => p_rec.effort_report_detail_id
310 ,p_object_version_number => p_rec.object_version_number
311 ) THEN
312 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
313 fnd_message.set_token('PROCEDURE ', l_proc);
314 fnd_message.set_token('STEP ', '5');
315 fnd_message.raise_error;
316 END IF;
317 --
318 -- EDIT_HERE: Add checks to ensure non-updateable args have
319 -- not been updated.
320 --
321 End chk_non_updateable_args;
322 --
323 -- ----------------------------------------------------------------------------
324 -- |---------------------------< insert_validate >----------------------------|
325 -- ----------------------------------------------------------------------------
326 Procedure insert_validate
327 (p_rec in psp_erd_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 --
338 -- EDIT_HERE: As this table does not have a mandatory business_group_id
339 -- column, ensure client_info is populated by calling a suitable
340 -- ???_???_bus.set_security_group_id procedure, or add one of the following
341 -- comments:
342 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
343 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
344 --
345 -- Validate Dependent Attributes
346 --
347 --
348 -- psp_erd_bus.chk_df(p_rec);
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_rec in psp_erd_shd.g_rec_type
358 ) is
359 --
360 l_proc varchar2(72) := g_package||'update_validate';
361 --
362 Begin
363 hr_utility.set_location('Entering:'||l_proc, 5);
364 --
365 -- Call all supporting business operations
366 --
367 --
368 -- EDIT_HERE: As this table does not have a mandatory business_group_id
369 -- column, ensure client_info is populated by calling a suitable
370 -- ???_???_bus.set_security_group_id procedure, or add one of the following
371 -- comments:
372 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
373 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
374 --
375 -- Validate Dependent Attributes
376 --
377 chk_non_updateable_args
378 (p_rec => p_rec
379 );
380 --
381 --
382 -- psp_erd_bus.chk_df(p_rec);
383 --
384 hr_utility.set_location(' Leaving:'||l_proc, 10);
385 End update_validate;
386 --
387 -- ----------------------------------------------------------------------------
388 -- |---------------------------< delete_validate >----------------------------|
389 -- ----------------------------------------------------------------------------
390 Procedure delete_validate
391 (p_rec in psp_erd_shd.g_rec_type
392 ) is
393 --
394 l_proc varchar2(72) := g_package||'delete_validate';
395 --
396 Begin
397 hr_utility.set_location('Entering:'||l_proc, 5);
398 --
399 -- Call all supporting business operations
400 --
401 hr_utility.set_location(' Leaving:'||l_proc, 10);
402 End delete_validate;
403 --
404 end psp_erd_bus;