Thursday, October 27, 2011

Find On-Hand inventory

While working on inventory module I wrote this code to find out the On-Hand inventory by using the InventOnHand class.

static void findingOnHand(Args _args)
{
ItemId itemId;
InventDim inventDim, inventDimCriteria;
InventDimParm inventDimParm;
InventOnhand inventOnhand = new InventOnhand();
;

itemId = '00200956';

inventDimCriteria.InventLocationId = '08';
inventDimParm.initFromInventDim(inventDimCriteria);

inventOnhand.parmInventDim(inventDimCriteria);
inventOnhand.parmInventDimParm(inventDimParm);
}

Find On-Hand inventory on given date

This piece of code can help you to find out On-Hand inventory at a particular date.

static void findingOnHandByDate(Args _args)
{
ItemId itemId;
InventDim inventDimCriteria;
InventDimParm inventDimParm;
InventSumDateDim inventSumDateDim;
;
// Specify the item to get onhand info on
itemId = '00005';
//inventDimCriteria.InventColorId = '02';
inventDimParm.initFromInventDim(inventDimCriteria);
inventSumDateDim = InventSumDateDim::newParameters(mkdate(31,12,2009), itemId, inventDimCriteria, inventDimParm);
info(strfmt("PostedQty: %1",inventSumDateDim.postedQty()));
info(strfmt("DeductedQty: %1",inventSumDateDim.deductedQty()));
info(strfmt("ReceivedQty: %1",inventSumDateDim.receivedQty()));
}

Check Active Inventory Dimension

In recent time I came across with a requirement how to find out an active inventory dimension associated with an item.

Here is a sample job to do this task;

static void checkInventDimActive(Args _args)
{
ItemId itemid = "1000";
;

info(strfmt("%1", InventDimSetup::find(InventTable::find(itemid).dimGroupId, fieldNum(InventDim, configId)).Active));
}