Monday, April 12, 2010

Key Flex Field Structures & How to Retrieve Information about segments based on code combination id

-- How to fetch meanings of each segment related to a code combination id?

Guys, Here I tried to fetch the details like description, meaning, id and value related to each segment based on code combination id. During the course I came across many tables related to KEY FLEXIFIELDS like below

Tables related to Flexi fields:


Below are queries used by me to reach out the main query..


 The table (fnd_id_flexs) used in the below query stores registration information about key flexfields.
 Each row includes the four–character code that identifies the key flexfield and can be used to dig further
 The "id_flex_code" is the column which can be used to dig further

SELECT application_table_name
      ,DECODE (application_table_type,
              ) table_type
      ,id_flex_code  -- Used to drill down
FROM   fnd_id_flexs
WHERE id_flex_name LIKE 'Accounting%';


The below query gives information about the segment meanings
We got this data by using the value we got for "id_flex_code"  in query 1

SELECT segment_name
      ,flex_value_set_id  -- Used to drill down
FROM  fnd_id_flex_segments
WHERE id_flex_code = 'GL#';

This query can be used to get various possible values for each segment.

SELECT ffv.flex_value_set_id
FROM   fnd_flex_values ffv
      ,fnd_flex_values_tl ffvt
WHERE  ffv.flex_value_id = ffvt.flex_value_id
AND    ffv.flex_value_set_id = '&id from query 2';

Main Query
 Below is our highlight and it can be used to get all possible information based on code combination id
 I had simplified the same. The decode statement differs from client to client. But it can be framed with use of query 2

SELECT fifs.segment_name
FROM  fnd_flex_values ffv
     ,fnd_flex_values_tl ffvt
     ,fnd_id_flex_segments fifs
     ,gl_code_combinations glv
WHERE ffv.flex_value_id = ffvt.flex_value_id
AND   ffv.flex_value_set_id = fifs.flex_value_set_id
AND   fifs.id_flex_code = 'GL#'
AND   ffv.flex_value    = DECODE(fifs.segment_name
                                ,'BUSINESS UNIT',glv.segment1
                                ,'LOCATION'     ,glv.segment2
                                ,'DEPARTMENT'   ,glv.segment3
                                ,'ACCOUNT'      ,glv.segment4
                                ,'PROJECT'      ,glv.segment5
                                ,'INTERCOMPANY' ,glv.segment6
                                ,'SPARE'        ,glv.segment7
AND  glv.code_combination_id = '&code_combination_id'
ORDER BY ffv.flex_value_set_id;

0 Responses to “Key Flex Field Structures & How to Retrieve Information about segments based on code combination id”

Post a Comment


The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.