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
539: END IF;
540: END IF;
541:
542: IF g_debug_flag = 'Y' THEN
543: fnd_file.put_line(fnd_file.log, 'Create_acct_lines >>');
544: END IF;
545:
546:
547: EXCEPTION
601:
602: BEGIN
603:
604: IF g_debug_flag = 'Y' THEN
605: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin <<'
606: || ' transaction_id: ' || i_ae_txn_rec.transaction_id);
607: END IF;
608:
609: l_ae_line_tbl := CSTPALTY.cst_ae_line_tbl_type();
713: l_curr_rec.currency_conv_rate := i_ae_txn_rec.currency_conv_rate;
714: END IF;
715:
716: IF g_debug_flag = 'Y' THEN
717: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num ||
718: ': l_curr_rec.pri_currency = ' || l_curr_rec.pri_currency ||
719: '; l_curr_rec.alt_currency = ' || l_curr_rec.alt_currency);
720: END IF;
721:
732: end if;
733: end if;
734:
735: IF g_debug_flag = 'Y' THEN
736: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num ||
737: ': l_curr_rec.currency_conv_rate = ' || l_curr_rec.currency_conv_rate);
738: END IF;
739:
740: /* Determine if a logical transaction
898: mtl_parameters
899: where organization_id = i_ae_txn_rec.organization_id;
900:
901: IF g_debug_flag = 'Y' THEN
902: fnd_file.put_line(fnd_file.log,'Organization_id : '||(i_ae_txn_rec.organization_id));
903: fnd_file.put_line(fnd_file.log,'l_enc_rev : '||(l_enc_rev));
904: fnd_file.put_line(fnd_file.log,'transaction_id : '||(i_ae_txn_rec.transaction_id));
905: fnd_file.put_line(fnd_file.log,'txn_action_id : '||(i_ae_txn_rec.txn_action_id));
906: END IF;
899: where organization_id = i_ae_txn_rec.organization_id;
900:
901: IF g_debug_flag = 'Y' THEN
902: fnd_file.put_line(fnd_file.log,'Organization_id : '||(i_ae_txn_rec.organization_id));
903: fnd_file.put_line(fnd_file.log,'l_enc_rev : '||(l_enc_rev));
904: fnd_file.put_line(fnd_file.log,'transaction_id : '||(i_ae_txn_rec.transaction_id));
905: fnd_file.put_line(fnd_file.log,'txn_action_id : '||(i_ae_txn_rec.txn_action_id));
906: END IF;
907:
900:
901: IF g_debug_flag = 'Y' THEN
902: fnd_file.put_line(fnd_file.log,'Organization_id : '||(i_ae_txn_rec.organization_id));
903: fnd_file.put_line(fnd_file.log,'l_enc_rev : '||(l_enc_rev));
904: fnd_file.put_line(fnd_file.log,'transaction_id : '||(i_ae_txn_rec.transaction_id));
905: fnd_file.put_line(fnd_file.log,'txn_action_id : '||(i_ae_txn_rec.txn_action_id));
906: END IF;
907:
908: 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
901: IF g_debug_flag = 'Y' THEN
902: fnd_file.put_line(fnd_file.log,'Organization_id : '||(i_ae_txn_rec.organization_id));
903: fnd_file.put_line(fnd_file.log,'l_enc_rev : '||(l_enc_rev));
904: fnd_file.put_line(fnd_file.log,'transaction_id : '||(i_ae_txn_rec.transaction_id));
905: fnd_file.put_line(fnd_file.log,'txn_action_id : '||(i_ae_txn_rec.txn_action_id));
906: END IF;
907:
908: 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
909:
924: -- FP 12.1.1 bug 7346244 fix
925: if (l_enc_rev = 1 AND i_ae_txn_rec.txn_action_id = 17) then
926:
927: IF g_debug_flag = 'Y' THEN
928: fnd_file.put_line(fnd_file.log,'CompEncumbrance_IntOrdersExp << : ');
929: END IF;
930:
931: CompEncumbrance_IntOrdersExp (
932: p_api_version => 1.0,
943: l_ae_txn_rec1.encum_amount :=l_enc_amount;
944: l_ae_txn_rec1.encum_account :=l_enc_account;
945:
946: IF g_debug_flag = 'Y' THEN
947: fnd_file.put_line(fnd_file.log,'encum_amount << : '||l_ae_txn_rec1.encum_amount);
948: fnd_file.put_line(fnd_file.log,'encum_account << : '||l_ae_txn_rec1.encum_account);
949: END IF;
950:
951: if (l_enc_rev = 1 and l_ae_txn_rec1.encum_amount <> 0) THEN
944: l_ae_txn_rec1.encum_account :=l_enc_account;
945:
946: IF g_debug_flag = 'Y' THEN
947: fnd_file.put_line(fnd_file.log,'encum_amount << : '||l_ae_txn_rec1.encum_amount);
948: fnd_file.put_line(fnd_file.log,'encum_account << : '||l_ae_txn_rec1.encum_account);
949: END IF;
950:
951: if (l_enc_rev = 1 and l_ae_txn_rec1.encum_amount <> 0) THEN
952:
965: l_stmt_num := 80;
966: o_ae_line_rec_tbl := l_ae_line_tbl;
967:
968: IF g_debug_flag = 'Y' THEN
969: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': return >>');
970: END IF;
971:
972: EXCEPTION
973:
1018:
1019: BEGIN
1020:
1021: IF g_debug_flag ='Y' THEN
1022: fnd_file.put_line(fnd_file.log, 'Wip_cost_txn <<');
1023: END IF;
1024: -- Initialize variables.
1025: -- ---------------------
1026: l_err_rec.l_err_num := 0;
1032: -- There are no cost distributions for expense items.
1033: -- --------------------------------------------------
1034: if (i_ae_txn_rec.exp_item = 1) then
1035: IF g_debug_flag = 'Y' THEN
1036: fnd_file.put_line(fnd_file.log,'No accounting for Expense item');
1037: END IF;
1038: return;
1039: end if;
1040:
1045: -- repetitive schedules
1046:
1047: IF (i_ae_txn_rec.wip_entity_type = 2) THEN
1048: IF g_debug_flag = 'Y' THEN
1049: fnd_file.put_line(fnd_file.log, 'Repetitive Schedule: ');
1050: END IF;
1051:
1052: l_stmt_num := 10;
1053:
1084:
1085: -- flow schedules
1086: ELSIF (i_ae_txn_rec.wip_entity_type = 4) THEN
1087: IF g_debug_flag = 'Y' THEN
1088: fnd_file.put_line(fnd_file.log,'Flow Schedule: ');
1089: END IF;
1090:
1091: SELECT
1092: material_account,
1107: AND wip_entity_id = i_ae_txn_rec.txn_src_id;
1108: ELSE
1109: -- discrete jobs
1110: IF g_debug_flag = 'Y' THEN
1111: fnd_file.put_line(fnd_file.log,'Discrete Job: ');
1112: END IF;
1113: l_stmt_num := 17;
1114: select
1115: material_account,
1143: -- Scrap transactions do not have inventory impact!!
1144: -- -------------------------------------------------
1145: if (i_ae_txn_rec.txn_action_id <> 30) then
1146: IF g_debug_flag = 'Y' THEN
1147: fnd_file.put_line(fnd_file.log,'Scrap txn: ');
1148: END IF;
1149: select decode(asset_inventory,1,0,1)
1150: into l_exp_sub
1151: from mtl_secondary_inventories
1156: -- not distributed.
1157: -- ----------------------------------------------------------------
1158: if (l_exp_sub = 1 and l_exp_job = 1) then
1159: IF g_debug_flag = 'Y' THEN
1160: fnd_file.put_line(fnd_file.log,'No accounting for Expense Sub or Expense Job');
1161: END IF;
1162: return;
1163: end if;
1164: if (l_exp_sub = 1) then
1174: -- ----------------------------------------------------------------
1175:
1176: if (i_ae_txn_rec.txn_action_id in (31,32)) then
1177: IF g_debug_flag = 'Y' THEN
1178: fnd_file.put_line(fnd_file.log,'Assembly completion/return');
1179: END IF;
1180: l_stmt_num := 40;
1181: select count(transaction_id) /* Bug No. 4586534 */
1182: into l_mat_ovhd_exists
1331: end if;
1332:
1333: end if;
1334: IF g_debug_flag = 'Y' THEN
1335: fnd_file.put_line(fnd_file.log,'Wip_cost_txn >>');
1336: END IF;
1337:
1338: EXCEPTION
1339:
1374: l_acct_rec CSTPALTY.cst_ae_acct_rec_type;
1375: BEGIN
1376:
1377: IF g_debug_flag = 'Y' THEN
1378: fnd_file.put_line(fnd_file.log,'Sub_cost_txn <<');
1379: END IF;
1380:
1381: -- Initialize variables.
1382: -- ---------------------
1387: -- There are no cost distributions for expense items.
1388: -- --------------------------------------------------
1389: if (i_ae_txn_rec.exp_item = 1) then
1390: IF g_debug_flag = 'Y' THEN
1391: fnd_file.put_line(fnd_file.log,'No accounting for Expense Item');
1392: END IF;
1393: return;
1394: end if;
1395:
1415: if (l_exp_sub1 = 1 and l_exp_sub2 = 1) or
1416: (l_exp_sub1 = 0 and l_exp_sub2 = 0)
1417: then
1418: IF g_debug_flag = 'Y' THEN
1419: fnd_file.put_line(fnd_file.log,'No accounting for Expense to Expense or Asset to Asset');
1420: END IF;
1421: return;
1422: end if;
1423:
1460: if (l_err_rec.l_err_num <> 0 and l_err_rec.l_err_num is not null) then
1461: raise process_error;
1462: end if;
1463: IF g_debug_flag = 'Y' THEN
1464: fnd_file.put_line(fnd_file.log,'Sub_cost_txn >>');
1465: END IF;
1466:
1467: EXCEPTION
1468:
1691:
1692: BEGIN
1693:
1694: IF g_debug_flag = 'Y' THEN
1695: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin <<'
1696: || ' transaction_id: ' || i_ae_txn_rec.transaction_id);
1697: END IF;
1698:
1699: -- Initialize variables.
1732: AND cost_group_id = i_ae_txn_rec.cost_group_id
1733: AND category_id = i_ae_txn_rec.category_id;
1734: EXCEPTION
1735: WHEN no_data_found THEN
1736: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num ||
1737: ': Category : '||to_char(i_ae_txn_rec.category_id) ||' has no accounts defined');
1738: raise no_mfca_acct_error;
1739: END;
1740:
1774:
1775: l_txfr_txn_cost_group_id := NVL(i_ae_txn_rec.xfer_cost_group_id, -1);
1776:
1777: IF g_debug_flag = 'Y' THEN
1778: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
1779: ': cost_group_id = ' || i_ae_txn_rec.cost_group_id ||
1780: ': txn_cost_group_id ' || l_txn_cost_group_id ||
1781: ': txfr_txn_cost_group_id ' || l_txfr_txn_cost_group_id);
1782: END IF;
1787:
1788: IF (l_txn_cost_group_id = l_txfr_txn_cost_group_id) THEN /* Same Cost Group Transfer */
1789:
1790: IF g_debug_flag = 'Y' THEN
1791: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Transfer Within Same Cost Group');
1792: END IF;
1793:
1794: /* Do not create accounting for same cost group transfers of expense items */
1795: IF i_ae_txn_rec.exp_item = 1 THEN
1794: /* Do not create accounting for same cost group transfers of expense items */
1795: IF i_ae_txn_rec.exp_item = 1 THEN
1796: l_stmt_num := 23;
1797: IF g_debug_flag = 'Y' THEN
1798: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': return >> ' ||
1799: '(No accounting for Expense item)');
1800: END IF;
1801: RETURN;
1802: END IF;
1807:
1808: l_stmt_num := 25;
1809:
1810: IF g_debug_flag = 'Y' THEN
1811: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Direct Transfer');
1812: END IF;
1813:
1814: SELECT decode(asset_inventory,1,0,1)
1815: INTO l_exp_sub2
1820: IF (l_exp_sub1 = 0 AND l_exp_sub2 = 0) OR
1821: (l_exp_sub1 = 1 AND l_exp_sub2 = 1)
1822: THEN
1823: IF g_debug_flag = 'Y' THEN
1824: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': return >> '
1825: || 'No accounting for Expense to Expense or Asset to Asset Subs');
1826: END IF;
1827: RETURN;
1828: END IF;
1835: ELSE
1836: l_stmt_num := 30;
1837:
1838: IF g_debug_flag = 'Y' THEN
1839: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Intransit Transfer');
1840: END IF;
1841:
1842: IF (i_ae_txn_rec.txn_action_id = 21) THEN
1843: l_dr_flag := TRUE;
1855: ---------------------------------------------------
1856: l_stmt_num := 31;
1857:
1858: IF g_debug_flag = 'Y' THEN
1859: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Create Accounting for same cost group transfer');
1860: END IF;
1861:
1862: -- In R12, the Inventory Offset Account field has been removed from
1863: -- the Periodic Account Assignments form, so cst_org_cost_group_accounts.
1919: raise process_error;
1920: end if;
1921:
1922: if (g_debug_flag = 'Y') then
1923: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': Interorg_cost_txn >>');
1924: end if;
1925:
1926: return; -- done processing same cost group transfers
1927:
1929:
1930: l_stmt_num := 35;
1931:
1932: IF g_debug_flag = 'Y' THEN
1933: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Transfer across different cost groups');
1934: END IF;
1935:
1936: /* Select the expense item status of the item in the org belonging
1937: to the cost group currently being processed. This may be different
1968: /* currency conversion rate in i_ae_curr_rec is always from the sending org to the receiving org */
1969: l_conv_rate := i_ae_curr_rec.currency_conv_rate;
1970:
1971: IF g_debug_flag = 'Y' THEN
1972: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Currency conversion rate: ' || l_conv_rate);
1973: END IF;
1974:
1975: /* Get transfer transaction id for receipt transactions */
1976: IF ( i_ae_txn_rec.txn_action_id in (12,22)
2060:
2061: l_tprice_option := 2; /* Make it 2 to ignore the CST Transfer Price profile */
2062:
2063: IF g_debug_flag = 'Y' THEN
2064: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ' ICR Set up:process-discrete xfer');
2065: END IF;
2066:
2067: END IF;
2068:
2071: END IF;
2072: -- INVCONV sikhanna END
2073:
2074: IF g_debug_flag = 'Y' THEN
2075: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2076: ': l_tprice_option: ' || l_tprice_option || ', process-discrete xfer: ' || l_pd_txfr_ind);
2077: END IF;
2078:
2079: l_stmt_num := 55;
2081: -- INVCONV sikhanna, process Internal sales order for OPM conv here
2082: IF ((i_ae_txn_rec.txn_src_type_id IN (7,8)) AND (l_tprice_option IN (1,2))) THEN /* Process Internal Orders */
2083:
2084: IF g_debug_flag = 'Y' THEN
2085: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2086: ': Shipment txn of Internal Order Transfer');
2087: END IF;
2088: /* Internal Sales Order with transfer price specified and profiles set.
2089: CST_TRANSFER_PRICING_OPTION is set to: Yes,Price as Incoming Cost or Yes, Price Not as Incoming Cost.
2095:
2096: l_stmt_num := 57;
2097:
2098: IF g_debug_flag = 'Y' THEN
2099: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2100: ': Shipment txn of Internal Order FOB Shipment - Sending Cost Group');
2101: END IF;
2102:
2103: IF g_debug_flag = 'Y' THEN
2100: ': Shipment txn of Internal Order FOB Shipment - Sending Cost Group');
2101: END IF;
2102:
2103: IF g_debug_flag = 'Y' THEN
2104: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2105: ': Discrete-Discrete Transfer');
2106: END IF;
2107:
2108: IF (l_cg_exp_item <> 1) THEN
2111: -- Bug 5573993 - Derive the COGS account to break dependency on perpetual
2112: -- code as if the trxn is not costed, mmt has incorrect account stamped
2113:
2114: IF g_debug_flag = 'Y' THEN
2115: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2116: 'Deriving COGS account');
2117: END IF;
2118:
2119: l_stmt_num := 61;
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 ||
2130: 'COGS Account ID: ' || l_cogs_account);
2131: END IF;
2132:
2133: -- Stamp all elemental accounts with the COGS account
2193:
2194: l_stmt_num := 65;
2195:
2196: IF g_debug_flag = 'Y' THEN
2197: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2198: ': Shipment txn of Internal Order FOB Shipment - Receiving Cost Group');
2199: END IF;
2200:
2201: /* Credit Intercompany Accrual and Debit Intransit */
2205: -- Bug 5573993 - Derive the Intercompany account to break dependency on perpetual
2206: -- code as if the trxn is not costed, mmt has incorrect or no account stamped
2207:
2208: IF g_debug_flag = 'Y' THEN
2209: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2210: 'Deriving intercompany account');
2211: END IF;
2212:
2213: l_accrual_account := get_intercompany_account (i_ae_txn_rec => i_ae_txn_rec,
2217: RAISE process_error;
2218: END IF;
2219:
2220: IF g_debug_flag = 'Y' THEN
2221: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2222: 'Intercompany Account ID: ' || l_accrual_account);
2223: END IF;
2224:
2225:
2271:
2272: END IF;
2273:
2274: IF g_debug_flag = 'Y' THEN
2275: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2276: ': Cr Intercompany Accrual @ : ' || l_transfer_price);
2277: END IF;
2278:
2279: l_ae_line_rec.account := l_accrual_account;
2296:
2297: IF (l_tprice_option = 2) THEN
2298:
2299: IF g_debug_flag = 'Y' THEN
2300: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2301: ': CST:Transfer Price Option = Yes, Price As Incoming Cost');
2302: END IF;
2303:
2304: ELSIF (l_tprice_option = 1) THEN
2303:
2304: ELSIF (l_tprice_option = 1) THEN
2305:
2306: IF g_debug_flag = 'Y' THEN
2307: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2308: ': CST:Transfer Price Option = Yes, Price Not As Incoming Cost');
2309: END IF;
2310:
2311: -- Debit/Credit Profit in Inventory
2407: l_stmt_num := 90;
2408: /* This can only be the sending CG */
2409:
2410: IF g_debug_flag = 'Y' THEN
2411: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2412: ': Shipment txn of Internal Order FOB Receipt - Shipping Cost Group');
2413: END IF;
2414:
2415: IF (l_cg_exp_item <> 1) THEN
2468: ELSIF (i_ae_txn_rec.txn_action_id not in (15,22)) THEN /* Ordinary Interorg shipments */
2469:
2470: l_stmt_num := 92;
2471: IF g_debug_flag = 'Y' THEN
2472: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2473: ': Interorg Shipment transaction');
2474: END IF;
2475:
2476: 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 */
2476: 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 */
2477:
2478: l_stmt_num := 94;
2479: IF g_debug_flag = 'Y' THEN
2480: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2481: ': Shipment txn of FOB Shipment - Shipping Cost Group');
2482: END IF;
2483:
2484:
2593: AND CPIC.COST_GROUP_ID = i_ae_txn_rec.cost_group_id
2594: AND CPIC.PAC_PERIOD_ID = i_ae_txn_rec.accounting_period_id;
2595:
2596: IF g_debug_flag = 'Y' THEN
2597: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2598: ': Using PAC Absorption Cost: ' || l_pacp_pwac_cost);
2599: END IF;
2600:
2601: /* Get transfer credit information */
2685:
2686: IF (l_use_prev_period_cost = 1) THEN
2687:
2688: IF g_debug_flag = 'Y' THEN
2689: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2690: ': Using prior period PWAC cost: ' || l_prev_period_pwac_cost);
2691: END IF;
2692:
2693: /* Get transfer credit information */
2817:
2818: IF (l_pd_txfr_ind = 0) THEN -- Discrete-Discrete X-fers
2819:
2820: IF g_debug_flag = 'Y' THEN
2821: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2822: ': Discrete-Discrete Transfer: Using MTA cost');
2823: END IF;
2824:
2825: BEGIN
2835: l_perp_ship_value := 0;
2836: END;
2837:
2838: IF g_debug_flag = 'Y' THEN
2839: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2840: ': l_perp_ship_value = ' || l_perp_ship_value);
2841: END IF;
2842:
2843: l_stmt_num := 145;
2855: l_txfr_credit := 0;
2856: END IF;
2857:
2858: IF g_debug_flag = 'Y' THEN
2859: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2860: ': l_txfr_credit = ' || l_txfr_credit);
2861: END IF;
2862:
2863: l_stmt_num := 150;
2864:
2865: l_io_rcv_value := l_txfr_credit + (l_perp_ship_value / abs(i_ae_txn_rec.primary_quantity));
2866:
2867: IF g_debug_flag = 'Y' THEN
2868: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2869: ': l_io_rcv_value = ' || l_io_rcv_value);
2870: END IF;
2871:
2872: l_ae_line_rec.transaction_value := l_io_rcv_value * abs(i_ae_txn_rec.primary_quantity);
2937:
2938: l_txfr_var_value := abs(l_txfr_var_value);
2939:
2940: IF g_debug_flag = 'Y' THEN
2941: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2942: ': l_txfr_var_value = ' || l_txfr_var_value);
2943: END IF;
2944:
2945: l_stmt_num := 170;
2977:
2978: l_stmt_num := 180;
2979:
2980: IF g_debug_flag = 'Y' THEN
2981: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
2982: ': Process-Discrete Transfer');
2983: END IF;
2984:
2985: SELECT mip.interorg_receivables_account,
3075:
3076: l_stmt_num := 210;
3077:
3078: IF g_debug_flag = 'Y' THEN
3079: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3080: ': Shipment txn of FOB Shipment - Receiving Cost Group');
3081: END IF;
3082:
3083: SELECT mip.interorg_payables_account,
3227:
3228: l_stmt_num := 225;
3229:
3230: IF g_debug_flag = 'Y' THEN
3231: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3232: ': Shipment txn of FOB Receipt - Shipping Cost Group');
3233: END IF;
3234:
3235: IF (l_cg_exp_item <> 1) THEN
3285:
3286: l_stmt_num := 230;
3287:
3288: IF g_debug_flag = 'Y' THEN
3289: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3290: ': Shipment txn of Direct Interorg - Shipping Cost Group');
3291: END IF;
3292:
3293: /* Credit Onhand inventory */
3409: AND CPIC.COST_GROUP_ID = i_ae_txn_rec.cost_group_id
3410: AND CPIC.PAC_PERIOD_ID = i_ae_txn_rec.accounting_period_id;
3411:
3412: IF g_debug_flag = 'Y' THEN
3413: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3414: ': Using PAC Absorption Cost: ' || l_pacp_pwac_cost);
3415: END IF;
3416:
3417: l_stmt_num := 272;
3537: IF (l_use_prev_period_cost = 1) THEN
3538: l_stmt_num := 282;
3539:
3540: IF g_debug_flag = 'Y' THEN
3541: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3542: ': Using prior period PWAC cost: ' || l_prev_period_pwac_cost);
3543: END IF;
3544:
3545: l_stmt_num := 285;
3708:
3709: IF (l_pd_txfr_ind = 1) THEN -- Process-Discrete X-fers
3710:
3711: IF g_debug_flag = 'Y' THEN
3712: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3713: ': Process-Discrete X-fers: ');
3714: END IF;
3715:
3716: SELECT mip.interorg_receivables_account,
3837:
3838:
3839: l_stmt_num := 340;
3840: IF g_debug_flag = 'Y' THEN
3841: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
3842: ': Using MTA cost: ');
3843: END IF;
3844:
3845:
4063:
4064: l_tprice_option := 2; /* Make it 2 to ignore the CST Transfer Price profile */
4065:
4066: IF g_debug_flag = 'Y' THEN
4067: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ' ICR Set up:process-discrete xfer');
4068: END IF;
4069:
4070: END IF;
4071:
4087:
4088: l_stmt_num := 380;
4089:
4090: IF g_debug_flag = 'Y' THEN
4091: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4092: ': Receipt txn of Internal Order FOB Receipt - Sending Cost Group');
4093: END IF;
4094:
4095: IF (l_cg_exp_item <> 1) THEN
4100: -- Bug 5573993 - Derive the COGS account to break dependency on perpetual
4101: -- code as if the trxn is not costed, mmt has incorrect account stamped
4102:
4103: IF g_debug_flag = 'Y' THEN
4104: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4105: 'Deriving COGS account');
4106: END IF;
4107:
4108: l_stmt_num := 61;
4114: RAISE process_error;
4115: END IF;
4116:
4117: IF g_debug_flag = 'Y' THEN
4118: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4119: 'COGS Account ID: ' || l_cogs_account);
4120: END IF;
4121:
4122: -- Stamp all elemental accounts with the COGS account
4172:
4173: l_stmt_num := 395;
4174:
4175: IF g_debug_flag = 'Y' THEN
4176: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4177: ': Receipt txn of Internal Order FOB Receipt - Receiving Cost Group');
4178: END IF;
4179:
4180: /* Credit Intercompany Accrual Account */
4188: -- Bug 5573993 - Derive the Intercompany account to break dependency on perpetual
4189: -- code as if the trxn is not costed, mmt has incorrect or no account stamped
4190:
4191: IF g_debug_flag = 'Y' THEN
4192: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4193: 'Deriving intecompany account');
4194: END IF;
4195:
4196: l_accrual_account := get_intercompany_account (i_ae_txn_rec => i_ae_txn_rec,
4200: raise process_error;
4201: end if;
4202:
4203: IF g_debug_flag = 'Y' THEN
4204: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4205: 'Intercompany Account ID: ' || l_accrual_account);
4206: END IF;
4207:
4208: l_dr_flag := FALSE;
4238: FROM mtl_material_transactions MMT
4239: WHERE MMT.transaction_id = i_ae_txn_rec.transaction_id;
4240:
4241: IF g_debug_flag = 'Y' THEN
4242: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4243: ': Cr Intercompany Accrual @ : ' || l_transfer_price);
4244: END IF;
4245:
4246: l_ae_line_rec.account := l_accrual_account;
4264: IF (l_tprice_option = 2) THEN
4265: l_stmt_num := 402;
4266:
4267: IF g_debug_flag = 'Y' THEN
4268: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4269: ': CST: Transfer Price Option = Yes, Price As Incoming Cost');
4270: END IF;
4271:
4272: ELSIF (l_tprice_option = 1) THEN
4271:
4272: ELSIF (l_tprice_option = 1) THEN
4273: l_stmt_num := 404;
4274: IF g_debug_flag = 'Y' THEN
4275: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4276: ': CST: Transfer Price Option = Yes, Price Not As Incoming Cost');
4277: END IF;
4278:
4279: -- Debit/Credit Profit in Inventory
4373:
4374: l_stmt_num := 422;
4375:
4376: IF g_debug_flag = 'Y' THEN
4377: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4378: ': Receipt txn of Internal Order FOB Shipment - Receiving Cost Group');
4379: END IF;
4380:
4381:
4438:
4439: l_stmt_num := 426;
4440:
4441: IF g_debug_flag = 'Y' THEN
4442: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4443: ': Interorg Receipt transaction');
4444: END IF;
4445:
4446: 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 */
4447:
4448: l_stmt_num := 428;
4449:
4450: IF g_debug_flag = 'Y' THEN
4451: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4452: ': Receipt txn of FOB Receipt - Receiving Cost Group');
4453: END IF;
4454:
4455: -- Processing the process-discrete txns
4460: WHERE MP.ORGANIZATION_ID = i_ae_txn_rec.xfer_organization_id
4461: OR MP.ORGANIZATION_ID = i_ae_txn_rec.organization_id;
4462:
4463: IF g_debug_flag = 'Y' THEN
4464: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4465: ': Process-isc Ind: ' || l_pd_txfr_ind);
4466: END IF;
4467:
4468: /* Process OPM-Discrete transfers here as the accouting distribution template is same INVCONV*/
4564:
4565: l_stmt_num := 445;
4566:
4567: IF g_debug_flag = 'Y' THEN
4568: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4569: ': Receipt txn of FOB Receipt - Shipping Cost Group');
4570: END IF;
4571:
4572: SELECT mip.interorg_receivables_account,
4689: AND CPIC.COST_GROUP_ID = i_ae_txn_rec.cost_group_id
4690: AND CPIC.PAC_PERIOD_ID = i_ae_txn_rec.accounting_period_id;
4691:
4692: IF g_debug_flag = 'Y' THEN
4693: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4694: ': Using PAC Absorption Cost: ' || l_pacp_pwac_cost);
4695: END IF;
4696:
4697: l_stmt_num := 492;
4811:
4812: IF (l_use_prev_period_cost = 1) THEN
4813:
4814: IF g_debug_flag = 'Y' THEN
4815: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4816: ': Using prior period PWAC cost: ' || l_prev_period_pwac_cost);
4817: END IF;
4818:
4819: l_stmt_num := 505;
4964:
4965: l_stmt_num := 540;
4966:
4967: IF g_debug_flag = 'Y' THEN
4968: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
4969: ': Using MTA cost');
4970: END IF;
4971:
4972: /* Debit Receivables */
5135:
5136: l_stmt_num := 575;
5137:
5138: IF g_debug_flag = 'Y' THEN
5139: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
5140: ': Receipt txn of FOB Shipment - Receiving Cost Group');
5141: END IF;
5142:
5143: -- Processing the process-discrete txns
5148: WHERE MP.ORGANIZATION_ID = i_ae_txn_rec.xfer_organization_id
5149: OR MP.ORGANIZATION_ID = i_ae_txn_rec.organization_id;
5150:
5151: IF g_debug_flag = 'Y' THEN
5152: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
5153: ': Process-isc Ind: ' || l_pd_txfr_ind);
5154: END IF;
5155:
5156: IF (l_cg_exp_item <> 1) THEN
5209:
5210: l_stmt_num := 585;
5211:
5212: IF g_debug_flag = 'Y' THEN
5213: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
5214: ': Direct Interorg Receipt - Receiving Cost Group');
5215: END IF;
5216:
5217: /* Debit On-Hand and credit Payables */
5322:
5323: l_stmt_num := 605;
5324:
5325: IF g_debug_flag = 'Y' THEN
5326: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
5327: ': OPM-Discrete Logical Receipt');
5328: END IF;
5329:
5330: SELECT mip.interorg_payables_account,
5495: ELSIF (i_ae_txn_rec.txn_action_id = 22 and l_fob_point = 2) THEN
5496:
5497: l_stmt_num := 645;
5498: IF g_debug_flag = 'Y' THEN
5499: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
5500: ': OPM-Discrete Logical Shipment');
5501: END IF;
5502:
5503: SELECT mip.interorg_receivables_account,
5649:
5650: l_stmt_num := 700;
5651:
5652: IF g_debug_flag = 'Y' THEN
5653: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': return >>');
5654: END IF;
5655:
5656: EXCEPTION
5657:
5655:
5656: EXCEPTION
5657:
5658: when no_mfca_acct_error then -- INVCONV
5659: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Error processing transaction ' || i_ae_txn_rec.transaction_id);
5660: o_ae_err_rec.l_err_num := 30005;
5661: o_ae_err_rec.l_err_code := 'CST_PAC_NO_MFCA_ACCTS';
5662: FND_MESSAGE.set_name('BOM', 'CST_PAC_NO_MFCA_ACCTS');
5663: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
5662: FND_MESSAGE.set_name('BOM', 'CST_PAC_NO_MFCA_ACCTS');
5663: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
5664:
5665: when no_interorg_profit_acct_error then
5666: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Error processing transaction ' || i_ae_txn_rec.transaction_id);
5667: o_ae_err_rec.l_err_num := 30005;
5668: o_ae_err_rec.l_err_code := 'CST_NO_INTERORG_PROFIT_ACCT';
5669: FND_MESSAGE.set_name('BOM', 'CST_NO_INTERORG_PROFIT_ACCT');
5670: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
5669: FND_MESSAGE.set_name('BOM', 'CST_NO_INTERORG_PROFIT_ACCT');
5670: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
5671:
5672: when no_profit_in_inv_acct_error then
5673: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Error processing transaction ' || i_ae_txn_rec.transaction_id);
5674: o_ae_err_rec.l_err_num := 30005;
5675: o_ae_err_rec.l_err_code := 'CST_NO_PROFIT_INV_ACCT';
5676: FND_MESSAGE.set_name('BOM', 'CST_NO_PROFIT_INV_ACCT');
5677: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
5733: process_error EXCEPTION;
5734: BEGIN
5735:
5736: IF g_debug_flag = 'Y' THEN
5737: fnd_file.put_line(fnd_file.log,'Pcu_cost_txn <<');
5738: END IF;
5739:
5740: -- Initialize variables.
5741: -- ---------------------
5756: and cost_group_id = i_ae_txn_rec.cost_group_id
5757: and category_id = i_ae_txn_rec.category_id;
5758:
5759: if (l_acct_exist = 0) then
5760: fnd_file.put_line(fnd_file.log,'Category: '||to_char(i_ae_txn_rec.category_id) || ' has no accounts defined');
5761: raise no_mfca_acct_error;
5762: end if;
5763:
5764: -- Get the accounts from MFCA.
6007: /* the l_dr_flag will have to be toggled again so that the variance account is credited or debited correctly.*/
6008: /* The toggling is removed for the bug No. 4586534 */
6009: /* the l_dr_flag will have to be toggled again so that the variance account is credited or debited correctly.*/
6010: ELSE
6011: 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');
6012: END IF; -- for l_cost <> 0 or (l_cost=0 and account id exists)
6013: IF(l_onhand_var <> 0) THEN
6014: if (l_onhand_var > 0) then
6015: l_dr_flag := "TRUE";
6053: END IF;
6054: ELSE
6055: l_loop_count := l_loop_count + 1;
6056: IF g_debug_flag = 'Y' THEN
6057: fnd_file.put_line(fnd_file.log,'No cost for element ....');
6058: END IF;
6059: END IF;
6060: END LOOP;
6061:
6144: end if;
6145:
6146: end if;
6147: IF g_debug_flag = 'Y' THEN
6148: fnd_file.put_line(fnd_file.log,'Pcu_cost_txn <<');
6149: END IF;
6150:
6151: EXCEPTION
6152:
6206: l_ref_om_line_id NUMBER; -- Revenue / COGS Matching
6207: BEGIN
6208:
6209: IF g_debug_flag = 'Y' THEN
6210: fnd_file.put_line(fnd_file.log,'Inv_cost_txn <<');
6211: END IF;
6212: -- Initialize variables.
6213: -- ---------------------
6214: l_err_rec.l_err_num := 0;
6230: -- return and PO delivery adjustments.
6231:
6232: if ((i_ae_txn_rec.exp_item = 1 or l_exp_sub = 1) and (i_ae_txn_rec.txn_src_type_id <>1)) then
6233: IF g_debug_flag = 'Y' THEN
6234: fnd_file.put_line(fnd_file.log,'Expense item or expense sub - No accounting ');
6235: END IF;
6236: return;
6237: end if;
6238:
6287: l_acct_rec.ovhd_account := '';
6288:
6289: if (i_ae_txn_rec.txn_action_id in (4,8)) then
6290: IF g_debug_flag = 'Y' THEN
6291: fnd_file.put_line(fnd_file.log,'Cycle Count or Physical Inv Adjustment');
6292: END IF;
6293:
6294: /* cycle count adjustment and physical inventory adjustment */
6295: /* Use the distribution account id as stated in mmt. */
6302: elsif (i_ae_txn_rec.txn_action_id in (1,27,29) and i_ae_txn_rec.txn_src_type_id = 1) then
6303:
6304: /* PO Issue, Receipt, delivery adjustments. */
6305: IF g_debug_flag = 'Y' THEN
6306: fnd_file.put_line(fnd_file.log,'PO Issue, Receipt, delivery adjustments');
6307: END IF;
6308:
6309: l_acct_rec.account := i_ae_txn_rec.dist_acct_id;
6310: l_elemental := 0;
6346: IF (i_ae_txn_rec.txn_src_type_id = 12 AND l_ref_om_line_id IS NOT NULL) then
6347:
6348: /* RMAs with Deferred COGS */
6349: IF g_debug_flag = 'Y' THEN
6350: fnd_file.put_line(fnd_file.log,'RMA with Deferred COGS');
6351: END IF;
6352:
6353: l_stmt_num := 35;
6354: -- Create the credit distributions to COGS and/or Deferred COGS
6370: ELSIF (i_ae_txn_rec.txn_src_type_id = 2 AND i_ae_txn_rec.so_issue_acct_type = 2) THEN
6371:
6372: /* Sales order issue with Deferred COGS */
6373: IF g_debug_flag = 'Y' THEN
6374: fnd_file.put_line(fnd_file.log,'Sales order issue ');
6375: END IF;
6376:
6377: l_stmt_num := 40;
6378: -- Get the Deferred COGS account
6392:
6393: ELSE
6394: /* Sales orders and RMAs with no deferred COGS */
6395: IF g_debug_flag = 'Y' THEN
6396: fnd_file.put_line(fnd_file.log,'Sales order, RMA and Rejection of RMA ');
6397: END IF;
6398:
6399: l_acct_rec.account := i_ae_txn_rec.dist_acct_id;
6400: if (l_acct_rec.account = -1) then
6425: elsif (i_ae_txn_rec.txn_action_id in (1,27,29) and i_ae_txn_rec.txn_src_type_id = 3) then
6426:
6427: /* Account */
6428: IF g_debug_flag = 'Y' THEN
6429: fnd_file.put_line(fnd_file.log,'Account txn');
6430: END IF;
6431:
6432: l_acct_rec.account := i_ae_txn_rec.txn_src_id;
6433: l_acct_line_type := 2;
6437: elsif (i_ae_txn_rec.txn_action_id in (1,27,29) and i_ae_txn_rec.txn_src_type_id = 6) then
6438:
6439: /* Account Alias*/
6440: IF g_debug_flag = 'Y' THEN
6441: fnd_file.put_line(fnd_file.log,'Account Alias txn ');
6442: END IF;
6443:
6444: l_stmt_num := 60;
6445:
6456: elsif (i_ae_txn_rec.txn_action_id = 6 and i_ae_txn_rec.txn_src_type_id in (1, 13)) then
6457:
6458: /* Transfer to regular/consigned */
6459: IF g_debug_flag = 'Y' THEN
6460: fnd_file.put_line(fnd_file.log,'Transfer to regular/consigned');
6461: END IF;
6462:
6463: l_acct_rec.account := i_ae_txn_rec.dist_acct_id;
6464: l_acct_line_type := 16;
6468: else
6469:
6470: /* Misc issue, receipt, default*/
6471: IF g_debug_flag = 'Y' THEN
6472: fnd_file.put_line(fnd_file.log,'Misc issue, receipt');
6473: END IF;
6474:
6475: l_acct_rec.account := i_ae_txn_rec.dist_acct_id;
6476: l_acct_line_type := 2;
6526: end if;
6527:
6528: <
6529: IF g_debug_flag = 'Y' THEN
6530: fnd_file.put_line(fnd_file.log,'Inv_cost_txn >> ');
6531: END IF;
6532:
6533: EXCEPTION
6534:
6574:
6575: BEGIN
6576:
6577: IF g_debug_flag = 'Y' THEN
6578: fnd_file.put_line(fnd_file.log,'Cost_logical_txn <<');
6579: END IF;
6580: -- Initialize variables.
6581: -- ---------------------
6582: l_err_rec.l_err_num := 0;
6624: if ((i_ae_txn_rec.exp_item = 1 or l_exp_sub = 1) and
6625: ((i_ae_txn_rec.txn_action_id = 26 and i_ae_txn_rec.txn_src_type_id = 12) OR
6626: (i_ae_txn_rec.txn_action_id = 7 and i_ae_txn_rec.txn_src_type_id = 2))) then
6627: IF g_debug_flag = 'Y' THEN
6628: fnd_file.put_line(fnd_file.log,'Expense item or expense sub - No accounting ');
6629: END IF;
6630: return;
6631: end if;
6632:
6713: IF (i_ae_txn_rec.txn_type_id = 16 AND l_ref_om_line_id IS NOT NULL) then
6714:
6715: /* RMAs with Deferred COGS */
6716: IF g_debug_flag = 'Y' THEN
6717: fnd_file.put_line(fnd_file.log,'RMA with Deferred COGS');
6718: END IF;
6719:
6720: l_stmt_num := 40;
6721: -- Create the credit distributions to COGS and/or Deferred COGS
6737: ELSIF (i_ae_txn_rec.txn_type_id = 30 AND i_ae_txn_rec.so_issue_acct_type = 2) THEN
6738:
6739: /* Sales order issue with Deferred COGS */
6740: IF g_debug_flag = 'Y' THEN
6741: fnd_file.put_line(fnd_file.log,'Sales order issue ');
6742: END IF;
6743:
6744: l_stmt_num := 50;
6745: -- Get the Deferred COGS account
6753:
6754: ELSE
6755: /* Logical Sales orders and RMAs with no deferred COGS */
6756: IF g_debug_flag = 'Y' THEN
6757: fnd_file.put_line(fnd_file.log,'Logical Sales order, RMA and Rejection of RMA ');
6758: END IF;
6759:
6760: l_acct_rec.account := i_ae_txn_rec.dist_acct_id;
6761: l_acct_line_type := 35;
6793:
6794: <
6795:
6796: IF g_debug_flag = 'Y' THEN
6797: fnd_file.put_line(fnd_file.log,'cost_logical_txn out ');
6798: END IF;
6799:
6800: EXCEPTION
6801:
6843:
6844: BEGIN
6845:
6846: IF g_debug_flag = 'Y' THEN
6847: fnd_file.put_line(fnd_file.log,'Cost_consigned_txn <<');
6848: END IF;
6849: -- Initialize variables.
6850: -- ---------------------
6851: l_err_rec.l_err_num := 0;
6954: end if;
6955:
6956:
6957: IF g_debug_flag = 'Y' THEN
6958: fnd_file.put_line(fnd_file.log,'Cost_consigned_update_txn >> ');
6959: END IF;
6960:
6961: EXCEPTION
6962:
6996: process_error exception;
6997: l_err_rec CSTPALTY.cst_ae_err_rec_type;
6998: BEGIN
6999: IF g_debug_flag = 'Y' THEN
7000: fnd_file.put_line(fnd_file.log,'Encumbrance_account <<');
7001: END IF;
7002: -- Initialize variables.
7003: -- ---------------------
7004: l_err_rec.l_err_num := 0;
7033: raise process_error;
7034: end if;
7035:
7036: IF g_debug_flag = 'Y' THEN
7037: fnd_file.put_line(fnd_file.log,'Encumbrance_account <<');
7038: END IF;
7039:
7040: EXCEPTION
7041:
7093: no_txn_det_error EXCEPTION;
7094: BEGIN
7095:
7096: IF g_debug_flag = 'Y' THEN
7097: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin <<');
7098: END IF;
7099: -- initialize variables.
7100: -- ---------------------
7101: l_err_rec.l_err_num := 0;
7113: and cost_group_id = i_ae_txn_rec.cost_group_id
7114: and category_id = i_ae_txn_rec.category_id;
7115:
7116: if (l_acct_exist = 0) then
7117: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num ||
7118: ': Category : '||to_char(i_ae_txn_rec.category_id) ||' has no accounts defined');
7119: raise no_mfca_acct_error;
7120: end if;
7121:
7204:
7205: if i_exp_flag then
7206: l_ae_line_rec.account := l_expense_account;
7207: IF g_debug_flag = 'Y' THEN
7208: FND_FILE.PUT_LINE(FND_FILE.LOG, l_api_name || ': ' || l_stmt_num || ': Expense Account: '||to_char(l_expense_account));
7209: END IF;
7210: else
7211: /* changed for bug no. 4586534 */
7212: IF cost_element = 1 THEN
7233: l_ae_line_rec.resource_id := NULL;
7234: l_ae_line_rec.cost_element_id := cost_element;
7235:
7236: IF g_debug_flag = 'Y' THEN
7237: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': Insert element ' || cost_element);
7238: END IF;
7239:
7240: insert_account (i_ae_txn_rec,
7241: i_ae_curr_rec,
7250: end if;
7251:
7252: else
7253: IF g_debug_flag = 'Y' THEN
7254: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': No cost for element ' || cost_element);
7255: END IF;
7256: end if;
7257:
7258: end loop;
7266: and pac_period_id = i_ae_txn_rec.accounting_period_id
7267: and cost_group_id = i_ae_txn_rec.cost_group_id;
7268:
7269: IF (l_var <> 0 AND (NOT i_exp_flag)) THEN
7270: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Creating Variance Entry');
7271: l_stmt_num := 60;
7272: l_ae_line_rec.ae_line_type := 13;
7273:
7274: IF (l_var > 0)
7302: /* Bug 3213936 : End */
7303:
7304:
7305: IF g_debug_flag = 'Y' THEN
7306: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': return >>');
7307: END IF;
7308:
7309: EXCEPTION
7310:
7371: no_txn_det_error EXCEPTION;
7372: l_api_name CONSTANT VARCHAR2(30) := 'CSTPAPBR.offset_accounts';
7373: BEGIN
7374: IF g_debug_flag = 'Y' THEN
7375: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin << ');
7376: FND_FILE.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': Elemental flag: ' ||to_char(i_elemental));
7377: END IF;
7378: -- initialize variables.
7379: -- ---------------------
7372: l_api_name CONSTANT VARCHAR2(30) := 'CSTPAPBR.offset_accounts';
7373: BEGIN
7374: IF g_debug_flag = 'Y' THEN
7375: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin << ');
7376: FND_FILE.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': Elemental flag: ' ||to_char(i_elemental));
7377: END IF;
7378: -- initialize variables.
7379: -- ---------------------
7380: l_err_rec.l_err_num := 0;
7480: end if;
7481:
7482: else
7483: IF g_debug_flag = 'Y' THEN
7484: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || 'No cost for element ' || cost_element);
7485: END IF;
7486: end if;
7487: end loop;
7488: else
7542: raise process_error;
7543: end if;
7544: else
7545: IF g_debug_flag = 'Y' THEN
7546: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || 'No Cost');
7547: END IF;
7548: end if;
7549: end if;
7550: IF g_debug_flag = 'Y' THEN
7547: END IF;
7548: end if;
7549: end if;
7550: IF g_debug_flag = 'Y' THEN
7551: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': return >>');
7552: END IF;
7553:
7554: EXCEPTION
7555:
7601:
7602:
7603: BEGIN
7604: IF g_debug_flag = 'Y' THEN
7605: fnd_file.put_line(fnd_file.log,'Ovhd_accounts << ');
7606: END IF;
7607:
7608: -- Initialize variables.
7609: -- ---------------------
7693: end if;
7694:
7695: end loop;
7696: IF g_debug_flag = 'Y' THEN
7697: fnd_file.put_line(fnd_file.log,'Ovhd_accounts >>');
7698: END IF;
7699:
7700: EXCEPTION
7701:
7740: l_api_name CONSTANT VARCHAR2(30) := 'CSTPAPBR.insert_account';
7741:
7742: BEGIN
7743: IF g_debug_flag = 'Y' THEN
7744: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin << ');
7745: END IF;
7746:
7747: -- Initialize variables.
7748: -- ---------------------
7858: l_ae_line_tbl(next_record_avail).accounted_dr := l_accounted_value;
7859: l_ae_line_tbl(next_record_avail).accounted_cr := NULL;
7860:
7861: IF g_debug_flag = 'Y' THEN
7862: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': Debit: ' ||
7863: l_ae_line_tbl(next_record_avail).description || ' ' || l_accounted_value);
7864: END IF;
7865: else
7866: l_ae_line_tbl(next_record_avail).entered_cr := nvl(l_entered_value,l_accounted_value);
7868: l_ae_line_tbl(next_record_avail).accounted_cr := l_accounted_value;
7869: l_ae_line_tbl(next_record_avail).accounted_dr := NULL;
7870:
7871: IF g_debug_flag = 'Y' THEN
7872: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': Credit: ' ||
7873: l_ae_line_tbl(next_record_avail).description || ' ' || l_accounted_value);
7874: END IF;
7875:
7876: end if;
7892: l_ae_line_tbl(next_record_avail).rate_or_amount := abs(i_ae_line_rec.transaction_value/i_ae_txn_rec.primary_quantity);
7893: END IF;
7894:
7895: IF g_debug_flag = 'Y' THEN
7896: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': Rate or amount: ' ||
7897: l_ae_line_tbl(next_record_avail).rate_or_amount);
7898: END IF;
7899:
7900: l_ae_line_tbl(next_record_avail).basis_type := 1;
7935: end if;
7936: end if;
7937:
7938: IF g_debug_flag = 'Y' THEN
7939: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': return >> ');
7940: END IF;
7941:
7942: EXCEPTION
7943:
7970: l_stmt_num NUMBER := 0;
7971: l_api_name CONSTANT VARCHAR2(30) := 'CSTPAPBR.balance_account';
7972: BEGIN
7973: IF g_debug_flag = 'Y' THEN
7974: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin << ');
7975: END IF;
7976:
7977: if (l_ae_line_tbl.exists(1)) then
7978: l_stmt_num := 10;
7982: end loop;
7983:
7984: if (l_ent_value = 0 and l_acc_value = 0) then
7985: IF g_debug_flag = 'Y' THEN
7986: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': return >> No balancing done.');
7987: END IF;
7988: return;
7989: end if;
7990:
7995: l_ae_line_tbl(l_last_rec).accounted_dr - l_acc_value;
7996: l_ae_line_tbl(l_last_rec).entered_dr :=
7997: l_ae_line_tbl(l_last_rec).entered_dr - l_ent_value;
7998: IF g_debug_flag = 'Y' THEN
7999: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': adjust debit by: ' || l_acc_value);
8000: END IF;
8001: elsif l_ae_line_tbl(l_last_rec).accounted_cr is not NULL then
8002: l_ae_line_tbl(l_last_rec).accounted_cr :=
8003: l_ae_line_tbl(l_last_rec).accounted_cr + l_acc_value;
8003: l_ae_line_tbl(l_last_rec).accounted_cr + l_acc_value;
8004: l_ae_line_tbl(l_last_rec).entered_cr :=
8005: l_ae_line_tbl(l_last_rec).entered_cr + l_ent_value;
8006: IF g_debug_flag = 'Y' THEN
8007: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': adjust credit by: ' || l_acc_value);
8008: END IF;
8009: end if;
8010: end if;
8011:
8009: end if;
8010: end if;
8011:
8012: IF g_debug_flag = 'Y' THEN
8013: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': return >> ');
8014: END IF;
8015:
8016: EXCEPTION
8017:
8081: and cost_element_id = l_cost_element;
8082:
8083: BEGIN
8084: IF g_debug_flag = 'Y' THEN
8085: fnd_file.put_line(fnd_file.log,'Create_wip_lines << ');
8086: fnd_file.put_line(fnd_file.log,'Transaction type: '||to_char(i_ae_txn_rec.txn_type_id));
8087: END IF;
8088:
8089: -- Initialize local variables.
8082:
8083: BEGIN
8084: IF g_debug_flag = 'Y' THEN
8085: fnd_file.put_line(fnd_file.log,'Create_wip_lines << ');
8086: fnd_file.put_line(fnd_file.log,'Transaction type: '||to_char(i_ae_txn_rec.txn_type_id));
8087: END IF;
8088:
8089: -- Initialize local variables.
8090: -- ---------------------------
8170: x_cost_element_id => l_cost_element
8171: );
8172:
8173: IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
8174: FND_FILE.put_line(FND_FILE.log, l_msg_data);
8175: l_api_message := 'get_CostEle_for_DirectItem returned unexpected error';
8176: FND_MESSAGE.set_name('BOM','CST_API_MESSAGE');
8177: FND_MESSAGE.set_token('TEXT', l_api_message);
8178: FND_MSG_pub.add;
8179: raise fnd_api.g_exc_unexpected_error;
8180: END IF;
8181:
8182: IF (g_debug_flag = 'Y') THEN
8183: FND_FILE.PUT_LINE(FND_FILE.LOG, 'mfg cost_element_id: '||
8184: to_char(l_cost_element));
8185: END IF;
8186:
8187: l_stmt_num := 40;
8443: -- ------------------------------
8444: l_stmt_num := 240;
8445: o_ae_line_rec_tbl := l_ae_line_tbl;
8446: IF g_debug_flag = 'Y' THEN
8447: fnd_file.put_line(fnd_file.log,'Create_wip_ae_lines >>');
8448: END IF;
8449:
8450: EXCEPTION
8451:
8498: process_error EXCEPTION;
8499: BEGIN
8500:
8501: IF g_debug_flag = 'Y' THEN
8502: fnd_file.put_line(fnd_file.log,'Get_accts <<');
8503: END IF;
8504:
8505: IF i_ae_txn_rec.txn_type_id <> 6 THEN
8506:
8548: where we.wip_entity_id = wt.wip_entity_id
8549: and wt.transaction_id = i_ae_txn_rec.transaction_id;
8550:
8551: IF g_debug_flag = 'Y' THEN
8552: fnd_file.put_line(fnd_file.log, 'Entity Type: ' ||to_char(l_entity_type));
8553: END IF;
8554:
8555: /* Bug 6937298 - Modified the If condition below to include lot-based jobs
8556: if (i_ae_txn_rec.txn_type_id <> 6 and l_entity_type in (1,3, 6, 7)) or
8653: from wip_flow_schedules
8654: where wip_entity_id = l_wip_entity_id;
8655: end if;
8656: IF g_debug_flag = 'Y' THEN
8657: fnd_file.put_line(fnd_file.log,'Get_accts >>');
8658: END IF;
8659:
8660: EXCEPTION
8661:
8720: process_error EXCEPTION;
8721: no_txn_det_error EXCEPTION;
8722: BEGIN
8723: IF g_debug_flag = 'Y' THEN
8724: fnd_file.put_line(fnd_file.log,'WIP_accounts << ');
8725: END IF;
8726: -- initialize variables.
8727: -- ---------------------
8728: l_err_rec.l_err_num := 0;
8851: RAISE process_error;
8852: END IF;
8853: ELSE
8854: IF g_debug_flag = 'Y' THEN
8855: fnd_file.put_line(fnd_file.log,'No Cost for element...');
8856: END IF;
8857: END IF;
8858:
8859: ---------------------------------------------------------------------------------------
8924: END IF; -- End of IF l_wip_variance <> 0
8925: END LOOP;
8926:
8927: IF g_debug_flag = 'Y' THEN
8928: fnd_file.put_line(fnd_file.log,'WIP_accounts >>');
8929: END IF;
8930:
8931: EXCEPTION
8932:
9000:
9001: l_inv_ccid := -1;
9002:
9003: IF g_debug_flag = 'Y' THEN
9004: fnd_file.put_line(fnd_file.log,'Get_Intercompany_account << ');
9005: END IF;
9006:
9007: l_stmt_num := 5;
9008: SELECT MOD(SUM(DECODE(MP.process_enabled_flag,'Y',1,2)), 2)
9011: WHERE mp.organization_id = i_ae_txn_rec.organization_id
9012: OR mp.organization_id = i_ae_txn_rec.xfer_organization_id;
9013:
9014: IF g_debug_flag = 'Y' THEN
9015: FND_FILE.put_line(FND_FILE.LOG, 'l_pd_txfr_ind:' || l_pd_txfr_ind);
9016: END IF;
9017:
9018: l_stmt_num := 7;
9019:
9037: l_shipping_cg_id := -1;
9038: END;
9039:
9040: IF g_debug_flag = 'Y' THEN
9041: FND_FILE.put_line(FND_FILE.LOG, 'l_shipping_cg_id:' || l_shipping_cg_id);
9042: END IF;
9043:
9044: if (i_ae_txn_rec.txn_action_id in (21, 22)) then
9045: l_from_org := i_ae_txn_rec.organization_id;
9088: WHERE org_information_context = 'Accounting Information'
9089: AND organization_id = l_to_org;
9090:
9091: if (g_debug_flag = 'Y') then
9092: FND_FILE.put_line(FND_FILE.LOG, 'l_from_ou = ' || l_from_ou ||
9093: ' l_to_ou = ' || l_to_ou || ' l_rcv_coa_id = ' || l_rcv_coa_id);
9094: end if;
9095:
9096: if (i_ae_txn_rec.txn_action_id in (15, 21)) then
9178:
9179: end if;
9180:
9181: if (g_debug_flag = 'Y') then
9182: FND_FILE.put_line(FND_FILE.LOG, 'l_cogs_ccid = ' || l_cogs_ccid);
9183: end if;
9184:
9185: /* Return COGS Account */
9186: l_acct_ccid := l_cogs_ccid;
9206: RAISE inv_exp_acct_err;
9207: END IF;
9208:
9209: if (g_debug_flag = 'Y') then
9210: FND_FILE.put_line(FND_FILE.LOG, 'l_inv_ccid = ' || l_inv_ccid);
9211: end if;
9212:
9213: /* Return IC Accrual Account */
9214: l_acct_ccid := l_inv_ccid;
9216: end if;
9217:
9218:
9219: IF g_debug_flag = 'Y' THEN
9220: FND_FILE.put_line(FND_FILE.LOG, 'l_acct_ccid = ' || l_acct_ccid);
9221: fnd_file.put_line(fnd_file.log,'Get_Intercompany_account >>');
9222: END IF;
9223:
9224: return l_acct_ccid;
9217:
9218:
9219: IF g_debug_flag = 'Y' THEN
9220: FND_FILE.put_line(FND_FILE.LOG, 'l_acct_ccid = ' || l_acct_ccid);
9221: fnd_file.put_line(fnd_file.log,'Get_Intercompany_account >>');
9222: END IF;
9223:
9224: return l_acct_ccid;
9225:
9333:
9334: BEGIN
9335:
9336: IF g_debug_flag = 'Y' THEN
9337: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin <<'
9338: || ' transaction_id: ' || i_ae_txn_rec.transaction_id);
9339: END IF;
9340:
9341: -- Initialize variables.
9348:
9349: l_stmt_num := 10;
9350:
9351: IF g_debug_flag = 'Y' THEN
9352: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': return >> ' ||
9353: '(No accounting for Expense item)');
9354: END IF;
9355:
9356: RETURN;
9395: AND category_id = i_ae_txn_rec.category_id;
9396: EXCEPTION
9397: WHEN no_data_found THEN
9398: l_stmt_num := 70;
9399: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num ||
9400: ': Category : '||to_char(i_ae_txn_rec.category_id) ||' has no accounts defined');
9401: RAISE no_mfca_acct_error;
9402: END;
9403:
9420:
9421: l_stmt_num := 90;
9422:
9423: IF g_debug_flag = 'Y' THEN
9424: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
9425: ': cost_group_id = ' || i_ae_txn_rec.cost_group_id ||
9426: ': txn_cost_group_id ' || l_txn_cost_group_id ||
9427: ': txfr_txn_cost_group_id ' || l_txfr_txn_cost_group_id);
9428: END IF;
9434:
9435: l_stmt_num := 100;
9436:
9437: IF g_debug_flag = 'Y' THEN
9438: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Transfer Within Same Cost Group');
9439: END IF;
9440:
9441: -- Case I Dis-Dis, same CG, treat as SubInv transfer
9442: -- Internal Order Issue 34-1-8 :
9448:
9449: l_stmt_num := 110;
9450:
9451: IF g_debug_flag = 'Y' THEN
9452: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': 34-1-8 Dr Expense and Cr Inv');
9453: END IF;
9454:
9455: l_dr_flag := TRUE;
9456:
9534:
9535: l_stmt_num := 170;
9536:
9537: IF g_debug_flag = 'Y' THEN
9538: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': 27-17-7 No accounting');
9539: END IF;
9540:
9541: END IF;
9542:
9544:
9545: l_stmt_num := 180;
9546:
9547: IF g_debug_flag = 'Y' THEN
9548: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Transfer across Cost Group');
9549: END IF;
9550:
9551: /* Check if it is a transfer between Process and Discrete Orgs */
9552: SELECT MOD(SUM(DECODE(process_enabled_flag,'Y',1,2)), 2)
9561:
9562: l_stmt_num := 200;
9563:
9564: IF g_debug_flag = 'Y' THEN
9565: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Discrete-Discrete X-fer');
9566: END IF;
9567:
9568: IF (i_ae_txn_rec.txn_action_id = 1) then
9569: -- Case II Dis-Dis, across CG. Sending CG
9643:
9644: IF (l_pacp_flag = 1) THEN
9645: l_stmt_num := 250;
9646: IF g_debug_flag = 'Y' THEN
9647: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
9648: ': Using PAC Absorption Cost: ');
9649: END IF;
9650:
9651: l_io_rcv_value := l_pacp_pwac_cost;
9652:
9653: ELSIF (l_prev_period_flag = 1) THEN
9654: l_stmt_num := 260;
9655: IF g_debug_flag = 'Y' THEN
9656: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
9657: ': Using prior period PWAC cost: ');
9658: END IF;
9659:
9660: l_io_rcv_value := l_prev_period_pwac_cost;
9661:
9662: ELSIF (l_perp_ship_flag = 1) THEN
9663: l_stmt_num := 270;
9664: IF g_debug_flag = 'Y' THEN
9665: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
9666: ': Using MTA cost');
9667: END IF;
9668:
9669: l_io_rcv_value := (l_perp_ship_value / abs(i_ae_txn_rec.primary_quantity));
9672:
9673: l_stmt_num := 280;
9674:
9675: IF g_debug_flag = 'Y' THEN
9676: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': PACP/PriorPrd/MTA value not returned');
9677: END IF;
9678:
9679: raise process_error;
9680: END IF; /* (l_pacp_flag = 1) */
9683:
9684: l_dr_flag := TRUE;
9685:
9686: IF g_debug_flag = 'Y' THEN
9687: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
9688: ': l_io_rcv_value = ' || l_io_rcv_value);
9689: END IF;
9690:
9691: l_ae_line_rec.account := l_io_rcv_acct;
9773: -- Cr. Payables @ Sending Org cost (from CPIC/Prior Prd PWAC/PerpMTA)
9774:
9775: l_stmt_num := 370;
9776: IF g_debug_flag = 'Y' THEN
9777: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': 27-17-7 Dr Exp and Cr Paybls');
9778: END IF;
9779:
9780: SELECT mip.interorg_payables_account,
9781: distribution_account_id
9809:
9810: IF (l_pacp_flag = 1) THEN
9811: l_stmt_num := 400;
9812: IF g_debug_flag = 'Y' THEN
9813: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
9814: ': Using PAC Absorption Cost: ');
9815: END IF;
9816:
9817: l_io_pay_value := l_pacp_pwac_cost;
9818:
9819: ELSIF (l_prev_period_flag = 1) THEN
9820: l_stmt_num := 410;
9821: IF g_debug_flag = 'Y' THEN
9822: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
9823: ': Using prior period PWAC cost: ');
9824: END IF;
9825:
9826: l_io_pay_value := l_prev_period_pwac_cost;
9827:
9828: ELSIF (l_perp_ship_flag = 1) THEN
9829: l_stmt_num := 420;
9830: IF g_debug_flag = 'Y' THEN
9831: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
9832: ': Using MTA cost');
9833: END IF;
9834:
9835: l_io_pay_value := (l_perp_ship_value / abs(i_ae_txn_rec.primary_quantity));
9838:
9839: l_stmt_num := 430;
9840:
9841: IF g_debug_flag = 'Y' THEN
9842: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': PACP/PriorPrd/MTA value not returned');
9843: END IF;
9844:
9845: RAISE process_error;
9846:
9850:
9851: l_dr_flag := FALSE;
9852:
9853: IF g_debug_flag = 'Y' THEN
9854: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
9855: ': l_io_pay_value = ' || l_io_pay_value);
9856: END IF;
9857:
9858: l_ae_line_rec.account := l_io_pay_acct;
9911:
9912: l_stmt_num := 500;
9913:
9914: IF g_debug_flag = 'Y' THEN
9915: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Process-Discrete X-fer');
9916: END IF;
9917:
9918: IF (i_ae_txn_rec.txn_action_id = 1) then
9919: -- Case IV Dis-OPM Xfer, Discrete is Sending CG
9924:
9925: l_stmt_num := 510;
9926:
9927: IF g_debug_flag = 'Y' THEN
9928: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': 34-1-8 Dr Rcv and Cr Inv');
9929: END IF;
9930:
9931: /* Debit Receivables @ Transfer Price */
9932:
10057:
10058: l_stmt_num := 620;
10059:
10060: IF g_debug_flag = 'Y' THEN
10061: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': 27-17-7 Dr Exp and Cr Paybls');
10062: END IF;
10063:
10064: SELECT mip.interorg_payables_account,
10065: distribution_account_id,
10131:
10132: l_stmt_num := 680;
10133:
10134: IF g_debug_flag = 'Y' THEN
10135: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': return >>');
10136: END IF;
10137:
10138: EXCEPTION
10139:
10137:
10138: EXCEPTION
10139:
10140: when no_mfca_acct_error then -- INVCONV
10141: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Error processing transaction ' || i_ae_txn_rec.transaction_id);
10142: o_ae_err_rec.l_err_num := 30005;
10143: o_ae_err_rec.l_err_code := 'CST_PAC_NO_MFCA_ACCTS';
10144: FND_MESSAGE.set_name('BOM', 'CST_PAC_NO_MFCA_ACCTS');
10145: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
10144: FND_MESSAGE.set_name('BOM', 'CST_PAC_NO_MFCA_ACCTS');
10145: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
10146:
10147: when no_interorg_profit_acct_error then
10148: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': Error processing transaction ' || i_ae_txn_rec.transaction_id);
10149: o_ae_err_rec.l_err_num := 30005;
10150: o_ae_err_rec.l_err_code := 'CST_NO_INTERORG_PROFIT_ACCT';
10151: FND_MESSAGE.set_name('BOM', 'CST_NO_INTERORG_PROFIT_ACCT');
10152: o_ae_err_rec.l_err_msg := FND_MESSAGE.Get;
10211:
10212: BEGIN
10213:
10214: IF g_debug_flag = 'Y' THEN
10215: fnd_file.put_line(fnd_file.log, l_api_name || ': ' || l_stmt_num || ': begin <<<'
10216: || ' transaction_id: ' || i_ae_txn_rec.transaction_id);
10217: END IF;
10218:
10219: -- Initialize variables.
10307: AND CPIC.COST_GROUP_ID = i_ae_txn_rec.cost_group_id
10308: AND CPIC.PAC_PERIOD_ID = i_ae_txn_rec.accounting_period_id;
10309:
10310: IF g_debug_flag = 'Y' THEN
10311: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
10312: ': Using PAC Absorption Cost: ');
10313: END IF;
10314:
10315: IF (l_txfr_percent <> 0) THEN
10372:
10373: o_prev_period_flag := 1;
10374:
10375: IF g_debug_flag = 'Y' THEN
10376: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
10377: ': Using prior period PWAC cost: ');
10378: END IF;
10379:
10380: l_stmt_num := 200;
10392:
10393: o_perp_ship_flag := 1;
10394:
10395: IF g_debug_flag = 'Y' THEN
10396: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num ||
10397: ': Using MTA cost');
10398: END IF;
10399:
10400: BEGIN
10445: END IF; /* End Same LE PACP available */
10446:
10447: l_stmt_num := 260;
10448: IF g_debug_flag = 'Y' THEN
10449: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num
10450: || ': o_pacp_flag :' || o_pacp_flag
10451: || ': o_pacp_pwac_cost :' || o_pacp_pwac_cost
10452: || ': o_prev_period_flag :' || o_prev_period_flag
10453: || ': o_prev_period_pwac_cost :' || o_prev_period_pwac_cost
10453: || ': o_prev_period_pwac_cost :' || o_prev_period_pwac_cost
10454: || ': o_perp_ship_flag :' || o_perp_ship_flag
10455: || ': o_perp_ship_value :' || o_perp_ship_value
10456: || ': o_txfr_credit :' || o_txfr_credit);
10457: fnd_file.put_line(fnd_file.log,l_api_name || ': ' || l_stmt_num || ': return >>>' );
10458: END IF;
10459:
10460: EXCEPTION
10461:
10515: l_hook_used :=0;
10516: l_stmt_num := 5;
10517:
10518: IF g_debug_flag= 'Y' THEN
10519: FND_FILE.PUT_LINE( FND_FILE.log, 'CompEncumbrance_IntOrdersExp <<< ');
10520: FND_FILE.PUT_LINE( FND_FILE.log, 'Req Line Identifier: '||p_req_line_id);
10521: FND_FILE.PUT_LINE( FND_FILE.log, 'Primary Quantity Encumbered before: '||p_total_primary_qty );
10522: END IF;
10523:
10516: l_stmt_num := 5;
10517:
10518: IF g_debug_flag= 'Y' THEN
10519: FND_FILE.PUT_LINE( FND_FILE.log, 'CompEncumbrance_IntOrdersExp <<< ');
10520: FND_FILE.PUT_LINE( FND_FILE.log, 'Req Line Identifier: '||p_req_line_id);
10521: FND_FILE.PUT_LINE( FND_FILE.log, 'Primary Quantity Encumbered before: '||p_total_primary_qty );
10522: END IF;
10523:
10524: /* 1. Get the budget_account, quantity ordered, and UOM from the Req */
10517:
10518: IF g_debug_flag= 'Y' THEN
10519: FND_FILE.PUT_LINE( FND_FILE.log, 'CompEncumbrance_IntOrdersExp <<< ');
10520: FND_FILE.PUT_LINE( FND_FILE.log, 'Req Line Identifier: '||p_req_line_id);
10521: FND_FILE.PUT_LINE( FND_FILE.log, 'Primary Quantity Encumbered before: '||p_total_primary_qty );
10522: END IF;
10523:
10524: /* 1. Get the budget_account, quantity ordered, and UOM from the Req */
10525: l_stmt_num := 10;
10540: and rd.requisition_line_id = rl.requisition_line_id
10541: and rl.UNIT_MEAS_LOOKUP_CODE = um.unit_of_measure;
10542:
10543: if g_debug_flag= 'Y' then
10544: fnd_file.put_line(fnd_file.log, 'Unit Price: '||l_unit_price||'Encumbrance Account: '||x_encumbrance_account);
10545: end if;
10546:
10547: /* Get UOM for this item/org from MSI */
10548: l_stmt_num := 30;
10559: to_unit => l_doc_uom_code,
10560: item_id => p_item_id,
10561: uom_rate => l_uom_rate );
10562: IF ( l_uom_rate = -99999) THEN
10563: fnd_file.put_line(fnd_file.log,'Inv_Convert.inv_um_conversion() failed to get the UOM rate');
10564: RAISE process_error;
10565: END IF;
10566:
10567: if g_debug_flag= 'Y' then
10564: RAISE process_error;
10565: END IF;
10566:
10567: if g_debug_flag= 'Y' then
10568: fnd_file.put_line(fnd_file.log, 'Primary UOM: '||l_primary_uom_code);
10569: end if;
10570: l_doc_rcv_qty := p_total_primary_qty * l_uom_rate;
10571: l_doc_primary_qty := p_primary_qty * l_uom_rate;
10572:
10570: l_doc_rcv_qty := p_total_primary_qty * l_uom_rate;
10571: l_doc_primary_qty := p_primary_qty * l_uom_rate;
10572:
10573: if g_debug_flag= 'Y' then
10574: fnd_file.put_line(fnd_file.log, 'Document Received Quantity: '||l_doc_rcv_qty||' Document Primary Quantity: '||l_doc_primary_qty);
10575: end if;
10576:
10577: /* The Requisition is always in the funtional currency */
10578: /* No need of currency conversion */
10588: END IF;
10589:
10590:
10591: IF g_debug_flag= 'Y' THEN
10592: fnd_file.put_line(fnd_file.log, 'Encumbrance Amount: '||x_encumbrance_amount);
10593: FND_FILE.PUT_LINE( FND_FILE.log, 'CompEncumbrance_IntOrdersExp >>>');
10594: END IF;
10595:
10596: EXCEPTION
10589:
10590:
10591: IF g_debug_flag= 'Y' THEN
10592: fnd_file.put_line(fnd_file.log, 'Encumbrance Amount: '||x_encumbrance_amount);
10593: FND_FILE.PUT_LINE( FND_FILE.log, 'CompEncumbrance_IntOrdersExp >>>');
10594: END IF;
10595:
10596: EXCEPTION
10597: when process_error then
10640: l_err_rec.l_err_msg := '';
10641:
10642: l_stmt_num := 5;
10643: if g_debug_flag= 'Y' then
10644: fnd_file.put_line(fnd_file.log, 'CompEncumbrance_IntOrdersExp (T) <<');
10645: end if;
10646: l_stmt_num := 10;
10647:
10648: SELECT
10684: and organization_id = l_organization_id
10685: and ( transaction_date < l_txn_date or (transaction_date = l_txn_date and transaction_id < p_transaction_id));
10686:
10687: if g_debug_flag= 'Y' then
10688: fnd_file.put_line(fnd_file.log, 'Total Received Primary Qty just before current receipt transaction: '||l_total_primary_qty);
10689: end if;
10690:
10691:
10692: /* Get Requisition Line ID */
10739: RETURN;
10740: END IF;
10741: END IF;
10742: if g_debug_flag= 'Y' then
10743: fnd_file.put_line(fnd_file.log, 'Requisition Line ID: '||l_req_line_id);
10744: end if;
10745:
10746: l_primary_qty := abs(l_primary_qty);
10747: l_total_primary_qty := abs(l_total_primary_qty);
10746: l_primary_qty := abs(l_primary_qty);
10747: l_total_primary_qty := abs(l_total_primary_qty);
10748:
10749: if g_debug_flag= 'Y' then
10750: fnd_file.put_line(fnd_file.log, 'Total Received Primary Qty so far just before current receipt transaction: '||l_total_primary_qty);
10751: end if;
10752:
10753: l_stmt_num := 30;
10754: CompEncumbrance_IntOrdersExp (
10764: x_encumbrance_account => x_encumbrance_account,
10765: o_ae_err_rec => l_err_rec );
10766:
10767: if g_debug_flag= 'Y' then
10768: fnd_file.put_line(fnd_file.log, 'CompEncumbrance_IntOrdersExp (T) >>');
10769: end if;
10770: if(l_err_rec.l_err_num <> 0 and l_err_rec.l_err_num is not null) then
10771: raise process_error;
10772: end if;