0

我需要编写一个 SQL 来在 Oracle EBS r12 中生成 AP 预付款余额报告。我想我需要使用, XLA_DISTRIBUTION_LINKS, AP_INVOICES_ALL, XLA_AE_LINES, XLA_AE_HEADERS, AP_SUPPLIERS,GL_CODE_COMBINATIONS表。下面是我为生成报告而编写的 SQL 查询,但由于输出不正确,因此出现了问题。

SELECT aps.vendor_name,
        invall.invoice_num,
        SUM (AEL.ACCOUNTED_CR) - SUM (AEL.ACCOUNTED_DR) AS INVOICE_SUM
FROM    XLA.XLA_AE_HEADERS              aeh,
        XLA.XLA_AE_LINES                ael,
        XLA.XLA_DISTRIBUTION_LINKS distlink,
        AP.AP_INVOICES_ALL            invall,
        AP.AP_SUPPLIERS                  aps
        GL.GL_CODE_COMBINATIONS  glcc
WHERE  AEL.AE_HEADER_ID = AEH.AE_HEADER_ID
       AND AEL.AE_HEADER_ID = DISTLINK.AE_HEADER_ID
       AND AEL.AE_HEADER_ID = DISTLINK.AE_LINE_NUM
       AND DISTLINK.APPLIED_TO_SOURCE_ID_NUM_1 = INVALL.INVOICE_ID
       AND DL.AE_LINE_NUM = AEL.AE_LINE_NUM
       AND GLCC.CODE_COMBINATION_ID = AEL.CODE_COMBINATION_ID
       AND APS.VENDOR_ID = INVALL.VENDOR_ID
       AND aps.vendor_name LIKE '%BETEKO%'
       AND invall.vendor_id = 407012
       AND TRUNC(AEL.ACCOUNTING_DATE)  <= '31-DEC-12'
       AND AEL.APPLICATION_ID      = 200
       AND GLCC.SEGMENT1   LIKE '13%'
       AND AEH.BALANCE_TYPE_CODE = 'A'
GROUP BY   APS.VENDOR_NAME,
           INVALL.INVOICE_NUM
 HAVING SUM (ael.accounted_cr) <> SUM (ael.accounted_dr)
4

0 回答 0