DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_PAE_BUS

Source


1 Package Body hr_pae_bus as
2 /* $Header: hrpaerhi.pkb 115.1 99/07/17 05:36:26 porting ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hr_pae_bus.';  -- Global package name
9 --
10 --
11 --  Business Validation Rules
12 --
13 -- --------------------------------------------------------------------------
14 -- |---------------------------< Check_Exception_Name >---------------------|
15 -- --------------------------------------------------------------------------
16 --
17 -- PUBLIC
18 -- Description:
19 --   Ensure that a valid exception name is enterd.  It must be unique,
20 --   (case-insensitive_check).
21 --
22 Procedure check_exception_name (p_exception_id in number default null,
23 				p_object_version_number in number default null,
24 				p_exception_name in varchar2) is
25 --
26 l_proc  varchar2(72) := g_package||'Check_Exception_Name';
27 l_api_updating boolean;
28 
29 cursor c1 is
30   select hpe.rowid
31   from   hr_pattern_exceptions hpe
32   where  upper(hpe.exception_name) = upper(p_exception_name);
33 
34  c1_rec c1%ROWTYPE;
35 
36 BEGIN
37   hr_utility.set_location('Entering:'||l_proc, 5);
38 
39     l_api_updating := hr_pae_shd.api_updating
40       (p_exception_id   => p_exception_id,
41        p_object_version_number => p_object_version_number);
42 
43   if ((l_api_updating and hr_pae_shd.g_old_rec.exception_name <>
44                                           p_exception_name)
45        or (NOT l_api_updating)) then
46 
47      hr_utility.set_location(l_proc,10);
48 
49      open c1;
50      fetch c1 into c1_rec;
51      if c1%FOUND then
52        close c1;
53     --  *** NEW_MESSAGE_REQUIRED ***
54        fnd_message.set_name('HR','EXCEP_NAME_NOT_UNIQUE');
55        fnd_message.raise_error;
56      end if;
57   end if;
58   hr_utility.set_location(' Leaving:'||l_proc, 20);
59 END check_exception_name;
60 --
61 -- -------------------------------------------------------------------------
62 -- |---------------------------< Check_Exception_Category >----------------|
63 -- -------------------------------------------------------------------------
64 --
65 -- PUBLIC
66 -- Description:
67 --   Ensure that the exception category is valid, must exist in
68 --   HR_LOOKUPS where lookup type = 'EXCEPTION_CATEGORY'
69 --
70 Procedure Check_Exception_Category ( p_exception_category in varchar2) is
71 --
72   l_proc  varchar2(72) := g_package||'Check_Exception_Category';
73 
74  cursor c1 is
75   select h.rowid
76   from   hr_lookups h
77   where  h.lookup_type = 'EXCEPTION_CATEGORY'
78     and  h.lookup_code = p_exception_category;
79 
80   c1_rec c1%ROWTYPE;
81 BEGIN
82   hr_utility.set_location('Entering:'||l_proc, 5);
83   --
84      if p_exception_category is not null then
85      open c1;
86      fetch c1 into c1_rec;
87      if c1%NOTFOUND    then
88     --  *** NEW_MESSAGE_REQUIRED ***
89        fnd_message.set_name('HR','INVALID_EXCEP_CATEGORY');
90        fnd_message.raise_error;
91      end if;
92      close c1;
93      end if;
94   hr_utility.set_location(' Leaving:'||l_proc, 10);
95 END check_exception_category;
96 
97 --
98 -- --------------------------------------------------------------------------
99 -- |---------------------------< To_Days >----------------------------------|
100 -- --------------------------------------------------------------------------
101 --
102 -- PUBLIC
103 -- Description:
104 --   Convert user-defined time-unit into days for ease of comparison
105 --   and manipulation
106 --
107 Function to_days (p_quantity in number,
108 		  p_units    varchar2) return number is
109 
110   l_proc  varchar2(72) := g_package||'Derive_Excep_End_Time';
111   conversion_factor   number := 1;
112 
113 BEGIN
114   hr_utility.set_location('Entering:'||l_proc, 5);
115 
116   if p_units = 'H' then
117      conversion_factor := 24;
118   elsif
119      p_units = 'W' then
120        conversion_factor := 1/7;
121   end if;
122 
123   return (p_quantity / conversion_factor);
124 
125   hr_utility.set_location('Entering:'||l_proc, 10);
126 END to_days;
127 --
128 -- --------------------------------------------------------------------------
129 -- |---------------------------< Derive_Excep_End_Time >--------------------|
130 -- --------------------------------------------------------------------------
131 --
132 -- PUBLIC
136 --    If there are pattern_construction children, then set the
133 -- Description:
134 --    If there are no pattern_construction_children, then set the
135 --    exception_end_time equal to the exception_start_time .
137 --    exception_end_time equal to the exception_start_time plus the
138 --    duration of the pattern construction.  Convert each base_time_unit
139 --    to a fraction of a day, multiplying that figure by the time unit
140 --    multiplier for each bit of the construction, then summate the
141 --    products (IU).
142 --
143 Procedure Derive_Excep_End_Time (p_pattern_id in number,
144 				 p_exception_start_time in date,
145 				 p_exception_end_time out date) is
146 
147   l_proc  varchar2(72) := g_package||'Derive_Excep_End_Time';
148   l_time  number := 0;
149 
150   cursor c1 is
151     select bit1.time_unit_multiplier tum,
152 	   bit1.base_time_unit btu,
153 	   con1.sequence_no,
154 	   0
155     from   hr_pattern_constructions  con1,
156 	   hr_pattern_bits           bit1
157     where  bit1.pattern_bit_id = con1.pattern_bit_id
158       and  con1.pattern_id     = p_pattern_id
159     union all
160     select bit2.time_unit_multiplier tum,
161 	   bit2.base_time_unit btu,
162 	   con2.sequence_no,
163 	   con3.sequence_no
164     from   hr_pattern_bits           bit2,
165 	   hr_pattern_constructions  con2,
166 	   hr_pattern_constructions  con3
167     where  bit2.pattern_bit_id = con3.pattern_bit_id
168       and  con2.component_pattern_id = con3.pattern_id
169       and  con2.pattern_id = p_pattern_id
170     order by 3,4;
171 
172 
173 BEGIN
174   hr_utility.set_location('Entering:'||l_proc, 5);
175 
176   for c1_rec in c1 loop
177      l_time := l_time + to_days(p_quantity   => c1_rec.tum,
178 				p_units      => c1_rec.btu);
179   end loop;
180   p_exception_end_time := p_exception_start_time + nvl(l_time,0);
181 
182   hr_utility.set_location('Entering:'||l_proc, 10);
183 END Derive_Excep_End_Time;
184 -- ----------------------------------------------------------------------------
185 -- |---------------------------< insert_validate >----------------------------|
186 -- ----------------------------------------------------------------------------
187 Procedure insert_validate(p_rec in out hr_pae_shd.g_rec_type) is
188 --
189   l_proc  varchar2(72) := g_package||'insert_validate';
190 --
191 Begin
192   hr_utility.set_location('Entering:'||l_proc, 5);
193   --
194   -- Call all supporting business operations
195   --
196     hr_api.mandatory_arg_error (p_api_name       => l_proc,
197 				p_argument       => 'pattern_id',
198 		                p_argument_value => p_rec.pattern_id);
199 
200     hr_api.mandatory_arg_error
201 	 (p_api_name       => l_proc,
202 	  p_argument       => 'exception_start_time',
203           p_argument_value => p_rec.exception_start_time);
204 
205   --
206 
207   hr_pae_bus.Derive_Excep_End_Time (p_rec.pattern_id,
208                                     p_rec.exception_start_time,
209 				    p_rec.exception_end_time);
210 
211   hr_pae_bus.check_exception_name (p_rec.exception_id,
212 				   p_rec.object_version_number,
213 				   p_rec.exception_name);
214   --
215   hr_pae_bus.Check_Exception_Category (p_rec.exception_category);
216   --
217   hr_utility.set_location(' Leaving:'||l_proc, 10);
218 End insert_validate;
219 --
220 -- ----------------------------------------------------------------------------
221 -- |---------------------------< update_validate >----------------------------|
222 -- ----------------------------------------------------------------------------
223 Procedure update_validate(p_rec in out hr_pae_shd.g_rec_type) is
224 --
225   l_proc  varchar2(72) := g_package||'update_validate';
226 --
227 Begin
228   hr_utility.set_location('Entering:'||l_proc, 5);
229   --
230   -- Call all supporting business operations
231   --
232 /*    if (hr_pae_shd.api_updating
233 	    ( p_exception_id           => p_rec.exception_id,
234    	      p_object_version_number  => p_rec.object_version_number)
235 	      and
236                p_rec.pattern_id <> hr_ern_shd.g_old_rec.pattern_id) then
237                   hr_api.argument_changed_error
238                          (p_api_name => l_proc,
239                           p_argument => 'pattern_id');
240     end if; */
241   --
242 /*    if (hr_pae_shd.api_updating
243 	    ( p_exception_id           => p_rec.exception_id,
244    	      p_object_version_number  => p_rec.object_version_number)
245 	      and
246                p_rec.exception_start_time <>
247 		      hr_ern_shd.g_old_rec.exception_start_time) then
248                   hr_api.argument_changed_error
249                          (p_api_name => l_proc,
250                           p_argument => 'p_rec.exception_start_time');
251     end if;
252  */ --
253 
254   hr_pae_bus.Derive_Excep_End_Time (p_rec.pattern_id,
255                                     p_rec.exception_start_time,
256 				    p_rec.exception_end_time);
257   --
258   hr_pae_bus.check_exception_name (p_rec.exception_id,
259 				   p_rec.object_version_number,
260 				   p_rec.exception_name);
261   --
262   hr_pae_bus.Check_Exception_Category (p_rec.exception_category);
263   --
264   --
265   hr_utility.set_location(' Leaving:'||l_proc, 10);
266 End update_validate;
267 --
268 -- ----------------------------------------------------------------------------
269 -- |---------------------------< delete_validate >----------------------------|
270 -- ----------------------------------------------------------------------------
271 Procedure delete_validate(p_rec in hr_pae_shd.g_rec_type) is
272 --
273   l_proc  varchar2(72) := g_package||'delete_validate';
274 --
275 Begin
276   hr_utility.set_location('Entering:'||l_proc, 5);
277   --
278   -- Call all supporting business operations
279   --
280   hr_utility.set_location(' Leaving:'||l_proc, 10);
281 End delete_validate;
282 --
283 end hr_pae_bus;