Вы находитесь на странице: 1из 4

I had to provide data to auditors on the Internal & Purchase Requisitions created by users Purchase Orders created for

the requisitions (inventory and non inventory items) Receiving transactions with PO and Requisition information I have given the queries here as could be useful. All data has been taken for ye ars 2010 and 2011. You can change it as per your requirement. Purchase Requisition details 01 SELECT prh.segment1 "Req #", prh.creation_date, prh.created_by, poh.segm ent1 "PO #", ppx.full_name "Requestor Name", 02 prh.description "Req Description", prh.authorization_status, prh. note_to_authorizer, prh.type_lookup_code, prl.line_num, 03 prl.line_type_id, prl.item_description, prl.unit_meas_lookup_code , prl.unit_price, prl.quantity, prl.quantity_delivered, 04 prl.need_by_date, prl.note_to_agent, prl.currency_code, prl.rate_ type, prl.rate_date, prl.quantity_cancelled, prl.cancel_date, 05 prl.cancel_reason 06 FROM po_requisition_headers_all prh, 07 po_requisition_lines_all prl, 08 po_req_distributions_all prd, 09 per_people_x ppx, 10 po_headers_all poh, 11 po_distributions_all pda 12 WHERE prh.requisition_header_id = prl.requisition_header_id 13 AND ppx.person_id = prh.preparer_id 14 AND prh.type_lookup_code = 'PURCHASE' 15 AND prd.requisition_line_id = prl.requisition_line_id 16 AND pda.req_distribution_id = prd.distribution_id 17 AND pda.po_header_id = poh.po_header_id 18 AND TO_CHAR (prh.creation_date, 'YYYY') IN ('2010', '2011') Internal Requisition details 01 SELECT prh.segment1 "Req #", prh.creation_date, prh.created_by, poh.segm ent1 "PO #", ppx.full_name "Requestor Name", 02 prh.description "Req Description", prh.authorization_status, prh. note_to_authorizer, prl.line_num, 03 prl.line_type_id, prl.source_type_code, prl.item_description, prl .unit_meas_lookup_code, prl.unit_price, prl.quantity, prl.quantity_delivered, 04 prl.need_by_date, prl.note_to_agent, prl.currency_code, prl.rate_ type, prl.rate_date, prl.quantity_cancelled, prl.cancel_date, 05 prl.cancel_reason 06 FROM po_requisition_headers_all prh, 07 po_requisition_lines_all prl, 08 po_req_distributions_all prd, 09 per_people_x ppx, 10 po_headers_all poh, 11 po_distributions_all pda 12 WHERE prh.requisition_header_id = prl.requisition_header_id 13 AND ppx.person_id = prh.preparer_id 14 AND prh.type_lookup_code = 'INTERNAL' 15 AND prd.requisition_line_id = prl.requisition_line_id 16 AND pda.req_distribution_id (+) = prd.distribution_id 17 AND pda.po_header_id = poh.po_header_id (+) 18 AND TO_CHAR (prh.creation_date, 'YYYY') IN ('2010', '2011') Purchase Order details 001 -- Purchase Orders for non inventory items like service 002 SELECT 003 ph.SEGMENT1 po_num 004 , ph.CREATION_DATE

005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064

, hou.name "Operating Unit" , ppx.full_name "Buyer Name" , ph.type_lookup_code "PO Type" , plc.displayed_field "PO Status" , ph.COMMENTS , pl.line_num , plt.order_type_lookup_code "Line Type" , NULL "Item Code" , pl.item_description , pl.unit_meas_lookup_code "UOM" , pl.base_unit_price , pl.unit_price , pl.quantity , ood.organization_code "Shipment Org Code" , ood.organization_name "Shipment Org Name" , pv.vendor_name supplier , pvs.vendor_site_code , (pl.unit_price * pl.quantity) "Line Amount" , prh.segment1 req_num , prh.type_lookup_code req_method , ppx1.full_name "Requisition requestor" FROM po_headers_all ph , po_lines_all pl , po_distributions_all pda , po_vendors pv , po_vendor_sites_all pvs , po_distributions_all pd , po_req_distributions_all prd , po_requisition_lines_all prl , po_requisition_headers_all prh , hr_operating_units hou , per_people_x ppx , po_line_types_b plt , org_organization_definitions ood , per_people_x ppx1 , po_lookup_codes plc WHERE 1=1 AND TO_CHAR(ph.creation_date, 'YYYY') IN (2010, 2011) AND ph.vendor_id = pv.vendor_id AND ph.po_header_id = pl.po_header_id AND ph.vendor_site_id = pvs.vendor_site_id AND ph.po_header_id = pd.po_header_id and pl.po_line_id = pd.po_line_id AND pd.req_distribution_id = prd.distribution_id (+) AND prd.requisition_line_id = prl.requisition_line_id (+) AND prl.requisition_header_id = prh.requisition_header_id (+) and hou.organization_id = ph.org_id and ph.agent_id = ppx.person_id and pda.po_header_id = ph.po_header_id and pda.po_line_id = pl.po_line_id and pl.line_type_id = plt.line_type_id and ood.organization_id = pda.destination_organization_id and ppx1.person_id (+) = prh.preparer_id and plc.lookup_type = 'DOCUMENT STATE' and plc.LOOKUP_CODE = ph.closed_code and pl.item_id is null UNION -- Purchase Orders for inventory items SELECT

065 ph.SEGMENT1 po_num 066 , ph.CREATION_DATE 067 , hou.name "Operating Unit" 068 , ppx.full_name "Buyer Name" 069 , ph.type_lookup_code "PO Type" 070 , plc.displayed_field "PO Status" 071 , ph.COMMENTS 072 , pl.line_num 073 , plt.order_type_lookup_code "Line Type" 074 , msi.segment1 "Item Code" 075 , pl.item_description 076 , pl.unit_meas_lookup_code "UOM" 077 , pl.base_unit_price 078 , pl.unit_price 079 , pl.quantity 080 , ood.organization_code "Shipment Org Code" 081 , ood.organization_name "Shipment Org Name" 082 , pv.vendor_name supplier 083 , pvs.vendor_site_code 084 , (pl.unit_price * pl.quantity) "Line Amount" 085 , prh.segment1 req_num 086 , prh.type_lookup_code req_method 087 , ppx1.full_name "Requisition requestor" 088 FROM po_headers_all ph 089 , po_lines_all pl 090 , po_distributions_all pda 091 , po_vendors pv 092 , po_vendor_sites_all pvs 093 , po_distributions_all pd 094 , po_req_distributions_all prd 095 , po_requisition_lines_all prl 096 , po_requisition_headers_all prh 097 , hr_operating_units hou 098 , per_people_x ppx 099 , mtl_system_items_b msi 100 , po_line_types_b plt 101 , org_organization_definitions ood 102 , per_people_x ppx1 103 , po_lookup_codes plc 104 WHERE 105 1=1 106 AND TO_CHAR(ph.creation_date, 'YYYY') IN (2010, 2011) 107 AND ph.vendor_id = pv.vendor_id 108 AND ph.po_header_id = pl.po_header_id 109 AND ph.vendor_site_id = pvs.vendor_site_id 110 AND ph.po_header_id = pd.po_header_id 111 and pl.po_line_id = pd.po_line_id 112 AND pd.req_distribution_id = prd.distribution_id (+) 113 AND prd.requisition_line_id = prl.requisition_line_id (+) 114 AND prl.requisition_header_id = prh.requisition_header_id (+) 115 and hou.organization_id = ph.org_id 116 and ph.agent_id = ppx.person_id 117 and pda.po_header_id = ph.po_header_id 118 and pda.po_line_id = pl.po_line_id 119 and pl.line_type_id = plt.line_type_id 120 and ood.organization_id = pda.destination_organization_id 121 and ppx1.person_id (+) = prh.preparer_id 122 and pda.destination_organization_id = msi.organization_id (+) 123 and msi.inventory_item_id = nvl(pl.item_id, msi.inventory_item_id)-- OR pl.item_id is null)

124 125 126

and plc.lookup_type = 'DOCUMENT STATE' and plc.LOOKUP_CODE = ph.closed_code and pl.item_id is not null

Receiving transactions with PO and requisition information 01 SELECT 02 ph.segment1 po_num, 03 ood.organization_name, 04 pol.po_line_id, 05 pll.quantity, 06 rsh. receipt_source_code, 07 rsh. vendor_id, 08 rsh. vendor_site_id, 09 rsh. organization_id, 10 rsh. shipment_num, 11 rsh. receipt_num, 12 rsh. ship_to_location_id, 13 rsh. bill_of_lading, 14 rsl.shipment_line_id, 15 rsl.QUANTITY_SHIPPED, 16 rsl.QUANTITY_RECEIVED , 17 rct.transaction_type, 18 rct.transaction_id, 19 nvl(rct.source_doc_quantity,0) transaction_qty 20 from rcv_transactions rct 21 , rcv_shipment_headers rsh 22 , rcv_shipment_lines rsl 23 , po_lines_all pol 24 , po_line_locations_all pll 25 , po_headers_all ph 26 , org_organization_definitions ood 27 where 1=1 28 and to_char(rct.creation_date, 'YYYY') in ('2010', '2011') 29 and rct.po_header_id = ph.po_header_id 30 and rct.po_line_location_id = pll.line_location_id 31 and rct.po_line_id = pol.po_line_id 32 and rct.shipment_line_id=rsl.shipment_line_id 33 and rsl.shipment_header_id=rsh.shipment_header_id 34 and rsh.ship_to_org_id = ood.organization_id 35 order by rct.transaction_id - See more at: http://www.oracleerpfunctional.com/2012/08/sql-queries-to-get-req uisition-po-and.html#sthash.KsvMsKGa.dpuf