37: CST_DIST_PKG_ERROR EXCEPTION;
38: BEGIN
39:
40: IF g_debug_flag = 'Y' THEN
41: fnd_file.put_line(fnd_file.log, 'CSTPAPBR.Create_acct_lines <<');
42: fnd_file.put_line(fnd_file.log, 'i_transaction_id: ' || i_transaction_id);
43: END IF;
44:
45: l_stmt_num := 10;
38: BEGIN
39:
40: IF g_debug_flag = 'Y' THEN
41: fnd_file.put_line(fnd_file.log, 'CSTPAPBR.Create_acct_lines <<');
42: fnd_file.put_line(fnd_file.log, 'i_transaction_id: ' || i_transaction_id);
43: END IF;
44:
45: l_stmt_num := 10;
46: o_err_num := 0;
68: -- Get the set of books id
69: -----------------------------------------------------------------------------
70:
71: IF g_debug_flag = 'Y' THEN
72: fnd_file.put_line(fnd_file.log,'Event type: '||(i_event_type_id));
73: END IF;
74:
75: l_stmt_num := 15;
76: SELECT
252: l_ae_txn_rec.xfer_organization_id);
253: END IF;
254:
255: IF g_debug_flag = 'Y' THEN
256: fnd_file.put_line(fnd_file.log,'Operating Unit: '||to_char(l_operating_unit));
257: END IF;
258:
259: l_stmt_num := 29;
260: SELECT decode(l_ae_txn_rec.txn_src_type_id,
549: END IF;
550: END IF;
551:
552: IF g_debug_flag = 'Y' THEN
553: fnd_file.put_line(fnd_file.log, 'Create_acct_lines >>');
554: END IF;
555:
556:
557: EXCEPTION
626:
627: BEGIN
628:
629: IF g_debug_flag = 'Y' THEN
630: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin <<'
631: || ' transaction_id: ' || i_ae_txn_rec.transaction_id);
632: END IF;
633:
634: l_ae_line_tbl := CSTPALTY.cst_ae_line_tbl_type();
738: l_curr_rec.currency_conv_rate := i_ae_txn_rec.currency_conv_rate;
739: END IF;
740:
741: IF g_debug_flag = 'Y' THEN
742: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num ||
743: ': l_curr_rec.pri_currency = ' || l_curr_rec.pri_currency ||
744: '; l_curr_rec.alt_currency = ' || l_curr_rec.alt_currency);
745: END IF;
746:
757: end if;
758: end if;
759:
760: IF g_debug_flag = 'Y' THEN
761: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num ||
762: ': l_curr_rec.currency_conv_rate = ' || l_curr_rec.currency_conv_rate);
763: END IF;
764:
765: /* forward port for 14541396*/
772: SELECT mmt.rcv_transaction_id into l_rcv_txn
773: FROM mtl_material_transactions mmt
774: WHERE mmt.transaction_id = i_ae_txn_rec.transaction_id;
775:
776: fnd_file.put_line(fnd_file.log,'i_ae_txn_rec.transaction_id << '|| i_ae_txn_rec.transaction_id);
777: fnd_file.put_line(fnd_file.log,'l_rcv_txn << '|| l_rcv_txn );
778:
779:
780: SELECT
773: FROM mtl_material_transactions mmt
774: WHERE mmt.transaction_id = i_ae_txn_rec.transaction_id;
775:
776: fnd_file.put_line(fnd_file.log,'i_ae_txn_rec.transaction_id << '|| i_ae_txn_rec.transaction_id);
777: fnd_file.put_line(fnd_file.log,'l_rcv_txn << '|| l_rcv_txn );
778:
779:
780: SELECT
781: rt6.transaction_id
788: rt6.transaction_id = l_rcv_txn
789: CONNECT BY
790: rt6.transaction_id = prior rt6.parent_transaction_id;
791:
792: fnd_file.put_line(fnd_file.log,'l_par_rcv_txn << '|| l_par_rcv_txn);
793:
794: SELECT
795: COUNT(rcv_transaction_id)
796: INTO
818: where crac.rcv_transaction_id = l_par_rcv_txn AND
819: crac.cost_type_id = i_ae_txn_rec.cost_type_id AND
820: crac.cost_group_id = i_ae_txn_rec.cost_group_id;
821:
822: fnd_file.put_line(fnd_file.log,'stmt num32 << ');
823: fnd_file.put_line(fnd_file.log,'l_nqr << ' || l_nqr);
824: fnd_file.put_line(fnd_file.log,'l_costed_quantity << '|| l_costed_quantity);
825: fnd_file.put_line(fnd_file.log,'l_acq_cost << '||l_acq_cost);
826:
819: crac.cost_type_id = i_ae_txn_rec.cost_type_id AND
820: crac.cost_group_id = i_ae_txn_rec.cost_group_id;
821:
822: fnd_file.put_line(fnd_file.log,'stmt num32 << ');
823: fnd_file.put_line(fnd_file.log,'l_nqr << ' || l_nqr);
824: fnd_file.put_line(fnd_file.log,'l_costed_quantity << '|| l_costed_quantity);
825: fnd_file.put_line(fnd_file.log,'l_acq_cost << '||l_acq_cost);
826:
827: IF (l_nqr = 0) THEN
820: crac.cost_group_id = i_ae_txn_rec.cost_group_id;
821:
822: fnd_file.put_line(fnd_file.log,'stmt num32 << ');
823: fnd_file.put_line(fnd_file.log,'l_nqr << ' || l_nqr);
824: fnd_file.put_line(fnd_file.log,'l_costed_quantity << '|| l_costed_quantity);
825: fnd_file.put_line(fnd_file.log,'l_acq_cost << '||l_acq_cost);
826:
827: IF (l_nqr = 0) THEN
828: IF g_debug_flag = 'Y' THEN
821:
822: fnd_file.put_line(fnd_file.log,'stmt num32 << ');
823: fnd_file.put_line(fnd_file.log,'l_nqr << ' || l_nqr);
824: fnd_file.put_line(fnd_file.log,'l_costed_quantity << '|| l_costed_quantity);
825: fnd_file.put_line(fnd_file.log,'l_acq_cost << '||l_acq_cost);
826:
827: IF (l_nqr = 0) THEN
828: IF g_debug_flag = 'Y' THEN
829: fnd_file.put_line(fnd_file.log, 'The Net Quantity Received is Zero');
825: fnd_file.put_line(fnd_file.log,'l_acq_cost << '||l_acq_cost);
826:
827: IF (l_nqr = 0) THEN
828: IF g_debug_flag = 'Y' THEN
829: fnd_file.put_line(fnd_file.log, 'The Net Quantity Received is Zero');
830: END IF;
831: return;
832: END IF;
833:
867: crac.cost_type_id = i_ae_txn_rec.cost_type_id AND
868: crac.cost_group_id = i_ae_txn_rec.cost_group_id)
869: and cracd.source_type = 'INVOICE';
870:
871: fnd_file.put_line(fnd_file.log,'stmt num 33 << ');
872: fnd_file.put_line(fnd_file.log,'l_acq_cost_ent_inv<<' || l_acq_cost_ent_inv );
873:
874: l_stmt_num := 34;
875:
868: crac.cost_group_id = i_ae_txn_rec.cost_group_id)
869: and cracd.source_type = 'INVOICE';
870:
871: fnd_file.put_line(fnd_file.log,'stmt num 33 << ');
872: fnd_file.put_line(fnd_file.log,'l_acq_cost_ent_inv<<' || l_acq_cost_ent_inv );
873:
874: l_stmt_num := 34;
875:
876: SELECT
893: AND rt.transaction_id = l_par_rcv_txn
894: AND rt.po_line_location_id = poll.line_location_id
895: AND cracd.source_type = 'PO';
896:
897: fnd_file.put_line(fnd_file.log,'stmt num 34 << ' );
898: fnd_file.put_line(fnd_file.log,'l_acq_cost_ent_po << '|| l_acq_cost_ent_po);
899:
900: IF (l_acq_cost_ent_po < 0) THEN
901: IF g_debug_flag = 'Y' THEN
894: AND rt.po_line_location_id = poll.line_location_id
895: AND cracd.source_type = 'PO';
896:
897: fnd_file.put_line(fnd_file.log,'stmt num 34 << ' );
898: fnd_file.put_line(fnd_file.log,'l_acq_cost_ent_po << '|| l_acq_cost_ent_po);
899:
900: IF (l_acq_cost_ent_po < 0) THEN
901: IF g_debug_flag = 'Y' THEN
902: fnd_file.put_line(fnd_file.log,'Error: No Acquisition Rate');
898: fnd_file.put_line(fnd_file.log,'l_acq_cost_ent_po << '|| l_acq_cost_ent_po);
899:
900: IF (l_acq_cost_ent_po < 0) THEN
901: IF g_debug_flag = 'Y' THEN
902: fnd_file.put_line(fnd_file.log,'Error: No Acquisition Rate');
903: END IF;
904: l_err_rec.l_err_num := 999;
905: END IF;
906:
905: END IF;
906:
907: l_acq_cost_ent := (nvl(l_acq_cost_ent_inv,0) + nvl(l_acq_cost_ent_po,0))/l_costed_quantity;
908:
909: fnd_file.put_line(fnd_file.log,'l_acq_cost_ent << '|| l_acq_cost_ent);
910:
911: IF (l_acq_cost_ent = 0) THEN
912: l_curr_conv_rate := 1;
913: ELSE
913: ELSE
914: l_curr_conv_rate := l_acq_cost/l_acq_cost_ent;
915: END IF;
916:
917: fnd_file.put_line(fnd_file.log,'l_curr_conv_rate << '|| l_curr_conv_rate );
918:
919: l_curr_rec.currency_conv_rate := l_curr_conv_rate;
920:
921: ELSE
919: l_curr_rec.currency_conv_rate := l_curr_conv_rate;
920:
921: ELSE
922: IF g_debug_flag = 'Y' THEN
923: fnd_file.put_line(fnd_file.log,'No Acquisition Cost');
924: END IF;
925: RETURN;
926: END IF;
927:
1090: mtl_parameters
1091: where organization_id = i_ae_txn_rec.organization_id;
1092:
1093: IF g_debug_flag = 'Y' THEN
1094: fnd_file.put_line(fnd_file.log,'Organization_id : '||(i_ae_txn_rec.organization_id));
1095: fnd_file.put_line(fnd_file.log,'l_enc_rev : '||(l_enc_rev));
1096: fnd_file.put_line(fnd_file.log,'transaction_id : '||(i_ae_txn_rec.transaction_id));
1097: fnd_file.put_line(fnd_file.log,'txn_action_id : '||(i_ae_txn_rec.txn_action_id));
1098: END IF;
1091: where organization_id = i_ae_txn_rec.organization_id;
1092:
1093: IF g_debug_flag = 'Y' THEN
1094: fnd_file.put_line(fnd_file.log,'Organization_id : '||(i_ae_txn_rec.organization_id));
1095: fnd_file.put_line(fnd_file.log,'l_enc_rev : '||(l_enc_rev));
1096: fnd_file.put_line(fnd_file.log,'transaction_id : '||(i_ae_txn_rec.transaction_id));
1097: fnd_file.put_line(fnd_file.log,'txn_action_id : '||(i_ae_txn_rec.txn_action_id));
1098: END IF;
1099:
1092:
1093: IF g_debug_flag = 'Y' THEN
1094: fnd_file.put_line(fnd_file.log,'Organization_id : '||(i_ae_txn_rec.organization_id));
1095: fnd_file.put_line(fnd_file.log,'l_enc_rev : '||(l_enc_rev));
1096: fnd_file.put_line(fnd_file.log,'transaction_id : '||(i_ae_txn_rec.transaction_id));
1097: fnd_file.put_line(fnd_file.log,'txn_action_id : '||(i_ae_txn_rec.txn_action_id));
1098: END IF;
1099:
1100: if ((i_ae_txn_rec.txn_src_type_id = 1) OR (i_ae_txn_rec.txn_src_type_id in (7,8) AND i_ae_txn_rec.txn_action_id NOT IN (1,17) )) then
1093: IF g_debug_flag = 'Y' THEN
1094: fnd_file.put_line(fnd_file.log,'Organization_id : '||(i_ae_txn_rec.organization_id));
1095: fnd_file.put_line(fnd_file.log,'l_enc_rev : '||(l_enc_rev));
1096: fnd_file.put_line(fnd_file.log,'transaction_id : '||(i_ae_txn_rec.transaction_id));
1097: fnd_file.put_line(fnd_file.log,'txn_action_id : '||(i_ae_txn_rec.txn_action_id));
1098: END IF;
1099:
1100: if ((i_ae_txn_rec.txn_src_type_id = 1) OR (i_ae_txn_rec.txn_src_type_id in (7,8) AND i_ae_txn_rec.txn_action_id NOT IN (1,17) )) then
1101:
1116: -- FP 12.1.1 bug 7346244 fix
1117: if (l_enc_rev = 1 AND i_ae_txn_rec.txn_action_id = 17 AND i_ae_txn_rec.exp_item = 0 ) then
1118:
1119: IF g_debug_flag = 'Y' THEN
1120: fnd_file.put_line(fnd_file.log,'CompEncumbrance_IntOrdersExp << : ');
1121: END IF;
1122:
1123: /* Check if the transfer is between Disc to Disc and the subinventory from which internal order issue is done is Expense then don't create encumbrance reversal as no actuals would be created */
1124:
1151: raise process_error;
1152: end if;
1153: ELSE
1154: IF g_debug_flag = 'Y' THEN
1155: fnd_file.put_line(fnd_file.log,'No Encumbrance Reversal as Int order issue is done from Exp sub in Discrete to Discrete Txfer');
1156: END IF;
1157: l_enc_amount := 0;
1158: END IF;
1159:
1161: l_ae_txn_rec1.encum_amount :=l_enc_amount;
1162: l_ae_txn_rec1.encum_account :=l_enc_account;
1163:
1164: IF g_debug_flag = 'Y' THEN
1165: fnd_file.put_line(fnd_file.log,'encum_amount << : '||l_ae_txn_rec1.encum_amount);
1166: fnd_file.put_line(fnd_file.log,'encum_account << : '||l_ae_txn_rec1.encum_account);
1167: END IF;
1168:
1169: if (l_enc_rev = 1 and l_ae_txn_rec1.encum_amount <> 0) THEN
1162: l_ae_txn_rec1.encum_account :=l_enc_account;
1163:
1164: IF g_debug_flag = 'Y' THEN
1165: fnd_file.put_line(fnd_file.log,'encum_amount << : '||l_ae_txn_rec1.encum_amount);
1166: fnd_file.put_line(fnd_file.log,'encum_account << : '||l_ae_txn_rec1.encum_account);
1167: END IF;
1168:
1169: if (l_enc_rev = 1 and l_ae_txn_rec1.encum_amount <> 0) THEN
1170:
1183: l_stmt_num := 80;
1184: o_ae_line_rec_tbl := l_ae_line_tbl;
1185:
1186: IF g_debug_flag = 'Y' THEN
1187: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': return >>');
1188: END IF;
1189:
1190: EXCEPTION
1191:
1236:
1237: BEGIN
1238:
1239: IF g_debug_flag ='Y' THEN
1240: fnd_file.put_line(fnd_file.log, 'Wip_cost_txn <<');
1241: END IF;
1242: -- Initialize variables.
1243: -- ---------------------
1244: l_err_rec.l_err_num := 0;
1250: -- There are no cost distributions for expense items.
1251: -- --------------------------------------------------
1252: if (i_ae_txn_rec.exp_item = 1) then
1253: IF g_debug_flag = 'Y' THEN
1254: fnd_file.put_line(fnd_file.log,'No accounting for Expense item');
1255: END IF;
1256: return;
1257: end if;
1258:
1263: -- repetitive schedules
1264:
1265: IF (i_ae_txn_rec.wip_entity_type = 2) THEN
1266: IF g_debug_flag = 'Y' THEN
1267: fnd_file.put_line(fnd_file.log, 'Repetitive Schedule: ');
1268: END IF;
1269:
1270: l_stmt_num := 10;
1271:
1302:
1303: -- flow schedules
1304: ELSIF (i_ae_txn_rec.wip_entity_type = 4) THEN
1305: IF g_debug_flag = 'Y' THEN
1306: fnd_file.put_line(fnd_file.log,'Flow Schedule: ');
1307: END IF;
1308:
1309: SELECT
1310: material_account,
1325: AND wip_entity_id = i_ae_txn_rec.txn_src_id;
1326: ELSE
1327: -- discrete jobs
1328: IF g_debug_flag = 'Y' THEN
1329: fnd_file.put_line(fnd_file.log,'Discrete Job: ');
1330: END IF;
1331: l_stmt_num := 17;
1332: select
1333: material_account,
1361: -- Scrap transactions do not have inventory impact!!
1362: -- -------------------------------------------------
1363: if (i_ae_txn_rec.txn_action_id <> 30) then
1364: IF g_debug_flag = 'Y' THEN
1365: fnd_file.put_line(fnd_file.log,'Scrap txn: ');
1366: END IF;
1367: select decode(asset_inventory,1,0,1)
1368: into l_exp_sub
1369: from mtl_secondary_inventories
1374: -- not distributed.
1375: -- ----------------------------------------------------------------
1376: if (l_exp_sub = 1 and l_exp_job = 1) then
1377: IF g_debug_flag = 'Y' THEN
1378: fnd_file.put_line(fnd_file.log,'No accounting for Expense Sub or Expense Job');
1379: END IF;
1380: return;
1381: end if;
1382: if (l_exp_sub = 1) then
1392: -- ----------------------------------------------------------------
1393:
1394: if (i_ae_txn_rec.txn_action_id in (31,32)) then
1395: IF g_debug_flag = 'Y' THEN
1396: fnd_file.put_line(fnd_file.log,'Assembly completion/return');
1397: END IF;
1398: l_stmt_num := 40;
1399: select count(transaction_id) /* Bug No. 4586534 */
1400: into l_mat_ovhd_exists
1549: end if;
1550:
1551: end if;
1552: IF g_debug_flag = 'Y' THEN
1553: fnd_file.put_line(fnd_file.log,'Wip_cost_txn >>');
1554: END IF;
1555:
1556: EXCEPTION
1557:
1592: l_acct_rec CSTPALTY.cst_ae_acct_rec_type;
1593: BEGIN
1594:
1595: IF g_debug_flag = 'Y' THEN
1596: fnd_file.put_line(fnd_file.log,'Sub_cost_txn <<');
1597: END IF;
1598:
1599: -- Initialize variables.
1600: -- ---------------------
1605: -- There are no cost distributions for expense items.
1606: -- --------------------------------------------------
1607: if (i_ae_txn_rec.exp_item = 1) then
1608: IF g_debug_flag = 'Y' THEN
1609: fnd_file.put_line(fnd_file.log,'No accounting for Expense Item');
1610: END IF;
1611: return;
1612: end if;
1613:
1633: if (l_exp_sub1 = 1 and l_exp_sub2 = 1) or
1634: (l_exp_sub1 = 0 and l_exp_sub2 = 0)
1635: then
1636: IF g_debug_flag = 'Y' THEN
1637: fnd_file.put_line(fnd_file.log,'No accounting for Expense to Expense or Asset to Asset');
1638: END IF;
1639: return;
1640: end if;
1641:
1678: if (l_err_rec.l_err_num <> 0 and l_err_rec.l_err_num is not null) then
1679: raise process_error;
1680: end if;
1681: IF g_debug_flag = 'Y' THEN
1682: fnd_file.put_line(fnd_file.log,'Sub_cost_txn >>');
1683: END IF;
1684:
1685: EXCEPTION
1686:
1911:
1912: BEGIN
1913:
1914: IF g_debug_flag = 'Y' THEN
1915: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin <<'
1916: || ' transaction_id: ' || i_ae_txn_rec.transaction_id);
1917: END IF;
1918:
1919: -- Initialize variables.
1952: AND cost_group_id = i_ae_txn_rec.cost_group_id
1953: AND category_id = i_ae_txn_rec.category_id;
1954: EXCEPTION
1955: WHEN no_data_found THEN
1956: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num ||
1957: ': Category : '||to_char(i_ae_txn_rec.category_id) ||' has no accounts defined');
1958: raise no_mfca_acct_error;
1959: END;
1960:
1994:
1995: l_txfr_txn_cost_group_id := NVL(i_ae_txn_rec.xfer_cost_group_id, -1);
1996:
1997: IF g_debug_flag = 'Y' THEN
1998: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
1999: ': cost_group_id = ' || i_ae_txn_rec.cost_group_id ||
2000: ': txn_cost_group_id ' || l_txn_cost_group_id ||
2001: ': txfr_txn_cost_group_id ' || l_txfr_txn_cost_group_id);
2002: END IF;
2007:
2008: IF (l_txn_cost_group_id = l_txfr_txn_cost_group_id) THEN /* Same Cost Group Transfer */
2009:
2010: IF g_debug_flag = 'Y' THEN
2011: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Transfer Within Same Cost Group');
2012: END IF;
2013:
2014: /* Do not create accounting for same cost group transfers of expense items */
2015: IF (i_ae_txn_rec.exp_item = 1 and i_ae_txn_rec.txn_action_id = 3) THEN
2014: /* Do not create accounting for same cost group transfers of expense items */
2015: IF (i_ae_txn_rec.exp_item = 1 and i_ae_txn_rec.txn_action_id = 3) THEN
2016: l_stmt_num := 23;
2017: IF g_debug_flag = 'Y' THEN
2018: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': return >> ' ||
2019: '(No accounting for Expense item)');
2020: END IF;
2021: RETURN;
2022: END IF;
2027:
2028: l_stmt_num := 25;
2029:
2030: IF g_debug_flag = 'Y' THEN
2031: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Direct Transfer');
2032: END IF;
2033:
2034: SELECT decode(asset_inventory,1,0,1)
2035: INTO l_exp_sub2
2040: IF (l_exp_sub1 = 0 AND l_exp_sub2 = 0) OR
2041: (l_exp_sub1 = 1 AND l_exp_sub2 = 1)
2042: THEN
2043: IF g_debug_flag = 'Y' THEN
2044: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': return >> '
2045: || 'No accounting for Expense to Expense or Asset to Asset Subs');
2046: END IF;
2047: RETURN;
2048: END IF;
2055: ELSE
2056: l_stmt_num := 30;
2057:
2058: IF g_debug_flag = 'Y' THEN
2059: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Intransit Transfer');
2060: END IF;
2061:
2062: if (l_exp_sub1 = 1 or i_ae_txn_rec.exp_item = 1) then
2063: l_exp1 := 1;
2125: raise process_error;
2126: end if;
2127:
2128: if (g_debug_flag = 'Y') then
2129: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': Interorg_cost_txn >>');
2130: end if;
2131:
2132: return; -- done processing same cost group transfers
2133:
2137: ---------------------------------------------------
2138: l_stmt_num := 31;
2139:
2140: IF g_debug_flag = 'Y' THEN
2141: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Create Accounting for same cost group transfer');
2142: END IF;
2143:
2144: -- In R12, the Inventory Offset Account field has been removed from
2145: -- the Periodic Account Assignments form, so cst_org_cost_group_accounts.
2201: raise process_error;
2202: end if;
2203:
2204: if (g_debug_flag = 'Y') then
2205: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': Interorg_cost_txn >>');
2206: end if;
2207:
2208: return; -- done processing same cost group transfers
2209:
2211:
2212: l_stmt_num := 35;
2213:
2214: IF g_debug_flag = 'Y' THEN
2215: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Transfer across different cost groups');
2216: END IF;
2217:
2218: /* Select the expense item status of the item in the org belonging
2219: to the cost group currently being processed. This may be different
2250: /* currency conversion rate in i_ae_curr_rec is always from the sending org to the receiving org */
2251: l_conv_rate := i_ae_curr_rec.currency_conv_rate;
2252:
2253: IF g_debug_flag = 'Y' THEN
2254: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Currency conversion rate: ' || l_conv_rate);
2255: END IF;
2256:
2257: /* Get transfer transaction id for receipt transactions */
2258: IF ( i_ae_txn_rec.txn_action_id in (12,22)
2342:
2343: l_tprice_option := 2; /* Make it 2 to ignore the CST Transfer Price profile */
2344:
2345: IF g_debug_flag = 'Y' THEN
2346: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ' ICR Set up:process-discrete xfer');
2347: END IF;
2348:
2349: END IF;
2350:
2353: END IF;
2354: -- INVCONV sikhanna END
2355:
2356: IF g_debug_flag = 'Y' THEN
2357: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2358: ': l_tprice_option: ' || l_tprice_option || ', process-discrete xfer: ' || l_pd_txfr_ind);
2359: END IF;
2360:
2361: l_stmt_num := 55;
2363: -- INVCONV sikhanna, process Internal sales order for OPM conv here
2364: IF ((i_ae_txn_rec.txn_src_type_id IN (7,8)) AND (l_tprice_option IN (1,2))) THEN /* Process Internal Orders */
2365:
2366: IF g_debug_flag = 'Y' THEN
2367: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2368: ': Shipment txn of Internal Order Transfer');
2369: END IF;
2370: /* Internal Sales Order with transfer price specified and profiles set.
2371: CST_TRANSFER_PRICING_OPTION is set to: Yes,Price as Incoming Cost or Yes, Price Not as Incoming Cost.
2377:
2378: l_stmt_num := 57;
2379:
2380: IF g_debug_flag = 'Y' THEN
2381: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2382: ': Shipment txn of Internal Order FOB Shipment - Sending Cost Group');
2383: END IF;
2384:
2385: IF g_debug_flag = 'Y' THEN
2382: ': Shipment txn of Internal Order FOB Shipment - Sending Cost Group');
2383: END IF;
2384:
2385: IF g_debug_flag = 'Y' THEN
2386: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2387: ': Discrete-Discrete Transfer');
2388: END IF;
2389:
2390: IF (l_cg_exp_item <> 1) THEN
2393: -- Bug 5573993 - Derive the COGS account to break dependency on perpetual
2394: -- code as if the trxn is not costed, mmt has incorrect account stamped
2395:
2396: IF g_debug_flag = 'Y' THEN
2397: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2398: 'Deriving COGS account');
2399: END IF;
2400:
2401: l_stmt_num := 61;
2407: RAISE process_error;
2408: END IF;
2409:
2410: IF g_debug_flag = 'Y' THEN
2411: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2412: 'COGS Account ID: ' || l_cogs_account);
2413: END IF;
2414:
2415: -- Stamp all elemental accounts with the COGS account
2475:
2476: l_stmt_num := 65;
2477:
2478: IF g_debug_flag = 'Y' THEN
2479: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2480: ': Shipment txn of Internal Order FOB Shipment - Receiving Cost Group');
2481: END IF;
2482:
2483: /* Credit Intercompany Accrual and Debit Intransit */
2487: -- Bug 5573993 - Derive the Intercompany account to break dependency on perpetual
2488: -- code as if the trxn is not costed, mmt has incorrect or no account stamped
2489:
2490: IF g_debug_flag = 'Y' THEN
2491: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2492: 'Deriving intercompany account');
2493: END IF;
2494:
2495: l_accrual_account := get_intercompany_account (i_ae_txn_rec => i_ae_txn_rec,
2499: RAISE process_error;
2500: END IF;
2501:
2502: IF g_debug_flag = 'Y' THEN
2503: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2504: 'Intercompany Account ID: ' || l_accrual_account);
2505: END IF;
2506:
2507:
2553:
2554: END IF;
2555:
2556: IF g_debug_flag = 'Y' THEN
2557: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2558: ': Cr Intercompany Accrual @ : ' || l_transfer_price);
2559: END IF;
2560:
2561: l_ae_line_rec.account := l_accrual_account;
2578:
2579: IF (l_tprice_option = 2) THEN
2580:
2581: IF g_debug_flag = 'Y' THEN
2582: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2583: ': CST:Transfer Price Option = Yes, Price As Incoming Cost');
2584: END IF;
2585:
2586: ELSIF (l_tprice_option = 1) THEN
2585:
2586: ELSIF (l_tprice_option = 1) THEN
2587:
2588: IF g_debug_flag = 'Y' THEN
2589: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2590: ': CST:Transfer Price Option = Yes, Price Not As Incoming Cost');
2591: END IF;
2592:
2593: -- Debit/Credit Profit in Inventory
2689: l_stmt_num := 90;
2690: /* This can only be the sending CG */
2691:
2692: IF g_debug_flag = 'Y' THEN
2693: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2694: ': Shipment txn of Internal Order FOB Receipt - Shipping Cost Group');
2695: END IF;
2696:
2697: IF (l_cg_exp_item <> 1) THEN
2750: ELSIF (i_ae_txn_rec.txn_action_id not in (15,22)) THEN /* Ordinary Interorg shipments */
2751:
2752: l_stmt_num := 92;
2753: IF g_debug_flag = 'Y' THEN
2754: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2755: ': Interorg Shipment transaction');
2756: END IF;
2757:
2758: IF ((i_ae_txn_rec.cost_group_id = l_shipping_cg_id) AND l_fob_point = 1) THEN /* This is the sending CG for FOBS */
2758: IF ((i_ae_txn_rec.cost_group_id = l_shipping_cg_id) AND l_fob_point = 1) THEN /* This is the sending CG for FOBS */
2759:
2760: l_stmt_num := 94;
2761: IF g_debug_flag = 'Y' THEN
2762: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2763: ': Shipment txn of FOB Shipment - Shipping Cost Group');
2764: END IF;
2765:
2766:
2875: AND CPIC.COST_GROUP_ID = i_ae_txn_rec.cost_group_id
2876: AND CPIC.PAC_PERIOD_ID = i_ae_txn_rec.accounting_period_id;
2877:
2878: IF g_debug_flag = 'Y' THEN
2879: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2880: ': Using PAC Absorption Cost: ' || l_pacp_pwac_cost);
2881: END IF;
2882:
2883: /* Get transfer credit information */
2967:
2968: IF (l_use_prev_period_cost = 1) THEN
2969:
2970: IF g_debug_flag = 'Y' THEN
2971: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2972: ': Using prior period PWAC cost: ' || l_prev_period_pwac_cost);
2973: END IF;
2974:
2975: /* Get transfer credit information */
3099:
3100: IF (l_pd_txfr_ind = 0) THEN -- Discrete-Discrete X-fers
3101:
3102: IF g_debug_flag = 'Y' THEN
3103: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3104: ': Discrete-Discrete Transfer: Using MTA cost');
3105: END IF;
3106:
3107: BEGIN
3117: l_perp_ship_value := 0;
3118: END;
3119:
3120: IF g_debug_flag = 'Y' THEN
3121: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3122: ': l_perp_ship_value = ' || l_perp_ship_value);
3123: END IF;
3124:
3125: l_stmt_num := 145;
3137: l_txfr_credit := 0;
3138: END IF;
3139:
3140: IF g_debug_flag = 'Y' THEN
3141: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3142: ': l_txfr_credit = ' || l_txfr_credit);
3143: END IF;
3144:
3145: l_stmt_num := 150;
3146:
3147: l_io_rcv_value := l_txfr_credit + (l_perp_ship_value / abs(i_ae_txn_rec.primary_quantity));
3148:
3149: IF g_debug_flag = 'Y' THEN
3150: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3151: ': l_io_rcv_value = ' || l_io_rcv_value);
3152: END IF;
3153:
3154: l_ae_line_rec.transaction_value := l_io_rcv_value * abs(i_ae_txn_rec.primary_quantity);
3219:
3220: l_txfr_var_value := abs(l_txfr_var_value);
3221:
3222: IF g_debug_flag = 'Y' THEN
3223: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3224: ': l_txfr_var_value = ' || l_txfr_var_value);
3225: END IF;
3226:
3227: l_stmt_num := 170;
3259:
3260: l_stmt_num := 180;
3261:
3262: IF g_debug_flag = 'Y' THEN
3263: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3264: ': Process-Discrete Transfer');
3265: END IF;
3266:
3267: SELECT mip.interorg_receivables_account,
3357:
3358: l_stmt_num := 210;
3359:
3360: IF g_debug_flag = 'Y' THEN
3361: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3362: ': Shipment txn of FOB Shipment - Receiving Cost Group');
3363: END IF;
3364:
3365: SELECT mip.interorg_payables_account,
3509:
3510: l_stmt_num := 225;
3511:
3512: IF g_debug_flag = 'Y' THEN
3513: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3514: ': Shipment txn of FOB Receipt - Shipping Cost Group');
3515: END IF;
3516:
3517: IF (l_cg_exp_item <> 1) THEN
3567:
3568: l_stmt_num := 230;
3569:
3570: IF g_debug_flag = 'Y' THEN
3571: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3572: ': Shipment txn of Direct Interorg - Shipping Cost Group');
3573: END IF;
3574:
3575: /* Credit Onhand inventory */
3691: AND CPIC.COST_GROUP_ID = i_ae_txn_rec.cost_group_id
3692: AND CPIC.PAC_PERIOD_ID = i_ae_txn_rec.accounting_period_id;
3693:
3694: IF g_debug_flag = 'Y' THEN
3695: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3696: ': Using PAC Absorption Cost: ' || l_pacp_pwac_cost);
3697: END IF;
3698:
3699: l_stmt_num := 272;
3819: IF (l_use_prev_period_cost = 1) THEN
3820: l_stmt_num := 282;
3821:
3822: IF g_debug_flag = 'Y' THEN
3823: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3824: ': Using prior period PWAC cost: ' || l_prev_period_pwac_cost);
3825: END IF;
3826:
3827: l_stmt_num := 285;
3990:
3991: IF (l_pd_txfr_ind = 1) THEN -- Process-Discrete X-fers
3992:
3993: IF g_debug_flag = 'Y' THEN
3994: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3995: ': Process-Discrete X-fers: ');
3996: END IF;
3997:
3998: SELECT mip.interorg_receivables_account,
4119:
4120:
4121: l_stmt_num := 340;
4122: IF g_debug_flag = 'Y' THEN
4123: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4124: ': Using MTA cost: ');
4125: END IF;
4126:
4127:
4345:
4346: l_tprice_option := 2; /* Make it 2 to ignore the CST Transfer Price profile */
4347:
4348: IF g_debug_flag = 'Y' THEN
4349: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ' ICR Set up:process-discrete xfer');
4350: END IF;
4351:
4352: END IF;
4353:
4369:
4370: l_stmt_num := 380;
4371:
4372: IF g_debug_flag = 'Y' THEN
4373: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4374: ': Receipt txn of Internal Order FOB Receipt - Sending Cost Group');
4375: END IF;
4376:
4377: IF (l_cg_exp_item <> 1) THEN
4382: -- Bug 5573993 - Derive the COGS account to break dependency on perpetual
4383: -- code as if the trxn is not costed, mmt has incorrect account stamped
4384:
4385: IF g_debug_flag = 'Y' THEN
4386: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4387: 'Deriving COGS account');
4388: END IF;
4389:
4390: l_stmt_num := 61;
4396: RAISE process_error;
4397: END IF;
4398:
4399: IF g_debug_flag = 'Y' THEN
4400: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4401: 'COGS Account ID: ' || l_cogs_account);
4402: END IF;
4403:
4404: -- Stamp all elemental accounts with the COGS account
4454:
4455: l_stmt_num := 395;
4456:
4457: IF g_debug_flag = 'Y' THEN
4458: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4459: ': Receipt txn of Internal Order FOB Receipt - Receiving Cost Group');
4460: END IF;
4461:
4462: /* Credit Intercompany Accrual Account */
4470: -- Bug 5573993 - Derive the Intercompany account to break dependency on perpetual
4471: -- code as if the trxn is not costed, mmt has incorrect or no account stamped
4472:
4473: IF g_debug_flag = 'Y' THEN
4474: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4475: 'Deriving intecompany account');
4476: END IF;
4477:
4478: l_accrual_account := get_intercompany_account (i_ae_txn_rec => i_ae_txn_rec,
4482: raise process_error;
4483: end if;
4484:
4485: IF g_debug_flag = 'Y' THEN
4486: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4487: 'Intercompany Account ID: ' || l_accrual_account);
4488: END IF;
4489:
4490: l_dr_flag := FALSE;
4520: FROM mtl_material_transactions MMT
4521: WHERE MMT.transaction_id = i_ae_txn_rec.transaction_id;
4522:
4523: IF g_debug_flag = 'Y' THEN
4524: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4525: ': Cr Intercompany Accrual @ : ' || l_transfer_price);
4526: END IF;
4527:
4528: l_ae_line_rec.account := l_accrual_account;
4546: IF (l_tprice_option = 2) THEN
4547: l_stmt_num := 402;
4548:
4549: IF g_debug_flag = 'Y' THEN
4550: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4551: ': CST: Transfer Price Option = Yes, Price As Incoming Cost');
4552: END IF;
4553:
4554: ELSIF (l_tprice_option = 1) THEN
4553:
4554: ELSIF (l_tprice_option = 1) THEN
4555: l_stmt_num := 404;
4556: IF g_debug_flag = 'Y' THEN
4557: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4558: ': CST: Transfer Price Option = Yes, Price Not As Incoming Cost');
4559: END IF;
4560:
4561: -- Debit/Credit Profit in Inventory
4655:
4656: l_stmt_num := 422;
4657:
4658: IF g_debug_flag = 'Y' THEN
4659: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4660: ': Receipt txn of Internal Order FOB Shipment - Receiving Cost Group');
4661: END IF;
4662:
4663:
4720:
4721: l_stmt_num := 426;
4722:
4723: IF g_debug_flag = 'Y' THEN
4724: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4725: ': Interorg Receipt transaction');
4726: END IF;
4727:
4728: IF ((i_ae_txn_rec.cost_group_id <> l_shipping_cg_id) AND l_fob_point = 2) THEN /* This is the receiving CG for FOBR */
4729:
4730: l_stmt_num := 428;
4731:
4732: IF g_debug_flag = 'Y' THEN
4733: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4734: ': Receipt txn of FOB Receipt - Receiving Cost Group');
4735: END IF;
4736:
4737: -- Processing the process-discrete txns
4742: WHERE MP.ORGANIZATION_ID = i_ae_txn_rec.xfer_organization_id
4743: OR MP.ORGANIZATION_ID = i_ae_txn_rec.organization_id;
4744:
4745: IF g_debug_flag = 'Y' THEN
4746: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4747: ': Process-isc Ind: ' || l_pd_txfr_ind);
4748: END IF;
4749:
4750: /* Process OPM-Discrete transfers here as the accouting distribution template is same INVCONV*/
4846:
4847: l_stmt_num := 445;
4848:
4849: IF g_debug_flag = 'Y' THEN
4850: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4851: ': Receipt txn of FOB Receipt - Shipping Cost Group');
4852: END IF;
4853:
4854: SELECT mip.interorg_receivables_account,
4971: AND CPIC.COST_GROUP_ID = i_ae_txn_rec.cost_group_id
4972: AND CPIC.PAC_PERIOD_ID = i_ae_txn_rec.accounting_period_id;
4973:
4974: IF g_debug_flag = 'Y' THEN
4975: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4976: ': Using PAC Absorption Cost: ' || l_pacp_pwac_cost);
4977: END IF;
4978:
4979: l_stmt_num := 492;
5093:
5094: IF (l_use_prev_period_cost = 1) THEN
5095:
5096: IF g_debug_flag = 'Y' THEN
5097: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
5098: ': Using prior period PWAC cost: ' || l_prev_period_pwac_cost);
5099: END IF;
5100:
5101: l_stmt_num := 505;
5246:
5247: l_stmt_num := 540;
5248:
5249: IF g_debug_flag = 'Y' THEN
5250: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
5251: ': Using MTA cost');
5252: END IF;
5253:
5254: /* Debit Receivables */
5417:
5418: l_stmt_num := 575;
5419:
5420: IF g_debug_flag = 'Y' THEN
5421: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
5422: ': Receipt txn of FOB Shipment - Receiving Cost Group');
5423: END IF;
5424:
5425: -- Processing the process-discrete txns
5430: WHERE MP.ORGANIZATION_ID = i_ae_txn_rec.xfer_organization_id
5431: OR MP.ORGANIZATION_ID = i_ae_txn_rec.organization_id;
5432:
5433: IF g_debug_flag = 'Y' THEN
5434: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
5435: ': Process-isc Ind: ' || l_pd_txfr_ind);
5436: END IF;
5437:
5438: IF (l_cg_exp_item <> 1) THEN
5491:
5492: l_stmt_num := 585;
5493:
5494: IF g_debug_flag = 'Y' THEN
5495: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
5496: ': Direct Interorg Receipt - Receiving Cost Group');
5497: END IF;
5498:
5499: /* Debit On-Hand and credit Payables */
5604:
5605: l_stmt_num := 605;
5606:
5607: IF g_debug_flag = 'Y' THEN
5608: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
5609: ': OPM-Discrete Logical Receipt');
5610: END IF;
5611:
5612: SELECT mip.interorg_payables_account,
5777: ELSIF (i_ae_txn_rec.txn_action_id = 22 and l_fob_point = 2) THEN
5778:
5779: l_stmt_num := 645;
5780: IF g_debug_flag = 'Y' THEN
5781: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
5782: ': OPM-Discrete Logical Shipment');
5783: END IF;
5784:
5785: SELECT mip.interorg_receivables_account,
5931:
5932: l_stmt_num := 700;
5933:
5934: IF g_debug_flag = 'Y' THEN
5935: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': return >>');
5936: END IF;
5937:
5938: EXCEPTION
5939:
5937:
5938: EXCEPTION
5939:
5940: when no_mfca_acct_error then -- INVCONV
5941: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Error processing transaction ' || i_ae_txn_rec.transaction_id);
5942: o_ae_err_rec.l_err_num := 30005;
5943: o_ae_err_rec.l_err_code := 'CST_PAC_NO_MFCA_ACCTS';
5944: FND_MESSAGE.set_name('BOM', 'CST_PAC_NO_MFCA_ACCTS');
5945: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
5944: FND_MESSAGE.set_name('BOM', 'CST_PAC_NO_MFCA_ACCTS');
5945: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
5946:
5947: when no_interorg_profit_acct_error then
5948: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Error processing transaction ' || i_ae_txn_rec.transaction_id);
5949: o_ae_err_rec.l_err_num := 30005;
5950: o_ae_err_rec.l_err_code := 'CST_NO_INTERORG_PROFIT_ACCT';
5951: FND_MESSAGE.set_name('BOM', 'CST_NO_INTERORG_PROFIT_ACCT');
5952: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
5951: FND_MESSAGE.set_name('BOM', 'CST_NO_INTERORG_PROFIT_ACCT');
5952: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
5953:
5954: when no_profit_in_inv_acct_error then
5955: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Error processing transaction ' || i_ae_txn_rec.transaction_id);
5956: o_ae_err_rec.l_err_num := 30005;
5957: o_ae_err_rec.l_err_code := 'CST_NO_PROFIT_INV_ACCT';
5958: FND_MESSAGE.set_name('BOM', 'CST_NO_PROFIT_INV_ACCT');
5959: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
6015: process_error EXCEPTION;
6016: BEGIN
6017:
6018: IF g_debug_flag = 'Y' THEN
6019: fnd_file.put_line(fnd_file.log,'Pcu_cost_txn <<');
6020: END IF;
6021:
6022: -- Initialize variables.
6023: -- ---------------------
6038: and cost_group_id = i_ae_txn_rec.cost_group_id
6039: and category_id = i_ae_txn_rec.category_id;
6040:
6041: if (l_acct_exist = 0) then
6042: fnd_file.put_line(fnd_file.log,'Category: '||to_char(i_ae_txn_rec.category_id) || ' has no accounts defined');
6043: raise no_mfca_acct_error;
6044: end if;
6045:
6046: -- Get the accounts from MFCA.
6292: raise process_error;
6293: end if;
6294:
6295: ELSE
6296: fnd_file.put_line(fnd_file.log,'No distributions created for Cost element ' || cost_element || ' as the associated cost is zero and Account is -1');
6297: END IF; -- for l_cost <> 0 or (l_cost=0 and account id exists)
6298: IF(l_onhand_var <> 0) THEN
6299: if (l_onhand_var > 0) then
6300: l_dr_flag := "TRUE";
6338: END IF;
6339: ELSE
6340: l_loop_count := l_loop_count + 1;
6341: IF g_debug_flag = 'Y' THEN
6342: fnd_file.put_line(fnd_file.log,'No cost for element ....');
6343: END IF;
6344: END IF;
6345: END LOOP;
6346:
6429: end if;
6430:
6431: end if;
6432: IF g_debug_flag = 'Y' THEN
6433: fnd_file.put_line(fnd_file.log,'Pcu_cost_txn <<');
6434: END IF;
6435:
6436: EXCEPTION
6437:
6491: l_ref_om_line_id NUMBER; -- Revenue / COGS Matching
6492: BEGIN
6493:
6494: IF g_debug_flag = 'Y' THEN
6495: fnd_file.put_line(fnd_file.log,'Inv_cost_txn <<');
6496: END IF;
6497: -- Initialize variables.
6498: -- ---------------------
6499: l_err_rec.l_err_num := 0;
6515: -- return and PO delivery adjustments.
6516:
6517: if ((i_ae_txn_rec.exp_item = 1 or l_exp_sub = 1) and (i_ae_txn_rec.txn_src_type_id <>1)) then
6518: IF g_debug_flag = 'Y' THEN
6519: fnd_file.put_line(fnd_file.log,'Expense item or expense sub - No accounting ');
6520: END IF;
6521: return;
6522: end if;
6523:
6572: l_acct_rec.ovhd_account := '';
6573:
6574: if (i_ae_txn_rec.txn_action_id in (4,8)) then
6575: IF g_debug_flag = 'Y' THEN
6576: fnd_file.put_line(fnd_file.log,'Cycle Count or Physical Inv Adjustment');
6577: END IF;
6578:
6579: /* cycle count adjustment and physical inventory adjustment */
6580: /* Use the distribution account id as stated in mmt. */
6587: elsif (i_ae_txn_rec.txn_action_id in (1,27,29) and i_ae_txn_rec.txn_src_type_id = 1) then
6588:
6589: /* PO Issue, Receipt, delivery adjustments. */
6590: IF g_debug_flag = 'Y' THEN
6591: fnd_file.put_line(fnd_file.log,'PO Issue, Receipt, delivery adjustments');
6592: END IF;
6593:
6594: l_acct_rec.account := i_ae_txn_rec.dist_acct_id;
6595: l_elemental := 0;
6650:
6651: IF (i_ae_txn_rec.txn_src_type_id = 12 AND l_ref_om_line_id IS NOT NULL AND l_count_so <> 0) then
6652: /* RMAs with Deferred COGS */
6653: IF g_debug_flag = 'Y' THEN
6654: fnd_file.put_line(fnd_file.log,'RMA with Deferred COGS');
6655: END IF;
6656:
6657: l_stmt_num := 35;
6658: -- Create the credit distributions to COGS and/or Deferred COGS
6674: ELSIF (i_ae_txn_rec.txn_src_type_id = 2 AND i_ae_txn_rec.so_issue_acct_type = 2) THEN
6675:
6676: /* Sales order issue with Deferred COGS */
6677: IF g_debug_flag = 'Y' THEN
6678: fnd_file.put_line(fnd_file.log,'Sales order issue ');
6679: END IF;
6680:
6681: l_stmt_num := 40;
6682: -- Get the Deferred COGS account
6696:
6697: ELSE
6698: /* Sales orders and RMAs with no deferred COGS */
6699: IF g_debug_flag = 'Y' THEN
6700: fnd_file.put_line(fnd_file.log,'Sales order, RMA and Rejection of RMA ');
6701: END IF;
6702:
6703: l_acct_rec.account := i_ae_txn_rec.dist_acct_id;
6704: if (l_acct_rec.account = -1) then
6729: elsif (i_ae_txn_rec.txn_action_id in (1,27,29) and i_ae_txn_rec.txn_src_type_id = 3) then
6730:
6731: /* Account */
6732: IF g_debug_flag = 'Y' THEN
6733: fnd_file.put_line(fnd_file.log,'Account txn');
6734: END IF;
6735:
6736: l_acct_rec.account := i_ae_txn_rec.txn_src_id;
6737: l_acct_line_type := 2;
6741: elsif (i_ae_txn_rec.txn_action_id in (1,27,29) and i_ae_txn_rec.txn_src_type_id = 6) then
6742:
6743: /* Account Alias*/
6744: IF g_debug_flag = 'Y' THEN
6745: fnd_file.put_line(fnd_file.log,'Account Alias txn ');
6746: END IF;
6747:
6748: l_stmt_num := 60;
6749:
6760: elsif (i_ae_txn_rec.txn_action_id = 6 and i_ae_txn_rec.txn_src_type_id in (1, 13)) then
6761:
6762: /* Transfer to regular/consigned */
6763: IF g_debug_flag = 'Y' THEN
6764: fnd_file.put_line(fnd_file.log,'Transfer to regular/consigned');
6765: END IF;
6766:
6767: l_acct_rec.account := i_ae_txn_rec.dist_acct_id;
6768: l_acct_line_type := 16;
6772: else
6773:
6774: /* Misc issue, receipt, default*/
6775: IF g_debug_flag = 'Y' THEN
6776: fnd_file.put_line(fnd_file.log,'Misc issue, receipt');
6777: END IF;
6778:
6779: l_acct_rec.account := i_ae_txn_rec.dist_acct_id;
6780: l_acct_line_type := 2;
6830: end if;
6831:
6832: <
6833: IF g_debug_flag = 'Y' THEN
6834: fnd_file.put_line(fnd_file.log,'Inv_cost_txn >> ');
6835: END IF;
6836:
6837: EXCEPTION
6838:
6882: /* Bug12914738 */
6883: BEGIN
6884:
6885: IF g_debug_flag = 'Y' THEN
6886: fnd_file.put_line(fnd_file.log,'Cost_logical_txn <<');
6887: END IF;
6888: -- Initialize variables.
6889: -- ---------------------
6890: l_err_rec.l_err_num := 0;
6932: if ((i_ae_txn_rec.exp_item = 1 or l_exp_sub = 1) and
6933: ((i_ae_txn_rec.txn_action_id = 26 and i_ae_txn_rec.txn_src_type_id = 12) OR
6934: (i_ae_txn_rec.txn_action_id = 7 and i_ae_txn_rec.txn_src_type_id = 2))) then
6935: IF g_debug_flag = 'Y' THEN
6936: fnd_file.put_line(fnd_file.log,'Expense item or expense sub - No accounting ');
6937: END IF;
6938: return;
6939: end if;
6940:
7021: IF (i_ae_txn_rec.txn_type_id = 16 AND l_ref_om_line_id IS NOT NULL) then
7022:
7023: /* RMAs with Deferred COGS */
7024: IF g_debug_flag = 'Y' THEN
7025: fnd_file.put_line(fnd_file.log,'RMA with Deferred COGS');
7026: END IF;
7027:
7028: l_stmt_num := 40;
7029: -- Create the credit distributions to COGS and/or Deferred COGS
7111: ELSIF (i_ae_txn_rec.txn_type_id = 30 AND i_ae_txn_rec.so_issue_acct_type = 2) THEN
7112:
7113: /* Sales order issue with Deferred COGS */
7114: IF g_debug_flag = 'Y' THEN
7115: fnd_file.put_line(fnd_file.log,'Sales order issue ');
7116: END IF;
7117:
7118: l_stmt_num := 50;
7119: -- Get the Deferred COGS account
7127:
7128: ELSE
7129: /* Logical Sales orders and RMAs with no deferred COGS */
7130: IF g_debug_flag = 'Y' THEN
7131: fnd_file.put_line(fnd_file.log,'Logical Sales order, RMA and Rejection of RMA ');
7132: END IF;
7133:
7134: l_acct_rec.account := i_ae_txn_rec.dist_acct_id;
7135: l_acct_line_type := 35;
7167:
7168: <
7169:
7170: IF g_debug_flag = 'Y' THEN
7171: fnd_file.put_line(fnd_file.log,'cost_logical_txn out ');
7172: END IF;
7173:
7174: EXCEPTION
7175:
7217:
7218: BEGIN
7219:
7220: IF g_debug_flag = 'Y' THEN
7221: fnd_file.put_line(fnd_file.log,'Cost_consigned_txn <<');
7222: END IF;
7223: -- Initialize variables.
7224: -- ---------------------
7225: l_err_rec.l_err_num := 0;
7328: end if;
7329:
7330:
7331: IF g_debug_flag = 'Y' THEN
7332: fnd_file.put_line(fnd_file.log,'Cost_consigned_update_txn >> ');
7333: END IF;
7334:
7335: EXCEPTION
7336:
7370: process_error exception;
7371: l_err_rec CSTPALTY.cst_ae_err_rec_type;
7372: BEGIN
7373: IF g_debug_flag = 'Y' THEN
7374: fnd_file.put_line(fnd_file.log,'Encumbrance_account <<');
7375: END IF;
7376: -- Initialize variables.
7377: -- ---------------------
7378: l_err_rec.l_err_num := 0;
7407: raise process_error;
7408: end if;
7409:
7410: IF g_debug_flag = 'Y' THEN
7411: fnd_file.put_line(fnd_file.log,'Encumbrance_account <<');
7412: END IF;
7413:
7414: EXCEPTION
7415:
7467: no_txn_det_error EXCEPTION;
7468: BEGIN
7469:
7470: IF g_debug_flag = 'Y' THEN
7471: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin <<');
7472: END IF;
7473: -- initialize variables.
7474: -- ---------------------
7475: l_err_rec.l_err_num := 0;
7487: and cost_group_id = i_ae_txn_rec.cost_group_id
7488: and category_id = i_ae_txn_rec.category_id;
7489:
7490: if (l_acct_exist = 0) then
7491: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num ||
7492: ': Category : '||to_char(i_ae_txn_rec.category_id) ||' has no accounts defined');
7493: raise no_mfca_acct_error;
7494: end if;
7495:
7578:
7579: if i_exp_flag then
7580: l_ae_line_rec.account := l_expense_account;
7581: IF g_debug_flag = 'Y' THEN
7582: FND_FILE.PUT_LINE(FND_FILE.LOG, l_api_name || ': ' || l_stmt_num || ': Expense Account: '||to_char(l_expense_account));
7583: END IF;
7584: else
7585: /* changed for bug no. 4586534 */
7586: IF cost_element = 1 THEN
7616: l_ae_line_rec.resource_id := NULL;
7617: l_ae_line_rec.cost_element_id := cost_element;
7618:
7619: IF g_debug_flag = 'Y' THEN
7620: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': Insert element ' || cost_element);
7621: END IF;
7622:
7623: insert_account (i_ae_txn_rec,
7624: i_ae_curr_rec,
7633: end if;
7634:
7635: else
7636: IF g_debug_flag = 'Y' THEN
7637: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': No cost for element ' || cost_element);
7638: END IF;
7639: end if;
7640:
7641: end loop;
7649: and pac_period_id = i_ae_txn_rec.accounting_period_id
7650: and cost_group_id = i_ae_txn_rec.cost_group_id;
7651:
7652: IF (l_var <> 0 AND (NOT i_exp_flag)) THEN
7653: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Creating Variance Entry');
7654: l_stmt_num := 60;
7655: l_ae_line_rec.ae_line_type := 13;
7656:
7657: IF (l_var > 0)
7685: /* Bug 3213936 : End */
7686:
7687:
7688: IF g_debug_flag = 'Y' THEN
7689: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': return >>');
7690: END IF;
7691:
7692: EXCEPTION
7693:
7754: no_txn_det_error EXCEPTION;
7755: l_api_name CONSTANT VARCHAR2(30) := 'CSTPAPBR.offset_accounts';
7756: BEGIN
7757: IF g_debug_flag = 'Y' THEN
7758: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin << ');
7759: FND_FILE.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': Elemental flag: ' ||to_char(i_elemental));
7760: END IF;
7761: -- initialize variables.
7762: -- ---------------------
7755: l_api_name CONSTANT VARCHAR2(30) := 'CSTPAPBR.offset_accounts';
7756: BEGIN
7757: IF g_debug_flag = 'Y' THEN
7758: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin << ');
7759: FND_FILE.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': Elemental flag: ' ||to_char(i_elemental));
7760: END IF;
7761: -- initialize variables.
7762: -- ---------------------
7763: l_err_rec.l_err_num := 0;
7863: end if;
7864:
7865: else
7866: IF g_debug_flag = 'Y' THEN
7867: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || 'No cost for element ' || cost_element);
7868: END IF;
7869: end if;
7870: end loop;
7871: else
7925: raise process_error;
7926: end if;
7927: else
7928: IF g_debug_flag = 'Y' THEN
7929: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || 'No Cost');
7930: END IF;
7931: end if;
7932: end if;
7933: IF g_debug_flag = 'Y' THEN
7930: END IF;
7931: end if;
7932: end if;
7933: IF g_debug_flag = 'Y' THEN
7934: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': return >>');
7935: END IF;
7936:
7937: EXCEPTION
7938:
7984:
7985:
7986: BEGIN
7987: IF g_debug_flag = 'Y' THEN
7988: fnd_file.put_line(fnd_file.log,'Ovhd_accounts << ');
7989: END IF;
7990:
7991: -- Initialize variables.
7992: -- ---------------------
8076: end if;
8077:
8078: end loop;
8079: IF g_debug_flag = 'Y' THEN
8080: fnd_file.put_line(fnd_file.log,'Ovhd_accounts >>');
8081: END IF;
8082:
8083: EXCEPTION
8084:
8123: l_api_name CONSTANT VARCHAR2(30) := 'CSTPAPBR.insert_account';
8124:
8125: BEGIN
8126: IF g_debug_flag = 'Y' THEN
8127: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin << ');
8128: END IF;
8129:
8130: -- Initialize variables.
8131: -- ---------------------
8241: l_ae_line_tbl(next_record_avail).accounted_dr := l_accounted_value;
8242: l_ae_line_tbl(next_record_avail).accounted_cr := NULL;
8243:
8244: IF g_debug_flag = 'Y' THEN
8245: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': Debit: ' ||
8246: l_ae_line_tbl(next_record_avail).description || ' ' || l_accounted_value);
8247: END IF;
8248: else
8249: l_ae_line_tbl(next_record_avail).entered_cr := nvl(l_entered_value,l_accounted_value);
8251: l_ae_line_tbl(next_record_avail).accounted_cr := l_accounted_value;
8252: l_ae_line_tbl(next_record_avail).accounted_dr := NULL;
8253:
8254: IF g_debug_flag = 'Y' THEN
8255: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': Credit: ' ||
8256: l_ae_line_tbl(next_record_avail).description || ' ' || l_accounted_value);
8257: END IF;
8258:
8259: end if;
8275: l_ae_line_tbl(next_record_avail).rate_or_amount := abs(i_ae_line_rec.transaction_value/i_ae_txn_rec.primary_quantity);
8276: END IF;
8277:
8278: IF g_debug_flag = 'Y' THEN
8279: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': Rate or amount: ' ||
8280: l_ae_line_tbl(next_record_avail).rate_or_amount);
8281: END IF;
8282:
8283: l_ae_line_tbl(next_record_avail).basis_type := 1;
8318: end if;
8319: end if;
8320:
8321: IF g_debug_flag = 'Y' THEN
8322: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': return >> ');
8323: END IF;
8324:
8325: EXCEPTION
8326:
8353: l_stmt_num NUMBER := 0;
8354: l_api_name CONSTANT VARCHAR2(30) := 'CSTPAPBR.balance_account';
8355: BEGIN
8356: IF g_debug_flag = 'Y' THEN
8357: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin << ');
8358: END IF;
8359:
8360: if (l_ae_line_tbl.exists(1)) then
8361: l_stmt_num := 10;
8365: end loop;
8366:
8367: if (l_ent_value = 0 and l_acc_value = 0) then
8368: IF g_debug_flag = 'Y' THEN
8369: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': return >> No balancing done.');
8370: END IF;
8371: return;
8372: end if;
8373:
8378: l_ae_line_tbl(l_last_rec).accounted_dr - l_acc_value;
8379: l_ae_line_tbl(l_last_rec).entered_dr :=
8380: l_ae_line_tbl(l_last_rec).entered_dr - l_ent_value;
8381: IF g_debug_flag = 'Y' THEN
8382: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': adjust debit by: ' || l_acc_value);
8383: END IF;
8384: elsif l_ae_line_tbl(l_last_rec).accounted_cr is not NULL then
8385: l_ae_line_tbl(l_last_rec).accounted_cr :=
8386: l_ae_line_tbl(l_last_rec).accounted_cr + l_acc_value;
8386: l_ae_line_tbl(l_last_rec).accounted_cr + l_acc_value;
8387: l_ae_line_tbl(l_last_rec).entered_cr :=
8388: l_ae_line_tbl(l_last_rec).entered_cr + l_ent_value;
8389: IF g_debug_flag = 'Y' THEN
8390: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': adjust credit by: ' || l_acc_value);
8391: END IF;
8392: end if;
8393: end if;
8394:
8392: end if;
8393: end if;
8394:
8395: IF g_debug_flag = 'Y' THEN
8396: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': return >> ');
8397: END IF;
8398:
8399: EXCEPTION
8400:
8467: and cost_element_id = l_cost_element;
8468:
8469: BEGIN
8470: IF g_debug_flag = 'Y' THEN
8471: fnd_file.put_line(fnd_file.log,'Create_wip_lines << ');
8472: fnd_file.put_line(fnd_file.log,'Transaction type: '||to_char(i_ae_txn_rec.txn_type_id));
8473: END IF;
8474:
8475: -- Initialize local variables.
8468:
8469: BEGIN
8470: IF g_debug_flag = 'Y' THEN
8471: fnd_file.put_line(fnd_file.log,'Create_wip_lines << ');
8472: fnd_file.put_line(fnd_file.log,'Transaction type: '||to_char(i_ae_txn_rec.txn_type_id));
8473: END IF;
8474:
8475: -- Initialize local variables.
8476: -- ---------------------------
8556: x_cost_element_id => l_cost_element
8557: );
8558:
8559: IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
8560: FND_FILE.put_line(FND_FILE.log, l_msg_data);
8561: l_api_message := 'get_CostEle_for_DirectItem returned unexpected error';
8562: FND_MESSAGE.set_name('BOM','CST_API_MESSAGE');
8563: FND_MESSAGE.set_token('TEXT', l_api_message);
8564: FND_MSG_pub.add;
8565: raise fnd_api.g_exc_unexpected_error;
8566: END IF;
8567:
8568: IF (g_debug_flag = 'Y') THEN
8569: FND_FILE.PUT_LINE(FND_FILE.LOG, 'mfg cost_element_id: '||
8570: to_char(l_cost_element));
8571: END IF;
8572:
8573: l_stmt_num := 40;
8840: mtl_parameters
8841: where organization_id = i_ae_txn_rec.organization_id;
8842:
8843: IF g_debug_flag = 'Y' THEN
8844: fnd_file.put_line(fnd_file.log,'Organization_id : '||(i_ae_txn_rec.organization_id));
8845: fnd_file.put_line(fnd_file.log,'l_enc_rev : '||(l_enc_rev));
8846: fnd_file.put_line(fnd_file.log,'transaction_id : '||(i_ae_txn_rec.transaction_id));
8847: END IF;
8848:
8841: where organization_id = i_ae_txn_rec.organization_id;
8842:
8843: IF g_debug_flag = 'Y' THEN
8844: fnd_file.put_line(fnd_file.log,'Organization_id : '||(i_ae_txn_rec.organization_id));
8845: fnd_file.put_line(fnd_file.log,'l_enc_rev : '||(l_enc_rev));
8846: fnd_file.put_line(fnd_file.log,'transaction_id : '||(i_ae_txn_rec.transaction_id));
8847: END IF;
8848:
8849: if (l_enc_rev = 1 and nvl(i_ae_txn_rec.encum_amount,0) <> 0) THEN
8842:
8843: IF g_debug_flag = 'Y' THEN
8844: fnd_file.put_line(fnd_file.log,'Organization_id : '||(i_ae_txn_rec.organization_id));
8845: fnd_file.put_line(fnd_file.log,'l_enc_rev : '||(l_enc_rev));
8846: fnd_file.put_line(fnd_file.log,'transaction_id : '||(i_ae_txn_rec.transaction_id));
8847: END IF;
8848:
8849: if (l_enc_rev = 1 and nvl(i_ae_txn_rec.encum_amount,0) <> 0) THEN
8850: l_ae_enc_curr_rec.pri_currency := l_ae_curr_rec.pri_currency;
8884: -- ------------------------------
8885: l_stmt_num := 240;
8886: o_ae_line_rec_tbl := l_ae_line_tbl;
8887: IF g_debug_flag = 'Y' THEN
8888: fnd_file.put_line(fnd_file.log,'Create_wip_ae_lines >>');
8889: END IF;
8890:
8891: EXCEPTION
8892:
8939: process_error EXCEPTION;
8940: BEGIN
8941:
8942: IF g_debug_flag = 'Y' THEN
8943: fnd_file.put_line(fnd_file.log,'Get_accts <<');
8944: END IF;
8945:
8946: IF i_ae_txn_rec.txn_type_id <> 6 THEN
8947:
8989: where we.wip_entity_id = wt.wip_entity_id
8990: and wt.transaction_id = i_ae_txn_rec.transaction_id;
8991:
8992: IF g_debug_flag = 'Y' THEN
8993: fnd_file.put_line(fnd_file.log, 'Entity Type: ' ||to_char(l_entity_type));
8994: END IF;
8995:
8996: /* Bug 6937298 - Modified the If condition below to include lot-based jobs
8997: if (i_ae_txn_rec.txn_type_id <> 6 and l_entity_type in (1,3, 6, 7)) or
9094: from wip_flow_schedules
9095: where wip_entity_id = l_wip_entity_id;
9096: end if;
9097: IF g_debug_flag = 'Y' THEN
9098: fnd_file.put_line(fnd_file.log,'Get_accts >>');
9099: END IF;
9100:
9101: EXCEPTION
9102:
9161: process_error EXCEPTION;
9162: no_txn_det_error EXCEPTION;
9163: BEGIN
9164: IF g_debug_flag = 'Y' THEN
9165: fnd_file.put_line(fnd_file.log,'WIP_accounts << ');
9166: END IF;
9167: -- initialize variables.
9168: -- ---------------------
9169: l_err_rec.l_err_num := 0;
9292: RAISE process_error;
9293: END IF;
9294: ELSE
9295: IF g_debug_flag = 'Y' THEN
9296: fnd_file.put_line(fnd_file.log,'No Cost for element...');
9297: END IF;
9298: END IF;
9299:
9300: ---------------------------------------------------------------------------------------
9365: END IF; -- End of IF l_wip_variance <> 0
9366: END LOOP;
9367:
9368: IF g_debug_flag = 'Y' THEN
9369: fnd_file.put_line(fnd_file.log,'WIP_accounts >>');
9370: END IF;
9371:
9372: EXCEPTION
9373:
9441:
9442: l_inv_ccid := -1;
9443:
9444: IF g_debug_flag = 'Y' THEN
9445: fnd_file.put_line(fnd_file.log,'Get_Intercompany_account << ');
9446: END IF;
9447:
9448: l_stmt_num := 5;
9449: SELECT MOD(SUM(DECODE(MP.process_enabled_flag,'Y',1,2)), 2)
9452: WHERE mp.organization_id = i_ae_txn_rec.organization_id
9453: OR mp.organization_id = i_ae_txn_rec.xfer_organization_id;
9454:
9455: IF g_debug_flag = 'Y' THEN
9456: FND_FILE.put_line(FND_FILE.LOG, 'l_pd_txfr_ind:' || l_pd_txfr_ind);
9457: END IF;
9458:
9459: l_stmt_num := 7;
9460:
9478: l_shipping_cg_id := -1;
9479: END;
9480:
9481: IF g_debug_flag = 'Y' THEN
9482: FND_FILE.put_line(FND_FILE.LOG, 'l_shipping_cg_id:' || l_shipping_cg_id);
9483: END IF;
9484:
9485: if (i_ae_txn_rec.txn_action_id in (21, 22)) then
9486: l_from_org := i_ae_txn_rec.organization_id;
9529: WHERE org_information_context = 'Accounting Information'
9530: AND organization_id = l_to_org;
9531:
9532: if (g_debug_flag = 'Y') then
9533: FND_FILE.put_line(FND_FILE.LOG, 'l_from_ou = ' || l_from_ou ||
9534: ' l_to_ou = ' || l_to_ou || ' l_rcv_coa_id = ' || l_rcv_coa_id);
9535: end if;
9536:
9537: if (i_ae_txn_rec.txn_action_id in (15, 21)) then
9619:
9620: end if;
9621:
9622: if (g_debug_flag = 'Y') then
9623: FND_FILE.put_line(FND_FILE.LOG, 'l_cogs_ccid = ' || l_cogs_ccid);
9624: end if;
9625:
9626: /* Return COGS Account */
9627: l_acct_ccid := l_cogs_ccid;
9647: RAISE inv_exp_acct_err;
9648: END IF;
9649:
9650: if (g_debug_flag = 'Y') then
9651: FND_FILE.put_line(FND_FILE.LOG, 'l_inv_ccid = ' || l_inv_ccid);
9652: end if;
9653:
9654: /* Return IC Accrual Account */
9655: l_acct_ccid := l_inv_ccid;
9657: end if;
9658:
9659:
9660: IF g_debug_flag = 'Y' THEN
9661: FND_FILE.put_line(FND_FILE.LOG, 'l_acct_ccid = ' || l_acct_ccid);
9662: fnd_file.put_line(fnd_file.log,'Get_Intercompany_account >>');
9663: END IF;
9664:
9665: return l_acct_ccid;
9658:
9659:
9660: IF g_debug_flag = 'Y' THEN
9661: FND_FILE.put_line(FND_FILE.LOG, 'l_acct_ccid = ' || l_acct_ccid);
9662: fnd_file.put_line(fnd_file.log,'Get_Intercompany_account >>');
9663: END IF;
9664:
9665: return l_acct_ccid;
9666:
9774:
9775: BEGIN
9776:
9777: IF g_debug_flag = 'Y' THEN
9778: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin <<'
9779: || ' transaction_id: ' || i_ae_txn_rec.transaction_id);
9780: END IF;
9781:
9782: -- Initialize variables.
9789:
9790: l_stmt_num := 10;
9791:
9792: IF g_debug_flag = 'Y' THEN
9793: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': return >> ' ||
9794: '(No accounting for Expense item)');
9795: END IF;
9796:
9797: RETURN;
9841: AND category_id = i_ae_txn_rec.category_id;
9842: EXCEPTION
9843: WHEN no_data_found THEN
9844: l_stmt_num := 70;
9845: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num ||
9846: ': Category : '||to_char(i_ae_txn_rec.category_id) ||' has no accounts defined');
9847: RAISE no_mfca_acct_error;
9848: END;
9849:
9866:
9867: l_stmt_num := 90;
9868:
9869: IF g_debug_flag = 'Y' THEN
9870: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
9871: ': cost_group_id = ' || i_ae_txn_rec.cost_group_id ||
9872: ': txn_cost_group_id ' || l_txn_cost_group_id ||
9873: ': txfr_txn_cost_group_id ' || l_txfr_txn_cost_group_id);
9874: END IF;
9880:
9881: l_stmt_num := 100;
9882:
9883: IF g_debug_flag = 'Y' THEN
9884: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Transfer Within Same Cost Group');
9885: END IF;
9886:
9887: -- Case I Dis-Dis, same CG, treat as SubInv transfer
9888: -- Internal Order Issue 34-1-8 :
9893: IF (i_ae_txn_rec.txn_action_id = 1) then
9894: /* If the internal order issue is from expense sub then no accounting for Int Order Issue and Corresponding Logical Expense Requisition Receipt in case of Disc to Disc */
9895: IF(l_exp_flag) THEN
9896: IF g_debug_flag = 'Y' THEN
9897: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': No Accounting for Internal Order Issue from Expense Sub ');
9898: END IF;
9899: RETURN;
9900: END IF;
9901:
9901:
9902: l_stmt_num := 110;
9903:
9904: IF g_debug_flag = 'Y' THEN
9905: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': 34-1-8 Dr Expense and Cr Inv');
9906: END IF;
9907:
9908: l_dr_flag := TRUE;
9909:
9987: l_stmt_num := 170;
9988: /* If the internal order issue is from expense sub then no accounting for Int Order Issue and Corresponding Logical Expense Requisition Receipt in case of Disc to Disc */
9989: IF(l_exp_flag) THEN
9990: IF g_debug_flag = 'Y' THEN
9991: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': No Accounting for Logical Int Req Receipt for Internal Order Issue from Expense Sub ');
9992: END IF;
9993: RETURN;
9994: END IF;
9995:
9993: RETURN;
9994: END IF;
9995:
9996: IF g_debug_flag = 'Y' THEN
9997: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': 27-17-7 No accounting');
9998: END IF;
9999:
10000: END IF;
10001:
10003:
10004: l_stmt_num := 180;
10005:
10006: IF g_debug_flag = 'Y' THEN
10007: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Transfer across Cost Group');
10008: END IF;
10009:
10010: /* Check if it is a transfer between Process and Discrete Orgs */
10011: SELECT MOD(SUM(DECODE(process_enabled_flag,'Y',1,2)), 2)
10020:
10021: l_stmt_num := 200;
10022:
10023: IF g_debug_flag = 'Y' THEN
10024: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Discrete-Discrete X-fer');
10025: END IF;
10026:
10027: IF (i_ae_txn_rec.txn_action_id = 1) THEN
10028: /* If the internal order issue is from expense sub then no accounting for Int Order Issue and Corresponding Logical Expense Requisition Receipt in case of Disc to Disc */
10027: IF (i_ae_txn_rec.txn_action_id = 1) THEN
10028: /* If the internal order issue is from expense sub then no accounting for Int Order Issue and Corresponding Logical Expense Requisition Receipt in case of Disc to Disc */
10029: IF(l_exp_flag) THEN
10030: IF g_debug_flag = 'Y' THEN
10031: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': No Accounting for Logical Int Req Receipt for Internal Order Issue from Expense Sub ');
10032: END IF;
10033: RETURN;
10034: END IF;
10035:
10110:
10111: IF (l_pacp_flag = 1) THEN
10112: l_stmt_num := 250;
10113: IF g_debug_flag = 'Y' THEN
10114: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
10115: ': Using PAC Absorption Cost: ');
10116: END IF;
10117:
10118: l_io_rcv_value := l_pacp_pwac_cost;
10119:
10120: ELSIF (l_prev_period_flag = 1) THEN
10121: l_stmt_num := 260;
10122: IF g_debug_flag = 'Y' THEN
10123: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
10124: ': Using prior period PWAC cost: ');
10125: END IF;
10126:
10127: l_io_rcv_value := l_prev_period_pwac_cost;
10128:
10129: ELSIF (l_perp_ship_flag = 1) THEN
10130: l_stmt_num := 270;
10131: IF g_debug_flag = 'Y' THEN
10132: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
10133: ': Using MTA cost');
10134: END IF;
10135:
10136: l_io_rcv_value := (l_perp_ship_value / abs(i_ae_txn_rec.primary_quantity));
10139:
10140: l_stmt_num := 280;
10141:
10142: IF g_debug_flag = 'Y' THEN
10143: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': PACP/PriorPrd/MTA value not returned');
10144: END IF;
10145:
10146: raise process_error;
10147: END IF; /* (l_pacp_flag = 1) */
10150:
10151: l_dr_flag := TRUE;
10152:
10153: IF g_debug_flag = 'Y' THEN
10154: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
10155: ': l_io_rcv_value = ' || l_io_rcv_value);
10156: END IF;
10157:
10158: l_ae_line_rec.account := l_io_rcv_acct;
10236: ELSIF (i_ae_txn_rec.txn_action_id = 17) THEN
10237: /* If the internal order issue is from expense sub then no accounting for Int Order Issue and Corresponding Logical Expense Requisition Receipt in case of Disc to Disc */
10238: IF(l_exp_flag) THEN
10239: IF g_debug_flag = 'Y' THEN
10240: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': No Accounting for Logical Int Req Receipt for Internal Order Issue from Expense Sub ');
10241: END IF;
10242: RETURN;
10243: END IF;
10244:
10248: -- Cr. Payables @ Sending Org cost (from CPIC/Prior Prd PWAC/PerpMTA)
10249:
10250: l_stmt_num := 370;
10251: IF g_debug_flag = 'Y' THEN
10252: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': 27-17-7 Dr Exp and Cr Paybls');
10253: END IF;
10254:
10255: SELECT mip.interorg_payables_account,
10256: distribution_account_id
10284:
10285: IF (l_pacp_flag = 1) THEN
10286: l_stmt_num := 400;
10287: IF g_debug_flag = 'Y' THEN
10288: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
10289: ': Using PAC Absorption Cost: ');
10290: END IF;
10291:
10292: l_io_pay_value := l_pacp_pwac_cost;
10293:
10294: ELSIF (l_prev_period_flag = 1) THEN
10295: l_stmt_num := 410;
10296: IF g_debug_flag = 'Y' THEN
10297: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
10298: ': Using prior period PWAC cost: ');
10299: END IF;
10300:
10301: l_io_pay_value := l_prev_period_pwac_cost;
10302:
10303: ELSIF (l_perp_ship_flag = 1) THEN
10304: l_stmt_num := 420;
10305: IF g_debug_flag = 'Y' THEN
10306: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
10307: ': Using MTA cost');
10308: END IF;
10309:
10310: l_io_pay_value := (l_perp_ship_value / abs(i_ae_txn_rec.primary_quantity));
10313:
10314: l_stmt_num := 430;
10315:
10316: IF g_debug_flag = 'Y' THEN
10317: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': PACP/PriorPrd/MTA value not returned');
10318: END IF;
10319:
10320: RAISE process_error;
10321:
10325:
10326: l_dr_flag := FALSE;
10327:
10328: IF g_debug_flag = 'Y' THEN
10329: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
10330: ': l_io_pay_value = ' || l_io_pay_value);
10331: END IF;
10332:
10333: l_ae_line_rec.account := l_io_pay_acct;
10386:
10387: l_stmt_num := 500;
10388:
10389: IF g_debug_flag = 'Y' THEN
10390: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Process-Discrete X-fer');
10391: END IF;
10392:
10393: IF (i_ae_txn_rec.txn_action_id = 1) then
10394: -- Case IV Dis-OPM Xfer, Discrete is Sending CG
10399:
10400: l_stmt_num := 510;
10401:
10402: IF g_debug_flag = 'Y' THEN
10403: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': 34-1-8 Dr Rcv and Cr Inv');
10404: END IF;
10405:
10406: /* Debit Receivables @ Transfer Price */
10407:
10532:
10533: l_stmt_num := 620;
10534:
10535: IF g_debug_flag = 'Y' THEN
10536: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': 27-17-7 Dr Exp and Cr Paybls');
10537: END IF;
10538:
10539: SELECT mip.interorg_payables_account,
10540: distribution_account_id,
10606:
10607: l_stmt_num := 680;
10608:
10609: IF g_debug_flag = 'Y' THEN
10610: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': return >>');
10611: END IF;
10612:
10613: EXCEPTION
10614:
10612:
10613: EXCEPTION
10614:
10615: when no_mfca_acct_error then -- INVCONV
10616: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Error processing transaction ' || i_ae_txn_rec.transaction_id);
10617: o_ae_err_rec.l_err_num := 30005;
10618: o_ae_err_rec.l_err_code := 'CST_PAC_NO_MFCA_ACCTS';
10619: FND_MESSAGE.set_name('BOM', 'CST_PAC_NO_MFCA_ACCTS');
10620: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
10619: FND_MESSAGE.set_name('BOM', 'CST_PAC_NO_MFCA_ACCTS');
10620: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
10621:
10622: when no_interorg_profit_acct_error then
10623: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Error processing transaction ' || i_ae_txn_rec.transaction_id);
10624: o_ae_err_rec.l_err_num := 30005;
10625: o_ae_err_rec.l_err_code := 'CST_NO_INTERORG_PROFIT_ACCT';
10626: FND_MESSAGE.set_name('BOM', 'CST_NO_INTERORG_PROFIT_ACCT');
10627: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
10686:
10687: BEGIN
10688:
10689: IF g_debug_flag = 'Y' THEN
10690: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin <<<'
10691: || ' transaction_id: ' || i_ae_txn_rec.transaction_id);
10692: END IF;
10693:
10694: -- Initialize variables.
10791: AND CPIC.COST_GROUP_ID = i_ae_txn_rec.cost_group_id
10792: AND CPIC.PAC_PERIOD_ID = i_ae_txn_rec.accounting_period_id;
10793: END IF;
10794: IF g_debug_flag = 'Y' THEN
10795: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
10796: ': Using PAC Absorption Cost: ');
10797: END IF;
10798:
10799: IF (l_txfr_percent <> 0) THEN
10856:
10857: o_prev_period_flag := 1;
10858:
10859: IF g_debug_flag = 'Y' THEN
10860: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
10861: ': Using prior period PWAC cost: ');
10862: END IF;
10863:
10864: l_stmt_num := 200;
10876:
10877: o_perp_ship_flag := 1;
10878:
10879: IF g_debug_flag = 'Y' THEN
10880: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
10881: ': Using MTA cost');
10882: END IF;
10883:
10884: BEGIN
10929: END IF; /* End Same LE PACP available */
10930:
10931: l_stmt_num := 260;
10932: IF g_debug_flag = 'Y' THEN
10933: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num
10934: || ': o_pacp_flag :' || o_pacp_flag
10935: || ': o_pacp_pwac_cost :' || o_pacp_pwac_cost
10936: || ': o_prev_period_flag :' || o_prev_period_flag
10937: || ': o_prev_period_pwac_cost :' || o_prev_period_pwac_cost
10937: || ': o_prev_period_pwac_cost :' || o_prev_period_pwac_cost
10938: || ': o_perp_ship_flag :' || o_perp_ship_flag
10939: || ': o_perp_ship_value :' || o_perp_ship_value
10940: || ': o_txfr_credit :' || o_txfr_credit);
10941: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': return >>>' );
10942: END IF;
10943:
10944: EXCEPTION
10945:
10999: l_hook_used :=0;
11000: l_stmt_num := 5;
11001:
11002: IF g_debug_flag= 'Y' THEN
11003: FND_FILE.PUT_LINE( FND_FILE.log, 'CompEncumbrance_IntOrdersExp <<< ');
11004: FND_FILE.PUT_LINE( FND_FILE.log, 'Req Line Identifier: '||p_req_line_id);
11005: FND_FILE.PUT_LINE( FND_FILE.log, 'Primary Quantity Encumbered before: '||p_total_primary_qty );
11006: END IF;
11007:
11000: l_stmt_num := 5;
11001:
11002: IF g_debug_flag= 'Y' THEN
11003: FND_FILE.PUT_LINE( FND_FILE.log, 'CompEncumbrance_IntOrdersExp <<< ');
11004: FND_FILE.PUT_LINE( FND_FILE.log, 'Req Line Identifier: '||p_req_line_id);
11005: FND_FILE.PUT_LINE( FND_FILE.log, 'Primary Quantity Encumbered before: '||p_total_primary_qty );
11006: END IF;
11007:
11008: /* 1. Get the budget_account, quantity ordered, and UOM from the Req */
11001:
11002: IF g_debug_flag= 'Y' THEN
11003: FND_FILE.PUT_LINE( FND_FILE.log, 'CompEncumbrance_IntOrdersExp <<< ');
11004: FND_FILE.PUT_LINE( FND_FILE.log, 'Req Line Identifier: '||p_req_line_id);
11005: FND_FILE.PUT_LINE( FND_FILE.log, 'Primary Quantity Encumbered before: '||p_total_primary_qty );
11006: END IF;
11007:
11008: /* 1. Get the budget_account, quantity ordered, and UOM from the Req */
11009: l_stmt_num := 10;
11024: and rd.requisition_line_id = rl.requisition_line_id
11025: and rl.UNIT_MEAS_LOOKUP_CODE = um.unit_of_measure;
11026:
11027: if g_debug_flag= 'Y' then
11028: fnd_file.put_line(fnd_file.log, 'Unit Price: '||l_unit_price||'Encumbrance Account: '||x_encumbrance_account);
11029: end if;
11030:
11031: /* Get UOM for this item/org from MSI */
11032: l_stmt_num := 30;
11043: to_unit => l_doc_uom_code,
11044: item_id => p_item_id,
11045: uom_rate => l_uom_rate );
11046: IF ( l_uom_rate = -99999) THEN
11047: fnd_file.put_line(fnd_file.log,'Inv_Convert.inv_um_conversion() failed to get the UOM rate');
11048: RAISE process_error;
11049: END IF;
11050:
11051: if g_debug_flag= 'Y' then
11048: RAISE process_error;
11049: END IF;
11050:
11051: if g_debug_flag= 'Y' then
11052: fnd_file.put_line(fnd_file.log, 'Primary UOM: '||l_primary_uom_code);
11053: end if;
11054: l_doc_rcv_qty := p_total_primary_qty * l_uom_rate;
11055: l_doc_primary_qty := p_primary_qty * l_uom_rate;
11056:
11054: l_doc_rcv_qty := p_total_primary_qty * l_uom_rate;
11055: l_doc_primary_qty := p_primary_qty * l_uom_rate;
11056:
11057: if g_debug_flag= 'Y' then
11058: fnd_file.put_line(fnd_file.log, 'Document Received Quantity: '||l_doc_rcv_qty||' Document Primary Quantity: '||l_doc_primary_qty);
11059: end if;
11060:
11061: /* The Requisition is always in the funtional currency */
11062: /* No need of currency conversion */
11072: END IF;
11073:
11074:
11075: IF g_debug_flag= 'Y' THEN
11076: fnd_file.put_line(fnd_file.log, 'Encumbrance Amount: '||x_encumbrance_amount);
11077: FND_FILE.PUT_LINE( FND_FILE.log, 'CompEncumbrance_IntOrdersExp >>>');
11078: END IF;
11079:
11080: EXCEPTION
11073:
11074:
11075: IF g_debug_flag= 'Y' THEN
11076: fnd_file.put_line(fnd_file.log, 'Encumbrance Amount: '||x_encumbrance_amount);
11077: FND_FILE.PUT_LINE( FND_FILE.log, 'CompEncumbrance_IntOrdersExp >>>');
11078: END IF;
11079:
11080: EXCEPTION
11081: when process_error then
11124: l_err_rec.l_err_msg := '';
11125:
11126: l_stmt_num := 5;
11127: if g_debug_flag= 'Y' then
11128: fnd_file.put_line(fnd_file.log, 'CompEncumbrance_IntOrdersExp (T) <<');
11129: end if;
11130: l_stmt_num := 10;
11131:
11132: SELECT
11168: and organization_id = l_organization_id
11169: and ( transaction_date < l_txn_date or (transaction_date = l_txn_date and transaction_id < p_transaction_id));
11170:
11171: if g_debug_flag= 'Y' then
11172: fnd_file.put_line(fnd_file.log, 'Total Received Primary Qty just before current receipt transaction: '||l_total_primary_qty);
11173: end if;
11174:
11175:
11176: /* Get Requisition Line ID */
11223: RETURN;
11224: END IF;
11225: END IF;
11226: if g_debug_flag= 'Y' then
11227: fnd_file.put_line(fnd_file.log, 'Requisition Line ID: '||l_req_line_id);
11228: end if;
11229:
11230: l_primary_qty := abs(l_primary_qty);
11231: l_total_primary_qty := abs(l_total_primary_qty);
11230: l_primary_qty := abs(l_primary_qty);
11231: l_total_primary_qty := abs(l_total_primary_qty);
11232:
11233: if g_debug_flag= 'Y' then
11234: fnd_file.put_line(fnd_file.log, 'Total Received Primary Qty so far just before current receipt transaction: '||l_total_primary_qty);
11235: end if;
11236:
11237: l_stmt_num := 30;
11238: CompEncumbrance_IntOrdersExp (
11248: x_encumbrance_account => x_encumbrance_account,
11249: o_ae_err_rec => l_err_rec );
11250:
11251: if g_debug_flag= 'Y' then
11252: fnd_file.put_line(fnd_file.log, 'CompEncumbrance_IntOrdersExp (T) >>');
11253: end if;
11254: if(l_err_rec.l_err_num <> 0 and l_err_rec.l_err_num is not null) then
11255: raise process_error;
11256: end if;