Wednesday, 18 July 2018

link between rcv_shipment_headers and ap_invoices_all

link between rcv_shipment_headers and ap_invoices_all

In this post , I am sharing sql query to get the data from PO receiving and AP invoices. In this post , I am sharing the link between  rcv_shipment_headers and ap_invoices_all. Using the sql script , you will get the link between the rcv_shipment_headers and ap_invoices_all
 

Tables Involved link between rcv_shipment_headers and ap_invoices_all

po_headers_all
po_distributions_all
ap_invoice_distributions_all
ap_invoices_all
rcv_shipment_lines
rcv_shipment_headers
 
 

SQL to link between rcv_shipment_headers and ap_invoices_all

 
SELECT distinct pha.segment1 po_number
       ,aia.invoice_num invoice_number
       ,rsh.receipt_num receipt_number
  FROM po_headers_all pha
       ,po_distributions_all pda
       ,ap_invoice_distributions_all aid
       ,ap_invoices_all aia
       ,rcv_shipment_lines rsl
       ,rcv_shipment_headers rsh
 WHERE pha.po_header_id=pda.po_header_id
   AND aid.po_distribution_id=pda.po_distribution_id
   AND aia.invoice_id=aid.invoice_id
   AND rsl.po_header_id=pha.po_header_id
   AND rsl.shipment_header_id=rsh.shipment_header_id
   AND pha.segment1=nvl(:P_PO_NUM,pha.segment1)
   AND aia.invoice_num=nvl(:P_INVOICE_NUM,aia.invoice_num)
   AND rsh.receipt_num=nvl(:P_RECEIPT_NUM,rsh.receipt_num)
 order by 2

2 comments:

Pawan Saraswat said...

rcv_transactions table is missing from the join. That's why duplicate values (invoice are repeating for receipts) are coming.
please update the query.

Pawan Saraswat said...

ap_invoice_distributions_all . RCV_TRANSACTION_ID must be join with
rcv_transactions . TRANSACTION_ID

Post a Comment

Contact us for any Collaboration, Project Support & On Job Support Work

Name

Email *

Message *