与联盟的金色箭头

时间:2017-10-31 09:53:09

标签: sql sapb1

我在SAP B1(SQL)中有一个查询,其中我使用UNION ALL来组合来自三个表的数据。我已将其设置为Boyum的B1可用性包中的通用功能,但由于三个来源,我不知道如何通过T0。[DocNum]列上的格式向导获得黄金箭头。有人可以帮忙吗?

SELECT T0.[DocDate], T0.[DocNum], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[VatSum]
FROM ODPI T0
WHERE T0.DocDate>='[%0]' and T0.DocDate<='[%1]'

UNION ALL

SELECT T0.[DocDate], T0.[DocNum], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[VatSum]
FROM OINV T0
WHERE T0.DocDate>='[%0]' and T0.DocDate<='[%1]'

UNION ALL

SELECT T0.[DocDate], T0.[DocNum], T0.[CardCode], T0.[CardName], -1 * T0 [DocTotal], -1 * T0.[VatSum]
FROM ORIN T0
WHERE T0.DocDate>='[%0]' and T0.DocDate<='[%1]'

1 个答案:

答案 0 :(得分:0)

基于您使用Boyum的B1可用性包这一事实,您可以利用其SQL报告通用功能来获取与列关联的正确对象类型。

您需要将不同源表的DocNum拆分为不同的列,以便您可以将类型应用于正确的列。

您使用的查询是这样的:

SELECT T0.[DocDate], T0.DocNum AS ODPI_DocNum, null as OINV_DocNum, null as ORIN_DocNum, T0.[DocNum], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[VatSum]
FROM ODPI T0
WHERE T0.DocDate>='[%0]' and T0.DocDate<='[%1]'

UNION ALL

SELECT T0.[DocDate], null AS ODPI_DocNum, T0.DocNum as OINV_DocNum, null as ORIN_DocNum, T0.[DocNum], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[VatSum]
FROM OINV T0
WHERE T0.DocDate>='[%0]' and T0.DocDate<='[%1]'

UNION ALL

SELECT T0.[DocDate], null AS ODPI_DocNum, null as OINV_DocNum, T0.DocNum as ORIN_DocNum, T0.[DocNum], T0.[CardCode], T0.[CardName], -1 * T0.[DocTotal], -1 * T0.[VatSum]
FROM ORIN T0
WHERE T0.DocDate>='[%0]' and T0.DocDate<='[%1]'

下图显示了您需要如何设置通用功能,特别是格式字段: enter image description here