REPORT ZEXAMPLE.

DATA: V_USRID LIKE SY-UNAME,

V_LOCK.

CALL FUNCTION 'F4_USER'

IMPORTING

RESULT = V_USRID.

CALL FUNCTION 'USER_EXISTS'

EXPORTING

BNAME = V_USRID

IMPORTING

LOCKED = V_LOCK

EXCEPTIONS

USER_DONT_EXIST = 1

USER_EXISTS = 2

OTHERS = 3.

IF SY-SUBRC EQ 2.

IF V_LOCK EQ 'X'.

WRITE:/ V_USRID, 'EXISTS AND IS LOCKED'.

ELSE.

WRITE:/ V_USRID, 'EXISTS AND IS UNLOCKED'.

ENDIF.

ELSEIF SY-SUBRC EQ 1.

WRITE:/ V_USRID, 'DOES NOT EXIST'.

ELSE.

WRITE:/ 'ERROR FINDING USER'.

ENDIF.