UpdateInventoryCost Stored Procedure

<< Click to Display Table of Contents >>

Navigation:  iVend Database Database > Stored Procedures >

UpdateInventoryCost Stored Procedure

Navigation: iVend Database Database > Stored Procedures >

hm_btn_navigate_prevhm_btn_navigate_tophm_btn_navigate_next

iVend 6.6 Database Help

UpdateInventoryCost Stored Procedure

Collapse All Expand All

iVend Database Database : UpdateInventoryCost Stored Procedure

Description

Used in replication to update the cost of an item if the costing method is set to enterprise

Properties

Creation Date

4/13/2015 12:00 PM

Encrypted

dbimages_boolean-false

Ansi Nulls

dbimages_boolean-true

Parameters

Parameter

Direction

Description

Data Type

Size

@pProductCostUpdateLogKey

In

 

VarWChar

50

@RETURN_VALUE

Return Value

 

Integer

4

Objects that UpdateInventoryCost depends on

 

Database Object

Object Type

Description

Dep Level

InvInventoryItem table

InvInventoryItem

Table

Stores inventory details for each Product for each Warehouse

1

InvProductCostUpdateLog table

InvProductCostUpdateLog

Table

Stores the log information for the Product cost

1

InvWarehouse table

InvWarehouse

Table

Defines a list of all warehouses defined in the system.

1

Procedure Source Code

CREATE PROCEDURE [dbo].[UpdateInventoryCost]

(

@pProductCostUpdateLogKey nvarchar(50)

)

AS

BEGIN

SET NOCOUNT ON

Declare @ErrorDesc varchar(255),

@lProductKey nvarchar(50),

@lAverageCost DECIMAL(20,5),

@lSubsidiaryKey nvarchar(50)

  Select @lProductKey = ProductKey , @lAverageCost = UpdatedCost, @lSubsidiaryKey = SubsidiaryKey

  From InvProductCostUpdateLog

  Where ProductCostUpdateLogKey = @pProductCostUpdateLogKey

  Update InvInventoryItem

  Set AverageCost = @lAverageCost

  Where ProductKey = @lProductKey

  And WarehouseKey IN (SELECT WarehouseKey From InvWarehouse Where SubsidiaryKey IN(@lSubsidiaryKey , 0))

IF(@@ERROR <>0)

    BEGIN

  SET @ErrorDesc = 'Error while updating the item cost.'

        GOTO ERRORHANDLER

END

RETURN

ERRORHANDLER:

RAISERROR('%s',16,-1,@ErrorDesc)

RETURN

END

See Also

Related Objects

iVend Database Database

 

 


© 2019 All Rights Reserved.

Send comments on this topic.