ECC Project Manufacturing, Procurement Activities, SQL3

Categories: Enterprise Command Center
Imported from Enterprise Command Center
Description: Project Manufacturing Procurement Details
Dataset Key: pjm-procurement
Security Procedure: PJM_ECC_DATASECURITY_PKG_PUB.GetFilterAttributeValues
select * from ( SELECT  /* BR */    'PROJ_BR' || '-' || dist.project_id || '-' || NVL( TO_CHAR(dist.task_id), 'NO_TASK' ) || '-' ||  por.po_header_id || '-' || por.po_release_id || '-' || pol.line_num || '-' || poll.shipment_num || '-' || dist.distribution_num AS ecc_spec_id, 'PROJ_BR' AS record_type,  b.language AS language,  GREATEST( NVL( pp.last_update_date, to_date('01-01-1990', 'DD-MM-YYYY')) , NVL( pt.last_update_date, to_date('01-01-1990', 'DD-MM-YYYY')) ,  NVL( poh.last_update_date, to_date('01-01-1990', 'DD-MM-YYYY')) , NVL( pol.last_update_date, to_date('01-01-1990', 'DD-MM-YYYY')) ,  NVL( poll.last_update_date, to_date('01-01-1990', 'DD-MM-YYYY')) , NVL( dist.last_update_date, to_date('01-01-1990', 'DD-MM-YYYY')) , NVL( por.last_update_date, to_date('01-01-1990', 'DD-MM-YYYY')) ) AS ecc_last_update_date,  pp.project_id AS project_id, pp.segment1 AS project_number, pp.org_id AS org_id, pt.task_id AS task_id, pt.task_number AS task_number, por.po_header_id AS po_header_id, poh.segment1 AS po_number, t.type_name AS br_document_type, por.po_release_id AS br_release_id, por.release_num AS br_release_number,  TO_CHAR(por.po_header_id)|| ',' ||TO_CHAR(por.po_release_id)  AS ACTIVITY_ID,  pol.line_num AS po_line_number,  poll.shipment_num AS po_shipment_number, dist.distribution_num AS po_distribution_number, por.revision_num AS po_revision_number, por.revised_date AS po_revised_date, por.release_date AS br_release_date, por.printed_date AS br_printed_date, plc1.displayed_field AS po_status, plc2.displayed_field AS br_closure_status, poh.vendor_id AS supplier_id,  pv.vendor_name AS supplier_name, poh.vendor_contact_id AS supplier_contact_id,  DECODE(pvc.last_name||', '||pvc.first_name, ', ', NULL, pvc.last_name||', '||pvc.first_name) AS supplier_contact_name,  poh.vendor_site_id AS supplier_site_id, pvs.vendor_site_code AS supplier_site_name, poh.ship_to_location_id AS ship_to_location_id,  hrl.location_code AS ship_to_location_name, poh.ship_via_lookup_code AS ship_via, plc3.displayed_field AS freight_terms,  plc4.displayed_field AS fob, por.agent_id AS po_agent_id, prf.full_name AS po_agent_name,  poh.bill_to_location_id AS bill_to_location_id, hrl2.location_code AS bill_to_location_name,  poh.terms_id AS terms_id, AS payment_term, poh.currency_code AS currency,  DECODE( pol.matching_basis, 'QUANTITY', dist.quantity_ordered * poll.price_override, 'AMOUNT', dist.amount_ordered ) AS po_dist_amount,  SUBSTR( msi.segment1, 1, 40 ) AS item_number,  NVL(msitl.description, pol.item_description) AS item_description,  dist.end_item_unit_number AS end_item_unit_number  FROM pa_projects_all pp, pa_tasks pt, po_releases_all por, po_headers_all poh, po_lines_all pol,  po_line_locations_all poll, po_distributions_all dist, po_document_types_all_tl t, po_lookup_codes plc1, po_lookup_codes plc2,  po_vendors pv,  po_vendor_contacts pvc,  po_vendor_sites_all pvs, hr_locations_all_tl hrl, po_lookup_codes plc3, po_lookup_codes plc4,  hr_locations_all_tl hrl2, per_all_people_f prf, ap_terms_tl b, mtl_system_items_b msi,  mtl_system_items_tl msitl  ,(select distinct project_id from pjm_project_parameters ) p3     WHERE pp.start_date >= NVL(to_date('','RRRR/MM/DD HH24:MI:SS'), pp.start_date) and pp.project_id = p3.project_id  AND pp.project_type <> 'AWARD_PROJECT'  AND pp.template_flag = 'N'  AND pp.project_id = dist.project_id  AND pt.task_id(+) = dist.task_id  AND poh.po_header_id = por.po_header_id  AND poh.type_lookup_code = 'BLANKET'  AND por.approved_flag IN ('Y', 'R')  AND dist.po_header_id = poh.po_header_id  AND dist.po_release_id = por.po_release_id  AND dist.po_line_id = pol.po_line_id  AND poh.po_header_id = pol.po_header_id  AND dist.line_location_id = poll.line_location_id  AND pol.po_line_id = poll.po_line_id  AND dist.org_id = pol.org_id  AND pol.item_id IS NOT NULL  AND t.document_type_code(+) = 'RELEASE'  AND t.document_subtype(+) = por.release_type  AND t.org_id(+) = por.org_id  AND plc1.lookup_code(+) = NVL( por.authorization_status, 'INCOMPLETE' )  AND plc1.lookup_type(+) = 'AUTHORIZATION STATUS'  AND plc2.lookup_code(+) = NVL( por.closed_code, 'OPEN' )  AND plc2.lookup_type(+) = 'DOCUMENT STATE'  AND pv.vendor_id(+) = poh.vendor_id  AND pvc.vendor_contact_id(+) = poh.vendor_contact_id  AND pvc.vendor_site_id(+) = poh.vendor_site_id  AND pvs.vendor_id(+) = poh.vendor_id  AND pvs.vendor_site_id(+) = poh.vendor_site_id  AND hrl.location_id(+) = poh.ship_to_location_id  AND plc3.lookup_code(+) = poh.freight_terms_lookup_code  AND plc3.lookup_type(+) = 'FREIGHT TERMS'  AND plc4.lookup_code(+) = poh.fob_lookup_code  AND plc4.lookup_type(+) = 'FOB'   AND prf.person_id(+) = por.agent_id  AND trunc(SYSDATE) BETWEEN prf.effective_start_date AND prf.effective_end_date  AND hrl2.location_id(+) = poh.bill_to_location_id  AND b.term_id = poh.terms_id  AND msi.inventory_item_id(+) = pol.item_id  AND NVL( msi.organization_id, dist.destination_organization_id ) = dist.destination_organization_id  AND msitl.inventory_item_id (+) = msi.inventory_item_id  AND msitl.organization_id (+) = msi.organization_id  AND dist.project_id IS NOT NULL  AND b.language = NVL( hrl.language, b.language )  AND b.language = NVL( hrl2.language, b.language )  AND b.language = NVL( t.language, b.language )  AND b.language = nvl(msitl.language, b.language)  AND b.language IN ('US') )  PIVOT(MAX(br_document_type) AS br_document_type, MAX(ship_to_location_name) AS ship_to_location_name, MAX(bill_to_location_name) AS bill_to_location_name, MAX(payment_term) AS payment_term, MAX(item_description) AS item_description FOR LANGUAGE IN ('US' "US"))
) x
Parameter Name SQL text Validation
Operating Unit
x.org_id in (select haouv.organization_id from hr_all_organization_units_vl haouv where