Thursday, October 18, 2012

Set Profile from back end -- fnd_profile.SAVE


DECLARE
   stat   BOOLEAN;
BEGIN
   DBMS_OUTPUT.DISABLE;
   DBMS_OUTPUT.ENABLE (100000);
   --stat := fnd_profile.SAVE ('ORG_ID', 88, 'RESP',21623,660);
   /* Profile name you are setting --- 'ORG_ID'
   /* Profile value you are setting --- org id value from  hr_all_organization_units
   /* Level that you're setting at-- 'RESP' Responsibility Level
   /* Level value that you are setting at --- 21623 -- Responsibility id
   /* 660 -- Responsbility Application id*/
   stat := fnd_profile.SAVE ('ORG_ID', 88, 'SITE');
 
   IF stat
   THEN
      DBMS_OUTPUT.put_line ('Stat = TRUE - profile updated');
   ELSE
      DBMS_OUTPUT.put_line ('Stat = FALSE - profile NOT updated');
   END IF;
   COMMIT;

END;

SELECT   fpo.profile_option_name short_name,
         fpot.user_profile_option_name NAME,
         DECODE (fpov.level_id,
                 10001, 'Site',
                 10002, 'Application',
                 10003, 'Responsibility',
                 10004, 'User',
                 10005, 'Server',
                 'UnDef'
                ) level_set,
         DECODE (TO_CHAR (fpov.level_id),
                 '10001', '',
                 '10002', fap.application_short_name,
                 '10003', frsp.responsibility_key,
                 '10005', fnod.node_name,
                 '10006', hou.NAME,
                 '10004', fu.user_name,
                 'UnDef'
                ) "CONTEXT",
         fpov.profile_option_value VALUE
    FROM fnd_profile_options fpo,
         fnd_profile_option_values fpov,
         fnd_profile_options_tl fpot,
         fnd_user fu,
         fnd_application fap,
         fnd_responsibility frsp,
         fnd_nodes fnod,
         hr_operating_units hou
   WHERE fpo.profile_option_id = fpov.profile_option_id(+)
     AND fpo.profile_option_name = fpot.profile_option_name
     AND fu.user_id(+) = fpov.level_value
     AND frsp.application_id(+) = fpov.level_value_application_id
     AND frsp.responsibility_id(+) = fpov.level_value
     AND fap.application_id(+) = fpov.level_value
     AND fnod.node_id(+) = fpov.level_value
     AND hou.organization_id(+) = fpov.level_value
     AND fpot.LANGUAGE = USERENV ('LANG')
     AND fpot.user_profile_option_name =
                     ('&Profie')
ORDER BY short_name;
 

No comments:

Post a Comment