Tuesday, October 9, 2018






Responsibility assign from backend API



SELECT fa.application_short_name,
  fr.responsibility_key,
  fsg.security_group_key,
  frt.description
FROM apps.fnd_responsibility fr,
  fnd_application fa,
  fnd_security_groups fsg,
  fnd_responsibility_tl frt
WHERE frt.responsibility_name = 'MWA Administrator'                -------------System Administrator
AND frt.LANGUAGE              = USERENV ('LANG')
AND frt.responsibility_id     = fr.responsibility_id
AND fr.application_id         = fa.application_id
AND fr.data_group_id          = fsg.security_group_id;


API to add Responsibility :

DECLARE
   v_user_name             VARCHAR2 (30)  := '&user_name';
   v_responsibility_name   VARCHAR2 (100) := '&responsibility_name';
   v_application_name      VARCHAR2 (100) := NULL;
   v_responsibility_key    VARCHAR2 (100) := NULL;
   v_security_group        VARCHAR2 (100) := NULL;
   v_description           VARCHAR2 (100) := NULL;
BEGIN
   SELECT fa.application_short_name, fr.responsibility_key,
          fsg.security_group_key, frt.description
     INTO v_application_name, v_responsibility_key,
          v_security_group, v_description
     FROM apps.fnd_responsibility fr,
          fnd_application fa,
          fnd_security_groups fsg,
          fnd_responsibility_tl frt
    WHERE frt.responsibility_name = v_responsibility_name
      AND frt.LANGUAGE = USERENV ('LANG')
      AND frt.responsibility_id = fr.responsibility_id
      AND fr.application_id = fa.application_id
      AND fr.data_group_id = fsg.security_group_id;

   fnd_user_pkg.addresp (username            => v_user_name,
                         resp_app            => v_application_name,
                         resp_key            => v_responsibility_key,
                         security_group      => v_security_group,
                         description         => v_description,
                         start_date          => SYSDATE,
                         end_date            => NULL
                        );
   COMMIT;
   DBMS_OUTPUT.put_line(   'Responsiblity '
                         || v_responsibility_name
                         || ' is attached to the user '
                         || v_user_name
                         || ' Successfully'
                        );
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line
                         (   'Unable to attach responsibility to user due to'
                          || SQLCODE
                          || ' '
                          || SUBSTR (SQLERRM, 1, 100)
                         );

END;


How to create user from backend in oracle applications R12

API to CREATE FND User




DECLARE
   lc_user_name                  VARCHAR2 (100) := 'TEST';
   lc_user_password            VARCHAR2 (100) := 'welcome1';
   ld_user_start_date           DATE           := TO_DATE ('23-JUN-2018');
   ld_user_end_date            VARCHAR2 (100) := NULL;
   ld_password_date            VARCHAR2 (100) := TO_DATE ('23-JUN-2018');
   ld_password_lifespan_days   NUMBER         := 90;
   ln_person_id                   NUMBER         := 32979;
   lc_email_address            VARCHAR2 (100) := 'TEST@host.com';
BEGIN
   fnd_user_pkg.createuser
                      (x_user_name                      => lc_user_name,
                       x_owner                              => NULL,
                       x_unencrypted_password    => lc_user_password,
                       x_start_date                        => ld_user_start_date,
                       x_end_date                         => ld_user_end_date,
                       x_password_date               => ld_password_date,
                       x_password_lifespan_days => ld_password_lifespan_days,
                       x_employee_id                  => ln_person_id,
                       x_email_address                => lc_email_address
                      );
   COMMIT;
EXCEPTION
   WHEN OTHERS
   THEN
      ROLLBACK;
      DBMS_OUTPUT.put_line (SQLERRM);
END;
/