List of BUKRS which the current user is allowed to see

為{幸葍}努か 提交于 2019-12-01 23:09:06

Another way to do it, based on the class CL_AUTH_OBJECTS_TO_SQL (>= 7.50), here the program reads the flights from the read-authorized airline carriers :

DATA(authsql) = cl_auth_objects_to_sql=>create_for_open_sql( ).

authsql->add_authorization_object( EXPORTING
    iv_authorization_object = 'S_CARRID'
    it_activities = VALUE #( ( auth_field = 'ACTVT' value = '03' ) )
    it_field_mapping = VALUE #(
      ( auth_field = 'CARRID'
        view_field = VALUE #( table_ddic_name = 'SFLIGHT' field_name = 'CARRID' ) ) ) ).

DATA(where) = authsql->get_sql_condition( ).

SELECT * FROM sflight INTO TABLE @data(sflights) WHERE (where).

I am afraid you can do it one by one only. Roughly:

SELECT bukrs
       INTO TABLE @DATA(lt_t001)
       FROM t001
       WHERE ... . "Selection critera, if necessary

LOOP AT lt_t001
     ASSIGNING FIELD-SYMBOL(<ls_t001>).
  DATA(lv_tabix) = sy-tabix.
  AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
           ID 'BUKRS' FIELD <ls_t001>-bukrs
           ID 'ACTVT' FIELD '03'. "Here you need the proper activity (display '03' /change '02' / etc.)
  IF sy-subrc <> 0. "Auth check failed
    DELETE lt_t001 INDEX lv_tabix.
  ENDIF.
ENDLOOP.

At the end lt_t001 contains only the company codes, for which the user has authorization.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!