关闭

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

150人阅读 评论(0) 收藏 举报
分类:
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

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:22793次
    • 积分:1348
    • 等级:
    • 排名:千里之外
    • 原创:119篇
    • 转载:3篇
    • 译文:0篇
    • 评论:1条
    文章分类
    最新评论