Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics RMS (Archived)

Why is HQ quantity not machine with store quantity?

Posted on by 20

 Why is HQ quantity not machine with store quantity, i.e in HQ an item in inventory the quantity will show like 20pcs but went you check store quantity tab you will see the quantity of each store but if you total evey thing it does not match with that of HQ.

*This post is locked for comments

  • Suggested answer
    archelle16 Profile Picture
    archelle16 1,735 on at
    RE: Why is HQ quantity not machine with store quantity?

    It is bcoz Item Quantity looks after the sum of itemdynamic.Quantity while the Store Quantity in ItemDynamic.SnapshotQuantity.

    To get rid if this, execute this trigger in your hq db. In this way, everytime the sync updates the current onhan, it will be automatically update the total item quantity.

    /****** Object:  Trigger [dbo].[tr_ItemStoreQty]    Script Date: 02/04/2016 09:42:49 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    CREATE TRIGGER [dbo].[tr_ItemStoreQty]

    ON [dbo].[ItemDynamic] FOR UPDATE, INSERT, DELETE AS

    /* Updates Quantity and QuantityCommitted in Item table when changes are made to the ItemDynamic table */

    DECLARE @Rows INT

    SELECT @Rows = @@ROWCOUNT

    IF @Rows = 0

      /* No rows inserted or deleted, exit trigger */

      RETURN

    /* Update the Quantity and QuantityCommitted fields in ItemDynamic table */      

    SELECT   ItemDynamic.ItemID,

            SUM(ItemDynamic.Quantity) AS Quantity,

            SUM(ItemDynamic.QuantityCommitted) AS QuantityCommitted

    INTO     #tr_Temp

    FROM     ItemDynamic

    WHERE    ItemDynamic.ItemID IN

            (

            SELECT ItemID

            FROM   INSERTED

    UNION

            SELECT ItemID

            FROM   DELETED

    )

    GROUP BY ItemDynamic.ItemID

    UPDATE   Item

    SET      Quantity = #tr_Temp.Quantity,

            QuantityCommitted = #Tr_temp.QuantityCommitted

    FROM     Item, #tr_Temp

    WHERE    Item.ID = #tr_Temp.ItemID

    GO

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans