SAP查询中有关拆分批次的报告的SQL查询

时间:2018-06-05 12:46:46

标签: sql sap sapb1

晚上好专家,

以牛肉胴体[a]为例,可以用另一组不同的切割[a11,a12,a13,a14]或[a21,a22,a23]生成几种不同的切割[a1,a2,a3等]从先前的削减产生。这种拆分可以达到4级或5级,每次新的切割成为批次和批次编号。

有一个解决方案hereherehere效果很好,但在我的情况下,我需要显示每个拆分项目/批次的批次编号(DistNumber)。该报告需要与附加链接中的解决方案生成的报告类似,但需要批号。

以下是我的查询,但它没有提供所需的输出。

SELECT T0."Father", O1."ItemName",A1."DistNumber",
T0."Code" AS "Product Code1", O2."ItemName" AS "Product Description1",A2."DistNumber",
T2."Code" AS "Product Code2", O3."ItemName" AS "Product Description2",A3."DistNumber",
T3."Code" AS "Product Code3", O4."ItemName" AS "Product Description3",A4."DistNumber"
FROM ITT1 T0
LEFT OUTER JOIN ITT1 T1 ON T0."Code" = T1."Father"
LEFT OUTER JOIN ITT1 T2 ON T1."Code" = T2."Father"
LEFT OUTER JOIN ITT1 T3 ON T2."Code" = T3."Father"
LEFT OUTER JOIN ITT1 T4 ON T3."Code" = T4."Father"

LEFT OUTER JOIN OITM OO ON T0."Father" = OO."ItemCode"
LEFT OUTER JOIN OITM O1 ON T0."Code" = O1."ItemCode"
LEFT OUTER JOIN OITM O2 ON T1."Code" = O2."ItemCode"
LEFT OUTER JOIN OITM O3 ON T2."Code" = O3."ItemCode"
LEFT OUTER JOIN OITM O4 ON T3."Code" = O4."ItemCode"

LEFT OUTER JOIN OBTN AA ON T0."Father" = AA."ItemCode"
LEFT OUTER JOIN OBTN A1 ON T0."Code" = A1."ItemCode"
LEFT OUTER JOIN OBTN A2 ON T1."Code" = A2."ItemCode"
LEFT OUTER JOIN OBTN A3 ON T2."Code" = A3."ItemCode"
LEFT OUTER JOIN OBTN A4 ON T3."Code" = A4."ItemCode"

WHERE A1."DistNumber" LIKE 'BM%' ORDER BY A1."DistNumber" ASC LIMIT 20000

非常感谢任何形式的协助

0 个答案:

没有答案