Tuesday, 8 May 2012

Ap Invoices on hold

SELECT DISTINCT ai.invoice_num, ai.invoice_amount, ai.invoice_date,
                ai.invoice_received_date, ah.hold_lookup_code, ah.hold_reason,
                pv.vendor_name, pv.segment1 vendor_number,
                ph.segment1 po_number,
                   gcc.segment1
                || '.'
                || gcc.segment2
                || '.'
                || gcc.segment3
                || '.'
                || gcc.segment4
                || '.'
                || gcc.segment5
                || '.'
                || gcc.segment6,
                aid.amount
           FROM ap_invoices_all ai,
                ap_holds_all ah,
                po_vendors pv,
                po_headers_all ph,
                ap_invoice_distributions_all aid,
                po_distributions_all pda,
                gl_code_combinations gcc
          WHERE 1 = 1
            AND ai.invoice_id = ah.invoice_id
            AND ai.vendor_id = pv.vendor_id
            AND ai.po_header_id = ph.po_header_id(+)
            AND ph.po_header_id = pda.po_header_id
            AND ah.invoice_id = aid.invoice_id
            AND aid.po_distribution_id = pda.po_distribution_id
            AND aid.dist_code_combination_id = gcc.code_combination_id
           

No comments:

Post a Comment