Friday 28 September 2018

PO, PR and RCV useful queries

-- zpr
select pha.*
from po_requisition_headers_all prha
, po_requisition_lines_all prla
where 1=1
--and prha.org_id = 6941
and prha.segment1 = '15668'
and prha.requisition_header_id = prla.requisition_header_id
--and prla.quantity <> prla.quantity_delivered
;

-- zprpo
select prha.segment1,prla.*
from po_headers_all pha
, po_lines_all pla
, po_distributions_all pda
, po_req_distributions_all prda
, po_requisition_lines_all prla
, po_requisition_headers_all prha
where 1=1
and pha.org_id = 6941
and pha.segment1 = '6715'
and pha.po_header_id = pla.po_header_id
and pla.po_line_id = pda.po_line_id
and pda.req_distribution_id = prda.distribution_id
and prda.requisition_line_id = prla.requisition_line_id
and prla.requisition_header_id = prha.requisition_header_id
;

-- zpo
select pha.segment1,plla.*
from po_headers_all pha
    ,po_lines_all pla
    --,po_line_locations_all plla
where 1=1 --and pha.po_header_id = 73815567
  and pha.segment1 = '2740'
  and pha.org_id = 6941
  and pha.po_header_id = pla.po_header_id
  and pla.po_header_id = pla.po_header_id
  --and pla.po_line_id = plla.po_line_id
  order by 1,2,3
  ;

--zrcv
select rsh.*,rsl.*
from rcv_shipment_headers rsh
    ,rcv_shipment_lines rsl
where 1=1 --and pha.po_header_id = 73815567
  and rsh.receipt_num in ('11228','12175','11362')
  --and rsh.shipment_num in ('11228','12175','11362')
  and rsh.shipment_header_id = rsl.shipment_header_id
  --order by 1,2,3
  ;

--zporcv 
select pha.segment1,pla.line_num,rt.*
from po_headers_all pha
    ,po_lines_all pla
    --,po_line_locations_all plla
,rcv_shipment_headers rsh
    ,rcv_shipment_lines rsl
    ,rcv_transactions rt
where 1=1 --and pha.po_header_id = 73815567
  and pha.segment1 = '2740'
  and pha.org_id = 6941
  and pha.po_header_id = pla.po_header_id
  and pla.po_header_id = plla.po_header_id
  --and pla.po_line_id = plla.po_line_id
  and rsl.po_line_id = pla.po_line_id
  and rsh.shipment_header_id = rsl.shipment_header_id
  and rsl.shipment_header_id = rt.shipment_header_id
  and rsl.shipment_line_id = rt.shipment_line_id
  order by 1,2,3
  ; 

No comments:

Post a Comment