SELECT
DECODE(PLLA.FROM_LINE_ID,'-1','手工','','自动创建') 下达方式,
rsh.receipt_num 收据号,
POV.SEGMENT1 供应商编号,
pov.vendor_name 供应商名称,
poh.segment1 采购订单,
pol.line_num 订单行,
PTL.LINE_TYPE 行类型,
PLLA.CREATION_DATE 订单下达日期,
PLLA.LAST_UPDATE_DATE 订单更新时间,
msi.segment1 物料编码,
msi.description 物料描述,
rcvt.unit_of_measure 计量单位,
POL.QUANTITY 订单行数量,
plla.shipment_num 发运行,
PLLA.CLOSED_CODE 发运状态,
PLLA.QUANTITY 发运行数量,
rcvt.quantity 处理数量,
DECODE(rcvt.transaction_type,'REJECT','拒绝','RETURN TO RECEIVING','退回至接收','DELIVER','交货','RECEIVE','接收','ACCEPT','接受','TRANSFER','转移','RETURN TO VENDOR','退回至供应商') 类型,
rcvt.transaction_date 接收日期,
FU.DESCRIPTION 采购员
FROM po.rcv_transactions rcvt,
po.rcv_shipment_headers rsh,
APPLSYS.FND_USER FU,
po.po_headers_all poh,
po.po_lines_all pol,
inv.mtl_system_items_b msi,
inv.MTL_ITEM_LOCATIONS mil,
po.po_line_locations_all PLLA,
po.po_vendors pov,
PO.PO_LINE_TYPES_TL PTL
WHERE rcvt.organization_id = X
AND rcvt.shipment_header_id = rsh.shipment_header_id
AND poh.po_header_id = rcvt.po_header_id
AND poh.org_id =Y
AND PLLA.po_line_id = rcvt.po_line_id
AND msi.organization_id = X
AND pol.item_id = msi.inventory_item_id
AND mil.inventory_location_id(+) = rcvt.locator_id
AND rsh.vendor_id = pov.vendor_id
AND PTL.LANGUAGE = 'ZHS'
AND PTL.LINE_TYPE_ID = POL.LINE_TYPE_ID
AND rcvt.transaction_type='RECEIVE'
AND PLLA.CREATED_BY=FU.USER_ID
AND PLLA.PO_HEADER_ID=POL.PO_HEADER_ID
AND PLLA.PO_LINE_ID=POL.PO_LINE_ID
AND plla.org_id=POH.org_id
AND PLLA.CREATION_DATE BETWEEN to_date('20**-01-01','yyyy-mm-dd') and to_date('20**-01-31','yyyy-mm-dd')