ABAP Authority-Check Object For User Other Than Current
Using ABAP Authority-Check Object statement with For User addition enables ABAP developers to check authorization of a specific user in their custom programs. If the checked authorization object is defined for the related SAP user pointed with the help of "For User" addition. If FOR USER and a SAP user following the FOR USER addition is not defined in AUTHORITY-CHECK ABAP statement, authorization of the current user is checked by default.
ABAP developers can use the FOR USER addition to check authorization for a specific user instead of current user running ABAP program.
Here is the ABAP code, following the FOR USER addition a local variable can be used to store the target SAP user name.
* Check authorization for user
AUTHORITY-CHECK OBJECT 'Z_TR_SALES'
FOR USER i_user_id
ID 'VKORG' FIELD lv_vkorg
ID 'VTWEG' FIELD lv_vtweg
ID 'SPART' FIELD lv_spart
ID 'ACTVT' FIELD '09'.