How to join (ap invoice distributions all) AP table info with PO Table

來源:互聯網
上載者:User
Below is the SQL for AP->PO->SLA->GL  for *R12*.
========================

select ph.segment1 po_number,
       aps.vendor_name,
       msi.segment1 item_number,
       msi.description item_description,
       
       'A/P PO Match' accrual_transaction,
       'AP*' source,
       (select organization_name
          from apps.org_organization_definitions
         where organization_id = pd.destination_organization_id)
       
       org,
       ai.invoice_num doc_number,
       ai.invoice_date doc_date,
       aid.invoice_line_number line,
       pl.unit_meas_lookup_code uom,
       
       aid.quantity_invoiced quantity,
       aid.unit_price,
       (nvl(xdl.unrounded_accounted_dr, 0) -
       nvl(xdl.unrounded_accounted_cr, 0)) accounted_amount,
       (nvl(xdl.unrounded_entered_cr, 0) - nvl(xdl.unrounded_entered_cr, 0)) entered_amount,
       xal.currency_code
  from apps.gl_je_headers                gjh,
       apps.gl_je_lines                  gjl,
       apps.gl_import_references         gir,
       apps.xla_ae_lines                 xal,
       apps.xla_ae_headers               xah,
       apps.xla_events                   xe,
       apps.xla_event_types_tl           xet,
       apps.xla_event_classes_tl         xect,
       apps.xla_distribution_links       xdl,
       apps.ap_invoice_distributions_all aid,
       apps.ap_invoices_all              ai,
       apps.po_headers_all               ph,
       apps.po_distributions_all         pd,
       apps.po_lines_all                 pl,
       apps.ap_suppliers                 aps,
       apps.mtl_system_items_b           msi
 where gjh.je_header_id = gjl.je_header_id
   and gjh.je_header_id = gir.je_header_id
   and gjl.je_header_id = gir.je_header_id
   and gir.je_line_num = gjl.je_line_num
   and gir.gl_sl_link_id = xal.gl_sl_link_id
   and xal.ae_header_id = xah.ae_header_id
   and xah.event_id = xe.event_id
   and xe.event_type_code = xet.event_type_code
   and xe.application_id = xet.application_id
   and xet.language = userenv('LANG')
   and xect.entity_code = xet.entity_code
   and xect.event_class_code = xet.event_class_code
   and xect.application_id = xe.application_id
   and xect.language = userenv('LANG')
   and xah.ae_header_id = xdl.ae_header_id
   and xal.ae_line_num = xdl.ae_line_num
   and xdl.source_distribution_type = 'AP_INV_DIST'
   and xdl.source_distribution_id_num_1 = aid.invoice_distribution_id
   and ai.invoice_id = aid.invoice_id
   and aid.po_distribution_id = pd.po_distribution_id
   and gjh.je_source = 'Payables'
   and ph.po_header_id = pd.po_header_id
   and pl.po_header_id = ph.po_header_id
   and pd.po_line_id = pl.po_line_id
   and pd.org_id = &org_id
   and ph.org_id = &org_id
   and ai.org_id = &org_id
   and aid.org_id = &org_id
   and gjl.code_combination_id = &ccid
   and ph.vendor_id = aps.vendor_id
   and msi.inventory_item_id = pl.item_id
   and msi.organization_id = pd.destination_organization_id
   

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.