Friday, 27 January 2012

gl_drill_down_to_ap_invoice_liablity_account

select distinct
         AIA.invoice_id,
--         AIA.ORG_ID,
         aia.DOC_SEQUENCE_VALUE,
         aia.invoice_num,
--         aia.gl_date,
         aia.INVOICE_AMOUNT,
         jl.ACCOUNTED_CR,
         jl.ACCOUNTED_DR,
--         jl.JE_LINE_NUM,
         jb.JE_BATCH_ID ,
         jl.JE_HEADER_ID,
          Gcc.SEGMENT1
         || '.'
         || Gcc.SEGMENT2
         || '.'
         || Gcc.SEGMENT3   --  -1545500    3835344   adv
         || '.'
         || Gcc.SEGMENT4
         || '.'
         || Gcc.SEGMENT5
         || '.'
         || Gcc.SEGMENT6
         || '.'
         || Gcc.SEGMENT7
            "CODE_COMBINATION"
            from gl_je_headers jh,gl_je_lines jl,gl_code_combinations Gcc,
            gl_import_references GIr,gl_je_batches jb ,ap_invoices_all AIA
where  jl.je_header_id = jh.je_header_id
and AIA.ACCTS_PAY_CODE_COMBINATION_ID = GCC.CODE_COMBINATION_ID
and AIA.INVOICE_ID = gir.REFERENCE_2
and aia.DOC_SEQUENCE_VALUE = gir.SUBLEDGER_DOC_SEQUENCE_VALUE
AND jl.code_combination_id = Gcc.code_combination_id
AND jh.je_header_id = GIr.je_header_id
AND jl.je_line_num = GIr.je_line_num
AND jl.je_header_id = GIr.je_header_id
AND jb.je_batch_id = jh.je_batch_id
and gir.JE_BATCH_ID = jb.JE_BATCH_ID
AND JH.JE_SOURCE = 'Payables'
AND JH.je_category = 'Purchase Invoices'
--and JH.PERIOD_NAME = 'APR-11'
AND GCC.SEGMENT1 = '41'
AND GCC.SEGMENT3 = '373100'
--and jh.je_header_id =2404071
and jl.SET_OF_BOOKS_ID = 5

No comments:

Post a Comment