IT干货网

ABAP-FTP-配置

shasha 2022年03月09日 SAP 999 0

1.FTP配置:

  设置FTP参数:IP地址、账号、密码、路径、RFC目标。

  设置数据表:数据表及字段明细,设置查询字段及报表输出字段。

2.操作界面 

3.程序 ZFID0003_ETL_FTP

 主程序:

 1 *&---------------------------------------------------------------------* 
 2 *& Report  ZFID0003_ETL_FTP 
 3 *& 
 4 *&---------------------------------------------------------------------* 
 5 *& 
 6 *& 
 7 *&---------------------------------------------------------------------* 
 8  
 9 report  zfid0003_etl_ftp. 
10  
11 include zfid0003_etl_ftp_cls. 
12  
13 include zfid0003_etl_ftp_top. 
14  
15 include zfid0003_etl_ftp_scr. 
16  
17 include zfid0003_etl_ftp_pro. 
18  
19 include zfid0003_etl_ftp_frm.
View Code

 Include程序:

 1 *&---------------------------------------------------------------------* 
 2 *&  包括              ZFID0003_ETL_FTP_CLS 
 3 *&---------------------------------------------------------------------* 
 4  
 5 *----------------------------------------------------------------------* 
 6 *       CLASS lcl_alv_event_handler DEFINITION 
 7 *----------------------------------------------------------------------* 
 8 * 
 9 *----------------------------------------------------------------------* 
10 class lcl_alv_event_handler definition. 
11   public section. 
12     methods: 
13       handle_double_click   for event double_click 
14                             of cl_gui_alv_grid 
15                             importing e_row e_column es_row_no, 
16  
17       handle_hotspot_click  for event hotspot_click 
18                             of cl_gui_alv_grid 
19                             importing e_row_id e_column_id es_row_no, 
20  
21       handle_toolbar        for event toolbar 
22                             of cl_gui_alv_grid 
23                             importing e_object e_interactive, 
24  
25       handle_toolbar_itm    for event toolbar 
26                             of cl_gui_alv_grid 
27                             importing e_object e_interactive, 
28  
29       handle_f4             for event onf4 
30                             of cl_gui_alv_grid 
31                             importing e_fieldname e_fieldvalue es_row_no er_event_data et_bad_cells, 
32  
33       handle_command_ftp    for event user_command 
34                             of cl_gui_alv_grid 
35                             importing e_ucomm, 
36  
37       handle_command_tabhd  for event user_command 
38                             of cl_gui_alv_grid 
39                             importing e_ucomm, 
40  
41       handle_command_tabit  for event user_command 
42                             of cl_gui_alv_grid 
43                             importing e_ucomm. 
44 endclass.                    "lcl_alv_event_handler DEFINITION 
45  
46 *----------------------------------------------------------------------* 
47 *       CLASS lcl_alv_event_handler IMPLEMENTATION 
48 *----------------------------------------------------------------------* 
49 * 
50 *----------------------------------------------------------------------* 
51 class lcl_alv_event_handler implementation . 
52   "双击行显示错误日志 
53   method handle_double_click. 
54     perform handle_double_click using e_row. 
55     perform alv_refresh_display. 
56   endmethod.                    "handle_double_click 
57  
58   method handle_hotspot_click. 
59     perform handle_hotspot_clk using e_row_id 
60                                   e_column_id 
61                                   es_row_no. 
62   endmethod.                   "handle_1100_data_changed 
63  
64   method handle_toolbar. 
65     perform handle_toolbar using  e_object e_interactive. 
66   endmethod.                    "HANDLE_TOOLBAR 
67  
68   method handle_toolbar_itm. 
69     perform handle_toolbar_itm using  e_object e_interactive. 
70   endmethod.                    "HANDLE_TOOLBAR 
71  
72   method handle_f4. 
73     perform handle_f4 using e_fieldname e_fieldvalue es_row_no er_event_data et_bad_cells. 
74   endmethod.                                                "HANDLE_F4 
75  
76   method handle_command_ftp. 
77     perform alv_changed_data. 
78     perform handle_command_ftp using e_ucomm. 
79     perform alv_refresh_display. 
80   endmethod.                    "HANDLE_USER_COMMAND 
81  
82   method handle_command_tabhd. 
83     perform alv_changed_data. 
84     perform handle_command_tabhd using e_ucomm. 
85     perform alv_refresh_display. 
86   endmethod.                    "HANDLE_USER_COMMAND 
87  
88   method handle_command_tabit. 
89     perform alv_changed_data. 
90     perform handle_command_tabit using e_ucomm. 
91     perform alv_refresh_display. 
92   endmethod.                    "HANDLE_USER_COMMAND 
93  
94 endclass.                    "lcl_alv_event_handler IMPLEMENTATION
View Code
 1 *&---------------------------------------------------------------------* 
 2 *&  包括              ZFID0003_ETL_FTP_TOP 
 3 *&---------------------------------------------------------------------* 
 4  
 5 type-pools: 
 6   ole2. 
 7  
 8 tables: 
 9   ztfi0035_tab_hd, 
10   ztfi0036_tab_itm, 
11   ztfi0037_etl_ftp, 
12   sscrfields. 
13  
14 data: 
15   gt_tab_ftp like table of ztfi0037_etl_ftp, 
16   gt_tab_hd  like table of ztfi0035_tab_hd, 
17   gt_all_itm like table of ztfi0036_tab_itm, 
18   gt_tab_itm like table of ztfi0036_tab_itm. 
19  
20 field-symbols: 
21   <fs_tab_ftp> like ztfi0037_etl_ftp, 
22   <fs_tab_hd>  like ztfi0035_tab_hd, 
23   <fs_tab_itm> like ztfi0036_tab_itm. 
24  
25 *"ALV PARAMETERS 
26 data: 
27   go_docking_con        type ref to cl_gui_docking_container, 
28   go_splitter_con       type ref to cl_gui_splitter_container, 
29   go_splitter_con_left  type ref to cl_gui_splitter_container, 
30   go_splitter_con_right type ref to cl_gui_splitter_container, 
31   go_con_left           type ref to cl_gui_container, 
32   go_con_right          type ref to cl_gui_container. 
33  
34  
35 data: 
36   go_con_ftp    type ref to cl_gui_container, 
37   go_con_tabhd  type ref to cl_gui_container, 
38   go_con_tabit  type ref to cl_gui_container, 
39   go_alv_ftp    type ref to cl_gui_alv_grid, 
40   go_alv_tabhd  type ref to cl_gui_alv_grid, 
41   go_alv_tabit  type ref to cl_gui_alv_grid, 
42   go_event_ftp   type ref to lcl_alv_event_handler, 
43   go_event_tabhd type ref to lcl_alv_event_handler, 
44   go_event_tabit type ref to lcl_alv_event_handler. 
45  
46 data: 
47   gt_fieldcat_ftp    type lvc_t_fcat, 
48   gt_fieldcat_tabhd  type lvc_t_fcat, 
49   gt_fieldcat_tabit  type lvc_t_fcat, 
50   gt_f4_ftp          type lvc_t_f4, 
51   gt_f4_tabhd        type lvc_t_f4, 
52   gt_f4_tabit        type lvc_t_f4, 
53   gt_exclude         type ui_functions. 
54 data: 
55   gs_fieldcat        type lvc_s_fcat, 
56   gs_f4              type lvc_s_f4, 
57   gs_layout          type lvc_s_layo.
View Code
 1 *&---------------------------------------------------------------------* 
 2 *&  包括              ZFID0003_ETL_FTP_SCR 
 3 *&---------------------------------------------------------------------* 
 4  
 5 selection-screen begin of block b_block with frame title text-001. 
 6 parameter: 
 7   p_ftpnm type ztfi0037_etl_ftp-ftpnm matchcode object zhfi0037_etl_ftp. 
 8  
 9 selection-screen pushbutton 70(10) bt_query user-command bt_query. 
10 selection-screen end of block b_block. 
11  
12 selection-screen function key 1.
View Code
 1 *&---------------------------------------------------------------------* 
 2 *&  包括              ZFID0003_ETL_FTP_PRO 
 3 *&---------------------------------------------------------------------* 
 4  
 5 initialization. 
 6   perform frm_initial_data. 
 7  
 8 at selection-screen output. 
 9   perform frm_split_dock. 
10   perform frm_event_dock. 
11   perform frm_alv_display. 
12  
13 at selection-screen. 
14   perform frm_ucomm_handler. 
15  
16 start-of-selection.
View Code
  1 *&---------------------------------------------------------------------* 
  2 *&  包括              ZFID0003_ETL_FTP_FRM 
  3 *&---------------------------------------------------------------------* 
  4 *&---------------------------------------------------------------------* 
  5 *&      Form  handle_toolbar 
  6 *&---------------------------------------------------------------------* 
  7 *       text 
  8 *----------------------------------------------------------------------* 
  9 *      -->P_E_OBJECT  text 
 10 *      -->P_E_INTERACTIVE  text 
 11 *----------------------------------------------------------------------* 
 12 form handle_toolbar  using  fv_object      type ref to cl_alv_event_toolbar_set 
 13                             fv_interactive type char1. 
 14   data: ls_toolbar type stb_button. 
 15  
 16   ls_toolbar-function = 'INSERT_ROW'. 
 17   ls_toolbar-icon = icon_insert_row. 
 18   ls_toolbar-text = space. 
 19   ls_toolbar-quickinfo = '新增行'. 
 20   append ls_toolbar to fv_object->mt_toolbar. 
 21   clear: ls_toolbar. 
 22  
 23   ls_toolbar-function = 'DELETE_ROW'. 
 24   ls_toolbar-icon = icon_delete_row. 
 25   ls_toolbar-text = space. 
 26   ls_toolbar-quickinfo = '删除行'. 
 27   append ls_toolbar to fv_object->mt_toolbar. 
 28   clear: ls_toolbar. 
 29 endform.                    " handle_toolbar 
 30 *&---------------------------------------------------------------------* 
 31 *&      Form  handle_f4 
 32 *&---------------------------------------------------------------------* 
 33 *       text 
 34 *----------------------------------------------------------------------* 
 35 *      -->P_E_FIELDNAME  text 
 36 *      -->P_E_FIELDVALUE  text 
 37 *      -->P_ES_ROW_NO  text 
 38 *      -->P_ER_EVENT_DATA  text 
 39 *      -->P_ET_BAD_CELLS  text 
 40 *----------------------------------------------------------------------* 
 41 form handle_f4  using   fv_fieldname type lvc_fname 
 42                         fv_fieldvalue type lvc_value 
 43                         fs_row_no type lvc_s_roid 
 44                         fo_event_data type ref to cl_alv_event_data 
 45                         ft_bad_cells type lvc_t_modi. 
 46   data: 
 47     ls_modi type lvc_s_modi. 
 48   data: 
 49     lv_dtext type dd02t-ddtext. 
 50   field-symbols: 
 51     <ft_modi> type lvc_t_modi. 
 52  
 53   fo_event_data->m_event_handled = 'X'. 
 54  
 55   case fv_fieldname. 
 56     when 'TABNM'. 
 57       perform f4_dd_table(rsaqddic) using 'SAPLAQJD_CNTRL' 
 58                                           '0300' 
 59                                           'G_DYN_0300-TNAME' 
 60                                     changing fv_fieldvalue. 
 61     when others. 
 62   endcase. 
 63  
 64   select single ddtext 
 65   into lv_dtext 
 66   from dd02t 
 67   where tabname = fv_fieldvalue. 
 68  
 69   assign fo_event_data->m_data->* to <ft_modi>. 
 70   ls_modi-row_id    = fs_row_no-row_id." 
 71   ls_modi-fieldname = fv_fieldname. 
 72   ls_modi-value     = fv_fieldvalue. 
 73   append ls_modi to <ft_modi>. 
 74   ls_modi-row_id    = fs_row_no-row_id." 
 75   ls_modi-fieldname = 'TABTX'. 
 76   ls_modi-value     = lv_dtext. 
 77   append ls_modi to <ft_modi>. 
 78  
 79 endform.                                                    " handle_f4 
 80 *&---------------------------------------------------------------------* 
 81 *&      Form  handle_user_command 
 82 *&---------------------------------------------------------------------* 
 83 *       text 
 84 *----------------------------------------------------------------------* 
 85 *      -->P_E_UCOMM  text 
 86 *----------------------------------------------------------------------* 
 87 form handle_command_ftp  using fv_ucomm. 
 88   data: 
 89     ls_tab_ftp type ztfi0037_etl_ftp, 
 90     ls_selected_row type lvc_s_row. 
 91   data: 
 92     lt_selected_row type lvc_t_row. 
 93  
 94   if fv_ucomm = 'INSERT_ROW'. 
 95     append ls_tab_ftp to gt_tab_ftp. 
 96   elseif fv_ucomm = 'DELETE_ROW'. 
 97     go_alv_ftp->get_selected_rows( 
 98       importing 
 99         et_index_rows = lt_selected_row ). 
100  
101     read table lt_selected_row into ls_selected_row index 1. 
102     if sy-subrc = 0. 
103       delete gt_tab_ftp index ls_selected_row-index. 
104     endif. 
105   endif. 
106 endform.                    " handle_user_command 
107 *&---------------------------------------------------------------------* 
108 *&      Form  frm_split_dock 
109 *&---------------------------------------------------------------------* 
110 *       text 
111 *----------------------------------------------------------------------* 
112 *  -->  p1        text 
113 *  <--  p2        text 
114 *----------------------------------------------------------------------* 
115 form frm_split_dock . 
116   check go_docking_con is initial. 
117  
118   "创建容器 
119   create object go_docking_con 
120     exporting 
121       ratio = 89 
122       side  = cl_gui_docking_container=>dock_at_bottom. 
123  
124   "拆分为左、右 
125   create object go_splitter_con 
126     exporting 
127       parent  = go_docking_con 
128       rows    = 1 
129       columns = 2. 
130   go_splitter_con->set_column_width( exporting id = 1 width = 45 ). 
131  
132   go_con_left  = go_splitter_con->get_container( row = 1 column = 1 ). 
133   go_con_right = go_splitter_con->get_container( row = 1 column = 2 ). 
134  
135   "左侧再次拆分为上下 
136   create object go_splitter_con_left 
137     exporting 
138       parent  = go_con_left 
139       rows    = 2 
140       columns = 1. 
141   go_splitter_con_left->set_row_height( exporting id = 1 height = 40 ). 
142  
143   "右侧不拆分 
144   create object go_splitter_con_right 
145     exporting 
146       parent  = go_con_right 
147       rows    = 1 
148       columns = 1. 
149   "go_splitter_con_right->set_row_height( EXPORTING id = 1 height = 40 ). 
150  
151   "创建FTP的ALV 
152   go_con_ftp = go_splitter_con_left->get_container( row = 1 column = 1 ). 
153   create object go_alv_ftp 
154     exporting 
155       i_parent = go_con_ftp. 
156  
157   "创建TABLE HEADER的ALV 
158   go_con_tabhd = go_splitter_con_left->get_container( row = 2 column = 1 ). 
159   create object go_alv_tabhd 
160     exporting 
161       i_parent = go_con_tabhd. 
162  
163   "创建TABLE ITEM的ALV 
164   go_con_tabit = go_splitter_con_right->get_container( row = 1 column = 1 ). 
165   create object go_alv_tabit 
166     exporting 
167       i_parent = go_con_tabit. 
168 endform.                    " frm_split_dock 
169 *&---------------------------------------------------------------------* 
170 *&      Form  frm_event_dock 
171 *&---------------------------------------------------------------------* 
172 *       text 
173 *----------------------------------------------------------------------* 
174 *  -->  p1        text 
175 *  <--  p2        text 
176 *----------------------------------------------------------------------* 
177 form frm_event_dock . 
178   if go_event_ftp is initial 
179   or go_event_tabhd is initial 
180   or go_event_tabit is initial. 
181     create object:go_event_ftp,go_event_tabhd,go_event_tabit. 
182     set handler: 
183       go_event_ftp->handle_f4   for go_alv_ftp, 
184       go_event_tabhd->handle_f4 for go_alv_tabhd, 
185       go_event_tabit->handle_f4 for go_alv_tabit, 
186  
187       go_event_ftp->handle_toolbar for go_alv_ftp, 
188       go_event_tabhd->handle_toolbar for go_alv_tabhd, 
189       go_event_tabit->handle_toolbar_itm for go_alv_tabit, 
190  
191       go_event_ftp->handle_command_ftp for go_alv_ftp, 
192       go_event_tabhd->handle_command_tabhd for go_alv_tabhd, 
193       go_event_tabit->handle_command_tabit for go_alv_tabit, 
194  
195       go_event_tabhd->handle_double_click for go_alv_tabhd. 
196   endif. 
197 endform.                    " frm_event_dock 
198 *&---------------------------------------------------------------------* 
199 *&      Form  frm_alv_display 
200 *&---------------------------------------------------------------------* 
201 *       text 
202 *----------------------------------------------------------------------* 
203 *  -->  p1        text 
204 *  <--  p2        text 
205 *----------------------------------------------------------------------* 
206 form frm_alv_display. 
207   define build_fieldcat. 
208     gs_fieldcat-fieldname  = &3. 
209     gs_fieldcat-edit       = &4. 
210     gs_fieldcat-checkbox   = &5. 
211     gs_fieldcat-f4availabl = &6. 
212     gs_fieldcat-lowercase  = &7. 
213     gs_fieldcat-outputlen  = &8. 
214     gs_fieldcat-coltext    = &9. 
215     if &3 = 'FTPPW'. 
216       gs_fieldcat-edit_mask  = '******'. 
217     endif. 
218     append gs_fieldcat to &1. 
219     clear gs_fieldcat. 
220  
221     if &6 = 'X'. 
222       gs_f4-fieldname = &3. 
223       gs_f4-register = 'X'. 
224       insert gs_f4 into table &2. 
225       clear gs_f4. 
226     endif. 
227   end-of-definition. 
228  
229   perform frm_alv_toolbar tables gt_exclude. 
230   perform frm_alv_layout changing gs_layout. 
231  
232   if gt_fieldcat_ftp is initial. 
233     "ALV显示FTP参数 
234     build_fieldcat: 
235       gt_fieldcat_ftp  gt_f4_ftp  'FTPNM'    'X'   ' '   ' '  ' '  10  'FTP名称', 
236       gt_fieldcat_ftp  gt_f4_ftp  'FTPTX'    'X'   ' '   ' '  ' '  15  'FTP描述', 
237       gt_fieldcat_ftp  gt_f4_ftp  'FTPIP'    'X'   ' '   ' '  ' '  15  'FTP地址', 
238       gt_fieldcat_ftp  gt_f4_ftp  'FTPUR'    'X'   ' '   ' '  'X'  10  'FTP账号', 
239       gt_fieldcat_ftp  gt_f4_ftp  'FTPPW'    'X'   ' '   ' '  'X'  15  'FTP密码', 
240       gt_fieldcat_ftp  gt_f4_ftp  'FTPDS'    'X'   ' '   ' '  ' '  15  'RFC目标'. 
241  
242     gs_layout-grid_title = 'FTP参数明细【参数设置】'. 
243     "gs_layout-NO_TOOLBAR = 'X'. 
244     gs_layout-cwidth_opt = 'X'. 
245  
246     call method go_alv_ftp->set_table_for_first_display 
247       exporting 
248         it_toolbar_excluding = gt_exclude 
249         is_layout            = gs_layout 
250       changing 
251         it_outtab            = gt_tab_ftp 
252         it_fieldcatalog      = gt_fieldcat_ftp. 
253   endif. 
254  
255   if gt_fieldcat_tabhd is initial. 
256     "ALV显示TABLE抬头 
257     build_fieldcat: 
258       gt_fieldcat_tabhd  gt_f4_tabhd  'FTPNM'      ' '   ' '   ' '  ' '  12  'FTP名称', 
259       gt_fieldcat_tabhd  gt_f4_tabhd  'TABNM'      'X'   ' '   'X'  ' '  15  '表名', 
260       gt_fieldcat_tabhd  gt_f4_tabhd  'TABTX'      'X'   ' '   'X'  ' '  15  '表描述', 
261       gt_fieldcat_tabhd  gt_f4_tabhd  'FG_FTP'     'X'   'X'   ' '  ' '  10  '标识-启用'. 
262     gs_layout-grid_title = '数据表抬头【请维护数据表并启用】'. 
263  
264     call method go_alv_tabhd->set_table_for_first_display 
265       exporting 
266         it_toolbar_excluding = gt_exclude 
267         is_layout            = gs_layout 
268       changing 
269         it_outtab            = gt_tab_hd 
270         it_fieldcatalog      = gt_fieldcat_tabhd. 
271  
272     "注册事件-搜索帮助 
273     go_alv_tabhd->register_f4_for_fields(  exporting it_f4 = gt_f4_tabhd ). 
274     go_alv_tabhd->register_edit_event(  exporting i_event_id = cl_gui_alv_grid=>mc_evt_modified ). 
275   endif. 
276  
277   if gt_fieldcat_tabit is initial. 
278     "ALV显示TABLE字段明细 
279     build_fieldcat: 
280       gt_fieldcat_tabit  gt_f4_tabit  'FTPNM'      ' '   ' '  ' '  ' '  12  'FTP名称', 
281       gt_fieldcat_tabit  gt_f4_tabit  'TABNM'      ' '   ' '  ' '  ' '  15  '表名', 
282       gt_fieldcat_tabit  gt_f4_tabit  'FLDNO'      ' '   ' '  ' '  ' '   6  '行项目', 
283       gt_fieldcat_tabit  gt_f4_tabit  'FLDNM'      ' '   ' '  ' '  ' '   8  '字段名', 
284       gt_fieldcat_tabit  gt_f4_tabit  'FLDTX'      ' '   ' '  ' '  ' '  20  '描述', 
285       gt_fieldcat_tabit  gt_f4_tabit  'FG_QRY'     'X'   'X'  ' '  ' '  10  '标识-查询', 
286       gt_fieldcat_tabit  gt_f4_tabit  'FG_EXP'     'X'   'X'  ' '  ' '  10  '标识-输出'. 
287     gs_layout-grid_title = '数据表明细【请单击左侧数据表并针对字段明细选择查询字段及输出字段】'. 
288  
289     call method go_alv_tabit->set_table_for_first_display 
290       exporting 
291         it_toolbar_excluding = gt_exclude 
292         is_layout            = gs_layout 
293       changing 
294         it_outtab            = gt_tab_itm 
295         it_fieldcatalog      = gt_fieldcat_tabit. 
296   endif. 
297 endform.                    " frm_alv_display 
298 *&---------------------------------------------------------------------* 
299 *&      Form  frm_initial_data 
300 *&---------------------------------------------------------------------* 
301 *       text 
302 *----------------------------------------------------------------------* 
303 *  -->  p1        text 
304 *  <--  p2        text 
305 *----------------------------------------------------------------------* 
306 form frm_initial_data . 
307   bt_query = '@BO@查询'. 
308   sscrfields-functxt_01 = '@2L@保存设置'. 
309 endform.                    " frm_initial_data 
310 *&---------------------------------------------------------------------* 
311 *&      Form  frm_alv_layout 
312 *&---------------------------------------------------------------------* 
313 *       text 
314 *----------------------------------------------------------------------* 
315 *      <--P_LS_LAYOUT  text 
316 *----------------------------------------------------------------------* 
317 form frm_alv_layout  changing fs_layout type lvc_s_layo. 
318   fs_layout-zebra = 'X'. 
319   fs_layout-sel_mode = 'A'. 
320   fs_layout-smalltitle = 'X'. 
321 endform.                    " frm_alv_layout 
322 *&---------------------------------------------------------------------* 
323 *&      Form  frm_ucomm_handler 
324 *&---------------------------------------------------------------------* 
325 *       text 
326 *----------------------------------------------------------------------* 
327 *  -->  p1        text 
328 *  <--  p2        text 
329 *----------------------------------------------------------------------* 
330 form frm_ucomm_handler . 
331   data: 
332     lv_flg type c. 
333   data: 
334     lt_return type table of bapiret2. 
335  
336   perform alv_changed_data. 
337  
338   case sy-ucomm. 
339     when 'FC01'. 
340       perform frm_save_check using lv_flg. 
341       perform frm_save_data using lv_flg. 
342  
343     when 'BT_QUERY'. 
344       perform frm_query_check. 
345       perform frm_query_data. 
346   endcase. 
347  
348   perform alv_refresh_display. 
349  
350   clear:sy-ucomm. 
351 endform.                    " frm_ucomm_handler 
352 *&---------------------------------------------------------------------* 
353 *&      Form  frm_query_check 
354 *&---------------------------------------------------------------------* 
355 *       text 
356 *----------------------------------------------------------------------* 
357 *  -->  p1        text 
358 *  <--  p2        text 
359 *----------------------------------------------------------------------* 
360 form frm_query_check . 
361   if gt_tab_ftp is not initial 
362   or gt_tab_hd  is not initial 
363   or gt_tab_itm is not initial. 
364  
365   endif. 
366 endform.                    " frm_query_check 
367 *&---------------------------------------------------------------------* 
368 *&      Form  frm_query_data 
369 *&---------------------------------------------------------------------* 
370 *       text 
371 *----------------------------------------------------------------------* 
372 *  -->  p1        text 
373 *  <--  p2        text 
374 *----------------------------------------------------------------------* 
375 form frm_query_data . 
376   select * 
377   into corresponding fields of table gt_tab_ftp 
378   from ztfi0037_etl_ftp 
379   where ftpnm = p_ftpnm. 
380  
381   select * 
382   into corresponding fields of table gt_tab_hd 
383   from ztfi0035_tab_hd 
384   where ftpnm = p_ftpnm. 
385 endform.                    " frm_query_data 
386 *&---------------------------------------------------------------------* 
387 *&      Form  frm_alv_toolbar 
388 *&---------------------------------------------------------------------* 
389 *       text 
390 *----------------------------------------------------------------------* 
391 *      -->P_GT_EXCLUDE  text 
392 *----------------------------------------------------------------------* 
393 form frm_alv_toolbar  tables   ft_exclude type ui_functions. 
394   "插入正确名称 <...>. 
395   refresh: ft_exclude. 
396  
397   append cl_gui_alv_grid=>mc_fc_maximum to ft_exclude. 
398   append cl_gui_alv_grid=>mc_fc_minimum to ft_exclude. 
399   append cl_gui_alv_grid=>mc_fc_subtot to ft_exclude. 
400   append cl_gui_alv_grid=>mc_fc_sum to ft_exclude. 
401   append cl_gui_alv_grid=>mc_fc_average to ft_exclude. 
402   append cl_gui_alv_grid=>mc_mb_sum to ft_exclude. 
403   append cl_gui_alv_grid=>mc_mb_subtot to ft_exclude. 
404   append cl_gui_alv_grid=>mc_fc_sort_asc to ft_exclude. 
405   append cl_gui_alv_grid=>mc_fc_sort_dsc to ft_exclude. 
406   append cl_gui_alv_grid=>mc_fc_find to ft_exclude. 
407   append cl_gui_alv_grid=>mc_fc_filter to ft_exclude. 
408   append cl_gui_alv_grid=>mc_fc_print to ft_exclude. 
409   append cl_gui_alv_grid=>mc_fc_print_prev to ft_exclude. 
410   append cl_gui_alv_grid=>mc_mb_export to ft_exclude. 
411   append cl_gui_alv_grid=>mc_fc_graph to ft_exclude. 
412   append cl_gui_alv_grid=>mc_mb_export to ft_exclude. 
413   append cl_gui_alv_grid=>mc_mb_view to ft_exclude. 
414   append cl_gui_alv_grid=>mc_fc_detail to ft_exclude. 
415   append cl_gui_alv_grid=>mc_fc_help to ft_exclude. 
416   append cl_gui_alv_grid=>mc_fc_info to ft_exclude. 
417   append cl_gui_alv_grid=>mc_mb_variant to ft_exclude. 
418   append cl_gui_alv_grid=>mc_fc_refresh to ft_exclude. 
419   append cl_gui_alv_grid=>mc_fc_check to ft_exclude. 
420   append cl_gui_alv_grid=>mc_fc_loc_copy to ft_exclude. 
421   append cl_gui_alv_grid=>mc_fc_loc_insert_row to ft_exclude. 
422   append cl_gui_alv_grid=>mc_fc_loc_delete_row to ft_exclude. 
423   append cl_gui_alv_grid=>mc_fc_loc_copy_row to ft_exclude. 
424   append cl_gui_alv_grid=>mc_fc_loc_append_row to ft_exclude. 
425   append cl_gui_alv_grid=>mc_fc_loc_undo to ft_exclude. 
426   append cl_gui_alv_grid=>mc_fc_loc_cut to ft_exclude. 
427   append cl_gui_alv_grid=>mc_mb_paste to ft_exclude. 
428 endform.                    " frm_alv_toolbar 
429 *&---------------------------------------------------------------------* 
430 *&      Form  alv_refresh_display 
431 *&---------------------------------------------------------------------* 
432 *       text 
433 *----------------------------------------------------------------------* 
434 *  -->  p1        text 
435 *  <--  p2        text 
436 *----------------------------------------------------------------------* 
437 form alv_refresh_display . 
438   go_alv_ftp->refresh_table_display( ). 
439   go_alv_tabhd->refresh_table_display( ). 
440   go_alv_tabit->refresh_table_display( ). 
441 endform.                    " alv_refresh_display 
442 *&---------------------------------------------------------------------* 
443 *&      Form  handle_double_click 
444 *&---------------------------------------------------------------------* 
445 *       text 
446 *----------------------------------------------------------------------* 
447 *      -->P_E_ROW  text 
448 *----------------------------------------------------------------------* 
449 form handle_double_click  using  fv_row. 
450   perform frm_check_ftp. 
451   perform frm_check_tabhd using fv_row. 
452  
453   perform frm_get_tabit using fv_row. 
454 endform.                    " handle_double_click 
455 *&---------------------------------------------------------------------* 
456 *&      Form  handle_hotspot_clk 
457 *&---------------------------------------------------------------------* 
458 *       text 
459 *----------------------------------------------------------------------* 
460 *      -->P_E_ROW_ID  text 
461 *      -->P_E_COLUMN_ID  text 
462 *      -->P_ES_ROW_NO  text 
463 *----------------------------------------------------------------------* 
464 form handle_hotspot_clk  using e_row_id  type lvc_s_row 
465                                e_column_id type lvc_s_col 
466                                es_row_no type lvc_s_roid. 
467   if e_column_id = 'VBELN'. 
468 *    read table gt_200_alv assigning <fs_200_alv> 
469 *    index es_row_no-row_id. 
470 *    if sy-subrc eq 0. 
471 *      check <fs_200_alv>-vbeln+0(1) ne 'Y'. 
472 *      set parameter id 'AUN' field <fs_200_alv>-vbeln. 
473 *      call transaction 'VA03' and skip first screen. 
474 *    endif. 
475   endif. 
476 endform.                    "handle_hotspot_clk 
477 *&---------------------------------------------------------------------* 
478 *&      Form  handle_command_tabhd 
479 *&---------------------------------------------------------------------* 
480 *       text 
481 *----------------------------------------------------------------------* 
482 *      -->P_E_UCOMM  text 
483 *----------------------------------------------------------------------* 
484 form handle_command_tabhd  using  fv_ucomm. 
485   perform frm_check_ftp. 
486  
487   data: 
488     ls_tab_tabhd type ztfi0035_tab_hd, 
489     ls_tab_ftp   type ztfi0037_etl_ftp, 
490     ls_selected_row type lvc_s_row. 
491   data: 
492     lt_selected_row type lvc_t_row. 
493  
494   if fv_ucomm = 'INSERT_ROW'. 
495     read table gt_tab_ftp into ls_tab_ftp index 1. 
496     if sy-subrc = 0. 
497       ls_tab_tabhd-ftpnm = ls_tab_ftp-ftpnm. 
498       append ls_tab_tabhd to gt_tab_hd. 
499     endif. 
500   elseif fv_ucomm = 'DELETE_ROW'. 
501     go_alv_ftp->get_selected_rows( 
502       importing 
503         et_index_rows = lt_selected_row ). 
504  
505     read table lt_selected_row into ls_selected_row index 1. 
506     if sy-subrc = 0. 
507       delete gt_tab_hd index ls_selected_row-index. 
508     endif. 
509   endif. 
510  
511   loop at gt_tab_hd into ls_tab_tabhd 
512   where tabtx = space. 
513     select single ddtext 
514     into ls_tab_tabhd-tabtx 
515     from dd02t 
516     where tabname = ls_tab_tabhd-tabnm. 
517     modify gt_tab_hd from ls_tab_tabhd. 
518     clear:ls_tab_tabhd. 
519   endloop. 
520  
521 endform.                    " handle_command_tabhd 
522 *&---------------------------------------------------------------------* 
523 *&      Form  handle_command_tabit 
524 *&---------------------------------------------------------------------* 
525 *       text 
526 *----------------------------------------------------------------------* 
527 *      -->P_E_UCOMM  text 
528 *----------------------------------------------------------------------* 
529 form handle_command_tabit  using fv_ucomm. 
530   field-symbols: 
531     <fs_all_itm> like ztfi0036_tab_itm. 
532  
533   if fv_ucomm = 'SAVE_ITM'. 
534     loop at gt_tab_itm assigning <fs_tab_itm>. 
535       append initial line to gt_all_itm assigning <fs_all_itm>. 
536       move-corresponding <fs_tab_itm> to <fs_all_itm>. 
537       unassign <fs_all_itm>. 
538     endloop. 
539   endif. 
540   message s007(zfi_00). 
541 endform.                    " handle_command_tabit 
542 *&---------------------------------------------------------------------* 
543 *&      Form  frm_check_ftp 
544 *&---------------------------------------------------------------------* 
545 *       text 
546 *----------------------------------------------------------------------* 
547 *  -->  p1        text 
548 *  <--  p2        text 
549 *----------------------------------------------------------------------* 
550 form frm_check_ftp . 
551   data: 
552     lv_count type i. 
553   data: 
554     ls_tab_ftp type ztfi0037_etl_ftp. 
555  
556   if gt_tab_ftp[] is initial. 
557     message e001(zfi_00). 
558   else. 
559     describe table gt_tab_ftp lines lv_count. 
560     if lv_count > 1. 
561       message e002(zfi_00). 
562     endif. 
563     read table gt_tab_ftp into ls_tab_ftp index 1. 
564     if sy-subrc = 0. 
565       if ls_tab_ftp-ftpnm is initial 
566       or ls_tab_ftp-ftpip is initial 
567       or ls_tab_ftp-ftpur is initial 
568       or ls_tab_ftp-ftppw is initial. 
569         message e003(zfi_00). 
570       endif. 
571     endif. 
572   endif. 
573 endform.                    " frm_check_ftp 
574 *&---------------------------------------------------------------------* 
575 *&      Form  frm_check_tabhd 
576 *&---------------------------------------------------------------------* 
577 *       text 
578 *----------------------------------------------------------------------* 
579 *  -->  p1        text 
580 *  <--  p2        text 
581 *----------------------------------------------------------------------* 
582 form frm_check_tabhd using fv_row. 
583   data: 
584     ls_tab_hd  type ztfi0035_tab_hd. 
585  
586   read table gt_tab_hd into ls_tab_hd index fv_row. 
587   if sy-subrc = 0. 
588     if ls_tab_hd-ftpnm is initial. 
589       message i004(zfi_00). 
590     endif. 
591     if ls_tab_hd-tabnm is initial. 
592       message i005(zfi_00). 
593     else. 
594       select single count(*) 
595       from dd02l 
596       where tabname = ls_tab_hd-tabnm. 
597       if sy-subrc <> 0. 
598         message i006(zfi_00) with ls_tab_hd-tabnm. 
599       endif. 
600     endif. 
601   endif. 
602  
603   loop at gt_tab_hd into ls_tab_hd 
604   where tabtx = space. 
605     select single ddtext 
606     into ls_tab_hd-tabtx 
607     from dd02t 
608     where tabname = ls_tab_hd-tabnm. 
609     modify gt_tab_hd from ls_tab_hd. 
610     clear:ls_tab_hd. 
611   endloop. 
612 endform.                    " frm_check_tabhd 
613 *&---------------------------------------------------------------------* 
614 *&      Form  alv_changed_data 
615 *&---------------------------------------------------------------------* 
616 *       text 
617 *----------------------------------------------------------------------* 
618 *  -->  p1        text 
619 *  <--  p2        text 
620 *----------------------------------------------------------------------* 
621 form alv_changed_data . 
622   go_alv_ftp->check_changed_data( ). 
623   go_alv_tabhd->check_changed_data( ). 
624   go_alv_tabit->check_changed_data( ). 
625 endform.                    " alv_changed_data 
626 *&---------------------------------------------------------------------* 
627 *&      Form  frm_get_tabit 
628 *&---------------------------------------------------------------------* 
629 *       text 
630 *----------------------------------------------------------------------* 
631 *      -->P_FV_ROW  text 
632 *----------------------------------------------------------------------* 
633 form frm_get_tabit  using fv_row. 
634   data: 
635     lt_tab_itm like table of ztfi0036_tab_itm, 
636     lt_dd03l like table of dd03l. 
637   data: 
638     ls_dd03l like dd03l, 
639     ls_tab_itm type ztfi0036_tab_itm, 
640     ls_tab_hd type ztfi0035_tab_hd. 
641   field-symbols: 
642     <fs_dd03l> like dd03l. 
643  
644   clear:gt_tab_itm. 
645   refresh:gt_tab_itm. 
646  
647   read table gt_tab_hd into ls_tab_hd index fv_row. 
648   if sy-subrc = 0. 
649     read table gt_all_itm into ls_tab_itm 
650     with key  ftpnm = ls_tab_hd-ftpnm 
651               tabnm = ls_tab_hd-tabnm. 
652     if sy-subrc <> 0. 
653       select * 
654       into table gt_tab_itm 
655       from ztfi0036_tab_itm 
656       where ftpnm = ls_tab_hd-ftpnm 
657         and tabnm = ls_tab_hd-tabnm. 
658       if sy-subrc <> 0. 
659         select * 
660         into table lt_dd03l 
661         from dd03l 
662         where tabname = ls_tab_hd-tabnm. 
663  
664         sort lt_dd03l by tabname position. 
665  
666         loop at lt_dd03l assigning <fs_dd03l>. 
667           append initial line to gt_tab_itm assigning <fs_tab_itm>. 
668           <fs_tab_itm>-ftpnm = ls_tab_hd-ftpnm. 
669           <fs_tab_itm>-tabnm = <fs_dd03l>-tabname. 
670           <fs_tab_itm>-fldno = <fs_dd03l>-position. 
671           <fs_tab_itm>-fldnm = <fs_dd03l>-fieldname. 
672           if <fs_dd03l>-rollname is not initial. 
673             select single ddtext 
674             into <fs_tab_itm>-fldtx 
675             from dd04t 
676             where rollname   = <fs_dd03l>-rollname 
677               and ddlanguage = sy-langu. 
678           else. 
679             select single ddtext 
680             into <fs_tab_itm>-fldtx 
681             from dd03t 
682             where tabname    = <fs_dd03l>-tabname 
683               and ddlanguage = sy-langu 
684               and fieldname  = <fs_dd03l>-fieldname. 
685           endif. 
686           unassign <fs_tab_itm>. 
687         endloop. 
688       endif. 
689     else. 
690       loop at gt_all_itm into ls_tab_itm 
691       where ftpnm = ls_tab_hd-ftpnm 
692         and tabnm = ls_tab_hd-tabnm. 
693         append initial line to gt_tab_itm assigning <fs_tab_itm>. 
694         move-corresponding ls_tab_itm to <fs_tab_itm>. 
695         unassign <fs_tab_itm>. 
696       endloop. 
697     endif. 
698   endif. 
699  
700 endform.                    " frm_get_tabit 
701 *&---------------------------------------------------------------------* 
702 *&      Form  handle_toolbar_itm 
703 *&---------------------------------------------------------------------* 
704 *       text 
705 *----------------------------------------------------------------------* 
706 *      -->P_E_OBJECT  text 
707 *      -->P_E_INTERACTIVE  text 
708 *----------------------------------------------------------------------* 
709 form handle_toolbar_itm  using  fv_object      type ref to cl_alv_event_toolbar_set 
710                                 fv_interactive type char1. 
711   data: ls_toolbar type stb_button. 
712  
713   ls_toolbar-function = 'SAVE_ITM'. 
714   ls_toolbar-icon = icon_system_save. 
715   ls_toolbar-text = '临时存储'. 
716   ls_toolbar-quickinfo = '保存明细'. 
717   append ls_toolbar to fv_object->mt_toolbar. 
718   clear: ls_toolbar. 
719  
720 endform.                    " handle_toolbar_itm 
721 *&---------------------------------------------------------------------* 
722 *&      Form  frm_save_check 
723 *&---------------------------------------------------------------------* 
724 *       text 
725 *----------------------------------------------------------------------* 
726 *  -->  p1        text 
727 *  <--  p2        text 
728 *----------------------------------------------------------------------* 
729 form frm_save_check using fv_flg. 
730   data: 
731     lv_erflg type c, 
732     lv_count type i. 
733   data: 
734     ls_tab_ftp type ztfi0037_etl_ftp. 
735  
736   if gt_tab_ftp[] is initial. 
737     message i001(zfi_00). 
738     lv_erflg = 'X'. 
739   else. 
740     describe table gt_tab_ftp lines lv_count. 
741     if lv_count > 1. 
742       message i002(zfi_00). 
743       lv_erflg = 'X'. 
744     endif. 
745     read table gt_tab_ftp into ls_tab_ftp index 1. 
746     if sy-subrc = 0. 
747       if ls_tab_ftp-ftpnm is initial 
748       or ls_tab_ftp-ftpip is initial 
749       or ls_tab_ftp-ftpur is initial 
750       or ls_tab_ftp-ftppw is initial. 
751         message i003(zfi_00). 
752         lv_erflg = 'X'. 
753       endif. 
754     endif. 
755   endif. 
756   fv_flg = lv_erflg. 
757 endform.                    " frm_save_check 
758 *&---------------------------------------------------------------------* 
759 *&      Form  frm_save_data 
760 *&---------------------------------------------------------------------* 
761 *       text 
762 *----------------------------------------------------------------------* 
763 *  -->  p1        text 
764 *  <--  p2        text 
765 *----------------------------------------------------------------------* 
766 form frm_save_data using fv_flg. 
767   check fv_flg is initial. 
768  
769   "存储FTP 
770   modify ztfi0037_etl_ftp from table gt_tab_ftp. 
771  
772   "存储TABHD 
773   modify ztfi0035_tab_hd from table gt_tab_hd. 
774  
775   "存储TABITM 
776   modify ztfi0036_tab_itm from table gt_all_itm. 
777  
778   commit work and wait. 
779   if sy-subrc = 0. 
780     message s008(zfi_00). 
781   endif. 
782 endform.                    " frm_save_data
View Code

4.配置表


评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!