Sunday, November 25, 2007

Check user roles

For checking if a user has a specific role the function
SRM_VE_GET_USER_ROLES can be of great help. The following code gives an
example of its use:

DATA lt_roles TYPE STANDARD TABLE OF str_agrs.

* Einlesen aller Rollen eines Users
CALL FUNCTION 'SRM_VE_GET_USER_ROLES'
EXPORTING
user_name = im_user
time_dependent = im_time_dependent
TABLES
activity_groups_users = lt_roles
EXCEPTIONS
no_activity_groups_available = 1
OTHERS = 2.

IF sy-subrc <> 0.
EXIT.
ENDIF.

SORT lt_roles BY agr_name.

* versuche, die benötigte Rolle zu finden
READ TABLE lt_roles WITH KEY agr_name = im_role_to_check
TRANSPORTING NO FIELDS BINARY SEARCH.

No comments: