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_*_directory problem

Former Member
0 Kudos

Hello all!

I'm using clase cl_gui_frontend_services, and every time that I try to get a directory using any of its methods I always get an empty string.

I have already tried:


DATA: dir_temp TYPE string.
CALL METHOD cl_gui_frontend_services->get_temp_directory
   CHANGING
     dir_temp = dir temp.

CALL METHOD cl_gui_frontend_services->get_sap_workdir
   CHANGING
     sapworkdir = dir temp.

CALL METHOD cl_gui_frontend_services->get_sapgui_directory
   CHANGING
     sapgui_directory = dir temp.

and all the methods bring an empty string.

Any ideas of what might happen here??

Thanks in advance.

Mauro.

2 REPLIES 2

Former Member
0 Kudos

Hi Mauro

the class CL_GUI_FRONTEND_SERVICES is based on the control framework, so certain methods need to be called together the method CL_GUI_CFW=>FLUSH.

After calling your method you have to call the FLUSH:

DATA: dir_temp TYPE string.

CALL METHOD cl_gui_frontend_services->get_temp_directory

CHANGING

dir_temp = dir temp.

CALL METHOD CL_GUI_CFW=>FLUSH

EXCEPTIONS

CNTL_SYSTEM_ERROR = 1

CNTL_ERROR = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

.........

ENDIF.

CALL METHOD cl_gui_frontend_services->get_sap_workdir

CHANGING

sapworkdir = dir temp.

CALL METHOD CL_GUI_CFW=>FLUSH

EXCEPTIONS

CNTL_SYSTEM_ERROR = 1

CNTL_ERROR = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

.........

ENDIF.

CALL METHOD cl_gui_frontend_services->get_sapgui_directory

CHANGING

sapgui_directory = dir temp.

CALL METHOD CL_GUI_CFW=>FLUSH

EXCEPTIONS

CNTL_SYSTEM_ERROR = 1

CNTL_ERROR = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

.........

ENDIF.

Max

Former Member
0 Kudos

Kindly check this demo program

<b>TEST_FRONTEND_SERVICES</b>

*************************************************

  • Test GET_TEMP_DIRECTORY

*************************************************


IF NOT P26 IS INITIAL.

  data: tempdir type string.

  CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_TEMP_DIRECTORY
                            CHANGING
                              TEMP_DIR     = tempdir
                            EXCEPTIONS
                              CNTL_ERROR   = 1
                              ERROR_NO_GUI = 2
                              others       = 3
                                  .
  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=>UPDATE_VIEW
*  EXPORTING
*    CALLED_BY_SYSTEM  =
                            EXCEPTIONS
                              CNTL_SYSTEM_ERROR = 1
                              CNTL_ERROR        = 2
                              others            = 3.

  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  if not tempdir is initial.
    write: / 'Temp directory is: ', tempdir.
    write: / 'GET_TEMP_DIRECTORY test ok.'.
  else.
    write: / 'GET_TEMP_DIRECTORY test failed.'.
  endif.
  write: / '---------------------------------------------------'.

ENDIF.

U can check this similar type of code sample in the demo program.

Hope this helps.

Kindly reward points for the answers which helped ot get back with queries.