# BAPI_USER_LOCK — Lock User

> Locks a user with an administrator lock; the user cannot log on until the lock is removed. Interfaces that automatically lock the users of leaving employees from HR or identity management systems use it. It needs the lock activity in authorization object S_USER_GRP; check the result in the RETURN table.

- Modules: BASIS
- Type: BAPI
- Function group: SU_USER
- Remote-enabled (RFC): Yes
- S/4HANA status: Used the same way in S/4HANA
- URL: https://nekuhub.com/en/functions/bapi-user-lock/

## Importing parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| USERNAME | BAPIBNAME-BAPIBNAME | User name | Yes |

## Tables parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| RETURN | BAPIRET2 | Return messages | Yes |

## Call template (ABAP)

```abap
CALL FUNCTION 'BAPI_USER_LOCK'
  EXPORTING
    username = lv_username
  TABLES
    return = lt_return.
```

## Related tables

USR02

