Monday, 11 July 2016

PlSql - Query to find the function name available in the active responsibility and active user which is not included in the menu exclusion list

PlSql - Query to find the function name available in the active responsibility and active user  which is not included in the menu exclusion list

SELECT frtl.responsibility_name,
       fr.responsibility_key,
       fm.menu_id,
       fm.menu_name,
       --menu.function_id,
       menu.prompt,
       fffv.user_function_name,
       fffv.function_name
       --,fffv.TYPE
  FROM (SELECT connect_by_root fmet.menu_id top_menu_id,
               fmet.menu_id                 menu_id,
               fmet.sub_menu_id,
               fmet.function_id,
               fmet.prompt
          FROM apps.fnd_menu_entries_vl fmet
        CONNECT BY PRIOR fmet.sub_menu_id = fmet.menu_id
                         AND PRIOR fmet.prompt IS NOT NULL) menu,
       apps.fnd_responsibility fr,
       apps.fnd_responsibility_tl frtl,
       apps.fnd_menus fm,
       apps.fnd_form_functions_vl fffv
 WHERE fr.menu_id = menu.top_menu_id
   AND fffv.function_id = menu.function_id
   AND fffv.TYPE <> 'SUBFUNCTION'
   AND menu.function_id IS NOT NULL
   AND menu.prompt IS NOT NULL
   AND fm.menu_id = menu.menu_id
   AND frtl.responsibility_id = fr.responsibility_id    
   AND menu.function_id NOT IN (SELECT ffvl.function_id
                                  FROM apps.fnd_resp_functions frf,
                                       applsys.fnd_responsibility_tl frt,
                                       apps.fnd_form_functions_vl ffvl
                                 WHERE
       frf.responsibility_id = frt.responsibility_id
                                   AND frf.action_id = ffvl.function_id
                                   AND frf.rule_type = 'F'
                                   AND
           frt.responsibility_name = frtl.responsibility_name)
   AND menu.menu_id NOT IN (SELECT fmv.menu_id
                              FROM apps.fnd_resp_functions frf,
                                   applsys.fnd_responsibility_tl frt,
                                   apps.fnd_menus_vl fmv
                             WHERE
       frf.responsibility_id = frt.responsibility_id
                               AND frf.action_id = fmv.menu_id
                               AND frf.rule_type = 'M'
                               AND
       frt.responsibility_name = frtl.responsibility_name)
       AND frtl.language='US'
       --AND frtl.responsibility_name='HCC PO SME'  AND fm.menu_id =78826
       AND fffv.function_name='XLA_MJE_SEARCH'  -- Function name
      and menu.function_id=25496    -- Function id
 AND fr.responsibility_id IN ( select  c.responsibility_id
     from apps.fnd_user_resp_groups_direct a,
       apps.fnd_user                    b,
       apps.fnd_responsibility_tl       c,
       apps.fnd_application_tl          d
 where a.user_id = b.user_id
   and a.responsibility_id = c.responsibility_id
   and c.application_id = d.application_id
   and (a.end_date > sysdate OR a.end_date is Null)
   and (b.end_date > sysdate OR b.end_date is Null)
   and c.language = d.language
   and c.language='US' )
and fr.responsibility_id not in (select ex.responsibility_id from fnd_resp_functions ex where ex.action_id!=25496)    -- Used for menu exclusions
 ORDER BY frtl.responsibility_name,fffv.user_function_name;

No comments:

Post a Comment