Application Development and Automation 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: 
Read only

How to use environment variable (PATH) from ABAP

Former Member
0 Likes
937

I am trying to see if there is any easier way to use the OS path environment varibale from my abap program. Any suggesions will be highly appreciated.

Thanks

Ram

5 REPLIES 5
Read only

Former Member
0 Likes
826

may be some where from from registry

Read only

0 Likes
826

the registry path

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment

data : path type string.
CALL METHOD cl_gui_frontend_services=>registry_get_value
  EXPORTING
    root                 = cl_gui_frontend_services=>HKEY_LOCAL_MACHINE
    key                  = 'SYSTEM\ControlSet001\Control\Session Manager\Environment'
    value                = 'Path'
  IMPORTING
    reg_value            = path
  EXCEPTIONS
    get_regvalue_failed  = 1
    cntl_error           = 2
    error_no_gui         = 3
    not_supported_by_gui = 4
    others               = 5
        .
IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

WRITE : path.

this fetches value in path

Edited by: Soumyaprakash Mishra on Oct 22, 2009 7:45 PM

Read only

0 Likes
826

Thanks Soumyaprakash for the quick response. I appreciate it.

Just to test, I tried copying and pasting your code in a se38 program and when i tried to run it crashed. Is there anything that i need to change here before running?

Read only

0 Likes
826

what does the crash say?

in windows, in start menu->run give regedit.

now in that, keep the cursor at the top node on the left hand side, search for 'Environment'.

check if you are getting the same key position or not..

Read only

Former Member
0 Likes
826

not answered, but closing to make room for other questions.