Available physical on exact dimensions

In case of following conditions
  • Item is enabled for advanced warehousing
    WHSInventEnabled::exist(ItemId);
  • some warehouses have negative stock
You will see that Available physical figure is different from what you most probably want to get:

In this case Available physical will display total value across all warehouses or any other dimensions you stated as a criteria.
Available physical on exact dimensions will display correct value considering specified dimensions.
WHSInventReserve table contains available physical (AvailPhysical field) for different dimension hierarchies (HierarchyLevel field).
0 - no dimensions
1 - Site level
2 - Site + Warehouse level
and so on:
Where DIM000000030 holds the only available Site, therefore values for hierarchies 0 and 1 are equal.
At \Classes\WHSInventOnHand\getReserveAvailQty it tries to select minimum AvailPhysical quantity across all dimension hierarchies available for that item and selected dimensions

Here is how to get Available physical on exact dimensions value from X++:
static void VKAvailablePhysical(Args _args)
{
    Qty                             qty;
    InventDim                       inventDim;
    InventDimParm                   inventDimParm;
    InventOnHandQty                 inventOnHandQty;
    ItemId                          itemId = '11011';
    
    InventAvailabilityByUnit        inventAvailabilityByUnit;
    WhsInventReserveQty             whsInventReserveQty;
    InventIAvailability             inventIAvailability;
    
    inventDim.clear();
    inventDim.InventSiteId      = 'SiteId';
    inventDim.InventLocationId  = 'Warehouse';
    inventDim = inventDim::findOrCreate(inventDim);
    
    if (WHSInventEnabled::exist(itemId))
    {
        // Available physical on exact dimensions 
        inventAvailabilityByUnit    = inventAvailabilityProvider::findByItemIdDim(itemId, inventDim);
        inventIAvailability         = inventAvailabilityByUnit.parmInventAvailability();
        if (inventIAvailability is WhsInventReserveQty)
        {
            whsInventReserveQty = inventIAvailability as WhsInventReserveQty;
            qty                 = whsInventReserveQty.availPhysicalLevel();
        }
    }
    else
    {
        // Usual process: Available physical
        inventDimParm.initFromInventDim(inventDim);
        inventOnHandQty = InventOnHandQty::newItemDim(itemId, inventDim, inventDimParm);
        qty             = inventOnHandQty.availPhysical();
    }
}



Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags