select
msi.segment1 物料编码,
msi.description 物料描述,
sum(rs.quantity) 接收中数量,
ph.segment1 采购订单,
pl.line_num 订单行,
pl.quantity 订单行数量,
rsh.receipt_num 收据号,
rsh.bill_of_lading 提单号
from
po.rcv_supply rs,
inv.mtl_system_items_b msi,
po.po_headers_all ph,
po.po_lines_all pl,
po.rcv_shipment_headers rsh,
po.rcv_shipment_lines rsl
where
rs.supply_type_code = 'RECEIVING'
and rs.to_organization_id = X
and rs.quantity <> 0
and rs.item_id = msi.inventory_item_id
and rs.to_organization_id = msi.organization_id
and rs.po_header_id = ph.po_header_id
and rs.po_line_id = pl.po_line_id
and ph.org_id = Y
and pl.org_id = Y
and ph.po_header_id = pl.po_header_id
and rs.po_line_id = rsl.po_line_id
and rs.po_header_id = rsl.po_header_id
and rs.to_organization_id = rsl.to_organization_id
and rsl.shipment_header_id = rsh.shipment_header_id
and rsh.ship_to_org_id = rsl.to_organization_id
group by
msi.segment1,
msi.description,
ph.segment1,
pl.line_num,
pl.quantity,
rsh.receipt_num,
rsh.bill_of_lading