Hello,
The following query runs in SQL mgmt. studio but fails in SAP B1 query generator due to the parameter values [%0] and [%1]. I have found three ways to get this query to work in mgmt. studio but all fail in B1 with the SWEI error. Below is a copy of my first attempt. Any thoughts or suggestions are greatly appreciated.
select T0.Code AS 'Component', T2.ItemName AS 'Component Desc', T2.InvntryUom AS 'UOM', (T0.Quantity * '[%0]') AS 'Qty Needed', sum(T1.OnHand - T1.IsCommited) AS 'Available Stock',
sum(T1.OnOrder) AS 'On Order', ISNULL((select sum(ISNULL(tB.PlannedQty,0)) as 'PlannedQty'
from OWOR tA
inner join WOR1 tB on tA.DocEntry = tB.DocEntry
where tA.status = 'P' and tA.ItemCode = '[%1]' and tB.ItemCode = T0.Code
group by tB.ItemCode),0) as 'Open Prd Ord Qty'
from ITT1 T0
inner join OITW T1 on T0.Code = T1.ItemCode
inner join OITM T2 on T0.Code = T2.ItemCode
where T0.Father = '[%1]'
and (T1.WhsCode = '01' or T1.WhsCode = '02' or T1.WhsCode = '03')
and T0.Code <> '1809-L'
and T0.Code <> '1810-O'
group by T0.Code,T0.Quantity,T2.ItemName,T2.InvntryUom
order by T0.Code asc