Pages

Friday, January 31, 2014

GL Query for Cost Management(source) - Inventory(category)

SELECT msib.segment1, msib.description, mtt.transaction_type_name,
       xal.accounting_class_code, xal.accounted_dr, xal.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,
       xla.xla_ae_lines xal,
       xla.xla_ae_headers xah,
       xla.xla_transaction_entities xte,
       apps.mtl_material_transactions mmt,
       apps.mtl_system_items_b msib,
       apps.gl_code_combinations_kfv gcc,
       apps.mtl_parameters mp,
       apps.mtl_transaction_types mtt
 WHERE gjh.je_header_id = gjl.je_header_id
   AND gjh.je_header_id = gir.je_header_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 gjl.period_name = 'AUG-12-13'
   AND gir.gl_sl_link_id = xal.gl_sl_link_id
   AND xal.ae_header_id = xah.ae_header_id
   AND xal.application_id = '707'
   AND xah.application_id = '707'
   AND xte.application_id = '707'
   AND xah.entity_id = xte.entity_id
   AND xte.source_id_int_1 = mmt.transaction_id
--   AND xte.entity_code = 'MTL_ACCOUNTING_EVENTS'
   AND mtt.transaction_type_id = mmt.transaction_type_id
   AND mmt.inventory_item_id = msib.inventory_item_id
   AND mmt.organization_id = msib.organization_id
   AND mp.organization_id = mmt.organization_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)
--   AND TRUNC (xal.accounting_date) BETWEEN '01-APR-2012' AND '31-MAR-2013'
   AND gjl.code_combination_id = gcc.code_combination_id
--   AND gcc.segment4 = '3021000'

No comments:

Post a Comment