cancel
Showing results for 
Search instead for 
Did you mean: 

Read out Windows-User

Denis_Müller
Participant
0 Kudos

Hello

i have a Webdynpro application and must read out the windows user.

There a function-module named GUI_GET_DESKTOP_INFO.

With this function-module i get the windows-user.

Problem is that the function-module is obsolete and you should user the class CL_GUI_FRONTEND_SERVICES.

Here you have the method get_user_name.

But it doesn't work.

How can i read out the windows user?

It can be in the webdynpro application or coded in a function-module

Thanks for your help

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member515618
Active Participant
0 Kudos

H Denis,

We should use cl_gui_frontend_services=>get_user_name in combination with cl_gui_cfw=>update_view method.

Try this out, you must get the user value in variable l_user.


CALL METHOD cl_gui_frontend_services=>get_user_name
  CHANGING
    user_name            = l_user
   EXCEPTIONS
     cntl_error           = 1
     error_no_gui         = 2
     not_supported_by_gui = 3
     others               = 4
        .
IF sy-subrc <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
    CALL METHOD cl_gui_cfw=>update_view
      EXCEPTIONS
        cntl_system_error = 1
        cntl_error        = 2
        OTHERS            = 3.
ENDIF.

Hope this helps,

Sravan Varagani

Denis_Müller
Participant
0 Kudos

is this code what i must include in the webdynpro application or in a function-module?

former_member515618
Active Participant
0 Kudos

Hi Dennis,

You can use it in your web dynpro application aswell. But handle the exceptions in WDA way and not as R/3.

Try the below in your WD component.


CALL METHOD cl_gui_frontend_services=>get_user_name
  CHANGING
    user_name            = l_user
   EXCEPTIONS
     cntl_error           = 1
     error_no_gui         = 2
     not_supported_by_gui = 3
     others               = 4.

    CALL METHOD cl_gui_cfw=>update_view
      EXCEPTIONS
        cntl_system_error = 1
        cntl_error        = 2
        OTHERS  

Regards,

Sravan Varagani

Denis_Müller
Participant
0 Kudos

ok i tried it in wd but it doesn't work

l_user is empty and the methode returns 1

and cl_gui_cfw=>update_view returns 0

what's the problem?

in a function-module i get the dump:

Usage of local result variables in a control/automatic-request

what is here the problem?

Edited by: Denis Müller on Apr 3, 2008 12:23 PM

former_member515618
Active Participant
0 Kudos

Hi Dennis,

Sorry, this cannot be used in Web applications as this is for getting GUI front end services.

My mistake. I guess we cannot use this in WD application..

Regards,

Sravan Varagani

Denis_Müller
Participant
0 Kudos

ok, no problem but how can i use it in a function-module?

former_member515618
Active Participant
0 Kudos

Hi Dennis,

Even if we create a function module, it works fine when run independently, but when called in a WD application, it doesnt fetch the values.

Regards.

Sravan Varagani

Denis_Müller
Participant
0 Kudos

if i create a function-module and start it independently i get the dump:

Usage of local result variables in a control/automatic-request

the error is for the variable l_user and this variable is defined like this:

data: l_user type string

former_member515618
Active Participant
0 Kudos

Hi Denis

Try this


FUNCTION yvsk_get_user_name.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  EXPORTING
*"     REFERENCE(E_USER_NAME) TYPE  STRING
*"----------------------------------------------------------------------
  CALL METHOD cl_gui_frontend_services=>get_user_name
    CHANGING
      user_name            = e_user_name
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      not_supported_by_gui = 3
      OTHERS               = 4.

  CALL METHOD cl_gui_cfw=>update_view
    EXCEPTIONS
      cntl_system_error = 1
      cntl_error        = 2
      OTHERS            = 3.

ENDFUNCTION.

This works for me perfectly when executed from SE37.

Regards,

Sravan Varagani

Denis_Müller
Participant
0 Kudos

ok now it works but the problem is that if i call the function moodule from the webdynpro application i get no user back.

is there any solution?

former_member515618
Active Participant
0 Kudos

Hi Denis,

Unfortunately, this doesnt work when executed through web dynpro as it doesnt have access to the GUI variables associated to desktop.

Regards,

Sravan Varagani

Denis_Müller
Participant
0 Kudos

hmmmm that bad

is there any way to read the windows-user for me?