SELECT
Pha. SEGMENT1 Order number,
Pha.approved_flag Approval Status,
Pha.closed_code Order off status,
Pha.comments Order Description,
Pvs.vendor_site_code Suppliers Location,
PLA. Line_num order lines,
Plla.need_by_date Commitment Date,
Plla.promised_date Demand Date,
PLA. Closed_code Line State,
Msi. SEGMENT1 Material Code,
Msi. DESCRIPTION description,
PLA. QUANTITY order line Quantity,
Plla.shipment_num Hair Run,
PLLA. Closed_code Shipment Status,
PLLA. QUANTITY Number of runs,
Pda.distribution_num allocation lines,
Pda.quantity_ordered the number of allocated rows,
pda.quantity_billed Order Quantity,
pda.quantity_delivered Receive Quantity,
Plla.attribute1
From PO. Po_lines_all PLA,
PO. Po_headers_all PHA,
INV. Mtl_system_items_b MSI,
Po.po_vendors PV,
Po.po_vendor_sites_all PVs,
Po. Po_distributions_archive_all PDA,
Po.po_line_locations_all PLLA
WHERE PLA. Po_header_id=pha. PO_HEADER_ID and PLA. Item_id=msi. inventory_item_id
and msi.organization_id=x
and pha.org_id=y
and pha.org_id=pla.org_id
and PLLA. Po_header_id=pla. po_header_id
and PLLA. Po_line_id=pla. po_line_id
--and (PLLA. QUANTITY =0 or pla.quantity=0)
and pha.vendor_id=pv.vendor_id
and pv.vendor_id=pvs.vendor_id
and pda.po_header_id (+) =plla.po_header_id
and pda.po_line_id (+) =plla.po_line_id
and pda.line_location_id (+) =plla.line_location_id
and pda.org_id (+) =plla.org_id
and plla.org_id=pla.org_id
--and trunc (plla.promised_date) between to_date (' 20**-01-01 ', ' yyyy-mm-dd ') and to_date (' 20**-01-31 ', ' yyyy-mm-dd ')