Oracle EBS 11i Add Responsibility to User by the Responsibility reference of Other User.

Warning: R12 version must be fixed columns sort to insert successfully.

 

 

DECLARE

   --input parameters

   l_reference_user_name             VARCHAR2 (50) := 'HKIT_KPWONG';

   l_add_resp_user_name              VARCHAR2 (50) := 'SZIT_QWR';

   l_resp_name                       VARCHAR2 (300) := 'Application Developer';

   -----------------------------------------------------------

 

   l_user_orig_system_id             NUMBER := -999999;

   l_role_name                       VARCHAR2 (300) := NULL;

   l_add_resp_user_exists            NUMBER := 0;

   l_insert_role_record             NUMBER := 0;

   l_insert_role_assign_record   NUMBER := 0;

BEGIN

   --get responsibility role name

   SELECT COUNT (1)

     INTO l_add_resp_user_exists

     FROM (SELECT u.user_id user_id

                , (SELECT responsibility_name

                     FROM fnd_responsibility_tl

                    WHERE     responsibility_id = wur.role_orig_system_id

                          AND application_id = fa.application_id

                          AND language = 'US')

                     app_responsibility_name

                , wur.role_name

                , wur.user_orig_system_id

                , wur.role_orig_system_id responsibility_id

                , fa.application_id responsibility_application_id

                , fsg.security_group_id security_group_id

                , fnd_date.canonical_to_date ('1000/01/01') start_date

                , TO_DATE (NULL) end_date

                , TO_CHAR (NULL) description

                , TO_NUMBER (NULL) created_by

                , TO_DATE (NULL) creation_date

                , TO_NUMBER (NULL) last_updated_by

                , TO_DATE (NULL) last_update_date

                , TO_NUMBER (NULL) last_update_login

             FROM fnd_user u

                , wf_user_role_assignments_v wura

                , wf_user_roles wur

                , fnd_application fa

                , fnd_security_groups fsg

            WHERE     wura.user_name = u.user_name

                  AND wur.role_orig_system = 'FND_RESP'

                  AND wur.partition_id = 2

                  AND wura.role_name = wur.role_name

                  AND wura.user_name = wur.user_name

                  AND fa.application_short_name = /* Val between 1 st and 2 nd separator */

                         REPLACE (SUBSTR (wura.role_name

                                        ,   INSTR (wura.role_name

                                                 , '|'

                                                 , 1

                                                 , 1)

                                          + 1

                                        , (  INSTR (wura.role_name

                                                  , '|'

                                                  , 1

                                                  , 2)

                                           - INSTR (wura.role_name

                                                  , '|'

                                                  , 1

                                                  , 1)

                                           - 1))

                                , '%col'

                                , ':')

                  AND fsg.security_group_key =  /* Val after 3 rd separator */

                         REPLACE (SUBSTR (wura.role_name

                                        ,   INSTR (wura.role_name

                                                 , '|'

                                                 , 1

                                                 , 3)

                                          + 1)

                                , '%col'

                                , ':')

                  AND u.user_name = l_add_resp_user_name) resp

    WHERE 1 = 1 AND resp.app_responsibility_name = l_resp_name;

 

 

   IF (l_add_resp_user_exists > 0)

   THEN

      DBMS_OUTPUT.put_line (

            'Failed !!! Add Responsebility Name: '

         || l_resp_name

         || ' to User: '

         || l_add_resp_user_name

         || ' by reference User: '

         || l_reference_user_name);

      DBMS_OUTPUT.put_line (

         'The Responsibility exists at Added User: ' || l_add_resp_user_name);

      RETURN;

   END IF;

 

 

 

   --get responsibility role name

   SELECT resp.role_name

     INTO l_role_name

     FROM (SELECT u.user_id user_id

                , (SELECT responsibility_name

                     FROM fnd_responsibility_tl

                    WHERE     responsibility_id = wur.role_orig_system_id

                          AND application_id = fa.application_id

                          AND language = 'US')

                     app_responsibility_name

                , wur.role_name

                , wur.user_orig_system_id

                , wur.role_orig_system_id responsibility_id

                , fa.application_id responsibility_application_id

                , fsg.security_group_id security_group_id

                , fnd_date.canonical_to_date ('1000/01/01') start_date

                , TO_DATE (NULL) end_date

                , TO_CHAR (NULL) description

                , TO_NUMBER (NULL) created_by

                , TO_DATE (NULL) creation_date

                , TO_NUMBER (NULL) last_updated_by

                , TO_DATE (NULL) last_update_date

                , TO_NUMBER (NULL) last_update_login

             FROM fnd_user u

                , wf_user_role_assignments_v wura

                , wf_user_roles wur

                , fnd_application fa

                , fnd_security_groups fsg

            WHERE     wura.user_name = u.user_name

                  AND wur.role_orig_system = 'FND_RESP'

                  AND wur.partition_id = 2

                  AND wura.role_name = wur.role_name

                  AND wura.user_name = wur.user_name

                  AND fa.application_short_name = /* Val between 1 st and 2 nd separator */

                         REPLACE (SUBSTR (wura.role_name

                                        ,   INSTR (wura.role_name

                                                 , '|'

                                                 , 1

                                                 , 1)

                                          + 1

                                        , (  INSTR (wura.role_name

                                                  , '|'

                                                  , 1

                                                  , 2)

                                           - INSTR (wura.role_name

                                                  , '|'

                                                  , 1

                                                  , 1)

                                           - 1))

                                , '%col'

                                , ':')

                  AND fsg.security_group_key =  /* Val after 3 rd separator */

                         REPLACE (SUBSTR (wura.role_name

                                        ,   INSTR (wura.role_name

                                                 , '|'

                                                 , 1

                                                 , 3)

                                          + 1)

                                , '%col'

                                , ':')

                  AND u.user_name = l_reference_user_name) resp

    WHERE 1 = 1 AND resp.app_responsibility_name = l_resp_name;

 

 

   IF (l_role_name IS NULL)

   THEN

      DBMS_OUTPUT.put_line (

            'Failed !!! Add Responsebility Name: '

         || l_resp_name

         || ' to User: '

         || l_add_resp_user_name

         || ' by reference User: '

         || l_reference_user_name);

      DBMS_OUTPUT.put_line (

            'The reference User have not the Responsibility: '

         || l_resp_name

         || '. Please input correct data!');

      RETURN;

   END IF;

 

 

   --get user orig system id

   SELECT DISTINCT wur.user_orig_system_id

     INTO l_user_orig_system_id

     FROM wf_user_roles wur

    WHERE 1 = 1 AND wur.user_name = l_add_resp_user_name;

 

 

   IF (l_user_orig_system_id = -999999)

   THEN

      DBMS_OUTPUT.put_line (

            'Failed !!! Add Responsebility Name: '

         || l_resp_name

         || ' to User: '

         || l_add_resp_user_name

         || ' by reference User: '

         || l_reference_user_name);

      DBMS_OUTPUT.put_line ('No found User Orig System ID.');

      RETURN;

   END IF;

 

 

   INSERT INTO wf_local_user_roles

      SELECT l_add_resp_user_name

           , wur.role_name

           , wur.user_orig_system

           , l_user_orig_system_id

           , wur.role_orig_system

           , wur.role_orig_system_id

           , wur.start_date

           , wur.expiration_date

           , wur.security_group_id

           , wur.partition_id

           , wur.owner_tag

           , wur.created_by

           , wur.creation_date

           , wur.last_updated_by

           , wur.last_update_date

           , wur.last_update_login

           , wur.assignment_type

           , wur.parent_orig_system

           , wur.parent_orig_system_id

           , wur.user_start_date

           , wur.role_start_date

           , wur.user_end_date

           , wur.role_end_date

           , wur.effective_start_date

           , wur.effective_end_date

           , wur.assignment_reason

        FROM wf_local_user_roles wur

       WHERE     1 = 1

             AND wur.user_name = l_reference_user_name

             AND wur.role_name = l_role_name;

 

 

   l_insert_role_record := SQL%ROWCOUNT;

 

   IF (l_insert_role_record = 0)

   THEN

      DBMS_OUTPUT.put_line (

            'Failed !!! Add Responsebility Name: '

         || l_resp_name

         || ' to User: '

         || l_add_resp_user_name

         || ' by reference User: '

         || l_reference_user_name);

      DBMS_OUTPUT.put_line ('No data into Role table.');

      RETURN;

   END IF;

 

 

   INSERT INTO wf_user_role_assignments

      SELECT l_add_resp_user_name

           , wura.role_name

           , wura.relationship_id

           , wura.assigning_role

           , wura.start_date

           , wura.end_date

           , wura.created_by

           , wura.creation_date

           , wura.last_updated_by

           , wura.last_update_date

           , wura.last_update_login

           , wura.user_start_date

           , wura.role_start_date

           , wura.assigning_role_start_date

           , wura.user_end_date

           , wura.role_end_date

           , wura.assigning_role_end_date

           , wura.partition_id

           , wura.effective_start_date

           , wura.effective_end_date

           , wura.user_orig_system

           , l_user_orig_system_id

           , wura.role_orig_system

           , wura.role_orig_system_id

           , wura.parent_orig_system

           , wura.parent_orig_system_id

           , wura.owner_tag

           , wura.assignment_reason

        FROM wf_user_role_assignments wura

       WHERE     1 = 1

             AND wura.user_name = l_reference_user_name

             AND wura.role_name = l_role_name;

 

 

   l_insert_role_assign_record := SQL%ROWCOUNT;

 

 

   IF (l_insert_role_record <> l_insert_role_assign_record)

   THEN

      DBMS_OUTPUT.put_line (

            'Failed !!! Add Responsebility Name: '

         || l_resp_name

         || ' to User: '

         || l_add_resp_user_name

         || ' by reference User: '

         || l_reference_user_name);

 

      ROLLBACK;

      COMMIT;

   END IF;

 

   DBMS_OUTPUT.put_line (

         'Successfully !!! Add Responsebility Name: '

      || l_resp_name

      || ' to User: '

      || l_add_resp_user_name

      || ' by reference User: '

      || l_reference_user_name);

 

   COMMIT;

END;

 

http://www.cnblogs.com/quanweiru/archive/2013/05/21/3090818.html

Oracle EBS Add Responsibility to User by the Responsibility reference of Other User.的更多相关文章

  1. Oracle EBS Standard Package Function Add User & Resp

    Oracle EBS Standard Package Function Add User & Resp. fnd_user_pkg.CreateUser; fnd_user_pkg.AddR ...

  2. Oracle EBS R12经验谈(二)

    作者: jianping.ni    时间: 2009-2-13 12:52     标题: Oracle EBS R12经验谈(二) OAF页面:银行帐户开户人LOV值列表无值    在输入 应付超 ...

  3. Oracle EBS应用笔记整理 (转自IT++ flyingkite)

    ***************************************************** Author: Flyingkite Blog:   http://space.itpub. ...

  4. Oracle EBS R12 (12.1.3) Installation Linux(64 bit)

    Oracle EBS R12 (12.1.3) Installation Linux(64 bit) Contents Objective. 3 1 Download & Unzip. 3 D ...

  5. [转]oracle EBS 基础100问

    from:http://www.cnblogs.com/xiaoL/p/3593691.html  http://f.dataguru.cn/thread-51057-1-1.html 1001 OR ...

  6. Oracle EBS Concurrent Request:Gather Schema Statistics[Z]

    Oracle EBS 的Concurrent Request"Gather Schema Statistics"是一个和性能相关的Concurrent Program,它会对表,列 ...

  7. Oracle EBS R12多组织(多OU)访问架构

    Oracle EBS R12多组织访问架构 多组织架构实现了经营单位(OU)的数据安全性,在底层数据表中有一列ORG_ID来记录数据所属的经营单一,所有多OU的基表都是以"_ALL" ...

  8. Using Integrated SOA Gateway in Oracle EBS

    FROM:http://blog.csdn.net/pan_tian/article/details/10159935 Oracle EBS如何与第三方系统相集成?比如这样的需求,X系统知道物料编码, ...

  9. Oracle EBS 12.2.6 on VirtualBox

    Back in May, Oracle announced the general availability of Oracle VM Virtual Appliance for E-Business ...

随机推荐

  1. js基础篇string&&array(应YX同学面试复习要求 - -)

    js中的数据类型一共有五个基本数据类型,分别是undefined,null,boolean,number,string. js中的Object类型中包括两大类型:Function类型和array类型. ...

  2. 关于OkHttp–支持SPDY协议的高效HTTP库 com.squareup.okhttp

    转载:http://liuzhichao.com/p/1707.html OkHttp–支持SPDY协议的高效HTTP库 柳志超博客 » Program » Andriod » OkHttp–支持SP ...

  3. 两个很经典的拓扑排序题目POJ3687+HDU1285

    一.题目链接 POJ:http://poj.org/problem?id=3687 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=1285 二.思路 这两 ...

  4. HDU-6156 Palindrome Function(数位DP)

    一.题目 二.思路 1.这是很明显的数位DP: 2.和以往数位DP不同的是,这里带了个进制进来,而以往做是纯十进制下或者纯二进制下做操作.但是,不管多少进制,原理都是一样的: 3.这里有个小坑,题目中 ...

  5. redis for windows之nosql还需要入门?

    RT:nosql给很多人的感觉就是上手特别快,本文也是一篇入门级的,哎~~ 又写了一篇没有卵用的博文,姑且把它当作一篇文档吧,还是没有发布/订阅.事件...等介绍的一篇残缺文档,幸好废话不是很多,凑合 ...

  6. 33_java之类加载器和反射

    01类加载器 * A.类的加载 当程序要使用某个类时,如果该类还未被加载到内存中,则系统会通过加载,连接,初始化三步来实现对这个类进行初始化. * a 加载 * 就是指将class文件读入内存,并为之 ...

  7. Pthreads 《并行程序设计导论》的补充代码

    ▶ 关于单链表的访问,插入结点和删除结点操作,并且将其推广到多线程中去. ● 代码,通用的随机数生成 // my_rand.h #ifndef _MY_RAND_H_ #define _MY_RAND ...

  8. 96. Unique Binary Search Trees (Tree; DP)

    Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...

  9. Visual Studio C++ include与library

    首先介绍几种目录: 1. 系统路径 系统路径在vc中是"Properties->Configuration Properties -> VC++ Directories" ...

  10. 自制精排 ePub 集、不定期更新(UPDATA-2015-8-2)

    说明 排版不说最好,上乘是必须的. 段落空行 首行缩进 具备清爽元数据 包含高清封面.目录 图片居中,图片标题以下标形式居中位于图片下* 支持多看/Kindle原生系统弹出注释,其他软件跳转注释* 各 ...