*&---------------------------------------------------------------------*
*&  Include           ZSOFTCOPY__CL_GUI_UNKNOWN                        *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*& This file is part of ZSOFTCOPY.                                     *
*&                                                                     *
*& ZSOFTCOPY is free software: you can redistribute it and/or modify   *
*& it under the terms of the GNU General Public License as published   *
*& by the Free Software Foundation, either version 3 of the License,   *
*& or any later version.                                               *
*&                                                                     *
*& ZSOFTCOPY is distributed in the hope that it will be useful,        *
*& but WITHOUT ANY WARRANTY; without even the implied warranty of      *
*& MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
*& GNU General Public License for more details.                        *
*&                                                                     *
*& You should have received a copy of the GNU General Public License   *
*& along with ZDOWNLOAD. If not, see <http://www.gnu.org/licenses/>.   *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&  Author:     Ruediger von Creytz     ruediger.creytz@globalbit.net  *
*&  Copyright:  globalBIT, LLC          http://www.globalbit.net       *
*&                                                                     *
*&---------------------------------------------------------------------*


*-----------------------------------------------------------------------
* cl_gui_get_folder
*-----------------------------------------------------------------------
FORM cl_gui_get_folder
  CHANGING
    c_selected_folder TYPE string
    c_subrc TYPE sysubrc.

  DATA:
  l_len TYPE i,
  l_char TYPE c.

  CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
      def_path = p_folder
      mask     = ',*.txt,*.txt.'
      mode     = 'O'
      title    = 'Choose a directory'
    IMPORTING
      filename = c_selected_folder
    EXCEPTIONS
      OTHERS   = 1.
  c_subrc = sy-subrc.
  IF c_subrc = 0 AND NOT c_selected_folder IS INITIAL.
    DO.
      l_len = strlen( c_selected_folder ).
      l_len = l_len - 1.
      l_char = c_selected_folder+l_len(1).
      IF l_len = 0.
        EXIT.
      ENDIF.
      c_selected_folder = c_selected_folder+0(l_len).
      IF l_char = gc_delimiter.
        EXIT.
      ENDIF.
    ENDDO.
  ENDIF.
ENDFORM.                    "cl_gui_get_folder
