DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_STB_BUS

Source


1 Package Body per_stb_bus as
2 /* $Header: pestbrhi.pkb 115.0 2003/07/03 06:26:56 kavenkat noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_stb_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_setup_task_code             varchar2(60)   default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_setup_task_code                      in varchar2
22   ,p_associated_column1                   in varchar2 default null
23   ) is
24   --
25   -- Declare cursor
26 
27   cursor csr_sec_grp is
28     select NULL --pbg.security_group_id,
29            -- pbg.legislation_code
30       from -- per_business_groups_perf pbg
31           per_ri_setup_tasks stb
32       --   , EDIT_HERE table_name(s) 333
33      where stb.setup_task_code = p_setup_task_code;
34       -- and pbg.business_group_id = EDIT_HERE 333.business_group_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   l_legislation_code  varchar2(150);
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           => 'setup_task_code'
51     ,p_argument_value     => p_setup_task_code
52     );
53   --
54   open csr_sec_grp;
55   fetch csr_sec_grp into l_security_group_id ;
56                       -- , l_legislation_code;
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,'SETUP_TASK_CODE')
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     --
79     -- Set the sessions legislation context in HR_SESSION_DATA
80     --
81     hr_api.set_legislation_context(l_legislation_code);
82   end if;
83   --
84   hr_utility.set_location(' Leaving:'|| l_proc, 20);
85   --
86 end set_security_group_id;
87 --
88 --  ---------------------------------------------------------------------------
89 --  |---------------------< return_legislation_code >-------------------------|
90 --  ---------------------------------------------------------------------------
91 --
92 Function return_legislation_code
93   (p_setup_task_code                      in     varchar2
94   )
95   Return Varchar2 Is
96   --
97   -- Declare cursor
98 
99   cursor csr_leg_code is
100     select NULL --pbg.legislation_code
101       from --per_business_groups_perf     pbg
102           per_ri_setup_tasks stb
103      where stb.setup_task_code = p_setup_task_code;
104       -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
105   --
106   -- Declare local variables
107   --
108   l_legislation_code  varchar2(150);
109   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
110   --
111 Begin
112   --
113   hr_utility.set_location('Entering:'|| l_proc, 10);
114   --
115   -- Ensure that all the mandatory parameter are not null
116   --
117   hr_api.mandatory_arg_error
118     (p_api_name           => l_proc
119     ,p_argument           => 'setup_task_code'
120     ,p_argument_value     => p_setup_task_code
121     );
122   --
123   if ( nvl(per_stb_bus.g_setup_task_code, hr_api.g_varchar2)
124        = p_setup_task_code) then
125     --
126     -- The legislation code has already been found with a previous
127     -- call to this function. Just return the value in the global
128     -- variable.
129     --
130     l_legislation_code := per_stb_bus.g_legislation_code;
131     hr_utility.set_location(l_proc, 20);
132   else
133     --
134     -- The ID is different to the last call to this function
135     -- or this is the first call to this function.
136     --
137     open csr_leg_code;
138     fetch csr_leg_code into l_legislation_code;
139     --
140     if csr_leg_code%notfound then
141       --
142       -- The primary key is invalid therefore we must error
143       --
144       close csr_leg_code;
145       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
146       fnd_message.raise_error;
147     end if;
148     hr_utility.set_location(l_proc,30);
149     --
150     -- Set the global variables so the values are
151     -- available for the next call to this function.
152     --
153     close csr_leg_code;
154     per_stb_bus.g_setup_task_code             := p_setup_task_code;
155     per_stb_bus.g_legislation_code  := l_legislation_code;
156   end if;
157   hr_utility.set_location(' Leaving:'|| l_proc, 40);
158   return l_legislation_code;
159 end return_legislation_code;
160 --
161 -- ----------------------------------------------------------------------------
162 -- |-----------------------< chk_non_updateable_args >------------------------|
163 -- ----------------------------------------------------------------------------
164 -- {Start Of Comments}
165 --
166 -- Description:
167 --   This procedure is used to ensure that non updateable attributes have
168 --   not been updated. If an attribute has been updated an error is generated.
169 --
170 -- Pre Conditions:
171 --   g_old_rec has been populated with details of the values currently in
172 --   the database.
173 --
174 -- In Arguments:
175 --   p_rec has been populated with the updated values the user would like the
176 --   record set to.
177 --
178 -- Post Success:
179 --   Processing continues if all the non updateable attributes have not
180 --   changed.
181 --
182 -- Post Failure:
183 --   An application error is raised if any of the non updatable attributes
184 --   have been altered.
185 --
186 -- {End Of Comments}
187 -- ----------------------------------------------------------------------------
188 Procedure chk_non_updateable_args
189   (p_effective_date               in date
190   ,p_rec in per_stb_shd.g_rec_type
191   ) IS
192 --
193   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
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 per_stb_shd.api_updating
201       (p_setup_task_code                   => p_rec.setup_task_code
202       ,p_object_version_number             => p_rec.object_version_number
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   -- EDIT_HERE: Add checks to ensure non-updateable args have
211   --            not been updated.
212   --
213 End chk_non_updateable_args;
214 --
215 --
216 --  ---------------------------------------------------------------------------
217 --  |-------------------------< chk_setup_task_type >--------------------------|
218 --  ---------------------------------------------------------------------------
219 --
220 --  Description:
221 --    Validates that the following business rules are met:
222 --    a)Validate against HR_LOOKUPS.lookup_code
223 --      where LOOKUP_TYPE = 'PER_RI_TASK_TYPE' (I,U)
224 --
225 --  Pre-conditions:
226 --    workbench_item_code must have been successfully validated.
227 --
228 --  In Arguments:
229 --    p_workbench_item_code
230 --    p_effective_date
231 --    p_object_version_number
232 --    p_workbench_item_type
233 --
234 --  Post Success:
235 --    If the above business rules are satisfied then processing continues.
236 --
237 --  Post Failure:
238 --    If the above business rules then an application error will be raised and
239 --    processing is terminated.
240 --
241 --  Access Status:
242 --   Internal Table Handler Use Only.
243 --
244 -- {End Of Comments}
245 -- ----------------------------------------------------------------------------
246 
247 Procedure chk_setup_task_type(p_setup_task_code          Varchar2
248                              ,p_effective_date           Varchar2
249                              ,p_object_version_number    Number
250                              ,p_setup_task_type          Varchar2
251                              ) Is
252 
253  l_proc varchar2(72)  :=  g_package||'chk_setup_task_type';
254 
255 Begin
256   hr_utility.set_location('Entering:'|| l_proc, 1);
257 
258   If p_setup_task_type Is Not Null Then
259 
260        hr_api.mandatory_arg_error
261 	       (p_api_name       => l_proc
262 	       ,p_argument       => 'EFFECTIVE_DATE'
263 	       ,p_argument_value => p_effective_date
264           );
265        If hr_api.not_exists_in_hr_lookups
266            (p_effective_date => p_effective_date
267            ,p_lookup_type    => 'PER_RI_TASK_TYPE'
268            ,p_lookup_code    => p_setup_task_type
269            ) Then
270           fnd_message.set_name('PER', 'HR_52966_INVALID_LOOKUP');
271           fnd_message.set_token('COLUMN ', p_setup_task_type);
272           fnd_message.set_token('LOOKUP_TYPE ', 'PER_RI_TASK_TYPE');
273           fnd_message.set_token('STEP ', '5');
274           fnd_message.raise_error;
275        End If;
276 
277   End If;
278 
279   hr_utility.set_location('Leaving:'|| l_proc, 1);
280 
281 End chk_setup_task_type;
282 --
283 -- ----------------------------------------------------------------------------
284 -- |---------------------------< insert_validate >----------------------------|
285 -- ----------------------------------------------------------------------------
286 Procedure insert_validate
287   (p_effective_date               in date
288   ,p_rec                          in per_stb_shd.g_rec_type
289   ) is
290 --
291   l_proc  varchar2(72) := g_package||'insert_validate';
292 --
293 Begin
294   hr_utility.set_location('Entering:'||l_proc, 5);
295   --
296   -- Call all supporting business operations
297   --
298   --
299   -- EDIT_HERE: As this table does not have a mandatory business_group_id
300   -- column, ensure client_info is populated by calling a suitable
301   -- ???_???_bus.set_security_group_id procedure, or add one of the following
302   -- comments:
303   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
304   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
305   --
306   -- Validate Dependent Attributes
307   --
308   chk_setup_task_type(p_setup_task_code        => p_rec.setup_task_code
309                      ,p_effective_date         => p_effective_date
310                      ,p_object_version_number  => p_rec.object_version_number
311                      ,p_setup_task_type        => p_rec.setup_task_type
312                       );
313   --
314   hr_utility.set_location(' Leaving:'||l_proc, 10);
315 End insert_validate;
316 --
317 -- ----------------------------------------------------------------------------
318 -- |---------------------------< update_validate >----------------------------|
319 -- ----------------------------------------------------------------------------
320 Procedure update_validate
321   (p_effective_date               in date
322   ,p_rec                          in per_stb_shd.g_rec_type
323   ) is
324 --
325   l_proc  varchar2(72) := g_package||'update_validate';
326 --
327 Begin
328   hr_utility.set_location('Entering:'||l_proc, 5);
329   --
330   -- Call all supporting business operations
331   --
332   --
333   -- EDIT_HERE: As this table does not have a mandatory business_group_id
334   -- column, ensure client_info is populated by calling a suitable
335   -- ???_???_bus.set_security_group_id procedure, or add one of the following
336   -- comments:
337   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
338   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
339   --
340   -- Validate Dependent Attributes
341   --
342   chk_non_updateable_args
343     (p_effective_date     => p_effective_date
344       ,p_rec              => p_rec
345     );
346   --
347   --
348   --
349   chk_setup_task_type(p_setup_task_code         => p_rec.setup_task_code
350                       ,p_effective_date         => p_effective_date
351                       ,p_object_version_number  => p_rec.object_version_number
352                       ,p_setup_task_type        => p_rec.setup_task_type
353                       );
354 
355   --
356   hr_utility.set_location(' Leaving:'||l_proc, 10);
357 End update_validate;
358 --
359 -- ----------------------------------------------------------------------------
360 -- |---------------------------< delete_validate >----------------------------|
361 -- ----------------------------------------------------------------------------
362 Procedure delete_validate
363   (p_rec                          in per_stb_shd.g_rec_type
364   ) is
365 --
366   l_proc  varchar2(72) := g_package||'delete_validate';
367 --
368 Begin
369   hr_utility.set_location('Entering:'||l_proc, 5);
370   --
371   -- Call all supporting business operations
372   --
373   hr_utility.set_location(' Leaving:'||l_proc, 10);
374 End delete_validate;
375 --
376 end per_stb_bus;