DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PWO_BUS

Source


1 Package Body pay_pwo_bus as
2 /* $Header: pypworhi.pkb 115.3 2002/12/05 15:11:25 swinton noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pay_pwo_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_occupation_id >------|
12 -- ----------------------------------------------------------------------------
13 --
14 -- Description
15 --   This procedure is used to check that the primary key for the table
16 --   is created properly. It should be null on insert and
17 --   should not be able to be updated.
18 --
19 -- Pre Conditions
20 --   None.
21 --
22 -- In Parameters
23 --   occupation_id PK of record being inserted or updated.
24 --   object_version_number Object version number of record being
25 --                         inserted or updated.
26 --
27 -- Post Success
28 --   Processing continues
29 --
30 -- Post Failure
31 --   Errors handled by the procedure
32 --
33 -- Access Status
34 --   Internal table handler use only.
35 --
36 Procedure chk_occupation_id(p_occupation_id                in number,
37                            p_object_version_number       in number) is
38   --
39   l_proc         varchar2(72) := g_package||'chk_occupation_id';
40   l_api_updating boolean;
41   --
42 Begin
43   --
44   hr_utility.set_location('Entering:'||l_proc, 5);
45   --
46   l_api_updating := pay_pwo_shd.api_updating
47     (p_occupation_id                => p_occupation_id,
48      p_object_version_number       => p_object_version_number);
49   --
50   if (l_api_updating
51      and nvl(p_occupation_id,hr_api.g_number)
52      <>  pay_pwo_shd.g_old_rec.occupation_id) then
53     --
54     -- raise error as PK has changed
55     --
56     pay_pwo_shd.constraint_error('PAY_WCI_OCCUPATIONS_PK');
57     --
58   elsif not l_api_updating then
59     --
60     -- check if PK is null
61     --
62     if p_occupation_id is not null then
63       --
64       -- raise error as PK is not null
65       --
66       pay_pwo_shd.constraint_error('PAY_WCI_OCCUPATIONS_PK');
67       --
68     end if;
69     --
70   end if;
71   --
72   hr_utility.set_location('Leaving:'||l_proc, 10);
73   --
74 End chk_occupation_id;
75 -- ----------------------------------------------------------------------------
76 -- |-----------------------------< chk_job_group >----------------------------|
77 -- ----------------------------------------------------------------------------
78 -- Description : This function is used to validate the job being inserted. It
79 --               must be a valid HR Job Group job.
80 -- Validation  : The job must exist in new view per_jobs_v
81 -- On Failure  : Raise message 'The job you have entered is not for a valid HR
82 --               Job Group.'
83 -- ----------------------------------------------------------------------------
84 FUNCTION chk_job_group (p_job_id           in number
85                        ,p_business_group_id in number)
86 RETURN BOOLEAN IS
87 --
88 CURSOR get_job_group_job(p_job_id number
89                         ,p_bg_id  number)
90 IS
91 SELECT job_id
92 FROM   per_jobs_v
93 WHERE  business_group_id = p_bg_id
94 AND    job_id = p_job_id;
95 --
96 l_proc          varchar2(72) := g_package||'chk_job_group';
97 l_exists        number;
98 v_return_value  boolean;
99 --
100 BEGIN
101 --
102 hr_utility.set_location('Entering:'||l_proc, 5);
103 --
104 OPEN  get_job_group_job (p_job_id, p_business_group_id);
105 FETCH get_job_group_job INTO l_exists;
106 --
107   IF get_job_group_job%NOTFOUND THEN
108   --
109     hr_utility.set_location('Returnig FALSE: '||l_proc, 10);
110     v_return_value := FALSE;
111     --
112     --
113   ELSE
114     hr_utility.set_location('Returning TRUE: '||l_proc, 15);
115     v_return_value := TRUE;
116     --
117   END IF;
118   --
119 CLOSE get_job_group_job;
120 --
121 RETURN v_return_value;
122 --
123 hr_utility.set_location('Leaving: '||l_proc, 20);
124 --
125 END chk_job_group;
126 -- ----------------------------------------------------------------------------
127 -- |---------------------------< insert_validate >----------------------------|
128 -- ----------------------------------------------------------------------------
129 Procedure insert_validate(p_rec in pay_pwo_shd.g_rec_type) is
130 --
131   l_proc  varchar2(72) := g_package||'insert_validate';
132 --
133 Begin
134   hr_utility.set_location('Entering:'||l_proc, 5);
135   --
136   -- Call all supporting business operations
137   --
138   chk_occupation_id
139   (p_occupation_id          => p_rec.occupation_id,
140    p_object_version_number => p_rec.object_version_number);
141   --
142   IF NOT chk_job_group (p_job_id            => p_rec.job_id
143                        ,p_business_group_id => p_rec.business_group_id)
144   THEN
145   --
146     hr_utility.set_message(801,'PAY_74036_INVALID_JOB');
147     hr_utility.raise_error;
148     --
149   ELSE
150   --
151     hr_utility.trace('Valid job group job');
152     --
153   END IF;
154   --
155   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
156   --
157   hr_utility.set_location(' Leaving:'||l_proc, 10);
158 End insert_validate;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |---------------------------< update_validate >----------------------------|
162 -- ----------------------------------------------------------------------------
163 Procedure update_validate(p_rec in pay_pwo_shd.g_rec_type) is
164 --
165   l_proc  varchar2(72) := g_package||'update_validate';
166 --
167 Begin
168   hr_utility.set_location('Entering:'||l_proc, 5);
169   --
170   -- Call all supporting business operations
171   --
172   chk_occupation_id
173   (p_occupation_id          => p_rec.occupation_id,
174    p_object_version_number => p_rec.object_version_number);
175   --
176   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
177   --
178   hr_utility.set_location(' Leaving:'||l_proc, 10);
179 End update_validate;
180 --
181 -- ----------------------------------------------------------------------------
182 -- |---------------------------< delete_validate >----------------------------|
183 -- ----------------------------------------------------------------------------
184 Procedure delete_validate(p_rec in pay_pwo_shd.g_rec_type) is
185 --
186   l_proc  varchar2(72) := g_package||'delete_validate';
187 --
188 Begin
189   hr_utility.set_location('Entering:'||l_proc, 5);
190   --
191   -- Call all supporting business operations
192   --
193   hr_utility.set_location(' Leaving:'||l_proc, 10);
194 End delete_validate;
195 --
196 --
197 --  ---------------------------------------------------------------------------
198 --  |---------------------< return_legislation_code >-------------------------|
199 --  ---------------------------------------------------------------------------
200 --
201 function return_legislation_code
202   (p_occupation_id in number) return varchar2 is
203   --
204   -- Declare cursor
205   --
206   cursor csr_leg_code is
207     select a.legislation_code
208     from   per_business_groups a,
209            pay_wci_occupations b
210     where b.occupation_id      = p_occupation_id
211     and   a.business_group_id = b.business_group_id;
212   --
213   -- Declare local variables
214   --
215   l_legislation_code  varchar2(150);
216   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
217   --
218 begin
219   --
220   hr_utility.set_location('Entering:'|| l_proc, 10);
221   --
222   -- Ensure that all the mandatory parameter are not null
223   --
224   hr_api.mandatory_arg_error(p_api_name       => l_proc,
225                              p_argument       => 'occupation_id',
226                              p_argument_value => p_occupation_id);
227   --
228   open csr_leg_code;
229     --
230     fetch csr_leg_code into l_legislation_code;
231     --
232     if csr_leg_code%notfound then
233       --
234       close csr_leg_code;
235       --
236       -- The primary key is invalid therefore we must error
237       --
238       hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
239       hr_utility.raise_error;
240       --
241     end if;
242     --
243   close csr_leg_code;
244   --
245   hr_utility.set_location(' Leaving:'|| l_proc, 20);
246   --
247   return l_legislation_code;
248   --
249 end return_legislation_code;
250 --
251 end pay_pwo_bus;