如何设计和使用自定义的权限对象(自定义权限检查函数)
在sap扩展中用户往往都需要使用自己的权限对象,为了达到次目的,请按下列步骤建立和维护权限对象

1、Create an Anthorization Field(SU20)创建权限对象字段(存储在AUTHX表中)

2、Create an Authorization Object(SU21) 创建权限对象
创建权限对象类别(存储在TOBCT表中)
点击对象类别创建权限对象(存储在TOBJ表中),生成SAP_ALL

3、Assign an Authorization Object to an Object Class(SU02或PFCG)

4、权限赋值关系图

user  master record
                        /  ............................../
            auth. profile              Composite auth. profile
              /................./                      /                  /
             /                   /                    /                    /
  Authorization                                            Auth. Profile
     /                                                               /................./

5、Call "Authorith-Check" in Program  to Check Authorization.

这是我编写针对具体权限对象替代Authorith-Check的函数

form zcustcheckauth using  value(z_vkbur) like vbak-vkbur
                     z_return type i.
data: wa_ust12 like ust12.
data: bgetsubfile(1) type c.
data: begin of db_file occurs 10,
         profile like ust04-profile,
         typ     like usr10-typ,
      end of db_file.

data: begin of mid_db_file occurs 10,
         profile like ust04-profile,
         typ     like usr10-typ,
      end of mid_db_file.

data: begin of db_file_end occurs 10,
         profile like ust04-profile,
      end of db_file_end.

data: begin of db_auth occurs 10,
         objct like ust10s-objct,
         auth like ust10s-auth,
      end of db_auth.

z_return = 4.
   select ust04~profile usr10~typ
     into corresponding fields of table db_file
     from ust04
       inner join usr10 on usr10~profn = ust04~profile
         and usr10~aktps = 'A'
   where ust04~bname = sy-uname.

refresh mid_db_file.
   clear mid_db_file.
   loop at db_file.
      if db_file-typ <> 'C'.
        db_file_end-profile = db_file-profile.
        append db_file_end to db_file_end.
      else.
        bgetsubfile = 'X'.
        append db_file to mid_db_file.
      endif.
   endloop.
   refresh db_file.
   clear db_file.

while bgetsubfile = 'X'.
     bgetsubfile = space.
     select ust10c~subprof as profile usr10~typ
       into corresponding fields of table db_file
     from ust10c
       inner join usr10 on usr10~profn =  ust10c~subprof
         and usr10~aktps = 'A'
     for all entries in mid_db_file
     where ust10c~profn = mid_db_file-profile.

refresh mid_db_file.
     clear mid_db_file.
     loop at db_file.
      if db_file-typ <> 'C'.
        db_file_end-profile = db_file-profile.
        append db_file_end to db_file_end.
      else.
        bgetsubfile = 'X'.
        append db_file to mid_db_file.
      endif.
     endloop.
     refresh db_file.
     clear db_file.
   endwhile.

select objct auth into corresponding fields of table db_auth
   from ust10s
   for all entries in db_file_end
   where ust10s~aktps = 'A' and ust10s~profn = db_file_end-profile.

select von bis into corresponding fields of wa_ust12
     from ust12
     for all entries in db_auth
     where ust12~aktps = 'A' and ust12~field = 'VKBUR'
       and ust12~objct = db_auth-objct
       and ust12~auth = db_auth-auth.

if ( wa_ust12-bis ne space ).
        if ( z_vkbur ge wa_ust12-von ).
          if ( z_vkbur le wa_ust12-bis ).
            z_return = 0.
            exit.
          endif.
        endif.
     elseif ( z_vkbur = wa_ust12-von ).
       z_return = 0.
       exit.
     elseif ( '*' = wa_ust12-von ).
       z_return = 0.
       exit.
     endif.
   endselect.
endform.
调用的方法

*&---------------------------------------------------------------------*
*&      Form  USEREXIT_CHECK_VBAK
*&---------------------------------------------------------------------*
*                                                                     *
*       This Userexit can be used to add additional logic for         *
*       checking the header for completeness and consistency.         *
*                                                                     *
*       US_DIALOG  -  Indicator, that can be used to suppress         *
*                     dialogs in certain routines, e.g. in a          *
*                     copy routine.                                   *
*                                                                     *
*       This form is called from form VBAK_PRUEFEN.                   *
*                                                                     *
*---------------------------------------------------------------------*
form userexit_check_vbak using us_dialog.
*{   INSERT         DEVK901354                                        1
 data: z_s_vkbur like knvv-vkbur.
 data: z_auth_check type i value 4.
 if sy-tcode = 'VA01' or
    sy-tcode = 'VA02'.
   authority-check object 'V_VBKA_VKO'
                 id 'VKORG' dummy
                 id 'VTWEG' dummy
                 id 'SPART' dummy
                 id 'VKBUR' field vbak-vkbur
                 id 'VKGRP' dummy
                 id 'KTAAR' dummy
                 id 'ACTVT' dummy.
   if  sy-subrc ne 0.
     message e900(zdev).
   endif."不能创建非主管商家订单
   if sy-tcode eq 'VA01'.
     select single vkbur into z_s_vkbur
     from knvv
     where knvv~kunnr =  vbak-kunnr
       and knvv~vkorg =  vbak-vkorg
       and knvv~vtweg =  vbak-vtweg
       and knvv~spart =  vbak-spart
       and knvv~vkbur =  vbak-vkbur.
     if sy-subrc ne 0.
       message e001(zdev).
     endif.
   endif.
 else.
   perform zcustcheckauth using vbak-vkbur z_auth_check.

if  z_auth_check ne 0.  "如果没有权限,取当前商家主管销售组
     select single vkbur into z_s_vkbur
     from knvv
     where knvv~kunnr =  vbak-kunnr.
     if sy-subrc ne 0.
       message e001(zdev).
     endif.    "检查当前商家主管销售组是否在用户权限内
     z_auth_check = 4.
     perform zcustcheckauth using z_s_vkbur z_auth_check.
     if z_auth_check ne 0.
       message e900(zdev).
     endif.
  endif.
 endif.
*}   INSERT

SAP 权限对象设置及在程序中的应用相关推荐

  1. Linux下设置时区(通过shell设置和程序中设置)及程序中设置环境变量

    Shell中设置 bash中   export TZ="Europe/Moscow"        date -u -s "2011-10-29 21:55:00&quo ...

  2. qt linux 程序设置字体,QT程序中显示中文字体解决办法

    最近一直在做移植qtopia4.4.3和QT4.7的工作.qtopia已经可以在龙芯开发板上正常运行.搭建QT4.7的环境,使用QT4.7编写小程序,发现不能显示中文.研究了一番,找到了如下的解决方法 ...

  3. 在Delphi程序中调用控制面板设置功能

    ====================================================== 注:本文源代码点此下载 ================================= ...

  4. windbg 用代理_[Z] C#程序中设置全局代理(Global Proxy)

    https://www.cnblogs.com/Javi/p/7274268.html 1. HttpWebRequest类的Proxy属性,只要设置了该属性就能够使用代理了,如下: 1        ...

  5. 微信小程序中的tabBar设置

    我们先来看一份图,这个设置在官方文档中已经写得很清楚了,我只是做一个总结 注:我写注释是为了方便说明,在小程序中的json文件中是不能用注释的 这个tabBar属于全局属性,因此就在全局配置文件app ...

  6. 利用ATL创建com组件和如何在程序中使用组件的接口函数和设置接口的属性

    这是一个ATL开发实例的流程: 1.       在atl中插入一个atl实例,然后添加一个类,派生自ccmdtarget. 2.       添加相应的属性或者方法,在这里需要明白一点的是,这个属性 ...

  7. C#程序中设置全局代理(Global Proxy)

    1. HttpWebRequest类的Proxy属性,只要设置了该属性就能够使用代理了,如下: 1 //设置代理 2 WebProxy WP = new WebProxy("41.76.44 ...

  8. 在Winform程序中设置管理员权限及为用户组添加写入权限

    在我们一些Winform程序中,往往需要具有一些特殊的权限才能操作系统文件,我们可以设置运行程序具有管理员权限或者设置运行程序的目录具有写入的权限,如果是在操作系统里面,我们可以设置运行程序以管理员身 ...

  9. 程序中 设置jvm 参数_高效应用程序的7个JVM参数

    程序中 设置jvm 参数 在撰写本文时(2020年3月),围绕垃圾收集和内存,您可以将600多个参数传递给JVM. 如果您包括其他方面,则JVM参数总数将很容易超过1000个.

最新文章

  1. linux系统查看CPU使用含义、IO、内存、硬盘使用、负载
  2. gevent.joinall()开启协程
  3. Hadoop教程(一):简介、大数据解决方案、介绍快速入门
  4. MyEclipse自定义servlet模板
  5. NSThread使用总结
  6. 计算机入门 姚班,清华“姚班”:学霸中的尖子生,大佬毕业后都去哪了?
  7. xlrd读取单元格演练
  8. NPL之如何使用Glove--词向量转化
  9. 删除PHP配置文件中的注释行
  10. hadoop——Map/Reduce中combiner的使用
  11. 几种建模工具简介(SPSS,SAS,Stata,R,Matlab,Amos,Lisrel)
  12. 需求分析报告和需求规格说明书有什么区别?
  13. c盘是不是越大越好_C盘下的pagefile文件是不是越大越好?
  14. 黑龙江计算机比赛,信息工程学院在第十三届中国大学生计算机设计大赛黑龙江省赛中喜获佳绩...
  15. python链家数据分析统计服_链家二手房成交——Python数据分析
  16. js设计模式--代理模式
  17. C语言中的静态变量和静态函数
  18. 互联网35岁会被清退,这可能是2022年最大的谎言
  19. 《操作系统真象还原》第二章 ---- 编写MBR主引导记录 初尝编写的快乐 雏形已显!
  20. 总是反酸是慢性胃炎的标志?

热门文章

  1. 私.Modbus测试_ZC02_串口方式
  2. 【haproxy初始化】init_haproxy.sh
  3. StoreFront web 无法启动指定的应用
  4. Java开发,月薪30k需要掌握哪些主流技术?
  5. 删除username的索引
  6. cs-HtmlHelpers
  7. RedisTemplate实现事物问题剖析和解决
  8. [ZigBee] 9、ZigBee之AD剖析——AD采集CC2530温度串口显示
  9. 转:从零开始开发一款Android App (from 简书)
  10. 移动web开发都会遇到的坑(会持续更新)