Calculate Onhand physical inventory in MSD Axapta

 Inventsum is right table to get onhand stock for items. Onhand stock stored dimensionwise. Inventdimid is unique id for dimension combination.


 InventDim inventDim;  
 InventSum inventSum;  
 ;  
 while select inventSum  
 join inventdim where inventSum.ItemId == 'item1'  
 && inventdim.InventLocationId == 'loc1'  
 && inventdim.inventBatchId != ''  
 && inventdim.inventDimId == inventSum.InventDimId  
 {  
 info(strfmt("%1",inventSum.physicalInvent()));  
 }