2024 Aug 01 4:00 PM - edited 2024 Aug 02 12:31 AM
Hello guys
i need a query from production order that will show the item planned qty against the qty available from 3 warehouses. Query looks something like this.
I was able to do it but the warehouses are aligned vertically and it doubling the item number so as its Qty.
This is the code I used.
SELECT T0."DocNum", T1."ItemCode",T1."PlannedQty", T2."WhsCode", T2."OnHand",T0."PostDate", T0."StartDate", T0."DueDate", T0."Status" FROM OWOR T0 INNER JOIN WOR1 T1 ON T0."DocEntry" = T1."DocEntry" INNER JOIN OITW T2 ON T1."ItemCode" = T2. "ItemCode" WHERE T0."Status" = 'P' and T2."WhsCode" IN ('RM','FG') and T0."StartDate" >= [%0] and T0."DueDate" <= [%1]
Item here is being double.
Looking forward for sap community help.
thanks in advance guys.
Hi,
You can refer this topic to convert from line to column.
https://forum.sapb1.vn/community/saphana/cach-pivot-ket-qua-truy-van-trong-sap-hana/#post-154
Hope this helps,
Son Tran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this is the code: SELECT T0."DocNum" , T1."ItemCode" , T1."PlannedQty" , T1."wareHouse" , (SELECT OnHand FROM OITW WHERE WhsCode = 'RM' AND ItemCode = T1."ItemCode") AS "OnHand\_RM" , (SELECT OnHand FROM OITW WHERE WhsCode = 'FG' AND ItemCode = T1."ItemCode") AS "OnHand\_FG" , T0."PostDate" , T0."StartDate" , T0."DueDate" , T0."Status" FROM OWOR T0 INNER JOIN WOR1 T1 ON T0."DocEntry" = T1."DocEntry" WHERE T0."Status" = 'P' AND T1."wareHouse" IN ('RM', 'FG') AND T0."StartDate" >= [%0] AND T0."DueDate" <= [%1]
SAP returns with an error. "1). [SAP AG][LIBODBCHDB DLL][HDBODBC] Syntax error or access violation;257 sql syntax error: line 1 col 8 'Received Alerts' (OAIB) (at pos 8)"
Maybe you can help me out to dedug the query... thanks a lot bro..
Try this
select T0.DocEntry, T0.StartDate, T0.DueDate,T0.Status, T1.ItemCode, T1.PlannedQty,
sum(case when T2.WhsCode='RM' then T2.OnHand else 0 end) as 'OnHand_RM',
sum(case when T2.WhsCode='FG' then T2.OnHand else 0 end) as 'OnHand_FG'
from OWOR T0 join WOR1 T1 on T0.DocEntry=T1.DocEntry and T1.ItemType=4
left join OITW T2 on T1.ItemCode=T2.ItemCode and T2.WhsCode in ('RM', 'FG')
where T0.Status ='P' and T0.StartDate>=[%0] and T0.StartDate <=[%1]
group by T0.DocEntry, T0.StartDate, T0.DueDate,T0.Status, T1.ItemCode, T1.PlannedQty
User | Count |
---|---|
110 | |
8 | |
8 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.