Obtain Purchase Order Details Details
SELECT dha.source_order_system ,
dfla.source_order_number ,
dha.order_number ,
dfla.source_line_number ,
dfla.fulfill_line_number ,
dfla.status_code ,
dla.line_number ,
dla.display_line_number ,
dha.header_id ,
dfla.fulfill_line_id ,
dla.line_id ,
dfla.FULFILL_LINE_NUMBER ,
PRHA.REQUISITION_NUMBER ,
PRHA.DOCUMENT_STATUS ,
PRHA.PROCESS_STATUS ,
PRLA.REQUISITION_LINE_ID ,
pha.segment1 po_number ,
pha.DOCUMENT_STATUS ,
pla.line_num po_line_number ,
pla.LINE_STATUS ,
pla.item_description ,
plla.shipment_num ,
plla.QUANTITY ,
plla.QUANTITY_RECEIVED ,
plla.QUANTITY_ACCEPTED ,
plla.QUANTITY_REJECTED ,
plla.QUANTITY_BILLED ,
plla.QUANTITY_CANCELLED
FROM fusion.por_requisition_headers_all prha,
fusion.por_requisition_lines_all prla ,
fusion.doo_headers_all dha ,
fusion.doo_fulfill_lines_all dfla ,
fusion.doo_lines_all dla ,
fusion.po_headers_all pha ,
fusion.po_lines_all pla ,
fusion.po_line_locations_all plla
WHERE prha.requisition_header_id = prla.requisition_header_id
AND dha.source_order_number IN ('&SOURCE_ORDER_NUMBER')
AND dha.header_id = dfla.header_id
AND TO_CHAR(dfla.fulfill_line_id) = prla.interface_LINE_KEY (+)
AND dha.submitted_flag = 'Y'
AND dfla.line_id = dla.line_id
AND pha.po_header_id = prla.po_header_id
AND pla.po_line_id = prla.po_line_id
AND plla.po_line_id (+) = pla.po_line_id
ORDER BY dla.display_line_number