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 | SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t_choice. |
33 |
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 |
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 |
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 |
97 |
98 | INITIALIZATION. |
99 |
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 |
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 |
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 |
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 |
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 |