how to get Current on hand qty is required in the sales line. based on item and dimensions

any one share the piece of code based on item and dimensions

You can use, \Classes\InventOnHandQty
Look at the cross reference for the quantity you need(Physical or Financial)
Look at the example - \Classes\WMSReserve_LocationOnHand\reserveOnHand (for getting available physical quantity)

You can also do this as standard with the lookup on the warehouse field of the sales line and ensure you tick the “range dimensions” box.