Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SQL query: availability check

0 Kudos
280
  • SAP Managed Tags:

Hi,

I'm trying to create a simple availability check for quotation items, but my problem is that the open quantities ([OpenCreQty]) of the same items distributed on different positions are not summed and matched with the stock.

I have tried to solve this by equating with the sum of the open quantity, but unfortunately this does not work yet.

Has anyone an idea to fix this simple query?

Thank you for your hint in advance.

SELECT T1.[U_position], T1.[ItemCode], T1.[Quantity], T1.[OpenCreQty], T2.[OnHand]

FROM OQUT T0

INNER JOIN QUT1 T1 ON T0.[DocEntry] = T1.[DocEntry]

INNER JOIN OITM T2 ON T1.[ItemCode] = T2.[ItemCode]

WHERE T0.[DocNum] = '332008' AND T2.[OnHand] < (SELECT SUM(T1.[OpenCreQty]) FROM OQUT T0 INNER JOIN QUT1 T1 ON T0.[DocEntry] = T1.[DocEntry] WHERE T0.[DocNum] = '332008' GROUP BY T1.[OpenCreQty]) AND T2.[InvntItem] = 'Y'

GROUP BY T1.[U_position], T1.[ItemCode], T1.[Quantity], T1.[OpenCreQty], T2.[OnHand]

0 REPLIES 0