*&---------------------------------------------------------------------*
*&  Include           ZDB_DOWNLOAD_DO                                  *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*& This file is part of ZDB.                                           *
*&                                                                     *
*& ZDB_DOWNLOAD 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.                                      *
*&                                                                     *
*& ZDB_DOWNLOAD 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       *
*&                                                                     *
*&---------------------------------------------------------------------*


*-----------------------------------------------------------------------
* form: download
*-----------------------------------------------------------------------
FORM download USING
                value(i_pack)
                value(i_tabname)
                value(i_extension)
                it_string TYPE it_string.

  DATA:
  l_infoline(80),
  l_uri TYPE string.

  PERFORM getfilename USING i_pack i_tabname i_extension
                      CHANGING l_uri.

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename = l_uri
    TABLES
      data_tab = it_string
    EXCEPTIONS
      OTHERS   = 1.

  IF sy-subrc <> 0.
    CONCATENATE i_tabname '.' i_extension
      INTO l_infoline.
    CONCATENATE
      text-010 l_infoline
      INTO l_infoline SEPARATED BY space.
    WRITE: l_infoline, sy-subrc.
  ENDIF.

ENDFORM.                    "download


*-----------------------------------------------------------------------
* form: getFilename
*-----------------------------------------------------------------------
FORM getfilename USING
                   value(i_pack)
                   value(i_tabname)
                   value(i_extension)
                 CHANGING
                   c_uri TYPE string.

  DATA:
  f_infoline(80),
  f_delimiter TYPE string VALUE '\',
  f_dbl_delimiter TYPE string VALUE '\\'.

  CONCATENATE i_tabname '.' i_extension
    INTO f_infoline.
  CONCATENATE
      text-009 f_infoline
      INTO f_infoline SEPARATED BY space.

  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
    EXPORTING
      text = f_infoline.

  CONCATENATE
      g_folder
      f_delimiter i_pack
      f_delimiter 'R3TR_TABL'
      f_delimiter i_tabname
      '.' i_extension
      INTO c_uri.
  PERFORM replace_all
    USING '/' f_delimiter
    CHANGING c_uri.
  WHILE c_uri CS f_dbl_delimiter.
    PERFORM replace_all
      USING f_dbl_delimiter f_delimiter
      CHANGING c_uri.
  ENDWHILE.

ENDFORM.                    "getFilename
