0% found this document useful (0 votes)
92 views12 pages

RKJ

The document describes a SQL query that retrieves data for payables transactions from various tables related to purchase invoices, payments, cross currency transactions, goods receiving, and work-in-progress transactions. The query returns fields including month, period, journal entry category and source, reference values, account codes, debit/credit amounts, effective dates and other identifying values. It filters for active records within a specified date range and for certain organization and account codes.

Uploaded by

Oracle developer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views12 pages

RKJ

The document describes a SQL query that retrieves data for payables transactions from various tables related to purchase invoices, payments, cross currency transactions, goods receiving, and work-in-progress transactions. The query returns fields including month, period, journal entry category and source, reference values, account codes, debit/credit amounts, effective dates and other identifying values. It filters for active records within a specified date range and for certain organization and account codes.

Uploaded by

Oracle developer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 12

--Payables(Purchase Invoices)--

SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,


gjh.je_category, gjh.je_source, TO_CHAR (aps.vendor_name) reference_1,
TO_CHAR (aia.invoice_num) "Party Bill No",
dnlcust.get_acc (gjl.code_combination_id) gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
TO_CHAR (assa.vendor_site_code) reference_2,
decode(rt.transaction_id,null,null,TO_CHAR(rsh.receipt_num)) reference_3,
NULL reference_4,
gjl.description, gjh.doc_sequence_value jv_no,
TO_CHAR (aps.vendor_name) supplier,
TO_CHAR (assa.vendor_site_code) site,
decode(rt.transaction_id,null,null,TO_CHAR(rsh.receipt_num)) grn_no
FROM apps.ap_invoices_all aia,
apps.ap_invoice_lines_all aila,
apps.rcv_transactions rt,
apps.rcv_shipment_headers rsh,
xla.xla_transaction_entities xte,
apps.xla_events xev,
apps.xla_ae_headers xah,
apps.xla_ae_lines xal,
apps.gl_import_references gir,
apps.gl_je_headers gjh,
apps.gl_je_lines gjl,
apps.ap_suppliers aps,
apps.ap_supplier_sites_all assa
WHERE aia.invoice_id = xte.source_id_int_1
AND xev.entity_id = xte.entity_id
AND xah.entity_id = xte.entity_id
AND xah.event_id = xev.event_id
AND xah.ae_header_id = xal.ae_header_id
AND xah.je_category_name = 'Purchase Invoices'
AND gjh.je_source = 'Payables'
AND xal.gl_sl_link_id = gir.gl_sl_link_id
AND gir.gl_sl_link_id = gjl.gl_sl_link_id
AND gir.gl_sl_link_table = xal.gl_sl_link_table
AND gjl.je_header_id = gjh.je_header_id
AND gjl.ledger_id = gjh.ledger_id
AND xah.ledger_id = gjh.ledger_id
AND gjh.je_header_id = gir.je_header_id
AND aia.set_of_books_id = gjh.ledger_id
AND gjl.je_header_id = gir.je_header_id
AND gir.je_line_num = gjl.je_line_num
AND aila.invoice_id = aia.invoice_id
AND rt.transaction_id(+) = aila.rcv_transaction_id
AND rsh.shipment_header_id(+) = rt.shipment_header_id
AND aila.LINE_NUMBER = 1
AND aia.vendor_id = aps.vendor_id
AND aia.vendor_site_id = assa.vendor_site_id
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
----Payables(Payments, Reconciled Payments)----
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, NULL reference_1,
NULL "Party Bill No",
dnlcust.get_acc (gjl.code_combination_id) gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
NULL reference_2,
NULL reference_3,
TO_CHAR (apc.check_number) reference_4,
gjl.description, gjh.doc_sequence_value jv_no,
NULL supplier,
NULL site,
null grn_no
FROM apps.ap_checks_all apc,
--apps.ap_invoices_all aia,
--apps.ap_invoice_payments_all aipa,
xla.xla_transaction_entities xte,
apps.xla_events xev,
apps.xla_ae_headers xah,
apps.xla_ae_lines xal,
apps.gl_import_references gir,
apps.gl_je_headers gjh,
apps.gl_je_lines gjl
WHERE apc.check_id = xte.source_id_int_1
AND gjh.je_header_id = gjl.je_header_id
AND gir.je_batch_id = gjh.je_batch_id
AND gir.je_header_id = gjh.je_header_id
AND gir.je_line_num = gjl.je_line_num
AND xal.gl_sl_link_id = gir.gl_sl_link_id
AND xal.gl_sl_link_table = gir.gl_sl_link_table
AND xal.application_id = xah.application_id
AND xal.ae_header_id = xah.ae_header_id
AND xev.application_id = xah.application_id
AND xev.event_id = xah.event_id
AND xev.entity_id = xah.entity_id
AND xte.entity_id = xah.entity_id
AND xah.je_category_name IN ('Payments', 'Reconciled Payments')
AND gjh.je_source = 'Payables'
--AND aia.set_of_books_id = gjh.ledger_id
--AND aipa.check_id = apc.check_id
--AND aia.invoice_id = aipa.invoice_id
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
------Payables(Cross Currency)------
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, NULL reference_1, NULL "Party Bill No",
dnlcust.get_acc (gjl.code_combination_id) gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
NULL reference_2, NULL reference_3, NULL reference_4, gjl.description,
gjh.doc_sequence_value jv_no, NULL supplier, NULL site, NULL grn_no
FROM apps.gl_je_lines gjl, apps.gl_je_headers gjh
WHERE gjl.je_header_id = gjh.je_header_id
AND gjh.je_source IN ('Payables')
AND gjh.je_category = 'Cross Currency'
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
------Cost Management(Receiving)-----
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, TO_CHAR (aps.vendor_name) reference_1,
NULL "Party Bill No", dnlcust.get_acc (gjl.code_combination_id)
gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
TO_CHAR (assa.vendor_site_code) reference_2,
TO_CHAR (rsh.receipt_num) reference_3,
TO_CHAR (poh.segment1) reference_4, gjl.description,
gjh.doc_sequence_value jv_no, TO_CHAR (aps.vendor_name) supplier,
TO_CHAR (assa.vendor_site_code) site, TO_CHAR (rsh.receipt_num) grn_no
FROM apps.rcv_shipment_headers rsh,
apps.rcv_transactions rt,
apps.po_headers_all poh,
xla.xla_transaction_entities xte,
apps.xla_events xev,
apps.xla_ae_headers xah,
apps.xla_ae_lines xal,
apps.gl_import_references gir,
apps.gl_je_headers gjh,
apps.gl_je_lines gjl,
apps.ap_suppliers aps,
apps.ap_supplier_sites_all assa
WHERE rt.transaction_id = xte.source_id_int_1
AND xev.entity_id = xte.entity_id
AND xah.entity_id = xte.entity_id
AND xah.event_id = xev.event_id
AND xah.ae_header_id = xal.ae_header_id
AND xah.je_category_name = 'Receiving'
AND gjh.je_source = 'Cost Management'
AND xal.gl_sl_link_id = gir.gl_sl_link_id
AND gir.gl_sl_link_id = gjl.gl_sl_link_id
AND gir.gl_sl_link_table = xal.gl_sl_link_table
AND gjl.je_header_id = gjh.je_header_id
AND gjl.ledger_id = gjh.ledger_id
AND xah.ledger_id = gjh.ledger_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 rt.shipment_header_id = rsh.shipment_header_id
AND rt.po_header_id = poh.po_header_id
AND rsh.vendor_id = aps.vendor_id
AND rsh.vendor_site_id = assa.vendor_site_id
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
-----Cost Management(WIP)-----
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, NULL reference_1,
NULL "Party Bill No", dnlcust.get_acc (gjl.code_combination_id)
gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
NULL reference_2,
TO_CHAR (ood.organization_code) reference_3,
TO_CHAR (wt.transaction_id) reference_4, gjl.description,
gjh.doc_sequence_value jv_no, NULL supplier,
NULL site, NULL grn_no
FROM apps.wip_transactions wt,
apps.org_organization_definitions ood,
xla.xla_transaction_entities xte,
apps.xla_events xev,
apps.xla_ae_headers xah,
apps.xla_ae_lines xal,
apps.gl_import_references gir,
apps.gl_je_headers gjh,
apps.gl_je_lines gjl
WHERE wt.transaction_id = xte.source_id_int_1
AND xev.entity_id = xte.entity_id
AND xah.entity_id = xte.entity_id
AND xah.event_id = xev.event_id
AND xah.ae_header_id = xal.ae_header_id
AND xah.je_category_name = 'WIP'
AND gjh.je_source = 'Cost Management'
AND xal.gl_sl_link_id = gir.gl_sl_link_id
AND gir.gl_sl_link_id = gjl.gl_sl_link_id
AND gir.gl_sl_link_table = xal.gl_sl_link_table
AND gjl.je_header_id = gjh.je_header_id
AND gjl.ledger_id = gjh.ledger_id
AND xah.ledger_id = gjh.ledger_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 ood.organization_id = wt.organization_id
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
------Cost Management(Inventory)-----
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, NULL reference_1,
NULL "Party Bill No", dnlcust.get_acc (gjl.code_combination_id)
gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
NULL reference_2,
NULL reference_3,
TO_CHAR (mmt.transaction_id) reference_4, gjl.description,
gjh.doc_sequence_value jv_no, NULL supplier,
NULL site, NULL grn_no
FROM apps.mtl_material_transactions mmt,
--apps.rcv_shipment_headers rsh,
--apps.rcv_transactions rt,
--apps.po_headers_all poh,
xla.xla_transaction_entities xte,
apps.xla_events xev,
apps.xla_ae_headers xah,
apps.xla_ae_lines xal,
apps.gl_import_references gir,
apps.gl_je_headers gjh,
apps.gl_je_lines gjl --,
--apps.ap_suppliers aps,
--apps.ap_supplier_sites_all assa
WHERE mmt.transaction_id = xte.source_id_int_1
AND xev.entity_id = xte.entity_id
AND xah.entity_id = xte.entity_id
AND xah.event_id = xev.event_id
AND xah.ae_header_id = xal.ae_header_id
AND xah.je_category_name = 'Inventory'
AND gjh.je_source = 'Cost Management'
AND xal.gl_sl_link_id = gir.gl_sl_link_id
AND gir.gl_sl_link_id = gjl.gl_sl_link_id
AND gir.gl_sl_link_table = xal.gl_sl_link_table
AND gjl.je_header_id = gjh.je_header_id
AND gjl.ledger_id = gjh.ledger_id
AND xah.ledger_id = gjh.ledger_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 mmt.rcv_transaction_id = rt.transaction_id
--AND rt.shipment_header_id = rsh.shipment_header_id
--AND rt.po_header_id = poh.po_header_id
--AND rsh.vendor_id = aps.vendor_id
--AND rsh.vendor_site_id = assa.vendor_site_id
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
-----Cost Management(MTL)-----
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, NULL reference_1, NULL "Party Bill No",
dnlcust.get_acc (gjl.code_combination_id) gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
NULL reference_2, NULL reference_3, NULL reference_4, gjl.description,
gjh.doc_sequence_value jv_no, NULL supplier, NULL site, NULL grn_no
FROM apps.gl_je_lines gjl, apps.gl_je_headers gjh
WHERE gjl.je_header_id = gjh.je_header_id
AND gjh.je_source IN ('Cost Management')
AND gjh.je_category = 'MTL'
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
-----Purchasing India (Accounting of India Localization of RTV Transactions)
Reference_5-------
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, TO_CHAR (aps.vendor_name) reference_1,
NULL "Party Bill No", dnlcust.get_acc (gjl.code_combination_id)
gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
TO_CHAR (assa.vendor_site_code) reference_2,
TO_CHAR (rsh.receipt_num) reference_3, NULL reference_4,
gjl.description, gjh.doc_sequence_value jv_no,
TO_CHAR (aps.vendor_name) supplier,
TO_CHAR (assa.vendor_site_code) site, TO_CHAR (rsh.receipt_num) grn_no
FROM apps.gl_je_headers gjh,
apps.gl_je_lines gjl,
apps.rcv_transactions rt,
apps.rcv_shipment_headers rsh,
apps.ap_suppliers aps,
apps.ap_supplier_sites_all assa
WHERE gjh.je_header_id = gjl.je_header_id
AND gjh.je_source = 'Purchasing India'
AND gjl.reference_2 = 'India Localization Entry'
AND TO_CHAR (rt.transaction_id) = gjl.reference_5
AND rt.shipment_header_id = rsh.shipment_header_id(+)
AND rsh.vendor_id = aps.vendor_id(+)
AND rsh.vendor_site_id = assa.vendor_site_id(+)
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
-----Purchasing India (Accounting of VAT Claim) Reference_6-------
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, TO_CHAR (aps.vendor_name) reference_1,
NULL "Party Bill No", dnlcust.get_acc (gjl.code_combination_id)
gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
TO_CHAR (assa.vendor_site_code) reference_2,
TO_CHAR (jrt.receipt_num) reference_3, NULL reference_4,
gjl.description, gjh.doc_sequence_value jv_no,
TO_CHAR (aps.vendor_name) supplier,
TO_CHAR (assa.vendor_site_code) site, TO_CHAR (jrt.receipt_num) grn_no
FROM apps.gl_je_headers gjh,
apps.gl_je_lines gjl,
apps.jai_rgm_trx_records rtr,
apps.jai_rcv_transactions jrt,
apps.rcv_shipment_headers rsh,
apps.ap_suppliers aps,
apps.ap_supplier_sites_all assa
WHERE gjh.je_header_id = gjl.je_header_id
AND gjh.je_source = 'Purchasing India'
AND gjl.reference_2 = 'India Localization Entry'
AND gjl.reference_5 = 'repository_id'
AND TO_CHAR (rtr.repository_id) = gjl.reference_6
AND rtr.source_document_id = jrt.transaction_id(+)
AND jrt.shipment_header_id = rsh.shipment_header_id(+)
AND rsh.vendor_id = aps.vendor_id(+)
AND rsh.vendor_site_id = assa.vendor_site_id(+)
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
------Purchasing India(Accounting of India Localization of PO Receipts) Reference_6
-----
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, TO_CHAR (aps.vendor_name) reference_1,
NULL "Party Bill No", dnlcust.get_acc (gjl.code_combination_id)
gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
TO_CHAR (assa.vendor_site_code) reference_2,
TO_CHAR (jrt.receipt_num) reference_3, NULL reference_4,
gjl.description, gjh.doc_sequence_value jv_no,
TO_CHAR (aps.vendor_name) supplier,
TO_CHAR (assa.vendor_site_code) site, TO_CHAR (jrt.receipt_num) grn_no
FROM apps.gl_je_headers gjh,
apps.gl_je_lines gjl,
apps.jai_rcv_transactions jrt,
apps.rcv_shipment_headers rsh,
apps.ap_suppliers aps,
apps.ap_supplier_sites_all assa
WHERE gjh.je_header_id = gjl.je_header_id
AND gjh.je_source = 'Purchasing India'
AND gjl.reference_2 = 'India Localization Entry'
AND gjl.reference_5 = 'transaction_id'
AND TO_CHAR(jrt.transaction_id) = gjl.reference_6
AND jrt.shipment_header_id = rsh.shipment_header_id(+)
AND rsh.vendor_id = aps.vendor_id(+)
AND rsh.vendor_site_id = assa.vendor_site_id(+)
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
------Inventory(Receiving)------
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, TO_CHAR (aps.vendor_name) reference_1,
NULL "Party Bill No", dnlcust.get_acc (gjl.code_combination_id)
gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
TO_CHAR (assa.vendor_site_code) reference_2,
TO_CHAR (rsh.receipt_num) reference_3, NULL reference_4,
gjl.description, gjh.doc_sequence_value jv_no,
TO_CHAR (aps.vendor_name) supplier,
TO_CHAR (assa.vendor_site_code) site, TO_CHAR (rsh.receipt_num) grn_no
FROM apps.gmf_rcv_accounting_txns rat,
apps.rcv_transactions rt,
apps.rcv_shipment_headers rsh,
xla.xla_transaction_entities xte,
apps.xla_events xev,
apps.xla_ae_headers xah,
apps.xla_ae_lines xal,
apps.gl_import_references gir,
apps.gl_je_headers gjh,
apps.gl_je_lines gjl,
apps.ap_suppliers aps,
apps.ap_supplier_sites_all assa
WHERE to_char(rat.accounting_txn_id) = xte.source_id_int_1
AND xev.entity_id = xte.entity_id
AND xah.entity_id = xte.entity_id
AND xah.event_id = xev.event_id
AND xah.ae_header_id = xal.ae_header_id
AND xah.je_category_name = 'Receiving'
AND gjh.je_source = 'Inventory'
AND xal.gl_sl_link_id = gir.gl_sl_link_id
AND gir.gl_sl_link_id = gjl.gl_sl_link_id
AND gir.gl_sl_link_table = xal.gl_sl_link_table
AND gjl.je_header_id = gjh.je_header_id
AND gjl.ledger_id = gjh.ledger_id
AND xah.ledger_id = gjh.ledger_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 rat.rcv_transaction_id = rt.transaction_id(+)
AND rsh.shipment_header_id(+) = rt.shipment_header_id
AND rsh.vendor_id = aps.vendor_id(+)
AND rsh.vendor_site_id = assa.vendor_site_id(+)
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
------Inventory(CLOS, SHIP, Miscellaneous Transaction, RCPT, RELE, INTE, OMSP,
XFER, STEP)------
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, NULL reference_1, NULL "Party Bill No",
dnlcust.get_acc (gjl.code_combination_id) gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
NULL reference_2, TO_CHAR(MMT.TRANSACTION_ID) reference_3, NULL reference_4,
gjl.description,
gjh.doc_sequence_value jv_no, TO_CHAR (OOD.ORGANIZATION_NAME) supplier, NULL
site, NULL grn_no
FROM apps.mtl_material_transactions mmt,
apps.org_organization_definitions ood,
xla.xla_transaction_entities xte,
apps.xla_events xev,
apps.xla_ae_headers xah,
apps.xla_ae_lines xal,
apps.gl_import_references gir,
apps.gl_je_headers gjh,
apps.gl_je_lines gjl
WHERE to_char(mmt.TRANSACTION_ID) = xte.source_id_int_1
AND xev.entity_id = xte.entity_id
AND xah.entity_id = xte.entity_id
AND xah.event_id = xev.event_id
AND xah.ae_header_id = xal.ae_header_id
AND xah.je_category_name <> 'Receiving'
AND gjh.je_source = 'Inventory'
AND xal.gl_sl_link_id = gir.gl_sl_link_id
AND gir.gl_sl_link_id = gjl.gl_sl_link_id
AND gir.gl_sl_link_table = xal.gl_sl_link_table
AND gjl.je_header_id = gjh.je_header_id
AND gjl.ledger_id = gjh.ledger_id
AND xah.ledger_id = gjh.ledger_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 mmt.ORGANIZATION_ID = ood.ORGANIZATION_ID(+)
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
-----Service Tax India(Register India--> Reference_4:
AP_INVOICE_DISTRIBUTIONS_ALL)----------
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, NULL reference_1,
(SELECT TO_CHAR(INVOICE_NUM) FROM apps.AP_INVOICES_ALL WHERE
INVOICE_ID=AIA.INVOICE_ID) "Party Bill No",
dnlcust.get_acc (gjl.code_combination_id) gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
NULL reference_2, NULL reference_3, NULL reference_4, gjl.description,
gjh.doc_sequence_value jv_no, TO_CHAR (aps.VENDOR_NAME ) supplier, TO_CHAR
(assa.vendor_site_code) site, NULL grn_no
FROM apps.gl_je_headers gjh,
apps.gl_je_lines gjl,
apps.AP_INVOICE_DISTRIBUTIONS_ALL AID,
apps.AP_INVOICES_ALL AIA,
apps.ap_suppliers aps,
apps.ap_supplier_sites_all assa
WHERE gjh.je_header_id = gjl.je_header_id
AND gjh.je_source = 'Service Tax India'
AND gjl.reference_2 = 'India Localization Entry'
AND gjl.REFERENCE_4 = 'AP_INVOICE_DISTRIBUTIONS_ALL'
AND TO_CHAR (AID.INVOICE_DISTRIBUTION_ID) = gjl.reference_5
AND AID.INVOICE_ID = AIA.INVOICE_ID(+)
AND AIA.VENDOR_ID = aps.VENDOR_ID(+)
AND AIA.VENDOR_SITE_ID = assa.VENDOR_SITE_ID(+)
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
-----Service Tax India(Register India--> Reference_4:
AP_INVOICE_PAYMENTS_ALL)----------
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, NULL reference_1,
(SELECT TO_CHAR(INVOICE_NUM) FROM apps.AP_INVOICES_ALL WHERE
INVOICE_ID=AIP.INVOICE_ID) "Party Bill No",
dnlcust.get_acc (gjl.code_combination_id) gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
NULL reference_2, NULL reference_3, NULL reference_4, gjl.description,
gjh.doc_sequence_value jv_no, TO_CHAR (APC.VENDOR_NAME) supplier, TO_CHAR
(APC.VENDOR_SITE_CODE) site, NULL grn_no
FROM apps.gl_je_headers gjh,
apps.gl_je_lines gjl,
apps.AP_INVOICE_PAYMENTS_ALL AIP,
apps.AP_CHECKS_ALL APC
WHERE gjh.je_header_id = gjl.je_header_id
AND gjh.je_source = 'Service Tax India'
AND gjl.reference_2 = 'India Localization Entry'
AND gjl.REFERENCE_4 = 'AP_INVOICE_PAYMENTS_ALL'
AND TO_CHAR (AIP.INVOICE_PAYMENT_ID) = gjl.reference_5
AND AIP.CHECK_ID = APC.CHECK_ID(+)
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
-----Service Tax India(Register India--> Reference_4: JAI_MAN_TRXS)----------
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, NULL reference_1,
TO_CHAR(JMT.INVOICE_NUMBER) "Party Bill No",
dnlcust.get_acc (gjl.code_combination_id) gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
NULL reference_2, NULL reference_3, NULL reference_4, gjl.description,
gjh.doc_sequence_value jv_no, TO_CHAR (aps.VENDOR_NAME) supplier, NULL site,
NULL grn_no
FROM apps.gl_je_headers gjh,
apps.gl_je_lines gjl,
apps.JAI_RGM_MANUAL_TRXS JMT,
apps.ap_suppliers aps
WHERE gjh.je_header_id = gjl.je_header_id
AND gjh.je_source = 'Service Tax India'
AND gjl.reference_2 = 'India Localization Entry'
AND gjl.REFERENCE_4 = 'JAI_MAN_TRXS'
AND TO_CHAR (JMT.TRANSACTION_NUMBER) = gjl.reference_5
AND JMT.PARTY_ID = aps.VENDOR_ID(+)
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
-----Service Tax India(Register India--> Reference_4:
JAI_RGM_DIS_DES_TAXS)----------
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, NULL reference_1, NULL "Party Bill No",
dnlcust.get_acc (gjl.code_combination_id) gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
NULL reference_2, NULL reference_3, NULL reference_4, gjl.description,
gjh.doc_sequence_value jv_no, NULL supplier, NULL site, NULL grn_no
FROM apps.gl_je_headers gjh,
apps.gl_je_lines gjl
WHERE gjh.je_header_id = gjl.je_header_id
AND gjh.je_source = 'Service Tax India'
AND gjl.reference_2 = 'India Localization Entry'
AND gjl.REFERENCE_4 = 'JAI_RGM_DIS_DES_TAXS'
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
-----Receivables, Cash Management, Assets, Consolidation, TCS Entry, Project
Accounting, 21, Purchasing, OM, Payables India, MassAllocation, Recurring, PUR,
Receivables India, Gemloc, Manual, Service Tax India, CM, PM, Budget Journal, IC,
Spreadsheet, Revaluation, Register India, VAT India----
UNION ALL
SELECT TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, NULL reference_1, NULL "Party Bill No",
dnlcust.get_acc (gjl.code_combination_id) gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
NULL reference_2, NULL reference_3, NULL reference_4, gjl.description,
gjh.doc_sequence_value jv_no, NULL supplier, NULL site, NULL grn_no
FROM apps.gl_je_lines gjl, apps.gl_je_headers gjh
WHERE gjl.je_header_id = gjh.je_header_id
AND gjh.je_source IN
('Receivables','Cash Management','Assets','Consolidation', 'TCS Entry',
'Project Accounting', '21',
'Purchasing', 'OM', 'Payables India', 'MassAllocation',
'Recurring', 'PUR', 'Receivables India', 'Gemloc', 'Manual',
'CM', 'PM', 'Budget Journal', 'IC',
'Spreadsheet', 'Revaluation', 'Register India', 'VAT India')
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')
union all
select
TO_CHAR (gjl.effective_date, 'YYYY/MM') MONTH, gjl.period_name,
gjh.je_category, gjh.je_source, ORGANIZATION_NAME
reference_1,to_char(TRX_NUMBER),
dnlcust.get_acc (gjl.code_combination_id) gl_code,
gjl.accounted_dr debit, gjl.accounted_cr credit, gjl.effective_date,
to_char(TRX_DATE) reference_2, to_char(TRX_LINE_NUMBER) reference_3,
ENTITY_CODE reference_4, gjl.description,
gjh.doc_sequence_value jv_no, PARTY_NAME supplier, PARTY_SITE_NAME site
,(select segment1 from apps.mtl_system_items_b where organization_id=0 and
inventory_item_id=ITEM_ID)Item_no
from apps.gl_je_headers gjh,
apps.gl_je_lines gjl,apps.gl_import_references gir,apps.jai_tax_lines_v
where 1=1
AND gjh.je_header_id = gjl.je_header_id
AND gir.je_batch_id = gjh.je_batch_id
AND gir.je_header_id = gjh.je_header_id
AND gir.je_line_num = gjl.je_line_num
AND gjh.ledger_id IN (1001,3001)
-- and gjl.REFERENCE_4='15602'
and det_factor_id=gjl.REFERENCE_3
and TAX_LINE_ID=gjl.REFERENCE_4
AND gjh.ledger_id IN (1001,3001)
AND gjl.status = 'P'
AND gjh.ACTUAL_FLAG = 'A'
and JE_SOURCE='Financials India'
AND gjl.effective_date BETWEEN :from_date
AND :TO_DATE
AND dnlcust.get_gl (gjl.code_combination_id) = :p_gl_code
AND SUBSTR (dnlcust.get_acc (gjl.code_combination_id), 1, 2) = :p_ou_code
AND gjh.je_source = NVL (:p_source_code, gjh.je_source)
AND gjh.je_source <> NVL (:n_source_code, 'XXX')

You might also like