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: 

Get user system domain name ?

Former Member
0 Kudos

Hi All,

Is there FM/Method to get the user's system domain name?

There are some function modules and front-end call methods to get username,terminal name..etc but haven't come across one which gives the domain name.

Any feedback will be helpfull..

Cheers,

Nameeth

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Nameeth,

you could use


call function 'WS_QUERY'
  exporting
    environment = 'USERDOMAIN'
    query       = 'EN'
  importing
    return      = _return_variable.

Yeah, it's an obsolete FM, and I've tried it just in Windows NT, but it may still work !!!

Please let us know if it was OK. BR,

Alvaro

6 REPLIES 6

eddy_declercq
Active Contributor
0 Kudos

Is it plain SAP or with HTPP(s)? If it's the latter you can always retrive the ip addresse (~remote_addr)

See http://help.sap.com/saphelp_erp2004/helpdata/en/c1/7f56d32e243141a1595268bfcf351a/frameset.htm

Have also a look at

Former Member
0 Kudos

Hi Nameeth,

you could use


call function 'WS_QUERY'
  exporting
    environment = 'USERDOMAIN'
    query       = 'EN'
  importing
    return      = _return_variable.

Yeah, it's an obsolete FM, and I've tried it just in Windows NT, but it may still work !!!

Please let us know if it was OK. BR,

Alvaro

0 Kudos

Hi Nameeth / Alvaro,

You wouldn't find this <i>obsolete</i>.

data front_end   type ref to CL_GUI_FRONTEND_SERVICES.
data user_domain type string.

start-of-selection.
  create object front_end.
  
  CALL METHOD cl_gui_frontend_services=>environment_get_variable
    EXPORTING
      variable             = 'USERDOMAIN'
    CHANGING
      value                = user_domain
    EXCEPTIONS
      others               = 4.
IF sy-subrc <> 0.
* Error Handling
ENDIF.

CALL METHOD CL_GUI_CFW=>FLUSH.

Regards,

Anand Mandalika.

0 Kudos

don't forget to reward points if you feel that your question is answered

0 Kudos

Hi

The method Anand mentioned is the best. However you can also use the function module <b>'TH_USER_INFO'</b> as far as I remember.

*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

Former Member
0 Kudos

nameeth,

if you need the hostname of the server you're logged on to, the variable SY-HOST should give you what you need.

but if you need the hostname of the user logged on, take a look at program RSUSR000 (tcode AL08) - you should be able to extract the information you need with the code inside. but basically you get all the systems/instances for the server you're logged on, and determine the users on each server. from there it shouldn't be hard to read off the hostname of the user's login name.

<b>[edit]</b> ... and the code above should give you what you need too. heheh. not only did i not read your question correctly, but by the time i got to post, someone had something more correct posted already. 😃 <b>[/edit]</b>

hope this helps anyway,

ryan.

Message was edited by: Ryan Kristoffer Tan

Message was edited by: Ryan Kristoffer Tan