Showing posts with label Apps Initialization using API. Show all posts
Showing posts with label Apps Initialization using API. Show all posts

Sunday, 10 April 2011

Apps Initialization using API

Apps Initialization using API


Procedure apps_initialize can be used to apps initialize from backend.

It is tested in 11i.

CREATE OR REPLACE PROCEDURE apps_initialize
IS
v_responsibility_name VARCHAR2 (100) := 'Payables';
v_user_name            VARCHAR2 (100) := 'Oracle';
v_application_id         NUMBER := 0;
v_responsibility_id      NUMBER := 0;
v_user_id                 NUMBER := 0;
v_flag                      NUMBER := 0;
BEGIN
      --Getting Responsbility and Application Id
      BEGIN
           SELECT responsibility_id,
                      application_id
           INTO     v_responsibility_id,
                      v_application_id
           FROM   fnd_responsibility_tl
          WHERE  responsibility_name = v_responsibility_name
          AND LANGUAGE = USERENV ('LANG');
       EXCEPTION
          WHEN OTHERS
          THEN
                   DBMS_OUTPUT.put_line
                                ( 'Error in getting Responsibility information and error is '
                                 || SUBSTR (SQLERRM, 1, 200)
                                );
             v_flag := 1;
         END;
        ----Getting User Id
        BEGIN
             SELECT user_id
             INTO v_user_id
             FROM fnd_user
             WHERE user_name = v_user_name;
        EXCEPTION
            WHEN OTHERS
           THEN
                   DBMS_OUTPUT.put_line
                         ( 'Error in getting User information and error is '
                            || SUBSTR (SQLERRM, 1, 200)
                          );
                   v_flag := 1;
         END;

        IF v_flag = 0
        THEN
                fnd_global.apps_initialize (v_user_id,
                                                   v_responsibility_id,
                                                   v_application_id
                                                    );
        END IF;
EXCEPTION
    WHEN OTHERS
     THEN
            DBMS_OUTPUT.put_line
                   ( 'Error in procedure apps initialize and error is '
                     || SUBSTR (SQLERRM, 1, 200)
                    );
END;
/