36:
37: BEGIN
38:
39: if (g_log_level_rec.statement_level) then
40: fa_debug_pkg.add(l_calling_fn
41: ,'Calling FND_FLEX_EXT.Get_segments'
42: ,p_coa_id
43: ,p_log_level_rec => g_log_level_rec);
44: end if;
51: ,l_num_of_segments
52: ,l_base_segments);
53:
54: if (g_log_level_rec.statement_level) then
55: fa_debug_pkg.add(l_calling_fn
56: ,'Segment Number'
57: ,l_base_segments(P_segment_num)
58: ,p_log_level_rec => g_log_level_rec);
59: end if;
105: where set_of_books_id = p_ledger_id
106: and book_class = 'CORPORATE';
107:
108: if (g_log_level_rec.statement_level) then
109: fa_debug_pkg.add(l_calling_fn
110: ,'number of book for this ledger'
111: ,to_char(l_count)
112: ,p_log_level_rec => g_log_level_rec);
113:
110: ,'number of book for this ledger'
111: ,to_char(l_count)
112: ,p_log_level_rec => g_log_level_rec);
113:
114: fa_debug_pkg.add(l_calling_fn
115: ,'inserting'
116: ,'category accounts into GT'
117: ,p_log_level_rec => g_log_level_rec);
118: end if;
190:
191:
192: l_count := SQL%ROWCOUNT;
193: if (g_log_level_rec.statement_level) then
194: fa_debug_pkg.add(l_calling_fn
195: ,'No of Records Inserted '
196: ,to_char(l_count)
197: ,p_log_level_rec => g_log_level_rec);
198: fa_debug_pkg.add(l_calling_fn
194: fa_debug_pkg.add(l_calling_fn
195: ,'No of Records Inserted '
196: ,to_char(l_count)
197: ,p_log_level_rec => g_log_level_rec);
198: fa_debug_pkg.add(l_calling_fn
199: ,'Deleting duplicate rows from '
200: ,'fa_category_accounts_gt'
201: ,p_log_level_rec => g_log_level_rec);
202: end if;
216:
217: l_count := SQL%ROWCOUNT;
218:
219: if (g_log_level_rec.statement_level) then
220: fa_debug_pkg.add(l_calling_fn
221: ,'No of Records Deleted '
222: ,to_char(l_count)
223: ,p_log_level_rec => g_log_level_rec);
224: fa_debug_pkg.add(l_calling_fn
220: fa_debug_pkg.add(l_calling_fn
221: ,'No of Records Deleted '
222: ,to_char(l_count)
223: ,p_log_level_rec => g_log_level_rec);
224: fa_debug_pkg.add(l_calling_fn
225: ,'Deleting duplicate other book rows from '
226: ,'fa_category_accounts_gt'
227: ,p_log_level_rec => g_log_level_rec);
228: end if;
240: where gt3.clearing_acct = gt1.clearing_acct);
241:
242: l_count := SQL%ROWCOUNT;
243: if (g_log_level_rec.statement_level) then
244: fa_debug_pkg.add(l_calling_fn
245: ,'No of Records Deleted '
246: ,to_char(l_count)
247: ,p_log_level_rec => g_log_level_rec);
248: end if;
331: ,l_asset_type_tbl
332: ,l_merged_code_tbl;
333:
334: if (g_log_level_rec.statement_level) then
335: fa_debug_pkg.add(l_calling_fn
336: ,'No of elements in the p_inv_dist_array'
337: ,p_invoice_dist_id_tbl.count
338: ,p_log_level_rec => g_log_level_rec);
339: fa_debug_pkg.add(l_calling_fn
335: fa_debug_pkg.add(l_calling_fn
336: ,'No of elements in the p_inv_dist_array'
337: ,p_invoice_dist_id_tbl.count
338: ,p_log_level_rec => g_log_level_rec);
339: fa_debug_pkg.add(l_calling_fn
340: ,'No of updated records fetched for iteration' || to_char(G_child_iteration_count)
341: , to_char(l_invoice_dist_id_tbl.count)
342: ,p_log_level_rec => g_log_level_rec);
343: end if;
418: bulk collect
419: into l_invoice_dist_id_tbl, l_mass_add_id_tbl, l_asset_type_tbl;
420:
421: if (g_log_level_rec.statement_level) then
422: fa_debug_pkg.add(l_calling_fn,
423: 'No of elements in the p_inv_dist_array'
424: ,p_invoice_dist_id_tbl.count
425: ,p_log_level_rec => g_log_level_rec);
426: fa_debug_pkg.add(l_calling_fn
422: fa_debug_pkg.add(l_calling_fn,
423: 'No of elements in the p_inv_dist_array'
424: ,p_invoice_dist_id_tbl.count
425: ,p_log_level_rec => g_log_level_rec);
426: fa_debug_pkg.add(l_calling_fn
427: ,'No of updated records updated for split MAD/AI lines'
428: , l_invoice_dist_id_tbl.count
429: ,p_log_level_rec => g_log_level_rec);
430: end if;
659:
660: -- populates the clearing gt used for ITEM/ACCRUAL category/book validation
661:
662: if (g_log_level_rec.statement_level) then
663: fa_debug_pkg.add(l_calling_fn
664: ,'Calling '
665: ,'Prepare_Clearing_GT '
666: ,p_log_level_rec => g_log_level_rec);
667: end if;
676: raise error_found;
677: end if;
678:
679: if (g_log_level_rec.statement_level) then
680: fa_debug_pkg.add(l_calling_fn
681: ,'Updating children to rejected'
682: ,'due to parents in the delete queue'
683: ,p_log_level_rec => g_log_level_rec);
684: end if;
700: exit;
701: end if;
702:
703: if (g_log_level_rec.statement_level) then
704: fa_debug_pkg.add(l_calling_fn
705: ,'No of rejected parents fetched'
706: ,l_invoice_dist_id_tbl.count
707: ,p_log_level_rec => g_log_level_rec);
708: fa_debug_pkg.add(l_calling_fn
704: fa_debug_pkg.add(l_calling_fn
705: ,'No of rejected parents fetched'
706: ,l_invoice_dist_id_tbl.count
707: ,p_log_level_rec => g_log_level_rec);
708: fa_debug_pkg.add(l_calling_fn
709: ,'calling'
710: ,'child line hook'
711: ,p_log_level_rec => g_log_level_rec);
712: end if;
744: close c_rejected;
745: end if;
746:
747: if (g_log_level_rec.statement_level) then
748: fa_debug_pkg.add(l_calling_fn
749: ,'processing'
750: ,'item and accrual lines'
751: ,p_log_level_rec => g_log_level_rec);
752: end if;
763: open c_item_accrual;
764: loop
765:
766: if (g_log_level_rec.statement_level) then
767: fa_debug_pkg.add(l_calling_fn
768: ,'fetching '
769: ,'item / accrual'
770: ,p_log_level_rec => g_log_level_rec);
771: end if;
780: exit;
781: end if;
782:
783: if (g_log_level_rec.statement_level) then
784: fa_debug_pkg.add(l_calling_fn
785: ,'updating item / accrual, array count: '
786: ,l_rowid.count
787: ,p_log_level_rec => g_log_level_rec);
788: fa_debug_pkg.add(l_calling_fn
784: fa_debug_pkg.add(l_calling_fn
785: ,'updating item / accrual, array count: '
786: ,l_rowid.count
787: ,p_log_level_rec => g_log_level_rec);
788: fa_debug_pkg.add(l_calling_fn
789: ,'segment_num: '
790: ,p_segment_num
791: ,p_log_level_rec => g_log_level_rec);
792: end if;
852: INTO l_invoice_dist_id_tbl, l_mass_add_id_tbl,
853: l_line_status_tbl, l_asset_type_tbl;
854:
855: if (g_log_level_rec.statement_level) then
856: fa_debug_pkg.add(l_calling_fn
857: ,'No of item/accrual lines Updated '
858: ,l_invoice_dist_id_tbl.count
859: ,p_log_level_rec => g_log_level_rec);
860: fa_debug_pkg.add(l_calling_fn
856: fa_debug_pkg.add(l_calling_fn
857: ,'No of item/accrual lines Updated '
858: ,l_invoice_dist_id_tbl.count
859: ,p_log_level_rec => g_log_level_rec);
860: fa_debug_pkg.add(l_calling_fn
861: ,'calling'
862: ,'child line hook'
863: ,p_log_level_rec => g_log_level_rec);
864: end if;
915:
916: savepoint FAMADC_preprocess5;
917:
918: if (g_log_level_rec.statement_level) then
919: fa_debug_pkg.add(l_calling_fn
920: ,'Processing'
921: ,'orphan child lines with parents in MAD'
922: ,p_log_level_rec => g_log_level_rec);
923: end if;
951: ,l_mad_count_tbl
952: limit g_batch_size;
953:
954: if (g_log_level_rec.statement_level) then
955: fa_debug_pkg.add(l_calling_fn
956: ,'No of MAD orphans fetched'
957: ,l_invoice_dist_id_tbl.count
958: ,p_log_level_rec => g_log_level_rec);
959: end if;
1008:
1009: end loop;
1010:
1011: if (g_log_level_rec.statement_level) then
1012: fa_debug_pkg.add(l_calling_fn
1013: ,'No of simple MAD orphans'
1014: ,l_child_inv_dist_id1_tbl.count
1015: ,p_log_level_rec => g_log_level_rec);
1016: fa_debug_pkg.add(l_calling_fn
1012: fa_debug_pkg.add(l_calling_fn
1013: ,'No of simple MAD orphans'
1014: ,l_child_inv_dist_id1_tbl.count
1015: ,p_log_level_rec => g_log_level_rec);
1016: fa_debug_pkg.add(l_calling_fn
1017: ,'No of split MAD orphans'
1018: ,l_child_inv_dist_id2_tbl.count
1019: ,p_log_level_rec => g_log_level_rec);
1020: end if;
1061:
1062: close c_orphans;
1063:
1064: if (g_log_level_rec.statement_level) then
1065: fa_debug_pkg.add(l_calling_fn
1066: ,'processing'
1067: ,'asset invoices children'
1068: ,p_log_level_rec => g_log_level_rec);
1069: end if;
1085: l_ai_distinct_asset_count_tbl
1086: limit g_batch_size;
1087:
1088: if (g_log_level_rec.statement_level) then
1089: fa_debug_pkg.add(l_calling_fn
1090: ,'No AI orphans fetched'
1091: ,l_invoice_dist_id_tbl.count
1092: ,p_log_level_rec => g_log_level_rec);
1093: end if;
1135:
1136: end loop;
1137:
1138: if (g_log_level_rec.statement_level) then
1139: fa_debug_pkg.add(l_calling_fn, 'No of simple AI orphans',l_child_inv_dist_id1_tbl.count
1140: ,p_log_level_rec => g_log_level_rec);
1141: fa_debug_pkg.add(l_calling_fn, 'No of split AI orphans', l_child_inv_dist_id2_tbl.count
1142: ,p_log_level_rec => g_log_level_rec);
1143: end if;
1137:
1138: if (g_log_level_rec.statement_level) then
1139: fa_debug_pkg.add(l_calling_fn, 'No of simple AI orphans',l_child_inv_dist_id1_tbl.count
1140: ,p_log_level_rec => g_log_level_rec);
1141: fa_debug_pkg.add(l_calling_fn, 'No of split AI orphans', l_child_inv_dist_id2_tbl.count
1142: ,p_log_level_rec => g_log_level_rec);
1143: end if;
1144:
1145: if (l_child_inv_dist_id1_tbl.count > 0) then
1188: l_child_queue_name1_tbl(l_child_queue_name1_tbl.count + 1) := 'NEW';
1189: end loop;
1190:
1191: if (g_log_level_rec.statement_level) then
1192: fa_debug_pkg.add(l_calling_fn
1193: ,'l_child_inv_dist_id1A_tbl.count'
1194: ,l_child_inv_dist_id1A_tbl.count
1195: ,p_log_level_rec => g_log_level_rec);
1196: fa_debug_pkg.add(l_calling_fn
1192: fa_debug_pkg.add(l_calling_fn
1193: ,'l_child_inv_dist_id1A_tbl.count'
1194: ,l_child_inv_dist_id1A_tbl.count
1195: ,p_log_level_rec => g_log_level_rec);
1196: fa_debug_pkg.add(l_calling_fn
1197: ,'l_child_mass_add_id1_tbl.count'
1198: ,l_child_mass_add_id1_tbl.count
1199: ,p_log_level_rec => g_log_level_rec);
1200: fa_debug_pkg.add(l_calling_fn
1196: fa_debug_pkg.add(l_calling_fn
1197: ,'l_child_mass_add_id1_tbl.count'
1198: ,l_child_mass_add_id1_tbl.count
1199: ,p_log_level_rec => g_log_level_rec);
1200: fa_debug_pkg.add(l_calling_fn
1201: ,'l_child_asset_id1A_tbl.count'
1202: ,l_child_asset_id1A_tbl.count
1203: ,p_log_level_rec => g_log_level_rec);
1204: fa_debug_pkg.add(l_calling_fn
1200: fa_debug_pkg.add(l_calling_fn
1201: ,'l_child_asset_id1A_tbl.count'
1202: ,l_child_asset_id1A_tbl.count
1203: ,p_log_level_rec => g_log_level_rec);
1204: fa_debug_pkg.add(l_calling_fn
1205: ,'l_child_line_status1A_tbl.count'
1206: ,l_child_line_status1A_tbl.count
1207: ,p_log_level_rec => g_log_level_rec);
1208: fa_debug_pkg.add(l_calling_fn
1204: fa_debug_pkg.add(l_calling_fn
1205: ,'l_child_line_status1A_tbl.count'
1206: ,l_child_line_status1A_tbl.count
1207: ,p_log_level_rec => g_log_level_rec);
1208: fa_debug_pkg.add(l_calling_fn
1209: ,'l_child_asset_type1A_tbl.count'
1210: ,l_child_asset_type1A_tbl.count
1211: ,p_log_level_rec => g_log_level_rec);
1212: fa_debug_pkg.add(l_calling_fn
1208: fa_debug_pkg.add(l_calling_fn
1209: ,'l_child_asset_type1A_tbl.count'
1210: ,l_child_asset_type1A_tbl.count
1211: ,p_log_level_rec => g_log_level_rec);
1212: fa_debug_pkg.add(l_calling_fn
1213: ,'l_child_posting_status1_tbl.count'
1214: ,l_child_posting_status1_tbl.count
1215: ,p_log_level_rec => g_log_level_rec);
1216: fa_debug_pkg.add(l_calling_fn
1212: fa_debug_pkg.add(l_calling_fn
1213: ,'l_child_posting_status1_tbl.count'
1214: ,l_child_posting_status1_tbl.count
1215: ,p_log_level_rec => g_log_level_rec);
1216: fa_debug_pkg.add(l_calling_fn
1217: ,'l_child_queue_name1_tbl.count'
1218: ,l_child_queue_name1_tbl.count
1219: ,p_log_level_rec => g_log_level_rec);
1220: fa_debug_pkg.add(l_calling_fn
1216: fa_debug_pkg.add(l_calling_fn
1217: ,'l_child_queue_name1_tbl.count'
1218: ,l_child_queue_name1_tbl.count
1219: ,p_log_level_rec => g_log_level_rec);
1220: fa_debug_pkg.add(l_calling_fn
1221: ,'l_child_merged_code1_tbl.count'
1222: ,l_child_merged_code1_tbl.count
1223: ,p_log_level_rec => g_log_level_rec);
1224: end if;
1271:
1272: savepoint FAMADC_preprocess7;
1273:
1274: if (g_log_level_rec.statement_level) then
1275: fa_debug_pkg.add(l_calling_fn
1276: ,'Updating depreciate_flag in'
1277: ,'fa_mass_additions_gt'
1278: ,p_log_level_rec => g_log_level_rec);
1279: end if;
1301:
1302: l_count := SQL%ROWCOUNT;
1303:
1304: if (g_log_level_rec.statement_level) then
1305: fa_debug_pkg.add(l_calling_fn
1306: ,'No of Records Updated'
1307: ,to_char(l_count)
1308: ,p_log_level_rec => g_log_level_rec);
1309: end if;
1378: l_user_id := FND_GLOBAL.user_id;
1379: l_login_id := FND_GLOBAL.login_id;
1380:
1381: if (g_log_level_rec.statement_level) then
1382: fa_debug_pkg.add(l_calling_fn, 'Stamp FA_SYSTEM_CONTROLS WITH ', l_request_id
1383: ,p_log_level_rec => g_log_level_rec);
1384: end if;
1385:
1386: update fa_system_controls
1386: update fa_system_controls
1387: set last_mass_additions = l_request_id;
1388:
1389: if (g_log_level_rec.statement_level) then
1390: fa_debug_pkg.add(l_calling_fn
1391: , 'Validating book '
1392: , p_book_type_code
1393: ,p_log_level_rec => g_log_level_rec);
1394: fa_debug_pkg.add(l_calling_fn
1390: fa_debug_pkg.add(l_calling_fn
1391: , 'Validating book '
1392: , p_book_type_code
1393: ,p_log_level_rec => g_log_level_rec);
1394: fa_debug_pkg.add(l_calling_fn
1395: ,'calling'
1396: ,'fa_cache_pkg.fazcbc'
1397: ,p_log_level_rec => g_log_level_rec);
1398: end if;
1402: raise create_err;
1403: end if;
1404:
1405: if (g_log_level_rec.statement_level) then
1406: fa_debug_pkg.add(l_calling_fn
1407: ,'calling'
1408: ,'fa_cache_pkg.fazcdp'
1409: ,p_log_level_rec => g_log_level_rec);
1410: end if;
1422: fa_cache_pkg.fazcdp_record.calendar_period_close_date ;
1423:
1424: IF l_date_ineffective IS NOT NULL THEN
1425: if (g_log_level_rec.statement_level) then
1426: fa_debug_pkg.add(l_calling_fn
1427: ,'Ineffective book '
1428: ,p_book_type_code
1429: ,p_log_level_rec => g_log_level_rec);
1430: end if;
1432: END IF;
1433:
1434: IF l_book_class <> 'CORPORATE' THEN
1435: if (g_log_level_rec.statement_level) then
1436: fa_debug_pkg.add(l_calling_fn
1437: ,'Incorrect Book class '
1438: ,p_book_type_code
1439: ,p_log_level_rec => g_log_level_rec);
1440: end if;
1442: END IF;
1443:
1444: -- Get Qualifier segment number
1445: if (g_log_level_rec.statement_level) then
1446: fa_debug_pkg.add(l_calling_fn
1447: ,'Get Qualifier Segment Column Name for Chart of Accounts ID '
1448: ,l_coa_id
1449: ,p_log_level_rec => g_log_level_rec);
1450: end if;
1458: raise create_err;
1459: end if;
1460:
1461: if (g_log_level_rec.statement_level) then
1462: fa_debug_pkg.add(l_calling_fn
1463: ,'application column name '
1464: ,l_app_column_name
1465: ,p_log_level_rec => g_log_level_rec);
1466: fa_debug_pkg.add(l_calling_fn
1462: fa_debug_pkg.add(l_calling_fn
1463: ,'application column name '
1464: ,l_app_column_name
1465: ,p_log_level_rec => g_log_level_rec);
1466: fa_debug_pkg.add(l_calling_fn
1467: ,'Checking Profile '
1468: ,'FA_DEFAULT_DPIS_TO_INV_DATE'
1469: ,p_log_level_rec => g_log_level_rec);
1470: end if;
1478: END IF;
1479:
1480: IF (l_def_dpis_enabled = 0) THEN /* For Future Dated Txns */
1481: if (g_log_level_rec.statement_level) then
1482: fa_debug_pkg.add(l_calling_fn
1483: ,'Get Default DPIS for '
1484: ,p_book_type_code
1485: ,p_log_level_rec => g_log_level_rec);
1486: end if;
1494: END IF;
1495:
1496:
1497: if (g_log_level_rec.statement_level) then
1498: fa_debug_pkg.add(l_calling_fn,'PreProcess Records in GT','that have book type code NULL'
1499: ,p_log_level_rec => g_log_level_rec);
1500: end if;
1501:
1502: IF NOT Preprocess_GT_Records
1506: ,p_column_name => l_app_column_name
1507: ,p_ledger_id => l_ledger_id
1508: ,p_def_dpis_dt => l_def_dpis_dt) THEN
1509: if (g_log_level_rec.statement_level) then
1510: fa_debug_pkg.add(l_calling_fn,'Error during PreProcessing in FA API ',p_book_type_code
1511: ,p_log_level_rec => g_log_level_rec);
1512: end if;
1513: raise create_err;
1514: END IF;
1516:
1517: -- Call the cache pkg to fetch the calendar_period_close_date
1518: if not fa_cache_pkg.fazcdp (x_book_type_code => p_book_type_code ) THEN
1519: if (g_log_level_rec.statement_level) then
1520: fa_debug_pkg.add(l_calling_fn
1521: ,'Unable to find valid depreciation information '
1522: ,p_book_type_code
1523: ,p_log_level_rec => g_log_level_rec);
1524: end if;
1525: raise fa_ineffective_book;
1526: end if;
1527:
1528: if (g_log_level_rec.statement_level) then
1529: fa_debug_pkg.add(l_calling_fn
1530: ,'Insert FA_MASS_ADDITIONS lines for primary ledger '
1531: ,p_book_type_code
1532: ,p_log_level_rec => g_log_level_rec);
1533: end if;
1750: and gt.line_status = 'VALID';
1751:
1752: l_count := SQL%ROWCOUNT;
1753: if (g_log_level_rec.statement_level) then
1754: fa_debug_pkg.add(l_calling_fn
1755: ,'No of Records Inserted '
1756: ,to_char(l_count)
1757: ,p_log_level_rec => g_log_level_rec);
1758: fa_debug_pkg.add(l_calling_fn
1754: fa_debug_pkg.add(l_calling_fn
1755: ,'No of Records Inserted '
1756: ,to_char(l_count)
1757: ,p_log_level_rec => g_log_level_rec);
1758: fa_debug_pkg.add(l_calling_fn
1759: ,'Inserting into FA_MC_MASS_RATES for reporting ledger(s) '
1760: ,p_book_type_code
1761: ,p_log_level_rec => g_log_level_rec);
1762: end if;
1788: and mcbc.mrc_converted_flag = 'Y';
1789:
1790: l_count := SQL%ROWCOUNT;
1791: if (g_log_level_rec.statement_level) then
1792: fa_debug_pkg.add(l_calling_fn
1793: ,'No of Records Inserted '
1794: ,to_char(l_count)
1795: ,p_log_level_rec => g_log_level_rec);
1796: end if;
1797:
1798: -- update for rejected is already handled in the preprocessing logic
1799:
1800: if (g_log_level_rec.statement_level) then
1801: fa_debug_pkg.add(l_calling_fn
1802: ,'Updating successful/processed rows in '
1803: ,'fa_mass_additions_gt'
1804: ,p_log_level_rec => g_log_level_rec);
1805: end if;
1819:
1820: l_count := SQL%ROWCOUNT;
1821:
1822: if (g_log_level_rec.statement_level) then
1823: fa_debug_pkg.add(l_calling_fn
1824: ,'No of Records Processed'
1825: ,to_char(l_count)
1826: ,p_log_level_rec => g_log_level_rec);
1827: end if;
1838: x_return_status := FND_API.G_RET_STS_ERROR;
1839:
1840: when fa_ineffective_book then
1841: if (g_log_level_rec.statement_level) then
1842: fa_debug_pkg.add(l_calling_fn
1843: ,'This book does not exist or has a date ineffective on or before today'
1844: ,p_book_type_code
1845: ,p_log_level_rec => g_log_level_rec);
1846: end if;
1847: x_return_status := FND_API.G_RET_STS_ERROR;
1848:
1849: when fa_not_corp_book then
1850: if (g_log_level_rec.statement_level) then
1851: fa_debug_pkg.add(l_calling_fn
1852: ,'Mass Additions Create cannot be run for non-corporate book'
1853: ,p_book_type_code
1854: ,p_log_level_rec => g_log_level_rec);
1855: end if;