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