Finding the Total Available and Available physical

2019-06-21 04:27发布

问题:

I have a method for a display field which does the following;

return InventSum::find(_salesLine.ItemId, InventDim::_salesLine.InventDimId).AvailPhysical();

This gives me the on-hand Available Physical for the line site/warehouse/location.

I need to see the total available for just the site/warehouse. I think I need to search inventDim by Item/Warehouse to get my inventdimid, but I cannot find the method so I am suspicious that this is incorrect.

Can anyone help?

回答1:

My working solution...

InventDimParm       invDimParm;
InventDim           warehouseInvDim;
InventDim           salesLineInventDim;
;

salesLineInventDim = _salesLine.inventDim();

warehouseInvDim.InventSiteId = salesLineInventDim.InventSiteId;
warehouseInvDim.InventLocationId = salesLineInventDim.InventLocationId;

warehouseInvDim = InventDim::findOrCreate(warehouseInvDim);
invDimParm.initFromInventDim(InventDim::find(warehouseInvDim.inventDimId));

return InventSum::findSum(_salesLine.ItemId,warehouseInvDim,invDimParm).availOrdered();

I know this is for availOrdered() but it works exactly the same for availPhysical()



回答2:

You should use the InventOnhand class.

It sums the invent on-hand values based on criteria like item id and inventory dimensions.

There are lots of uses in AX, search the Class node.



回答3:

The following job finds all Sales Lines with the Open Order status, which have an Available Physical quantity on hand matching all dimensions specified on the Sales Lines except location:

static void FindOpenSalesLineAvailPhys(Args _args)
{
    SalesLine salesline;
    InventDim inventDim;
    InventDimParm inventDimParm;
    InventOnHand inventOnHand;
    ;

    while select salesLine where salesLine.SalesStatus == SalesStatus::Backorder
    {
        inventDim = salesLine.inventDim();
        inventDimParm.initFromInventDim(inventDim);
        inventDimParm.WMSLocationIdFlag = NoYes::No;
        inventOnHand = InventOnHand::newItemDim(salesLine.ItemId, inventDim, inventDimParm);
        if (inventOnHand.availPhysical())
        {
            info(strfmt("Sales Order %1 Line %2 Item Id %3 Available Physical (ignoring Location) %4",
                salesLine.salesId, salesLine.LineNum, salesLine.ItemId, inventOnHand.availPhysical()));
        }
    }
}


回答4:

You basically set your inventDim values the way you want to search for them, and then do an InventDim::FindOrCreate to see if either the inventory dimension already exists, or it needs to be created and a new number sequence will be consumed. This is used so that the InventDim table doesn't store every single possible combination of dimensions. Also because if you have any serialized products, it's not feasible for the table to store all of the combinations, so it only stores the ones it needs.

InventDim   inventDim;
SalesLine   _salesLine;
;

inventDim.InventSiteId      = 'mySite';
inventDim.InventLocationId  = 'myWarehouse';
inventDim   = InventDim::findOrCreate(inventDim);

return InventSum::find(_salesLine.ItemId, inventDim.inventDimId).AvailPhysical();