Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Local User

Former Member
0 Likes
1,788

Hi!

I need to get the local User information from the client workstation - who is signed on at the client. Is there an ABAP-function available which reads the local user-id.

Thanks for your help!

Thomas

8 REPLIES 8
Read only

Former Member
0 Likes
1,537

You can try

TH_USER_LIST

It returns a table of the user currently logged into the client.

Also


DATA: RETURN TYPE TABLE OF BAPIRET2,
      user_data TYPE BAPIADDR3.
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
  EXPORTING
    USERNAME = SY-UNAME
  IMPORTING
    ADDRESS  = user_data
  TABLES
    RETURN   = return.

Read only

andreas_mann3
Active Contributor
0 Likes
1,537

Hi Thomas,

CL_GUI_FRONTEND_SERVICES->GET_USER_NAME

Grx Andreas

Read only

0 Likes
1,537

Hi Andreas!

I tried the Method GET_USER_NAME --> without a result. sy-subrc = 0 but the returnvalue doesn't contain the login-user.

Any Idea ??

Thomas

Read only

0 Likes
1,537

Typically the user that is login is kept in the value SY-UNAME in ABAP and BSP at least it is the right value.

Read only

nablan_umar
Product and Topic Expert
Product and Topic Expert
0 Likes
1,537

Hi Thomas,

Are you looking for user id that login into SAP or user id that login into your PC?

Read only

0 Likes
1,537

I'm looking for the user ID logged in into my PC. No SAP-User !!

Thomas

Read only

0 Likes
1,537

Hi Thomas,

sorry for my first reply:

I've not tested the method before posting -

the method works but without result...

here's another solution - that works <b>with</b> result

CALL FUNCTION 'GUI_GET_DESKTOP_INFO'

EXPORTING

TYPE = 5

CHANGING

RETURN = name.

Grx Andreas

Read only

0 Likes
1,537

Did you flush after the call to get_user_name? You have to call cl_gui_cfw=>flush( ) after most calls to the frontend services class. The following code sample might help explain:


REPORT  yes_tjung_flush_test                                        .

DATA: username TYPE string.

CALL METHOD cl_gui_frontend_services=>get_user_name
  CHANGING
    user_name            = username
  EXCEPTIONS
    cntl_error           = 1
    error_no_gui         = 2
    not_supported_by_gui = 3
    OTHERS               = 4.
IF sy-subrc <> 0.
ENDIF.

WRITE: / 'Test1', username.

cl_gui_cfw=>flush( ).

WRITE: / 'Test2', username.