Tuesday, October 8, 2013

Key segments value set details (Values/Effective/Hierarchy/Qualifiers)

-----------------------------------------
select ffvs.flex_value_set_name
        ,ffv.flex_value
        ,ffvt.description
        ,ffv.start_date_active
        ,ffv.end_date_active
        ,decode(ffv.enabled_flag,'N','No','Yes') enabled
        ,decode(ffv.summary_flag,'N','No','Yes') parent
        ,ffhv.hierarchy_code rollup_group
        -- Qualifiers
        ,decode(substr(to_char(ffv.compiled_value_attributes),1,1),'N','No','Yes') budgeting_allowed
        ,decode(substr(to_char(ffv.compiled_value_attributes),3,1),'N','No','Yes') posting_allowed
        ,(select acct_type_desc2
            from gl_acct_typ gat
           where gat.acct_type_code = substr(to_char(ffv.compiled_value_attributes),5,1) ) account_type
        ,decode(substr(to_char(ffv.compiled_value_attributes),7,1),'N','No','Yes') third_party_control
        ,decode(substr(to_char(ffv.compiled_value_attributes),9,1),'N','No','Yes') reconcile
 from fnd_flex_values ffv
        ,fnd_flex_values_tl ffvt
        ,fnd_flex_value_sets ffvs
        ,fnd_id_flex_segments fifs
        ,fnd_flex_hierarchies_vl ffhv
where ffv.flex_value_id = ffvt.flex_value_id
    and ffv.flex_value_set_id = ffvs.flex_value_set_id
    and fifs.flex_value_set_id = ffvs.flex_value_set_id
    and ffvs.flex_value_set_name = <<'AK_Account'>>
    and fifs.id_flex_code = 'GL#'
    and ffv.structured_hierarchy_level = ffhv.hierarchy_id(+)
order by ffv.flex_value
;

------------------------------------------------