SAP爱好者

的专栏

ABAP 代码中实现权限Check的两种方式
1. 针对SU01中Parameter的check,获取用户Parameter的语句如下

n  获取用户Parameter
 
GET PARAMETER ID 'ZPBOM' FIELD ID.


2. 对于用户权限对象的Check,举例:

FORM f_check_m_best_bsa USING    i_bsart TYPE esart
                       
CHANGING o_power TYPE c.

 
TYPES: BEGIN OF t_t161,
    bstyp
TYPE bstyp,
    bsart
TYPE esart,
 
END OF t_t161.
 
DATA: lt_values TYPE STANDARD TABLE OF us335.
 
DATA: lw_value  LIKE LINE OF lt_values.
 
DATA: lt_t161   TYPE STANDARD TABLE OF t_t161.

 
AUTHORITY-CHECK OBJECT 'M_BEST_BSA' ID 'ACTVT' FIELD '09'
                                     
ID 'BSART' FIELD '*'.
 
IF sy-subrc = 0.
    o_power
= 'X'.
   
EXIT.
 
ENDIF.

CALL FUNCTION 'GET_AUTH_VALUES'
   
EXPORTING
      object1          
= 'M_BEST_BSA'
      user             
= sy-uname
      tcode            
= sy-tcode
   
TABLES
      values           
= lt_values
   
EXCEPTIONS
      user_doesnt_exist
= 1
     
OTHERS            = 2.

 
LOOP AT lt_values INTO lw_value.

   
IF lw_value-field = 'ACTVT' AND lw_value-lowval = '09'.
     
READ TABLE lt_values TRANSPORTING NO FIELDS
          
WITH KEY auth = lw_value-auth
                  
field = 'BSART'
                  lowval
= i_bsart.
     
IF sy-subrc = 0.
        o_power
= 'X'.
       
EXIT.
     
ENDIF.
   
ENDIF.

   
IF lw_value-highval IS NOT INITIAL.
     
SELECT bstyp bsart
       
INTO TABLE lt_t161
       
FROM t161
      
WHERE bstyp = 'F'
        
AND bsart >= lw_value-lowval
        
AND bsart <= lw_value-highval.

     
READ TABLE lt_t161 TRANSPORTING NO FIELDS
          
WITH KEY bsart = i_bsart.

     
IF sy-subrc = 0.
       
READ TABLE lt_values TRANSPORTING NO FIELDS
            
WITH KEY auth = lw_value-auth
                    
field = 'ACTVT'
                    lowval
= '09'.
       
IF sy-subrc = 0.
          o_power
= 'X'.
         
EXIT.
       
ENDIF.
     
ENDIF.
   
ENDIF.

   
CLEAR lw_value.
 
ENDLOOP.

 
FREE: lt_values,lt_t161.

ENDFORM.                    " f_check_m_best_bsa

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xx4565715/article/details/46799609
个人分类: ABAP
想对作者说点什么? 我来说一句

SAP中AUTHORITY-CHECK 的使用

starshus starshus

2008-01-10 00:03:00

阅读数:11849

没有更多推荐了,返回首页

不良信息举报

ABAP 代码中实现权限Check的两种方式

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭