1 Package Body ghr_cpl_bus as
2 /* $Header: ghcplrhi.pkb 115.1 2003/01/30 19:25:27 asubrahm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ghr_cpl_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_compl_person_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_compl_person_id in number
22 ) is
23 --
24 -- Declare cursor
25 --
26 -- EDIT_HERE In the following cursor statement add join(s) between
27 -- ghr_compl_people and PER_BUSINESS_GROUPS
28 -- so that the security_group_id for
29 -- the current business group context can be derived.
30 -- Remove this comment when the edit has been completed.
31 cursor csr_sec_grp is
32 select pbg.security_group_id
33 from per_business_groups pbg
34 , ghr_compl_people cpl
35 -- , EDIT_HERE table_name(s) 333
36 where cpl.compl_person_id = p_compl_person_id;
37 -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
38 --
39 -- Declare local variables
40 --
41 l_security_group_id number;
42 l_proc varchar2(72) := g_package||'set_security_group_id';
43 --
44 begin
45 --
46 hr_utility.set_location('Entering:'|| l_proc, 10);
47 --
48 -- Ensure that all the mandatory parameter are not null
49 --
50 hr_api.mandatory_arg_error
51 (p_api_name => l_proc
52 ,p_argument => 'compl_person_id'
53 ,p_argument_value => p_compl_person_id
54 );
55 --
56 open csr_sec_grp;
57 fetch csr_sec_grp into l_security_group_id;
58 --
59 if csr_sec_grp%notfound then
60 --
61 close csr_sec_grp;
62 --
63 -- The primary key is invalid therefore we must error
64 --
65 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
66 fnd_message.raise_error;
67 --
68 end if;
69 close csr_sec_grp;
70 --
71 -- Set the security_group_id in CLIENT_INFO
72 --
73 hr_api.set_security_group_id
74 (p_security_group_id => l_security_group_id
75 );
76 --
77 hr_utility.set_location(' Leaving:'|| l_proc, 20);
78 --
79 end set_security_group_id;
80 --
81 -- ---------------------------------------------------------------------------
82 -- |---------------------< return_legislation_code >-------------------------|
83 -- ---------------------------------------------------------------------------
84 --
85 Function return_legislation_code
86 (p_compl_person_id in number
87 )
88 Return Varchar2 Is
89 --
90 -- Declare cursor
91 --
92 -- EDIT_HERE In the following cursor statement add join(s) between
93 -- ghr_compl_people and PER_BUSINESS_GROUPS
94 -- so that the legislation_code for
95 -- the current business group context can be derived.
96 -- Remove this comment when the edit has been completed.
97 cursor csr_leg_code is
98 select pbg.legislation_code
99 from per_business_groups pbg
100 , ghr_compl_people cpl
101 -- , EDIT_HERE table_name(s) 333
102 where cpl.compl_person_id = p_compl_person_id;
103 -- and pbg.business_group_id = EDIT_HERE 333.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 => 'compl_person_id'
119 ,p_argument_value => p_compl_person_id
120 );
121 --
122 if ( nvl(ghr_cpl_bus.g_compl_person_id, hr_api.g_number)
123 = p_compl_person_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 := ghr_cpl_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 ghr_cpl_bus.g_compl_person_id := p_compl_person_id;
154 ghr_cpl_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_effective_date in date
189 ,p_rec in ghr_cpl_shd.g_rec_type
190 ) IS
191 --
192 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
193 l_error EXCEPTION;
194 l_argument varchar2(30);
195 --
196 Begin
197 --
198 -- Only proceed with the validation if a row exists for the current
199 -- record in the HR Schema.
200 --
201 IF NOT ghr_cpl_shd.api_updating
202 (p_compl_person_id => p_rec.compl_person_id
203 ,p_object_version_number => p_rec.object_version_number
204 ) THEN
205 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
206 fnd_message.set_token('PROCEDURE ', l_proc);
207 fnd_message.set_token('STEP ', '5');
208 fnd_message.raise_error;
209 END IF;
210 --
211 -- EDIT_HERE: Add checks to ensure non-updateable args have
212 -- not been updated.
213 --
214 EXCEPTION
215 WHEN l_error THEN
216 hr_api.argument_changed_error
217 (p_api_name => l_proc
218 ,p_argument => l_argument);
219 WHEN OTHERS THEN
220 RAISE;
221 End chk_non_updateable_args;
222 --
223 -- ----------------------------------------------------------------------------
224 -- |---------------------------< insert_validate >----------------------------|
225 -- ----------------------------------------------------------------------------
226 Procedure insert_validate
227 (p_effective_date in date
228 ,p_rec in ghr_cpl_shd.g_rec_type
229 ) is
230 --
231 l_proc varchar2(72) := g_package||'insert_validate';
232 --
233 Begin
234 hr_utility.set_location('Entering:'||l_proc, 5);
235 --
236 -- Call all supporting business operations
237 --
238 --
239 -- EDIT_HERE: As this table does not have a mandatory business_group_id
240 -- column, ensure client_info is populated by calling a suitable
241 -- ???_???_bus.set_security_group_id procedure, or add one of the following
242 -- comments:
243 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
244 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
245 --
246 --
247 hr_utility.set_location(' Leaving:'||l_proc, 10);
248 End insert_validate;
249 --
250 -- ----------------------------------------------------------------------------
251 -- |---------------------------< update_validate >----------------------------|
252 -- ----------------------------------------------------------------------------
253 Procedure update_validate
254 (p_effective_date in date
255 ,p_rec in ghr_cpl_shd.g_rec_type
256 ) is
257 --
258 l_proc varchar2(72) := g_package||'update_validate';
259 --
260 Begin
261 hr_utility.set_location('Entering:'||l_proc, 5);
262 --
263 -- Call all supporting business operations
264 --
265 --
266 -- EDIT_HERE: As this table does not have a mandatory business_group_id
267 -- column, ensure client_info is populated by calling a suitable
268 -- ???_???_bus.set_security_group_id procedure, or add one of the following
269 -- comments:
270 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
271 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
272 --
273 chk_non_updateable_args
274 (p_effective_date => p_effective_date
275 ,p_rec => p_rec
276 );
277 --
278 --
279 hr_utility.set_location(' Leaving:'||l_proc, 10);
280 End update_validate;
281 --
282 -- ----------------------------------------------------------------------------
283 -- |---------------------------< delete_validate >----------------------------|
284 -- ----------------------------------------------------------------------------
285 Procedure delete_validate
286 (p_rec in ghr_cpl_shd.g_rec_type
287 ) is
288 --
289 l_proc varchar2(72) := g_package||'delete_validate';
290 --
291 Begin
292 hr_utility.set_location('Entering:'||l_proc, 5);
293 --
294 -- Call all supporting business operations
295 --
296 hr_utility.set_location(' Leaving:'||l_proc, 10);
297 End delete_validate;
298 --
299 end ghr_cpl_bus;