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