1 Package Body per_cit_bus as
2 /* $Header: pecitrhi.pkb 115.3 2004/06/28 22:24:21 jpthomas noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_cit_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_cagr_entitlement_item_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_cagr_entitlement_item_id in number
23 ) is
24 --
25 -- Declare cursor
26 --
27 -- EDIT_HERE In the following cursor statement add join(s) between
28 -- per_cagr_entitlement_items_tl and PER_BUSINESS_GROUPS
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 -- Bug 3648630 Starts Here
33 --
34 /* cursor csr_sec_grp is
35 select pbg.security_group_id
36 from per_business_groups pbg
37 , per_cagr_entitlement_items_tl cit
38 -- , EDIT_HERE table_name(s) 333
39 where cit.cagr_entitlement_item_id = p_cagr_entitlement_item_id;
40 -- and pbg.business_group_id = EDIT_HERE 333.business_group_id; */
41 cursor csr_sec_grp is
42 select pbg.security_group_id
43 from per_business_groups pbg
44 , per_cagr_entitlement_items_tl cit
45 , per_cagr_entitlement_items ci
46 where cit.cagr_entitlement_item_id = p_cagr_entitlement_item_id
47 and ci.cagr_entitlement_item_id = cit.cagr_entitlement_item_id
48 and ci.business_group_id = pbg.business_group_id;
49 -- Bug 3648630 Ends Here
50 --
51 -- Declare local variables
52 --
53 l_security_group_id number;
54 l_proc varchar2(72) := g_package||'set_security_group_id';
55 --
56 begin
57 --
58 hr_utility.set_location('Entering:'|| l_proc, 10);
59 --
60 -- Ensure that all the mandatory parameter are not null
61 --
62 hr_api.mandatory_arg_error
63 (p_api_name => l_proc
64 ,p_argument => 'cagr_entitlement_item_id'
65 ,p_argument_value => p_cagr_entitlement_item_id
66 );
67 --
68 --
69 open csr_sec_grp;
70 fetch csr_sec_grp into l_security_group_id;
71 --
72 if csr_sec_grp%notfound then
73 --
74 close csr_sec_grp;
75 --
76 -- The primary key is invalid therefore we must error
77 --
78 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
79 fnd_message.raise_error;
80 --
81 end if;
82 close csr_sec_grp;
83 --
84 -- Set the security_group_id in CLIENT_INFO
85 --
86 hr_api.set_security_group_id
87 (p_security_group_id => l_security_group_id
88 );
89 --
90 hr_utility.set_location(' Leaving:'|| l_proc, 20);
91 --
92 end set_security_group_id;
93 --
94 -- ---------------------------------------------------------------------------
95 -- |---------------------< return_legislation_code >-------------------------|
96 -- ---------------------------------------------------------------------------
97 --
98 Function return_legislation_code
99 (p_cagr_entitlement_item_id in number
100 ,p_language in varchar2
101 )
102 Return Varchar2 Is
103 --
104 -- Declare cursor
105 --
106 -- EDIT_HERE In the following cursor statement add join(s) between
107 -- per_cagr_entitlement_items_tl and PER_BUSINESS_GROUPS
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 pbg
114 , per_cagr_entitlement_items_tl cit
115 -- , EDIT_HERE table_name(s) 333
116 where cit.cagr_entitlement_item_id = p_cagr_entitlement_item_id
117 and cit.language = p_language;
118 -- and pbg.business_group_id = EDIT_HERE 333.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 => 'cagr_entitlement_item_id'
134 ,p_argument_value => p_cagr_entitlement_item_id
135 );
136 --
137 --
138 if (( nvl(per_cit_bus.g_cagr_entitlement_item_id, hr_api.g_number)
139 = p_cagr_entitlement_item_id)
140 and ( nvl(per_cit_bus.g_language, hr_api.g_varchar2)
141 = p_language)) then
142 --
143 -- The legislation code has already been found with a previous
144 -- call to this function. Just return the value in the global
145 -- variable.
146 --
147 l_legislation_code := per_cit_bus.g_legislation_code;
148 hr_utility.set_location(l_proc, 20);
149 else
150 --
151 -- The ID is different to the last call to this function
152 -- or this is the first call to this function.
153 --
154 open csr_leg_code;
155 fetch csr_leg_code into l_legislation_code;
156 --
157 if csr_leg_code%notfound then
158 --
159 -- The primary key is invalid therefore we must error
160 --
161 close csr_leg_code;
162 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
163 fnd_message.raise_error;
164 end if;
165 hr_utility.set_location(l_proc,30);
166 --
167 -- Set the global variables so the values are
168 -- available for the next call to this function.
169 --
170 close csr_leg_code;
171 per_cit_bus.g_cagr_entitlement_item_id := p_cagr_entitlement_item_id;
172 per_cit_bus.g_language := p_language;
173 per_cit_bus.g_legislation_code := l_legislation_code;
174 end if;
175 hr_utility.set_location(' Leaving:'|| l_proc, 40);
176 return l_legislation_code;
177 end return_legislation_code;
178 --
179 -- ----------------------------------------------------------------------------
180 -- |-----------------------< chk_non_updateable_args >------------------------|
181 -- ----------------------------------------------------------------------------
182 -- {Start Of Comments}
183 --
184 -- Description:
185 -- This procedure is used to ensure that non updateable attributes have
186 -- not been updated. If an attribute has been updated an error is generated.
187 --
188 -- Pre Conditions:
189 -- g_old_rec has been populated with details of the values currently in
190 -- the database.
191 --
192 -- In Arguments:
193 -- p_rec has been populated with the updated values the user would like the
194 -- record set to.
195 --
196 -- Post Success:
197 -- Processing continues if all the non updateable attributes have not
198 -- changed.
199 --
200 -- Post Failure:
201 -- An application error is raised if any of the non updatable attributes
202 -- have been altered.
203 --
204 -- {End Of Comments}
205 -- ----------------------------------------------------------------------------
206 Procedure chk_non_updateable_args
207 (p_rec in per_cit_shd.g_rec_type
208 ) IS
209 --
210 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
211 l_error EXCEPTION;
212 l_argument varchar2(30);
213 --
214 Begin
215 --
216 -- Only proceed with the validation if a row exists for the current
217 -- record in the HR Schema.
218 --
219 IF NOT per_cit_shd.api_updating
220 (p_cagr_entitlement_item_id => p_rec.cagr_entitlement_item_id
221 ,p_language => p_rec.language
222 ) THEN
223 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
224 fnd_message.set_token('PROCEDURE ', l_proc);
225 fnd_message.set_token('STEP ', '5');
226 fnd_message.raise_error;
227 END IF;
228 --
229 -- EDIT_HERE: Add checks to ensure non-updateable args have
230 -- not been updated.
231 --
232 EXCEPTION
233 WHEN l_error THEN
234 hr_api.argument_changed_error
235 (p_api_name => l_proc
236 ,p_argument => l_argument);
237 WHEN OTHERS THEN
238 RAISE;
239 End chk_non_updateable_args;
240 --
241 -- ----------------------------------------------------------------------------
242 -- |---------------------------< insert_validate >----------------------------|
243 -- ----------------------------------------------------------------------------
244 Procedure insert_validate
245 (p_rec in per_cit_shd.g_rec_type
246 ) is
247 --
248 l_proc varchar2(72) := g_package||'insert_validate';
249 --
250 Begin
251 hr_utility.set_location('Entering:'||l_proc, 5);
252 --
253 -- Call all supporting business operations
254 --
255 --
256 -- EDIT_HERE: As this table does not have a mandatory business_group_id
257 -- column, ensure client_info is populated by calling a suitable
258 -- ???_???_bus.set_security_group_id procedure, or add one of the following
259 -- comments:
260 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
261 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
262 --
263 --
264 hr_utility.set_location(' Leaving:'||l_proc, 10);
265 End insert_validate;
266 --
267 -- ----------------------------------------------------------------------------
268 -- |---------------------------< update_validate >----------------------------|
269 -- ----------------------------------------------------------------------------
270 Procedure update_validate
271 (p_rec in per_cit_shd.g_rec_type
272 ) is
273 --
274 l_proc varchar2(72) := g_package||'update_validate';
275 --
276 Begin
277 hr_utility.set_location('Entering:'||l_proc, 5);
278 --
279 -- Call all supporting business operations
280 --
281 --
282 -- EDIT_HERE: As this table does not have a mandatory business_group_id
283 -- column, ensure client_info is populated by calling a suitable
284 -- ???_???_bus.set_security_group_id procedure, or add one of the following
285 -- comments:
286 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
287 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
288 --
289 chk_non_updateable_args
290 (p_rec => p_rec
291 );
292 --
293 --
294 hr_utility.set_location(' Leaving:'||l_proc, 10);
295 End update_validate;
296 --
297 -- ----------------------------------------------------------------------------
298 -- |---------------------------< delete_validate >----------------------------|
299 -- ----------------------------------------------------------------------------
300 Procedure delete_validate
301 (p_rec in per_cit_shd.g_rec_type
302 ) is
303 --
304 l_proc varchar2(72) := g_package||'delete_validate';
305 --
306 Begin
307 hr_utility.set_location('Entering:'||l_proc, 5);
308 --
309 -- Call all supporting business operations
310 --
311 hr_utility.set_location(' Leaving:'||l_proc, 10);
312 End delete_validate;
313 --
314 end per_cit_bus;