Friday, May 30, 2014

API to Create User Securing Attributes

DECLARE
   l_return_status    VARCHAR2 (2000);
   l_msg_count        NUMBER;
   l_msg_data         VARCHAR2 (2000);
   l_attribute_code   VARCHAR2 (500) := 'ICX_HR_PERSON_ID';
   l_application_id NUMBER := NULL;

   CURSOR c1
   IS
      SELECT *
        FROM fnd_user
       WHERE user_name = 'BIJOYJ';
BEGIN
   -- Block to Get Application ID
   BEGIN
      SELECT application_id
        INTO l_application_id
        FROM fnd_application_tl
       WHERE application_name = 'Oracle iProcurement' AND language = 'US';
   EXCEPTION
      WHEN OTHERS
      THEN
         l_application_id := NULL;
   END;

   FOR i IN c1
   LOOP
      BEGIN
         icx_user_sec_attr_pub.
          create_user_sec_attr (p_api_version_number   => 1,
                                p_return_status        => l_return_status,
                                p_msg_count            => l_msg_count,
                                p_msg_data             => l_msg_data,
                                p_web_user_id          => i.user_id,
                                p_attribute_code       => l_attribute_code,
                                p_attribute_appl_id    => l_application_id,
                                p_varchar2_value       => '',
                                p_date_value           => '',
                                p_number_value         => i.employee_id,
                                p_created_by           => -1,
                                p_creation_date        => SYSDATE,
                                p_last_updated_by      => -1,
                                p_last_update_date     => SYSDATE,
                                p_last_update_login    => -1);

         COMMIT;

         IF (l_return_status <> 'S')
         THEN
            DBMS_OUTPUT.
             put_line (
               'Failue !!! Attribute has not been created for '
               || i.user_name);
         ELSE
            DBMS_OUTPUT.
             put_line ('Attribute has been created for ' || i.user_name);
         END IF;
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.put_line ('Inner Exception: ' || SQLERRM);
      END;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Main Exception: ' || SQLERRM);
END;


Query to Check if Securing Attributes have been loaded Successfully

SELECT *
  FROM ak_web_user_sec_attr_values
 WHERE web_user_id = (SELECT user_id
                        FROM fnd_user

                       WHERE user_name = 'BIJOYJ')

1 comment: