BAPI_USER_GET_DETAIL¶
Read user master data (the same record you see in SU01).
Purpose¶
Returns full user master data — address, defaults, roles, profiles, parameters, license, validity dates — for a given user ID. The standard, RFC-enabled way to read SU01 data programmatically.
Signature (the parts you'll actually use)¶
| Parameter | Direction | Type | Notes |
|---|---|---|---|
USERNAME |
IMPORTING | XUBNAME |
The user ID. Required. |
LOGONDATA |
EXPORTING | BAPILOGOND |
Validity dates, user type, time zone |
ADDRESS |
EXPORTING | BAPIADDR3 |
Name, email, phone, department |
DEFAULTS |
EXPORTING | BAPIDEFAUL |
Logon language, decimal format, date format |
ACTIVITYGROUPS |
TABLES | BAPIAGR |
Assigned roles |
PROFILES |
TABLES | BAPIPROF |
Assigned profiles |
RETURN |
TABLES | BAPIRET2 |
Messages — always check this |
Example¶
DATA: lv_user TYPE xubname VALUE 'TESTUSER',
ls_address TYPE bapiaddr3,
ls_logondata TYPE bapilogond,
lt_agr TYPE STANDARD TABLE OF bapiagr,
lt_return TYPE STANDARD TABLE OF bapiret2.
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = lv_user
IMPORTING
address = ls_address
logondata = ls_logondata
TABLES
activitygroups = lt_agr
return = lt_return.
" Always inspect RETURN — the BAPI doesn't raise exceptions
LOOP AT lt_return INTO DATA(ls_msg) WHERE type CA 'EAX'.
WRITE: / ls_msg-message.
ENDLOOP.
WRITE: / 'Email :', ls_address-e_mail,
/ 'Valid from:', ls_logondata-gltgv,
/ 'Valid to :', ls_logondata-gltgb.
Common pitfalls¶
Authorisation matters
The caller needs S_USER_GRP with activity 03 (display) for the user's group. Without it, RETURN comes back populated but the detail tables are empty — and it's easy to miss because there's no exception.
Locked vs. valid
LOGONDATA-GLTGB (valid to) being in the past is not the same as a locked user. To check lock status, look at ISLOCKED (BAPIUSLOCK) — there's a separate FM BAPI_USER_GET_DETAIL exporting ISLOCKED parameter, plus dedicated BAPI_USER_LOCK / BAPI_USER_UNLOCK.
- No COMMIT WORK needed — this is a read-only BAPI.
- Performance: if you need many users, batch them — there's no mass version, but a parallel
cl_abap_parallelwrapper around this FM is the standard pattern. USERNAMEis case sensitive in newer releases — useTRANSLATE lv_user TO UPPER CASE.first if input comes from a free text field.
Related¶
BAPI_USER_CREATE1— create a userBAPI_USER_CHANGE— modify a userBAPI_USER_LOCK/BAPI_USER_UNLOCKBAPI_USER_GETLIST— list users matching a filterSUSR_USER_READ— internal alternative when an RFC isn't required
See also¶
- Class
CL_USER_MASTER_DATA(newer, OO wrapper) - Transactions: SU01, SUIM