DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_OTY_BUS

Source


1 Package Body hr_oty_bus as
2 /* $Header: hrotyrhi.pkb 115.0 2004/01/09 02:19 vkarandi noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_oty_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_option_type_id              number         default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |-----------------------< chk_non_updateable_args >------------------------|
17 -- ----------------------------------------------------------------------------
18 -- {Start Of Comments}
19 --
20 -- Description:
21 --   This procedure is used to ensure that non updateable attributes have
22 --   not been updated. If an attribute has been updated an error is generated.
23 --
24 -- Pre Conditions:
25 --   g_old_rec has been populated with details of the values currently in
26 --   the database.
27 --
28 -- In Arguments:
29 --   p_rec has been populated with the updated values the user would like the
30 --   record set to.
31 --
32 -- Post Success:
33 --   Processing continues if all the non updateable attributes have not
34 --   changed.
35 --
36 -- Post Failure:
37 --   An application error is raised if any of the non updatable attributes
38 --   have been altered.
39 --
40 -- {End Of Comments}
41 -- ----------------------------------------------------------------------------
42 Procedure chk_non_updateable_args
43   (p_rec in hr_oty_shd.g_rec_type
44   ) IS
45 --
46   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
47 --
48 Begin
49   --
50   -- Only proceed with the validation if a row exists for the current
51   -- record in the HR Schema.
52   --
53   IF NOT hr_oty_shd.api_updating
54       (p_option_type_id                    => p_rec.option_type_id
55       ,p_object_version_number             => p_rec.object_version_number
56       ) THEN
57      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
58      fnd_message.set_token('PROCEDURE ', l_proc);
59      fnd_message.set_token('STEP ', '5');
60      fnd_message.raise_error;
61   END IF;
62 
63   if nvl(p_rec.option_type_key, hr_api.g_varchar2) <>
64        nvl(hr_oty_shd.g_old_rec.option_type_key
65            ,hr_api.g_varchar2
66            ) then
67       hr_api.argument_changed_error
68         (p_api_name   => l_proc
69         ,p_argument   => 'OPTION_TYPE_KEY'
70         ,p_base_table => hr_oty_shd.g_tab_nam
71         );
72   end if;
73 
74 End chk_non_updateable_args;
75 
76 -- ----------------------------------------------------------------------------
77 -- |-----------------------< CHK_OPTION_TYPE_KEY>------------------------|
78 -- ----------------------------------------------------------------------------
79 -- {Start Of Comments}
80 --
81 -- Description:
82 --   This procedure ensures a valid option type key is entered
83 -- Pre Conditions:
84 --   g_old_rec has been populated with details of the values currently in
85 --   the database.
86 --
87 -- In Arguments:
88 --   p_option_type_key
89 -- Post Success:
90 --   Processing continues if option type key is not null and unique
91 --
92 -- Post Failure:
93 --   An application error is raised if option type key is null or exists already
94 --
95 -- {End Of Comments}
96 -- ----------------------------------------------------------------------------
97 Procedure chk_option_type_key
98   (p_option_type_key     in varchar2
99 
100   ) IS
101 --
102   l_proc     varchar2(72) := g_package || 'CHK_OPTION_TYPE_KEY';
103   l_key     varchar2(1) ;
104   cursor csr_key is
105          select null
106            from hr_ki_option_types
107           where  option_type_key = p_option_type_key;
108 --
109 Begin
110   hr_utility.set_location('Entering:'||l_proc,10);
111   --
112   -- Check value has been passed
113   --
114   hr_api.mandatory_arg_error
115   (p_api_name           => l_proc
116   ,p_argument           => 'OPTION_TYPE_KEY'
117   ,p_argument_value     => p_option_type_key
118   );
119 
120   hr_utility.set_location('Opening cursor:'||l_proc,20);
121     open csr_key;
122     fetch csr_key into l_key;
123     if (csr_key%found)
124     then
125       close csr_key;
126       fnd_message.set_name('PER','PER_449945_OTY_OPTION_KEY_DUP');
127       fnd_message.raise_error;
128     end if;
129     close csr_key;
130 
131   hr_utility.set_location(' Leaving:'||l_proc,30);
132   exception
133   when app_exception.application_exception then
134     if hr_multi_message.exception_add
135     (p_associated_column1 => 'HR_KI_OPTION_TYPES.OPTION_TYPE_KEY'
136     )then
137       hr_utility.set_location(' Leaving:'||l_proc, 40);
138       raise;
139     end if;
140     hr_utility.set_location(' Leaving:'||l_proc,50);
141 End chk_option_type_key;
142 
143 
144 
145 -- ----------------------------------------------------------------------------
146 -- |-----------------------< CHK_DISPLAY_TYPE>------------------------|
147 -- ----------------------------------------------------------------------------
148 -- {Start Of Comments}
149 --
150 -- Description:
151 --   This procedure ensures a display type is entered in correct format,
152 --   Also If display type is lookup then VOName is entered or not.
153 --   Format is
154 --   textfield
155 --   OR
156 --   lookup:<VOName which populates lookup>
157 --
158 -- Pre Conditions:
159 --   g_old_rec has been populated with details of the values currently in
160 --   the database.
161 --
162 -- In Arguments:
163 --   p_display_type
164 -- Post Success:
165 --   Processing continues if display type is valid.
166 --
167 -- Post Failure:
168 --   An application error is raised if display type is in invalid format
169 --
170 -- {End Of Comments}
171 -- ----------------------------------------------------------------------------
172 Procedure CHK_DISPLAY_TYPE
173   (p_display_type     in varchar2
174 
175   ) IS
176 --
177   l_proc     varchar2(72) := g_package || 'CHK_DISPLAY_TYPE';
178   l_text     varchar2(20) :='TEXTFIELD';
179   l_lookup   varchar2(20) :='LOOKUP#';
180   l_view_name     varchar2(100):='';
181 
182 --
183 Begin
184   hr_utility.set_location('Entering:'||l_proc,10);
185 
186   --
187   -- Check value has been passed
188   --
189   hr_api.mandatory_arg_error
190   (p_api_name           => l_proc
191   ,p_argument           => 'DISPLAY_TYPE'
192   ,p_argument_value     => p_display_type
193   );
194 
195   hr_utility.set_location('Display type is not null'||l_proc,20);
196 
197   IF upper(p_display_type) =l_text  THEN
198      --display type is textfield no validations are required
199     null;
200 
201   ELSIF (instr(upper(p_display_type),l_lookup) > 0) THEN
202 
203   l_view_name:=substr(upper(p_display_type),length(l_lookup)+1);
204 
205 
206            if l_view_name is null then
207               fnd_message.set_name ( 'PER','PER_449947_OTY_DIS_TY_NOVO');
208               -- Specify VOName for lookup
209                fnd_message.raise_error;
210           end if;
211 
212   ELSE
213      fnd_message.set_name      ( 'PER' ,'PER_449946_OTY_DIS_TY_INVALID');
214      --Please specify display type as either textfield or lookup:<VOName>
215       fnd_message.raise_error;
216   END IF;
217 
218   hr_utility.set_location(' Leaving:'||l_proc,30);
219   exception
220   when app_exception.application_exception then
221     if hr_multi_message.exception_add
222     (p_associated_column1 => 'HR_KI_OPTION_TYPES.DISPLAY_TYPE'
223     )then
224       hr_utility.set_location(' Leaving:'||l_proc, 40);
225       raise;
226     end if;
227     hr_utility.set_location(' Leaving:'||l_proc,50);
228 End CHK_DISPLAY_TYPE;
229 
230 -- ----------------------------------------------------------------------------
231 -- -------------------------------< CHK_DELETE>--------------------------------
232 -- ----------------------------------------------------------------------------
233 -- {Start Of Comments}
234 --
235 -- Description:
236 --   This procedure ensures that a delete occurs only if there are no child
237 --   rows for a record in hr_ki_option_types. The tables that contain child
238 --   rows are hr_ki_option_types_tl,hr_ki_options.
239 -- Pre Conditions:
240 --   g_rec has been populated with details of the values
241 --   from the ins or the upd procedures
242 --
243 -- In Arguments:
244 --   p_integration_id
245 
246 -- Post Success:
247 --   Processing continues if there are no child records.
248 --
249 -- Post Failure:
250 --   An application error is raised if there are any child rows from any of the
251 --   above mentioned tables.
252 --
253 -- {End Of Comments}
254 -- ----------------------------------------------------------------------------
255 --
256 procedure chk_delete
257   (p_option_type_id                        in number
258   )
259   is
260   --
261   -- Declare local variables
262   --
263   l_proc              varchar2(72) :=  g_package||'chk_delete';
264   l_exists            varchar2(1);
265   l_exists_tl         varchar2(1);
266   --
267   --  Cursor to check that if maintenance rows type exists.
268   --
269   cursor csr_maintenance_option is
270     select null
271       from hr_ki_options
272      where option_type_id          = p_option_type_id         ;
273 
274   cursor csr_maintenance_tl is
275     select null
276       from hr_ki_option_types_tl
277      where option_type_id          = p_option_type_id         ;
278 
279   --
280 begin
281   hr_utility.set_location('Entering:'|| l_proc, 10);
282   --
283   -- Can always execute the cursor as chk_delete
284   -- will only be called for delete validation
285   -- from within the row handler.
286   --
287   open csr_maintenance_option;
288   fetch csr_maintenance_option into l_exists;
289   if csr_maintenance_option%found then
290     close csr_maintenance_option;
291     fnd_message.set_name('PER', 'PER_449948_OTY_OPT_MAIN_EXIST');
292     fnd_message.raise_error;
293   end if;
294   close csr_maintenance_option;
295 
296   hr_utility.set_location('Checking for TL:'|| l_proc, 20);
297   open csr_maintenance_tl;
298   fetch csr_maintenance_tl into l_exists_tl;
299   if csr_maintenance_tl%found then
300     close csr_maintenance_tl;
301     fnd_message.set_name('PER', 'PER_449949_OTY_OP_TL_EXIST');
302     fnd_message.raise_error;
303   end if;
304   close csr_maintenance_tl;
305 
306   hr_utility.set_location(' Leaving:'|| l_proc, 30);
307 exception
308   when app_exception.application_exception then
309     if hr_multi_message.exception_add
310           (p_associated_column1 => 'HR_KI_OPTION_TYPES.option_type_id'
311           ) then
312       hr_utility.set_location(' Leaving:'|| l_proc, 40);
313       raise;
314     end if;
315     hr_utility.set_location(' Leaving:'|| l_proc, 50);
316 end chk_delete;
317 
318 --
319 -- ----------------------------------------------------------------------------
320 -- |---------------------------< insert_validate >----------------------------|
321 -- ----------------------------------------------------------------------------
322 Procedure insert_validate
323   (p_rec                          in hr_oty_shd.g_rec_type
324   ) is
325 --
326   l_proc  varchar2(72) := g_package||'insert_validate';
327 --
328 Begin
329   hr_utility.set_location('Entering:'||l_proc, 5);
330   --
331   -- Call all supporting business operations
332   --
333   --
334   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
335   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
336   --
337   -- Validate Dependent Attributes
338   --
339   --
340   -- Call for attribute validations
341   CHK_OPTION_TYPE_KEY
342     (
343      p_option_type_key  => p_rec.option_type_key
344 
345     );
346 
347   CHK_DISPLAY_TYPE
348     (
349     p_display_type  => p_rec.display_type
350     );
351 
352   --end call for attribute validations
353 
354   hr_utility.set_location(' Leaving:'||l_proc, 10);
355 
356 End insert_validate;
357 --
358 -- ----------------------------------------------------------------------------
359 -- |---------------------------< update_validate >----------------------------|
360 -- ----------------------------------------------------------------------------
361 Procedure update_validate
362   (p_rec                          in hr_oty_shd.g_rec_type
363   ) is
364 --
365   l_proc  varchar2(72) := g_package||'update_validate';
366 --
367 Begin
368   hr_utility.set_location('Entering:'||l_proc, 5);
369   --
370   -- Call all supporting business operations
371   --
372   --
373   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
374   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
375   --
376   -- Validate Dependent Attributes
377   --
378   chk_non_updateable_args
379     (p_rec              => p_rec
380     );
381   --check for display type validation
382   HR_OTY_BUS.CHK_DISPLAY_TYPE
383     (
384     p_display_type  => p_rec.display_type
385     );
386 
387   --
388   --
389   hr_utility.set_location(' Leaving:'||l_proc, 10);
390 End update_validate;
391 --
392 -- ----------------------------------------------------------------------------
393 -- |---------------------------< delete_validate >----------------------------|
394 -- ----------------------------------------------------------------------------
395 Procedure delete_validate
396   (p_rec                          in hr_oty_shd.g_rec_type
397   ) is
398 --
399   l_proc  varchar2(72) := g_package||'delete_validate';
400 --
401 Begin
402   hr_utility.set_location('Entering:'||l_proc, 5);
403   --
404   -- Call all supporting business operations
405   --
406     HR_OTY_BUS.chk_delete
407     (p_option_type_id       =>     p_rec.option_type_id
408     );
409 
410   hr_utility.set_location(' Leaving:'||l_proc, 10);
411 End delete_validate;
412 --
413 end hr_oty_bus;