Wednesday, December 28, 2016

API to Create Security Rule Usages

--select * from fnd_flex_value_rule_usages where flex_value_set_id = 1014149 order by creation_date desc

DECLARE
   l_flex_value_set_name      VARCHAR2 (100) := 'XX_GL_FUTURE1_VS';
   l_flex_value_rule_name     VARCHAR2 (100) := NULL;
   l_responsibility_key       VARCHAR2 (100) := NULL;
   l_application_short_name   VARCHAR2 (100) := NULL;
BEGIN
   SELECT flex_value_rule_name
     INTO l_flex_value_rule_name
     FROM fnd_flex_value_rules
    WHERE flex_value_rule_id = 1858;

   SELECT fr.responsibility_key, fa.application_short_name
     INTO l_responsibility_key, l_application_short_name
     FROM fnd_responsibility fr,
          fnd_responsibility_tl frt,
          fnd_application fa,
          fnd_application_tl fat
    WHERE     fr.responsibility_id = frt.responsibility_id
          AND frt.language = 'US'
          AND fa.application_id = fr.application_id
          AND fr.application_id = fat.application_id
          AND fat.language = 'US'
          AND responsibility_name = 'XX GL Super User';

   DBMS_OUTPUT.PUT_LINE (l_responsibility_key);
   DBMS_OUTPUT.PUT_LINE (l_application_short_name);

   fnd_flex_loader_apis.up_vset_security_usage (
      p_upload_mode              => NULL,
      p_flex_value_set_name      => l_flex_value_set_name,
      p_flex_value_rule_name     => l_flex_value_rule_name,
      p_parent_flex_value_low    => NULL,
      p_application_short_name   => l_application_short_name,
      p_responsibility_key       => l_responsibility_key,
      p_last_update_date         => SYSDATE,
      p_owner                    => 'BIJOY',
      p_parent_flex_value_high   => NULL);

   DBMS_OUTPUT.put_line ('Security Added');
   COMMIT;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line (SQLERRM);

END;

No comments:

Post a Comment