DECLARE
vOrganizationId mtl_system_items_vl.organization_id%TYPE := 00;
vConcatenatedSegments mtl_system_items_vl.concatenated_segments%TYPE := 'XX';
vInventoryItemId mtl_system_items_vl.inventory_item_id%TYPE;
vInItemRec inv_item_grp.item_rec_type;
vOutItemRec inv_item_grp.item_rec_type;
vErrorTable inv_item_grp.error_tbl_type;
vControlLevel NUMBER;
vReturnStatus VARCHAR2(1);
eItemNotFound EXCEPTION;
BEGIN
vInventoryItemId := inv_value_to_id.Inventory_Item(p_organization_id => vOrganizationId,
p_inventory_item => vConcatenatedSegments);
IF vInventoryItemId = FND_API.G_MISS_NUM THEN
RAISE eItemNotFound;
END IF;
vControlLevel := ego_item_pub.get_item_attr_control_level(P_ITEM_ATTRIBUTE => 'MTL_SYSTEM_ITEMS.LIST_PRICE_PER_UNIT');
IF vControlLevel = 1 THEN --Master Level
vOrganizationId := ego_item_pub.Get_Master_Organization_Id(P_ORGANIZATION_ID => vOrganizationId);
END IF;
vInItemRec.inventory_item_id := vInventoryItemId; -- inventory_item_id
vInItemRec.organization_id := vOrganizationId; -- organization
vInItemRec.list_price_per_unit := 0;
inv_item_grp.update_item(p_commit => fnd_api.g_true,
p_lock_rows => fnd_api.g_true,
p_validation_level => fnd_api.g_valid_level_full,
p_item_rec => vInItemRec,
x_item_rec => vOutItemRec,
x_return_status => vReturnStatus,
x_error_tbl => vErrorTable);
IF vReturnStatus = fnd_api.g_ret_sts_success THEN
dbms_output.put_line('API Update Status => ' || vReturnStatus);
ELSE
IF vErrorTable.count > 0 THEN
FOR i IN 1 .. vErrorTable.count
LOOP
dbms_output.put_line('Message Name => ' || vErrorTable(i).message_name ||
'Message Text =>' || vErrorTable(i).message_text);
END LOOP;
END IF;
END IF;
EXCEPTION
WHEN eItemNotFound THEN
dbms_output.put_line('Item not found !!!');
WHEN OTHERS THEN
dbms_output.put_line(dbms_utility.format_error_stack);
END;
沒有留言:
張貼留言