DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_HTL_BUS

Source


1 Package Body hr_htl_bus as
2 /* $Header: hrhtlrhi.pkb 115.1 2004/04/05 07:20 menderby noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_htl_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_hierarchy_id             number         default null;
14 g_language                    varchar2(4)    default null;
15 --
16 --
17 -- ----------------------------------------------------------------------------
18 -- |-----------------------< chk_non_updateable_args >------------------------|
19 -- ----------------------------------------------------------------------------
20 -- {Start Of Comments}
21 --
22 -- Description:
23 --   This procedure is used to ensure that non updateable attributes have
24 --   not been updated. If an attribute has been updated an error is generated.
25 --
26 -- Pre Conditions:
27 --   g_old_rec has been populated with details of the values currently in
28 --   the database.
29 --
30 -- In Arguments:
31 --   p_rec has been populated with the updated values the user would like the
32 --   record set to.
33 --
34 -- Post Success:
35 --   Processing continues if all the non updateable attributes have not
36 --   changed.
37 --
38 -- Post Failure:
39 --   An application error is raised if any of the non updatable attributes
40 --   have been altered.
41 --
42 -- {End Of Comments}
43 -- ----------------------------------------------------------------------------
44 Procedure chk_non_updateable_args
45   (p_rec in hr_htl_shd.g_rec_type
46   ) IS
47 --
48   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
49 --
50 Begin
51   --
52   -- Only proceed with the validation if a row exists for the current
53   -- record in the HR Schema.
54   --
55   IF NOT hr_htl_shd.api_updating
56       (p_hierarchy_id                   => p_rec.hierarchy_id,
57       p_language               => p_rec.language
58       ) THEN
59      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
60      fnd_message.set_token('PROCEDURE ', l_proc);
61      fnd_message.set_token('STEP ', '5');
62      fnd_message.raise_error;
63   END IF;
64   --
65   -- EDIT_HERE: Add checks to ensure non-updateable args have
66   --            not been updated.
67   --
68 End chk_non_updateable_args;
69 -- ----------------------------------------------------------------------------
70 -- --------------------------< CHK_HIERARCHY_ID>------------------------------
71 -- ----------------------------------------------------------------------------
72 -- {Start Of Comments}
73 --
74 -- Description:
75 --   This procedure checks that the hierarchy id entered in the TL table is
76 --   present in the base table.
77 
78 -- Pre Conditions:
79 --   g_rec has been populated with details of the values
80 --   from the ins or the upd procedures
81 --
82 -- In Arguments:
83 --   p_hierarchy_id
84 -- Post Success:
85 --   Processing continues if hierarchy key is not null and unique
86 --
87 -- Post Failure:
88 --   An application error is raised if hierarchy key is null or exists already
89 --
90 -- {End Of Comments}
91 -- ----------------------------------------------------------------------------
92 procedure chk_hierarchy_id
93 (
94   p_hierarchy_id in number
95 )
96 is
97 
98   -- Cursor to check if there is an entry in hr_ki_hierarchies
99 
100 CURSOR csr_htl_parent is
101   select
102    'found'
103   From
104     hr_ki_hierarchies  hrc
105   where
106     hrc.hierarchy_id = p_hierarchy_id;
107 
108  l_proc        varchar2(72) := g_package||'chk_hierarchy_id';
109  l_found varchar2(30);
110 
111   Begin
112 
113    hr_utility.set_location(' Entering:' || l_proc,10);
114 
115    hr_api.mandatory_arg_error
116    (p_api_name           => l_proc
117     ,p_argument           => 'HIERARCHY_ID'
118     ,p_argument_value     => p_hierarchy_id
119    );
120 
121    open csr_htl_parent;
122    fetch csr_htl_parent into l_found;
123 
124    if csr_htl_parent%NOTFOUND then
125     close csr_htl_parent;
126     fnd_message.set_name('PER', 'PER_449920_HTL_HRC_ID_ABSENT');
127     fnd_message.raise_error;
128    end if;
129 
130    close csr_htl_parent;
131 
132    hr_utility.set_location(' Leaving:' || l_proc,20);
133 
134 Exception
135  when app_exception.application_exception then
136     IF hr_multi_message.exception_add
137                  (p_associated_column1   => 'HR_KI_HIERARCHIES_TL.HIERARCHY_ID'
138                  ) THEN
139        hr_utility.set_location(' Leaving:'|| l_proc,30);
140        raise;
141     END IF;
142 
143     hr_utility.set_location(' Leaving:'|| l_proc,40);
144   --
145   End chk_hierarchy_id;
146 
147 -- ----------------------------------------------------------------------------
148 -- --------------------------< CHK_NAME>------------------------------
149 -- ----------------------------------------------------------------------------
150 -- {Start Of Comments}
151 --
152 -- Description:
153 --   This procedure checks that the hierarchy id entered in the TL table is
154 --   present in the base table.
155 
156 -- Pre Conditions:
157 --   g_rec has been populated with details of the values
158 --   from the ins or the upd procedures
159 --
160 -- In Arguments:
161 --   p_hierarchy_id
162 -- Post Success:
163 --   Processing continues if hierarchy key is not null and unique
164 --
165 -- Post Failure:
166 --   An application error is raised if hierarchy key is null or exists already
167 --
168 -- {End Of Comments}
169 -- ----------------------------------------------------------------------------
170 
171 procedure chk_name
172 (
173   p_language in varchar2,
174   p_name in varchar2,
175   p_hierarchy_id in number
176 )
177 is
178   -- Declare cursors and local variables
179   --
180   -- Cursor to check if there is an entry in hr_ki_hierarchies
181 
182 CURSOR csr_htl_name is
183   select
184    'found'
185   From
186     hr_ki_hierarchies_tl  htl
187   where
188     htl.language = p_language and
189     htl.name = p_name and
190     htl.hierarchy_id <> p_hierarchy_id;
191 
192  l_proc        varchar2(72) := g_package||'chk_name';
193  l_found varchar2(30);
194 
195   Begin
196 
197    hr_utility.set_location(' Entering:' || l_proc,10);
198 
199    hr_api.mandatory_arg_error
200    (p_api_name           => l_proc
201     ,p_argument           => 'NAME'
202     ,p_argument_value     => p_name
203    );
204 
205    open csr_htl_name;
206    fetch csr_htl_name into l_found;
207 
208    if csr_htl_name%FOUND then
209     close csr_htl_name;
210     fnd_message.set_name('PER', 'PER_449921_HTL_NAME_DUPLICATE');
211     fnd_message.raise_error;
212    end if;
213 
214    close csr_htl_name;
215 
216    hr_utility.set_location(' Leaving:' || l_proc,20);
217 
218 Exception
219  when app_exception.application_exception then
220     IF hr_multi_message.exception_add
221                  (p_associated_column1   => 'HR_KI_HIERARCHIES_TL.NAME'
222                  ) THEN
223        hr_utility.set_location(' Leaving:'|| l_proc,30);
224        raise;
225     END IF;
226 
227     hr_utility.set_location(' Leaving:'|| l_proc,40);
228   --
229   End chk_name;
230 
231 
232 --
233 -- ----------------------------------------------------------------------------
234 -- |---------------------------< insert_validate >----------------------------|
235 -- ----------------------------------------------------------------------------
236 Procedure insert_validate
237   (p_rec                          in hr_htl_shd.g_rec_type,
238    p_hierarchy_id              in number
239   ) is
240 --
241   l_proc  varchar2(72) := g_package||'insert_validate';
242 --
243 Begin
244   hr_utility.set_location('Entering:'||l_proc, 5);
245   --
246   -- Call all supporting business operations
247   --
248   --
249   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
250   -- Validate Dependent Attributes
251   --
252   --
253    chk_hierarchy_id(p_hierarchy_id);
254    chk_name(p_rec.language,p_rec.name,p_hierarchy_id);
255 
256 
257   hr_utility.set_location(' Leaving:'||l_proc, 10);
258 End insert_validate;
259 --
260 -- ----------------------------------------------------------------------------
261 -- |---------------------------< update_validate >----------------------------|
262 -- ----------------------------------------------------------------------------
263 Procedure update_validate
264   (p_rec                          in hr_htl_shd.g_rec_type
265   ) is
266 --
267   l_proc  varchar2(72) := g_package||'update_validate';
268 --
269 Begin
270   hr_utility.set_location('Entering:'||l_proc, 5);
271   --
272   -- Call all supporting business operations
273   --
274   --
275   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
276   --
277   -- Validate Dependent Attributes
278   --
279   chk_non_updateable_args
280     (p_rec              => p_rec
281     );
282 
283    chk_name(p_rec.language,p_rec.name,p_rec.hierarchy_id);
284   --
285   --
286   hr_utility.set_location(' Leaving:'||l_proc, 10);
287 
288 End update_validate;
289 --
290 -- ----------------------------------------------------------------------------
291 -- |---------------------------< delete_validate >----------------------------|
292 -- ----------------------------------------------------------------------------
293 Procedure delete_validate
294   (p_rec                          in hr_htl_shd.g_rec_type
295   ) is
296 --
297   l_proc  varchar2(72) := g_package||'delete_validate';
298 --
299 Begin
300   hr_utility.set_location('Entering:'||l_proc, 5);
301   --
302   -- Call all supporting business operations
303   --
304   hr_utility.set_location(' Leaving:'||l_proc, 10);
305 End delete_validate;
306 --
307 end hr_htl_bus;