DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RNK_BUS

Source


1 Package Body pqh_rnk_bus as
2 /* $Header: pqrnkrhi.pkb 120.1 2005/06/23 13:27 nsanghal noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package constant varchar2(33) := '  pqh_rnk_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_rank_process_id             number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_rank_process_id                      in number
22   ,p_associated_column1                   in varchar2 default null
23   ) is
24   --
25   -- Declare cursor
26   --
27   cursor csr_sec_grp is
28     select   pbg.security_group_id,
29              pbg.legislation_code
30       from   per_business_groups_perf pbg
31            , pqh_rank_processes       rnk
32            , per_all_people_f         per
33        where rnk.rank_process_id   = p_rank_process_id
34          and rnk.person_id         = per.person_id
35          and pbg.business_group_id = per.business_group_id
36          and rnk.process_date between per.effective_start_date and per.effective_end_date;
37   --
38   -- Declare local variables
39   --
40   l_security_group_id number;
41   l_proc constant            varchar2(72)  :=  g_package||'set_security_group_id';
42   l_legislation_code  varchar2(150);
43   --
44 begin
45   --
46   hr_utility.set_location('Entering:'|| l_proc, 10);
47   --
48   -- Ensure that all the mandatory parameter are not null
49   --
50   hr_api.mandatory_arg_error
51     (p_api_name           => l_proc
52     ,p_argument           => 'rank_process_id'
53     ,p_argument_value     => p_rank_process_id
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,'RANK_PROCESS_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_rank_process_id                      in     number
96   )
97   Return Varchar2 Is
98   --
99   -- Declare cursor
100   --
101   cursor csr_leg_code is
102     select pbg.legislation_code
103       from per_business_groups_perf pbg
104          , pqh_rank_processes       rnk
105          , per_all_people_f         per
106        where rnk.rank_process_id   = p_rank_process_id
107          and rnk.person_id         = per.person_id
108          and pbg.business_group_id = per.business_group_id
109          and rnk.process_date between per.effective_start_date and per.effective_end_date;
110   --
111   -- Declare local variables
112   --
113   l_legislation_code  varchar2(150);
114   l_proc  constant           varchar2(72)  :=  g_package||'return_legislation_code';
115   --
116 Begin
117   --
118   hr_utility.set_location('Entering:'|| l_proc, 10);
119   --
120   -- Ensure that all the mandatory parameter are not null
121   --
122   hr_api.mandatory_arg_error
123     (p_api_name           => l_proc
124     ,p_argument           => 'rank_process_id'
125     ,p_argument_value     => p_rank_process_id
126     );
127   --
128   if ( nvl(pqh_rnk_bus.g_rank_process_id, hr_api.g_number)
129        = p_rank_process_id) then
130     --
131     -- The legislation code has already been found with a previous
132     -- call to this function. Just return the value in the global
133     -- variable.
134     --
135     l_legislation_code := pqh_rnk_bus.g_legislation_code;
136     hr_utility.set_location(l_proc, 20);
137   else
138     --
139     -- The ID is different to the last call to this function
140     -- or this is the first call to this function.
141     --
142     open csr_leg_code;
143     fetch csr_leg_code into l_legislation_code;
144     --
145     if csr_leg_code%notfound then
146       --
147       -- The primary key is invalid therefore we must error
148       --
149       close csr_leg_code;
150       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
151       fnd_message.raise_error;
152     end if;
153     hr_utility.set_location(l_proc,30);
154     --
155     -- Set the global variables so the values are
156     -- available for the next call to this function.
157     --
158     close csr_leg_code;
159     pqh_rnk_bus.g_rank_process_id             := p_rank_process_id;
160     pqh_rnk_bus.g_legislation_code  := l_legislation_code;
161   end if;
162   hr_utility.set_location(' Leaving:'|| l_proc, 40);
163   return l_legislation_code;
164 end return_legislation_code;
165 --
166 -- ----------------------------------------------------------------------------
167 -- |-----------------------< chk_non_updateable_args >------------------------|
168 -- ----------------------------------------------------------------------------
169 -- {Start Of Comments}
170 --
171 -- Description:
172 --   This procedure is used to ensure that non updateable attributes have
173 --   not been updated. If an attribute has been updated an error is generated.
174 --
175 -- Pre Conditions:
176 --   g_old_rec has been populated with details of the values currently in
177 --   the database.
178 --
179 -- In Arguments:
180 --   p_rec has been populated with the updated values the user would like the
181 --   record set to.
182 --
183 -- Post Success:
184 --   Processing continues if all the non updateable attributes have not
185 --   changed.
186 --
187 -- Post Failure:
188 --   An application error is raised if any of the non updatable attributes
189 --   have been altered.
190 --
191 -- {End Of Comments}
192 -- ----------------------------------------------------------------------------
193 Procedure chk_non_updateable_args
194   (p_effective_date in date
195   ,p_rec            in pqh_rnk_shd.g_rec_type
196   ) IS
197 --
198   l_proc constant   varchar2(72) := g_package || 'chk_non_updateable_args';
199 --
200 Begin
201   --
202   -- Only proceed with the validation if a row exists for the current
203   -- record in the HR Schema.
204   --
205   IF NOT pqh_rnk_shd.api_updating
206       (p_rank_process_id                   => p_rec.rank_process_id
207       ,p_object_version_number             => p_rec.object_version_number
208       ) THEN
209      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
210      fnd_message.set_token('PROCEDURE ', l_proc);
211      fnd_message.set_token('STEP ', '5');
212      fnd_message.raise_error;
213   END IF;
214   --
215   --
216 End chk_non_updateable_args;
217 --
218 -- ----------------------------------------------------------------------------
219 -- |---------------------------< insert_validate >----------------------------|
220 -- ----------------------------------------------------------------------------
221 Procedure insert_validate
222   (p_effective_date               in date
223   ,p_rec                          in pqh_rnk_shd.g_rec_type
224   ) is
225 --
226   l_proc constant varchar2(72) := g_package||'insert_validate';
227 --
228 Begin
229   hr_utility.set_location('Entering:'||l_proc, 5);
230   --
231   -- Validate Dependent Attributes
232   --
233      pqh_rnk_bus.set_security_group_id(
234         p_rank_process_id  => p_rec.rank_process_id);
235   --
236   hr_utility.set_location(' Leaving:'||l_proc, 10);
237 End insert_validate;
238 --
239 -- ----------------------------------------------------------------------------
240 -- |---------------------------< update_validate >----------------------------|
241 -- ----------------------------------------------------------------------------
242 Procedure update_validate
243   (p_effective_date               in date
244   ,p_rec                          in pqh_rnk_shd.g_rec_type
245   ) is
246 --
247   l_proc constant  varchar2(72) := g_package||'update_validate';
248 --
249 Begin
250   hr_utility.set_location('Entering:'||l_proc, 5);
251   --
252   pqh_rnk_bus.set_security_group_id(
253         p_rank_process_id  => p_rec.rank_process_id);
254   --
255   chk_non_updateable_args
256     (p_effective_date   => p_effective_date
257     ,p_rec              => p_rec
258     );
259   --
260   --
261   hr_utility.set_location(' Leaving:'||l_proc, 10);
262 End update_validate;
263 --
264 -- ----------------------------------------------------------------------------
265 -- |---------------------------< delete_validate >----------------------------|
266 -- ----------------------------------------------------------------------------
267 Procedure delete_validate
268   (p_rec                          in pqh_rnk_shd.g_rec_type
269   ) is
270 --
271   l_proc constant  varchar2(72) := g_package||'delete_validate';
272 --
273 Begin
274   hr_utility.set_location('Entering:'||l_proc, 5);
275   --
276   -- Call all supporting business operations
277   --
278   hr_utility.set_location(' Leaving:'||l_proc, 10);
279 End delete_validate;
280 --
281 end pqh_rnk_bus;