1 Package Body hr_ort_bus as
2 /* $Header: hrortrhi.pkb 115.4 2004/06/29 00:31:44 kjagadee noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_ort_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_organization_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_organization_id in number
23 ) is
24 --
25 -- Declare cursor
26 --
27 -- EDIT_HERE In the following cursor statement add join(s) between
28 -- hr_all_organization_units_tl and PER_BUSINESS_GROUPS
29 -- so that the security_group_id for
30 -- the current business group context can be derived.
31 -- Remove this comment when the edit has been completed.
32 cursor csr_sec_grp is
33 select pbg.security_group_id
34 from per_business_groups pbg
35 , hr_all_organization_units ort
36 -- , EDIT_HERE table_name(s) 333
37 where ort.organization_id = p_organization_id
38 and pbg.business_group_id = ort.business_group_id;
39 -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
40 --
41 -- Declare local variables
42 --
43 l_security_group_id number;
44 l_proc varchar2(72) := g_package||'set_security_group_id';
45 --
46 begin
47 --
48 hr_utility.set_location('Entering:'|| l_proc, 10);
49 --
50 -- Ensure that all the mandatory parameter are not null
51 --
52 hr_api.mandatory_arg_error
53 (p_api_name => l_proc
54 ,p_argument => 'organization_id'
55 ,p_argument_value => p_organization_id
56 );
57 --
58 --
59 open csr_sec_grp;
60 fetch csr_sec_grp into l_security_group_id;
61 --
62 if csr_sec_grp%notfound then
63 --
64 close csr_sec_grp;
65 --
66 -- The primary key is invalid therefore we must error
67 --
68 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
69 fnd_message.raise_error;
70 --
71 end if;
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 hr_utility.set_location(' Leaving:'|| l_proc, 20);
81 --
82 end set_security_group_id;
83 --
84 -- ---------------------------------------------------------------------------
85 -- |---------------------< return_legislation_code >-------------------------|
86 -- ---------------------------------------------------------------------------
87 --
88 Function return_legislation_code
89 (p_organization_id in number
90 ,p_language in varchar2
91 )
92 Return Varchar2 Is
93 --
94 -- Declare cursor
95 --
96 -- EDIT_HERE In the following cursor statement add join(s) between
97 -- hr_all_organization_units_tl and PER_BUSINESS_GROUPS
98 -- so that the legislation_code for
99 -- the current business group context can be derived.
100 -- Remove this comment when the edit has been completed.
101 cursor csr_leg_code is
102 select pbg.legislation_code
103 from per_business_groups pbg
104 , hr_all_organization_units_tl ort
105 -- , EDIT_HERE table_name(s) 333
106 where ort.organization_id = p_organization_id
107 and ort.language = p_language;
108 -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
109 --
110 -- Declare local variables
111 --
112 l_legislation_code varchar2(150);
113 l_proc varchar2(72) := g_package||'return_legislation_code';
114 --
115 Begin
116 --
117 hr_utility.set_location('Entering:'|| l_proc, 10);
118 --
119 -- Ensure that all the mandatory parameter are not null
120 --
121 hr_api.mandatory_arg_error
122 (p_api_name => l_proc
123 ,p_argument => 'organization_id'
124 ,p_argument_value => p_organization_id
125 );
126 --
127 --
128 if (( nvl(hr_ort_bus.g_organization_id, hr_api.g_number)
129 = p_organization_id)
130 and ( nvl(hr_ort_bus.g_language, hr_api.g_varchar2)
131 = p_language)) 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 := hr_ort_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 hr_ort_bus.g_organization_id := p_organization_id;
162 hr_ort_bus.g_language := p_language;
163 hr_ort_bus.g_legislation_code := l_legislation_code;
164 end if;
165 hr_utility.set_location(' Leaving:'|| l_proc, 40);
166 return l_legislation_code;
167 end return_legislation_code;
168 --
169 -- ----------------------------------------------------------------------------
170 -- |-----------------------< chk_non_updateable_args >------------------------|
171 -- ----------------------------------------------------------------------------
172 -- {Start Of Comments}
173 --
174 -- Description:
175 -- This procedure is used to ensure that non updateable attributes have
176 -- not been updated. If an attribute has been updated an error is generated.
177 --
178 -- Pre Conditions:
179 -- g_old_rec has been populated with details of the values currently in
180 -- the database.
181 --
182 -- In Arguments:
183 -- p_rec has been populated with the updated values the user would like the
184 -- record set to.
185 --
186 -- Post Success:
187 -- Processing continues if all the non updateable attributes have not
188 -- changed.
189 --
190 -- Post Failure:
191 -- An application error is raised if any of the non updatable attributes
192 -- have been altered.
193 --
194 -- {End Of Comments}
195 -- ----------------------------------------------------------------------------
196 Procedure chk_non_updateable_args
197 (p_rec in hr_ort_shd.g_rec_type
198 ) IS
199 --
200 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
201 l_error EXCEPTION;
202 l_argument varchar2(30);
203 --
204 Begin
205 --
206 -- Only proceed with the validation if a row exists for the current
207 -- record in the HR Schema.
208 --
209 IF NOT hr_ort_shd.api_updating
210 (p_organization_id => p_rec.organization_id
211 ,p_language => p_rec.language
212 ) THEN
213 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
214 fnd_message.set_token('PROCEDURE ', l_proc);
215 fnd_message.set_token('STEP ', '5');
216 fnd_message.raise_error;
217 END IF;
218 --
219 -- EDIT_HERE: Add checks to ensure non-updateable args have
220 -- not been updated.
221 --
222 EXCEPTION
223 WHEN l_error THEN
224 hr_api.argument_changed_error
225 (p_api_name => l_proc
226 ,p_argument => l_argument);
227 WHEN OTHERS THEN
228 RAISE;
229 End chk_non_updateable_args;
230 --
231 -- ----------------------------------------------------------------------------
232 -- |---------------------------< insert_validate >----------------------------|
233 -- ----------------------------------------------------------------------------
234 Procedure insert_validate
235 (p_rec in hr_ort_shd.g_rec_type
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 --
245 --
246 -- EDIT_HERE: As this table does not have a mandatory business_group_id
247 -- column, ensure client_info is populated by calling a suitable
248 -- ???_???_bus.set_security_group_id procedure, or add one of the following
249 -- comments:
250 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
251 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
252 --
253 --
254 hr_utility.set_location(' Leaving:'||l_proc, 10);
255 End insert_validate;
256 --
257 -- ----------------------------------------------------------------------------
258 -- |---------------------------< update_validate >----------------------------|
259 -- ----------------------------------------------------------------------------
260 Procedure update_validate
261 (p_rec in hr_ort_shd.g_rec_type
262 ) is
263 --
264 l_proc varchar2(72) := g_package||'update_validate';
265 --
266 Begin
267 hr_utility.set_location('Entering:'||l_proc, 5);
268 --
269 -- Call all supporting business operations
270 --
271 -- EDIT_HERE: As this table does not have a mandatory business_group_id
272 -- column, ensure client_info is populated by calling a suitable
273 -- ???_???_bus.set_security_group_id procedure, or add one of the following
274 -- comments:
275 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
276 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
277 --
278 chk_non_updateable_args
279 (p_rec => p_rec
280 );
281 --
282 --
283 hr_utility.set_location(' Leaving:'||l_proc, 10);
284 End update_validate;
285 --
286 -- ----------------------------------------------------------------------------
287 -- |---------------------------< delete_validate >----------------------------|
288 -- ----------------------------------------------------------------------------
289 Procedure delete_validate
290 (p_rec in hr_ort_shd.g_rec_type
291 ) is
292 --
293 l_proc varchar2(72) := g_package||'delete_validate';
294 --
295 Begin
296 hr_utility.set_location('Entering:'||l_proc, 5);
297 --
298 -- Call all supporting business operations
299 --
300 hr_utility.set_location(' Leaving:'||l_proc, 10);
301 End delete_validate;
302 --
303 end hr_ort_bus;