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