DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_TTL_BUS

Source


1 Package Body hr_ttl_bus as
2 /* $Header: hrttlrhi.pkb 115.1 2004/04/05 07:21 menderby noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_ttl_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_topic_id                 number         default null;
15 g_language                    varchar2(4)    default null;
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_ttl_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_ttl_shd.api_updating
56       (p_topic_id                       => p_rec.topic_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 -- ----------------------------------------------------------------------------
71 -- ------------------------------< CHK_TOPIC_ID >------------------------------
72 -- ----------------------------------------------------------------------------
73 -- {Start Of Comments}
74 --
75 -- Description:
76 --   This procedure ensures that the topic id entered in the TL table is
77 --   present in the base table.
78 
79 -- Pre Conditions:
80 --   g_rec has been populated with details of the values
81 --   from the ins or the upd procedures
82 --
83 -- In Arguments:
84 --   p_topic_id
85 
86 -- Post Success:
87 --   Processing continues if topic id is present in the base table
88 --
89 -- Post Failure:
90 --   An application error is raised if topic id is absent in the base table
91 --
92 -- {End Of Comments}
93 -- ----------------------------------------------------------------------------
94 
95 procedure chk_topic_id
96 (
97   p_topic_id in number
98 )
99 is
100   -- Declare cursors and local variables
101   --
102   -- Cursor to check if there is an entry in hr_ki_topics
103 
104 CURSOR csr_ttl_parent is
105   select
106    'found'
107   From
108     hr_ki_topics  tpc
109   where
110     tpc.topic_id = p_topic_id;
111 
112  l_proc        varchar2(72) := g_package||'chk_topic_id';
113  l_found       varchar2(10);
114 
115   Begin
116 
117    hr_utility.set_location(' Entering:' || l_proc,10);
118 
119    hr_api.mandatory_arg_error
120    (p_api_name           => l_proc
121    ,p_argument           => 'TOPIC_ID'
122    ,p_argument_value     => p_topic_id
123    );
124 
125    open csr_ttl_parent;
126    fetch csr_ttl_parent into l_found;
127 
128    if csr_ttl_parent%NOTFOUND then
129     close csr_ttl_parent;
130     fnd_message.set_name('PER', 'PER_449934_TTL_TPC_ID_ABSENT');
131     fnd_message.raise_error;
132    end if;
133 
134    close csr_ttl_parent;
135 
136    hr_utility.set_location(' Leaving:' || l_proc,20);
137 
138 Exception
139  when app_exception.application_exception then
140     IF hr_multi_message.exception_add
141                  (p_associated_column1   => 'HR_KI_TOPICS_TL.TOPIC_ID'
142                  ) THEN
143        hr_utility.set_location(' Leaving:'|| l_proc,30);
144        raise;
145     END IF;
146 
147     hr_utility.set_location(' Leaving:'|| l_proc,40);
148   --
149   End chk_topic_id;
150 
151 -- ----------------------------------------------------------------------------
152 -- ------------------------------< CHK_NAME >----------------------------------
153 -- ----------------------------------------------------------------------------
154 -- {Start Of Comments}
155 --
156 -- Description:
157 --   This procedure ensures that the NAME value entered in the TL table is
158 --   not null and unique.
159 
160 -- Pre Conditions:
161 --   g_rec has been populated with details of the values
162 --   from the ins or the upd procedures
163 --
164 -- In Arguments:
165 --   p_topic_id
166 
167 -- Post Success:
168 --   Processing continues if name is not null and unique
169 --
170 -- Post Failure:
171 --   An application error is raised if name is null or already present for a
172 --   language.
173 --
174 -- {End Of Comments}
175 -- ----------------------------------------------------------------------------
176 
177 procedure chk_name
178 (
179   p_language in varchar2,
180   p_name in varchar2,
181   p_topic_id in number
182 )
183 is
184   -- Declare cursors and local variables
185   --
186   -- Cursor to check if there is an entry in hr_ki_hierarchies
187 
188 CURSOR csr_ttl_name is
189   select
190    'found'
191   From
192     hr_ki_topics_tl  ttl
193   where
194     ttl.language = p_language and
195     ttl.name = p_name and
196     ttl.topic_id <> p_topic_id;
197 
198  l_proc        varchar2(72) := g_package||'chk_name';
199  l_found       varchar2(10);
200 
201   Begin
202 
203    hr_utility.set_location(' Entering:' || l_proc,10);
204 
205    hr_api.mandatory_arg_error
206    (p_api_name           => l_proc
207    ,p_argument           => 'NAME'
208    ,p_argument_value     => p_name
209    );
210 
211    open csr_ttl_name;
212    fetch csr_ttl_name into l_found;
213 
214    if csr_ttl_name%FOUND then
215     close csr_ttl_name;
216     fnd_message.set_name('PER', 'PER_449935_TTL_NAME_DUPLI');
217     fnd_message.raise_error;
218    end if;
219 
220    close csr_ttl_name;
221 
222    hr_utility.set_location(' Leaving:' || l_proc,20);
223 
224 Exception
225  when app_exception.application_exception then
226     IF hr_multi_message.exception_add
227                  (p_associated_column1   => 'HR_KI_TOPICS_TL.NAME'
228                  ) THEN
229        hr_utility.set_location(' Leaving:'|| l_proc,30);
230        raise;
231     END IF;
232 
233     hr_utility.set_location(' Leaving:'|| l_proc,40);
234   --
235   End chk_name;
236 
237 --
238 -- ----------------------------------------------------------------------------
239 -- |---------------------------< insert_validate >----------------------------|
240 -- ----------------------------------------------------------------------------
241 Procedure insert_validate
242   (p_rec                          in hr_ttl_shd.g_rec_type,
243    p_topic_id                  in number
244   ) is
245 --
246   l_proc  varchar2(72) := g_package||'insert_validate';
247 --
248 Begin
249   hr_utility.set_location('Entering:'||l_proc, 5);
250   --
251   -- Call all supporting business operations
252   --
253   --
254   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
255   --
256   -- Validate Dependent Attributes
257   chk_topic_id(p_topic_id);
258   chk_name(p_rec.language,p_rec.name,p_topic_id);
259   --
260   --
261   hr_utility.set_location(' Leaving:'||l_proc, 10);
262 End insert_validate;
263 --
264 -- ----------------------------------------------------------------------------
265 -- |---------------------------< update_validate >----------------------------|
266 -- ----------------------------------------------------------------------------
267 Procedure update_validate
268   (p_rec                          in hr_ttl_shd.g_rec_type
269   ) is
270 --
271   l_proc  varchar2(72) := g_package||'update_validate';
272 --
273 Begin
274   hr_utility.set_location('Entering:'||l_proc, 5);
275   --
276   -- Call all supporting business operations
277   --
278   --
279   -- Validate Dependent Attributes
280   --
281   chk_non_updateable_args
282     (p_rec              => p_rec
283     );
284 
285  chk_name(p_rec.language,p_rec.name,p_rec.topic_id);
286   --
287   --
288   hr_utility.set_location(' Leaving:'||l_proc, 10);
289 End update_validate;
290 --
291 -- ----------------------------------------------------------------------------
292 -- |---------------------------< delete_validate >----------------------------|
293 -- ----------------------------------------------------------------------------
294 Procedure delete_validate
295   (p_rec                          in hr_ttl_shd.g_rec_type
296   ) is
297 --
298   l_proc  varchar2(72) := g_package||'delete_validate';
299 --
300 Begin
301   hr_utility.set_location('Entering:'||l_proc, 5);
302   --
303   -- Call all supporting business operations
304   --
305   hr_utility.set_location(' Leaving:'||l_proc, 10);
306 End delete_validate;
307 --
308 end hr_ttl_bus;