[Home] [Help]
PACKAGE BODY: APPS.OTA_SRT_BUS
Source
1 Package Body ota_srt_bus as
2 /* $Header: otsrtrhi.pkb 115.3 2003/05/19 07:56:51 jbharath noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ota_srt_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_supplied_resource_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_supplied_resource_id in number
23 ,p_associated_column1 in varchar2 default null
24 ) is
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 pbg
32 , ota_suppliable_resources tsr
33 where tsr.supplied_resource_id = p_supplied_resource_id
34 and pbg.business_group_id = tsr.business_group_id;
35 --
36 -- Declare local variables
37 --
38 l_security_group_id number;
39 l_proc varchar2(72) := g_package||'set_security_group_id';
40 l_legislation_code varchar2(150);
41 --
42 begin
43 --
44 hr_utility.set_location('Entering:'|| l_proc, 10);
45 --
46 -- Ensure that all the mandatory parameter are not null
47 --
48 hr_api.mandatory_arg_error
49 (p_api_name => l_proc
50 ,p_argument => 'supplied_resource_id'
51 ,p_argument_value => p_supplied_resource_id
52 );
53 --
54 --
55 open csr_sec_grp;
56 fetch csr_sec_grp into l_security_group_id
57 , l_legislation_code;
58 --
59 if csr_sec_grp%notfound then
60 --
61 close csr_sec_grp;
62 --
63 -- The primary key is invalid therefore we must error
64 --
65 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
66 hr_multi_message.add
67 (p_associated_column1
68 => nvl(p_associated_column1,'SUPPLIED_RESOURCE_ID')
69 );
70 --
71 else
72 close csr_sec_grp;
73 --
74 -- Set the security_group_id in CLIENT_INFO
75 --
76 hr_api.set_security_group_id
77 (p_security_group_id => l_security_group_id
78 );
79 --
80 -- Set the sessions legislation context in HR_SESSION_DATA
81 --
82 hr_api.set_legislation_context(l_legislation_code);
83 end if;
84 --
85 hr_utility.set_location(' Leaving:'|| l_proc, 20);
86 --
87 end set_security_group_id;
88 --
89 -- ---------------------------------------------------------------------------
90 -- |---------------------< return_legislation_code >-------------------------|
91 -- ---------------------------------------------------------------------------
92 --
93 Function return_legislation_code
94 (p_supplied_resource_id in number
95 ,p_language in varchar2
96 )
97 Return Varchar2 Is
98 --
99 -- Declare cursor
100 --
101 cursor csr_leg_code is
102 select pbg.legislation_code
103 from per_business_groups pbg
107 --
104 , ota_suppliable_resources tsr
105 where tsr.supplied_resource_id = p_supplied_resource_id
106 and pbg.business_group_id = tsr.business_group_id;
108 -- Declare local variables
109 --
110 l_legislation_code varchar2(150);
111 l_proc varchar2(72) := g_package||'return_legislation_code';
112 --
113 Begin
114 --
115 hr_utility.set_location('Entering:'|| l_proc, 10);
116 --
117 -- Ensure that all the mandatory parameter are not null
118 --
119 hr_api.mandatory_arg_error
120 (p_api_name => l_proc
121 ,p_argument => 'supplied_resource_id'
122 ,p_argument_value => p_supplied_resource_id
123 );
124 --
125 --
126 if (( nvl(ota_srt_bus.g_supplied_resource_id, hr_api.g_number)
127 = p_supplied_resource_id)
128 and ( nvl(ota_srt_bus.g_language, hr_api.g_varchar2)
129 = p_language)) then
130 --
131 -- The legislation code has already been found with a previous
132 -- call to this function. Just return the value in the global
133 -- variable.
134 --
135 l_legislation_code := ota_srt_bus.g_legislation_code;
136 hr_utility.set_location(l_proc, 20);
137 else
138 --
139 -- The ID is different to the last call to this function
140 -- or this is the first call to this function.
141 --
142 open csr_leg_code;
143 fetch csr_leg_code into l_legislation_code;
144 --
145 if csr_leg_code%notfound then
146 --
147 -- The primary key is invalid therefore we must error
148 --
149 close csr_leg_code;
150 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
151 fnd_message.raise_error;
152 end if;
153 hr_utility.set_location(l_proc,30);
154 --
155 -- Set the global variables so the values are
156 -- available for the next call to this function.
157 --
158 close csr_leg_code;
159 ota_srt_bus.g_supplied_resource_id := p_supplied_resource_id;
160 ota_srt_bus.g_language := p_language;
161 ota_srt_bus.g_legislation_code := l_legislation_code;
162 end if;
163 hr_utility.set_location(' Leaving:'|| l_proc, 40);
164 return l_legislation_code;
165 end return_legislation_code;
166 --
167 -- ----------------------------------------------------------------------------
168 -- |-----------------------< chk_non_updateable_args >------------------------|
169 -- ----------------------------------------------------------------------------
170 -- {Start Of Comments}
171 --
172 -- Description:
173 -- This procedure is used to ensure that non updateable attributes have
174 -- not been updated. If an attribute has been updated an error is generated.
175 --
176 -- Pre Conditions:
177 -- g_old_rec has been populated with details of the values currently in
178 -- the database.
179 --
180 -- In Arguments:
181 -- p_rec has been populated with the updated values the user would like the
182 -- record set to.
183 --
184 -- Post Success:
185 -- Processing continues if all the non updateable attributes have not
186 -- changed.
187 --
188 -- Post Failure:
189 -- An application error is raised if any of the non updatable attributes
190 -- have been altered.
191 --
192 -- {End Of Comments}
193 -- ----------------------------------------------------------------------------
194 Procedure chk_non_updateable_args
195 (p_effective_date in date
196 ,p_rec in ota_srt_shd.g_rec_type
197 ) IS
198 --
199 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
200 --
201 Begin
202 --
203 -- Only proceed with the validation if a row exists for the current
204 -- record in the HR Schema.
205 --
206 IF NOT ota_srt_shd.api_updating
207 (p_supplied_resource_id => p_rec.supplied_resource_id
208 ,p_language => p_rec.language
209 ) THEN
210 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
211 fnd_message.set_token('PROCEDURE ', l_proc);
212 fnd_message.set_token('STEP ', '5');
213 fnd_message.raise_error;
214 END IF;
215 --
216 --
217 End chk_non_updateable_args;
218 --
219 -- ----------------------------------------------------------------------------
220 -- |---------------------------< check_unique_name >----------------------------|
221 -- ----------------------------------------------------------------------------
222 procedure check_unique_name (
223 p_business_group_id number default null,
224 p_supplied_resource_id number,
225 p_language varchar2,
226 p_name varchar2,
227 p_resource_type varchar2 default null
228 ) is
229 ----------------
230 l_business_group_id ota_suppliable_resources.business_group_id%type ;
231 l_resource_type ota_suppliable_resources.resource_type%type ;
232
233 cursor csr_tsr_bsg_type is
234 select business_group_id,resource_type
235 from ota_suppliable_resources
236 where supplied_resource_id = p_supplied_resource_id ;
237
238 cursor csr_tsr is
239 select tsr.supplied_resource_id
240 from ota_suppliable_resources tsr, ota_suppliable_resources_tl srt
241 where tsr.business_group_id = l_business_group_id
242 and srt.supplied_resource_id = tsr.supplied_resource_id
243 and srt.language = p_language
244 and (p_supplied_resource_id is null or p_supplied_resource_id <> srt.supplied_resource_id)
245 and srt.name = p_name
246 and tsr.resource_type = l_resource_type;
247 --
251 l_dummy number ;
248 l_tsr_exists boolean;
249
250 --
252 --
253 l_proc varchar2(72) := g_package||'check_unique_name';
254 --
255 begin
256 hr_utility.set_location('Entering:'||l_proc, 5);
257 --
258 if p_business_group_id is null or p_resource_type is null then
259 open csr_tsr_bsg_type ;
260 fetch csr_tsr_bsg_type into l_business_group_id, l_resource_type ;
261 close csr_tsr_bsg_type ;
262 else
263 l_business_group_id := p_business_group_id ;
264 l_resource_type := p_resource_type ;
265 end if;
266 --
267 hr_api.mandatory_arg_error(g_package,'business_group',l_business_group_id);
268 --
269 open csr_tsr;
270 fetch csr_tsr into l_dummy;
271 l_tsr_exists := csr_tsr%found;
272 close csr_tsr;
273 --
274 if l_tsr_exists then
275 -- constraint_error2('resource_already_exists');
276 fnd_message.set_name('PAY','HR_TRANSLATION_EXISTS');
277 fnd_message.raise_error;
278 end if;
279 --
280 hr_utility.set_location(' Leaving:'||l_proc, 10);
281 end check_unique_name;
282 --
283 -- ----------------------------------------------------------------------------
284 -- |---------------------------< insert_validate >----------------------------|
285 -- ----------------------------------------------------------------------------
286 Procedure insert_validate
287 (p_effective_date in date
288 ,p_rec in ota_srt_shd.g_rec_type
289 ,p_supplied_resource_id in number
290 ) is
291 --
292 l_proc varchar2(72) := g_package||'insert_validate';
293 --
294 Begin
295 hr_utility.set_location('Entering:'||l_proc, 5);
296 --
297 -- Call all supporting business operations
298 --
299 --
300 ota_srt_bus.set_security_group_id(p_supplied_resource_id) ;
301 --
302 -- Validate Dependent Attributes
303 check_unique_name(p_supplied_resource_id => p_supplied_resource_id
304 ,p_name => p_rec.name
305 ,p_language => p_rec.language
306 ) ;
307 --
308 --
309 hr_utility.set_location(' Leaving:'||l_proc, 10);
310 End insert_validate;
311 --
312 -- ----------------------------------------------------------------------------
313 -- |---------------------------< update_validate >----------------------------|
314 -- ----------------------------------------------------------------------------
315 Procedure update_validate
316 (p_effective_date in date
317 ,p_rec in ota_srt_shd.g_rec_type
318 ) is
319 --
320 l_proc varchar2(72) := g_package||'update_validate';
321 --
322 Begin
323 hr_utility.set_location('Entering:'||l_proc, 5);
324 --
325 -- Call all supporting business operations
326 --
327 --
328 ota_srt_bus.set_security_group_id(p_rec.supplied_resource_id) ;
329 --
330 -- Validate Dependent Attributes
331 check_unique_name(p_supplied_resource_id => p_rec.supplied_resource_id
332 ,p_name => p_rec.name
333 ,p_language => p_rec.language
334 ) ;
335 --
336 chk_non_updateable_args
337 (p_effective_date => p_effective_date
338 ,p_rec => p_rec
339 );
340 --
341 --
342 hr_utility.set_location(' Leaving:'||l_proc, 10);
343 End update_validate;
344 --
345 -- ----------------------------------------------------------------------------
346 -- |---------------------------< delete_validate >----------------------------|
347 -- ----------------------------------------------------------------------------
348 Procedure delete_validate
349 (p_rec in ota_srt_shd.g_rec_type
350 ) is
351 --
352 l_proc varchar2(72) := g_package||'delete_validate';
353 --
354 Begin
355 hr_utility.set_location('Entering:'||l_proc, 5);
356 --
357 -- Call all supporting business operations
358 --
359 hr_utility.set_location(' Leaving:'||l_proc, 10);
360 End delete_validate;
361 --
362
363 --
364 end ota_srt_bus;