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