1 Package Body pqp_ert_bus as
2 /* $Header: pqertrhi.pkb 120.7 2006/09/15 00:09:58 sshetty noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqp_ert_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_exception_report_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_exception_report_id in number
23 ) is
24 --
25 -- Declare cursor
26 --
27 cursor csr_sec_grp is
28 select pbg.security_group_id
29 from per_business_groups pbg
30 , pqp_exception_reports_tl ert
31 , pqp_exception_reports exr
32 where ert.exception_report_id = p_exception_report_id
33 and pbg.business_group_id = exr.business_group_id
34 and exr.exception_report_id = ert.exception_report_id;
35 --
36 -- Declare local variables
37 --
38 l_security_group_id number;
39 l_proc varchar2(72) := g_package||'set_security_group_id';
40 --
41 begin
42 --
43 hr_utility.set_location('Entering:'|| l_proc, 10);
44 --
45 -- Ensure that all the mandatory parameter are not null
46 --
47 hr_api.mandatory_arg_error
48 (p_api_name => l_proc
49 ,p_argument => 'exception_report_id'
50 ,p_argument_value => p_exception_report_id
51 );
52 --
53 --
54 IF hr_startup_data_api_support.g_startup_mode NOT IN ('GENERIC','STARTUP') THEN
55 open csr_sec_grp;
56 fetch csr_sec_grp into l_security_group_id;
57 --
58 if csr_sec_grp%notfound then
59 --
60 close csr_sec_grp;
61 --
62 -- The primary key is invalid therefore we must error
63 --
64 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
65 fnd_message.raise_error;
66 --
67 end if;
68 close csr_sec_grp;
69 END IF;
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 -- |---------------------< return_legislation_code >-------------------------|
83 -- ---------------------------------------------------------------------------
84 --
85 Function return_legislation_code
86 (p_exception_report_id in number
87 ,p_language in varchar2
88 )
89 Return Varchar2 Is
90 --
91 -- Declare cursor
92 --
93 cursor csr_leg_code is
94 select pbg.legislation_code
95 from per_business_groups pbg
96 ,pqp_exception_reports exr
97 where exr.exception_report_id = p_exception_report_id
98 and pbg.business_group_id = exr.business_group_id;
99
100 --
101 -- Declare local variables
102 --
103 l_legislation_code varchar2(150);
104 l_proc varchar2(72) := g_package||'return_legislation_code';
105 --
106 Begin
107 --
108 hr_utility.set_location('Entering:'|| l_proc, 10);
109 --
110 -- Ensure that all the mandatory parameter are not null
111 --
112 hr_api.mandatory_arg_error
113 (p_api_name => l_proc
114 ,p_argument => 'exception_report_id'
115 ,p_argument_value => p_exception_report_id
116 );
117 --
118 --
119 if (( nvl(pqp_ert_bus.g_exception_report_id, hr_api.g_number)
120 = p_exception_report_id)
121 and ( nvl(pqp_ert_bus.g_language, hr_api.g_varchar2)
122 = p_language)) then
123 --
124 -- The legislation code has already been found with a previous
125 -- call to this function. Just return the value in the global
126 -- variable.
127 --
128 l_legislation_code := pqp_ert_bus.g_legislation_code;
129 hr_utility.set_location(l_proc, 20);
130 else
131 --
132 -- The ID is different to the last call to this function
133 -- or this is the first call to this function.
134 --
135 open csr_leg_code;
136 fetch csr_leg_code into l_legislation_code;
137 --
138 if csr_leg_code%notfound then
139 --
140 -- The primary key is invalid therefore we must error
141 --
142 close csr_leg_code;
143 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
144 fnd_message.raise_error;
145 end if;
146 hr_utility.set_location(l_proc,30);
147 --
148 -- Set the global variables so the values are
149 -- available for the next call to this function.
150 --
151 close csr_leg_code;
152 pqp_ert_bus.g_exception_report_id := p_exception_report_id;
153 pqp_ert_bus.g_language := p_language;
154 pqp_ert_bus.g_legislation_code := l_legislation_code;
155 end if;
156 hr_utility.set_location(' Leaving:'|| l_proc, 40);
157 return l_legislation_code;
158 end return_legislation_code;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |-----------------------< chk_non_updateable_args >------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 -- This procedure is used to ensure that non updateable attributes have
167 -- not been updated. If an attribute has been updated an error is generated.
168 --
169 -- Pre Conditions:
170 -- g_old_rec has been populated with details of the values currently in
171 -- the database.
172 --
173 -- In Arguments:
174 -- p_rec has been populated with the updated values the user would like the
175 -- record set to.
176 --
177 -- Post Success:
178 -- Processing continues if all the non updateable attributes have not
179 -- changed.
180 --
181 -- Post Failure:
182 -- An application error is raised if any of the non updatable attributes
183 -- have been altered.
184 --
185 -- {End Of Comments}
186 -- ----------------------------------------------------------------------------
187 Procedure chk_non_updateable_args
188 (p_rec in pqp_ert_shd.g_rec_type
189 ) IS
190 --
191 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
192 l_error EXCEPTION;
193 l_argument varchar2(30);
194 --
195 Begin
196 --
197 -- Only proceed with the validation if a row exists for the current
198 -- record in the HR Schema.
199 --
200 IF NOT pqp_ert_shd.api_updating
201 (p_exception_report_id => p_rec.exception_report_id
202 ,p_language => p_rec.language
203 ) THEN
204 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
205 fnd_message.set_token('PROCEDURE ', l_proc);
206 fnd_message.set_token('STEP ', '5');
207 fnd_message.raise_error;
208 END IF;
209 --
210 --
211 EXCEPTION
212 WHEN l_error THEN
213 hr_api.argument_changed_error
214 (p_api_name => l_proc
215 ,p_argument => l_argument);
216 WHEN OTHERS THEN
217 RAISE;
218 End chk_non_updateable_args;
219 --
220 -- ----------------------------------------------------------------------------
221 -- |---------------------------< insert_validate >----------------------------|
222 -- ----------------------------------------------------------------------------
223 Procedure insert_validate
224 (p_rec in pqp_ert_shd.g_rec_type
225 ) is
226 --
227 l_proc varchar2(72) := g_package||'insert_validate';
228 --
229 Begin
230 hr_utility.set_location('Entering:'||l_proc, 5);
231 --
232 -- Call all supporting business operations
233 --
234 --
235 --set_security_group_id(p_rec.exception_report_id);
236 --
237 hr_utility.set_location(' Leaving:'||l_proc, 10);
238 End insert_validate;
239 --
240 -- ----------------------------------------------------------------------------
241 -- |---------------------------< update_validate >----------------------------|
242 -- ----------------------------------------------------------------------------
243 Procedure update_validate
244 (p_rec in pqp_ert_shd.g_rec_type
245 ) is
246 --
247 l_proc varchar2(72) := g_package||'update_validate';
248 --
249 Begin
250 hr_utility.set_location('Entering:'||l_proc, 5);
251 --
252 -- Call all supporting business operations
253 --
254 --
255 set_security_group_id(p_rec.exception_report_id);
256 --
257 chk_non_updateable_args (
258 p_rec => p_rec
259 );
260 --
261 --
262 hr_utility.set_location(' Leaving:'||l_proc, 10);
263 End update_validate;
264 --
265 -- ----------------------------------------------------------------------------
266 -- |---------------------------< delete_validate >----------------------------|
267 -- ----------------------------------------------------------------------------
268 Procedure delete_validate
269 (p_rec in pqp_ert_shd.g_rec_type
270 ) is
271 --
272 l_proc varchar2(72) := g_package||'delete_validate';
273 --
274 Begin
275 hr_utility.set_location('Entering:'||l_proc, 5);
276 --
277 -- Call all supporting business operations
278 --
279 hr_utility.set_location(' Leaving:'||l_proc, 10);
280 End delete_validate;
281 --
282 end pqp_ert_bus;