1 Package Body pay_itr_ins as
2 /* $Header: pyitrrhi.pkb 115.6 2002/12/16 17:48:51 dsaxby noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_itr_ins.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |----------------------------< dt_insert_dml >-----------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 -- This procedure controls the actual dml insert logic for datetrack. The
17 -- functions of this procedure are as follows:
18 -- 1) Get the object_version_number.
19 -- 2) To set the effective start and end dates to the corresponding
20 -- validation start and end dates. Also, the object version number
21 -- record attribute is set.
22 -- 3) To set and unset the g_api_dml status as required (as we are about to
23 -- perform dml).
24 -- 4) To insert the row into the schema with the derived effective start
25 -- and end dates and the object version number.
26 -- 5) To trap any constraint violations that may have occurred.
27 -- 6) To raise any other errors.
28 --
29 -- Prerequisites:
30 -- This is an internal private procedure which must be called from the
31 -- insert_dml and pre_update (logic permitting) procedure and must have
32 -- all mandatory arguments set.
33 --
34 -- In Parameters:
35 -- A Pl/Sql record structure.
36 --
37 -- Post Success:
38 -- The specified row will be inserted into the schema.
39 --
40 -- Post Failure:
41 -- On the insert dml failure it is important to note that we always reset the
42 -- g_api_dml status to false.
43 -- If a check or unique integrity constraint violation is raised the
44 -- constraint_error procedure will be called.
45 -- If any other error is reported, the error will be raised after the
46 -- g_api_dml status is reset.
47 --
51 --
48 -- Developer Implementation Notes:
49 -- This is an internal datetrack maintenance procedure which should
50 -- not be modified in anyway.
52 -- Access Status:
53 -- Internal Row Handler Use Only.
54 --
55 -- {End Of Comments}
56 -- ----------------------------------------------------------------------------
57 Procedure dt_insert_dml
58 (p_rec in out nocopy pay_itr_shd.g_rec_type
59 ,p_effective_date in date
60 ,p_datetrack_mode in varchar2
61 ,p_validation_start_date in date
62 ,p_validation_end_date in date
63 ) is
64 -- Cursor to select 'old' created AOL who column values
65 --
66 Cursor C_Sel1 Is
67 select t.created_by,
68 t.creation_date
69 from pay_iterative_rules_f t
70 where t.iterative_rule_id = p_rec.iterative_rule_id
71 and t.effective_start_date =
72 pay_itr_shd.g_old_rec.effective_start_date
73 and t.effective_end_date = (p_validation_start_date - 1);
74 --
75 l_proc varchar2(72) := g_package||'dt_insert_dml';
76 l_created_by pay_iterative_rules_f.created_by%TYPE;
77 l_creation_date pay_iterative_rules_f.creation_date%TYPE;
78 l_last_update_date pay_iterative_rules_f.last_update_date%TYPE;
79 l_last_updated_by pay_iterative_rules_f.last_updated_by%TYPE;
80 l_last_update_login pay_iterative_rules_f.last_update_login%TYPE;
81 --
82 Begin
83 hr_utility.set_location('Entering:'||l_proc, 5);
84 --
85 -- Get the object version number for the insert
86 --
87 p_rec.object_version_number :=
88 dt_api.get_object_version_number
89 (p_base_table_name => 'pay_iterative_rules_f'
90 ,p_base_key_column => 'iterative_rule_id'
91 ,p_base_key_value => p_rec.iterative_rule_id
92 );
93 --
94 -- Set the effective start and end dates to the corresponding
95 -- validation start and end dates
96 --
97 p_rec.effective_start_date := p_validation_start_date;
98 p_rec.effective_end_date := p_validation_end_date;
99 --
100 -- If the datetrack_mode is not INSERT then we must populate the WHO
101 -- columns with the 'old' creation values and 'new' updated values.
102 --
103 If (p_datetrack_mode <> hr_api.g_insert) then
104 hr_utility.set_location(l_proc, 10);
105 --
106 -- Select the 'old' created values
107 --
108 Open C_Sel1;
109 Fetch C_Sel1 Into l_created_by, l_creation_date;
110 If C_Sel1%notfound Then
111 --
112 -- The previous 'old' created row has not been found. We need
113 -- to error as an internal datetrack problem exists.
114 --
115 Close C_Sel1;
116 fnd_message.set_name(801, 'HR_6153_ALL_PROCEDURE_FAIL');
117 fnd_message.set_token('PROCEDURE', l_proc);
118 fnd_message.set_token('STEP','10');
119 fnd_message.raise_error;
120 End If;
121 Close C_Sel1;
122 --
123 -- Set the AOL updated WHO values
124 --
125 l_last_update_date := sysdate;
126 l_last_updated_by := fnd_global.user_id;
127 l_last_update_login := fnd_global.login_id;
128 End If;
129 --
130 --
131 --
132 -- Insert the row into: pay_iterative_rules_f
133 --
134 insert into pay_iterative_rules_f
135 (iterative_rule_id
136 ,element_type_id
137 ,effective_start_date
138 ,effective_end_date
139 ,result_name
140 ,iterative_rule_type
141 ,input_value_id
142 ,severity_level
143 ,business_group_id
144 ,legislation_code
145 ,object_version_number
146 ,created_by
147 ,creation_date
148 ,last_update_date
149 ,last_updated_by
150 ,last_update_login
151 )
152 Values
153 (p_rec.iterative_rule_id
154 ,p_rec.element_type_id
155 ,p_rec.effective_start_date
156 ,p_rec.effective_end_date
157 ,p_rec.result_name
158 ,p_rec.iterative_rule_type
159 ,p_rec.input_value_id
160 ,p_rec.severity_level
161 ,p_rec.business_group_id
162 ,p_rec.legislation_code
163 ,p_rec.object_version_number
164 ,l_created_by
165 ,l_creation_date
166 ,l_last_update_date
167 ,l_last_updated_by
168 ,l_last_update_login
169 );
170 --
171 --
172 hr_utility.set_location(' Leaving:'||l_proc, 15);
173 --
174 Exception
175 When hr_api.check_integrity_violated Then
176 -- A check constraint has been violated
177 --
178 pay_itr_shd.constraint_error
179 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
180 When hr_api.unique_integrity_violated Then
181 -- Unique integrity has been violated
182 --
183 pay_itr_shd.constraint_error
184 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
185 When Others Then
186 --
187 Raise;
188 End dt_insert_dml;
189 --
190 -- ----------------------------------------------------------------------------
191 -- |------------------------------< insert_dml >------------------------------|
192 -- ----------------------------------------------------------------------------
193 Procedure insert_dml
194 (p_rec in out nocopy pay_itr_shd.g_rec_type
195 ,p_effective_date in date
196 ,p_datetrack_mode in varchar2
197 ,p_validation_start_date in date
201 l_proc varchar2(72) := g_package||'insert_dml';
198 ,p_validation_end_date in date
199 ) is
200 --
202 --
203 Begin
204 hr_utility.set_location('Entering:'||l_proc, 5);
205 --
206 pay_itr_ins.dt_insert_dml
207 (p_rec => p_rec
208 ,p_effective_date => p_effective_date
209 ,p_datetrack_mode => p_datetrack_mode
210 ,p_validation_start_date => p_validation_start_date
211 ,p_validation_end_date => p_validation_end_date
212 );
213 --
214 hr_utility.set_location(' Leaving:'||l_proc, 10);
215 End insert_dml;
216 --
217 -- ----------------------------------------------------------------------------
218 -- |------------------------------< pre_insert >------------------------------|
219 -- ----------------------------------------------------------------------------
220 -- {Start Of Comments}
221 --
222 -- Description:
223 -- This private procedure contains any processing which is required before
224 -- the insert dml. Presently, if the entity has a corresponding primary
225 -- key which is maintained by an associating sequence, the primary key for
226 -- the entity will be populated with the next sequence value in
227 -- preparation for the insert dml.
228 -- Also, if comments are defined for this entity, the comments insert
229 -- logic will also be called, generating a comment_id if required.
230 --
231 -- Prerequisites:
232 -- This is an internal procedure which is called from the ins procedure.
233 --
234 -- In Parameters:
235 -- A Pl/Sql record structure.
236 --
237 -- Post Success:
238 -- Processing continues.
239 --
240 -- Post Failure:
241 -- If an error has occurred, an error message and exception will be raised
242 -- but not handled.
243 --
244 -- Developer Implementation Notes:
245 -- Any pre-processing required before the insert dml is issued should be
246 -- coded within this procedure. As stated above, a good example is the
247 -- generation of a primary key number via a corresponding sequence.
248 -- It is important to note that any 3rd party maintenance should be reviewed
249 -- before placing in this procedure.
250 --
251 -- Access Status:
252 -- Internal Row Handler Use Only.
253 --
254 -- {End Of Comments}
255 -- ----------------------------------------------------------------------------
256 Procedure pre_insert
257 (p_rec in out nocopy pay_itr_shd.g_rec_type
258 ,p_effective_date in date
259 ,p_datetrack_mode in varchar2
260 ,p_validation_start_date in date
261 ,p_validation_end_date in date
262 ) is
263 --
264 l_proc varchar2(72) := g_package||'pre_insert';
265 --
266 Cursor C_Sel1 is select pay_iterative_rules_s.nextval from sys.dual;
267 --
268 Begin
269 hr_utility.set_location('Entering:'||l_proc, 5);
270 --
271 --
272 -- Select the next sequence number
273 --
274 Open C_Sel1;
275 Fetch C_Sel1 Into p_rec.iterative_rule_id;
276 Close C_Sel1;
277 --
278 --
279 hr_utility.set_location(' Leaving:'||l_proc, 10);
280 End pre_insert;
281 --
282 -- ----------------------------------------------------------------------------
283 -- |----------------------------< post_insert >-------------------------------|
284 -- ----------------------------------------------------------------------------
285 -- {Start Of Comments}
286 --
287 -- Description:
288 -- This private procedure contains any processing which is required after the
289 -- insert dml.
290 --
291 -- Prerequisites:
292 -- This is an internal procedure which is called from the ins procedure.
293 --
294 -- In Parameters:
295 -- A Pl/Sql record structure.
296 --
297 -- Post Success:
298 -- Processing continues.
299 --
300 -- Post Failure:
301 -- If an error has occurred, an error message and exception will be raised
302 -- but not handled.
303 --
304 -- Developer Implementation Notes:
305 -- Any post-processing required after the insert dml is issued should be
306 -- coded within this procedure. It is important to note that any 3rd party
307 -- maintenance should be reviewed before placing in this procedure.
308 --
309 -- Access Status:
310 -- Internal Row Handler Use Only.
311 --
312 -- {End Of Comments}
313 -- ----------------------------------------------------------------------------
314 Procedure post_insert
315 (p_rec in pay_itr_shd.g_rec_type
316 ,p_effective_date in date
317 ,p_datetrack_mode in varchar2
318 ,p_validation_start_date in date
319 ,p_validation_end_date in date
320 ) is
321 --
322 l_proc varchar2(72) := g_package||'post_insert';
323 --
324 Begin
325 hr_utility.set_location('Entering:'||l_proc, 5);
326 begin
327 --
328 pay_itr_rki.after_insert
329 (p_effective_date
330 => p_effective_date
331 ,p_validation_start_date
332 => p_validation_start_date
333 ,p_validation_end_date
334 => p_validation_end_date
335 ,p_iterative_rule_id
336 => p_rec.iterative_rule_id
337 ,p_element_type_id
338 => p_rec.element_type_id
339 ,p_effective_start_date
340 => p_rec.effective_start_date
341 ,p_effective_end_date
342 => p_rec.effective_end_date
343 ,p_result_name
347 ,p_input_value_id
344 => p_rec.result_name
345 ,p_iterative_rule_type
346 => p_rec.iterative_rule_type
348 => p_rec.input_value_id
349 ,p_severity_level
350 => p_rec.severity_level
351 ,p_business_group_id
352 => p_rec.business_group_id
353 ,p_legislation_code
354 => p_rec.legislation_code
355 ,p_object_version_number
356 => p_rec.object_version_number
357 );
358 --
359 exception
360 --
361 when hr_api.cannot_find_prog_unit then
362 --
363 hr_api.cannot_find_prog_unit_error
364 (p_module_name => 'PAY_ITERATIVE_RULES_F'
365 ,p_hook_type => 'AI');
366 --
367 end;
368 --
369 hr_utility.set_location(' Leaving:'||l_proc, 10);
370 End post_insert;
371 --
372 -- ----------------------------------------------------------------------------
373 -- |-------------------------------< ins_lck >--------------------------------|
374 -- ----------------------------------------------------------------------------
375 -- {Start Of Comments}
376 --
377 -- Description:
378 -- The ins_lck process has one main function to perform. When inserting
379 -- a datetracked row, we must validate the DT mode.
380 --
381 -- Prerequisites:
382 -- This procedure can only be called for the datetrack mode of INSERT.
383 --
384 -- In Parameters:
385 --
386 -- Post Success:
387 -- On successful completion of the ins_lck process the parental
388 -- datetracked rows will be locked providing the p_enforce_foreign_locking
389 -- argument value is TRUE.
390 -- If the p_enforce_foreign_locking argument value is FALSE then the
391 -- parential rows are not locked.
392 --
393 -- Post Failure:
394 -- The Lck process can fail for:
395 -- 1) When attempting to lock the row the row could already be locked by
396 -- another user. This will raise the HR_Api.Object_Locked exception.
397 -- 2) When attempting to the lock the parent which doesn't exist.
398 -- For the entity to be locked the parent must exist!
399 --
400 -- Developer Implementation Notes:
401 -- None.
402 --
403 -- Access Status:
404 -- Internal Row Handler Use Only.
405 --
406 -- {End Of Comments}
407 -- ----------------------------------------------------------------------------
408 Procedure ins_lck
409 (p_effective_date in date
410 ,p_datetrack_mode in varchar2
411 ,p_rec in pay_itr_shd.g_rec_type
412 ,p_validation_start_date out nocopy date
413 ,p_validation_end_date out nocopy date
414 ) is
415 --
416 l_proc varchar2(72) := g_package||'ins_lck';
417 l_validation_start_date date;
418 l_validation_end_date date;
419 --
420 Begin
421 hr_utility.set_location('Entering:'||l_proc, 5);
422 --
423 -- Validate the datetrack mode mode getting the validation start
424 -- and end dates for the specified datetrack operation.
425 --
426 dt_api.validate_dt_mode
427 (p_effective_date => p_effective_date
428 ,p_datetrack_mode => p_datetrack_mode
429 ,p_base_table_name => 'pay_iterative_rules_f'
430 ,p_base_key_column => 'iterative_rule_id'
431 ,p_base_key_value => p_rec.iterative_rule_id
432 ,p_enforce_foreign_locking => true
433 ,p_validation_start_date => l_validation_start_date
434 ,p_validation_end_date => l_validation_end_date
435 );
436 --
437 -- Set the validation start and end date OUT arguments
438 --
439 p_validation_start_date := l_validation_start_date;
440 p_validation_end_date := l_validation_end_date;
441 --
442 hr_utility.set_location(' Leaving:'||l_proc, 10);
443 --
444 End ins_lck;
445 --
446 -- ----------------------------------------------------------------------------
447 -- |---------------------------------< ins >----------------------------------|
448 -- ----------------------------------------------------------------------------
449 Procedure ins
450 (p_effective_date in date
451 ,p_rec in out nocopy pay_itr_shd.g_rec_type
452 ) is
453 --
454 l_proc varchar2(72) := g_package||'ins';
455 l_datetrack_mode varchar2(30) := hr_api.g_insert;
456 l_validation_start_date date;
457 l_validation_end_date date;
458 --
459 Begin
460 hr_utility.set_location('Entering:'||l_proc, 5);
461 --
462 -- Call the lock operation
463 --
464 pay_itr_ins.ins_lck
465 (p_effective_date => p_effective_date
466 ,p_datetrack_mode => l_datetrack_mode
467 ,p_rec => p_rec
468 ,p_validation_start_date => l_validation_start_date
469 ,p_validation_end_date => l_validation_end_date
470 );
471 --
472 -- Call the supporting insert validate operations
473 --
474 pay_itr_bus.insert_validate
475 (p_rec => p_rec
476 ,p_effective_date => p_effective_date
477 ,p_datetrack_mode => l_datetrack_mode
478 ,p_validation_start_date => l_validation_start_date
479 ,p_validation_end_date => l_validation_end_date
480 );
481 --
482 -- Call the supporting pre-insert operation
483 --
484 pay_itr_ins.pre_insert
485 (p_rec => p_rec
486 ,p_effective_date => p_effective_date
487 ,p_datetrack_mode => l_datetrack_mode
488 ,p_validation_start_date => l_validation_start_date
489 ,p_validation_end_date => l_validation_end_date
490 );
494 pay_itr_ins.insert_dml
491 --
492 -- Insert the row
493 --
495 (p_rec => p_rec
496 ,p_effective_date => p_effective_date
497 ,p_datetrack_mode => l_datetrack_mode
498 ,p_validation_start_date => l_validation_start_date
499 ,p_validation_end_date => l_validation_end_date
500 );
501 --
502 -- Call the supporting post-insert operation
503 --
504 pay_itr_ins.post_insert
505 (p_rec => p_rec
506 ,p_effective_date => p_effective_date
507 ,p_datetrack_mode => l_datetrack_mode
508 ,p_validation_start_date => l_validation_start_date
509 ,p_validation_end_date => l_validation_end_date
510 );
511 --
512 hr_utility.set_location('Leaving:'||l_proc,10);
513 end ins;
514 --
515 -- ----------------------------------------------------------------------------
516 -- |---------------------------------< ins >----------------------------------|
517 -- ----------------------------------------------------------------------------
518 Procedure ins
519 (p_effective_date in date
520 ,p_element_type_id in number
521 ,p_result_name in varchar2
522 ,p_iterative_rule_type in varchar2
523 ,p_input_value_id in number default null
524 ,p_severity_level in varchar2 default null
525 ,p_business_group_id in number default null
526 ,p_legislation_code in varchar2 default null
527 ,p_iterative_rule_id out nocopy number
528 ,p_object_version_number out nocopy number
529 ,p_effective_start_date out nocopy date
530 ,p_effective_end_date out nocopy date
531 ) is
532 --
533 l_rec pay_itr_shd.g_rec_type;
534 l_proc varchar2(72) := g_package||'ins';
535 --
536 Begin
537 hr_utility.set_location('Entering:'||l_proc, 5);
538 --
539 -- Call conversion function to turn arguments into the
540 -- p_rec structure.
541 --
542 l_rec :=
543 pay_itr_shd.convert_args
544 (null
545 ,p_element_type_id
546 ,null
547 ,null
548 ,p_result_name
549 ,p_iterative_rule_type
550 ,p_input_value_id
551 ,p_severity_level
552 ,p_business_group_id
553 ,p_legislation_code
554 ,null
555 );
556 --
557 -- Having converted the arguments into the pay_itr_rec
558 -- plsql record structure we call the corresponding record
559 -- business process.
560 --
561 pay_itr_ins.ins
562 (p_effective_date
563 ,l_rec
564 );
565 --
566 -- Set the OUT arguments.
567 --
568 p_iterative_rule_id := l_rec.iterative_rule_id;
569 p_effective_start_date := l_rec.effective_start_date;
570 p_effective_end_date := l_rec.effective_end_date;
571 p_object_version_number := l_rec.object_version_number;
572 --
573 --
574 hr_utility.set_location(' Leaving:'||l_proc, 10);
575 End ins;
576 --
577 end pay_itr_ins;