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