SELECT jrmt.transaction_number, jrmt.regime_code, jrmt.transaction_type_code,
jrmt.transaction_date, jrmt.remarks, fu.description, gjl.accounted_dr,
gjl.accounted_cr , gjh.je_source, gjh.je_category
FROM apps.gl_je_headers gjh,
apps.gl_je_lines gjl,
apps.gl_je_batches gjb,
apps.gl_import_references gir,
apps.gl_code_combinations_kfv gcc,
apps.jai_rgm_manual_trxs jrmt,
apps.fnd_user fu
WHERE gjh.je_header_id = gjl.je_header_id
AND gjl.code_combination_id = gcc.code_combination_id
AND gir.je_header_id = gjl.je_header_id
AND gir.je_line_num = gjl.je_line_num
AND gjb.je_batch_id = gir.je_batch_id
AND gjh.je_source IN ('Service Tax India','VAT India')
AND jrmt.transaction_number = gjl.reference_5
AND fu.user_id = jrmt.created_by
AND gjl.period_name in (select distinct period_name from apps.gl_periods where start_date between :p_from_per and :p_to_per)
AND gcc.segment4 in (3021000, 3021100)--, 3021700, 3023000, 3023100)
AND gcc.segment3 in (100603)
AND gcc.segment2 not in (102)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SELECT msib.segment1 item, mp.organization_code, pv.vendor_name,
jcrt.excise_invoice_no, jcrt.excise_invoice_date, jcrt.register_type,
jcrt.remarks, jcrt.transaction_date, gjl.accounted_dr,
gjl.accounted_cr , gjh.je_source, gjh.je_category
FROM apps.gl_je_headers gjh,
apps.gl_je_lines gjl,
apps.gl_je_batches gjb,
apps.gl_import_references gir,
apps.gl_code_combinations_kfv gcc,
apps.jai_cmn_rg_23ac_ii_trxs jcrt,
apps.mtl_system_items_b msib,
apps.mtl_parameters mp,
apps.po_vendors pv
WHERE gjh.je_header_id = gjl.je_header_id
AND gjl.code_combination_id = gcc.code_combination_id
AND gir.je_header_id = gjl.je_header_id
AND gir.je_line_num = gjl.je_line_num
AND gjb.je_batch_id = gir.je_batch_id
AND gjh.je_source = 'Register India'
AND TO_CHAR (jcrt.register_id) = gjl.reference_5
AND msib.inventory_item_id = jcrt.inventory_item_id
AND msib.organization_id = jcrt.organization_id
AND mp.organization_id = jcrt.organization_id
AND pv.vendor_id = jcrt.vendor_id
AND gjl.period_name in (select distinct period_name from apps.gl_periods where start_date between :p_from_per and :p_to_per)
AND gcc.segment4 in (3021000, 3021100)--, 3021700, 3023000, 3023100)
AND gcc.segment3 in (100603)
AND gcc.segment2 not in (102)
UNION ALL
SELECT msib.segment1, mp.organization_code, pv.vendor_name,
jcrt.excise_invoice_no, jcrt.excise_invoice_date, jcrt.register_type,
jcrt.remarks, jcrt.transaction_date, gjl.accounted_dr,
gjl.accounted_cr, gjh.je_source, gjh.je_category
FROM apps.gl_je_headers gjh,
apps.gl_je_lines gjl,
apps.gl_je_batches gjb,
apps.gl_import_references gir,
apps.gl_code_combinations_kfv gcc,
apps.jai_cmn_rg_23ac_ii_trxs jcrt,
apps.mtl_system_items_b msib,
apps.mtl_parameters mp,
apps.po_vendors pv
WHERE gjh.je_header_id = gjl.je_header_id
AND gjl.code_combination_id = gcc.code_combination_id
AND gir.je_header_id = gjl.je_header_id
AND gir.je_line_num = gjl.je_line_num
AND gjb.je_batch_id = gir.je_batch_id
AND gjh.je_source = 'Register India'
AND TO_CHAR (jcrt.register_id) = gjl.reference_6
AND msib.inventory_item_id = jcrt.inventory_item_id
AND msib.organization_id = jcrt.organization_id
AND mp.organization_id = jcrt.organization_id
AND pv.vendor_id = jcrt.vendor_id
AND gjl.period_name in (select distinct period_name from apps.gl_periods where start_date between :p_from_per and :p_to_per)
AND gcc.segment4 in (3021000, 3021100)--, 3021700, 3023000, 3023100)
AND gcc.segment3 in (100603)
AND gcc.segment2 not in (102)