Thursday, February 7, 2013

Loading Responsibilities through API


DECLARE
   CURSOR resp
   IS
      SELECT *
        FROM custom_fnd_responsibility
       WHERE responsibility_key NOT IN (SELECT responsibility_key
                                          FROM fnd_responsibility);
                                       
   v_resp_id            NUMBER;
   v_menu_id            NUMBER;
   v_request_group_id   NUMBER;
   v_msg varchar2(500);
   v_rowid varchar2(500);
   v_application_id number;
   v_version number;
v_resp_key varchar2(500);
v_resp_name varchar2(500);
v_web_host_name varchar2(500);
v_web_agent_name varchar2(500);

BEGIN
   FOR resp_rec IN resp
   LOOP
      SELECT fnd_responsibility_s.NEXTVAL
        INTO v_resp_id
        FROM DUAL;

      BEGIN
         SELECT menu_id
           INTO v_menu_id
           FROM fnd_menus
          WHERE menu_name = resp_rec.menu_name;
      EXCEPTION
         WHEN NO_DATA_FOUND
         THEN
            v_msg := 'No Menu';
            DBMS_OUTPUT.put_line (v_msg);
      END;

      BEGIN
         SELECT request_group_id
           INTO v_request_group_id
           FROM fnd_request_groups
          WHERE request_group_name = resp_rec.request_group_name
          and application_id = resp_rec.application_id;
      EXCEPTION
         WHEN others
         THEN
            v_msg := 'No Request Group'||resp_rec.request_group_name;
            DBMS_OUTPUT.put_line (v_msg);
            v_request_group_id := null;
      END;
   
v_application_id := resp_rec.application_id;
v_version := 4;
v_resp_key := resp_rec.responsibility_key;
v_resp_name :=resp_rec.responsibility_name;
   

fnd_responsibility_pkg.insert_row(
-- out params
x_rowid => v_rowid,
-- in params
x_responsibility_id => v_resp_id,
x_application_id => v_application_id,
x_web_host_name => v_web_host_name,
x_web_agent_name => v_web_agent_name,
x_data_group_application_id => v_application_id,
x_data_group_id => 0,
x_menu_id => v_menu_id,
x_start_date => sysdate,
x_end_date => null,
x_group_application_id => v_application_id,
x_request_group_id => v_request_group_id,
x_version => v_version,
x_responsibility_key => v_resp_key,
x_responsibility_name => v_resp_name,
x_description => '',
x_creation_date => sysdate,
x_created_by => 0,
x_last_update_date => sysdate,
x_last_updated_by => 0,
x_last_update_login => 0
);
   
   END LOOP;
   commit;
exception
when others then
dbms_output.put_line('failed to add resp' || sqlerrm);
END;

2 comments:

  1. what are the values assigned for the v_web_host_name ,
    v_web_agent_name. Is it passing the values from the table and not doing any validation?

    ReplyDelete
  2. Provide the table structure for custom_fnd_responsibility

    ReplyDelete