Finding the Total Available and Available physical for an Item/Warehouse
Asked Answered
E

4

5

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?

Emblaze answered 27/1, 2012 at 13:17 Comment(0)
E
4

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()

Emblaze answered 30/1, 2012 at 10:30 Comment(0)
N
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.

Nullipore answered 28/1, 2012 at 7:17 Comment(0)
S
2

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()));
        }
    }
}
Scever answered 3/2, 2012 at 17:15 Comment(1)
You said "I need to see the total available for just the site/warehouse" The above code gives you exactly that, how is this not relevant?Tumbrel
H
0

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();
Hormuz answered 27/1, 2012 at 15:34 Comment(3)
I doubt it will work if there are other dimensions involved (like batch number). Invent sums are stored on the specific dimensions.Nullipore
I did it with something very similar to this, I will take a look on monday (back in the office) and let you know. I have a feeling it is the same as this with 1 more lineEmblaze
I agree Jan. I didn't even think about the question really, I was just trying to show how to find/create an inventDim. Probably should have tried to think of the correct way to get the quantities.Hormuz

© 2022 - 2024 — McMap. All rights reserved.