-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathfile-upload.sublime-snippet
83 lines (77 loc) · 2.59 KB
/
file-upload.sublime-snippet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<snippet>
<content><![CDATA[
PARAMETERS p_fname TYPE localfile OBLIGATORY DEFAULT 'C:\temp\input.txt'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
PERFORM get_file_name USING ',*.TXT.' CHANGING p_fname.
*&---------------------------------------------------------------------*
*& Form upload_file
*&---------------------------------------------------------------------*
FORM upload_file.
DATA: l_filename TYPE string,
BEGIN OF ls_file,
${1:line TYPE string},
END OF ls_file,
lt_file LIKE TABLE OF ls_file.
l_filename = p_fname.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_filename
filetype = 'ASC'
codepage = '4310' "UTF-8
CHANGING
data_tab = lt_file
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.
IF sy-subrc = 0.
LOOP AT lt_file INTO ls_file.
${0:"write some code here...}
ENDLOOP.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. "upload_file
*---------------------------------------------------------------------*
* FORM get_file_name *
*---------------------------------------------------------------------*
FORM get_file_name USING p_mask
CHANGING p_file LIKE rlgrap-filename.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = p_file
def_path = 'C:\'
mask = p_mask
mode = '0'
title = ''
IMPORTING
filename = p_file
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
ENDFORM. "get_file_name
]]></content>
<tabTrigger>file-up</tabTrigger>
<scope>source.abp</scope>
<description>File upload</description>
</snippet>