AP预付款余额报告SQL

时间:2013-09-03 10:58:26

标签: sql oracle

我需要编写一个SQL来生成Oracle EBS r12中的AP预付费余额报告。我想我需要使用XLA_DISTRIBUTION_LINKSAP_INVOICES_ALLXLA_AE_LINESXLA_AE_HEADERSAP_SUPPLIERSGL_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)

0 个答案:

没有答案