--Query to find AP Transactions for particular vendor with Natural Account Details
SELECT c.period_name, b.segment1, b.vendor_name, a.invoice_num,
invoice_type_lookup_code, e.line_source, z.item_description,
a.invoice_currency_code, c.amount,
NVL (c.base_amount, c.amount) AS base_amount,
NVL (z.segment2, d.segment2) AS account_code,
(SELECT ffv.description
FROM fnd_flex_values_vl ffv
WHERE 1 = 1
AND flex_value_meaning = NVL (z.segment2, d.segment2)
AND ffv.flex_value_set_id IN (
SELECT flex_value_set_id
FROM fnd_flex_value_sets
WHERE flex_value_set_name =
:p_account))
account_description,
a.invoice_date, c.description, c.match_status_flag, c.posted_flag,
a.payment_status_flag
FROM ap_invoices_all a,
po_vendors b,
ap_invoice_distributions_all c,
gl_code_combinations d,
ap_invoice_lines_all e,
(SELECT item_id, item_description, b.po_header_id, b.po_line_id,
pda.po_distribution_id, pda.code_combination_id,
gcc.segment2
FROM po_headers_all a,
po_lines_all b,
po_distributions_all pda,
gl_code_combinations gcc
WHERE a.po_header_id = b.po_header_id
AND a.org_id = b.org_id
AND a.vendor_id = a.vendor_id
AND a.po_header_id = pda.po_header_id
AND b.po_line_id = pda.po_line_id
AND pda.code_combination_id = gcc.code_combination_id) z
WHERE a.vendor_id = b.vendor_id
AND a.invoice_id = c.invoice_id
AND a.org_id = c.org_id
AND b.segment1 = :p_supplier_num
AND c.dist_code_combination_id = d.code_combination_id
AND a.invoice_id = e.invoice_id
AND a.org_id = e.org_id
AND e.line_number = c.invoice_line_number
AND e.po_header_id = z.po_header_id(+)
AND e.po_line_id = z.po_line_id(+)
AND e.po_distribution_id = z.po_distribution_id(+)
AND a.cancelled_date IS NULL
AND c.line_type_lookup_code <> 'PREPAY'
AND c.accounting_date BETWEEN :p_from_date AND :p_to_date
ORDER BY c.accounting_date;
SELECT c.period_name, b.segment1, b.vendor_name, a.invoice_num,
invoice_type_lookup_code, e.line_source, z.item_description,
a.invoice_currency_code, c.amount,
NVL (c.base_amount, c.amount) AS base_amount,
NVL (z.segment2, d.segment2) AS account_code,
(SELECT ffv.description
FROM fnd_flex_values_vl ffv
WHERE 1 = 1
AND flex_value_meaning = NVL (z.segment2, d.segment2)
AND ffv.flex_value_set_id IN (
SELECT flex_value_set_id
FROM fnd_flex_value_sets
WHERE flex_value_set_name =
:p_account))
account_description,
a.invoice_date, c.description, c.match_status_flag, c.posted_flag,
a.payment_status_flag
FROM ap_invoices_all a,
po_vendors b,
ap_invoice_distributions_all c,
gl_code_combinations d,
ap_invoice_lines_all e,
(SELECT item_id, item_description, b.po_header_id, b.po_line_id,
pda.po_distribution_id, pda.code_combination_id,
gcc.segment2
FROM po_headers_all a,
po_lines_all b,
po_distributions_all pda,
gl_code_combinations gcc
WHERE a.po_header_id = b.po_header_id
AND a.org_id = b.org_id
AND a.vendor_id = a.vendor_id
AND a.po_header_id = pda.po_header_id
AND b.po_line_id = pda.po_line_id
AND pda.code_combination_id = gcc.code_combination_id) z
WHERE a.vendor_id = b.vendor_id
AND a.invoice_id = c.invoice_id
AND a.org_id = c.org_id
AND b.segment1 = :p_supplier_num
AND c.dist_code_combination_id = d.code_combination_id
AND a.invoice_id = e.invoice_id
AND a.org_id = e.org_id
AND e.line_number = c.invoice_line_number
AND e.po_header_id = z.po_header_id(+)
AND e.po_line_id = z.po_line_id(+)
AND e.po_distribution_id = z.po_distribution_id(+)
AND a.cancelled_date IS NULL
AND c.line_type_lookup_code <> 'PREPAY'
AND c.accounting_date BETWEEN :p_from_date AND :p_to_date
ORDER BY c.accounting_date;
No comments:
Post a Comment