ECC Procurement, Purchase Orders, SQL4

Description
Columns: Ecc Spec Id, 'Po Ord D Row Id', 'Po Ord D Context', 'Po Ord D Concatenated Segments', Po Dist Id, Po Dist Num, Po Dist Charge Account, Project Name, Project Number, Task Name ...
Imported from ECC
SELECT * FROM
(SELECT gt.char1 ecc_spec_id, DFV.*,
po_dist.po_distribution_id                                         po_dist_id,
		 po_dist.distribution_num                                           po_dist_num,
		 (SELECT flv.meaning
          FROM   fnd_lookup_values flv
          WHERE  flv.lookup_type = 'DESTINATION TYPE'
          AND flv.lookup_code = po_dist.destination_type_code
          AND flv.language= po_hr_org_unit_tl.LANGUAGE)	                po_dist_destination_type,
		 (SELECT  concatenated_segments
          FROM gl_code_combinations_kfv  gl_code_kfv
          WHERE code_combination_id = po_dist.code_combination_id)   	    po_dist_charge_account,
		 pa_project.name                                                    project_name,
		 pa_project.segment1                                                project_number,
		 pa_task.task_name                                                  task_name,
		 pa_task.task_number                                                task_number,
		 po_dist.expenditure_type                                           po_expenditure_type,
         po_hr_org_unit_tl.name                                             po_EXPENDITURE_ORGANIZATION,
         po_dist.EXPENDITURE_ITEM_DATE                                      po_EXPENDITURE_ITEM_DATE,
		 (SELECT full_name
          FROM  hr_employees hr_emp
          WHERE hr_emp.employee_id = po_dist.deliver_to_person_id)       	po_dist_requester,
          po_hr_org_unit_tl.LANGUAGE,
     (select req_header.segment1
      from po_requisition_headers_all req_header,
           po_distributions_all pda,
           po_requisition_lines_all req_line,
           po_req_distributions_all req_dist
      where req_line.requisition_header_id = req_header.requisition_header_id
      and req_line.requisition_line_id  = req_dist.requisition_line_id
      and req_dist.distribution_id     = pda.req_distribution_id
      AND pda.po_distribution_id = po_dist.po_distribution_id) requisition,
po_dist.destination_subinventory 	po_dist_dest_sub_inv
FROM
po_distributions_all po_dist,
po_session_gt gt,
po_headers_all po_header,
pa_projects_all pa_project,
	 pa_tasks  pa_task,
  hr_all_organization_units_tl po_hr_org_unit_tl,
  (select 'PO_ORD_D_ROW_ID','PO_ORD_D_CONTEXT','PO_ORD_D_CONCATENATED_SEGMENTS' from dual where 1=2  union select ROWIDTOCHAR(ROW_ID),CONTEXT,CONCATENATED_SEGMENTS from PO_DISTRIBUTIONS_ALL_DFV) DFV
 
WHERE gt.KEY=3132480
AND po_dist.po_header_id = gt.num1
AND po_dist.po_line_id = gt.num2
AND po_dist.line_location_id = gt.num3
and po_header.po_header_id = po_dist.po_header_id
	  and po_dist.task_id = pa_task.task_id(+)
	  and pa_task.project_id = pa_project.project_id (+)
	  and po_header.org_id =   po_hr_org_unit_tl.organization_id(+)
          AND po_hr_org_unit_tl.language IN ('US')
	  AND po_dist.rowid = dfv."'PO_ORD_D_ROW_ID'" (+))
      PIVOT (max(po_EXPENDITURE_ORGANIZATION) as po_EXPENDITURE_ORGANIZATION,
	  max(po_dist_destination_type) as po_dist_destination_type
 for LANGUAGE in ('US' "US"))