Tuesday, 27 July 2021

link between PO and Projects Query in oracle fusion (po_headers_all and pjf_projects_all_b)

 SELECT

ph.segment1 CommitmentNumber
,pl.line_num ItemNumber
,(SELECT DISTINCT esi.item_number
  FROM egp_system_items_b esi
  WHERE esi.inventory_item_id=pl.item_id) ITEM
,pl.item_description ItemDescription
,plt.line_type ITEM_TYPE
,gcc.segment1||gcc.segment2||gcc.segment3 ACCT_UNIT
,gcc.segment4 ACCT_CATEGORY
,ppa.segment1 ActivityNumber
,pl.list_price ENT_UNIT_CST
,pll.quantity QUANTITY
,(pll.quantity*pl.list_price) CommitmentItemAmount
,pll.need_by_date POSTED_DATE
,ps.segment1 CompanyNumber
,hp.party_name Description
,ppa.attribute3 ProjectIdentifier
,ph.creation_date CommitmentDate
,ppn.full_name BUYER_CODE
,pld.location_code REQ_LOCATION
,pl.attribute1||','||pl.attribute2 BudgetLineItem
,'Purchase Order' CommitmentType
FROM po_headers_all ph,po_lines_all pl
,po_line_types_tl plt
,gl_code_combinations gcc
,po_distributions_all pd
,pjf_projects_all_b ppa
,po_line_locations_all pll
,poz_suppliers ps
,hz_parties hp
,per_person_names_f ppn
,per_location_details_f_tl pld
,per_location_details_f pldf
WHERE ph.po_header_id=pl.po_header_id
AND plt.line_type_id=pl.line_type_id
AND plt.language=USERENV('LANG')
AND pd.po_header_id=pl.po_header_id
AND pd.po_line_id=pl.po_line_id
AND pd.code_combination_id=gcc.code_combination_id
AND gcc.enabled_flag='Y'
AND SYSDATE BETWEEN NVL(gcc.start_date_active,SYSDATE) AND NVL(gcc.end_date_active,SYSDATE)
AND pd.Pjc_Project_id=ppa.project_id
AND pll.po_header_id=pl.po_header_id
AND pll.po_line_id=pl.po_line_id
AND ph.vendor_id=ps.vendor_id
AND ps.party_id=hp.party_id
AND ppn.person_id=ph.agent_id
AND ppn.name_type='GLOBAL'
AND SYSDATE BETWEEN NVL(ppn.effective_start_date,SYSDATE) AND NVL(ppn.effective_end_date,SYSDATE)
AND ps.enabled_flag='Y'
AND SYSDATE BETWEEN NVL(ps.start_date_active,SYSDATE) AND NVL(ps.end_date_active,SYSDATE)
AND pldf.location_id=pd.Deliver_to_location_ID
AND pldf.active_status='A'
AND SYSDATE BETWEEN NVL(pldf.effective_start_date,SYSDATE) AND NVL(pldf.effective_end_date,SYSDATE)
AND pld.location_details_id=pldf.location_details_id
AND pld.language=USERENV('LANG')