Properties | SourceCde
Title | Database - upload gui |
Original language | DE | Englisch
Created | 24.08.2012 |  | CREYTZ |
Last changed by | 23.02.2021 |  | CREYTZ |
Status | Active |
Attributes
Type | INCLUDE program |
Status | Customer production program |
Application |  |
Authorization Group |  |
Package | ZDB | database
| Editor lock
txt
    1
    *&---------------------------------------------------------------------*
    2
    *&  Include           ZDB_UPLOAD_GUI                                   *
    3
    *&                                                                     *
    4
    *&---------------------------------------------------------------------*
    5
    *&                                                                     *
    6
    *& This file is part of ZDB.                                           *
    7
    *&                                                                     *
    8
    *& ZDB_DOWNLOAD is free software: you can redistribute it and/or       *
    9
    *& modify it under the terms of the GNU General Public License as      *
    10
    *& published by the Free Software Foundation, either version 3 of the  *
    11
    *& License, or any later version.                                      *
    12
    *&                                                                     *
    13
    *& ZDB_DOWNLOAD 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
    *  Selection screen declaration
    31
    *-----------------------------------------------------------------------
    32
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t_choice.
    33
    * File
    34
    SELECTION-SCREEN BEGIN OF LINE.
    35
    SELECTION-SCREEN COMMENT 1(25) t_file.
    36
    PARAMETERS p_file LIKE rlgrap-filename MEMORY ID mfile.
    37
    SELECTION-SCREEN END OF LINE.
    38
    * Database
    39
    SELECTION-SCREEN ULINE.
    40
    SELECTION-SCREEN BEGIN OF LINE.
    41
    SELECTION-SCREEN COMMENT 1(25) t_db.
    42
    PARAMETERS p_db LIKE dd02l-tabname MEMORY ID mfile.
    43
    SELECTION-SCREEN END OF LINE.
    44
    SELECTION-SCREEN: END OF BLOCK b1.
    45
    46
    SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE t_opts.
    47
    SELECTION-SCREEN BEGIN OF LINE.
    48
    SELECTION-SCREEN COMMENT 1(25) t_clear.
    49
    PARAMETERS p_clear AS CHECKBOX DEFAULT abap_true.
    50
    SELECTION-SCREEN END OF LINE.
    51
    SELECTION-SCREEN: END OF BLOCK b2.
    52
    53
    54
    *-----------------------------------------------------------------------
    55
    * Display a file picker window
    56
    *-----------------------------------------------------------------------
    57
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    58
    59
      DATA:
    60
      s_obj_file TYPE REF TO cl_gui_frontend_services,
    61
      st_picked_file TYPE filetable,
    62
      ss_picked_file TYPE file_table,
    63
      s_initial_file TYPE string,
    64
      s_rc TYPE i.
    65
    66
      IF sy-batch IS INITIAL.
    67
        CREATE OBJECT s_obj_file.
    68
    69
        IF NOT p_file IS INITIAL.
    70
          s_initial_file = p_file.
    71
        ELSE.
    72
          CALL METHOD s_obj_file->get_temp_directory
    73
            CHANGING
    74
              temp_dir = s_initial_file
    75
            EXCEPTIONS
    76
              OTHERS   = 1.
    77
        ENDIF.
    78
    79
        CALL METHOD s_obj_file->file_open_dialog
    80
          CHANGING
    81
            file_table = st_picked_file
    82
            rc         = s_rc
    83
          EXCEPTIONS
    84
            OTHERS     = 1.
    85
    86
        IF sy-subrc = 0.
    87
          READ TABLE st_picked_file INTO ss_picked_file INDEX 1.
    88
          p_file = ss_picked_file-filename.
    89
        ELSE.
    90
          WRITE: / text-001.
    91
        ENDIF.
    92
      ENDIF.
    93
    94
    95
    *-----------------------------------------------------------------------
    96
    *  Initialization
    97
    *-----------------------------------------------------------------------
    98
    INITIALIZATION.
    99
    * screen texts
    100
      t_choice = 'Choice'.
    101
      t_clear  = 'Clear old DB content'.
    102
      t_db     = 'Database'.
    103
      t_file   = 'File'.
    104
      t_opts   = 'Options'.
    105
    106
    107
    *-----------------------------------------------------------------------
    108
    * start-of-selection
    109
    *-----------------------------------------------------------------------
    110
    START-OF-SELECTION.
    111
      CLEAR:
    112
      g_file,
    113
      g_tabname.
    114
    115
      IF p_db IS INITIAL.
    116
        WRITE: / text-005.
    117
      ELSEIF p_file IS INITIAL.
    118
        WRITE: / text-006.
    119
      ELSE.
    120
    *DB-Table
    121
        g_tabname = p_db.
    122
        SELECT SINGLE tabname FROM dd02l INTO g_tabname
    123
            WHERE tabname = g_tabname
    124
            AND as4local = 'A'
    125
            AND tabclass = 'TRANSP'.
    126
        IF sy-subrc <> 0.
    127
          CLEAR g_tabname.
    128
        ENDIF.
    129
    *Other Parameters
    130
        g_file = p_file.
    131
        g_clear = p_clear.
    132
      ENDIF.
    133
    134
    END-OF-SELECTION.
    135
    136
      IF NOT g_tabname IS INITIAL.
    137
        PERFORM start_upload.
    138
    139
        WRITE: 'Database table has been uploaded successfully.'.
    140
      ENDIF.
    141
    142
    143
    *-----------------------------------------------------------------------
    144
    * form: start_upload
    145
    *-----------------------------------------------------------------------
    146
    FORM start_upload.
    147
      DATA:
    148
      l_it_string TYPE it_string.
    149
    150
      IF g_clear = abap_true.
    151
        DELETE FROM (g_tabname).
    152
      ENDIF.
    153
    154
      PERFORM upload CHANGING l_it_string.
    155
    156
      PERFORM csv2data USING g_tabname l_it_string.
    157
    158
    ENDFORM.                    "start_upload