‎2006 Dec 19 9:48 AM
Hi!
I would like to know, is there a way to query the logged user's documents and settings directory in Windows XP.
For example if Bill Gates is using his Windows XP home (and not his Linux ), his documents directory will be on the following path: "C:Documents and settingsBill GatesDocuments".
I would like to get this path from ABAP (with a FM or with a class maybe).
Thank you in advance
Tamá
‎2006 Dec 19 9:51 AM
Hello:
use the method GET_SAPGUI_WORKDIR of class CL_GUI_FRONTEND_SERVICES. This method will return the SAP Working directory which will be C:\Documents and Settings\User\SAPWorkdir
GET_DESKTOP_DIRECTORY will return the desktop directory.
ENVIRONMENT_GET_VARIABLE will get the value of an environment variable.
Manoj
‎2006 Dec 19 9:51 AM
Hello:
use the method GET_SAPGUI_WORKDIR of class CL_GUI_FRONTEND_SERVICES. This method will return the SAP Working directory which will be C:\Documents and Settings\User\SAPWorkdir
GET_DESKTOP_DIRECTORY will return the desktop directory.
ENVIRONMENT_GET_VARIABLE will get the value of an environment variable.
Manoj
‎2006 Dec 19 10:28 AM
Thanx for the answer... Sadly I receive only a blank field, I'll attach my coding, did I forget sg?
DATA: go_gui_frontend type ref to CL_GUI_FRONTEND_SERVICES.
DATA: lv_sapworkdir TYPE string.
...
CREATE OBJECT go_gui_frontend.
CLEAR lv_sapworkdir.
CALL METHOD go_gui_frontend->GET_SAPGUI_WORKDIR
CHANGING sapworkdir = lv_sapworkdir.
Thank you
Tamá
‎2006 Dec 19 10:43 AM
You dont need to create an object for the class since it is a static method. You can use the class name directly to call the method.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_SAPGUI_WORKDIR
CHANGING sapworkdir = lv_sapworkdir.
Manoj
‎2006 Dec 19 12:09 PM
Seems this method is not working... It gives only a blank field for me...
‎2007 Jan 11 1:19 PM
‎2007 Sep 07 1:40 PM
Probably need to add a flush. I was trying to figure this out myself, here is the example I got to work:
REPORT ztest_enviromentalvariable .
DATA: go_gui_frontend TYPE REF TO cl_gui_frontend_services.
DATA: lv_tmp TYPE string.
...
CREATE OBJECT go_gui_frontend.
CLEAR lv_tmp.
CALL METHOD cl_gui_frontend_services=>environment_get_variable
EXPORTING
variable = 'TMP'
IMPORTING
value = lv_tmp
EXCEPTIONS
cntl_error = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL METHOD CL_GUI_CFW=>FLUSH
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
Error handling
ENDIF.
WRITE: / lv_tmp.