18 August, 2025

Assign responsibility to user based on program responsibility

 DECLARE
   lv_user_name        VARCHAR2 (20) := 'XXUSER';
   --lv_req_resp_key     VARCHAR2 (50) := 'APPLICATION_DEVELOPER';
   lv_description      VARCHAR2 (100) := 'Adding Responsibility to user for report testing';
   lv_req_resp_name    VARCHAR2 (200);
   lv_appl_shrt_name   VARCHAR2 (20);
   lv_appl_name        VARCHAR2 (50);
   lv_resp_key         VARCHAR2 (50);
  
BEGIN

for c_cur in (

Select RESPONSIBILITY_KEY lv_req_resp_key, 
(select application_short_name  from fnd_application_vl fav where fr.application_id = fav.application_id) lv_appl_shrt_name
From apps.fnd_Responsibility fr,
apps.fnd_responsibility_tl frt,
apps.fnd_request_groups frg,
apps.fnd_request_group_units frgu,
apps.fnd_concurrent_programs_tl fcpt
Where upper(fcpt.user_concurrent_program_name) like upper('%Aged Trial Balance with Payments%')
and request_group_name = 'XX_AR_INQ_REPORTS'
and fcpt.concurrent_program_id = frgu.request_unit_id
and frgu.request_group_id = frg.request_group_id
and frg.request_group_id = fr.request_group_id
and fr.responsibility_id = frt.responsibility_id
Order By 2
      )

      loop
   fnd_user_pkg.addresp (username         => lv_user_name,
                         resp_app         => c_cur.lv_appl_shrt_name,
                         resp_key         => c_cur.lv_req_resp_key,
                         security_group   => 'STANDARD',
                         description      => lv_description,
                         start_date       => SYSDATE,
                         end_date         => NULL
                                              );
   COMMIT;
  end loop;
   DBMS_OUTPUT.put_line ('The responsibility ' || lv_req_resp_name || ' is added to the user ' || lv_user_name);
  
EXCEPTION
   WHEN OTHERS THEN
      DBMS_OUTPUT.put_line ('Responsibility IS NOT added due to ' || SQLCODE || '; ' || SUBSTR (SQLERRM, 1, 250));
      ROLLBACK;
END;

Query to get all details of the concurrent program

 SELECT DISTINCT fcpl.user_concurrent_program_name "Concurrent Program Name",
  fcp.concurrent_program_name "Short Name"                                 ,
  fat.application_name                                                     ,
  fl.meaning execution_method                                              ,
  fe.execution_file_name                     ,
  fcp.output_file_type                                                     ,
  fdfcuv.column_seq_num "Column Seq Number"                                ,
  fdfcuv.end_user_column_name "Parameter Name"                             ,
  fdfcuv.form_left_prompt "Prompt"                                         ,
  fdfcuv.enabled_flag " Enabled Flag"                                      ,
  fdfcuv.required_flag "Required Flag"                                     ,
  fdfcuv.display_flag "Display Flag"                                       ,
  fdfcuv.flex_value_set_id "Value Set Id"                                  ,
  ffvs.flex_value_set_name "Value Set Name"                                ,
  flv.meaning "Default Type"                                               ,
  fdfcuv.default_value "Default Value"
 FROM apps.fnd_concurrent_programs fcp ,
  apps.fnd_concurrent_programs_tl fcpl   ,
  apps.fnd_descr_flex_col_usage_vl fdfcuv,
  apps.fnd_flex_value_sets ffvs          ,
  apps.fnd_lookup_values flv             ,
  apps.fnd_lookups fl                    ,
  apps.fnd_executables fe                ,
  apps.fnd_executables_tl fet            ,
  apps.fnd_application_tl fat
  WHERE 1                     = 1
AND fcp.concurrent_program_id = fcpl.concurrent_program_id
AND fcp.enabled_flag          = 'Y'
AND fcpl.user_concurrent_program_name = 'XX Vendor Invoice Payment Report' --<Your Concurrent Program Name>
AND fdfcuv.descriptive_flexfield_name = '$SRS$.'
  || fcp.concurrent_program_name
AND ffvs.flex_value_set_id = fdfcuv.flex_value_set_id
AND flv.lookup_type(+)     = 'FLEX_DEFAULT_TYPE'
AND flv.lookup_code(+)     = fdfcuv.default_type
AND fcpl.language          = 'US'
AND flv.language(+)        = 'US'
AND fl.lookup_type         ='CP_EXECUTION_METHOD_CODE'
AND fl.lookup_code         =fcp.execution_method_code
AND fe.executable_id       = fcp.executable_id
AND fe.executable_id       =fet.executable_id
AND fet.language           = 'US'
AND fat.application_id     =fcp.application_id
AND fat.language           = 'US'
ORDER BY fdfcuv.column_seq_num;

Query to get responsibility name based on menu name

SELECT DISTINCT a.responsibility_name, c.user_menu_name
FROM apps.fnd_responsibility_tl a,
apps.fnd_responsibility b,
apps.fnd_menus_tl c,
apps.fnd_menus d,
apps.fnd_application_tl e,
apps.fnd_application f
WHERE a.responsibility_id(+) = b.responsibility_id
AND b.menu_id = c.menu_id
AND b.menu_id = d.menu_id
AND e.application_id = f.application_id
AND f.application_id = b.application_id
AND a.LANGUAGE = 'US'
--and responsibility_name ='AR Customer Maintenance'
and upper(user_menu_name) = 'XX_AR_CUST';