The following lines contain the word 'select', 'insert', 'update' or 'delete':
I_LAST_UPDATED_BY IN NUMBER,
I_COST_TYPE_ID IN NUMBER,
I_ITEM_TYPE IN NUMBER,
I_LOT_SIZE IN NUMBER,
I_SHRINKAGE_RATE IN NUMBER,
O_RETURN_CODE OUT NOCOPY NUMBER,
O_RETURN_ERR OUT NOCOPY VARCHAR2
) IS
row_count NUMBER;
select primary_cost_method
into p_cost_method
from mtl_parameters
where organization_id = I_ORGANIZATION_ID;
select count(*)
into row_count
from cst_item_cost_details
where organization_id = I_ORGANIZATION_ID
and inventory_item_id = I_INVENTORY_ITEM_ID
and cost_type_id = p_cost_method
and (level_type = 2
OR
cost_element_id <> 2);
select count(*)
into row_count
from wip_transactions
where organization_id = I_ORGANIZATION_ID
and primary_item_id = I_INVENTORY_ITEM_ID;
select count(*)
into row_count
from wip_move_transactions
where organization_id = I_ORGANIZATION_ID
and primary_item_id = I_INVENTORY_ITEM_ID;
select count(*)
into row_count
from mtl_material_transactions
where organization_id = I_ORGANIZATION_ID
and inventory_item_id = I_INVENTORY_ITEM_ID;
* delete all previously existing costs
*/
delete
from cst_item_cost_details
where organization_id = I_ORGANIZATION_ID
and inventory_item_id = I_INVENTORY_ITEM_ID
and cost_type_id = p_cost_method;
* Bug FP 5218221: The previously existing costs were not being deleted from the
* Summary table - CST_ITEM_COSTS, causing discrepancy between CIC and CICD.
*/
UPDATE cst_item_costs
SET pl_material = 0, pl_material_overhead = 0,
pl_resource = 0, pl_outside_processing = 0,
pl_overhead = 0, tl_material = 0,
tl_material_overhead = 0, tl_resource = 0,
tl_outside_processing = 0, tl_overhead = 0,
material_cost = 0, material_overhead_cost = 0,
resource_cost = 0, outside_processing_cost = 0,
overhead_cost = 0, pl_item_cost = 0,
tl_item_cost = 0, item_cost = 0,
unburdened_cost = 0, burden_cost = 0,
last_update_date = SYSDATE,
last_updated_by = i_last_updated_by
WHERE inventory_item_id = i_inventory_item_id
AND organization_id = i_organization_id
AND cost_type_id = p_cost_method;
I_LAST_UPDATED_BY,
I_COST_TYPE_ID,
I_ITEM_TYPE,
I_LOT_SIZE,
I_SHRINKAGE_RATE,
retval,
retmsg);