10 July 2019

How to calculate Available physical of an item given the inventLocationId that shown on the on hand form


How to get available physical for an Item and for Warehouse in AX 2012 / D365 FO 
InventDimParm       invDimParm;
   InventDim           invDim;
   Qty                 availPhys;

   invDim.InventLocationId = 'INVENTLOCATIONID';
   invDim = InventDim::findOrCreate(invDim);
   invDimParm.initFromInventDim(InventDim::find(invDim.inventDimId));
   availPhys = InventSum::findSum("ITEMID",invDim,invDimParm).availPhysical();
   info(strfmt("availPhys:%1 ",availPhys));
========
InventDim           inventDim;
   InventDimParm       inventDimParm;
   InventOnhand        inventOnhand;
  
   inventDim.InventLocationId = 'Yourwarehouse';
   inventDimParm.initFromInventDim(inventDim);
   inventOnhand = InventOnhand::newParameters('Youritem', inventDim, inventDimParm);
   info(strfmt("Available Physical: %1", inventOnhand.availPhysical()));

No comments:

Post a Comment

Give me the commetns and solutions

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...