SAP get windows login user function

FUNCTION ZIEB_RFC_CHECK04.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" EXPORTING
*" VALUE(USERNAME) TYPE STRING
*" VALUE(DOMAINNAME) 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.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH and-msgv1 and-msgv2 and-msgv3 and-msgv4.

ENDIF.

CALL METHOD cl_gui_frontend_services=>environment_get_variable
EXPORTING
variable = 'USERDOMAIN'
CHANGING
value = domainname
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 and-msgv1 and-msgv2 and-msgv3 and-msgv4.

ENDIF.

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

ENDFUNCTION.

Guess you like

Origin blog.csdn.net/SAPmatinal/article/details/132134816