How to check for released products currently on-hand in D365FO using x++ code?
Please advice.

How to check for released products currently on-hand in D365FO using x++ code?
Please advice.
I am sharing this function. It gets two arguments which are as follows:
ItemId
InventDimId
It returns on hand inventory.
public InventQtyAvailPhysical onHandInventory(ItemId _itemId, InventDimId _inventDimId)
{
InventOnhand inventOnhand;
InventDim inventDim = inventDim::find(_inventDimId);
InventDimParm inventDimParm;
inventDimParm.initFromInventDim(inventDim);
inventOnhand = InventOnhand::newParameters(_itemId, inventDim, inventDimParm);
return inventOnhand.availPhysical();
}