SAP B1 9.1 未结销售订单数量查询

SAP B1 9.1 Open sales order Quantity query

我需要查询可以查看未清销售订单数量(采购订单和库存),但我需要根据客户参考查看。我有一个客户有很多商店。和他的订单#加入商店#。所以在每个订单下一次可以有 100 家商店。针对每家商店,SAP B1 9.1 中都有一个销售订单,其参考编号为 818201-3001(PO# -Store#),以便可以根据商店地址发货。在商店级别拆分“NUMATCARD”并合并数量超出了我的方法。

我需要一个将结果显示为附加输出的查询 sheet。

我有此查询,但无法将 CustomerRef 转换为行和列。

SELECT T0.[DocDueDate],
    T0.[CardName],
    T0.[NumAtCard],
    T0.[DocNum],
    T1.[ItemCode],
    T1.[Dscription],
    T3.[WhsCode],
    T3.[OnHand] - SUM(OpenQty) OVER (Partition By T1.ItemCode ORDER BY DocDueDate, LineNum, NumAtCard, DocNum) + SUM(T1.OpenQty) AS 'Available',
    SUM(T1.[Quantity]) AS 'PO QTY',
    SUM(T1.OpenQty) AS 'To Release'
FROM
    ORDR T0 
    INNER JOIN RDR1 T1 ON T0.[DocEntry] = T1.[DocEntry] 
    INNER JOIN OITM T2 ON T1.[ItemCode] = T2.[ItemCode] 
    INNER JOIN OITW T3 ON T2.[ItemCode] = T3.[ItemCode] AND T1.[WhsCode] = T3.[WhsCode]
WHERE
    T0.[CardCode] = 'c00192' and
    T0.[DocStatus] = 'O' AND
    T1.[LineStatus] = 'O' AND
    T0.[CANCELED] = 'N' AND
    T1.[WhsCode] = '161'           
GROUP BY
    T0.[DocDueDate], 
    T0.[CardName], 
    T0.[NumAtCard], 
    T0.[DocNum], 
    T1.[ItemCode], 
    T1.[Dscription],
    T3.[OnHand],
    T3.[WhsCode],
    T1.[LineNum],
    T1.OpenQty
ORDER BY 
    T0.[DocDueDate], 
    T0.[NumAtCard], 
    T0.[DocNum]