1: PACKAGE BODY arp_auto_rule AS
2: /* $Header: ARPLARLB.pls 120.57 2012/06/18 10:33:05 naneja ship $ */
3: PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'Y');
4:
5: cr CONSTANT char(1) := '
83:
84: FUNCTION assign_glp_index RETURN NUMBER IS
85: error_message FND_NEW_MESSAGES.MESSAGE_TEXT%TYPE; -- bug 4194220
86: BEGIN
87: arp_standard.debug('arp_auto_rule.assign_glp_index()+ ' ||
88: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
89:
90: /* Set glp_index_start to the period having MIN GL date for the trx. */
91:
140: END IF;
141: END LOOP;
142:
143: RETURN 0;
144: arp_standard.debug('arp_auto_rule.assign_glp_index()- ' ||
145: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
146:
147: END assign_glp_index;
148:
169: +-------------------------------------------------------------------------*/
170: PROCEDURE assign_glp_rec IS
171:
172: BEGIN
173: arp_standard.debug('arp_auto_rule.assign_glp_rec()+ ' ||
174: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
175:
176: /* Set glp_index_rec to the period having REC record's gl date */
177:
187: END LOOP;
188:
189: arp_standard.debug('glp table index rec = '||glp_index_rec);
190:
191: arp_standard.debug('arp_auto_rule.assign_glp_rec()- ' ||
192: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
193:
194: END assign_glp_rec;
195:
257: last_good_date DATE;
258:
259: BEGIN
260: IF PG_DEBUG in ('Y', 'C') THEN
261: arp_standard.debug('arp_auto_rule.populate_glp_table()+ ' ||
262: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
263: arp_standard.debug('Populating gl_period_statuses table.');
264: END IF;
265:
313:
314: END IF; /* end of call-once case */
315:
316: IF PG_DEBUG in ('Y', 'C') THEN
317: arp_standard.debug('arp_auto_rule.populate_glp_table()- ');
318: END IF;
319:
320: END populate_glp_table;
321:
349: Retcode OUT NOCOPY VARCHAR2) IS
350: BEGIN
351:
352: IF PG_DEBUG in ('Y', 'C') THEN
353: arp_standard.debug( 'arp_auto_rule.refresh()+ ' ||
354: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
355: END IF;
356:
357: SAVEPOINT AR_PERIODS_1;
501: );
502:
503: IF PG_DEBUG in ('Y', 'C') THEN
504: arp_standard.debug('row(s) updated: ' || TO_CHAR(sql%rowcount));
505: arp_standard.debug( 'arp_auto_rule.refresh()- ' ||
506: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
507: END IF;
508:
509: EXCEPTION
509: EXCEPTION
510: WHEN OTHERS THEN
511:
512: IF PG_DEBUG in ('Y', 'C') THEN
513: arp_standard.debug('Exception occured in: arp_auto_rule.refresh()');
514: END IF;
515:
516: ROLLBACK TO SAVEPOINT AR_PERIODS_1;
517: RAISE;
730: l_need_rev_rec VARCHAR2(1);
731: BEGIN
732:
733: IF PG_DEBUG in ('Y', 'C') THEN
734: arp_standard.debug( 'arp_auto_rule.create_assignments()+ ' ||
735: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
736: END IF;
737:
738: SELECT
1058:
1059: EXCEPTION
1060: WHEN OTHERS THEN
1061: IF PG_DEBUG in ('Y', 'C') THEN
1062: arp_standard.debug('EXCEPTION: arp_auto_rule.create_assignments() - rule_end_date');
1063: arp_standard.debug(SQLERRM);
1064: arp_standard.debug( 'arp_auto_rule.create_assignments()- ' ||
1065: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
1066: END IF;
1060: WHEN OTHERS THEN
1061: IF PG_DEBUG in ('Y', 'C') THEN
1062: arp_standard.debug('EXCEPTION: arp_auto_rule.create_assignments() - rule_end_date');
1063: arp_standard.debug(SQLERRM);
1064: arp_standard.debug( 'arp_auto_rule.create_assignments()- ' ||
1065: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
1066: END IF;
1067:
1068: return -2; --fail and reset indexes
1283:
1284: IF PG_DEBUG in ('Y', 'C') THEN
1285: arp_standard.debug('Revenue lines inserted total: ' ||
1286: l_rows);
1287: arp_standard.debug('arp_auto_rule.create_assignments()- ' ||
1288: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
1289: END IF;
1290:
1291: RETURN( l_rows);
1293: EXCEPTION
1294: WHEN OTHERS THEN
1295:
1296: IF PG_DEBUG in ('Y', 'C') THEN
1297: arp_standard.debug('EXCEPTION: arp_auto_rule.create_assignments()');
1298: arp_standard.debug(SQLERRM);
1299: arp_standard.debug( 'arp_auto_rule.create_assignments()- ' ||
1300: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
1301: END IF;
1295:
1296: IF PG_DEBUG in ('Y', 'C') THEN
1297: arp_standard.debug('EXCEPTION: arp_auto_rule.create_assignments()');
1298: arp_standard.debug(SQLERRM);
1299: arp_standard.debug( 'arp_auto_rule.create_assignments()- ' ||
1300: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
1301: END IF;
1302:
1303: RETURN( -1 );
1357:
1358: BEGIN
1359:
1360: IF PG_DEBUG in ('Y', 'C') THEN
1361: arp_standard.debug( 'arp_auto_rule.create_other_receivable()+ ' ||
1362: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
1363: END IF;
1364:
1365: INSERT INTO ra_cust_trx_line_gl_dist /* REC line */
1482:
1483: /* bug 1947192 */
1484: FOR i IN c_update_ps(p_trx_id) LOOP
1485: IF PG_DEBUG in ('Y', 'C') THEN
1486: arp_standard.debug('arp_auto_rule.create_other_receivable(): Change Payment Schedule Gl Date');
1487: END IF;
1488: UPDATE ar_payment_schedules
1489: SET gl_date = i.gl_date ,
1490: last_updated_by = arp_standard.profile.user_id,
1492: WHERE payment_schedule_id = i.ps_id;
1493: END LOOP;
1494:
1495: IF PG_DEBUG in ('Y', 'C') THEN
1496: arp_standard.debug( 'arp_auto_rule.create_other_receivable()- ' ||
1497: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
1498: END IF;
1499:
1500: RETURN( l_rows );
1502: EXCEPTION
1503: WHEN OTHERS THEN
1504:
1505: IF PG_DEBUG in ('Y', 'C') THEN
1506: arp_standard.debug( 'EXCEPTION: arp_auto_rule.create_other_receivable()');
1507: arp_standard.debug( SQLERRM);
1508: arp_standard.debug( 'arp_auto_rule.create_other_receivable()- ' ||
1509: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
1510: END IF;
1504:
1505: IF PG_DEBUG in ('Y', 'C') THEN
1506: arp_standard.debug( 'EXCEPTION: arp_auto_rule.create_other_receivable()');
1507: arp_standard.debug( SQLERRM);
1508: arp_standard.debug( 'arp_auto_rule.create_other_receivable()- ' ||
1509: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
1510: END IF;
1511:
1512: RETURN( -1 );
1558:
1559: BEGIN
1560:
1561: IF PG_DEBUG in ('Y', 'C') THEN
1562: arp_standard.debug( 'arp_auto_rule.create_round()+ ' ||
1563: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
1564: END IF;
1565:
1566:
1641:
1642: IF PG_DEBUG in ('Y', 'C') THEN
1643: arp_standard.debug( 'ROUND lines inserted: ' ||
1644: l_rows);
1645: arp_standard.debug( 'arp_auto_rule.create_round()- ' ||
1646: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
1647: END IF;
1648:
1649: RETURN( l_rows);
1651: EXCEPTION
1652: WHEN OTHERS THEN
1653:
1654: IF PG_DEBUG in ('Y', 'C') THEN
1655: arp_standard.debug( 'EXCEPTION: arp_auto_rule.create_round()');
1656: arp_standard.debug( SQLERRM);
1657: arp_standard.debug( 'arp_auto_rule.create_round()- ' ||
1658: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
1659: END IF;
1653:
1654: IF PG_DEBUG in ('Y', 'C') THEN
1655: arp_standard.debug( 'EXCEPTION: arp_auto_rule.create_round()');
1656: arp_standard.debug( SQLERRM);
1657: arp_standard.debug( 'arp_auto_rule.create_round()- ' ||
1658: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
1659: END IF;
1660:
1661: RETURN( -1 );
1736:
1737: BEGIN
1738:
1739: IF PG_DEBUG in ('Y', 'C') THEN
1740: arp_standard.debug( 'arp_auto_rule.create_other_plug()+ ' ||
1741: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
1742: arp_standard.debug(' use_inv_acctg = ' || g_use_inv_acctg);
1743: END IF;
1744:
2165:
2166: IF PG_DEBUG in ('Y', 'C') THEN
2167: arp_standard.debug( 'Other plug lines inserted: ' ||
2168: l_rows);
2169: arp_standard.debug( 'arp_auto_rule.create_other_plug()- ' ||
2170: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2171: END IF;
2172:
2173: /*Bug 5450534 FP of bug 5260489*/
2201:
2202: EXCEPTION
2203: WHEN NO_ROF_EXCEPTION THEN
2204: IF PG_DEBUG in ('Y', 'C') THEN
2205: arp_standard.debug( 'EXCEPTION: arp_auto_rule.create_other_plug()');
2206: arp_standard.debug( 'set_rec_offset_flag unable to set flag properly');
2207: arp_standard.debug( 'arp_auto_rule.create_other_plug()- ' ||
2208: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2209: END IF;
2203: WHEN NO_ROF_EXCEPTION THEN
2204: IF PG_DEBUG in ('Y', 'C') THEN
2205: arp_standard.debug( 'EXCEPTION: arp_auto_rule.create_other_plug()');
2206: arp_standard.debug( 'set_rec_offset_flag unable to set flag properly');
2207: arp_standard.debug( 'arp_auto_rule.create_other_plug()- ' ||
2208: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2209: END IF;
2210: RETURN( -1 );
2211: WHEN OTHERS THEN
2210: RETURN( -1 );
2211: WHEN OTHERS THEN
2212:
2213: IF PG_DEBUG in ('Y', 'C') THEN
2214: arp_standard.debug( 'EXCEPTION: arp_auto_rule.create_other_plug()');
2215: arp_standard.debug( SQLERRM);
2216: arp_standard.debug( 'arp_auto_rule.create_other_plug()- ' ||
2217: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2218: END IF;
2212:
2213: IF PG_DEBUG in ('Y', 'C') THEN
2214: arp_standard.debug( 'EXCEPTION: arp_auto_rule.create_other_plug()');
2215: arp_standard.debug( SQLERRM);
2216: arp_standard.debug( 'arp_auto_rule.create_other_plug()- ' ||
2217: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2218: END IF;
2219:
2220: RETURN( -1 );
2258:
2259: BEGIN
2260:
2261: IF PG_DEBUG in ('Y', 'C') THEN
2262: arp_standard.debug( 'arp_auto_rule.create_other_tax()+ ' ||
2263: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2264: END IF;
2265:
2266: /* 7131147 - ignore autorule_complete_flag on an
2414:
2415: IF PG_DEBUG in ('Y', 'C') THEN
2416: arp_standard.debug( 'Tax lines inserted: ' ||
2417: l_rows);
2418: arp_standard.debug( 'arp_auto_rule.create_other_tax()- ' ||
2419: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2420: END IF;
2421:
2422: RETURN( l_rows );
2424: EXCEPTION
2425: WHEN OTHERS THEN
2426:
2427: IF PG_DEBUG in ('Y', 'C') THEN
2428: arp_standard.debug( 'EXCEPTION: arp_auto_rule.create_other_tax()');
2429: arp_standard.debug( SQLERRM);
2430: arp_standard.debug( 'arp_auto_rule.create_other_tax()- ' ||
2431: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2432: END IF;
2426:
2427: IF PG_DEBUG in ('Y', 'C') THEN
2428: arp_standard.debug( 'EXCEPTION: arp_auto_rule.create_other_tax()');
2429: arp_standard.debug( SQLERRM);
2430: arp_standard.debug( 'arp_auto_rule.create_other_tax()- ' ||
2431: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2432: END IF;
2433:
2434: RETURN( -1 );
2470:
2471: BEGIN
2472:
2473: IF PG_DEBUG in ('Y', 'C') THEN
2474: arp_standard.debug( 'arp_auto_rule.create_other_freight()+ ' ||
2475: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2476: END IF;
2477:
2478: INSERT INTO ra_cust_trx_line_gl_dist /* FREIGHT Lines */
2616:
2617: IF PG_DEBUG in ('Y', 'C') THEN
2618: arp_standard.debug( 'Freight lines inserted: ' ||
2619: l_rows);
2620: arp_standard.debug( 'arp_auto_rule.create_other_freight()- ' ||
2621: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2622: END IF;
2623:
2624: RETURN( l_rows );
2626: EXCEPTION
2627: WHEN OTHERS THEN
2628:
2629: IF PG_DEBUG in ('Y', 'C') THEN
2630: arp_standard.debug( 'EXCEPTION: arp_auto_rule.create_other_freight()');
2631: arp_standard.debug( SQLERRM);
2632: arp_standard.debug( 'arp_auto_rule.create_other_freight()- ' ||
2633: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2634: END IF;
2628:
2629: IF PG_DEBUG in ('Y', 'C') THEN
2630: arp_standard.debug( 'EXCEPTION: arp_auto_rule.create_other_freight()');
2631: arp_standard.debug( SQLERRM);
2632: arp_standard.debug( 'arp_auto_rule.create_other_freight()- ' ||
2633: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2634: END IF;
2635:
2636: RETURN( -1 );
2686:
2687: BEGIN
2688: IF PG_DEBUG in ('Y', 'C') THEN
2689:
2690: arp_standard.debug( 'arp_auto_rule.update_durations()+ ' ||
2691: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2692: END IF;
2693:
2694: /* This statement needs to update the autorule_complete_flag
2774: IF (PG_DEBUG = 'Y') THEN
2775: arp_standard.debug(' rows updated: ' ||
2776: l_rows);
2777:
2778: arp_standard.debug( 'arp_auto_rule.update_durations()- ' ||
2779: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS' || cr));
2780: END IF;
2781:
2782: RETURN( l_rows );
2783:
2784: EXCEPTION
2785: WHEN OTHERS THEN
2786:
2787: arp_standard.debug('EXCEPTION: arp_auto_rule.update_durations()');
2788: arp_standard.debug(SQLERRM);
2789: arp_standard.debug( 'arp_auto_rule.update_durations()- ' ||
2790: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2791:
2785: WHEN OTHERS THEN
2786:
2787: arp_standard.debug('EXCEPTION: arp_auto_rule.update_durations()');
2788: arp_standard.debug(SQLERRM);
2789: arp_standard.debug( 'arp_auto_rule.update_durations()- ' ||
2790: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2791:
2792: RETURN( -1 );
2793:
2965: arp_standard.enable_debug;
2966: END IF;
2967:
2968: IF PG_DEBUG in ('Y', 'C') THEN
2969: arp_standard.debug( 'arp_auto_rule.create_distributions()+ ' ||
2970: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
2971: arp_standard.debug( 'debug = '|| p_debug ||', commit = ' || p_commit);
2972: arp_standard.debug( 'round = ' || p_suppress_round || ', continue on error = ' ||
2973: p_continue_on_error);
3497: END IF;
3498: END IF;
3499:
3500: IF PG_DEBUG in ('Y', 'C') THEN
3501: arp_standard.debug( 'arp_auto_rule.create_distributions()- ' ||
3502: TO_CHAR(sysdate, 'DD-MON-YY HH:MI:SS'));
3503: END IF;
3504:
3505: RETURN( NVL(sum_dist_created, 0) );
3550: WHEN OTHERS THEN
3551: g_autoinv := FALSE;
3552: END;
3553:
3554: END ARP_AUTO_RULE;