1 Package Body per_wbt_bus as
2 /* $Header: pewbtrhi.pkb 115.2 2004/07/04 23:58:13 balchand noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_wbt_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_workbench_item_code varchar2(60) 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_workbench_item_code in varchar2
23 ,p_associated_column1 in varchar2 default null
24 ) is
25 --
26 -- Declare cursor
27 --
28
29 cursor csr_sec_grp is
30 select Null --pbg.security_group_id,
31 --pbg.legislation_code
32 from -- per_business_groups_perf pbg
33 per_ri_workbench_items_tl wbt
34 where wbt.workbench_item_code = p_workbench_item_code;
35
36 --
37 -- Declare local variables
38 --
39 l_security_group_id number;
40 l_proc varchar2(72) := g_package||'set_security_group_id';
41 l_legislation_code varchar2(150);
42 --
43 begin
44 --
45 hr_utility.set_location('Entering:'|| l_proc, 10);
46 --
47 -- Ensure that all the mandatory parameter are not null
48 --
49 hr_api.mandatory_arg_error
50 (p_api_name => l_proc
51 ,p_argument => 'workbench_item_code'
52 ,p_argument_value => p_workbench_item_code
53 );
54 --
55 --
56 open csr_sec_grp;
57 fetch csr_sec_grp into l_security_group_id ;
58 --, l_legislation_code;
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 hr_multi_message.add
68 (p_associated_column1
69 => nvl(p_associated_column1,'WORKBENCH_ITEM_CODE')
70 );
71 --
72 else
73 close csr_sec_grp;
74 --
75 -- Set the security_group_id in CLIENT_INFO
76 --
77 hr_api.set_security_group_id
78 (p_security_group_id => l_security_group_id
79 );
80 --
81 -- Set the sessions legislation context in HR_SESSION_DATA
82 --
83 hr_api.set_legislation_context(l_legislation_code);
84 end if;
85 --
86 hr_utility.set_location(' Leaving:'|| l_proc, 20);
87 --
88 end set_security_group_id;
89 --
90 -- ---------------------------------------------------------------------------
91 -- |---------------------< return_legislation_code >-------------------------|
92 -- ---------------------------------------------------------------------------
93 --
94 Function return_legislation_code
95 (p_workbench_item_code in varchar2
96 ,p_language in varchar2
97 )
98 Return Varchar2 Is
99 --
100 -- Declare cursor
101 --
102 -- EDIT_HERE In the following cursor statement add join(s) between
103 -- per_ri_workbench_items_tl and PER_BUSINESS_GROUPS_PERF
104 -- so that the legislation_code for
105 -- the current business group context can be derived.
106 -- Remove this comment when the edit has been completed.
107 cursor csr_leg_code is
108 select null --pbg.legislation_code
109 from --per_business_groups_perf pbg
110 per_ri_workbench_items_tl wbt
111 -- , EDIT_HERE table_name(s) 333
112 where wbt.workbench_item_code = p_workbench_item_code
113 and wbt.language = p_language;
114 -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
115 --
116 -- Declare local variables
117 --
118 l_legislation_code varchar2(150);
119 l_proc varchar2(72) := g_package||'return_legislation_code';
120 --
121 Begin
122 --
123 hr_utility.set_location('Entering:'|| l_proc, 10);
124 --
125 -- Ensure that all the mandatory parameter are not null
126 --
127 hr_api.mandatory_arg_error
128 (p_api_name => l_proc
129 ,p_argument => 'workbench_item_code'
130 ,p_argument_value => p_workbench_item_code
131 );
132 --
133 --
134 if (( nvl(per_wbt_bus.g_workbench_item_code, hr_api.g_varchar2)
135 = p_workbench_item_code)
136 and ( nvl(per_wbt_bus.g_language, hr_api.g_varchar2)
137 = p_language)) then
138 --
139 -- The legislation code has already been found with a previous
140 -- call to this function. Just return the value in the global
141 -- variable.
142 --
143 l_legislation_code := per_wbt_bus.g_legislation_code;
144 hr_utility.set_location(l_proc, 20);
145 else
146 --
147 -- The ID is different to the last call to this function
148 -- or this is the first call to this function.
149 --
150 open csr_leg_code;
151 fetch csr_leg_code into l_legislation_code;
152 --
153 if csr_leg_code%notfound then
154 --
155 -- The primary key is invalid therefore we must error
156 --
157 close csr_leg_code;
158 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
159 fnd_message.raise_error;
160 end if;
161 hr_utility.set_location(l_proc,30);
162 --
163 -- Set the global variables so the values are
164 -- available for the next call to this function.
165 --
166 close csr_leg_code;
167 per_wbt_bus.g_workbench_item_code := p_workbench_item_code;
168 per_wbt_bus.g_language := p_language;
169 per_wbt_bus.g_legislation_code := l_legislation_code;
170 end if;
171 hr_utility.set_location(' Leaving:'|| l_proc, 40);
172 return l_legislation_code;
173 end return_legislation_code;
174 --
175 -- ----------------------------------------------------------------------------
176 -- |-----------------------< chk_non_updateable_args >------------------------|
177 -- ----------------------------------------------------------------------------
178 -- {Start Of Comments}
179 --
180 -- Description:
181 -- This procedure is used to ensure that non updateable attributes have
182 -- not been updated. If an attribute has been updated an error is generated.
183 --
184 -- Pre Conditions:
185 -- g_old_rec has been populated with details of the values currently in
186 -- the database.
187 --
188 -- In Arguments:
189 -- p_rec has been populated with the updated values the user would like the
190 -- record set to.
191 --
192 -- Post Success:
193 -- Processing continues if all the non updateable attributes have not
194 -- changed.
195 --
196 -- Post Failure:
197 -- An application error is raised if any of the non updatable attributes
198 -- have been altered.
199 --
200 -- {End Of Comments}
201 -- ----------------------------------------------------------------------------
202 Procedure chk_non_updateable_args
203 (p_rec in per_wbt_shd.g_rec_type
204 ) IS
205 --
206 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
207 --
208 Begin
209 --
210 -- Only proceed with the validation if a row exists for the current
211 -- record in the HR Schema.
212 --
213 IF NOT per_wbt_shd.api_updating
214 (p_workbench_item_code => p_rec.workbench_item_code
215 ,p_language => p_rec.language
216 ) THEN
217 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
218 fnd_message.set_token('PROCEDURE ', l_proc);
219 fnd_message.set_token('STEP ', '5');
220 fnd_message.raise_error;
221 END IF;
222 --
223 -- EDIT_HERE: Add checks to ensure non-updateable args have
224 -- not been updated.
225 --
226 End chk_non_updateable_args;
227 --
228 -- ----------------------------------------------------------------------------
229 -- |---------------------------< insert_validate >----------------------------|
230 -- ----------------------------------------------------------------------------
231 Procedure insert_validate
232 (p_rec in per_wbt_shd.g_rec_type
233 ) is
234 --
235 l_proc varchar2(72) := g_package||'insert_validate';
236 --
237 Begin
238 hr_utility.set_location('Entering:'||l_proc, 5);
239 --
240 -- Call all supporting business operations
241 --
242 --
243 -- EDIT_HERE: As this table does not have a mandatory business_group_id
244 -- column, ensure client_info is populated by calling a suitable
245 -- ???_???_bus.set_security_group_id procedure, or add one of the following
246 -- comments:
247 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
248 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
249 --
250 -- Validate Dependent Attributes
251 --
252 --
253 hr_utility.set_location(' Leaving:'||l_proc, 10);
254 End insert_validate;
255 --
256 -- ----------------------------------------------------------------------------
257 -- |---------------------------< update_validate >----------------------------|
258 -- ----------------------------------------------------------------------------
259 Procedure update_validate
260 (p_rec in per_wbt_shd.g_rec_type
261 ) is
262 --
263 l_proc varchar2(72) := g_package||'update_validate';
264 --
265 Begin
266 hr_utility.set_location('Entering:'||l_proc, 5);
267 --
268 -- Call all supporting business operations
269 --
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 -- Validate Dependent Attributes
279 --
280 chk_non_updateable_args
281 (p_rec => p_rec
282 );
283 --
284 --
285 hr_utility.set_location(' Leaving:'||l_proc, 10);
286 End update_validate;
287 --
288 -- ----------------------------------------------------------------------------
289 -- |---------------------------< delete_validate >----------------------------|
290 -- ----------------------------------------------------------------------------
291 Procedure delete_validate
292 (p_rec in per_wbt_shd.g_rec_type
293 ) is
294 --
295 l_proc varchar2(72) := g_package||'delete_validate';
296 --
297 Begin
298 hr_utility.set_location('Entering:'||l_proc, 5);
299 --
300 -- Call all supporting business operations
301 --
302 hr_utility.set_location(' Leaving:'||l_proc, 10);
303 End delete_validate;
304 --
305 end per_wbt_bus;