[Home] [Help]
PACKAGE BODY: APPS.IGF_AW_COA_ITEMS_PKG
Source
1 PACKAGE BODY igf_aw_coa_items_pkg AS
2 /* $Header: IGFWI57B.pls 120.0 2005/06/01 13:39:34 appldev noship $ */
3
4 l_rowid VARCHAR2(25);
5 old_references igf_aw_coa_items%ROWTYPE;
6 new_references igf_aw_coa_items%ROWTYPE;
7
8 PROCEDURE set_column_values (
9 p_action IN VARCHAR2,
10 x_rowid IN VARCHAR2,
11 x_base_id IN NUMBER,
12 x_item_code IN VARCHAR2,
13 x_amount IN NUMBER,
14 x_pell_coa_amount IN NUMBER,
15 x_alt_pell_amount IN NUMBER,
16 x_fixed_cost IN VARCHAR2,
17 x_legacy_record_flag IN VARCHAR2 ,
18 x_creation_date IN DATE,
19 x_created_by IN NUMBER,
20 x_last_update_date IN DATE,
21 x_last_updated_by IN NUMBER,
22 x_last_update_login IN NUMBER,
23 x_lock_flag IN VARCHAR2
24 ) AS
25 /*
26 || Created By : sjadhav
27 || Created On : 19-OCT-2002
28 || Purpose : Initialises the Old and New references for the columns of the table.
29 || Known limitations, enhancements or remarks :
30 || Change History :
31 || Who When What
32 || (reverse chronological order - newest change first)
33 */
34
35 CURSOR cur_old_ref_values IS
36 SELECT *
37 FROM igf_aw_coa_items
38 WHERE rowid = x_rowid;
39
40 BEGIN
41
42 l_rowid := x_rowid;
43
44 -- Code for setting the Old and New Reference Values.
45 -- Populate Old Values.
46 OPEN cur_old_ref_values;
47 FETCH cur_old_ref_values INTO old_references;
48 IF ((cur_old_ref_values%NOTFOUND) AND (p_action NOT IN ('INSERT', 'VALIDATE_INSERT'))) THEN
49 CLOSE cur_old_ref_values;
50 fnd_message.set_name ('FND', 'FORM_RECORD_DELETED');
51 igs_ge_msg_stack.add;
52 app_exception.raise_exception;
53 RETURN;
54 END IF;
55 CLOSE cur_old_ref_values;
56
57 -- Populate New Values.
58 new_references.base_id := x_base_id;
59 new_references.item_code := x_item_code;
60 new_references.amount := x_amount;
61 new_references.pell_coa_amount := x_pell_coa_amount;
62 new_references.alt_pell_amount := x_alt_pell_amount;
63 new_references.fixed_cost := x_fixed_cost;
64 new_references.legacy_record_flag := x_legacy_record_flag ;
65 new_references.lock_flag := x_lock_flag;
66
67 IF (p_action = 'UPDATE') THEN
68 new_references.creation_date := old_references.creation_date;
69 new_references.created_by := old_references.created_by;
70 ELSE
71 new_references.creation_date := x_creation_date;
72 new_references.created_by := x_created_by;
73 END IF;
74
75 new_references.last_update_date := x_last_update_date;
76 new_references.last_updated_by := x_last_updated_by;
77 new_references.last_update_login := x_last_update_login;
78
79 END set_column_values;
80
81
82 PROCEDURE check_parent_existance AS
83 /*
84 || Created By : sjadhav
85 || Created On : 19-OCT-2002
86 || Purpose : Checks for the existance of Parent records.
87 || Known limitations, enhancements or remarks :
88 || Change History :
89 || Who When What
90 || (reverse chronological order - newest change first)
91 */
92 BEGIN
93
94 IF (((old_references.base_id = new_references.base_id)) OR
95 ((new_references.base_id IS NULL))) THEN
96 NULL;
97 ELSIF NOT igf_ap_fa_base_rec_pkg.get_pk_for_validation (
98 new_references.base_id
99 ) THEN
100 fnd_message.set_name ('FND', 'FORM_RECORD_DELETED');
101 igs_ge_msg_stack.add;
102 app_exception.raise_exception;
103 END IF;
104
105 IF (((old_references.item_code = new_references.item_code)) OR
106 ((new_references.item_code IS NULL))) THEN
107 NULL;
108 ELSIF NOT igf_aw_item_pkg.get_pk_for_validation (
109 new_references.item_code
110 ) THEN
111 fnd_message.set_name ('FND', 'FORM_RECORD_DELETED');
112 igs_ge_msg_stack.add;
113 app_exception.raise_exception;
114 END IF;
115
116 END check_parent_existance;
117
118
119 PROCEDURE check_child_existance AS
120 /*
121 || Created By : sjadhav
122 || Created On : 19-OCT-2002
123 || Purpose : Checks for the existance of Child records.
124 || Known limitations, enhancements or remarks :
125 || Change History :
126 || Who When What
127 || (reverse chronological order - newest change first)
128 */
129 BEGIN
130
131 igf_aw_coa_itm_terms_pkg.get_fk_igf_aw_coa_items (
132 old_references.base_id,
133 old_references.item_code
134 );
135
136 END check_child_existance;
137
138
139 FUNCTION get_pk_for_validation (
140 x_base_id IN NUMBER,
141 x_item_code IN VARCHAR2
142 ) RETURN BOOLEAN AS
143 /*
144 || Created By : sjadhav
145 || Created On : 19-OCT-2002
146 || Purpose : Validates the Primary Key of the table.
147 || Known limitations, enhancements or remarks :
148 || Change History :
149 || Who When What
150 || (reverse chronological order - newest change first)
151 */
152 CURSOR cur_rowid IS
153 SELECT rowid
154 FROM igf_aw_coa_items
155 WHERE base_id = x_base_id
156 AND item_code = x_item_code
157 FOR UPDATE NOWAIT;
158
159 lv_rowid cur_rowid%RowType;
160
161 BEGIN
162
163 OPEN cur_rowid;
164 FETCH cur_rowid INTO lv_rowid;
165 IF (cur_rowid%FOUND) THEN
166 CLOSE cur_rowid;
167 RETURN(TRUE);
168 ELSE
169 CLOSE cur_rowid;
170 RETURN(FALSE);
171 END IF;
172
173 END get_pk_for_validation;
174
175
176 PROCEDURE get_fk_igf_ap_fa_base_rec (
177 x_base_id IN NUMBER
178 ) AS
179 /*
180 || Created By : sjadhav
181 || Created On : 19-OCT-2002
182 || Purpose : Validates the Foreign Keys for the table.
183 || Known limitations, enhancements or remarks :
184 || Change History :
185 || Who When What
186 || (reverse chronological order - newest change first)
187 */
188 CURSOR cur_rowid IS
189 SELECT rowid
190 FROM igf_aw_coa_items
191 WHERE ((base_id = x_base_id));
192
193 lv_rowid cur_rowid%RowType;
194
195 BEGIN
196
197 OPEN cur_rowid;
198 FETCH cur_rowid INTO lv_rowid;
199 IF (cur_rowid%FOUND) THEN
200 CLOSE cur_rowid;
201 fnd_message.set_name ('IGF', 'IGF_AW_COAI_FABASE_FK');
202 igs_ge_msg_stack.add;
203 app_exception.raise_exception;
204 RETURN;
205 END IF;
206 CLOSE cur_rowid;
207
208 END get_fk_igf_ap_fa_base_rec;
209
210
211 PROCEDURE get_fk_igf_aw_item (
212 x_item_code IN VARCHAR2
213 ) AS
214 /*
215 || Created By : sjadhav
216 || Created On : 19-OCT-2002
217 || Purpose : Validates the Foreign Keys for the table.
218 || Known limitations, enhancements or remarks :
219 || Change History :
220 || Who When What
221 || (reverse chronological order - newest change first)
222 */
223 CURSOR cur_rowid IS
224 SELECT rowid
225 FROM igf_aw_coa_items
226 WHERE ((item_code = x_item_code));
227
228 lv_rowid cur_rowid%RowType;
229
230 BEGIN
231
232 OPEN cur_rowid;
233 FETCH cur_rowid INTO lv_rowid;
234 IF (cur_rowid%FOUND) THEN
235 CLOSE cur_rowid;
236 fnd_message.set_name ('IGF', 'IGF_AW_COAI_AWITEM_FK');
237 igs_ge_msg_stack.add;
238 app_exception.raise_exception;
239 RETURN;
240 END IF;
241 CLOSE cur_rowid;
242
243 END get_fk_igf_aw_item;
244
245
246 PROCEDURE before_dml (
247 p_action IN VARCHAR2,
248 x_rowid IN VARCHAR2,
249 x_base_id IN NUMBER,
250 x_item_code IN VARCHAR2,
251 x_amount IN NUMBER,
252 x_pell_coa_amount IN NUMBER,
253 x_alt_pell_amount IN NUMBER,
254 x_fixed_cost IN VARCHAR2,
255 x_legacy_record_flag IN VARCHAR2,
256 x_creation_date IN DATE,
257 x_created_by IN NUMBER,
258 x_last_update_date IN DATE,
259 x_last_updated_by IN NUMBER,
260 x_last_update_login IN NUMBER,
261 x_lock_flag IN VARCHAR2
262 ) AS
263 /*
264 || Created By : sjadhav
265 || Created On : 19-OCT-2002
266 || Purpose : Initialises the columns, Checks Constraints, Calls the
267 || Trigger Handlers for the table, before any DML operation.
268 || Known limitations, enhancements or remarks :
269 || Change History :
270 || Who When What
271 || (reverse chronological order - newest change first)
272 */
273 BEGIN
274
275 set_column_values (
276 p_action,
277 x_rowid,
278 x_base_id,
279 x_item_code,
280 x_amount,
281 x_pell_coa_amount,
282 x_alt_pell_amount,
283 x_fixed_cost,
284 x_legacy_record_flag ,
285 x_creation_date,
286 x_created_by,
287 x_last_update_date,
288 x_last_updated_by,
289 x_last_update_login,
290 x_lock_flag
291 );
292
293 IF (p_action = 'INSERT') THEN
294 -- Call all the procedures related to Before Insert.
295 IF ( get_pk_for_validation(
296 new_references.base_id,
297 new_references.item_code
298 )
299 ) THEN
300 fnd_message.set_name('IGS','IGS_GE_RECORD_ALREADY_EXISTS');
301 igs_ge_msg_stack.add;
302 app_exception.raise_exception;
303 END IF;
304 check_parent_existance;
305 ELSIF (p_action = 'UPDATE') THEN
306 -- Call all the procedures related to Before Update.
307 check_parent_existance;
308 ELSIF (p_action = 'DELETE') THEN
309 -- Call all the procedures related to Before Delete.
310 check_child_existance;
311 ELSIF (p_action = 'VALIDATE_INSERT') THEN
312 -- Call all the procedures related to Before Insert.
313 IF ( get_pk_for_validation (
314 new_references.base_id,
315 new_references.item_code
316 )
317 ) THEN
318 fnd_message.set_name('IGS','IGS_GE_RECORD_ALREADY_EXISTS');
319 igs_ge_msg_stack.add;
320 app_exception.raise_exception;
321 END IF;
322 ELSIF (p_action = 'VALIDATE_DELETE') THEN
323 check_child_existance;
324 END IF;
325
326 END before_dml;
327
328
329 PROCEDURE insert_row (
330 x_rowid IN OUT NOCOPY VARCHAR2,
331 x_base_id IN NUMBER,
332 x_item_code IN VARCHAR2,
333 x_amount IN NUMBER,
334 x_pell_coa_amount IN NUMBER,
335 x_alt_pell_amount IN NUMBER,
336 x_fixed_cost IN VARCHAR2,
337 x_legacy_record_flag IN VARCHAR2,
338 x_mode IN VARCHAR2,
339 x_lock_flag IN VARCHAR2
340 ) AS
341 /*
342 || Created By : sjadhav
343 || Created On : 19-OCT-2002
344 || Purpose : Handles the INSERT DML logic for the table.
345 || Known limitations, enhancements or remarks :
346 || Change History :
347 || Who When What
348 || (reverse chronological order - newest change first)
349 */
350
351 x_last_update_date DATE;
352 x_last_updated_by NUMBER;
353 x_last_update_login NUMBER;
354 x_request_id NUMBER;
355 x_program_id NUMBER;
356 x_program_application_id NUMBER;
357 x_program_update_date DATE;
358
359 BEGIN
360
361 x_last_update_date := SYSDATE;
362 IF (x_mode = 'I') THEN
363 x_last_updated_by := 1;
364 x_last_update_login := 0;
365 ELSIF (x_mode = 'R') THEN
366 x_last_updated_by := fnd_global.user_id;
367 IF (x_last_updated_by IS NULL) THEN
368 x_last_updated_by := -1;
369 END IF;
370 x_last_update_login := fnd_global.login_id;
371 IF (x_last_update_login IS NULL) THEN
372 x_last_update_login := -1;
373 END IF;
374 x_request_id := fnd_global.conc_request_id;
375 x_program_id := fnd_global.conc_program_id;
376 x_program_application_id := fnd_global.prog_appl_id;
377
378 IF (x_request_id = -1) THEN
379 x_request_id := NULL;
380 x_program_id := NULL;
381 x_program_application_id := NULL;
382 x_program_update_date := NULL;
383 ELSE
384 x_program_update_date := SYSDATE;
385 END IF;
386 ELSE
387 fnd_message.set_name ('FND', 'SYSTEM-INVALID ARGS');
388 igs_ge_msg_stack.add;
389 app_exception.raise_exception;
390 END IF;
391
392 before_dml(
393 p_action => 'INSERT',
394 x_rowid => x_rowid,
395 x_base_id => x_base_id,
396 x_item_code => x_item_code,
397 x_amount => x_amount,
398 x_pell_coa_amount => x_pell_coa_amount,
399 x_alt_pell_amount => x_alt_pell_amount,
400 x_fixed_cost => x_fixed_cost,
401 x_legacy_record_flag => x_legacy_record_flag,
402 x_creation_date => x_last_update_date,
403 x_created_by => x_last_updated_by,
404 x_last_update_date => x_last_update_date,
405 x_last_updated_by => x_last_updated_by,
406 x_last_update_login => x_last_update_login,
407 x_lock_flag => x_lock_flag
408 );
409
410 INSERT INTO igf_aw_coa_items (
411 base_id,
412 item_code,
413 amount,
414 pell_coa_amount,
415 alt_pell_amount,
416 fixed_cost,
417 legacy_record_flag,
418 creation_date,
419 created_by,
420 last_update_date,
421 last_updated_by,
422 last_update_login,
423 request_id,
424 program_id,
425 program_application_id,
426 program_update_date,
427 lock_flag
428 ) VALUES (
429 new_references.base_id,
430 new_references.item_code,
431 new_references.amount,
432 new_references.pell_coa_amount,
433 new_references.alt_pell_amount,
434 new_references.fixed_cost,
435 new_references.legacy_record_flag,
436 x_last_update_date,
437 x_last_updated_by,
438 x_last_update_date,
439 x_last_updated_by,
440 x_last_update_login ,
441 x_request_id,
442 x_program_id,
443 x_program_application_id,
444 x_program_update_date,
445 new_references.lock_flag
446 ) RETURNING ROWID INTO x_rowid;
447
448 END insert_row;
449
450
451 PROCEDURE lock_row (
452 x_rowid IN VARCHAR2,
453 x_base_id IN NUMBER,
454 x_item_code IN VARCHAR2,
455 x_amount IN NUMBER,
456 x_pell_coa_amount IN NUMBER,
457 x_alt_pell_amount IN NUMBER,
458 x_fixed_cost IN VARCHAR2,
459 x_legacy_record_flag IN VARCHAR2,
460 x_lock_flag IN VARCHAR2
461 ) AS
462 /*
463 || Created By : sjadhav
464 || Created On : 19-OCT-2002
465 || Purpose : Handles the LOCK mechanism for the table.
466 || Known limitations, enhancements or remarks :
467 || Change History :
468 || Who When What
469 || (reverse chronological order - newest change first)
470 */
471 CURSOR c1 IS
472 SELECT
473 amount,
474 pell_coa_amount,
475 alt_pell_amount,
476 fixed_cost,
477 legacy_record_flag,
478 lock_flag
479 FROM igf_aw_coa_items
480 WHERE rowid = x_rowid
481 FOR UPDATE NOWAIT;
482
483 tlinfo c1%ROWTYPE;
484
485 BEGIN
486
487 OPEN c1;
488 FETCH c1 INTO tlinfo;
489 IF (c1%notfound) THEN
490 fnd_message.set_name('FND', 'FORM_RECORD_DELETED');
491 igs_ge_msg_stack.add;
492 CLOSE c1;
493 app_exception.raise_exception;
494 RETURN;
495 END IF;
496 CLOSE c1;
497
498 IF (
499 (tlinfo.amount = x_amount)
500 AND ((tlinfo.pell_coa_amount = x_pell_coa_amount) OR ((tlinfo.pell_coa_amount IS NULL) AND (X_pell_coa_amount IS NULL)))
501 AND ((tlinfo.alt_pell_amount = x_alt_pell_amount) OR ((tlinfo.alt_pell_amount IS NULL) AND (X_alt_pell_amount IS NULL)))
502 AND ((tlinfo.fixed_cost = x_fixed_cost) OR ((tlinfo.fixed_cost IS NULL) AND (X_fixed_cost IS NULL)))
503 AND ((tlinfo.legacy_record_flag = x_legacy_record_flag) OR ((tlinfo.legacy_record_flag IS NULL) AND (x_legacy_record_flag IS NULL)))
504 AND ((tlinfo.lock_flag = x_lock_flag) OR ((tlinfo.lock_flag IS NULL) AND (x_lock_flag IS NULL)))
505
506 ) THEN
507 NULL;
508 ELSE
509 fnd_message.set_name('FND', 'FORM_RECORD_CHANGED');
510 igs_ge_msg_stack.add;
511 app_exception.raise_exception;
512 END IF;
513
514 RETURN;
515
516 END lock_row;
517
518
519 PROCEDURE update_row (
520 x_rowid IN VARCHAR2,
521 x_base_id IN NUMBER,
522 x_item_code IN VARCHAR2,
523 x_amount IN NUMBER,
524 x_pell_coa_amount IN NUMBER,
525 x_alt_pell_amount IN NUMBER,
526 x_fixed_cost IN VARCHAR2,
527 x_legacy_record_flag IN VARCHAR2,
528 x_mode IN VARCHAR2,
529 x_lock_flag IN VARCHAR2
530 ) AS
531 /*
532 || Created By : sjadhav
533 || Created On : 19-OCT-2002
534 || Purpose : Handles the UPDATE DML logic for the table.
535 || Known limitations, enhancements or remarks :
536 || Change History :
537 || Who When What
538 || (reverse chronological order - newest change first)
539 */
540 x_last_update_date DATE ;
541 x_last_updated_by NUMBER;
542 x_last_update_login NUMBER;
543 x_request_id NUMBER;
544 x_program_id NUMBER;
545 x_program_application_id NUMBER;
546 x_program_update_date DATE;
547
548 BEGIN
549
550 x_last_update_date := SYSDATE;
551 IF (X_MODE = 'I') THEN
552 x_last_updated_by := 1;
553 x_last_update_login := 0;
554 ELSIF (x_mode = 'R') THEN
555 x_last_updated_by := fnd_global.user_id;
556 IF x_last_updated_by IS NULL THEN
557 x_last_updated_by := -1;
558 END IF;
559 x_last_update_login := fnd_global.login_id;
560 IF (x_last_update_login IS NULL) THEN
561 x_last_update_login := -1;
562 END IF;
563 ELSE
564 fnd_message.set_name( 'FND', 'SYSTEM-INVALID ARGS');
565 igs_ge_msg_stack.add;
566 app_exception.raise_exception;
567 END IF;
568
569 before_dml(
570 p_action => 'UPDATE',
571 x_rowid => x_rowid,
572 x_base_id => x_base_id,
573 x_item_code => x_item_code,
574 x_amount => x_amount,
575 x_pell_coa_amount => x_pell_coa_amount,
576 x_alt_pell_amount => x_alt_pell_amount,
577 x_fixed_cost => x_fixed_cost,
578 x_legacy_record_flag => x_legacy_record_flag ,
579 x_creation_date => x_last_update_date,
580 x_created_by => x_last_updated_by,
581 x_last_update_date => x_last_update_date,
582 x_last_updated_by => x_last_updated_by,
583 x_last_update_login => x_last_update_login,
584 x_lock_flag => x_lock_flag
585 );
586
587 IF (x_mode = 'R') THEN
588 x_request_id := fnd_global.conc_request_id;
589 x_program_id := fnd_global.conc_program_id;
590 x_program_application_id := fnd_global.prog_appl_id;
591 IF (x_request_id = -1) THEN
592 x_request_id := old_references.request_id;
593 x_program_id := old_references.program_id;
594 x_program_application_id := old_references.program_application_id;
595 x_program_update_date := old_references.program_update_date;
596 ELSE
597 x_program_update_date := SYSDATE;
598 END IF;
599 END IF;
600
601 UPDATE igf_aw_coa_items
602 SET
603 amount = new_references.amount,
604 pell_coa_amount = new_references.pell_coa_amount,
605 alt_pell_amount = new_references.alt_pell_amount,
606 fixed_cost = new_references.fixed_cost,
607 legacy_record_flag = new_references.legacy_record_flag,
608 last_update_date = x_last_update_date,
609 last_updated_by = x_last_updated_by,
610 last_update_login = x_last_update_login ,
611 request_id = x_request_id,
612 program_id = x_program_id,
613 program_application_id = x_program_application_id,
614 program_update_date = x_program_update_date,
615 lock_flag = new_references.lock_flag
616 WHERE rowid = x_rowid;
617
618 IF (SQL%NOTFOUND) THEN
619 RAISE NO_DATA_FOUND;
620 END IF;
621
622 END update_row;
623
624
625 PROCEDURE add_row (
626 x_rowid IN OUT NOCOPY VARCHAR2,
627 x_base_id IN NUMBER,
628 x_item_code IN VARCHAR2,
629 x_amount IN NUMBER,
630 x_pell_coa_amount IN NUMBER,
631 x_alt_pell_amount IN NUMBER,
632 x_fixed_cost IN VARCHAR2,
633 x_legacy_record_flag IN VARCHAR2,
634 x_mode IN VARCHAR2,
635 x_lock_flag IN VARCHAR2
636 ) AS
637 /*
638 || Created By : sjadhav
639 || Created On : 19-OCT-2002
640 || Purpose : Adds a row if there is no existing row, otherwise updates existing row in the table.
641 || Known limitations, enhancements or remarks :
642 || Change History :
643 || Who When What
644 || (reverse chronological order - newest change first)
645 */
646 CURSOR c1 IS
647 SELECT rowid
648 FROM igf_aw_coa_items
649 WHERE base_id = x_base_id
650 AND item_code = x_item_code;
651
652 BEGIN
653
654 OPEN c1;
655 FETCH c1 INTO x_rowid;
656 IF (c1%NOTFOUND) THEN
657 CLOSE c1;
658
659 insert_row (
660 x_rowid,
661 x_base_id,
662 x_item_code,
663 x_amount,
664 x_pell_coa_amount,
665 x_alt_pell_amount,
666 x_fixed_cost,
667 x_legacy_record_flag,
668 x_mode,
669 x_lock_flag
670 );
671 RETURN;
672 END IF;
673 CLOSE c1;
674
675 update_row (
676 x_rowid,
677 x_base_id,
678 x_item_code,
679 x_amount,
680 x_pell_coa_amount,
681 x_alt_pell_amount,
682 x_fixed_cost,
683 x_legacy_record_flag ,
684 x_mode,
685 x_lock_flag
686 );
687
688 END add_row;
689
690
691 PROCEDURE delete_row (
692 x_rowid IN VARCHAR2
693 ) AS
694 /*
695 || Created By : sjadhav
696 || Created On : 19-OCT-2002
697 || Purpose : Handles the DELETE DML logic for the table.
698 || Known limitations, enhancements or remarks :
699 || Change History :
700 || Who When What
701 || (reverse chronological order - newest change first)
702 */
703 BEGIN
704
705 before_dml (
706 p_action => 'DELETE',
707 x_rowid => x_rowid
708 );
709
710 DELETE FROM igf_aw_coa_items
711 WHERE rowid = x_rowid;
712
713 IF (SQL%NOTFOUND) THEN
714 RAISE NO_DATA_FOUND;
715 END IF;
716
717 END delete_row;
718
719
720 END igf_aw_coa_items_pkg;