Purchase Order Query

About: below script to fetch Purchase Order details with some additional information related to PO

            based on mtl_parameters  organization_id 


SELECT

       ph.segment1                     AS po_number,

       ph.creation_date,

       ph.type_lookup_code,

       ph.freight_terms_lookup_code,

       ph.authorization_status,

       msib.segment1                   AS item,

       msib.segment2,

       ph.closed_code,

       pll.need_by_date,

       pll.promised_date,

       mp.organization_code,

       ph.org_id,

       ph.currency_code,

       pol.unit_price,

       hou.name                        AS ou_name,

       pol.quantity,

       pov.vendor_name                 AS supplier_name,

       ph.vendor_site_id,

       povs.vendor_site_code

FROM   apps.po_headers_all            ph,

       apps.po_lines_all              pol,

       apps.po_line_locations_all     pll,

       apps.mtl_parameters            mp,

       apps.hr_operating_units        hou,

       apps.mtl_system_items_b        msib,

       apps.po_vendors                pov,

       apps.po_vendor_sites_all       povs

WHERE       ph.po_header_id              = pol.po_header_id

        AND ph.org_id                    = pol.org_id

        AND ph.po_header_id              = pll.po_header_id

        AND pll.ship_to_organization_id  = mp.organization_id

        AND ph.org_id                    = hou.organization_id

        AND pol.item_id                  = msib.inventory_item_id

        AND mp.organization_id           = msib.organization_id

        AND ph.vendor_id                 = pov.vendor_id

        AND ph.vendor_site_id            = povs.vendor_site_id

        AND mp.organization_id           = :org_id

        AND ROWNUM                      <= 2

        AND ph.creation_date            >=TRUNC(SYSDATE - 10);

Comments