1 Package Body ota_thg_bus as
2 /* $Header: otthgrhi.pkb 120.0 2005/05/29 07:44:06 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ota_thg_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_gl_default_segment_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_gl_default_segment_id in number
22 ) is
23 --
24 -- Declare cursor
25 --
26 -- In the following cursor statement add join(s) between
27 -- ota_hr_gl_flex_maps 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_perf pbg
34 , ota_hr_gl_flex_maps thg
35 , ota_cross_charges tcc
36 where tcc.cross_charge_id = thg.cross_charge_id and
37 thg.gl_default_segment_id = p_gl_default_segment_id and
38 pbg.business_group_id = tcc.business_group_id;
39 --
40 -- Declare local variables
41 --
42 l_security_group_id number;
43 l_proc varchar2(72) := g_package||'set_security_group_id';
44 --
45 begin
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 => 'gl_default_segment_id'
54 ,p_argument_value => p_gl_default_segment_id
55 );
56 --
57 open csr_sec_grp;
58 fetch csr_sec_grp into l_security_group_id;
59 --
60 if csr_sec_grp%notfound then
61 --
62 close csr_sec_grp;
63 --
64 -- The primary key is invalid therefore we must error
65 --
66 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
67 fnd_message.raise_error;
68 --
69 end if;
70 close csr_sec_grp;
71 --
72 -- Set the security_group_id in CLIENT_INFO
73 --
74 hr_api.set_security_group_id
75 (p_security_group_id => l_security_group_id
76 );
77 --
78 hr_utility.set_location(' Leaving:'|| l_proc, 20);
79 --
80 end set_security_group_id;
81 --
82 -- ---------------------------------------------------------------------------
83 -- |---------------------< return_legislation_code >-------------------------|
84 -- ---------------------------------------------------------------------------
85 --
86 Function return_legislation_code
87 (p_gl_default_segment_id in number
88 )
89 Return Varchar2 Is
90 --
91 -- Declare cursor
92 --
93 -- In the following cursor statement add join(s) between
94 -- ota_hr_gl_flex_maps and PER_BUSINESS_GROUPS
95 -- so that the legislation_code for
96 -- the current business group context can be derived.
97 -- Remove this comment when the edit has been completed.
98 cursor csr_leg_code is
99 select pbg.legislation_code
100 from per_business_groups_perf pbg
101 , ota_hr_gl_flex_maps thg
102 , ota_cross_charges tcc
103 where tcc. Cross_charge_id = thg.cross_charge_id and
104 thg.gl_default_segment_id = p_gl_default_segment_id and
105 pbg.business_group_id = tcc.business_group_id;
106 --
107 -- Declare local variables
108 --
109 l_legislation_code varchar2(150);
110 l_proc varchar2(72) := g_package||'return_legislation_code';
111 --
112 Begin
113 --
114 hr_utility.set_location('Entering:'|| l_proc, 10);
115 --
116 -- Ensure that all the mandatory parameter are not null
117 --
118 hr_api.mandatory_arg_error
119 (p_api_name => l_proc
120 ,p_argument => 'gl_default_segment_id'
121 ,p_argument_value => p_gl_default_segment_id
122 );
123 --
124 if ( nvl(ota_thg_bus.g_gl_default_segment_id, hr_api.g_number)
125 = p_gl_default_segment_id) then
126 --
127 -- The legislation code has already been found with a previous
128 -- call to this function. Just return the value in the global
129 -- variable.
130 --
131 l_legislation_code := ota_thg_bus.g_legislation_code;
132 hr_utility.set_location(l_proc, 20);
133 else
134 --
135 -- The ID is different to the last call to this function
136 -- or this is the first call to this function.
137 --
138 open csr_leg_code;
139 fetch csr_leg_code into l_legislation_code;
140 --
141 if csr_leg_code%notfound then
142 --
143 -- The primary key is invalid therefore we must error
144 --
145 close csr_leg_code;
146 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
147 fnd_message.raise_error;
148 end if;
149 hr_utility.set_location(l_proc,30);
150 --
151 -- Set the global variables so the values are
152 -- available for the next call to this function.
153 --
154 close csr_leg_code;
155 ota_thg_bus.g_gl_default_segment_id := p_gl_default_segment_id;
156 ota_thg_bus.g_legislation_code := l_legislation_code;
157 end if;
158 hr_utility.set_location(' Leaving:'|| l_proc, 40);
159 return l_legislation_code;
160 end return_legislation_code;
161 --
162 -- ----------------------------------------------------------------------------
163 -- |-----------------------< chk_non_updateable_args >------------------------|
164 -- ----------------------------------------------------------------------------
165 -- {Start Of Comments}
166 --
167 -- Description:
168 -- This procedure is used to ensure that non updateable attributes have
169 -- not been updated. If an attribute has been updated an error is generated.
170 --
171 -- Pre Conditions:
172 -- g_old_rec has been populated with details of the values currently in
173 -- the database.
174 --
175 -- In Arguments:
176 -- p_rec has been populated with the updated values the user would like the
177 -- record set to.
178 --
179 -- Post Success:
180 -- Processing continues if all the non updateable attributes have not
181 -- changed.
182 --
183 -- Post Failure:
184 -- An application error is raised if any of the non updatable attributes
185 -- have been altered.
186 --
187 -- {End Of Comments}
188 -- ----------------------------------------------------------------------------
189 Procedure chk_non_updateable_args
190 (p_effective_date in date
191 ,p_rec in ota_thg_shd.g_rec_type
192 ) IS
193 --
194 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
195 l_error EXCEPTION;
196 l_argument varchar2(30);
197 --
198 Begin
199 --
200 -- Only proceed with the validation if a row exists for the current
201 -- record in the HR Schema.
202 --
203 IF NOT ota_thg_shd.api_updating
204 (p_gl_default_segment_id => p_rec.gl_default_segment_id
205 ,p_object_version_number => p_rec.object_version_number
206 ) THEN
207 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
208 fnd_message.set_token('PROCEDURE ', l_proc);
209 fnd_message.set_token('STEP ', '5');
210 fnd_message.raise_error;
211 END IF;
212 --
213 -- EDIT_HERE: Add checks to ensure non-updateable args have
214 -- not been updated.
215 --
216 EXCEPTION
217 WHEN l_error THEN
218 hr_api.argument_changed_error
219 (p_api_name => l_proc
220 ,p_argument => l_argument);
221 WHEN OTHERS THEN
222 RAISE;
223 End chk_non_updateable_args;
224
225 -- ----------------------------------------------------------------------------
226 -- |----------------------< chk_hr_data_source >----------------------------|
227 -- ----------------------------------------------------------------------------
228 Procedure chk_hr_data_source
229 (p_gl_default_segment_id in number
230 ,p_hr_data_source in varchar2
231 ,p_effective_date in date) is
232
233 --
234 l_proc varchar2(72) := g_package||'chk_hr_data_source';
235 l_api_updating boolean;
236
237 begin
238 hr_utility.set_location(' Leaving:'||l_proc, 10);
239
240
241 if (((p_gl_default_segment_id is not null) and
242 nvl(ota_thg_shd.g_old_rec.hr_data_source,hr_api.g_varchar2) <>
243 nvl(p_hr_data_source,hr_api.g_varchar2))
244 or
245 (p_gl_default_segment_id is null)) then
246
247 hr_utility.set_location(' entering:'||l_proc, 20);
248 --
249 -- if HR_data_source is not null then
250 -- check if the hr_data_source value exists in hr_lookups
251 -- where lookup_type is 'OTA_CROSS_CHARGE_TABLE'
252 --
253 if p_hr_data_source is not null then
254 if hr_api.not_exists_in_hrstanlookups
255 (p_effective_date => p_effective_date
256 ,p_lookup_type => 'OTA_CROSS_CHARGE_TABLE'
257 ,p_lookup_code => p_hr_data_source) then
258 fnd_message.set_name('OTA','OTA_13225_THG_SOURCE_INVALID');
259 fnd_message.raise_error;
260 end if;
261 hr_utility.set_location(' Leaving:'||l_proc, 30);
262
263 end if;
264
265 end if;
266 hr_utility.set_location(' Leaving:'||l_proc, 40);
267
268 end chk_hr_data_source;
269
270 --
271 -- ----------------------------------------------------------------------------
272 -- |---------------------------< insert_validate >----------------------------|
273 -- ----------------------------------------------------------------------------
274 Procedure insert_validate
275 (p_effective_date in date
276 ,p_rec in ota_thg_shd.g_rec_type
277 ) is
278 --
279 l_proc varchar2(72) := g_package||'insert_validate';
280 --
281 Begin
282 hr_utility.set_location('Entering:'||l_proc, 5);
283 --
284 -- Call all supporting business operations
285 --
286 --
287 --
288 --
289 ota_tcc_bus.set_security_group_id(p_rec.cross_charge_id);
290
291 chk_hr_data_source
292 (p_gl_default_segment_id => p_rec.gl_default_segment_id
293 ,p_hr_data_source => p_rec.hr_data_source
294 ,p_effective_date =>p_effective_date);
295
296 hr_utility.set_location(' Leaving:'||l_proc, 10);
297 End insert_validate;
298 --
299 -- ----------------------------------------------------------------------------
300 -- |---------------------------< update_validate >----------------------------|
301 -- ----------------------------------------------------------------------------
302 Procedure update_validate
303 (p_effective_date in date
304 ,p_rec in ota_thg_shd.g_rec_type
305 ) is
306 --
307 l_proc varchar2(72) := g_package||'update_validate';
308 --
309 Begin
310 hr_utility.set_location('Entering:'||l_proc, 5);
311 --
312 -- Call all supporting business operations
313 --
314 --
315 --
316 ota_tcc_bus.set_security_group_id(p_rec.cross_charge_id);
317
318 chk_non_updateable_args
319 (p_effective_date => p_effective_date
320 ,p_rec => p_rec
321 );
322
323 chk_hr_data_source
324 (p_gl_default_segment_id => p_rec.gl_default_segment_id
325 ,p_hr_data_source => p_rec.hr_data_source
326 ,p_effective_date =>p_effective_date);
327
328 --
329 --
330 hr_utility.set_location(' Leaving:'||l_proc, 10);
331 End update_validate;
332 --
333 -- ----------------------------------------------------------------------------
334 -- |---------------------------< delete_validate >----------------------------|
335 -- ----------------------------------------------------------------------------
336 Procedure delete_validate
337 (p_rec in ota_thg_shd.g_rec_type
338 ) is
339 --
340 l_proc varchar2(72) := g_package||'delete_validate';
341 --
342 Begin
343 hr_utility.set_location('Entering:'||l_proc, 5);
344 --
345 -- Call all supporting business operations
346 --
347 hr_utility.set_location(' Leaving:'||l_proc, 10);
348 End delete_validate;
349 --
350 end ota_thg_bus;