Pages

Friday, January 31, 2014

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

SELECT   distinct
         gjh.je_source                  as sour
       , gjh.je_category                as categ
       , gjh.doc_sequence_value         as doc
       , gjh.period_name                as period
       , trunc(mmt.transaction_date)    as trans_date
       , msi.segment1                   as item
       , REGEXP_REPLACE (msi.description,
       '([^[:alnum:]])', ' ')           as item_dec
       , mmt.primary_quantity           as qty
--       , xal.accounted_dr, xal.accounted_cr
       , (mta.base_transaction_value)     as amt
       , gcc.segment2                   as activity
       , gcc.segment3                   as dept
       , ffvv.description               as des
       , gcc.segment4                   as acc_code
       , mmt.organization_id            as org
       , mtt.transaction_type_name      as type_name
       , mtt.transaction_type_id        as type_id
       , mmt.transaction_source_id
       , mmt.trx_source_line_id
       , mmt.transaction_id
 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.gl_code_combinations_kfv gcc
      , apps.wip_transactions wt
      , apps.eam_work_orders_v ewov
      , apps.wip_entities we
      , apps.mtl_parameters mp
      , apps.mtl_material_transactions mmt
      , apps.mtl_system_items msi
      , apps.mtl_transaction_accounts mta
      , apps.mtl_transaction_types mtt
      , apps.fnd_flex_values_vl ffvv
WHERE 1=1
    and 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 gjh.je_source = 'Cost Management'
    and gjh.je_category = 'WIP'
    and gir.gl_sl_link_id = xal.gl_sl_link_id
    and xal.ae_header_id = xah.ae_header_id
    and gjl.code_combination_id = gcc.code_combination_id
    and xah.entity_id = xte.entity_id
    and xte.source_id_int_1 = wt.transaction_id
    and ewov.wip_entity_id = wt.wip_entity_id
    and wt.wip_entity_id  = we.wip_entity_id
    and ewov.organization_id = mp.organization_id
    and wt.wip_entity_id = mmt.transaction_source_id
    and mmt.inventory_item_id = msi.inventory_item_id
    and mmt.organization_id = msi.organization_id
    and mmt.transaction_id = mta.transaction_id
    and mmt.transaction_type_id = mtt.transaction_type_id
    and ffvv.flex_value = gcc.segment3
    and ffvv.compiled_value_attributes is not null
    and gcc.segment4 in (3021000, 3021100)--, 3021700, 3023000, 3023100)
    and gcc.segment3 in (100603)
    and gcc.segment2 not in (102)
    and to_char(mmt.transaction_date, 'MON-YYYY') between to_char(:p_from_per, 'MON-YYYY') and to_char(:p_to_per, 'MON-YYYY')
    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 msi.segment1 = :p_s

No comments:

Post a Comment