1 Package Body hxc_hts_bus as
2 /* $Header: hxchtsrhi.pkb 120.2 2005/09/23 07:49:02 nissharm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_hts_bus.'; -- Global package name
9
10 g_debug boolean := hr_utility.debug_enabled;
11 --
12 -- ----------------------------------------------------------------------------
13 -- |-----------------------< chk_non_updateable_args >------------------------|
14 -- ----------------------------------------------------------------------------
15 -- {Start Of Comments}
16 --
17 -- Description:
18 -- This procedure is used to ensure that non updateable attributes have
19 -- not been updated. If an attribute has been updated an error is generated.
20 --
21 -- Pre Conditions:
22 -- g_old_rec has been populated with details of the values currently in
23 -- the database.
24 --
25 -- In Arguments:
26 -- p_rec has been populated with the updated values the user would like the
27 -- record set to.
28 --
29 -- Post Success:
30 -- Processing continues if all the non updateable attributes have not
31 -- changed.
32 --
33 -- Post Failure:
34 -- An application error is raised if any of the non updatable attributes
35 -- have been altered.
36 --
37 -- {End Of Comments}
38 -- ----------------------------------------------------------------------------
39 Procedure chk_non_updateable_args
40 (p_effective_date in date
41 ,p_rec in hxc_hts_shd.g_rec_type
42 ) IS
43 --
44 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
45 l_error EXCEPTION;
46 l_argument varchar2(30);
47 --
48 Begin
49 --
50 -- Only proceed with the validation if a row exists for the current
51 -- record in the HR Schema.
52 --
53 IF NOT hxc_hts_shd.api_updating
54 (p_time_source_id => p_rec.time_source_id
55 ,p_object_version_number => p_rec.object_version_number
56 ) THEN
57 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
58 fnd_message.set_token('PROCEDURE ', l_proc);
59 fnd_message.set_token('STEP ', '5');
60 fnd_message.raise_error;
61 END IF;
62 --
63 -- EDIT_HERE: Add checks to ensure non-updateable args have
64 -- not been updated.
65 --
66 EXCEPTION
67 WHEN l_error THEN
68 hr_api.argument_changed_error
69 (p_api_name => l_proc
70 ,p_argument => l_argument);
71 WHEN OTHERS THEN
72 RAISE;
73 End chk_non_updateable_args;
74 --
75 -- ----------------------------------------------------------------------------
76 -- |-----------------------< chk_name >---------------------------------------|
77 -- ----------------------------------------------------------------------------
78 -- {Start Of Comments}
79 --
80 -- Description:
81 --
82 -- SEE DESCRIPTION IN PACKAGE HEADER
83 --
84 -- Pre Conditions:
85 -- None
86 --
87 -- In Arguments:
88 -- name
89 -- time_source_id
90 --
91 -- Post Success:
92 -- Processing continues if the name business rules have not been violated
93 --
94 -- Post Failure:
95 -- An application error is raised if the name is not valid
96 --
97 -- {End Of Comments}
98 -- ----------------------------------------------------------------------------
99 Procedure chk_name
100 (
101 p_name in hxc_time_sources.name%TYPE
102 ,p_time_source_id in hxc_time_sources.time_source_id%TYPE
103 ) IS
104 --
105 l_proc varchar2(72);
106 --
107 -- cursor to check name is unique
108 --
109 CURSOR csr_chk_name IS
110 SELECT 'error'
111 FROM sys.dual
112 WHERE EXISTS (
113 SELECT 'x'
114 FROM hxc_time_sources tr
115 WHERE tr.name = p_name
116 AND ( tr.time_source_id <> p_time_source_id
117 OR p_time_source_id IS NULL) );
118 --
119 l_dup_name varchar2(5) := NULL;
120 --
121 BEGIN
122 g_debug := hr_utility.debug_enabled;
123
124 if g_debug then
125 l_proc := g_package||'chk_name';
126 hr_utility.set_location('Entering:'||l_proc, 5);
127 end if;
128 --
129 -- check that the name has been entered
130 --
131 IF p_name IS NULL
132 THEN
133 --
134 hr_utility.set_message(809, 'HXC_0062_HTS_NAME_MAND');
135 hr_utility.raise_error;
136 --
137 END IF;
138 if g_debug then
139 hr_utility.set_location('Processing:'||l_proc, 10);
140 end if;
141 --
142 -- check that the name is unique
143 --
144 OPEN csr_chk_name;
145 FETCH csr_chk_name INTO l_dup_name;
146 CLOSE csr_chk_name;
147 --
148 IF l_dup_name IS NOT NULL
149 THEN
150 --
151 hr_utility.set_message(809, 'HXC_0063_HTS_DUP_NAME');
152 hr_utility.raise_error;
153 --
154 END IF;
155 --
156 if g_debug then
157 hr_utility.set_location('Leaving:'||l_proc, 20);
158 end if;
159 --
160 END chk_name;
161 --
162 -- ----------------------------------------------------------------------------
163 -- |-----------------------< chk_delete >-------------------------------------|
164 -- ----------------------------------------------------------------------------
165 --
166 -- Description:
167 --
168 -- SEE DESCRIPTION IN PACKAGE HEADER
169 --
170 -- Pre Conditions:
171 -- None
172 --
173 -- In Arguments:
174 -- time_source_id
175 --
176 -- Post Success:
177 -- Processing continues if the name is not being referenced
178 --
179 -- Post Failure:
180 -- An application error is raised if the rule is being used.
181 --
182 -- {End Of Comments}
183 -- ----------------------------------------------------------------------------
184 Procedure chk_delete
185 (
186 p_time_source_id in hxc_time_sources.time_source_id%TYPE
187 ) IS
188
189 l_used_elsewhere VARCHAR2(1) := 'N';
190
191 CURSOR csr_chk_dep IS
192 SELECT 'Y'
193 FROM sys.dual
194 WHERE EXISTS (
195 SELECT 'x'
196 FROM hxc_deposit_processes dep
197 WHERE dep.time_source_id = p_time_source_id);
198
199 BEGIN -- chk_delete
200
201 OPEN csr_chk_dep;
202 FETCH csr_chk_dep INTO l_used_elsewhere;
203 CLOSE csr_chk_dep;
204
205 IF ( l_used_elsewhere = 'Y' )
206 THEN
207 hr_utility.set_message(809, 'HXC_0064_HTS_IN_USE');
208 hr_utility.raise_error;
209 END IF;
210
211 END chk_delete;
212
213 -- ----------------------------------------------------------------------------
214 -- |---------------------------< insert_validate >----------------------------|
215 -- ----------------------------------------------------------------------------
216 Procedure insert_validate
217 (p_effective_date in date
218 ,p_rec in hxc_hts_shd.g_rec_type
219 ) is
220 --
221 l_proc varchar2(72);
222 --
223 Begin
224 g_debug := hr_utility.debug_enabled;
225
226 if g_debug then
227 l_proc := g_package||'insert_validate';
228 hr_utility.set_location('Entering:'||l_proc, 5);
229 end if;
230 --
231 -- Call all supporting business operations
232 --
233 hxc_hts_bus.chk_name ( p_name => p_rec.name
234 ,p_time_source_id => p_rec.time_source_id );
235
236 -- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS.
237 --
238 --
239 if g_debug then
240 hr_utility.set_location(' Leaving:'||l_proc, 10);
241 end if;
242 End insert_validate;
243 --
244 -- ----------------------------------------------------------------------------
245 -- |---------------------------< update_validate >----------------------------|
246 -- ----------------------------------------------------------------------------
247 Procedure update_validate
248 (p_effective_date in date
249 ,p_rec in hxc_hts_shd.g_rec_type
250 ) is
251 --
252 l_proc varchar2(72);
253 --
254 Begin
255 g_debug := hr_utility.debug_enabled;
256
257 if g_debug then
258 l_proc := g_package||'update_validate';
259 hr_utility.set_location('Entering:'||l_proc, 5);
260 end if;
261 --
262 -- Call all supporting business operations
263 --
264 hxc_hts_bus.chk_name ( p_name => p_rec.name
265 ,p_time_source_id => p_rec.time_source_id );
266 --
267 -- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS.
268 --
269 chk_non_updateable_args
270 (p_effective_date => p_effective_date
271 ,p_rec => p_rec
272 );
273 --
274 --
275 if g_debug then
276 hr_utility.set_location(' Leaving:'||l_proc, 10);
277 end if;
278 End update_validate;
279 --
280 -- ----------------------------------------------------------------------------
281 -- |---------------------------< delete_validate >----------------------------|
282 -- ----------------------------------------------------------------------------
283 Procedure delete_validate
284 (p_rec in hxc_hts_shd.g_rec_type
285 ) is
286 --
287 l_proc varchar2(72);
288 --
289 Begin
290 g_debug := hr_utility.debug_enabled;
291
292 if g_debug then
293 l_proc := g_package||'delete_validate';
294 hr_utility.set_location('Entering:'||l_proc, 5);
295 end if;
296 --
297 -- Call all supporting business operations
298 --
299 hxc_hts_bus.chk_delete ( p_time_source_id => p_rec.time_source_id );
300
301 if g_debug then
302 hr_utility.set_location(' Leaving:'||l_proc, 10);
303 end if;
304 End delete_validate;
305 --
306 end hxc_hts_bus;