1 Package Body pay_tdu_ins as
2 /* $Header: pytdurhi.pkb 120.2 2005/10/14 07:07 adkumar noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_tdu_ins.'; -- Global package name
9 --
10 -- The following global variables are only to be used by
11 -- the set_base_key_value and pre_insert procedures.
12 --
13 g_time_definition_id_i number default null;
14 g_usage_type_i varchar2(30) default null;
15 --
16 -- ----------------------------------------------------------------------------
17 -- |------------------------< set_base_key_value >----------------------------|
18 -- ----------------------------------------------------------------------------
19 procedure set_base_key_value
20 (p_time_definition_id in number
21 ,p_usage_type in varchar2) is
22 --
23 l_proc varchar2(72) := g_package||'set_base_key_value';
24 --
25 Begin
26 hr_utility.set_location('Entering:'||l_proc, 10);
27 --
28 pay_tdu_ins.g_time_definition_id_i := p_time_definition_id;
29 pay_tdu_ins.g_usage_type_i := p_usage_type;
30 --
31 hr_utility.set_location(' Leaving:'||l_proc, 20);
32 End set_base_key_value;
33 --
34 --
35 -- ----------------------------------------------------------------------------
36 -- |------------------------------< insert_dml >------------------------------|
37 -- ----------------------------------------------------------------------------
38 -- {Start Of Comments}
39 --
40 -- Description:
41 -- This procedure controls the actual dml insert logic. The processing of
42 -- this procedure are as follows:
43 -- 1) Initialise the object_version_number to 1 if the object_version_number
44 -- is defined as an attribute for this entity.
45 -- 2) To set and unset the g_api_dml status as required (as we are about to
46 -- perform dml).
47 -- 3) To insert the row into the schema.
48 -- 4) To trap any constraint violations that may have occurred.
49 -- 5) To raise any other errors.
50 --
51 -- Prerequisites:
52 -- This is an internal private procedure which must be called from the ins
53 -- procedure and must have all mandatory attributes set (except the
54 -- object_version_number which is initialised within this procedure).
55 --
56 -- In Parameters:
57 -- A Pl/Sql record structre.
58 --
59 -- Post Success:
60 -- The specified row will be inserted into the schema.
61 --
62 -- Post Failure:
63 -- On the insert dml failure it is important to note that we always reset the
64 -- g_api_dml status to false.
65 -- If a check, unique or parent integrity constraint violation is raised the
66 -- constraint_error procedure will be called.
67 -- If any other error is reported, the error will be raised after the
68 -- g_api_dml status is reset.
69 --
70 -- Developer Implementation Notes:
71 -- None.
72 --
73 -- Access Status:
74 -- Internal Row Handler Use Only.
75 --
76 -- {End Of Comments}
77 -- ----------------------------------------------------------------------------
78 Procedure insert_dml
79 (p_rec in out nocopy pay_tdu_shd.g_rec_type
80 ) is
81 --
82 l_proc varchar2(72) := g_package||'insert_dml';
83 --
84 Begin
85 hr_utility.set_location('Entering:'||l_proc, 5);
86 p_rec.object_version_number := 1; -- Initialise the object version
87 --
88 --
89 --
90 -- Insert the row into: pay_time_def_usages
91 --
92 insert into pay_time_def_usages
93 (time_definition_id
94 ,usage_type
95 ,object_version_number
96 )
97 Values
98 (p_rec.time_definition_id
99 ,p_rec.usage_type
100 ,p_rec.object_version_number
101 );
102 --
103 --
104 --
105 hr_utility.set_location(' Leaving:'||l_proc, 10);
106 Exception
107 When hr_api.check_integrity_violated Then
108 -- A check constraint has been violated
109 --
110 pay_tdu_shd.constraint_error
111 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
112 When hr_api.parent_integrity_violated Then
113 -- Parent integrity has been violated
114 --
115 pay_tdu_shd.constraint_error
116 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
117 When hr_api.unique_integrity_violated Then
118 -- Unique integrity has been violated
119 --
120 pay_tdu_shd.constraint_error
121 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
122 When Others Then
123 --
124 Raise;
125 End insert_dml;
126 --
127 -- ----------------------------------------------------------------------------
128 -- |------------------------------< pre_insert >------------------------------|
129 -- ----------------------------------------------------------------------------
130 -- {Start Of Comments}
131 --
132 -- Description:
133 -- This private procedure contains any processing which is required before
134 -- the insert dml. Presently, if the entity has a corresponding primary
135 -- key which is maintained by an associating sequence, the primary key for
136 -- the entity will be populated with the next sequence value in
137 -- preparation for the insert dml.
138 --
139 -- Prerequisites:
140 -- This is an internal procedure which is called from the ins procedure.
141 --
142 -- In Parameters:
143 -- A Pl/Sql record structure.
144 --
145 -- Post Success:
146 -- Processing continues.
147 --
148 -- Post Failure:
149 -- If an error has occurred, an error message and exception will be raised
150 -- but not handled.
151 --
152 -- Developer Implementation Notes:
153 -- Any pre-processing required before the insert dml is issued should be
154 -- coded within this procedure. As stated above, a good example is the
155 -- generation of a primary key number via a corresponding sequence.
156 -- It is important to note that any 3rd party maintenance should be reviewed
157 -- before placing in this procedure.
158 --
159 -- Access Status:
160 -- Internal Row Handler Use Only.
161 --
162 -- {End Of Comments}
163 -- ----------------------------------------------------------------------------
164 Procedure pre_insert
165 (p_rec in out nocopy pay_tdu_shd.g_rec_type
166 ) is
167 --
168 Cursor C_Sel2 is
169 Select null
170 from pay_time_def_usages
171 where time_definition_id =
172 pay_tdu_ins.g_time_definition_id_i
173 and usage_type =
174 pay_tdu_ins.g_usage_type_i;
175 --
176 l_proc varchar2(72) := g_package||'pre_insert';
177 l_exists varchar2(1);
178 --
179 Begin
180 hr_utility.set_location('Entering:'||l_proc, 5);
181 --
182 If (pay_tdu_ins.g_time_definition_id_i is not null or
183 pay_tdu_ins.g_usage_type_i is not null) Then
184 --
185 -- Verify registered primary key values not already in use
186 --
187 Open C_Sel2;
188 Fetch C_Sel2 into l_exists;
189 If C_Sel2%found Then
190 Close C_Sel2;
191 --
192 -- The primary key values are already in use.
193 --
194 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
195 fnd_message.set_token('TABLE_NAME','pay_time_def_usages');
196 fnd_message.raise_error;
197 End If;
198 Close C_Sel2;
199 --
200 -- Use registered key values and clear globals
201 --
202 p_rec.time_definition_id :=
203 pay_tdu_ins.g_time_definition_id_i;
204 pay_tdu_ins.g_time_definition_id_i := null;
205 p_rec.usage_type :=
206 pay_tdu_ins.g_usage_type_i;
207 pay_tdu_ins.g_usage_type_i := null;
208
209 End If;
210 --
211 hr_utility.set_location(' Leaving:'||l_proc, 10);
212 End pre_insert;
213 --
214 -- ----------------------------------------------------------------------------
215 -- |-----------------------------< post_insert >------------------------------|
216 -- ----------------------------------------------------------------------------
217 -- {Start Of Comments}
218 --
219 -- Description:
220 -- This private procedure contains any processing which is required after
221 -- the insert dml.
222 --
223 -- Prerequisites:
224 -- This is an internal procedure which is called from the ins procedure.
225 --
226 -- In Parameters:
227 -- A Pl/Sql record structre.
228 --
229 -- Post Success:
230 -- Processing continues.
231 --
232 -- Post Failure:
233 -- If an error has occurred, an error message and exception will be raised
234 -- but not handled.
235 --
236 -- Developer Implementation Notes:
237 -- Any post-processing required after the insert dml is issued should be
238 -- coded within this procedure. It is important to note that any 3rd party
239 -- maintenance should be reviewed before placing in this procedure.
240 --
241 -- Access Status:
242 -- Internal Row Handler Use Only.
243 --
244 -- {End Of Comments}
245 -- ----------------------------------------------------------------------------
246 Procedure post_insert
247 (p_effective_date in date
248 ,p_rec in pay_tdu_shd.g_rec_type
249 ) is
250 --
251 l_proc varchar2(72) := g_package||'post_insert';
252 --
253 Begin
254 hr_utility.set_location('Entering:'||l_proc, 5);
255 begin
256 --
257 pay_tdu_rki.after_insert
258 (p_effective_date => p_effective_date
259 ,p_time_definition_id
260 => p_rec.time_definition_id
261 ,p_usage_type
262 => p_rec.usage_type
263 ,p_object_version_number
264 => p_rec.object_version_number
265 );
266 --
267 exception
268 --
269 when hr_api.cannot_find_prog_unit then
270 --
271 hr_api.cannot_find_prog_unit_error
272 (p_module_name => 'PAY_TIME_DEF_USAGES'
273 ,p_hook_type => 'AI');
274 --
275 end;
276 --
277 hr_utility.set_location(' Leaving:'||l_proc, 10);
278 End post_insert;
279 --
280 -- ----------------------------------------------------------------------------
281 -- |---------------------------------< ins >----------------------------------|
282 -- ----------------------------------------------------------------------------
283 Procedure ins
284 (p_effective_date in date
285 ,p_rec in out nocopy pay_tdu_shd.g_rec_type
286 ) is
287 --
288 l_proc varchar2(72) := g_package||'ins';
289 --
290 Begin
291 hr_utility.set_location('Entering:'||l_proc, 5);
292 --
293 -- Call the supporting insert validate operations
294 --
295 pay_tdu_bus.insert_validate
296 (p_effective_date
297 ,p_rec
298 );
299 --
300 -- Call to raise any errors on multi-message list
301 hr_multi_message.end_validation_set;
302 --
303 -- Call the supporting pre-insert operation
304 --
305 pay_tdu_ins.pre_insert(p_rec);
306 --
307 -- Insert the row
308 --
309 pay_tdu_ins.insert_dml(p_rec);
310 --
311 -- Call the supporting post-insert operation
312 --
313 pay_tdu_ins.post_insert
314 (p_effective_date
315 ,p_rec
316 );
317 --
318 -- Call to raise any errors on multi-message list
319 hr_multi_message.end_validation_set;
320 --
321 hr_utility.set_location('Leaving:'||l_proc, 20);
322 end ins;
323 --
324 -- ----------------------------------------------------------------------------
325 -- |---------------------------------< ins >----------------------------------|
326 -- ----------------------------------------------------------------------------
327 Procedure ins
328 (p_effective_date in date
329 ,p_time_definition_id in number
330 ,p_usage_type in varchar2
331 ,p_object_version_number out nocopy number
332 ) is
333 --
334 l_rec pay_tdu_shd.g_rec_type;
335 l_proc varchar2(72) := g_package||'ins';
336 --
337 Begin
338 hr_utility.set_location('Entering:'||l_proc, 5);
339 --
340 -- Call conversion function to turn arguments into the
341 -- p_rec structure.
342 --
343 l_rec :=
344 pay_tdu_shd.convert_args
345 (p_time_definition_id
346 ,p_usage_type
347 ,null
348 );
349 --
350 -- Having converted the arguments into the pay_tdu_rec
351 -- plsql record structure we call the corresponding record business process.
352 --
353 pay_tdu_ins.ins
354 (p_effective_date
355 ,l_rec
356 );
357 --
358 -- As the primary key argument(s)
359 -- are specified as an OUT's we must set these values.
360 --
361 p_object_version_number := l_rec.object_version_number;
362 --
363 hr_utility.set_location(' Leaving:'||l_proc, 10);
364 End ins;
365 --
366 end pay_tdu_ins;