BatchLocationQuantityUpdates Stored Procedure

<< Click to Display Table of Contents >>

Navigation:  iVend Database Database > Stored Procedures >

BatchLocationQuantityUpdates Stored Procedure

Navigation: iVend Database Database > Stored Procedures >

hm_btn_navigate_prevhm_btn_navigate_tophm_btn_navigate_next

iVend 6.6 Database Help

BatchLocationQuantityUpdates Stored Procedure

Collapse All Expand All

iVend Database Database : BatchLocationQuantityUpdates Stored Procedure

Description

Used in replication to update the Batch quantities

Properties

Creation Date

9/18/2015 10:23 AM

Encrypted

dbimages_boolean-false

Ansi Nulls

dbimages_boolean-true

Parameters

Parameter

Direction

Description

Data Type

Size

@pInventoryBatchLocationLogKey

In

Reference key of the Inventory Batch Location Log

VarWChar

50

@pDebug

In

Whether this procedure has to be executed in Debug mode or not

VarChar

1

@RETURN_VALUE

Return Value

 

Integer

4

Objects that BatchLocationQuantityUpdates depends on

 

Database Object

Object Type

Description

Dep Level

CfgEnterprise table

CfgEnterprise

Table

Stores the basic configuration entries for the system . These settings are mandatory for the system to work properly.

2

CfgSiteInformation table

CfgSiteInformation

Table

Stores the site information. Enterprise always has the site id as 1. System Table Warning : Should not be modified directly

2

GetCompanyDateTime function

GetCompanyDateTime

User Defined Function

 

1

InvBatchLocation table

InvBatchLocation

Table

Describes the batch information with Location, Warehouse, Product and Expiry date

1

InvBatchLocationLog table

InvBatchLocationLog

Table

Stores each record processed for the batch with location deifned.

1

Procedure Source Code

CREATE PROCEDURE [dbo].[BatchLocationQuantityUpdates]

(

@pInventoryBatchLocationLogKey NVARCHAR(50),

@pDebug   CHAR(1) = 'N'

)

AS

BEGIN

SET NOCOUNT ON

Declare @ErrorDesc varchar(255)

If @pDebug = 'Y'

  SELECT 'UPDATE THE INVENTORY'

  Update B

  Set B.AvailableQuantity = B.AvailableQuantity + A.InQty - A.OutQty - isnull(A.AllocatedQuantity,0),

   B.InStockQuantity = B.InStockQuantity + A.InQty - A.OutQty - isnull(A.AllocatedQuantity,0),

   B.Status = case when B.AvailableQuantity + A.InQty - A.OutQty > 0 then 1 else 0 end,

   B.Modified = dbo.GetCompanyDateTime() ,

   B.AllocatedQuantity = ISNULL(B.AllocatedQuantity, 0) + ISNULL(A.AllocatedQuantity, 0)

  FROM  InvBatchLocationLog A,  InvBatchLocation B

  WHERE A.ProductKey = B.ProductKey

  AND  A.WarehouseKey = B.WarehouseKey

  AND  A.BatchKey = B.BatchKey

  AND     A.LocationKey   = B.LocationKey

  AND  A.BatchLocationLogKey = @pInventoryBatchLocationLogKey

IF(@@ERROR <>0)

    BEGIN

  SET @ErrorDesc = 'Error while updating the batch quantities.'

        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.