add

About Me

My photo
Oracle Apps - Techno Functional consultant

Tuesday, January 9


Script To Remove End Date From Responsibilities Assigned to a user



DECLARE
    p_user_name           VARCHAR2(50) := 'RSRIVASTAV';
    p_resp_name           VARCHAR2(50) := 'System Administrator';
    v_user_id             NUMBER(10) := 0;
    v_responsibility_id   NUMBER(10) := 0;
    v_application_id      NUMBER(10) := 0;
BEGIN
    BEGIN
        SELECT
            user_id
        INTO
            v_user_id
        FROM
            fnd_user
        WHERE
            upper(user_name) = upper(p_user_name);

    EXCEPTION
        WHEN no_data_found THEN
            dbms_output.put_line('User not found');
            RAISE;
        WHEN OTHERS THEN
            dbms_output.put_line('Error finding User.');
            RAISE;
    END;

    BEGIN
        SELECT
            application_id,
            responsibility_id
        INTO
            v_application_id,v_responsibility_id
        FROM
            fnd_responsibility_vl
        WHERE
            upper(responsibility_name) = upper(p_resp_name);

    EXCEPTION
        WHEN no_data_found THEN
            dbms_output.put_line('Responsibility not found.');
            RAISE;
        WHEN too_many_rows THEN
            dbms_output.put_line('More than one responsibility found with this name.');
            RAISE;
        WHEN OTHERS THEN
            dbms_output.put_line('Error finding responsibility.');
            RAISE;
    END;

    BEGIN
        dbms_output.put_line('Initializing The Application');
        fnd_global.apps_initialize(user_id => v_user_id,resp_id => v_responsibility_id,resp_appl_id => v_application_id);

        dbms_output.put_line('Calling FND_USER_RESP_GROUPS_API API To Insert/Update Resp');
        fnd_user_resp_groups_api.update_assignment(user_id => v_user_id,responsibility_id => v_responsibility_id,responsibility_application_id
=> v_application_id,security_group_id => 0,start_date => SYSDATE,end_date => SYSDATE + 10,description => NULL);

        dbms_output.put_line('The End Date has been removed from responsibility');
        COMMIT;
    EXCEPTION
        WHEN OTHERS THEN
            dbms_output.put_line('Error calling the API');
            RAISE;
    END;

END;

No comments: