Wednesday, 13 June 2012

Query to get RECEIPT number using PO number

SELECT  
              pha.po_header_id,
              pha.segment1 "po number",
              rsh.receipt_num "receipt number"
FROM   po_headers_all pha,
              rcv_shipment_lines  rsl,
              rcv_shipment_headers rsh
WHERE  1=1
AND     pha.po_header_id=rsl.po_header_id
AND     rsl.shipment_header_id=rsh.shipment_header_id
AND     pha.segment1='200300';--po number

4 comments:

  1. I need one query where i can match the po_num with the receipt_num but without this
    AND pha.segment1='200300';--po number

    i need it for ma period of time

    ReplyDelete
  2. directly give receiput number by giving input as po numebr
    SELECT pha.segment1 "PO Number"
    , rsh.receipt_num
    FROM po_headers_all pha,
    po_lines_all pla,
    po_distributions_all pda,
    po_line_locations_all plla,
    rcv_shipment_headers rsh,
    rcv_shipment_lines rsl,
    rcv_transactions rt
    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 pha.po_header_id = plla.po_header_id
    AND pha.po_header_id = pda.po_header_id
    AND pla.po_line_id = pda.po_line_id
    AND rsh.shipment_header_id = rsl.shipment_header_id
    AND rsl.shipment_line_id = rt.shipment_line_id
    AND rsh.shipment_header_id = rt.shipment_header_id
    AND rt.po_distribution_id = pda.po_distribution_id
    AND pha.segment1 = :po_number
    AND rt.transaction_type = 'RECEIVE';

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. I need this output-- Invoice number will be displayed if PO has been matched to invoice, otherwise only receipt number will be displayed

    ReplyDelete