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.
32.
33.
DATA:
BEGIN OF datatab OCCURS 0,
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.
49.
p_sepr OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b01.
50.
51.
INITIALIZATION.
52.
bl_title = ' '(b01).
53.
comm_sel =
54.
' ''K''.'(001).
55.
56.
57.
58.
59.
IF sy-opsys = 'Windows NT'.
p_sepr = '\'.
ELSE.
p_sepr = '/'.
ENDIF.
60.
61.
62.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_cofile.
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.
83.
OTHERS
= 5.
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.
91.
92.
93.
AT SELECTION-SCREEN.
DATA:
file TYPE string.
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.
110.
WITH ' co-.'
' - 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.
125.
abap_true.
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.
131.
abap_true.
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.
151.
START-OF-SELECTION.
DATA:
152.
parameter TYPE spar,
153.
parameters TYPE TABLE OF spar.
154.
CALL FUNCTION 'RSPO_R_SAPGPARAM'
155.
EXPORTING
156.
name
157.
IMPORTING
158.
value
159.
EXCEPTIONS
160.
error
161.
OTHERS = 2.
162.
= 'DIR_TRANS'
= transdir
= 1
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.
189.
* check authority to add request to the import queue
CALL FUNCTION 'TR_AUTHORITY_CHECK_ADMIN'
190.
191.
192.
EXPORTING
iv_adminfunction = 'TADD'
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.
211.
IMPORTING
es_exception
212.
EXCEPTIONS
213.
OTHERS
= ls_exception
= 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.
220.
221.
IMPORTING
et_request_infos
= et_request_infos
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.
231.
CALL FUNCTION 'TMS_MGR_MAINTAIN_TR_QUEUE'
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.
239.
240.
IMPORTING
et_tp_maintains
= lt_tp_maintain
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.
249.
250.
251.
252.
253.
254.
ENDIF.
ENDIF.
* check authority to start request import
CALL FUNCTION 'TR_AUTHORITY_CHECK_ADMIN'
EXPORTING
iv_adminfunction = 'IMPS'
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.
270.
EXCEPTIONS
read_config_failed
= 1
271.
table_of_requests_is_empty = 2
272.
OTHERS
273.
274.
= 3.
ENDDO.
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
302.
ap_file_open_error = 4
303.
ap_file_exists
= 5
304.
OTHERS
= 6.
305.
= 3
IF sy-subrc <> 0.
306.
WRITE: / ''(005), trfile, ' '(007).
307.
WRITE: / ' STMS'.
308.
ELSE.
309.
WRITE: / ''(005), trfile, ' '(007).
310.
WRITE: / ' STMS'.
311.
312.
ENDIF.
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.
42.
43.
44.
DATA:
BEGIN OF datatab OCCURS 0,
buf(8192) TYPE c,
END OF datatab.
45.
46.
47.
DATA: len TYPE i,
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.
**
78.
**
79.
**
80.
**
separator_not_maintained
= 1
81.
**
wrong_call
= 2
82.
**
wsaf_config_not_maintained = 3
83.
**
OTHERS
84.
IF sy-subrc NE 0.
IMPORTING
separator
= p_sepr
EXCEPTIONS
= 4.
85.
*
MESSAGE s001(00) WITH 'Unable to find out the separator symbol for
the system.'(008).
86.
ENDIF.
87.
88.
89.
90.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_cofile.
DATA:
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.
169.
ENDIF.
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
177.
IMPORTING
178.
value
179.
EXCEPTIONS
180.
error
181.
OTHERS = 2.
182.
= 'DIR_TRANS'
= transdir
= 1
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.
196.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
197.
text_question
198.
IMPORTING
199.
answer
200.
EXCEPTIONS
= 'Copy all files?'(a03)
= ans
201.
text_not_found = 1
202.
OTHERS
203.
= 2.
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
Rewrite?'(a04)
210.
IMPORTING
211.
answer
212.
= ans
TABLES
213.
214.
= 'File ''&FILE&'' already exists.
parameter
= parameters
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.
236.
237.
EXPORTING
iv_adminfunction = 'TADD'
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.
262.
263.
IMPORTING
et_request_infos
= et_request_infos
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.
273.
CALL FUNCTION 'TMS_MGR_MAINTAIN_TR_QUEUE'
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.
282.
et_tp_maintains
= lt_tp_maintain
EXCEPTIONS
283.
read_config_failed
284.
table_of_requests_is_empty = 2
285.
OTHERS
286.
= 1
= 3.
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.
291.
292.
293.
294.
295.
296.
ENDIF.
ENDIF.
* Check authority to start request import
CALL FUNCTION 'TR_AUTHORITY_CHECK_ADMIN'
EXPORTING
iv_adminfunction = 'IMPS'
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
313.
import_request_denied = 2
314.
import_request_failed = 3
315.
OTHERS
316.
317.
= 1
= 4.
ENDDO.
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.
**
337.
**
filename
= l_filename
338.
**
filetype
= 'BIN'
339.
**
340.
**
341.
**
342.
**
data_tab
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
EXPORTING
IMPORTING
filelength
= flen
CHANGING
= datatab[]
358.
**
disk_full
= 15
359.
**
dp_timeout
= 16
360.
**
not_supported_by_gui
= 17
361.
**
error_no_gui
= 18
362.
**
OTHERS
= 19.
363.
**
364.
**
WRITE: / 'Error uploading file'(003), l_filename.
365.
**
EXIT.
366.
**
ENDIF.
367.
**
CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
368.
**
369.
**
activity
= sabc_act_write
370.
**
filename
= filename
371.
**
EXCEPTIONS
372.
**
no_authority
373.
**
activity_unknown = 2
374.
**
OTHERS
375.
**
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.
IF sy-subrc NE 0.
EXPORTING
= 1
= 3.
IF sy-subrc <> 0.
385.
**
ENDIF.
386.
**
LOOP AT datatab.
387.
**
IF flen < 8192.
388.
**
len = flen.
389.
**
390.
**
391.
**
ENDIF.
392.
**
TRANSFER datatab-buf TO filename LENGTH len.
393.
**
flen = flen - len.
394.
**
ENDLOOP.
395.
**
CLOSE DATASET filename.
ELSE.
len = 8192.
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.
407.
E_FLG_OPEN_ERROR
408.
E_OS_MESSAGE
409.
IMPORTING
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.
418.
419.
420.
421.
422.
.
IF sy-subrc <> 0.
WRITE: / 'File'(005), trfile, 'upload error'(007).
ELSE.
WRITE: / 'File'(005), trfile, 'uploaded'(007).
ENDIF.
ENDFORM. "copy_file