SELECT DISTINCT
c.name ORG,
b.organization_code ORGANIZATION,
poh.segment1 PO_NUMBER,
poa.vendor_name VENDOR_NAME,
poh.APPROVED_DATE,
a.agent_name BUYER_NAME,
msi.segment1 PART_NUMBER,
msi.description,
mc.description CATEGORY_CONCAT_SEGS,
pol.unit_price PO_PRICE,
poh.currency_code po_currency_code,
pol.QUANTITY,
pol.UNIT_MEAS_LOOKUP_CODE PO_UOM,
cst.item_cost STD_COST,
gsb.CURRENCY_CODE STD_COST_CURRENCY_CODE,
poh.creation_date "PO ISSUE DATE",--,MMT.CURRENCY_CODE
msi.INVENTORY_ITEM_STATUS_CODE ITEM_STATUS,--,rsh.creation_date "PO RECIEVE DATE"
(SELECT DISTINCT MAX (h.creation_date)
FROM rcv_shipment_headers h, rcv_shipment_lines i
WHERE h.SHIPMENT_HEADER_ID = i.SHIPMENT_HEADER_ID
AND i.PO_LINE_ID = pol.PO_LINE_ID)
"PO RECIEVE DATE",
(SELECT SUM (NVL (d.QUANTITY_RECEIVED, 0))
FROM rcv_shipment_lines d
WHERE pol.PO_LINE_ID = d.PO_LINE_ID)
"RECIEVED QUANTITY"
FROM po_headers_all poh,
po_lines_all pol,
mtl_system_items_b msi,
mtl_categories mc,
CST_ITEM_COSTS cst,
org_organization_definitions b,
GL_SETS_OF_BOOKS gsb,
po_vendors poa,
po_agents_v a,
hr_operating_units c
WHERE pol.po_header_id = poh.po_header_id
AND poh.org_id = pol.org_id
AND msi.inventory_item_id = pol.item_id
AND mc.category_id = pol.category_id
AND cst.INVENTORY_ITEM_ID = msi.inventory_item_id
AND msi.organization_id = cst.organization_id
AND poh.org_id IN (103, 235, 237)
AND cst.cost_type_id = 3
AND cst.item_cost <> 0
AND msi.organization_id IN
(SELECT organization_id
FROM org_organization_definitions
WHERE organization_code IN
('U01',
'U06',
'U08',
'U09',
'U13',
'U19',
'U20',
'U21',
'U23',
'U26'))
AND b.organization_id = msi.organization_id
AND poa.vendor_id = poh.vendor_id
AND a.agent_id = poh.agent_id
AND c.ORGANIZATION_ID = poh.org_id
--and poh.segment1='700017217'
AND poh.creation_date BETWEEN '25-SEP-2013' AND '25-SEP-2014'
/*and MMT.TRANSACTION_SOURCE_ID = poh.PO_HEADER_ID
and MMT.INVENTORY_ITEM_ID=msi.inventory_item_id
and mmt.organization_id=cst.organization_id
and mmt.currency_code is not null*/
AND gsb.SET_OF_BOOKS_ID = b.SET_OF_BOOKS_ID
--and pll.PO_HEADER_ID=poh.po_header_id
--and pol.PO_LINE_ID=pll.PO_LINE_ID(+)
--and pol.PO_LINE_ID=pod.PO_LINE_ID(+)
--and pll.org_id=poh.org_id
--and pol.po_header_id=rsl.po_header_id
--and pol.PO_LINE_ID=rsl.PO_LINE_ID(+)
--and nvl(rsl.SHIPMENT_HEADER_ID,0)=nvl(rsh.SHIPMENT_HEADER_ID,0)
--and pll.LINE_LOCATION_ID=rsl.PO_LINE_LOCATION_ID
ORDER BY poh.segment1,
msi.segment1,
c.name,
b.organization_code
No comments:
Post a Comment