Managing SAP user data with Identity GUID via an ABAP Class
BAPIs or SAP standard functions for USR are pretty handy in managing SAP user data in most cases but how about if an external system needs a USER GUID instead of BNAME to search SAP user ? What if a case of that you need to manage SAP user data only by GUID (Identity)?
Class CL_IDENTITY_FACTORY is providing very useful functions for user & for user Identity such as searching, deleting, creating, checking, and more. Even the use of CL_IDENTITY_FACTORY is not complicated as it has only static & public methods which giving you direct access without instantiating an object .
If you want to check SAP user existence in SAP system, Checking USR table might be the simplest way. However, here is an other way to do that
DATA : LV_BNAME TYPE XUBNAME,
LS_MESSAGE TYPE SYMSG,
LS_BNAME_EXIST TYPE SUID_ST_IDENTITY.
* Check User existance
LV_BNAME = CV_USERNAME.
IV_BNAME = LV_BNAME
ES_IDENTITY = LS_BNAME_EXIST ).
* IF LS_BNAME_EXIST IS INITIAL.
* RAISE EXCEPTION
IS_BNAME_EXIST = LS_BNAME_EXIST.
You can also send a query for user data or deal with multiple users or get info of BPs assigned to the users. To get further & deeper handling, check out class CL_IDENTITY .