Showing posts with label on hand inventory. Show all posts
Showing posts with label on hand inventory. Show all posts

Sunday, July 29, 2012

How to get onhand inventory?

A very common practice for a developer on day to day basis is to get on hand inventory based on different parameters (dimensions). I’ve came across a situation where I was getting this physical available from ‘InventSum’ table directly rather using ‘InventOnhand’ class and the result was different for some items. I think it would be better to use the InventOnHand class for querying on hand data. AX uses a secondary table called ‘InventSumDelta’ for capturing changes applied to the ‘inventSum’ that haven’t been committed yet. Not taking the ‘InventSumDelta’ in consideration can lead to unexpected results.
Here is the sample code snippet you can use for this purpose

Saturday, May 7, 2011

How to get On-Hand inventory of past years (by date)

Many a times we come accross a requirement from customer to show on hand inventory of last year or some other report of this type as it is not included in the out of box package. I found a very interesting job from the community web site related to this.

static void findingOnHandByDate(Args _args)
{
ItemId itemId;
InventDim inventDimCriteria;
InventDimParm inventDimParm;
InventSumDateDim inventSumDateDim;
TransDate start, finish;
int c;
int onHandTotal;
;
start = str2date("1/1/2010", 213);
finish = str2date("12/31/2010", 213);
onHandTotal = 0;
while(start != finish)
{
c++;
// Specify the item to get onhand info on
itemId = "00017470";

inventSumDateDim =
InventSumDateDim::newParameters(start,
itemId,
inventDimCriteria,
inventDimParm);

info(strfmt("Date: %1 on hand: %2", start, num2str(inventSumDateDim.postedQty() + inventSumDateDim.receivedQty() - inventSumDateDim.deductedQty(), 0, 2, 1, 1)));
onHandTotal += (inventSumDateDim.postedQty() + inventSumDateDim.receivedQty() - inventSumDateDim.deductedQty());
start += 1;
}
info(strfmt("Avg on hand per year: %1", onHandTotal / 365));
}