1、创建data element&domain
Tcode: SE11
Name: ZJULY_CHECK_AUTHORIT
2、创建authorization objects
Tcode: SU20
Field Name: ZJULY
Data element:ZJULY_CHECK_AUTHORIT
3、创建authorization object
Tcode: SU21
Class: ZJUL
Object: Z_JULY (July's object class)
Field: ZJULY
![](https://i-blog.csdnimg.cn/blog_migrate/dcccd6eb00d316781ee9999f5d7a70a3.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/54a46f06e184fc4bb04f5205cc022ef2.jpeg)
4、创建ROLE
Tcode: PFCG
Role: ZJULY
在Roles' 的Authorizations tab上,将anthorization object:z_july填入Expert Mode for Profile Generation产生的 profile 里面,自动产生profile name
5、为用户添加profile
Tcode: SU01
6、创建测试程序
DATA: Z(20) VALUE 'abc'.
AUTHORITY-CHECK OBJECT 'Z_JULY'
ID 'ZJULY' DUMMY.
WRITE:/ Z.
IF SY-SUBRC = 0.
WRITE:/ 'PASS'.
ELSE.
WRITE:/ 'Sorry.'.
ENDIF.
7、运行程序
必须先退出系统然后登录后前面设置的role才会生效.运行程序,结果为PASS.