List SAP User-Roles Assignments in ABAP Code
To get a list of valid SAP User Role assignments in ABAP codes, developers can use AGR_USERS SAP transparent table to get a similar list seen on SU01D transaction screen.
Using SAP SU01D transaction code (Display Users screen), SAP users can display the Roles assigned to a specific SAP user or assigned roles to themselves.
SAP user roles assignments are stored in ABAP table AGR_USERS with the validity dates.
If you query the transparent table AGR_USERS in SE11 or using ABAP codes, you can get a list of SAP roles assigned to a user as follows
Here is a short ABAP code which queries SAP table AGR_USERS for valid user roles at the execution time for the current SAP user and lists SAP user roles on the screen.