Monday, 11 July 2011

Query to find accounting flexfield structure

    select sob.name Ledger_Name
    , sob.ledger_id Ledger_Id
    , sob.chart_of_accounts_id coa_id
   , fifst.id_flex_structure_name struct_name
    , ifs.segment_name
    , ifs.application_column_name column_name
   , sav1.attribute_value BALANCING
    , sav2.attribute_value COST_CENTER
    , sav3.attribute_value NATURAL_ACCOUNT
    , sav4.attribute_value INTERCOMPANY
    , sav5.attribute_value SECONDARY_TRACKING
    , sav6.attribute_value GLOBAL
    , ffvs.flex_value_set_name
    , ffvs.flex_value_set_id
    from fnd_id_flex_structures fifs
    , fnd_id_flex_structures_tl fifst
    , fnd_segment_attribute_values sav1
    , fnd_segment_attribute_values sav2
    , fnd_segment_attribute_values sav3
    , fnd_segment_attribute_values sav4
    , fnd_segment_attribute_values sav5
    , fnd_segment_attribute_values sav6
    , fnd_id_flex_segments ifs
    , fnd_flex_value_sets ffvs
    , gl_ledgers sob
    where 1=1
    and fifs.id_flex_code = 'GL#'
    and fifs.application_id = fifst.application_id
    and fifs.id_flex_code = fifst.id_flex_code
    and fifs.id_flex_num = fifst.id_flex_num
    and fifs.application_id = ifs.application_id
    and fifs.id_flex_code = ifs.id_flex_code
    and fifs.id_flex_num = ifs.id_flex_num
    and sav1.application_id = ifs.application_id
    and sav1.id_flex_code = ifs.id_flex_code
    and sav1.id_flex_num = ifs.id_flex_num
    and sav1.application_column_name = ifs.application_column_name
    and sav2.application_id = ifs.application_id
    and sav2.id_flex_code = ifs.id_flex_code
    and sav2.id_flex_num = ifs.id_flex_num
    and sav2.application_column_name = ifs.application_column_name
    and sav3.application_id = ifs.application_id
    and sav3.id_flex_code = ifs.id_flex_code
    and sav3.id_flex_num = ifs.id_flex_num
   and sav3.application_column_name = ifs.application_column_name
    and sav4.application_id = ifs.application_id
    and sav4.id_flex_code = ifs.id_flex_code
    and sav4.id_flex_num = ifs.id_flex_num
    and sav4.application_column_name = ifs.application_column_name
    and sav5.application_id = ifs.application_id
    and sav5.id_flex_code = ifs.id_flex_code
    and sav5.id_flex_num = ifs.id_flex_num
    and sav5.application_column_name = ifs.application_column_name
    and sav6.application_id = ifs.application_id
    and sav6.id_flex_code = ifs.id_flex_code
    and sav6.id_flex_num = ifs.id_flex_num
    and sav6.application_column_name = ifs.application_column_name
    and sav1.segment_attribute_type = 'GL_BALANCING'
    and sav2.segment_attribute_type = 'FA_COST_CTR'
    and sav3.segment_attribute_type = 'GL_ACCOUNT'
    and sav4.segment_attribute_type = 'GL_INTERCOMPANY'
    and sav5.segment_attribute_type = 'GL_SECONDARY_TRACKING'
    and sav6.segment_attribute_type = 'GL_GLOBAL'
    and ifs.id_flex_num = sob.chart_of_accounts_id
    and ifs.flex_value_set_id = ffvs.flex_value_set_id
    and sob.ledger_id =
    nvl(fnd_profile.value('GL_SET_OF_BKS_ID'),sob.ledger_id)
    order by sob.name, sob.chart_of_accounts_id, ifs.application_column_name;

No comments:

Post a Comment