'Sap Business One sql query for "Open transaction stock report"

I would really appreciate if someone can build a query based on the requirements below:

"

This report asks the user to enter a stock item. Then it displays all the open sales orders and purchase order transactions relating to an item. it should also show the stock levels and then the closing stock levels once the transactions have been calculated. a bit like an opening balance and a closing balance. So you would have your current in stock levels and as you list an open sales order it would show the quantity on that order with the running balance and as you display a purchase transaction it would display the amount being ordered and increase the stock levels. this is to give a user the ability to see what stock they have but when it is committed to customers and when it is due to arrive. you should use the delivery date to sort the transactions

"

Best Regards,

Daniel



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source