Properties SourceCde
txt
1
*&---------------------------------------------------------------------*
2
*&  Include           ZDB_DOWNLOAD_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
* Package
34
SELECTION-SCREEN BEGIN OF LINE.
35
SELECTION-SCREEN COMMENT 1(22) t_pack.
36
SELECT-OPTIONS p_pack FOR tdevc-devclass.
37
SELECTION-SCREEN END OF LINE.
38
* Database
39
SELECTION-SCREEN BEGIN OF LINE.
40
SELECTION-SCREEN COMMENT 1(22) t_db.
41
SELECT-OPTIONS p_db FOR dd02l-tabname.
42
SELECTION-SCREEN END OF LINE.
43
*Folder
44
SELECTION-SCREEN ULINE.
45
SELECTION-SCREEN BEGIN OF LINE.
46
SELECTION-SCREEN COMMENT 1(25) t_path.
47
PARAMETERS: p_folder LIKE rlgrap-filename MEMORY ID mfolder.
48
SELECTION-SCREEN END OF LINE.
49
SELECTION-SCREEN: END OF BLOCK b1.
50
 
51
SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE t_opts.
52
SELECTION-SCREEN BEGIN OF LINE.
53
SELECTION-SCREEN COMMENT 1(25) t_format.
54
PARAMETERS p_csv AS CHECKBOX DEFAULT abap_true.
55
SELECTION-SCREEN COMMENT 29(15) t_csv.
56
PARAMETERS p_xml AS CHECKBOX DEFAULT abap_true.
57
SELECTION-SCREEN COMMENT 47(15) t_xml.
58
SELECTION-SCREEN END OF LINE.
59
SELECTION-SCREEN BEGIN OF LINE.
60
SELECTION-SCREEN COMMENT 1(25) t_max.
61
PARAMETERS p_max TYPE i DEFAULT 500.
62
SELECTION-SCREEN END OF LINE.
63
SELECTION-SCREEN: END OF BLOCK b2.
64
 
65
 
66
*-----------------------------------------------------------------------
67
* Display a directory picker window
68
*-----------------------------------------------------------------------
69
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_folder.
70
 
71
  DATA:
72
  s_obj_file TYPE REF TO cl_gui_frontend_services,
73
  s_picked_folder TYPE string,
74
  s_initial_folder TYPE string.
75
 
76
  IF sy-batch IS INITIAL.
77
    CREATE OBJECT s_obj_file.
78
 
79
    IF NOT p_folder IS INITIAL.
80
      s_initial_folder = p_folder.
81
    ELSE.
82
      CALL METHOD s_obj_file->get_temp_directory
83
        CHANGING
84
          temp_dir = s_initial_folder
85
        EXCEPTIONS
86
          OTHERS   = 1.
87
    ENDIF.
88
 
89
    CALL METHOD s_obj_file->directory_browse
90
      EXPORTING
91
        initial_folder  = s_initial_folder
92
      CHANGING
93
        selected_folder = s_picked_folder
94
      EXCEPTIONS
95
        OTHERS          = 1.
96
 
97
    IF sy-subrc = 0.
98
      p_folder = s_picked_folder.
99
    ELSE.
100
      WRITE: / text-001.
101
    ENDIF.
102
  ENDIF.
103
 
104
 
105
*-----------------------------------------------------------------------
106
*  Initialization
107
*-----------------------------------------------------------------------
108
INITIALIZATION.
109
* screen texts
110
  t_choice = 'Choice'.
111
  t_csv    = gc_extension_csv.
112
  t_db     = 'Database'.
113
  t_format = 'Format'.
114
  t_max    = 'Max. no. of lines'.
115
  t_opts   = 'Options'.
116
  t_pack   = 'Package'.
117
  t_path   = 'Directory'.
118
  t_xml    = gc_extension_xml.
119
 
120
 
121
*-----------------------------------------------------------------------
122
* start-of-selection
123
*-----------------------------------------------------------------------
124
START-OF-SELECTION.
125
  DATA:
126
  lt_tadir TYPE STANDARD TABLE OF tadir,
127
  l_tabname TYPE tabname.
128
 
129
  FIELD-SYMBOLS:
130
  <ls_tadir> TYPE tadir.
131
 
132
  CLEAR:
133
  g_folder,
134
  g_add_db_format_csv,
135
  g_add_db_format_xml.
136
 
137
  g_add_db_max_lines = 500.
138
 
139
  REFRESH:
140
  gt_tadir.
141
 
142
  IF p_pack IS INITIAL AND p_db IS INITIAL.
143
    WRITE: / text-005.
144
  ELSEIF p_folder IS INITIAL.
145
    WRITE: / text-006.
146
  ELSEIF p_csv IS INITIAL AND p_xml IS INITIAL.
147
    WRITE: / text-014.
148
  ELSE.
149
*DB-Tables
150
    IF NOT p_pack IS INITIAL
151
    AND NOT p_db IS INITIAL.
152
      SELECT * FROM tadir
153
          INTO TABLE lt_tadir
154
          WHERE pgmid = 'R3TR'
155
          AND object = 'TABL'
156
          AND obj_name IN p_db
157
          AND devclass IN p_pack.
158
    ELSEIF NOT p_pack IS INITIAL.
159
      SELECT * FROM tadir
160
          INTO TABLE lt_tadir
161
          WHERE pgmid = 'R3TR'
162
          AND object = 'TABL'
163
          AND devclass IN p_pack.
164
    ELSEIF NOT p_db IS INITIAL.
165
      SELECT * FROM tadir
166
          INTO TABLE lt_tadir
167
          WHERE pgmid = 'R3TR'
168
          AND object = 'TABL'
169
          AND obj_name IN p_db.
170
    ENDIF.
171
    LOOP AT lt_tadir ASSIGNING <ls_tadir>.
172
      l_tabname = <ls_tadir>-obj_name.
173
      SELECT SINGLE tabname FROM dd02l INTO l_tabname
174
          WHERE tabname = l_tabname
175
          AND as4local = 'A'
176
          AND tabclass = 'TRANSP'.
177
      IF sy-subrc = 0.
178
        APPEND <ls_tadir> TO gt_tadir.
179
      ENDIF.
180
    ENDLOOP.
181
*Other Parameters
182
    g_folder = p_folder.
183
    g_add_db_format_csv = p_csv.
184
    g_add_db_format_xml = p_xml.
185
    g_add_db_max_lines = p_max.
186
  ENDIF.
187
 
188
END-OF-SELECTION.
189
 
190
  IF NOT gt_tadir IS INITIAL.
191
    PERFORM start_download.
192
 
193
    WRITE: 'Database tables have been downloaded successfully.'.
194
  ENDIF.
195
 
196
 
197
*-----------------------------------------------------------------------
198
* form: start_download
199
*-----------------------------------------------------------------------
200
FORM start_download.
201
  DATA:
202
  l_tabname TYPE tabname,
203
  lt_string TYPE it_string.
204
 
205
  FIELD-SYMBOLS:
206
  <ls_tadir> TYPE tadir.
207
 
208
  LOOP AT gt_tadir ASSIGNING <ls_tadir>.
209
    l_tabname = <ls_tadir>-obj_name.
210
    IF g_add_db_format_csv = abap_true.
211
      PERFORM data2csv
212
        USING l_tabname
213
        CHANGING lt_string.
214
      PERFORM download
215
        USING
216
          <ls_tadir>-devclass
217
          l_tabname
218
          gc_extension_csv
219
          lt_string.
220
    ENDIF.
221
    IF g_add_db_format_xml = abap_true.
222
      PERFORM data2xml
223
        USING l_tabname
224
        CHANGING lt_string.
225
      PERFORM download
226
        USING
227
          <ls_tadir>-devclass
228
          l_tabname
229
          gc_extension_xml
230
          lt_string.
231
    ENDIF.
232
  ENDLOOP.
233
 
234
ENDFORM.                    "start_download