Eigenschaften | Quelltext
Titel | SoftCopy - download |
Originalsprache | DE | Deutsch
Erstellt | 03.01.2013 |  | CREYTZ |
Letzte Änderung | 23.02.2021 |  | CREYTZ |
Status | aktiv |
Attribute
Typ | Include-Programm |
Status | Produktives Kundenprogramm |
Anwendung |  |
Berechtigungsgruppe |  |
Paket | ZSOFTCOPY | SoftCopy
| Editorsperre
txt
    1
    *&---------------------------------------------------------------------*
    2
    *&  Include           ZSOFTCOPY_DOWNLOAD                               *
    3
    *&                                                                     *
    4
    *&---------------------------------------------------------------------*
    5
    *&                                                                     *
    6
    *& This file is part of ZSOFTCOPY.                                     *
    7
    *&                                                                     *
    8
    *& ZSOFTCOPY is free software: you can redistribute it and/or modify   *
    9
    *& it under the terms of the GNU General Public License as published   *
    10
    *& by the Free Software Foundation, either version 3 of the License,   *
    11
    *& or any later version.                                               *
    12
    *&                                                                     *
    13
    *& ZSOFTCOPY is distributed in the hope that it will be useful,        *
    14
    *& but WITHOUT ANY WARRANTY; without even the implied warranty of      *
    15
    *& MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
    16
    *& GNU General Public License for more details.                        *
    17
    *&                                                                     *
    18
    *& You should have received a copy of the GNU General Public License   *
    19
    *& along with ZDOWNLOAD. If not, see <http://www.gnu.org/licenses/>.   *
    20
    *&                                                                     *
    21
    *&---------------------------------------------------------------------*
    22
    *&                                                                     *
    23
    *&  Author:     Ruediger von Creytz     ruediger.creytz@globalbit.net  *
    24
    *&  Copyright:  globalBIT, LLC          http://www.globalbit.net       *
    25
    *&                                                                     *
    26
    *&---------------------------------------------------------------------*
    27
    28
    29
    *-----------------------------------------------------------------------
    30
    * form: download
    31
    *-----------------------------------------------------------------------
    32
    FORM download
    33
      USING
    34
        it_html TYPE it_string
    35
        value(i_pgmid)
    36
        value(i_object)
    37
        value(i_filename)
    38
        value(i_extension)
    39
        value(i_do_count).
    40
    41
      DATA:
    42
      l_infoline TYPE syucomm,
    43
      l_uri TYPE string,
    44
      l_sub_uri TYPE char255,
    45
    *  l_dbl_delimiter type string,
    46
    *  l_cnt_downloads type string,
    47
    *  l_cnt_elems type string,
    48
      l_txt TYPE string,
    49
      l_message TYPE string,
    50
      l_codepage(20) TYPE c.
    51
    52
      PERFORM download_get_params
    53
        USING
    54
          i_pgmid
    55
          i_object
    56
          i_filename
    57
          i_extension
    58
          i_do_count
    59
        CHANGING
    60
          l_uri
    61
          l_sub_uri
    62
          l_infoline.
    63
    64
      PERFORM download_replace_wildcards
    65
        USING
    66
          l_sub_uri
    67
        CHANGING
    68
          it_html.
    69
    70
    *  if i_do_count = abap_true.
    71
    *    g_cnt_downloads = g_cnt_downloads + 1.
    72
    *  endif.
    73
    *
    74
    *  l_cnt_downloads = g_cnt_downloads.
    75
    *  condense l_cnt_downloads.
    76
    *  l_cnt_elems = g_cnt_elems.
    77
    *  condense l_cnt_elems.
    78
    *  perform get_message_text using 'DSVAS' '226'
    79
    *                               i_filename space space space
    80
    *                         changing l_message.
    81
    *  concatenate
    82
    *    l_cnt_downloads '/' l_cnt_elems '|'
    83
    *    l_message into l_infoline
    84
    *    separated by space.
    85
    *
    86
    *  concatenate g_folder g_c_delimiter g_pack g_c_delimiter into l_uri.
    87
    *  if not i_pgmid is initial and not i_object is initial.
    88
    *    concatenate l_uri i_pgmid '_' i_object g_c_delimiter into l_uri.
    89
    *  endif.
    90
    *  concatenate l_uri i_filename into l_uri.
    91
    *  if not i_extension is initial.
    92
    *    concatenate l_uri '.' i_extension into l_uri.
    93
    *  endif.
    94
    *  concatenate g_c_delimiter g_c_delimiter into l_dbl_delimiter.
    95
    *  perform replace_all
    96
    *    using '/' g_c_delimiter
    97
    *    changing l_uri.
    98
    *  perform replace_all
    99
    *    using '<' '-'
    100
    *    changing l_uri.
    101
    *  perform replace_all
    102
    *    using '>' '-'
    103
    *    changing l_uri.
    104
    *  while l_uri cs l_dbl_delimiter.
    105
    *    perform replace_all
    106
    *      using l_dbl_delimiter g_c_delimiter
    107
    *      changing l_uri.
    108
    *  endwhile.
    109
    110
      IF NOT i_extension = gc_extension_htm
    111
      AND NOT i_extension = gc_extension_xml.
    112
        l_codepage = '4110'.                                    "UTF-8
    113
      ENDIF.
    114
    115
      IF g_has_download_status = abap_true.
    116
        CALL FUNCTION 'GUI_DOWNLOAD'
    117
          EXPORTING
    118
            filename             = l_uri
    119
            codepage             = l_codepage
    120
            show_transfer_status = abap_false
    121
          TABLES
    122
            data_tab             = it_html
    123
          EXCEPTIONS
    124
            OTHERS               = 1.
    125
      ELSE.
    126
        CALL FUNCTION 'GUI_DOWNLOAD'
    127
          EXPORTING
    128
            filename = l_uri
    129
            codepage = l_codepage
    130
          TABLES
    131
            data_tab = it_html
    132
          EXCEPTIONS
    133
            OTHERS   = 1.
    134
      ENDIF.
    135
      IF sy-subrc <> 0.
    136
        CLEAR l_message.
    137
        l_txt = sy-subrc.
    138
        CONDENSE l_txt.
    139
        CONCATENATE 'RC=' l_txt ',' INTO l_txt.
    140
        PERFORM get_message_text USING 'MEREP_00' '245'
    141
                                       l_txt space space space
    142
                                 CHANGING l_message.
    143
        CONCATENATE l_message l_uri INTO l_message SEPARATED BY space.
    144
        WRITE / l_message.
    145
      ELSE.
    146
        CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
    147
          EXPORTING
    148
            text = l_infoline.
    149
      ENDIF.
    150
    151
    ENDFORM.                    "download
    152
    153
    154
    *-----------------------------------------------------------------------
    155
    * form: download_binary
    156
    *-----------------------------------------------------------------------
    157
    FORM download_binary
    158
      USING
    159
        it_content TYPE it_o2content_binary
    160
        value(i_bin_filesize) TYPE i
    161
        value(i_pgmid)
    162
        value(i_object)
    163
        value(i_filename)
    164
        value(i_extension)
    165
        value(i_do_count).
    166
    167
      DATA:
    168
      l_infoline TYPE syucomm,
    169
      l_uri TYPE string,
    170
      l_sub_uri TYPE char255,
    171
      l_txt TYPE string,
    172
      l_message TYPE string.
    173
    174
      PERFORM download_get_params
    175
        USING
    176
          i_pgmid
    177
          i_object
    178
          i_filename
    179
          i_extension
    180
          i_do_count
    181
        CHANGING
    182
          l_uri
    183
          l_sub_uri
    184
          l_infoline.
    185
    186
      IF g_has_download_status = abap_true.
    187
        CALL FUNCTION 'GUI_DOWNLOAD'
    188
          EXPORTING
    189
            bin_filesize         = i_bin_filesize
    190
            filename             = l_uri
    191
            filetype             = 'BIN'
    192
            show_transfer_status = abap_false
    193
          TABLES
    194
            data_tab             = it_content
    195
          EXCEPTIONS
    196
            OTHERS               = 2.
    197
      ELSE.
    198
        CALL FUNCTION 'GUI_DOWNLOAD'
    199
          EXPORTING
    200
            bin_filesize = i_bin_filesize
    201
            filename     = l_uri
    202
            filetype     = 'BIN'
    203
          TABLES
    204
            data_tab     = it_content
    205
          EXCEPTIONS
    206
            OTHERS       = 2.
    207
      ENDIF.
    208
      IF sy-subrc <> 0.
    209
        CLEAR l_message.
    210
        l_txt = sy-subrc.
    211
        CONDENSE l_txt.
    212
        CONCATENATE 'RC=' l_txt ',' INTO l_txt.
    213
        PERFORM get_message_text USING 'MEREP_00' '245'
    214
                                       l_txt space space space
    215
                                 CHANGING l_message.
    216
        CONCATENATE l_message l_uri INTO l_message SEPARATED BY space.
    217
        WRITE / l_message.
    218
      ELSE.
    219
        CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
    220
          EXPORTING
    221
            text = l_infoline.
    222
      ENDIF.
    223
    224
    ENDFORM.                    "download_binary
    225
    226
    227
    *-----------------------------------------------------------------------
    228
    * form: download_get_params
    229
    *-----------------------------------------------------------------------
    230
    FORM download_get_params
    231
      USING
    232
        value(i_pgmid)
    233
        value(i_object)
    234
        value(i_filename)
    235
        value(i_extension)
    236
        value(i_do_count)
    237
      CHANGING
    238
        c_uri TYPE string
    239
        c_sub_uri TYPE char255
    240
        c_infoline TYPE syucomm.
    241
    242
      DATA:
    243
      l_cnt_downloads TYPE string,
    244
      l_cnt_elems TYPE string,
    245
      l_txt TYPE string,
    246
      l_message TYPE string,
    247
      l_codepage(20) TYPE c.
    248
    249
      CLEAR:
    250
      c_uri,
    251
      c_sub_uri,
    252
      c_infoline.
    253
    254
      IF i_do_count = abap_true.
    255
        g_cnt_downloads = g_cnt_downloads + 1.
    256
      ENDIF.
    257
    258
    * new text for infoline
    259
      l_cnt_downloads = g_cnt_downloads.
    260
      CONDENSE l_cnt_downloads.
    261
      l_cnt_elems = g_cnt_elems.
    262
      CONDENSE l_cnt_elems.
    263
      PERFORM get_message_text USING 'DSVAS' '226'
    264
                                   i_filename space space space
    265
                             CHANGING l_message.
    266
      CONCATENATE
    267
        l_cnt_downloads '/' l_cnt_elems '|'
    268
        l_message INTO c_infoline
    269
        SEPARATED BY space.
    270
    271
    272
    273
    * uri from top folder to file
    274
      IF NOT i_pgmid IS INITIAL AND NOT i_object IS INITIAL.
    275
        CONCATENATE c_uri i_pgmid '_' i_object gc_delimiter INTO c_uri.
    276
      ENDIF.
    277
      CONCATENATE c_uri i_filename INTO c_uri.
    278
      IF NOT i_extension IS INITIAL.
    279
        CONCATENATE c_uri '.' i_extension INTO c_uri.
    280
      ENDIF.
    281
    282
      PERFORM download_make_plain_uri CHANGING c_uri.
    283
    284
      c_sub_uri = c_uri.
    285
      IF c_sub_uri+0(1) = gc_delimiter.
    286
        c_sub_uri = c_sub_uri+1.
    287
      ENDIF.
    288
      c_uri = c_sub_uri.
    289
    290
    * full uri
    291
      CONCATENATE g_folder gc_delimiter g_pack gc_delimiter c_uri
    292
          INTO c_uri.
    293
      PERFORM download_make_plain_uri CHANGING c_uri.
    294
    295
    ENDFORM.                    "download_get_params
    296
    297
    298
    *-----------------------------------------------------------------------
    299
    * form: download_make_plain_uri
    300
    *-----------------------------------------------------------------------
    301
    FORM download_make_plain_uri
    302
      CHANGING
    303
        c_uri TYPE string.
    304
    305
      DATA:
    306
      l_dbl_delimiter TYPE string.
    307
    308
      CONCATENATE gc_delimiter gc_delimiter INTO l_dbl_delimiter.
    309
      PERFORM replace_all
    310
        USING '/' gc_delimiter
    311
        CHANGING c_uri.
    312
      PERFORM replace_all
    313
        USING '<' '-'
    314
        CHANGING c_uri.
    315
      PERFORM replace_all
    316
        USING '>' '-'
    317
        CHANGING c_uri.
    318
      WHILE c_uri CS l_dbl_delimiter.
    319
        PERFORM replace_all
    320
          USING l_dbl_delimiter gc_delimiter
    321
          CHANGING c_uri.
    322
      ENDWHILE.
    323
    324
    ENDFORM.                    "download_replace_wildcards
    325
    326
    327
    *-----------------------------------------------------------------------
    328
    * form: download_replace_wildcards
    329
    *-----------------------------------------------------------------------
    330
    FORM download_replace_wildcards
    331
      USING
    332
        value(i_sub_uri) TYPE char255
    333
      CHANGING
    334
        ct_html TYPE it_string.
    335
    336
      DATA:
    337
      l_index_htm TYPE char255,
    338
      l_cnt TYPE i,
    339
      l_len TYPE i.
    340
    341
      CONSTANTS:
    342
      lc_replacements TYPE i VALUE 2.
    343
    344
      FIELD-SYMBOLS:
    345
      <ls_html> TYPE string.
    346
    347
      l_len = strlen( i_sub_uri ).
    348
    349
    * make replacement for ../index.htm
    350
      CONCATENATE 'index.' gc_extension_htm
    351
          INTO l_index_htm.
    352
      DO l_len TIMES.
    353
        IF i_sub_uri+l_cnt(1) = gc_delimiter.
    354
          CONCATENATE '../' l_index_htm INTO l_index_htm.
    355
        ENDIF.
    356
        ADD 1 TO l_cnt.
    357
      ENDDO.
    358
    359
    * replace
    360
      CLEAR l_cnt.
    361
      LOOP AT ct_html ASSIGNING <ls_html>.
    362
        IF <ls_html> CS '../index.htm'.
    363
          PERFORM replace_all
    364
            USING
    365
              '##INDEX_HTM##'
    366
              l_index_htm
    367
            CHANGING
    368
              <ls_html>.
    369
          ADD 1 TO l_cnt.
    370
        ENDIF.
    371
        IF l_cnt = lc_replacements.
    372
          EXIT.
    373
        ENDIF.
    374
      ENDLOOP.
    375
    376
    ENDFORM.                    "download_replace_wildcards