Wednesday, January 8, 2025

Query to get Parent and Child Accounts in Oracle APPS R12

SELECT ffv1.flex_value parent_account
      ,ffvt1.description parent_account_desc
  ,ffv2.flex_value child_account
  ,ffvt2.description child_account_desc
  FROM fnd_flex_values_tl ffvt2
      ,fnd_flex_values ffv2
      ,fnd_flex_value_hierarchies ffvh
      ,fnd_flex_values_tl ffvt1
      ,fnd_flex_values ffv1
      ,fnd_id_flex_segments fifs
 WHERE fifs.application_id = 101
   AND fifs.id_flex_code = 'GL#'
   AND fifs.id_flex_num = 101
   AND fifs.application_column_name = 'SEGMENT4'
   AND fifs.enabled_flag = 'Y'
   AND ffv1.enabled_flag = 'Y'
   AND ffv1.summary_flag = 'Y'
   AND ffv1.flex_value != 'T'
   AND ffv1.flex_value_set_id = fifs.flex_value_set_id + 0
   AND NVL (TO_CHAR (ffv1.start_date_active, 'YYYY/MM/DD'), '0000/00/00') <= TO_CHAR (SYSDATE, 'YYYY/MM/DD')
   AND NVL (TO_CHAR (ffv1.end_date_active, 'YYYY/MM/DD'), '9999/99/99') >= TO_CHAR (SYSDATE, 'YYYY/MM/DD')
   AND ffvt1.flex_value_id = ffv1.flex_value_id + 0
   AND ffvt1.language = USERENV ('LANG')
   AND ffvh.flex_value_set_id = fifs.flex_value_set_id + 0
   AND ffvh.parent_flex_value = ffv1.flex_value
   AND ffv2.summary_flag = 'N'
   AND NVL (TO_CHAR (ffv2.start_date_active, 'YYYY/MM/DD'), '0000/00/00') <= TO_CHAR (SYSDATE, 'YYYY/MM/DD')
   AND NVL (TO_CHAR (ffv2.end_date_active, 'YYYY/MM/DD'), '9999/99/99') >= TO_CHAR (SYSDATE, 'YYYY/MM/DD')
   AND ffv2.flex_value_set_id + 0 = fifs.flex_value_set_id + 0
   AND ffv2.flex_value BETWEEN ffvh.child_flex_value_low AND ffvh.child_flex_value_high
   AND ffv2.enabled_flag = 'Y'
   AND ffvt2.flex_value_id = ffv2.flex_value_id + 0
   AND ffvt2.language = USERENV ('LANG')
ORDER BY ffv1.flex_value, ffv2.flex_value

No comments:

Post a Comment

Query to get Parent and Child Accounts in Oracle APPS R12

SELECT ffv1.flex_value parent_account       ,ffvt1.description parent_account_desc   ,ffv2.flex_value child_account   ,ffvt2.description...