[Home] [Help]
387: IF l_so_line_id IS NOT NULL THEN
388: -- A Sales Order is referenced, use the average cost of the Sales Order Issues
389: l_stmt_num := 74;
390: INSERT
391: INTO mtl_cst_txn_cost_details (
392: transaction_id,
393: organization_id,
394: inventory_item_id,
395: cost_element_id,
442: -- No Sales Order is referenced and the cost method is FIFO, use the cost of
443: -- earliest positive layer if one exists
444: l_stmt_num := 76;
445: INSERT
446: INTO mtl_cst_txn_cost_details (
447: transaction_id,
448: organization_id,
449: inventory_item_id,
450: cost_element_id,
1761: if (l_err_num <> 0) then
1762: raise process_error;
1763: end if;
1764: else
1765: insert into mtl_cst_txn_cost_details (
1766: transaction_id,
1767: organization_id,
1768: cost_element_id,
1769: level_type,
1942: NULL,
1943: 'N',
1944: 0,
1945: 'N'
1946: FROM mtl_cst_txn_cost_details ctcd
1947: WHERE ctcd.transaction_id = l_txn_update_id
1948: AND ctcd.organization_id = l_std_org
1949: /* AND ctcd.transaction_cost >= 0 */; -- modified for bug #3835412
1950:
2051: NULL,
2052: 'N',
2053: 0,
2054: 'N'
2055: FROM mtl_cst_txn_cost_details ctcd
2056: WHERE ctcd.transaction_id = l_txn_update_id
2057: AND ctcd.organization_id = l_std_org
2058: /* AND ctcd.transaction_cost >= 0 */; -- modified for bug #3835412
2059:
2146: NULL,
2147: 'N',
2148: 0,
2149: 'N'
2150: FROM mtl_cst_txn_cost_details ctcd
2151: WHERE ctcd.transaction_id = decode(i_txn_org_id, l_std_org, l_txfr_txn_id, l_txn_update_id) -- sending txn id
2152: AND ctcd.organization_id = l_std_org
2153: /* AND ctcd.transaction_cost >= 0 */; -- modified for bug #3835412
2154:
2447: into l_from_cost_org
2448: from mtl_parameters
2449: where organization_id = i_from_org;
2450:
2451: insert into mtl_cst_txn_cost_details (
2452: transaction_id,
2453: organization_id,
2454: cost_element_id,
2455: level_type,
2495:
2496: elsif (i_exp_flag = 1) then
2497: l_stmt_num := 15;
2498:
2499: insert into mtl_cst_txn_cost_details (
2500: transaction_id,
2501: organization_id,
2502: cost_element_id,
2503: level_type,
2539:
2540: else
2541:
2542: l_stmt_num := 20;
2543: insert into mtl_cst_txn_cost_details (
2544: transaction_id,
2545: organization_id,
2546: cost_element_id,
2547: level_type,
2588: l_stmt_num := 30;
2589: -- Find out if there is already exist this level material overhead in mctcd.
2590: select count(*)
2591: into l_movh_cnt
2592: from mtl_cst_txn_cost_details mctcd
2593: where mctcd.transaction_id = i_txn_update_id
2594: and mctcd.organization_id = i_to_org
2595: and mctcd.inventory_item_id = i_item_id
2596: and mctcd.level_type = 1
2599: if (l_movh_cnt > 0) then
2600: l_stmt_num := 40;
2601: select NVL(mctcd.transaction_cost,0)
2602: into l_rcv_movh
2603: from mtl_cst_txn_cost_details mctcd
2604: where mctcd.transaction_id = i_txn_update_id
2605: and mctcd.organization_id = i_to_org
2606: and mctcd.inventory_item_id = i_item_id
2607: and mctcd.level_type = 1
2629: -- If there already exist movh in mctcd, then update mctcd with new movhd
2630: -- value. Otherwise insert the new movhd into mctcd
2631: if (l_movh_cnt > 0) then
2632: l_stmt_num := 50;
2633: update mtl_cst_txn_cost_details mctcd
2634: set mctcd.transaction_cost = l_rcv_movh
2635: where mctcd.transaction_id = i_txn_update_id
2636: and mctcd.organization_id = i_to_org
2637: and mctcd.inventory_item_id = i_item_id
2638: and mctcd.level_type = 1
2639: and mctcd.cost_element_id = 2;
2640: elsif (l_rcv_movh > 0) then
2641: l_stmt_num := 60;
2642: insert into mtl_cst_txn_cost_details (
2643: transaction_id,
2644: organization_id,
2645: cost_element_id,
2646: level_type,
2823: -- populate mctcd
2824: if (i_hook = 0) then -- if no hook is used then populate mctcd
2825: if l_temp_element_cost(l_index_counter) <> 0 then
2826: l_stmt_num := 25;
2827: insert into mtl_cst_txn_cost_details(
2828: TRANSACTION_ID,
2829: ORGANIZATION_ID,
2830: COST_ELEMENT_ID,
2831: LEVEL_TYPE,
3110: -- mctcd will be created before sub_transfer is called.
3111:
3112: select count(*)
3113: into l_txn_cost_exist
3114: from mtl_cst_txn_cost_details
3115: where transaction_id = i_txn_id
3116: and organization_id = i_org_id;
3117:
3118: l_stmt_num := 70;
3618: if (l_exp_item = 0 and l_layer_chg = 1 and l_to_exp = 0) then
3619: if i_hook = 0 then -- no cost hook
3620: select count(*) -- check for existing mctcd
3621: into l_txn_cost_exist
3622: from mtl_cst_txn_cost_details
3623: where transaction_id = i_txn_id
3624: and organization_id = i_org_id;
3625: if l_txn_cost_exist = 0 then -- populate mctcd if it does not exist
3626: insert into mtl_cst_txn_cost_details(
3622: from mtl_cst_txn_cost_details
3623: where transaction_id = i_txn_id
3624: and organization_id = i_org_id;
3625: if l_txn_cost_exist = 0 then -- populate mctcd if it does not exist
3626: insert into mtl_cst_txn_cost_details(
3627: transaction_id,
3628: organization_id,
3629: cost_element_id,
3630: level_type,
3751:
3752: if (l_exp_item = 0 and l_layer_chg = 0 and l_from_exp = 1 and l_to_exp = 0) then
3753: if i_hook = 0 and l_txn_cost_exist = 0 then -- no cost hook and no mctcd
3754: if l_inv_layer_id = 0 then -- no layer cost
3755: insert into mtl_cst_txn_cost_details(
3756: transaction_id,
3757: organization_id,
3758: cost_element_id,
3759: level_type,
3784: sysdate,
3785: i_item_id,
3786: 0);
3787: else -- has layer cost
3788: insert into mtl_cst_txn_cost_details(
3789: transaction_id,
3790: organization_id,
3791: cost_element_id,
3792: level_type,
4562: fnd_file.put_line(fnd_file.log, 'inserting to MCTCD for txn: ' || i_txn_id || '. trxCost: ' || l_rcv_txn_cost);
4563: END IF;
4564:
4565: l_stmt_num := 80;
4566: insert into mtl_cst_txn_cost_details (
4567: transaction_id,
4568: organization_id,
4569: cost_element_id,
4570: level_type,