[Home] [Help]
PACKAGE BODY: APPS.HR_PAC_BUS
Source
1 Package Body hr_pac_bus as
2 /* $Header: hrpacrhi.pkb 115.2 99/07/17 05:36:19 porting ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_pac_bus.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |---------------------------< chk_SSP_rules >-------------------------------|
12 -- ----------------------------------------------------------------------------
13 procedure chk_SSP_rules (
14 --
15 p_pattern_id in number,
16 p_availability in varchar2,
17 p_component_pattern_id in number default null,
18 p_pattern_bit_id in number default null
19 ) is
20 --
21 l_proc varchar2(72) := g_package||'chk_SSP_rules';
22 l_dummy integer (1) := null;
23 --
24 cursor csr_pattern_purpose is
25 --
26 -- Check for a purpose of SSP qualifying pattern
27 --
28 select 1
29 from hr_pattern_purposes
30 where pattern_id = p_pattern_id
31 and pattern_purpose = 'QUALIFYING PATTERN';
32 --
33 cursor csr_pattern_bit is
34 --
35 select 1
36 from hr_pattern_bits
37 where pattern_bit_id = p_pattern_bit_id
38 and (time_unit_multiplier <> ceil (time_unit_multiplier)
39 or base_time_unit <> 'DAYS'
40 or p_availability is null
41 or p_availability not in ('QUALIFYING','NON QUALIFYING'))
42 union all
43 select 1
44 from hr_pattern_bits BIT,
45 hr_pattern_constructions CON
46 where bit.pattern_bit_id = con.pattern_bit_id
47 and con.pattern_id = p_component_pattern_id
48 and (bit.time_unit_multiplier <> ceil (bit.time_unit_multiplier)
49 or bit.base_time_unit <> 'DAYS'
50 or con.availability not in ('QUALIFYING','NON QUALIFYING'));
51 --
52 procedure check_parameters is
53 --
54 begin
55 --
56 hr_api.mandatory_arg_error
57 (p_api_name => l_proc,
58 p_argument => 'pattern_id',
59 p_argument_value => p_pattern_id);
60 --
61 -- There must be either a pattern bit or a component pattern id,
62 -- but not both
63 --
64 if (p_component_pattern_id is not null
65 and p_pattern_bit_id is not null)
66 or (p_component_pattern_id is null
67 and p_pattern_bit_id is null)
68 then
69 --
70 hr_pac_shd.constraint_error ('HR_PAC_PAB_PAT_ARC');
71 --
72 end if;
73 --
74 end check_parameters;
75 --
76 begin
77 --
78 hr_utility.set_location ('Entering '||l_proc,1);
79 --
80 check_parameters;
81 --
82 open csr_pattern_purpose;
83 fetch csr_pattern_purpose into l_dummy;
84 --
85 if csr_pattern_purpose%found then
86 --
87 -- The pattern may be used for SSP qualifying patterns. Therefore, it may
88 -- only have pattern bits of whole days. That goes for any component
89 -- patterns as well.
90 --
91 close csr_pattern_purpose;
92 open csr_pattern_bit;
93 fetch csr_pattern_bit into l_dummy;
94 if csr_pattern_bit%found then
95 --
96 -- The pattern bit chosen, or one of the pattern bits in the component
97 -- pattern chosen, was not a whole multiple of a day.
98 --
99 close csr_pattern_bit;
100 hr_utility.set_message (801,'HR_51073_PAC_SSP_BITS');
101 hr_utility.raise_error;
102 --
103 else
104 --
105 close csr_pattern_bit;
106 --
107 end if;
108 --
109 else
110 --
111 close csr_pattern_purpose;
112 --
113 end if;
114 --
115 hr_utility.set_location ('Leaving '||l_proc,10);
116 --
117 end chk_SSP_rules;
118 -- ----------------------------------------------------------------------------
119 -- |---------------------------< chk_availability >---------------------------|
120 -- ----------------------------------------------------------------------------
121 procedure chk_availability (
122 --
123 p_availability in varchar2
124 ) is
125 --
126 l_proc varchar2(72) := g_package||'chk_availability';
127 l_dummy integer(1) := null;
128 --
129 cursor csr_lookup is
130 --
131 select 1
132 from hr_lookups
133 where lookup_code = p_availability
134 and lookup_type = 'AVAILABILITY';
135 --
136 begin
137 --
138 hr_utility.set_location ('Entering '||l_proc,1);
139 --
140 if p_availability is not null then
141 --
142 open csr_lookup;
143 fetch csr_lookup into l_dummy;
144 if csr_lookup%notfound then
145 --
146 -- The availability was not valid.
147 --
148 close csr_lookup;
149 hr_utility.set_message (801,'HR_51074_PAC_AVAILABILITY');
150 hr_utility.raise_error;
151 --
152 else
153 --
154 close csr_lookup;
155 --
156 end if;
157 --
158 end if;
159 --
160 hr_utility.set_location ('Leaving '||l_proc,10);
161 --
162 end chk_availability;
163 -- ----------------------------------------------------------------------------
164 -- |---------------------------< chk_component_pattern_id >-------------------|
165 -- ----------------------------------------------------------------------------
166 procedure chk_component_pattern_id (
167 --
168 p_component_pattern_id in number
169 ) is
170 --
171 l_proc varchar2(72) := g_package||'chk_component_pattern_id';
172 l_dummy integer (1) := null;
173 --
174 cursor csr_component is
175 --
176 -- Check that the component pattern is not itself made up of further
177 -- component patterns.
178 --
179 select 1
180 from hr_pattern_constructions
181 where pattern_id = p_component_pattern_id
182 and component_pattern_id is not null;
183 --
184 begin
185 --
186 hr_utility.set_location ('Entering '||l_proc,1);
187 --
188 if p_component_pattern_id is not null then
189 --
190 open csr_component;
191 fetch csr_component into l_dummy;
192 if csr_component%found then
193 --
194 close csr_component;
195 hr_utility.set_message (801,'HR_51075_PAC_PAT_HIERARCHY');
196 hr_utility.raise_error;
197 --
198 else
199 --
200 close csr_component;
201 --
202 end if;
203 --
204 end if;
205 --
206 hr_utility.set_location ('Leaving '||l_proc,10);
207 --
208 end chk_component_pattern_id;
209 -- ----------------------------------------------------------------------------
210 -- |---------------------------< insert_validate >----------------------------|
211 -- ----------------------------------------------------------------------------
212 Procedure insert_validate(p_rec in hr_pac_shd.g_rec_type) is
213 --
214 l_proc varchar2(72) := g_package||'insert_validate';
215 --
216 Begin
217 hr_utility.set_location('Entering:'||l_proc, 5);
218 --
219 -- Call all supporting business operations
220 --
221 chk_availability (p_availability=> p_rec.availability);
222 --
223 chk_component_pattern_id (p_component_pattern_id=>p_rec.component_pattern_id);
224 --
225 chk_SSP_rules (p_pattern_id=> p_rec.pattern_id,
226 p_availability=> p_rec.availability,
227 p_component_pattern_id=> p_rec.component_pattern_id,
228 p_pattern_bit_id=> p_rec.pattern_bit_id);
229 --
230 --
231 hr_utility.set_location(' Leaving:'||l_proc, 10);
232 End insert_validate;
233 --
234 -- ----------------------------------------------------------------------------
235 -- |---------------------------< update_validate >----------------------------|
236 -- ----------------------------------------------------------------------------
237 Procedure update_validate(p_rec in hr_pac_shd.g_rec_type) is
238 --
239 l_proc varchar2(72) := g_package||'update_validate';
240 --
241 Begin
242 hr_utility.set_location('Entering:'||l_proc, 5);
243 --
244 -- Call all supporting business operations
245 --
246 -- Update is NOT allowed
247 --
248 hr_utility.set_location(' Leaving:'||l_proc, 10);
249 End update_validate;
250 --
251 -- ----------------------------------------------------------------------------
252 -- |---------------------------< delete_validate >----------------------------|
253 -- ----------------------------------------------------------------------------
254 Procedure delete_validate(p_rec in hr_pac_shd.g_rec_type) is
255 --
256 l_proc varchar2(72) := g_package||'delete_validate';
257 --
258 Begin
259 hr_utility.set_location('Entering:'||l_proc, 5);
260 --
261 -- Call all supporting business operations
262 --
263 hr_utility.set_location(' Leaving:'||l_proc, 10);
264 End delete_validate;
265 --
266 end hr_pac_bus;