SELECT pha.segment1 "PO_NO" ,
pha.creation_date "PO_DATE",
pv.vendor_name,
SUM(pla.quantity) "PO_QTY",
rsh.receipt_num "GRN_NO",
rt.transaction_date "GRN_DATE",
SUM(plla.quantity_received) "RECEIVED_QTY",
SUM(plla.quantity_accepted) "ACCEPTED_QTY",
SUM(aila.quantity_invoiced) "INVOICED_QTY",
aia.amount_paid "PAYMENT_AMT",
apt.name "PAYMENT_TERMS",
apsa.due_date "PAYMENT_DATE",
aca.payment_method_code "PAYMENT_MODE",
DECODE(aca.payment_method_code,'CHECK',aca.check_number,
'NETTING',aca.check_number) "CHECK_NUMBER",
DECODE(aca.payment_method_code,'CHECK',aca.check_date,
'NETTING',aca.check_date) "CHECK_DATE"
FROM po_headers_all pha,
po_lines_all pla,
po_line_locations_all plla,
po_distributions_all pda,
po_vendors pv,
rcv_transactions rt,
rcv_shipment_headers rsh,
rcv_shipment_lines rsl,
ap_invoices_all aia,
ap_invoice_lines_all aila,
ap_invoice_distributions_all aida,
ap_invoice_payments_all aipa,
ap_payment_schedules_all apsa,
ap_checks_all aca,
ap_terms apt,
mtl_system_items_b msib,
org_organization_definitions ood
WHERE pha.po_header_id=pla.po_header_id
AND pla.po_line_id=plla.po_line_id
AND plla.line_location_id=pda.line_location_id
AND pv.vendor_id=pha.vendor_id
AND rsh.shipment_header_id=rsl.shipment_header_id
AND pda.po_distribution_id=rsl.po_distribution_id
AND rsl.shipment_line_id=rt.shipment_line_id
AND aia.invoice_id=aila.invoice_id
AND aia.invoice_id=aida.invoice_id
AND aipa.invoice_id(+)=aia.invoice_id
AND aia.invoice_id=apsa.invoice_id
AND aipa.check_id=aca.check_id(+)
AND apt.term_id=aia.terms_id
AND pla.item_id=msib.inventory_item_id(+)
AND ood.organization_id(+)=msib.organization_id
AND rt.transaction_id=aida.rcv_transaction_id
AND TRUNC(rt.transaction_date) BETWEEN NVL(:FROM_RECEIPT_DATE,to_date
(rt.transaction_date,'DD-MON-RR')) AND NVL(:TO_RECEIPT_DATE,to_date
(rt.transaction_date,'DD-MON-RR'))
AND pv.vendor_name=NVL(:VENDOR_NAME,pv.vendor_name)
AND aca.payment_method_code='CHECK'
GROUP BY pha.segment1,
pha.creation_date,
pv.vendor_name,
rsh.receipt_num,
rt.transaction_date,
aia.amount_paid,
apt.name,
apsa.due_date,
aca.payment_method_code,
aca.check_number,
aca.check_date
pha.creation_date "PO_DATE",
pv.vendor_name,
SUM(pla.quantity) "PO_QTY",
rsh.receipt_num "GRN_NO",
rt.transaction_date "GRN_DATE",
SUM(plla.quantity_received) "RECEIVED_QTY",
SUM(plla.quantity_accepted) "ACCEPTED_QTY",
SUM(aila.quantity_invoiced) "INVOICED_QTY",
aia.amount_paid "PAYMENT_AMT",
apt.name "PAYMENT_TERMS",
apsa.due_date "PAYMENT_DATE",
aca.payment_method_code "PAYMENT_MODE",
DECODE(aca.payment_method_code,'CHECK',aca.check_number,
'NETTING',aca.check_number) "CHECK_NUMBER",
DECODE(aca.payment_method_code,'CHECK',aca.check_date,
'NETTING',aca.check_date) "CHECK_DATE"
FROM po_headers_all pha,
po_lines_all pla,
po_line_locations_all plla,
po_distributions_all pda,
po_vendors pv,
rcv_transactions rt,
rcv_shipment_headers rsh,
rcv_shipment_lines rsl,
ap_invoices_all aia,
ap_invoice_lines_all aila,
ap_invoice_distributions_all aida,
ap_invoice_payments_all aipa,
ap_payment_schedules_all apsa,
ap_checks_all aca,
ap_terms apt,
mtl_system_items_b msib,
org_organization_definitions ood
WHERE pha.po_header_id=pla.po_header_id
AND pla.po_line_id=plla.po_line_id
AND plla.line_location_id=pda.line_location_id
AND pv.vendor_id=pha.vendor_id
AND rsh.shipment_header_id=rsl.shipment_header_id
AND pda.po_distribution_id=rsl.po_distribution_id
AND rsl.shipment_line_id=rt.shipment_line_id
AND aia.invoice_id=aila.invoice_id
AND aia.invoice_id=aida.invoice_id
AND aipa.invoice_id(+)=aia.invoice_id
AND aia.invoice_id=apsa.invoice_id
AND aipa.check_id=aca.check_id(+)
AND apt.term_id=aia.terms_id
AND pla.item_id=msib.inventory_item_id(+)
AND ood.organization_id(+)=msib.organization_id
AND rt.transaction_id=aida.rcv_transaction_id
AND TRUNC(rt.transaction_date) BETWEEN NVL(:FROM_RECEIPT_DATE,to_date
(rt.transaction_date,'DD-MON-RR')) AND NVL(:TO_RECEIPT_DATE,to_date
(rt.transaction_date,'DD-MON-RR'))
AND pv.vendor_name=NVL(:VENDOR_NAME,pv.vendor_name)
AND aca.payment_method_code='CHECK'
GROUP BY pha.segment1,
pha.creation_date,
pv.vendor_name,
rsh.receipt_num,
rt.transaction_date,
aia.amount_paid,
apt.name,
apsa.due_date,
aca.payment_method_code,
aca.check_number,
aca.check_date
No comments:
Post a Comment