2339: l_return_status VARCHAR2(11);
2340: l_msg_data VARCHAR2(2000);
2341: l_wms_flg NUMBER;
2342: process_error EXCEPTION;
2343: -- Changes for PJM for Standard Costing
2344: l_pjm_flg NUMBER;
2345: l_debug VARCHAR2(1);
2346:
2347: --Changes for MOH Absorption
2650: where MIP.from_organization_id = l_from_org
2651: and MIP.to_organization_id = l_to_org
2652: and MMT.transaction_id = i_txn_id;
2653:
2654: -- Standard org computation
2655: l_std_from_org := CSTPAVCP.standard_cost_org(l_from_org);
2656: l_std_to_org := CSTPAVCP.standard_cost_org(l_to_org);
2657:
2658: l_stmt_num := 40;
2651: and MIP.to_organization_id = l_to_org
2652: and MMT.transaction_id = i_txn_id;
2653:
2654: -- Standard org computation
2655: l_std_from_org := CSTPAVCP.standard_cost_org(l_from_org);
2656: l_std_to_org := CSTPAVCP.standard_cost_org(l_to_org);
2657:
2658: l_stmt_num := 40;
2659:
2652: and MMT.transaction_id = i_txn_id;
2653:
2654: -- Standard org computation
2655: l_std_from_org := CSTPAVCP.standard_cost_org(l_from_org);
2656: l_std_to_org := CSTPAVCP.standard_cost_org(l_to_org);
2657:
2658: l_stmt_num := 40;
2659:
2660: /* Bug 2926258 - changed default to -1 to support org_id=0 */
2665:
2666: -- For direct interorg transfers, we only care about the transction org id.
2667: --
2668: -- OPM INVCONV umoogala: For process-discrete xfer, txn_org will always be
2669: -- standard costing org. Transfer to standard costing org will be processed
2670: -- by standard cost worker.
2671: --
2672: if ((i_txn_act_id = 3 and i_txn_org_id = i_org_id) OR
2673: (l_pd_txfr_ind = 1)) -- OPM INVCONV umoogala
2666: -- For direct interorg transfers, we only care about the transction org id.
2667: --
2668: -- OPM INVCONV umoogala: For process-discrete xfer, txn_org will always be
2669: -- standard costing org. Transfer to standard costing org will be processed
2670: -- by standard cost worker.
2671: --
2672: if ((i_txn_act_id = 3 and i_txn_org_id = i_org_id) OR
2673: (l_pd_txfr_ind = 1)) -- OPM INVCONV umoogala
2674: then
2683: from mtl_system_items
2684: where inventory_item_id = i_item_id
2685: and organization_id = l_std_org;
2686:
2687: -- if the standard org is the transaction org id then need to find out
2688: -- expense sub flag and inventory accounts. Otherwise we use intransit
2689: -- accounts.
2690:
2691: if (l_std_org = i_txn_org_id) then
2695: else
2696: l_wms_flg := 0;
2697: end if;
2698:
2699: /* Changes for PJM for Standard costing */
2700: l_stmt_num := 47;
2701: SELECT decode(nvl(cost_group_accounting,0),0,0,
2702: decode(nvl(project_reference_enabled,0),1,1,0))
2703: INTO l_pjm_flg
2712: from mtl_secondary_inventories msi
2713: where msi.organization_id = l_std_org
2714: and secondary_inventory_name = l_subinv;
2715:
2716: /* Changes for PJM for Standard Costing */
2717: if (l_wms_flg = 0 AND l_pjm_flg = 0) then
2718: select material_account, material_overhead_account, resource_account,
2719: outside_processing_account, overhead_account,
2720: nvl(expense_account, l_std_exp_acct)
3309: if (l_err_num <> 0) then
3310: raise process_error;
3311: end if;
3312:
3313: elsif ((l_std_exp_item = 0) and (i_exp_item = 0)) then /* Standard cost org */
3314: /* Credit inventory at sending org's cost */
3315: if (l_std_exp_sub = 1) then
3316: distribute_accounts(l_from_org, i_txn_id,
3317: 0,i_cost_grp_id,i_txn_act_id,
3600:
3601: fnd_file.put_line(fnd_file.log,'ppv:' || l_ppv);
3602:
3603:
3604: -- Changes for PJM for Standard Costing
3605: l_stmt_num := 95;
3606: update mtl_material_transactions
3607: set variance_amount = l_ppv * abs(l_rcv_qty)
3608: where transaction_id = i_txn_id
3869:
3870: fnd_file.put_line(fnd_file.log,'ppv:' || l_ppv);
3871:
3872:
3873: /* Changes for PJM for Standard Costing */
3874: l_stmt_num := 95;
3875: update mtl_material_transactions
3876: set variance_amount = l_ppv * abs(l_rcv_qty)
3877: where transaction_id = i_txn_id
4212:
4213: end if; -- OPM INVCONV umoogala
4214: */
4215:
4216: elsif (l_std_exp_item = 0) then /* Standard Cost Org */
4217:
4218: fnd_file.put_line(fnd_file.log,'Std org: Dr inv at receiving org cost');
4219:
4220:
4743: end if;
4744:
4745: l_stmt_num := 20;
4746: -- hit up MP for some values
4747: select primary_cost_method, -- Standard costing orgs will have to call the new inventory_accounts_std() procedure
4748: deferred_cogs_account
4749: into l_cost_method,
4750: l_def_cogs_acct_id
4751: from mtl_parameters
5227: INTO l_pjm_flg
5228: FROM MTL_PARAMETERS
5229: WHERE organization_id = i_org_id;
5230:
5231: /* Changes for PJM Standard Costing. */
5232: if (l_wms_flg=0 AND l_pjm_flg=0 AND i_subinv is not null) then
5233: l_stmt_num := 50;
5234:
5235: SELECT
5889: fnd_file.put_line(fnd_file.log,'i_elemental:' || i_elemental);
5890: fnd_file.put_line(fnd_file.log,'i_ovhd_absp:' || i_ovhd_absp);
5891:
5892:
5893: -- For the logical txns introduced in the dropshipment project, standard costing
5894: -- orgs will also call the average cost distribution processor. A few changes
5895: -- are needed to distribute_accounts() because of this so l_cost_method stores
5896: -- the costing method.
5897: l_stmt_num := 0;
6855: |-------------------------------------------------------------------------
6856: | OPM INVCONV umoogala 15-Apr-2005 Process-Discrete Xfers Enh.
6857: |
6858: | added new function cost_process_discrete_trx to cost transfer
6859: | involving Discrete Standard Costing Orgs only. This new routine will
6860: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6861: | be called from cmlmcw.lpc.
6862: |
6863: | Note: Process Mfg. Orgs are always marked as Standard Costing Orgs.
6859: | involving Discrete Standard Costing Orgs only. This new routine will
6860: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6861: | be called from cmlmcw.lpc.
6862: |
6863: | Note: Process Mfg. Orgs are always marked as Standard Costing Orgs.
6864: |
6865: | All the entries are for the transaction org only i.e., discrete
6866: | costing orgs.
6867: | All the intransit entries are booked using new logical transaction
7099: l_debug := fnd_profile.value('MRP_DEBUG');
7100:
7101: /* Check if the organization_id and/or transfer_organization_id
7102: are average or FIFO/LIFO orgs. If so, error out this transaction, since it is just meant
7103: for Standard Costing
7104: */
7105: l_stmt_num := 10;
7106:
7107:
7199:
7200: /*----------------------------------------------------------------------+
7201: -- set PJM flag
7202: +----------------------------------------------------------------------*/
7203: /* Changes for PJM Standard Costing. */
7204: /*Check if cost group accounting has been enabled. */
7205: l_stmt_num := 55;
7206:
7207: SELECT decode(nvl(cost_group_accounting,0),0,0,
7428: end if; /* if (!wms_flg ) */
7429:
7430:
7431: /*----------------------------------------------------------------------+
7432: |Insert standard cost into mtl_cst_actual_cost_details
7433: +----------------------------------------------------------------------*/
7434: fnd_file.put_line(fnd_file.log, 'inserting into mcacd');
7435:
7436: l_stmt_num := 280;
7448: end if;
7449:
7450:
7451: /*----------------------------------------------------------------------+
7452: |Call standard cost distribution hook. Return code of 1 means that the
7453: |hook has been used.
7454: +----------------------------------------------------------------------*/
7455:
7456: l_stmt_num := 290;
8323: /*----------------------------------------------------------------------+
8324: | Dr receiving Inter-org PPV
8325: +----------------------------------------------------------------------*/
8326:
8327: /* Changes for PJM Standard Costing - Update MMT with PPV amount*/
8328:
8329:
8330: UPDATE mtl_material_transactions
8331: SET variance_amount = (SELECT -1 * nvl(sum(base_transaction_value),0)