[ABAP] SAP-Workdir ermitteln

Variante 1 (cl_gui_frontend_services)

PARAMETERS: p_path TYPE string OBLIGATORY LOWER CASE.

INITIALIZATION.

TRY.
  cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = p_path ).

  cl_gui_cfw=>flush( ).
CATCH cx_root INTO DATA(e_txt).
  WRITE: / e_txt->get_text( ).
ENDTRY.

Variante 2 (IW_C_GET_SAPWORKDIR)

DATA: lvsapworkdir TYPE sdok_chtrd.
DATA: lverror_msg	TYPE iwerrormsg.

* SAP Workdir aus der Registry bestimmen (Temporär)
CALL FUNCTION 'IW_C_GET_SAPWORKDIR'
  IMPORTING
    sapworkdir = lvsapworkdir
    error_msg  = lverror_msg.

WRITE: / lvsapworkdir.
WRITE: / lverror_msg.