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:

Import and Export file from BLOB storage Account(Azure) in D365 F&O using X++

  Import and Export file from BLOB storage Account in D365 F&O using X++ Import: /// <summary> /// MKInventQualityOrderLineService...