Application Development 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: 

Computer Name to be retrieved

Former Member
0 Kudos

Hi All,

How to retrieve the computer name of the user who is working on a SAP System.

Pointers would be helpful.

Thanks,

Best regards,

Prashant

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hai Prashant,

If you want to tract the hostname of your computer use the static method GET_COMPUTER_NAME of class CL_GUI_FRONTEND_SERVICES.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_COMPUTER_NAME

importing COMPUTER_NAME = c_name.

For HTTP sessions, you can use the following FM to ge the terminal name (host)

RFC_IP_TO_HOST

pass the ip address you get from thusrinfo, it will return the terminal name (host).

Regards,

Srikanth.

Reward points if helpful..

Message was edited by: Srikanth

8 REPLIES 8

timo_wendt
Explorer
0 Kudos

Hi,

maybe this helps:

DATA: name TYPE string.

CALL METHOD cl_gui_frontend_services=>get_computer_name

CHANGING

computer_name = name

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.

ENDIF.

Regards.

Timo

Former Member
0 Kudos

Hi Prashant,

Try this FM TH_USER_INFO.

hope this helps,

priya

Former Member
0 Kudos

Hello Prashant,

Did u try TMP_GUI_GET_COMPUTERNAME.

Former Member
0 Kudos

Hai Prashant,

If you want to tract the hostname of your computer use the static method GET_COMPUTER_NAME of class CL_GUI_FRONTEND_SERVICES.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_COMPUTER_NAME

importing COMPUTER_NAME = c_name.

For HTTP sessions, you can use the following FM to ge the terminal name (host)

RFC_IP_TO_HOST

pass the ip address you get from thusrinfo, it will return the terminal name (host).

Regards,

Srikanth.

Reward points if helpful..

Message was edited by: Srikanth

former_member223537
Active Contributor
0 Kudos

Hi,

The above method is not returning any value though the sy-subrc is 0.

Please help.

Best regards,

Prashant

Former Member
0 Kudos

hi prashant ,

just execute this code and see if it suffice ur need .

regards,

TVK.

DATA SI LIKE RFCSI.

CALL FUNCTION 'RFC_SYSTEM_INFO' DESTINATION 'SAPGUI'

IMPORTING

RFCSI_EXPORT = SI.

WRITE:

/ 'RFC log version:', SI-RFCPROTO,

/ 'Character set (SAP name):', SI-RFCCHARTYP,

/ 'Integer format (1 / 2 = little / big endian):', SI-RFCINTTYP,

/ 'Floating point format (1=IEEE, 2=IBM/370 format):', SI-RFCFLOTYP,

/ 'Logical destination (specified when calling function):', SI-RFCDEST,

/ 'Host:', SI-RFCHOST,

/ 'System: SAP System ID:', SI-RFCSYSID,

/ 'System: SAP System ID:', SI-RFCDATABS,

/ 'Database host name:', SI-RFCDBHOST,

/ 'System: Database system:', SI-RFCDBSYS,

/ 'System: SAP Release:', SI-RFCSAPRL,

/ 'RFC: SAP machine ID:', SI-RFCMACH,

/ 'System: Operating system:', SI-RFCOPSYS,

/ 'Time zone (difference from UTC in seconds):', SI-RFCTZONE,

/ 'Summertime active ? (''daylight saving time''):', SI-RFCDAYST,

/ 'IP address:', SI-RFCIPADDR.

skip 3.

DATA: W_HOSTADDR LIKE MSXXLIST-HOSTADR,

W_TERMINAL(30) TYPE C,

w_1 type i,

w_2 like w_1,

w_3 like w_1,

w_4 like w_1.

CALL FUNCTION 'TH_USER_INFO'

IMPORTING

HOSTADDR = W_HOSTADDR

TERMINAL = W_TERMINAL

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC = 0.

w_1 = W_HOSTADDR(1).

w_2 = W_HOSTADDR+1(1).

w_3 = W_HOSTADDR+2(1).

w_4 = W_HOSTADDR+3(1).

WRITE: / 'IP address:', w_1,'.',w_2,'.',w_3,'.',w_4,

/ 'Terminal :', W_TERMINAL.

ELSE.

WRITE / 'Unknown Error.'.

ENDIF.

former_member188685
Active Contributor
0 Kudos

Hi Prashant,

Check this code..

this program will give user's system name , ip address etc..

REPORT  ZTEST_IPGET                             .

DATA: BEGIN OF USR_TABL OCCURS 10.
        INCLUDE STRUCTURE UINFO.
DATA: END OF USR_TABL.

DATA:TH_OPCODE(1)  TYPE X.
DATA: IPADDR(30).

CONSTANTS: OPCODE_LIST  LIKE TH_OPCODE VALUE 2.

CALL 'ThUsrInfo' ID 'OPCODE' FIELD OPCODE_LIST
ID 'TAB' FIELD USR_TABL-*SYS*.



LOOP AT USR_TABL.

  CALL FUNCTION 'GWY_IPADR2STRING'
    EXPORTING
      IPADR  = USR_TABL-HOSTADR
    IMPORTING
      STRING = IPADDR.

  WRITE:/ USR_TABL-BNAME ,USR_TABL-TERM, IPADDR.
ENDLOOP.

Regards

Vjay

Former Member
0 Kudos
REPORT  YCHATEST                                .

data : info_txt(40).

CALL FUNCTION 'GUI_GET_DESKTOP_INFO'
         EXPORTING
              type    = 1
         changing
              return  = info_txt.

write : / info_txt.