1 Package Body pay_app_bus as
2 /* $Header: pyapprhi.pkb 120.0.12000000.1 2007/01/17 15:36:55 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_process_parameter_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_process_parameter_id in number
22 ,p_associated_column1 in varchar2 default null
23 ) is
24 --
25 --
26 -- Declare cursor
27 --
28 cursor csr_sec_grp is
29 select pbg.security_group_id,
30 pbg.legislation_code
31 from per_business_groups_perf pbg
32 , pay_au_process_parameters app
33 , pay_au_processes ap
34 where app.process_parameter_id = p_process_parameter_id
35 and pbg.business_group_id(+) = ap.business_group_id
36 and ap.process_id = app.process_id;
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 => 'process_parameter_id'
54 ,p_argument_value => p_process_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,'PROCESS_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_process_parameter_id in number
97 )
98 Return Varchar2 Is
99 --
100 -- Declare curso
101 --
102 cursor csr_leg_code is
103 select pbg.legislation_code
104 from per_business_groups_perf pbg
105 , pay_au_process_parameters app
106 , pay_au_processes ap
107 where app.process_parameter_id = p_process_parameter_id
108 and pbg.business_group_id(+) = ap.business_group_id
109 and ap.process_id = app.process_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 => 'process_parameter_id'
127 ,p_argument_value => p_process_parameter_id
128 );
129 --
130 if ( nvl(pay_app_bus.g_process_parameter_id, hr_api.g_number)
131 = p_process_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_app_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_app_bus.g_process_parameter_id := p_process_parameter_id;
162 pay_app_bus.g_legislation_code := l_legislation_code;
163 end if;
164 --
165 hr_utility.set_location(' Leaving:'|| l_proc, 40);
166 return l_legislation_code;
167 end return_legislation_code;
168 --
169 --
170 -- ----------------------------------------------------------------------------
171 -- |-----------------------< chk_non_updateable_args >------------------------|
172 -- ----------------------------------------------------------------------------
173 -- {Start Of Comments}
174 --
175 -- Description:
176 -- This procedure is used to ensure that non updateable attributes have
177 -- not been updated. If an attribute has been updated an error is generated.
178 --
179 -- Pre Conditions:
180 -- g_old_rec has been populated with details of the values currently in
181 -- the database.
182 --
183 -- In Arguments:
184 -- p_rec has been populated with the updated values the user would like the
185 -- record set to.
186 --
187 -- Post Success:
188 -- Processing continues if all the non updateable attributes have not
189 -- changed.
190 --
191 -- Post Failure:
192 -- An application error is raised if any of the non updatable attributes
193 -- have been altered.
194 --
195 -- {End Of Comments}
196 -- ----------------------------------------------------------------------------
197 Procedure chk_non_updateable_args
198 (p_rec in pay_app_shd.g_rec_type
199 ) IS
200 --
201 l_proc varchar2(72);
202 --
203 Begin
204 --
205 l_proc := g_package || 'chk_non_updateable_args';
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_app_shd.api_updating
211 (p_process_parameter_id => p_rec.process_parameter_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_app_shd.g_rec_type
230 ) is
231 --
232 l_proc varchar2(72);
233 --
234 Begin
235 l_proc := g_package||'insert_validate';
236 --
237 hr_utility.set_location('Entering:'||l_proc, 5);
238 --
239 -- Call all supporting business operations
240 --
241 -- comments:
242 --
243 -- "-- No business group context."
244 --
245 -- Validate Dependent Attributes
246 --
247 --
248 hr_utility.set_location(' Leaving:'||l_proc, 10);
249 End insert_validate;
250 --
251 -- ----------------------------------------------------------------------------
252 -- |---------------------------< update_validate >----------------------------|
253 -- ----------------------------------------------------------------------------
254 Procedure update_validate
255 (p_rec in pay_app_shd.g_rec_type
256 ) is
257 --
258 l_proc varchar2(72);
259 --
260 Begin
261 l_proc := g_package||'update_validate';
262 --
263 hr_utility.set_location('Entering:'||l_proc, 5);
264 --
265 -- Call all supporting business operations
266 --
267 -- comments:
268 -- "-- No business group context."
269 --
270 --
271 --
272 -- Validate Dependent Attributes
273 --
274 chk_non_updateable_args
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 pay_app_shd.g_rec_type
287 ) is
288 --
289 l_proc varchar2(72);
290 --
291 Begin
292 l_proc := g_package||'delete_validate';
293 --
294 hr_utility.set_location('Entering:'||l_proc, 5);
295 --
296 -- Call all supporting business operations
297 --
298 hr_utility.set_location(' Leaving:'||l_proc, 10);
299 End delete_validate;
300 --
301 begin
302 g_package := ' pay_app_bus.'; -- Global package name
303 end pay_app_bus;