DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_LPT_BUS

Source


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