Tuesday, 17 January 2017

Stock on Hand of a Item using X++ code

Here we will see how to find the Stock on hand of a Item using the X++ code.

Key things to know:

1. The stock on hand will vary depending on Inventory dimensions.
2. The standard Class "InventOnhand" will have all the methods to find out the different formats of stock.
3. Job:

static void MK_stockOnHand(Args _args)
{
    InventOnhand        inventOnHand;
    InventDim           inventDim;
    InventDimParm       inventDimParm;
    InventQty           stockOnHand;
    ItemId              itemid = "00001aTestInter";
   
    inventDim.InventSiteId = "VIC"; // site
    inventDim.InventLocationId = "SOM"; // warehouse
   // inventDim.InventLocationId = "RES";
   
    inventDimParm.initFromInventDim(inventDim);
   
    inventOnHand = InventOnhand::newParameters(itemid,inventDim,inventDimParm);
   
    stockOnHand = inventOnHand.availPhysical();
   
    info (strFmt(" Stock on Hand for Item %1 is %2",itemid,stockOnHand));
   
}

Happy learning...Mallik

No comments:

How to Disable “Advanced Filter or Sort” and Enforce Custom Filters on Any D365FO Form

 In Dynamics 365 Finance and Operations, users can apply filters through the “Advanced filter or sort” feature found under the Options tab...