1 Package Body hr_pft_bus as
2 /* $Header: hrpftrhi.pkb 120.0 2005/05/31 02:07:40 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_pft_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_position_id number default null;
15 g_language varchar2(4) default null;
16 --
17 -- ---------------------------------------------------------------------------
18 -- |----------------------< set_security_group_id >--------------------------|
19 -- ---------------------------------------------------------------------------
20 --
21 Procedure set_security_group_id
22 (p_position_id in number
23 ,p_associated_column1 in varchar2 default null
24 ) is
25 --
26 -- Declare cursor
27 --
28 -- EDIT_HERE In the following cursor statement add join(s) between
29 -- hr_all_positions_f_tl and PER_BUSINESS_GROUPS
30 -- so that the security_group_id for
31 -- the current business group context can be derived.
32 -- Remove this comment when the edit has been completed.
33 /*cursor csr_sec_grp is
34 select pbg.security_group_id
35 from per_business_groups pbg
36 , hr_all_positions_f_tl pft
37 -- , EDIT_HERE table_name(s) 333
38 where pft.position_id = p_position_id; */
39 -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
40
41 -- Bug fix 3648750 start here.
42 -- cursor modified to improve performance.
43
44 cursor csr_sec_grp is
45 select pbg.security_group_id
46 from per_business_groups pbg
47 ,hr_all_positions_f_tl pft
48 ,hr_all_positions_f pf
49 where pf.position_id =p_position_id
50 and pft.position_id = pf.position_id
51 and pf.business_group_id = pbg.business_group_id;
52
53 -- bug fix 3648750 ends here.
54 --
55 -- Declare local variables
56 --
57 l_security_group_id number;
58 l_proc varchar2(72) := g_package||'set_security_group_id';
59 --
60 begin
61 --
62 hr_utility.set_location('Entering:'|| l_proc, 10);
63 --
64 -- Ensure that all the mandatory parameter are not null
65 --
66 hr_api.mandatory_arg_error
67 (p_api_name => l_proc
68 ,p_argument => 'position_id'
69 ,p_argument_value => p_position_id
70 );
71 --
72 --
73 open csr_sec_grp;
74 fetch csr_sec_grp into l_security_group_id;
75 --
76 if csr_sec_grp%notfound then
77 --
78 close csr_sec_grp;
79 --
80 -- The primary key is invalid therefore we must error
81 --
82 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
83 hr_multi_message.add
84 (p_associated_column1
85 => nvl(p_associated_column1,'POSITION_ID')
86 );
87 --
88 else
89 close csr_sec_grp;
90 --
91 -- Set the security_group_id in CLIENT_INFO
92 --
93 hr_api.set_security_group_id
94 (p_security_group_id => l_security_group_id
95 );
96 end if;
97 --
98 hr_utility.set_location(' Leaving:'|| l_proc, 20);
99 --
100 end set_security_group_id;
101 --
102 -- ---------------------------------------------------------------------------
103 -- |---------------------< return_legislation_code >-------------------------|
104 -- ---------------------------------------------------------------------------
105 --
106 Function return_legislation_code
107 (p_position_id in number
108 ,p_language in varchar2
109 )
110 Return Varchar2 Is
111 --
112 -- Declare cursor
113 --
114 -- EDIT_HERE In the following cursor statement add join(s) between
115 -- hr_all_positions_f_tl and PER_BUSINESS_GROUPS
116 -- so that the legislation_code for
117 -- the current business group context can be derived.
118 -- Remove this comment when the edit has been completed.
119 cursor csr_leg_code is
120 select pbg.legislation_code
121 from per_business_groups pbg
122 , hr_all_positions_f_tl pft
123 , hr_positions_f pof
124 where pft.position_id = p_position_id
125 and pft.language = p_language
126 and pof.position_id = pft.position_id
127 and pbg.business_group_id = pof.business_group_id;
128 --
129 -- Declare local variables
130 --
131 l_legislation_code varchar2(150);
132 l_proc varchar2(72) := g_package||'return_legislation_code';
133 --
134 Begin
135 --
136 hr_utility.set_location('Entering:'|| l_proc, 10);
137 --
138 -- Ensure that all the mandatory parameter are not null
139 --
140 hr_api.mandatory_arg_error
141 (p_api_name => l_proc
142 ,p_argument => 'position_id'
143 ,p_argument_value => p_position_id
144 );
145 --
146 --
147 if (( nvl(hr_pft_bus.g_position_id, hr_api.g_number)
148 = p_position_id)
149 and ( nvl(hr_pft_bus.g_language, hr_api.g_varchar2)
150 = p_language)) then
151 --
152 -- The legislation code has already been found with a previous
153 -- call to this function. Just return the value in the global
154 -- variable.
155 --
156 l_legislation_code := hr_pft_bus.g_legislation_code;
157 hr_utility.set_location(l_proc, 20);
158 else
159 --
160 -- The ID is different to the last call to this function
161 -- or this is the first call to this function.
162 --
163 open csr_leg_code;
164 fetch csr_leg_code into l_legislation_code;
165 --
166 if csr_leg_code%notfound then
167 --
168 -- The primary key is invalid therefore we must error
169 --
170 close csr_leg_code;
171 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
172 fnd_message.raise_error;
173 end if;
174 hr_utility.set_location(l_proc,30);
175 --
176 -- Set the global variables so the values are
177 -- available for the next call to this function.
178 --
179 close csr_leg_code;
180 hr_pft_bus.g_position_id := p_position_id;
181 hr_pft_bus.g_language := p_language;
182 hr_pft_bus.g_legislation_code := l_legislation_code;
183 end if;
184 hr_utility.set_location(' Leaving:'|| l_proc, 40);
185 return l_legislation_code;
186 end return_legislation_code;
187 --
188 -- ----------------------------------------------------------------------------
189 -- |-----------------------< chk_non_updateable_args >------------------------|
190 -- ----------------------------------------------------------------------------
191 -- {Start Of Comments}
192 --
193 -- Description:
194 -- This procedure is used to ensure that non updateable attributes have
195 -- not been updated. If an attribute has been updated an error is generated.
196 --
197 -- Pre Conditions:
198 -- g_old_rec has been populated with details of the values currently in
199 -- the database.
200 --
201 -- In Arguments:
202 -- p_rec has been populated with the updated values the user would like the
203 -- record set to.
204 --
205 -- Post Success:
206 -- Processing continues if all the non updateable attributes have not
207 -- changed.
208 --
209 -- Post Failure:
210 -- An application error is raised if any of the non updatable attributes
211 -- have been altered.
212 --
213 -- {End Of Comments}
214 -- ----------------------------------------------------------------------------
215 Procedure chk_non_updateable_args
216 (p_rec in hr_pft_shd.g_rec_type
217 ) IS
218 --
219 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
220 --
221 Begin
222 --
223 -- Only proceed with the validation if a row exists for the current
224 -- record in the HR Schema.
225 --
226 IF NOT hr_pft_shd.api_updating
227 (p_position_id => p_rec.position_id
228 ,p_language => p_rec.language
229 ) THEN
230 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
231 fnd_message.set_token('PROCEDURE ', l_proc);
232 fnd_message.set_token('STEP ', '5');
233 fnd_message.raise_error;
234 END IF;
235 --
236 -- PMFLETCH No non-updateable args
237 --
238 End chk_non_updateable_args;
239 --
240 -- ----------------------------------------------------------------------------
241 -- |---------------------------< insert_validate >----------------------------|
242 -- ----------------------------------------------------------------------------
243 Procedure insert_validate
244 (p_rec in hr_pft_shd.g_rec_type
245 ) is
246 --
247 l_proc varchar2(72) := g_package||'insert_validate';
248 --
249 Begin
250 hr_utility.set_location('Entering:'||l_proc, 5);
251 --
252 -- Call all supporting business operations
253 --
254 -- PMFLETCH call to base table set_security_group_id
255 -- Temporarily commented out - awaiting info from Adrian
256 --hr_psf_bus.set_security_group_id(p_rec.position_id);
257 --
258 --
259 -- PMFLETCH Base table does validate uniqueness of name, but because name is
260 -- derived from concatenated key flex segments, and we are not translating
261 -- free format text within tose segments, then no name validation is required
262 -- for the TL table.
263 --
264 -- Validate Dependent Attributes
265 --
266 --
267 hr_utility.set_location(' Leaving:'||l_proc, 10);
268 End insert_validate;
269 --
270 -- ----------------------------------------------------------------------------
271 -- |---------------------------< update_validate >----------------------------|
272 -- ----------------------------------------------------------------------------
273 Procedure update_validate
274 (p_rec in hr_pft_shd.g_rec_type
275 ) is
276 --
277 l_proc varchar2(72) := g_package||'update_validate';
278 --
279 Begin
280 hr_utility.set_location('Entering:'||l_proc, 5);
281 --
282 -- Call all supporting business operations
283 --
284 -- PMFLETCH call to base table set_security_group_id
285 hr_psf_bus.set_security_group_id(p_rec.position_id);
286 --
287 --
288 -- PMFLETCH Base table does validate uniqueness of name, but because name is
289 -- derived from concatenated key flex segments, and we are not translating
290 -- free format text within tose segments, then no name validation is required
291 -- for the TL table.
292 --
293 -- Validate Dependent Attributes
294 --
295 chk_non_updateable_args
296 (p_rec => p_rec
297 );
298 --
299 --
300 hr_utility.set_location(' Leaving:'||l_proc, 10);
301 End update_validate;
302 --
303 -- ----------------------------------------------------------------------------
304 -- |---------------------------< delete_validate >----------------------------|
305 -- ----------------------------------------------------------------------------
306 Procedure delete_validate
307 (p_rec in hr_pft_shd.g_rec_type
308 ) is
309 --
310 l_proc varchar2(72) := g_package||'delete_validate';
311 --
312 Begin
313 hr_utility.set_location('Entering:'||l_proc, 5);
314 --
315 -- Call all supporting business operations
316 --
317 hr_utility.set_location(' Leaving:'||l_proc, 10);
318 End delete_validate;
319 --
320 end hr_pft_bus;