sap权限控制


如有转载请注明出处:

http://blog.youkuaiyun.com/donkey2004112103/archive/2009/05/06/4156065.aspx

今天终于了解了sap如何从技术的角度去实现权限控制,我觉得权限控制是这样实现的,首先想想为什么不同的用户可以有不同的权限了?因为有角色的概念,不同的用户分配了不同的的权限,所以有不同的权限。而角色由参数文件(profile )组成,参数文件里添加了授权对象(authority object),授权对象又由授权字段(authorization field)构成。这就从上到下的组成了权限控制的全部。如图:

这些东西配置好之后,我们便可以在程序中通过代码判断用户是否有该权限去执行某项操作了。那从代码开始一步一步讲解吧。 
代码:

AUTHORITY-CHECK OBJECT 'ZEMPOBJ04' 
                                 ID 'ACTVT' FIELD test. 
      IF SY-SUBRC = 0. 
          WRITE:/ 'PASS'. 
      ELSE. 
         WRITE:/ 'Sorry.'. 
     ENDIF.

上面这段代码便完成了一次权限检查,ZEMPOBJ04是权限对象,ACTVT是权限字段,test是我们要检测的字段,有可能是公司代码或者查看的权限等,然后通过sy-subrc字段取判断,如果为0则有这个权限。

权限字段:

可以通过SU20来创建权限字段,如下:

字段名和数据元素为必输,名字随便可以输入,数据元素可以自建,也可以参照创建。table name字段就是创建完成之后的check table,我们在创建权限对象添加字段的时候,如果这个权限字段有check table那么就会有一些值可供选择,如ACTVT:

如果没有输入table的话这个时候便没有,只能在profile里自己维护字段值了。

权限对象:

SU21进入权限对象的界面,可以先建立一个object class,它相当于一个目录包含了若干个权限对象,这样方便维护。我们创建好权限对象之后便可以添加刚才自己创建的字段了,或者系统标准的权限字段。然后选择这个权限对象有哪些值可以使用。

参数文件:

pfcg进入角色维护后可以先创建一个新的角色或者维护已经存在的角色,进入权限tab,选择更改授权数据。如图:

然后便可以添加若干权限对象,系统标准的或者自己创建的。在权限对象里就可以维护这个profile到底有哪些权限可以使用。

如图就是一个例子,注意做完操作后要点击生成,就是那个小圆圈的按钮。

角色:

最后我们只要把这个角色添加给用户,用户变拥有这个权限了。最后点击下”用户比较”按钮。

按需引入<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Ant Design Vue 纯HTML项目示例</title> <!-- 引入Ant Design Vue的CSS --> <link rel="stylesheet" href="https://unpkg.com/ant-design-vue@3.2.21/dist/antd.css"> <!-- 引入Ant Design X Vue的CSS --> <link rel="stylesheet" href="https://unpkg.com/ant-design-x-vue@1.0.0/dist/antdx.css"> <!-- vue3引入 --> <script src="https://unpkg.com/dayjs/dayjs.min.js"></script> <script src="https://unpkg.com/dayjs/plugin/customParseFormat.js"></script> <script src="https://unpkg.com/dayjs/plugin/weekday.js"></script> <script src="https://unpkg.com/dayjs/plugin/localeData.js"></script> <script src="https://unpkg.com/dayjs/plugin/weekOfYear.js"></script> <script src="https://unpkg.com/dayjs/plugin/weekYear.js"></script> <script src="https://unpkg.com/dayjs/plugin/advancedFormat.js"></script> <script src="https://unpkg.com/dayjs/plugin/quarterOfYear.js"></script> <!-- vue3 --> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <!-- antdv --> <script src="https://cdn.jsdelivr.net/npm/ant-design-vue@4.2.6/dist/antd.min.js"></script> <!-- antdxv --> <script src="https://cdn.jsdelivr.net/npm/ant-design-x-vue@1.2.7/dist/index.umd.min.js"></script> </head> <body> <div id="app"></div> <script> const { createApp, ref, computed } = Vue; const { Button } = antd; const { Bubble, XProvider } = antdx; createApp({ template: ` <AXProvider :theme="{ algorithm: myThemeAlgorithm, }"> <div :style="{ padding: &#39;24px&#39;, backgroundColor: bgColor, }"> UMD <AXBubble content="hello bubble"></AXBubble> <AButton type="primary" @click="setLightTheme">Light</AButton> <AButton type="primary" @click="setDarkTheme">Dark</AButton> </div> </AXProvider> `, setup() { const { theme } = antd; const bgColor = ref("white"); const myThemeAlgorithm = ref(theme.defaultAlgorithm); const setLightTheme = () => { myThemeAlgorithm.value = theme.defaultAlgorithm; bgColor.value = "white"; }; const setDarkTheme = () => { myThemeAlgorithm.value = theme.darkAlgorithm; bgColor.value = "#141414"; }; return { myThemeAlgorithm, bgColor, setLightTheme, setDarkTheme }; } }) .use(XProvider) .use(Button) .use(Bubble) .mount("#app"); </script> <style> .container { max-width: 1200px; margin: 24px auto; padding: 0 16px; } .search-form { margin-bottom: 24px; padding: 16px; background-color: #f5f5f5; border-radius: 4px; } .user-table { margin-top: 16px; } .mb-6 { margin-bottom: 24px; } .mt-2 { margin-top: 8px; } </style> </body> </html>
07-17
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值