Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

--Query to get Asset to XLA to GL Link (Depreciation)

SELECT GLCC.concatenated_segments segments


,GJL.period_name
,GJH.name journal_name
,GJB.name batch_name
,GJH.je_source journal_source
,GJH.je_category journal_category
,GLCC.segment1 entity_segment
,GLCC.segment2 project_segment
,FFV.attribute1 project_vertical_dff
,GLCC.segment3
,GLCC.segment4
,GLCC.segment5
,GLCC.segment6
,GLCC.segment7
,TO_CHAR (GJH.doc_sequence_value) gl_doc_no
,TO_CHAR (GJH.default_effective_date, 'DD-MON-YYYY') gl_date
,TO_CHAR (GJH.posted_date, 'DD-MON-YYYY') posted_date
,(SELECT NAME
FROM xla_event_classes_tl XECT
WHERE XECT.event_class_code = XDL.event_class_code
AND XECT.application_id = XDL.application_id)
sla_event_class
,XAH.event_type_code sla_event_type
,TO_CHAR(FDS.asset_id) document_number
,FAD.description document_description
,TO_CHAR (FB.date_placed_in_service, 'DD-MON-YYYY')
document_date
,NVL((XDL.unrounded_accounted_cr)*-1,
(XDL.unrounded_accounted_dr)) transaction_cur_amount
,GL.currency_code entered_currency_code
,NVL((XDL.unrounded_accounted_cr)*-1,
(XDL.unrounded_accounted_dr)) functional_currency_amount
FROM fa_additions FAD
,fa_books FB
,fa_book_controls FBC
,fa_deprn_summary FDS
,xla_distribution_links XDL
,xla_ae_lines XAL
,xla_ae_headers XAH
,gl_import_references GIR
,gl_je_lines GJL
,gl_je_headers GJH
,gl_je_batches GJB
,gl_code_combinations_kfv GLCC
,gl_ledgers GL
,fnd_flex_value_sets FVS
,fnd_flex_values FFV
WHERE 1=1
AND FAD.asset_id = FB.asset_id
AND FB.book_type_code = FBC.book_type_code
AND FB.DATE_INEFFECTIVE IS NULL
AND FAD.asset_id = FDS.asset_id
AND FB.book_type_code = FDS.book_type_code
AND FBC.book_type_code = FDS.book_type_code
AND fds.deprn_source_code ='DEPRN'
AND fds.period_counter = (select period_counter from fa_deprn_periods where
period_name =GJH.period_name and book_type_code=fb.book_type_code )
AND FDS.asset_id =
XDL.source_distribution_id_num_1
AND FB.book_type_code = XDL.source_distribution_id_char_4
AND FBC.set_of_books_id = GL.ledger_id
AND XDL.ae_header_id = XAL.ae_header_id
AND XDL.ae_line_num = XAL.ae_line_num
AND XAL.ae_header_id = XAH.ae_header_id
AND XAH.application_id = XAL.application_id
AND XAL.gl_sl_link_id = GIR.gl_sl_link_id
AND XAL.gl_sl_link_table = GIR.gl_sl_link_table
AND GIR.je_line_num = GJL.je_line_num
AND GIR.je_header_id = GJL.je_header_id
AND GIR.je_header_id = GJH.je_header_id
AND GJH.je_batch_id = GJB.je_batch_id
AND GJL.code_combination_id = GLCC.code_combination_id
AND GJH.status = 'P'
-- and UPPER(XDL.rounding_class_code) ='ASSET'
AND UPPER(FDS.deprn_source_code) IN ('BOOKS','DEPRN')
AND UPPER (GJH.je_source) = 'ASSETS'
AND UPPER (GJH.je_category) = 'DEPRECIATION'
AND FFV.flex_value_set_id = FVS.flex_value_set_id(+)
AND GLCC.segment2 = FFV.flex_value(+)
AND UPPER (FVS.flex_value_set_name) = UPPER ('PLL_Project')
AND GJH.default_effective_date >= lc_gl_date_from
AND GJH.default_effective_date <= lc_gl_date_to
AND TRUNC (GJH.posted_date) BETWEEN NVL (lc_gl_posted_from,TRUNC
(GJH.posted_date))AND NVL (lc_gl_posted_to,TRUNC (GJH.posted_date))
AND GJH.je_source = NVL (p_gl_source, GJH.je_source)
AND GJH.je_category = NVL (p_gl_category, GJH.je_category)
AND GLCC.segment1 BETWEEN lc_segment_from(1) AND lc_segment_to(1)
AND GLCC.segment2 BETWEEN lc_segment_from(2) AND lc_segment_to(2)
AND GLCC.segment3 BETWEEN lc_segment_from(3) AND lc_segment_to(3)
AND GLCC.segment4 BETWEEN lc_segment_from(4) AND lc_segment_to(4)
AND GLCC.segment5 BETWEEN lc_segment_from(5) AND lc_segment_to(5)
AND GLCC.segment6 BETWEEN lc_segment_from(6) AND lc_segment_to(6)
AND GLCC.segment7 BETWEEN lc_segment_from(7) AND lc_segment_to(7)

AND NVL (FFV.attribute1, '-1') = NVL (p_proj_vertical_dff, NVL


(FFV.attribute1, '-1'))

You might also like