Counting of inventory On-Hand in AX2012


Guys, sometime it’s required to do a counting of inventory and in some case if you want to do it technically, I've created a static method which will be helpful to create a counting history and related voucher posting (Inventory count).

Front end navigation: Inventory On-Hand >> Quantity adjustment














Code:

public static void adjustInventoryCount(
                                ItemId              _item,
                                InventLocationId    _inventLocation,
                                WMSLocationId       _wmsLocation,
                                Qty                 _qtyCounted
                                )
{
    WMSOnlineCountingServer     wmsOnlineCountingServer;
    TmpWMSOnlineCounting        tmpWMSOnlineCounting;

    void initOnHandItem(
                        ItemId              _itemId,
                        InventLocationId    _inventLocationId,
                        WMSLocationId       _wmsLocationId,
                        Qty                 _counted
                        )
    {
        InventSum   inventSum;
        InventDim   inventDim;

        if (!_itemId)
        {
            return;
        }

        while select ItemId, PhysicalInvent, PdsCWPhysicalInvent, InventDimId
            from inventSum
            where inventSum.ItemId          == _itemId      &&
                  inventSum.ClosedQty       == NoYes::No    &&
                  inventSum.PhysicalInvent  != 0
        exists join InventDimId, InventLocationId, wmsLocationId from inventDim
            where inventDim.InventDimId == inventSum.InventDimId
              && (!_inventLocationId || inventDim.InventLocationId == _inventLocationId)
              && (!_wmsLocationId    ||  inventDim.wmsLocationId   == _wmsLocationId)
        {
            tmpWMSOnlineCounting.ItemId         = inventSum.ItemId;
            tmpWMSOnlineCounting.InventDimId    = inventSum.InventDimId;

            tmpWMSOnlineCounting.QtyOnHand      = inventSum.PhysicalInvent;
            tmpWMSOnlineCounting.QtyCounted     = _counted;

            tmpWMSOnlineCounting.PdsCWQtyOnHand     = inventSum.PdsCWPhysicalInvent;
            tmpWMSOnlineCounting.PdsCWQtyCounted    = _counted;

            tmpWMSOnlineCounting.insert();

            wmsOnlineCountingServer.parmSBStmpWMSOnlineCounting(tmpWMSOnlineCounting);

        }
    }

    wmsOnlineCountingServer = WMSOnlineCountingServer::construct();
    initOnHandItem(_item, _inventLocation, _wmsLocation, _qtyCounted);
    wmsOnlineCountingServer.run();
}


2 comments:

  1. Did you know that Microsoft Dynamics AX has created a great software for managing advertising?

    ReplyDelete
  2. Hello! I have already changed job and now my work is connected counting of inventory and some similar things, and I must use Microsoft dynamics ax to do this. I’m a beginner in this field and have never used dynamics ax before, so your method was very useful for me :) Thanks for sharing!

    ReplyDelete

Powered by Blogger.