SAP B1将AP发票发送给PO用户

时间:2017-06-30 14:21:51

标签: sap hana

下午好,我正在尝试生成一个查询,该查询将返回付款保留AP发票的标题信息,但也会显示输入原始采购订单的用户名。
我的一些发票没有关系历史记录,因此我不希望返回任何用户详细信息,但仍需要发票标题信息。其他人有多个GRPO条目,因此返回2-3行,我只需要一行。以下是我的查询。
提前致谢。

select distinct  T0."DocNum"
                ,T0."DocDate"
                ,T0."DocType"
                ,T0."CardCode"
                ,T0."CardName"
                ,T0."DocStatus"
                ,T0."GroupNum"
                ,T0."DocDueDate"
                ,T0."DocCur"
                ,T0."DocTotal"
                ,T0."DocTotalFC"
                ,T0."PayBlock"
                ,T0."PaymentRef"
              --,T1."DocEntry"
              --,T2."DocEntry"
              --,T4."DocNum"
              --,T3."ItemCode"
              --,IFNULL(T4."UserSign", 0) AS "User_Code"
             -- ,T4."UserSign"
                ,T5."U_NAME" as "Purc_User"
                ,IFNULL(T5."U_NAME",'') as "PURC_USER"
                ,'HT' as Entity
                ,T0."Comments"
FROM OPCH T0  
left JOIN PCH1 T1 ON T1."DocEntry" = T0."DocEntry" 
left JOIN PDN1 T2 on T1."BaseEntry"= T2."DocEntry"  and T1."BaseLine"= T2."LineNum"
left JOIN POR1 T3 on T2."BaseEntry" = T3."DocEntry" and T2."BaseLine" = T3."LineNum" 
left JOIN OPOR T4 on T4. "DocEntry" = T3."DocEntry"
left JOIN OUSR T5 on T5."USERID" = T4."UserSign"       
where     T0."DocStatus" = 'O' 
and T0."PayBlock" = 'Y'
order by T0."DocNum"

0 个答案:

没有答案