Monday, 31 October 2011

po_lines_with_PR_NUMBER

SELECT   DISTINCT
         prh.segment1 PR_NO,
         pl.po_header_id,
         pl.po_line_id,
         (SELECT   segment1
            FROM   po_headers_all poh
           WHERE   poh.po_header_id = pl.po_header_id
                   AND poh.org_id = pl.org_id)
            L_REFERENCE_NUM,
         pl.line_num,
         pll.shipment_num,
         plt.line_type,
         msi.segment1 Item_Code,
         msi.DESCRIPTION Item_Desc,
         pl.unit_meas_lookup_code uom_code,
         pl.quantity,
         pl.unit_price,
         pll.promised_date,
         ood.organization_code ship_to_organization_code,
         hloc.location_code l_ship_to_location,
         pll.invoice_close_tolerance inv_cl_toler,
         pll.receive_close_tolerance rec_cl_toler,
         pl.attribute_category l_attribute_category,
         pl.attribute1 l_attribute1,
         pl.attribute2 l_attribute2,
         pl.attribute3 l_attribute3,
         pl.attribute4 l_attribute4,
         pl.attribute5 l_attribute5,
         pl.attribute6 l_attribute6,
         pl.attribute7 l_attribute7,
         pl.attribute8 l_attribute8,
         pl.attribute9 l_attribute9,
         pl.attribute10 l_attribute10,
         pl.attribute11 l_attribute11,
         pl.attribute12 l_attribute12,
         pl.attribute13 l_attribute13,
         pl.attribute14 l_attribute14,
         pl.attribute15 l_attribute15
  FROM   po_lines_all pl,
         po_line_types plt,
         mtl_system_items_b msi,
         po_line_locations_all pll,
         org_organization_definitions ood,
         hr_locations_all hloc,
         po_requisition_headers_All prh,
         po_requisition_lines_all prl,
         po_req_distributions_All prd,
         po_distributions_all pod
 WHERE       pl.line_type_id = plt.line_type_id
         AND pl.item_id = msi.inventory_item_id
         AND pl.po_line_id = pll.po_line_id
         AND pl.org_id = pll.org_id
         AND hloc.location_id(+) = pll.ship_to_location_id
         AND ood.organization_id(+) = pll.ship_to_organization_id
         AND pl.org_id = ood.operating_unit
         AND prh.REQUISITION_HEADER_ID = prl.REQUISITION_HEADER_ID
         AND prl.REQUISITION_LINE_ID = prd.REQUISITION_LINE_ID
         and pod.REQ_DISTRIBUTION_ID=prd.DISTRIBUTION_ID
         AND ood.set_of_books_id = 5
         AND TRUNC (pl.creation_date) BETWEEN '01-APR-2011' AND '31-jul-2011'

No comments:

Post a Comment