1 Package Body pqh_ftr_bus as
2 /* $Header: pqftrrhi.pkb 115.4 2002/11/27 23:43:38 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_ftr_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_wrkplc_vldtn_jobftr_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_wrkplc_vldtn_jobftr_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 from per_business_groups pbg
30 , pqh_de_wrkplc_vldtn_jobftrs ftr
31 where ftr.wrkplc_vldtn_jobftr_id = p_wrkplc_vldtn_jobftr_id
32 and pbg.business_group_id = ftr.business_group_id;
33 --
34 -- Declare local variables
35 --
36 l_security_group_id number;
37 l_proc varchar2(72) := g_package||'set_security_group_id';
38 --
39 begin
40 --
41 hr_utility.set_location('Entering:'|| l_proc, 10);
42 --
43 -- Ensure that all the mandatory parameter are not null
44 --
45 hr_api.mandatory_arg_error
46 (p_api_name => l_proc
47 ,p_argument => 'wrkplc_vldtn_jobftr_id'
48 ,p_argument_value => p_wrkplc_vldtn_jobftr_id
49 );
50 --
51 open csr_sec_grp;
52 fetch csr_sec_grp into l_security_group_id;
53 --
54 if csr_sec_grp%notfound then
55 --
56 close csr_sec_grp;
57 --
58 -- The primary key is invalid therefore we must error
59 --
60 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
61 hr_multi_message.add
62 (p_associated_column1
63 => nvl(p_associated_column1,'WRKPLC_VLDTN_JOBFTR_ID')
64 );
65 --
66 else
67 close csr_sec_grp;
68 --
69 -- Set the security_group_id in CLIENT_INFO
70 --
71 hr_api.set_security_group_id
72 (p_security_group_id => l_security_group_id
73 );
74 end if;
75 --
76 hr_utility.set_location(' Leaving:'|| l_proc, 20);
77 --
78 end set_security_group_id;
79 --
80 -- ---------------------------------------------------------------------------
81 -- |---------------------< return_legislation_code >-------------------------|
82 -- ---------------------------------------------------------------------------
83 --
84 Function return_legislation_code
85 (p_wrkplc_vldtn_jobftr_id in number
86 )
87 Return Varchar2 Is
88 --
89 -- Declare cursor
90 --
91 cursor csr_leg_code is
92 select pbg.legislation_code
93 from per_business_groups pbg
94 , pqh_de_wrkplc_vldtn_jobftrs ftr
95 where ftr.wrkplc_vldtn_jobftr_id = p_wrkplc_vldtn_jobftr_id
96 and pbg.business_group_id = ftr.business_group_id;
97 --
98 -- Declare local variables
99 --
100 l_legislation_code varchar2(150);
101 l_proc varchar2(72) := g_package||'return_legislation_code';
102 --
103 Begin
104 --
105 hr_utility.set_location('Entering:'|| l_proc, 10);
106 --
107 -- Ensure that all the mandatory parameter are not null
108 --
109 hr_api.mandatory_arg_error
110 (p_api_name => l_proc
111 ,p_argument => 'wrkplc_vldtn_jobftr_id'
112 ,p_argument_value => p_wrkplc_vldtn_jobftr_id
113 );
114 --
115 if ( nvl(pqh_ftr_bus.g_wrkplc_vldtn_jobftr_id, hr_api.g_number)
116 = p_wrkplc_vldtn_jobftr_id) then
117 --
118 -- The legislation code has already been found with a previous
119 -- call to this function. Just return the value in the global
120 -- variable.
121 --
122 l_legislation_code := pqh_ftr_bus.g_legislation_code;
123 hr_utility.set_location(l_proc, 20);
124 else
125 --
126 -- The ID is different to the last call to this function
127 -- or this is the first call to this function.
128 --
129 open csr_leg_code;
130 fetch csr_leg_code into l_legislation_code;
131 --
132 if csr_leg_code%notfound then
133 --
134 -- The primary key is invalid therefore we must error
135 --
136 close csr_leg_code;
137 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
138 fnd_message.raise_error;
139 end if;
140 hr_utility.set_location(l_proc,30);
141 --
142 -- Set the global variables so the values are
143 -- available for the next call to this function.
144 --
145 close csr_leg_code;
146 pqh_ftr_bus.g_wrkplc_vldtn_jobftr_id := p_wrkplc_vldtn_jobftr_id;
147 pqh_ftr_bus.g_legislation_code := l_legislation_code;
148 end if;
149 hr_utility.set_location(' Leaving:'|| l_proc, 40);
150 return l_legislation_code;
151 end return_legislation_code;
152 --
153 -- ----------------------------------------------------------------------------
154 -- |-----------------------< chk_non_updateable_args >------------------------|
155 -- ----------------------------------------------------------------------------
156 -- {Start Of Comments}
157 --
158 -- Description:
159 -- This procedure is used to ensure that non updateable attributes have
160 -- not been updated. If an attribute has been updated an error is generated.
161 --
162 -- Pre Conditions:
163 -- g_old_rec has been populated with details of the values currently in
164 -- the database.
165 --
166 -- In Arguments:
167 -- p_rec has been populated with the updated values the user would like the
168 -- record set to.
169 --
170 -- Post Success:
171 -- Processing continues if all the non updateable attributes have not
172 -- changed.
173 --
174 -- Post Failure:
175 -- An application error is raised if any of the non updatable attributes
176 -- have been altered.
177 --
178 -- {End Of Comments}
179 -- ----------------------------------------------------------------------------
180 Procedure chk_non_updateable_args
181 (p_effective_date in date
182 ,p_rec in pqh_ftr_shd.g_rec_type
183 ) IS
184 --
185 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
186 --
187 Begin
188 --
189 -- Only proceed with the validation if a row exists for the current
190 -- record in the HR Schema.
191 --
192 IF NOT pqh_ftr_shd.api_updating
193 (p_wrkplc_vldtn_jobftr_id => p_rec.wrkplc_vldtn_jobftr_id
194 ,p_object_version_number => p_rec.object_version_number
195 ) THEN
196 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
197 fnd_message.set_token('PROCEDURE ', l_proc);
198 fnd_message.set_token('STEP ', '5');
199 fnd_message.raise_error;
200 END IF;
201 --
202 -- EDIT_HERE: Add checks to ensure non-updateable args have
203 -- not been updated.
204 --
205 End chk_non_updateable_args;
206
207 Procedure Chk_Jobftr
208 (p_effective_date in date
209 ,p_Jobftr_Code in Varchar2) is
210 --
211 l_proc varchar2(72) := g_package||'Chk_Jobftr';
212 l_Result Varchar2(1);
213 --
214 Cursor Jobftr is
215 Select '1' from
216 Hr_Lookups
217 Where Lookup_Type = 'DE_PQH_JOB_FEATURE'
218 and Lookup_Code = p_Jobftr_Code
219 and P_Effective_date
220 between Nvl(START_DATE_ACTIVE,Trunc(Sysdate))
221 and Nvl(END_DATE_ACTIVE,Trunc(Sysdate))
222 and ENABLED_FLAG = 'Y';
223 Begin
224 hr_utility.set_location('Entering:'||l_proc, 5);
225 --
226 Open JobFtr;
227 Fetch JobFtr into l_Result;
228 If JobFtr%NOTFOUND Then
229 Close Jobftr;
230 hr_utility.set_message(8302,'PQH_DE_FTR_VALDTN');
231 hr_utility.raise_error;
232 End If;
233 Exception
234 when app_exception.application_exception then
235 if hr_multi_message.exception_add
236 (p_associated_column1 => 'PQH_DE_WRKPLC_VLDTN_JOBFTRS.JOB_FEATURE_CODE'
237 ) then
238 hr_utility.set_location(' Leaving:'||l_proc,60);
239 raise;
240 end if;
241 hr_utility.set_location(' Leaving:'||l_proc,70);
242 End Chk_Jobftr;
243 --
244 -- ----------------------------------------------------------------------------
245 -- |---------------------------< insert_validate >----------------------------|
246 -- ----------------------------------------------------------------------------
247 Procedure insert_validate
248 (p_effective_date in date
249 ,p_rec in pqh_ftr_shd.g_rec_type
250 ) is
251 --
252 l_proc varchar2(72) := g_package||'insert_validate';
253 --
254 Begin
255 hr_utility.set_location('Entering:'||l_proc, 5);
256 --
257 -- Call all supporting business operations
258 --
259 hr_api.validate_bus_grp_id
260 (p_business_group_id => p_rec.business_group_id
261 ,p_associated_column1 => pqh_ftr_shd.g_tab_nam
262 || '.BUSINESS_GROUP_ID');
263 --
264 -- After validating the set of important attributes,
265 -- if Multiple Message detection is enabled and at least
266 -- one error has been found then abort further validation.
267 --
268 hr_multi_message.end_validation_set;
269 --
270 -- Validate Dependent Attributes
271 --
272 Chk_Jobftr(p_effective_date, p_Rec.JOB_FEATURE_CODE);
273 --
274 hr_utility.set_location(' Leaving:'||l_proc, 10);
275 End insert_validate;
276 --
277 -- ----------------------------------------------------------------------------
278 -- |---------------------------< update_validate >----------------------------|
279 -- ----------------------------------------------------------------------------
280 Procedure update_validate
281 (p_effective_date in date
282 ,p_rec in pqh_ftr_shd.g_rec_type
283 ) is
284 --
285 l_proc varchar2(72) := g_package||'update_validate';
286 --
287 Begin
288 hr_utility.set_location('Entering:'||l_proc, 5);
289 --
290 -- Call all supporting business operations
291 --
292 hr_api.validate_bus_grp_id
293 (p_business_group_id => p_rec.business_group_id
294 ,p_associated_column1 => pqh_ftr_shd.g_tab_nam
295 || '.BUSINESS_GROUP_ID');
296 --
297 -- After validating the set of important attributes,
298 -- if Multiple Message detection is enabled and at least
299 -- one error has been found then abort further validation.
300 --
301 hr_multi_message.end_validation_set;
302 --
303 -- Validate Dependent Attributes
304 --
305 chk_non_updateable_args
306 (p_effective_date => p_effective_date
307 ,p_rec => p_rec
308 );
309 --
310 Chk_Jobftr(p_effective_date, p_Rec.JOB_FEATURE_CODE);
311 --
312 hr_utility.set_location(' Leaving:'||l_proc, 10);
313 End update_validate;
314 --
315 -- ----------------------------------------------------------------------------
316 -- |---------------------------< delete_validate >----------------------------|
317 -- ----------------------------------------------------------------------------
318 Procedure delete_validate
319 (p_rec in pqh_ftr_shd.g_rec_type
320 ) is
321 --
322 l_proc varchar2(72) := g_package||'delete_validate';
323 --
324 Begin
325 hr_utility.set_location('Entering:'||l_proc, 5);
326 --
327 -- Call all supporting business operations
328 --
329 hr_utility.set_location(' Leaving:'||l_proc, 10);
330 End delete_validate;
331 --
332 end pqh_ftr_bus;