on 04-26-2012 5:19 PM
Dear Experts,
I was trying to make a query to know the difference between BOM and production order.
SELECT T0.[DocNum], T0.[ItemCode], T0.[PostDate], T0.[CmpltQty], T0.[WOR1Count],Count(T1.[LineNum]) as 'Original line no.',(T0.[WOR1Count] - Count(T1.[LineNum])) as 'Difference' FROM OWOR T0 INNER JOIN WOR1 T1 ON T0.DocEntry = T1.DocEntry WHERE T1.[LineNum] <> T0.[WOR1Count] GROUP BY T0.[DocNum], T0.[ItemCode], T0.[PostDate], T0.[CmpltQty], T0.[WOR1Count]
The above query is not giving me accurate result it is also showing me production orders and BOM in which there is no difference.
Thanks-
Mona.
Dear Mona,
You need ITT1 table in the query to compare Production Order against BOM.
Thanks,
Gordon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Gordon,
To get the result i tried below query also for multilevel BOM.
SELECT T0.[DocNum], T0.[ItemCode], T1.[LineNum], T1.[ItemCode], T2.[Father], T2.[Code]
FROM OWOR T0 INNER JOIN WOR1 T1 ON T0.DocEntry = T1.DocEntry inner join ITT1 T2 on T2.Father = T0.Itemcode
WHERE T1.[ItemCode] <> T2.[Code] GROUP BY T0.[DocNum], T0.[ItemCode],
T1.[LineNum], T1.[ItemCode], T2.[Father], T2.[Code]
Mona.
If you have multiple level BOM, it may be too hard to compare with production order.
Try this first:
SELECT T0.[DocNum], T0.[ItemCode], T1.[LineNum], T1.[ItemCode]
FROM OWOR T0 INNER JOIN WOR1 T1 ON T0.DocEntry = T1.DocEntry
WHERE T1.[ItemCode] NOT IN (SELECT T2.[Code] FROM ITT1 T2 WHERE T2.Father = T0.Itemcode) AND T0.DocNum LIKE '[%0]%'
User | Count |
---|---|
111 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.