1 PACKAGE BODY HR_OTT_BUS as
2 /* $Header: hrottrhi.pkb 115.1 2004/04/05 07:21 menderby noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_ott_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_option_type_id number default null;
15 g_language varchar2(4) default null;
16 -- ----------------------------------------------------------------------------
17 -- |-----------------------< chk_non_updateable_args >------------------------|
18 -- ----------------------------------------------------------------------------
19 -- {Start Of Comments}
20 --
21 -- Description:
22 -- This procedure is used to ensure that non updateable attributes have
23 -- not been updated. If an attribute has been updated an error is generated.
24 --
25 -- Pre Conditions:
26 -- g_old_rec has been populated with details of the values currently in
27 -- the database.
28 --
29 -- In Arguments:
30 -- p_rec has been populated with the updated values the user would like the
31 -- record set to.
32 --
33 -- Post Success:
34 -- Processing continues if all the non updateable attributes have not
35 -- changed.
36 --
37 -- Post Failure:
38 -- An application error is raised if any of the non updatable attributes
39 -- have been altered.
40 --
41 -- {End Of Comments}
42 -- ----------------------------------------------------------------------------
43 Procedure chk_non_updateable_args
44 (p_rec in hr_ott_shd.g_rec_type
45 ) IS
46 --
47 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
48 --
49 Begin
50 --
51 -- Only proceed with the validation if a row exists for the current
52 -- record in the HR Schema.
53 --
54 IF NOT hr_ott_shd.api_updating
55 (p_option_type_id => p_rec.option_type_id
56 ,p_language
57 => p_rec.language
58
59 ) THEN
60 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
61 fnd_message.set_token('PROCEDURE ', l_proc);
62 fnd_message.set_token('STEP ', '5');
63 fnd_message.raise_error;
64 END IF;
65
66 End chk_non_updateable_args;
67
68 -- ----------------------------------------------------------------------------
69 -- |-----------------------< CHK_OPTION_NAME>------------------------|
70 -- ----------------------------------------------------------------------------
71 -- {Start Of Comments}
72 --
73 -- Description:
74 -- This procedure ensures a valid name is entered
75 -- Pre Conditions:
76 -- g_old_rec has been populated with details of the values currently in
77 -- the database.
78 --
79 -- In Arguments:
80 -- p_name
81 -- p_language
82 -- Post Success:
83 -- Processing continues if name is not null and unique
84 --
85 -- Post Failure:
86 -- An application error is raised if name is null or exists already
87 --
88 -- {End Of Comments}
89 -- ----------------------------------------------------------------------------
90 procedure chk_option_name
91 (
92 p_option_type_id in number
93 ,p_option_name in varchar2
94 ,p_language in varchar2
95 ) IS
96 --
97 l_proc varchar2(72) := g_package || 'chk_option_name';
98 l_name varchar2(1);
99
100 CURSOR csr_name IS
101 select
102 null
103 from
104 hr_ki_option_types_tl
105 where
106 option_type_id <> p_option_type_id
107 and option_name =p_option_name
108 and language=p_language;
109
110
111 l_check varchar2(1);
112
113 Begin
114 hr_utility.set_location('Entering:'||l_proc,10);
115 --
116 -- Check value has been passed
117 --
118 hr_api.mandatory_arg_error
119 (p_api_name => l_proc
120 ,p_argument => 'OPTION_NAME'
121 ,p_argument_value => p_option_name
122 );
123 hr_utility.set_location('Checking:'||l_proc,20);
124
125 -- check if the record already exists
126
127 open csr_name;
128 fetch csr_name into l_name;
129 hr_utility.set_location('After fetching:'||l_proc,30);
130 if (csr_name%found)
131 then
132 close csr_name;
133 fnd_message.set_name('PER','PER_449951_OTT_NAME_DUPLICATE');
134 fnd_message.raise_error;
135 end if;
136 close csr_name;
137
138 hr_utility.set_location(' Leaving:'||l_proc,40);
139
140 exception
141 when app_exception.application_exception then
142 if hr_multi_message.exception_add
143 (p_associated_column1 => 'HR_KI_OPTION_TYPES_TL.OPTION_NAME'
144 )then
145 hr_utility.set_location(' Leaving:'||l_proc, 50);
146 raise;
147 end if;
148 hr_utility.set_location(' Leaving:'||l_proc,60);
149
150
151 End chk_option_name;
152 --
153
154 -- ----------------------------------------------------------------------------
155 -- |-----------------------< chk_option_type_id>------------------------|
156 -- ----------------------------------------------------------------------------
157 -- {Start Of Comments}
158 --
159 -- Description:
160 -- This procedure ensures a if parent option type id exists
161 -- Pre Conditions:
162 -- g_old_rec has been populated with details of the values currently in
163 -- the database.
164 --
165 -- In Arguments:
166 -- p_option_type_id
167 --
168 -- Post Success:
169 -- Processing continues if option type id exist in hr_ki_option_types table
170 --
171 -- Post Failure:
172 -- An application error is raised if id does not exist in hr_ki_option_types
173 --
174 -- {End Of Comments}
175 -- ----------------------------------------------------------------------------
176
177
178 procedure chk_option_type_id
179 (
180 p_option_type_id in number
181 )
182 is
183 -- Declare cursors and local variables
184 --
185 -- Cursor to check if there is an entry in hr_ki_hi
186 l_proc varchar2(72) := g_package || 'chk_option_type_id';
187 l_name varchar2(1);
188
189
190 CURSOR csr_id is
191 select
192 null
193 From
194 hr_ki_option_types
195 where
196 option_type_id = p_option_type_id;
197
198 Begin
199
200
201 hr_utility.set_location(' Entering:' || l_proc,10);
202
203 open csr_id;
204 fetch csr_id into l_name;
205
206 if csr_id%NOTFOUND then
207 fnd_message.set_name('PER', 'PER_449950_OTT_ID_ABSENT');
208 fnd_message.raise_error;
209 end if;
210
211 close csr_id;
212
213 hr_utility.set_location(' Leaving:' || l_proc,20);
214
215 Exception
216 when app_exception.application_exception then
217 IF hr_multi_message.exception_add
218 (p_associated_column1 => 'HR_KI_OPTION_TYPES_TL.OPTION_TYPE_ID'
219 ) THEN
220 hr_utility.set_location(' Leaving:'|| l_proc,30);
221 raise;
222 END IF;
223
224 hr_utility.set_location(' Leaving:'|| l_proc,40);
225 --
226 End chk_option_type_id;
227
228
229 --
230 -- ----------------------------------------------------------------------------
231 -- |---------------------------< insert_validate >----------------------------|
232 -- ----------------------------------------------------------------------------
233 Procedure insert_validate
234 (p_rec in hr_ott_shd.g_rec_type
235 ,p_option_type_id in number
236 ) is
237 --
238 l_proc varchar2(72) := g_package||'insert_validate';
239 --
240 Begin
241 hr_utility.set_location('Entering:'||l_proc, 5);
242 --
243 -- Call all supporting business operations
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 --call validation methods
251
252
253 CHK_OPTION_TYPE_ID
254 (
255 p_option_type_id => p_option_type_id
256 );
257
258 CHK_OPTION_NAME
259 (
260 p_option_type_id => p_option_type_id
261 ,p_option_name => p_rec.option_name
262 ,p_language => p_rec.language
263 );
264
265
266 hr_utility.set_location(' Leaving:'||l_proc, 10);
267 End insert_validate;
268 --
269 -- ----------------------------------------------------------------------------
270 -- |---------------------------< update_validate >----------------------------|
271 -- ----------------------------------------------------------------------------
272 Procedure update_validate
273 (p_rec in hr_ott_shd.g_rec_type
274 ,p_option_type_id in number
275 ) is
276 --
277 l_proc varchar2(72) := g_package||'update_validate';
278 --
279 Begin
280 hr_utility.set_location('Entering:'||l_proc, 5);
281 --
282 -- Call all supporting business operations
283 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
284 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
285 --
286 -- Validate Dependent Attributes
287 --
288 chk_non_updateable_args
289 (p_rec => p_rec
290 );
291
292 CHK_OPTION_NAME
293 (
294 p_option_type_id => p_option_type_id
295 ,p_option_name => p_rec.option_name
296 ,p_language => p_rec.language
297 );
298
299 --
300 --
301 hr_utility.set_location(' Leaving:'||l_proc, 10);
302 End update_validate;
303 --
304 -- ----------------------------------------------------------------------------
305 -- |---------------------------< delete_validate >----------------------------|
306 -- ----------------------------------------------------------------------------
307 Procedure delete_validate
308 (p_rec in hr_ott_shd.g_rec_type
309 ) is
310 --
311 l_proc varchar2(72) := g_package||'delete_validate';
312 --
313 Begin
314 hr_utility.set_location('Entering:'||l_proc, 5);
315 --
316 -- Call all supporting business operations
317 --
318 hr_utility.set_location(' Leaving:'||l_proc, 10);
319 End delete_validate;
320 --
321 end hr_ott_bus;