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