Skip to Content
author's profile photo
Former Member

get_*_directory problem

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.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • author's profile photo
    Former Member
    Sep 30, 2005 at 10:36 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 03, 2005 at 04:22 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded