Onhand quantity adjustment query in ax 2009

Hi,

I want to adjust onhand quantity for all items based on warehouse. i want to set my below query in InventCountCreate class to create counting journal , how to do that in ax 2009
`
SELECT
FIRSTFAST *
FROM
InventSum
ORDER BY
InventSum.ItemId ASC,
InventDim.InventLocationId ASC
JOIN FIRSTFAST *
FROM
InventDim
WHERE
InventSum.InventDimId = InventDim.inventDimId
AND (
(
InventLocationId = N ‘OBDC’
OR InventLocationId = N ‘QOBDC’
)
)
AND (
(
wMSLocationId = N ‘OBDC’
OR wMSLocationId = N ‘Locked’
)
) EXISTS
JOIN FIRSTFAST *
FROM
InventTable
WHERE
InventSum.ItemId = InventTable.ItemId
AND ((AutoReportFinished = 0))

`