ABAP/BC/Загрузка транспортных запросов

Материал из Викиучебника — открытых книг для открытого мира
Перейти к навигации Перейти к поиску

Без подтверждения и опций[править]

  1 *=======================================*
  2 * Автоматически сгенерированная         *
  3 * Программа загрузки транспортных       *
  4 * запросов                              *
  5 *=======================================*
  6  REPORT  zbc_request_upload.
  7  TYPE-POOLS: abap, sabc, stms.
  8  CONSTANTS: gc_tp_fillclient LIKE stpa-command
  9  VALUE 'FILLCLIENT'.
 10  DATA:
 11    lt_request TYPE stms_tr_requests,
 12    lt_tp_maintain TYPE stms_tp_maintains.
 13  DATA:
 14    sl TYPE i,
 15    l_datafile(255) TYPE c,
 16    datafiles TYPE i,
 17    ret TYPE i,
 18    ans TYPE c.
 19  DATA:
 20    et_request_infos TYPE stms_wbo_requests,
 21    request_info TYPE stms_wbo_request,
 22    system TYPE tmscsys-sysnam,
 23    request LIKE e070-trkorr.
 24  DATA:
 25    folder TYPE string,
 26    retval LIKE TABLE OF ddshretval WITH HEADER LINE,
 27    fldvalue LIKE help_info-fldvalue,
 28    transdir TYPE text255,
 29    filename LIKE authb-filename,
 30    trfile(20) TYPE c.
 31  DATA:
 32    BEGIN OF datatab OCCURS 0,
 33      buf(8192) TYPE c,
 34    END OF datatab.
 35  DATA: len TYPE i,
 36        flen TYPE i.
 37  SELECTION-SCREEN COMMENT /1(79) comm_sel.
 38  PARAMETERS:
 39  p_cofile(255) TYPE c LOWER CASE OBLIGATORY.
 40  SELECTION-SCREEN SKIP.
 41  SELECTION-SCREEN BEGIN OF BLOCK b01
 42  WITH FRAME TITLE bl_title.
 43  PARAMETERS:
 44    p_addque AS CHECKBOX DEFAULT abap_true,
 45    p_tarcli LIKE tmsbuffer-tarcli
 46             DEFAULT sy-mandt
 47             MATCHCODE OBJECT h_t000,
 48     p_sepr OBLIGATORY.
 49  SELECTION-SCREEN END OF BLOCK b01.
 50 
 51  INITIALIZATION.
 52    bl_title = 'Параметры очереди импорта'(b01).
 53    comm_sel =
 54  'Имя должно начинаться на ''K''.'(001).
 55    IF sy-opsys = 'Windows NT'.
 56      p_sepr = '\'.
 57    ELSE.
 58      p_sepr = '/'.
 59    ENDIF.
 60 
 61  AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_cofile.
 62    DATA:
 63      file TYPE file_table,
 64      rc TYPE i,
 65      title TYPE string,
 66      file_table TYPE filetable,
 67      file_filter TYPE string
 68  VALUE 'CO-файлы (K*.*)|K*.*||'.
 69    title = 'Выберите CO-файл'(006).
 70    CALL METHOD cl_gui_frontend_services=>file_open_dialog
 71      EXPORTING
 72        window_title            = title
 73        file_filter             = file_filter
 74      CHANGING
 75        file_table              = file_table
 76        rc                      = rc
 77      EXCEPTIONS
 78        file_open_dialog_failed = 1
 79        cntl_error              = 2
 80        error_no_gui            = 3
 81        not_supported_by_gui    = 4
 82        OTHERS                  = 5.
 83    IF sy-subrc <> 0.
 84      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
 85      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
 86    ENDIF.
 87    READ TABLE file_table INTO file INDEX 1.
 88    p_cofile = file.
 89 
 90  AT SELECTION-SCREEN.
 91    DATA:
 92     file TYPE string.
 93    sl = STRLEN( p_cofile ).
 94 
 95    IF sl < 11.
 96      MESSAGE e001(00)
 97      WITH 'Неверный формат имени co-файла.'
 98  'Имя файла должно быть - KNNNNNNN.SSS'(009).
 99    ENDIF.
100    sl = sl - 11.
101    IF p_cofile+sl(1) NE 'K'.
102      MESSAGE e001(00)
103      WITH 'Неверный формат имени co-файла.'
104  'Имя файла должно быть - KNNNNNNN.SSS'(009).
105    ENDIF.
106    sl = sl + 1.
107    IF NOT p_cofile+sl(6) CO '0123456789'.
108      MESSAGE e001(00)
109      WITH 'Неверный формат имени co-файла.'
110  'Имя файла должно быть - KNNNNNNN.SSS'(009).
111    ENDIF.
112    sl = sl + 6.
113    IF p_cofile+sl(1) NE '.'.
114      MESSAGE e001(00)
115      WITH 'Неверный формат имени co-файла.'
116  'Имя файла должно быть - KNNNNNNN.SSS'(009).
117    ENDIF.
118    sl = sl - 7.
119    CLEAR datafiles.
120    l_datafile = p_cofile.
121    l_datafile+sl(1) = 'R'.
122    file = l_datafile.
123    IF cl_gui_frontend_services=>file_exist( file = file ) =
124 abap_true.
125      ADD 1 TO datafiles.
126    ENDIF.
127    l_datafile+sl(1) = 'D'.
128    file = l_datafile.
129    IF cl_gui_frontend_services=>file_exist( file = file ) =
130 abap_true.
131      ADD 1 TO datafiles.
132    ENDIF.
133    sl = sl + 8.
134    request = p_cofile+sl(3).
135    sl = sl - 8.
136    CONCATENATE request p_cofile+sl(7) INTO request.
137    TRANSLATE request TO UPPER CASE.
138    IF datafiles = 0.
139      MESSAGE e398(00)
140      WITH 'Corresponding data-files of transport request'(010)
141      request
142      'not found.'(011).
143    ELSE .
144      MESSAGE s398(00)
145      WITH datafiles
146      'data-files have been found for transport request'(012)
147      request.
148    ENDIF.
149 
150  START-OF-SELECTION.
151    DATA:
152        parameter TYPE spar,
153        parameters TYPE TABLE OF spar.
154    CALL FUNCTION 'RSPO_R_SAPGPARAM'
155      EXPORTING
156        name   = 'DIR_TRANS'
157      IMPORTING
158        value  = transdir
159      EXCEPTIONS
160        error  = 1
161        OTHERS = 2.
162    IF sy-subrc <> 0.
163      MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
164      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
165    ENDIF.
166    filename = p_cofile+sl(11).
167    TRANSLATE filename TO UPPER CASE.
168    CONCATENATE transdir 'cofiles' filename
169      INTO filename
170    SEPARATED BY p_sepr.
171    OPEN DATASET filename FOR INPUT IN BINARY MODE.
172    ret = sy-subrc.
173    CLOSE DATASET filename.
174    trfile = p_cofile+sl(11).
175    TRANSLATE trfile TO UPPER CASE.
176    PERFORM copy_file USING 'cofiles' trfile p_cofile.
177    trfile(1) = 'R'.
178    l_datafile+sl(1) = 'R'.
179    PERFORM copy_file USING 'data' trfile l_datafile.
180    IF datafiles > 1.
181      trfile(1) = 'D'.
182      l_datafile+sl(1) = 'D'.
183      PERFORM copy_file USING 'data' trfile l_datafile.
184    ENDIF.
185    IF p_addque = abap_true.
186      system = sy-sysid.
187      DO 1 TIMES.
188 * check authority to add request to the import queue
189        CALL FUNCTION 'TR_AUTHORITY_CHECK_ADMIN'
190          EXPORTING
191            iv_adminfunction = 'TADD'
192          EXCEPTIONS
193            e_no_authority   = 1
194            e_invalid_user   = 2
195            OTHERS           = 3.
196        IF sy-subrc <> 0.
197          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
198          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
199          EXIT.
200        ENDIF.
201        DATA ls_exception LIKE stmscalert.
202        CALL FUNCTION 'TMS_MGR_FORWARD_TR_REQUEST'
203          EXPORTING
204            iv_request      = request
205            iv_target       = system
206            iv_tarcli       = p_tarcli
207            iv_import_again = abap_true
208            iv_monitor      = abap_true
209            iv_verbose      = abap_true
210          IMPORTING
211            es_exception    = ls_exception
212          EXCEPTIONS
213            OTHERS          = 99.
214        CHECK sy-subrc = 0.
215        CALL FUNCTION 'TMS_MGR_READ_TRANSPORT_REQUEST'
216          EXPORTING
217            iv_request                 = request
218            iv_target_system           = system
219          IMPORTING
220            et_request_infos           = et_request_infos
221          EXCEPTIONS
222            read_config_failed         = 1
223            table_of_requests_is_empty = 2
224            system_not_available       = 3
225            OTHERS                     = 4.
226        CLEAR request_info.
227        READ TABLE et_request_infos INTO request_info INDEX 1.
228        IF request_info-e070-korrdev = 'CUST'
229        AND NOT p_tarcli IS INITIAL.
230          CALL FUNCTION 'TMS_MGR_MAINTAIN_TR_QUEUE'
231            EXPORTING
232              iv_command                 = gc_tp_fillclient
233              iv_system                  = system
234              iv_request                 = request
235              iv_tarcli                  = p_tarcli
236              iv_monitor                 = abap_true
237              iv_verbose                 = abap_true
238            IMPORTING
239              et_tp_maintains            = lt_tp_maintain
240            EXCEPTIONS
241              read_config_failed         = 1
242              table_of_requests_is_empty = 2
243              OTHERS                     = 3.
244          IF sy-subrc <> 0.
245            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
246            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
247            EXIT.
248          ENDIF.
249        ENDIF.
250 * check authority to start request import
251        CALL FUNCTION 'TR_AUTHORITY_CHECK_ADMIN'
252          EXPORTING
253            iv_adminfunction = 'IMPS'
254          EXCEPTIONS
255            e_no_authority   = 1
256            e_invalid_user   = 2
257            OTHERS           = 3.
258 
259        IF sy-subrc <> 0.
260          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
261          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
262          EXIT.
263        ENDIF.
264        CALL FUNCTION 'TMS_MGR_IMPORT_TR_REQUEST'
265          EXPORTING
266            iv_system                  = system
267            iv_request                 = request
268            iv_client                  = p_tarcli
269          EXCEPTIONS
270            read_config_failed         = 1
271            table_of_requests_is_empty = 2
272            OTHERS                     = 3.
273      ENDDO.
274    ENDIF.
275 *&-------------------------------------------*
276 *& form copy_file
277 *&-------------------------------------------*
278 * text
279 *-----------------------------------------*
280 * -->subdir text
281 * -->fname text
282 * -->source_filetext
283 *-----------------------------------------*
284  FORM copy_file USING subdir fname source_file.
285    DATA: l_filename TYPE string.
286    DATA: lv_file_appl LIKE rcgfiletr-ftappl.
287    l_filename = source_file.
288    CONCATENATE transdir subdir fname
289      INTO filename
290      SEPARATED BY p_sepr.
291    REFRESH datatab.
292    lv_file_appl = filename.
293    CALL FUNCTION 'C13Z_FILE_UPLOAD_BINARY'
294      EXPORTING
295        i_file_front_end   = l_filename
296        i_file_appl        = lv_file_appl
297        i_file_overwrite   = abap_true
298      EXCEPTIONS
299        fe_file_not_exists = 1
300        fe_file_read_error = 2
301        ap_no_authority    = 3
302        ap_file_open_error = 4
303        ap_file_exists     = 5
304        OTHERS             = 6.
305    IF sy-subrc <> 0.
306      WRITE: / 'Файл'(005), trfile, ' ошибка загрузки'(007).
307      WRITE: / 'Проверьте ошибки в STMS'.
308    ELSE.
309      WRITE: / 'Файл'(005), trfile, ' успешно загружен'(007).
310      WRITE: / 'Проверьте статус импорта в STMS'.
311    ENDIF.
312  ENDFORM. "copy_file

С подтверждением и опциями[править]

  1 *======================================================================*
  2 * Initial idea and first release by Igor Yaskevitch (IBS), 2003        *
  3 * Enhancements by Sergei Korolev, 2005 (added import queue             *
  4 * manipulations, authority checking, minor interface improvements)     *
  5 *----------------------------------------------------------------------*
  6 * Function : This is a utility tool for uploading binary               *
  7 * files of a transport request from a Client PC,                       *
  8 * adding to an import queue and importing into the                     *
  9 * system.                                                              *
 10 *======================================================================*
 11 REPORT zbc_upload_transport_request.
 12 
 13 TYPE-POOLS: abap, sabc, stms.
 14 
 15 CONSTANTS: gc_tp_fillclient LIKE stpa-command VALUE 'FILLCLIENT'.
 16 DATA:
 17   lt_request TYPE stms_tr_requests,
 18   lt_tp_maintain TYPE stms_tp_maintains.
 19 
 20 DATA:
 21   sl TYPE i,
 22   l_datafile(255) TYPE c,
 23   datafiles TYPE i,
 24   ret TYPE i,
 25   ans TYPE c.
 26 
 27 DATA:
 28   et_request_infos TYPE stms_wbo_requests,
 29   request_info TYPE stms_wbo_request,
 30   system TYPE tmscsys-sysnam,
 31   request LIKE e070-trkorr.
 32 
 33 DATA:
 34   folder TYPE string,
 35   retval LIKE TABLE OF ddshretval WITH HEADER LINE,
 36   fldvalue LIKE help_info-fldvalue,
 37   transdir TYPE text255,
 38   filename LIKE authb-filename,
 39   trfile(20) TYPE c.
 40 
 41 DATA:
 42   BEGIN OF datatab OCCURS 0,
 43     buf(8192) TYPE c,
 44   END OF datatab.
 45 
 46 DATA: len TYPE i,
 47       flen TYPE i.
 48 
 49 SELECTION-SCREEN COMMENT /1(79) comm_sel.
 50 
 51 PARAMETERS:
 52 p_cofile(255) TYPE c LOWER CASE OBLIGATORY.
 53 
 54 SELECTION-SCREEN SKIP.
 55 
 56 SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE bl_title.
 57 
 58 PARAMETERS:
 59   p_addque AS CHECKBOX DEFAULT 'X',
 60   p_tarcli LIKE tmsbuffer-tarcli
 61            DEFAULT sy-mandt
 62            MATCHCODE OBJECT h_t000,
 63 
 64    p_sepr OBLIGATORY.
 65 
 66 SELECTION-SCREEN END OF BLOCK b01.
 67 
 68 INITIALIZATION.
 69   bl_title = 'Import queue parameters'(b01).
 70   comm_sel = 'Select co-file. Filename must start with ''K''.'(001).
 71   IF sy-opsys = 'Windows NT'.
 72     p_sepr = '\'.
 73   ELSE.
 74     p_sepr = '/'.
 75   ENDIF.
 76 **  CALL FUNCTION 'WSAF_BUILD_SEPARATOR'
 77 **    IMPORTING
 78 **      separator                  = p_sepr
 79 **    EXCEPTIONS
 80 **      separator_not_maintained   = 1
 81 **      wrong_call                 = 2
 82 **      wsaf_config_not_maintained = 3
 83 **      OTHERS                     = 4.
 84 *  IF sy-subrc NE 0.
 85 *    MESSAGE s001(00) WITH 'Unable to find out the separator symbol for the system.'(008).
 86 *  ENDIF.
 87 
 88 AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_cofile.
 89   DATA:
 90     file TYPE file_table,
 91     rc TYPE i,
 92     title TYPE string,
 93     file_table TYPE filetable,
 94     file_filter TYPE string VALUE 'CO-files (K*.*)|K*.*||'.
 95 
 96   title = 'Select CO-file'(006).
 97   CALL METHOD cl_gui_frontend_services=>file_open_dialog
 98     EXPORTING
 99       window_title            = title
100       file_filter             = file_filter
101     CHANGING
102       file_table              = file_table
103       rc                      = rc
104     EXCEPTIONS
105       file_open_dialog_failed = 1
106       cntl_error              = 2
107       error_no_gui            = 3
108       not_supported_by_gui    = 4
109       OTHERS                  = 5.
110   IF sy-subrc <> 0.
111     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
112     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
113   ENDIF.
114   READ TABLE file_table INTO file INDEX 1.
115   p_cofile = file.
116 
117 AT SELECTION-SCREEN.
118   DATA:
119   file TYPE string.
120   sl = STRLEN( p_cofile ).
121   IF sl < 11.
122     MESSAGE e001(00)
123     WITH 'Invalid co-file name format. File name format must be KNNNNNNN.SSS'(009).
124   ENDIF.
125   sl = sl - 11.
126   IF p_cofile+sl(1) NE 'K'.
127     MESSAGE e001(00)
128     WITH 'Invalid co-file name format. File name format must be KNNNNNNN.SSS'(009).
129   ENDIF.
130   sl = sl + 1.
131   IF NOT p_cofile+sl(6) CO '0123456789'.
132     MESSAGE e001(00)
133     WITH 'Invalid co-file name format. File name format must be KNNNNNNN.SSS'(009).
134   ENDIF.
135   sl = sl + 6.
136   IF p_cofile+sl(1) NE '.'.
137     MESSAGE e001(00)
138     WITH 'Invalid co-file name format. File name format must be KNNNNNNN.SSS'(009).
139   ENDIF.
140   sl = sl - 7.
141   CLEAR datafiles.
142   l_datafile = p_cofile.
143   l_datafile+sl(1) = 'R'.
144   file = l_datafile.
145   IF cl_gui_frontend_services=>file_exist( file = file ) = 'X'.
146     ADD 1 TO datafiles.
147   ENDIF.
148   l_datafile+sl(1) = 'D'.
149   file = l_datafile.
150   IF cl_gui_frontend_services=>file_exist( file = file ) = 'X'.
151     ADD 1 TO datafiles.
152   ENDIF.
153   sl = sl + 8.
154   request = p_cofile+sl(3).
155   sl = sl - 8.
156   CONCATENATE request p_cofile+sl(7) INTO request.
157   TRANSLATE request TO UPPER CASE.
158   IF datafiles = 0.
159     MESSAGE e398(00)
160     WITH 'Corresponding data-files of transport request'(010)
161     request
162     'not found.'(011).
163   ELSE.
164     MESSAGE s398(00)
165     WITH datafiles
166     'data-files have been found for transport request'(012)
167     request.
168   ENDIF.
169 
170 START-OF-SELECTION.
171   DATA:
172   parameter TYPE spar,
173   parameters TYPE TABLE OF spar.
174   CALL FUNCTION 'RSPO_R_SAPGPARAM'
175     EXPORTING
176       name   = 'DIR_TRANS'
177     IMPORTING
178       value  = transdir
179     EXCEPTIONS
180       error  = 1
181       OTHERS = 2.
182   IF sy-subrc <> 0.
183     MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
184     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
185   ENDIF.
186   filename = p_cofile+sl(11).
187   TRANSLATE filename TO UPPER CASE.
188   CONCATENATE transdir 'cofiles' filename
189   INTO filename
190   SEPARATED BY p_sepr.
191   OPEN DATASET filename FOR INPUT IN BINARY MODE.
192   ret = sy-subrc.
193   CLOSE DATASET filename.
194   IF NOT ret = 0.
195     CALL FUNCTION 'POPUP_TO_CONFIRM'
196       EXPORTING
197         text_question  = 'Copy all files?'(a03)
198       IMPORTING
199         answer         = ans
200       EXCEPTIONS
201         text_not_found = 1
202         OTHERS         = 2.
203   ELSE.
204     parameter-param = 'FILE'.
205     parameter-value = filename.
206     APPEND parameter TO parameters.
207     CALL FUNCTION 'POPUP_TO_CONFIRM'
208       EXPORTING
209         text_question  = 'File ''&FILE&'' already exists. Rewrite?'(a04)
210       IMPORTING
211         answer         = ans
212       TABLES
213         parameter      = parameters
214       EXCEPTIONS
215         text_not_found = 1
216         OTHERS         = 2.
217   ENDIF.
218   CHECK ans = '1'.
219   trfile = p_cofile+sl(11).
220   TRANSLATE trfile TO UPPER CASE.
221   PERFORM copy_file USING 'cofiles' trfile p_cofile.
222   trfile(1) = 'R'.
223   l_datafile+sl(1) = 'R'.
224   PERFORM copy_file USING 'data' trfile l_datafile.
225   IF datafiles > 1.
226     trfile(1) = 'D'.
227     l_datafile+sl(1) = 'D'.
228     PERFORM copy_file USING 'data' trfile l_datafile.
229   ENDIF.
230   IF p_addque = 'X'.
231     system = sy-sysid.
232     DO 1 TIMES.
233 * Check authority to add request to the import queue
234       CALL FUNCTION 'TR_AUTHORITY_CHECK_ADMIN'
235         EXPORTING
236           iv_adminfunction = 'TADD'
237         EXCEPTIONS
238           e_no_authority   = 1
239           e_invalid_user   = 2
240           OTHERS           = 3.
241       IF sy-subrc <> 0.
242         MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
243         WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
244         EXIT.
245       ENDIF.
246       CALL FUNCTION 'TMS_UI_APPEND_TR_REQUEST'
247         EXPORTING
248           iv_system             = system
249           iv_request            = request
250           iv_expert_mode        = 'X'
251           iv_ctc_active         = 'X'
252         EXCEPTIONS
253           cancelled_by_user     = 1
254           append_request_failed = 2
255           OTHERS                = 3.
256       CHECK sy-subrc = 0.
257       CALL FUNCTION 'TMS_MGR_READ_TRANSPORT_REQUEST'
258         EXPORTING
259           iv_request                 = request
260           iv_target_system           = system
261         IMPORTING
262           et_request_infos           = et_request_infos
263         EXCEPTIONS
264           read_config_failed         = 1
265           table_of_requests_is_empty = 2
266           system_not_available       = 3
267           OTHERS                     = 4.
268       CLEAR request_info.
269       READ TABLE et_request_infos INTO request_info INDEX 1.
270       IF request_info-e070-korrdev = 'CUST'
271       AND NOT p_tarcli IS INITIAL.
272         CALL FUNCTION 'TMS_MGR_MAINTAIN_TR_QUEUE'
273           EXPORTING
274             iv_command                 = gc_tp_fillclient
275             iv_system                  = system
276             iv_request                 = request
277             iv_tarcli                  = p_tarcli
278             iv_monitor                 = 'X'
279             iv_verbose                 = 'X'
280           IMPORTING
281             et_tp_maintains            = lt_tp_maintain
282           EXCEPTIONS
283             read_config_failed         = 1
284             table_of_requests_is_empty = 2
285             OTHERS                     = 3.
286         IF sy-subrc <> 0.
287           MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
288           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
289           EXIT.
290         ENDIF.
291       ENDIF.
292 * Check authority to start request import
293       CALL FUNCTION 'TR_AUTHORITY_CHECK_ADMIN'
294         EXPORTING
295           iv_adminfunction = 'IMPS'
296         EXCEPTIONS
297           e_no_authority   = 1
298           e_invalid_user   = 2
299           OTHERS           = 3.
300       IF sy-subrc <> 0.
301         MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
302         WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
303         EXIT.
304       ENDIF.
305       CALL FUNCTION 'TMS_UI_IMPORT_TR_REQUEST'
306         EXPORTING
307           iv_system             = system
308           iv_request            = request
309           iv_tarcli             = p_tarcli
310           iv_some_active        = space
311         EXCEPTIONS
312           cancelled_by_user     = 1
313           import_request_denied = 2
314           import_request_failed = 3
315           OTHERS                = 4.
316     ENDDO.
317   ENDIF.
318 *&--------------------------------------------------------------------*
319 *& Form copy_file
320 *&--------------------------------------------------------------------*
321 * text
322 *---------------------------------------------------------------------*
323 * -->SUBDIR text
324 * -->FNAME text
325 * -->SOURCE_FILEtext
326 *---------------------------------------------------------------------*
327 FORM copy_file USING subdir fname source_file.
328   DATA: l_filename TYPE string.
329   l_filename = source_file.
330   CONCATENATE transdir subdir fname
331   INTO filename
332   SEPARATED BY p_sepr.
333   REFRESH datatab.
334 **  CLEAR flen.
335 **  CALL METHOD cl_gui_frontend_services=>gui_upload
336 **    EXPORTING
337 **      filename                = l_filename
338 **      filetype                = 'BIN'
339 **    IMPORTING
340 **      filelength              = flen
341 **    CHANGING
342 **      data_tab                = datatab[]
343 **    EXCEPTIONS
344 **      file_open_error         = 1
345 **      file_read_error         = 2
346 **      no_batch                = 3
347 **      gui_refuse_filetransfer = 4
348 **      invalid_type            = 5
349 **      no_authority            = 6
350 **      unknown_error           = 7
351 **      bad_data_format         = 8
352 **      header_not_allowed      = 9
353 **      separator_not_allowed   = 10
354 **      header_too_long         = 11
355 **      unknown_dp_error        = 12
356 **      access_denied           = 13
357 **      dp_out_of_memory        = 14
358 **      disk_full               = 15
359 **      dp_timeout              = 16
360 **      not_supported_by_gui    = 17
361 **      error_no_gui            = 18
362 **      OTHERS                  = 19.
363 **  IF sy-subrc NE 0.
364 **    WRITE: / 'Error uploading file'(003), l_filename.
365 **    EXIT.
366 **  ENDIF.
367 **  CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
368 **    EXPORTING
369 **      activity         = sabc_act_write
370 **      filename         = filename
371 **    EXCEPTIONS
372 **      no_authority     = 1
373 **      activity_unknown = 2
374 **      OTHERS           = 3.
375 **  IF sy-subrc <> 0.
376 **    FORMAT COLOR COL_NEGATIVE.
377 **    WRITE: / 'Write access denied. File'(013), filename.
378 **    FORMAT COLOR OFF.
379 **    EXIT.
380 **  ENDIF.
381 **  OPEN DATASET filename FOR OUTPUT IN BINARY MODE.
382 **  IF sy-subrc NE 0.
383 **    WRITE: / 'File open error'(004), trfile.
384 **    EXIT.
385 **  ENDIF.
386 **  LOOP AT datatab.
387 **    IF flen < 8192.
388 **      len = flen.
389 **    ELSE.
390 **      len = 8192.
391 **    ENDIF.
392 **    TRANSFER datatab-buf TO filename LENGTH len.
393 **    flen = flen - len.
394 **  ENDLOOP.
395 **  CLOSE DATASET filename.
396 
397   DATA lv_file_appl LIKE rcgfiletr-ftappl.
398 
399   lv_file_appl = filename.
400 
401   CALL FUNCTION 'C13Z_FILE_UPLOAD_BINARY'
402     EXPORTING
403       i_file_front_end         = l_filename
404       i_file_appl              = lv_file_appl
405       i_file_overwrite         = 'X'
406 *   IMPORTING
407 *     E_FLG_OPEN_ERROR         =
408 *     E_OS_MESSAGE             =
409    EXCEPTIONS
410      fe_file_not_exists       = 1
411      fe_file_read_error       = 2
412      ap_no_authority          = 3
413      ap_file_open_error       = 4
414      ap_file_exists           = 5
415      OTHERS                   = 6
416             .
417   IF sy-subrc <> 0.
418     WRITE: / 'File'(005), trfile, 'upload error'(007).
419   ELSE.
420     WRITE: / 'File'(005), trfile, 'uploaded'(007).
421   ENDIF.
422 ENDFORM. "copy_file