科技越来越进步,人也就变的越来越懒,最终的演变就是大脑发达,四肢退化。。。AI的到来,准备接招吧。。。
报表若没有过多的用户交互逻辑,一般可通过SQ01配置生成,本文介绍用ABAP方式实现报表程序的动态生成(程序是很久前从其他地方拷贝的,忘记了博文地址)。
1.动态程序测试
输入程序名,设置表清单、表关联关系、查询字段、输出字段、附加字段等信息
点击按钮’生成程序’,事务码SE38查询 ZRICO_TEST1205 ,程序已自动生成。
程序 ZRICO_TEST1205 执行测试:
2.动态程序代码:
1 *&---------------------------------------------------------------------* 2 *& Report ZRICO_DY_0001 3 *& 4 *&---------------------------------------------------------------------* 5 *& 6 *& 7 *&---------------------------------------------------------------------* 8 9 REPORT zreport_generator. 10 11 TYPE-POOLS: ole2. 12 13 TABLES: sscrfields. 14 15 SELECTION-SCREEN BEGIN OF LINE. 16 SELECTION-SCREEN COMMENT (6) text. 17 SELECTION-SCREEN POSITION 7. 18 PARAMETERS p_prog TYPE programm. 19 SELECTION-SCREEN PUSHBUTTON 50(10) gen USER-COMMAND gen. 20 SELECTION-SCREEN END OF LINE. 21 22 SELECTION-SCREEN FUNCTION KEY 1. 23 SELECTION-SCREEN FUNCTION KEY 2. 24 SELECTION-SCREEN FUNCTION KEY 3. 25 SELECTION-SCREEN FUNCTION KEY 4. 26 27 *----------------------------------------------------------------------* 28 * CLASS lcl_alv_event_handler DEFINITION 29 *----------------------------------------------------------------------* 30 * 31 *----------------------------------------------------------------------* 32 CLASS lcl_alv_event_handler DEFINITION. 33 PUBLIC SECTION. 34 METHODS: 35 handle_toolbar FOR EVENT toolbar 36 OF cl_gui_alv_grid 37 IMPORTING e_object e_interactive, 38 39 handle_f4 FOR EVENT onf4 40 OF cl_gui_alv_grid 41 IMPORTING e_fieldname e_fieldvalue es_row_no er_event_data et_bad_cells, 42 43 handle_user_command FOR EVENT user_command 44 OF cl_gui_alv_grid 45 IMPORTING e_ucomm. 46 ENDCLASS. "lcl_alv_event_handler DEFINITION 47 48 TYPES: 49 BEGIN OF typ_table, 50 tabname TYPE tabname, 51 leftjoin TYPE c, 52 astable TYPE tabname, 53 END OF typ_table, 54 55 BEGIN OF typ_join, 56 tab1 TYPE tabname, 57 field1 TYPE fieldname, 58 tab2 TYPE tabname, 59 field2 TYPE fieldname, 60 END OF typ_join, 61 62 BEGIN OF typ_field1, 63 astable TYPE tabname, 64 fieldname TYPE fieldname, 65 asfield TYPE lvc_fname, 66 query TYPE c, 67 query_pos TYPE i, 68 single TYPE c, 69 display TYPE c, 70 qfieldname TYPE lvc_qfname, 71 cfieldname TYPE lvc_cfname, 72 ref_table TYPE lvc_rtname, 73 ref_field TYPE lvc_rfname, 74 convexit TYPE convexit, 75 emphasize TYPE lvc_emphsz, 76 scrtext_l TYPE scrtext_l, 77 sel_field TYPE fieldname, 78 sql_field TYPE c LENGTH 60, 79 out_field TYPE fieldname, 80 typ_field TYPE c LENGTH 60, 81 mark TYPE c LENGTH 60, 82 END OF typ_field1, 83 84 BEGIN OF typ_field2, 85 fieldname TYPE lvc_fname, 86 qfieldname TYPE lvc_qfname, 87 cfieldname TYPE lvc_cfname, 88 ref_table TYPE lvc_rtname, 89 ref_field TYPE lvc_rfname, 90 convexit TYPE convexit, 91 emphasize TYPE lvc_emphsz, 92 scrtext_l TYPE scrtext_l, 93 typ_field TYPE c LENGTH 60, 94 END OF typ_field2. 95 96 DATA: 97 go_docking_con TYPE REF TO cl_gui_docking_container, 98 go_splitter_con TYPE REF TO cl_gui_splitter_container, 99 go_splitter_con_left TYPE REF TO cl_gui_splitter_container, 100 go_splitter_con_right TYPE REF TO cl_gui_splitter_container, 101 go_con_tables TYPE REF TO cl_gui_container, 102 go_con_joins TYPE REF TO cl_gui_container, 103 go_con_fields1 TYPE REF TO cl_gui_container, 104 go_con_fields2 TYPE REF TO cl_gui_container, 105 go_alv_tables TYPE REF TO cl_gui_alv_grid, 106 go_alv_joins TYPE REF TO cl_gui_alv_grid, 107 go_alv_fields1 TYPE REF TO cl_gui_alv_grid, 108 go_alv_fields2 TYPE REF TO cl_gui_alv_grid, 109 go_event_tables TYPE REF TO lcl_alv_event_handler, 110 go_event_joins TYPE REF TO lcl_alv_event_handler, 111 go_event_fields1 TYPE REF TO lcl_alv_event_handler, 112 go_event_fields2 TYPE REF TO lcl_alv_event_handler. 113 114 DATA: 115 gt_tables TYPE TABLE OF typ_table, 116 gs_table TYPE typ_table, 117 gt_joins TYPE TABLE OF typ_join, 118 gs_join TYPE typ_join, 119 gt_fields1 TYPE TABLE OF typ_field1, 120 gs_field1 TYPE typ_field1, 121 gt_fields2 TYPE TABLE OF typ_field2, 122 gs_field2 TYPE typ_field2, 123 gt_query TYPE TABLE OF typ_field1, 124 gs_query TYPE typ_field1. 125 126 DATA: 127 gt_fieldcat_tables TYPE lvc_t_fcat, 128 gt_fieldcat_joins TYPE lvc_t_fcat, 129 gt_fieldcat_fields1 TYPE lvc_t_fcat, 130 gt_fieldcat_fields2 TYPE lvc_t_fcat, 131 gs_fieldcat TYPE lvc_s_fcat, 132 gt_f4_tables TYPE lvc_t_f4, 133 gt_f4_joins TYPE lvc_t_f4, 134 gt_f4_fields1 TYPE lvc_t_f4, 135 gt_f4_fields2 TYPE lvc_t_f4, 136 gs_f4 TYPE lvc_s_f4, 137 gt_exclude TYPE ui_functions, 138 gs_layout TYPE lvc_s_layo. 139 140 DATA: 141 BEGIN OF gt_color OCCURS 0, 142 sel TYPE c, 143 color TYPE c LENGTH 4, 144 value TYPE c LENGTH 4, 145 END OF gt_color. 146 147 DATA: 148 ok_code TYPE sy-ucomm, 149 g_flag_error TYPE c, 150 g_indxid TYPE indx_srtfd, 151 gt_codes TYPE TABLE OF string, 152 g_code TYPE string, 153 go_excel TYPE ole2_object, 154 go_books TYPE ole2_object, 155 go_book TYPE ole2_object, 156 go_sheet TYPE ole2_object, 157 go_cell TYPE ole2_object, 158 g_row TYPE i, 159 g_col TYPE i, 160 g_value TYPE string. 161 162 DEFINE d_build_fieldcat. 163 gs_fieldcat-fieldname = &3. 164 gs_fieldcat-edit = &4. 165 gs_fieldcat-checkbox = &5. 166 gs_fieldcat-f4availabl = &6. 167 gs_fieldcat-outputlen = &7. 168 gs_fieldcat-coltext = &8. 169 append gs_fieldcat to &1. 170 clear gs_fieldcat. 171 172 if &6 = 'X'. 173 gs_f4-fieldname = &3. 174 gs_f4-register = 'X'. 175 insert gs_f4 into table &2. 176 clear gs_f4. 177 endif. 178 END-OF-DEFINITION. 179 180 DEFINE append_code. 181 append &1 to gt_codes. 182 END-OF-DEFINITION. 183 *----------------------------------------------------------------------* 184 * CLASS lcl_alv_event_handler IMPLEMENTATION 185 *----------------------------------------------------------------------* 186 * 187 *----------------------------------------------------------------------* 188 CLASS lcl_alv_event_handler IMPLEMENTATION . 189 METHOD handle_toolbar. 190 PERFORM handle_toolbar USING e_object e_interactive. 191 ENDMETHOD. "HANDLE_TOOLBAR 192 193 METHOD handle_f4. 194 PERFORM handle_f4 USING e_fieldname e_fieldvalue es_row_no er_event_data et_bad_cells. 195 ENDMETHOD. "HANDLE_F4 196 197 METHOD handle_user_command. 198 PERFORM handle_user_command USING e_ucomm. 199 ENDMETHOD. "HANDLE_USER_COMMAND 200 ENDCLASS. "lcl_alv_event_handler IMPLEMENTATION 201 202 INITIALIZATION. 203 text = '程序'. 204 gen = '生成程序'. 205 sscrfields-functxt_01 = '保存设置'. 206 sscrfields-functxt_02 = '加载设置'. 207 sscrfields-functxt_03 = '下载到Excel'. 208 sscrfields-functxt_04 = '从Excel上载'. 209 210 AT SELECTION-SCREEN OUTPUT. 211 CHECK go_docking_con IS INITIAL. 212 "创建容器 213 CREATE OBJECT go_docking_con 214 EXPORTING 215 ratio = 95 216 side = cl_gui_docking_container=>dock_at_bottom. 217 218 "拆分为左、右 219 CREATE OBJECT go_splitter_con 220 EXPORTING 221 parent = go_docking_con 222 rows = 1 223 columns = 2. 224 go_splitter_con->set_column_width( EXPORTING id = 1 width = 25 ). 225 226 "左侧再次拆分为上下 227 CREATE OBJECT go_splitter_con_left 228 EXPORTING 229 parent = go_splitter_con->get_container( row = 1 column = 1 ) 230 rows = 2 231 columns = 1. 232 go_splitter_con_left->set_row_height( EXPORTING id = 1 height = 40 ). 233 234 "右侧再次拆分为上下 235 CREATE OBJECT go_splitter_con_right 236 EXPORTING 237 parent = go_splitter_con->get_container( row = 1 column = 2 ) 238 rows = 2 239 columns = 1. 240 go_splitter_con_right->set_row_height( EXPORTING id = 2 height = 40 ). 241 242 "创建TABLES的ALV 243 go_con_tables = go_splitter_con_left->get_container( row = 1 column = 1 ). 244 CREATE OBJECT go_alv_tables 245 EXPORTING 246 i_parent = go_con_tables. 247 248 "创建JOINS的ALV 249 go_con_joins = go_splitter_con_left->get_container( row = 2 column = 1 ). 250 CREATE OBJECT go_alv_joins 251 EXPORTING 252 i_parent = go_con_joins. 253 254 "创建FIELDS1的ALV 255 go_con_fields1 = go_splitter_con_right->get_container( row = 1 column = 1 ). 256 CREATE OBJECT go_alv_fields1 257 EXPORTING 258 i_parent = go_con_fields1. 259 260 "创建FIELDS2的ALV 261 go_con_fields2 = go_splitter_con_right->get_container( row = 2 column = 1 ). 262 CREATE OBJECT go_alv_fields2 263 EXPORTING 264 i_parent = go_con_fields2. 265 266 "事件响应 267 CREATE OBJECT: go_event_tables, go_event_joins, go_event_fields1, go_event_fields2. 268 SET HANDLER: 269 go_event_tables->handle_f4 FOR go_alv_tables, 270 go_event_joins->handle_f4 FOR go_alv_joins, 271 go_event_fields1->handle_f4 FOR go_alv_fields1, 272 go_event_fields1->handle_toolbar FOR go_alv_fields1, 273 go_event_fields1->handle_user_command FOR go_alv_fields1, 274 go_event_fields2->handle_f4 FOR go_alv_fields2. 275 276 "显示ALV 277 PERFORM alv_prepare_toolbar TABLES gt_exclude. 278 PERFORM alv_prepare_layout CHANGING gs_layout. 279 280 d_build_fieldcat: 281 gt_fieldcat_tables gt_f4_tables 'TABNAME' 'X' ' ' 'X' 12 '表名', 282 gt_fieldcat_tables gt_f4_tables 'LEFTJOIN' 'X' 'X' ' ' 6 '左连接', 283 gt_fieldcat_tables gt_f4_tables 'ASTABLE' 'X' ' ' ' ' 4 '别名'. 284 gs_layout-grid_title = '表清单【表顺序可以上下拖动】'. 285 CALL METHOD go_alv_tables->set_table_for_first_display 286 EXPORTING 287 it_toolbar_excluding = gt_exclude 288 is_layout = gs_layout 289 CHANGING 290 it_outtab = gt_tables 291 it_fieldcatalog = gt_fieldcat_tables. 292 293 d_build_fieldcat: 294 gt_fieldcat_joins gt_f4_joins 'TAB1' 'X' ' ' 'X' 12 '表1', 295 gt_fieldcat_joins gt_f4_joins 'FIELD1' 'X' ' ' 'X' 15 '字段1', 296 gt_fieldcat_joins gt_f4_joins 'TAB2' 'X' ' ' 'X' 12 '表2', 297 gt_fieldcat_joins gt_f4_joins 'FIELD2' 'X' ' ' 'X' 15 '字段2(或特定值)'. 298 gs_layout-grid_title = '表关联【请遵循本程序约定:表1在“表清单”中的位置需要在表2以下】'. 299 CALL METHOD go_alv_joins->set_table_for_first_display 300 EXPORTING 301 it_toolbar_excluding = gt_exclude 302 is_layout = gs_layout 303 CHANGING 304 it_outtab = gt_joins 305 it_fieldcatalog = gt_fieldcat_joins. 306 307 d_build_fieldcat: 308 gt_fieldcat_fields1 gt_f4_fields1 'ASTABLE' 'X' ' ' 'X' 12 '表名', 309 gt_fieldcat_fields1 gt_f4_fields1 'FIELDNAME' 'X' ' ' 'X' 15 '字段名', 310 gt_fieldcat_fields1 gt_f4_fields1 'ASFIELD' 'X' ' ' ' ' 8 '字段别名', 311 gt_fieldcat_fields1 gt_f4_fields1 'QUERY' 'X' 'X' ' ' 4 '查询', 312 gt_fieldcat_fields1 gt_f4_fields1 'QUERY_POS' 'X' ' ' ' ' 4 '位置', 313 gt_fieldcat_fields1 gt_f4_fields1 'SINGLE' 'X' 'X' ' ' 4 '单值', 314 gt_fieldcat_fields1 gt_f4_fields1 'DISPLAY' 'X' 'X' ' ' 4 '输出', 315 gt_fieldcat_fields1 gt_f4_fields1 'QFIELDNAME' 'X' ' ' 'X' 8 '单位字段', 316 gt_fieldcat_fields1 gt_f4_fields1 'CFIELDNAME' 'X' ' ' 'X' 8 '货币字段', 317 gt_fieldcat_fields1 gt_f4_fields1 'REF_TABLE' 'X' ' ' ' ' 12 '参照表', 318 gt_fieldcat_fields1 gt_f4_fields1 'REF_FIELD' 'X' ' ' ' ' 15 '参照字段', 319 gt_fieldcat_fields1 gt_f4_fields1 'CONVEXIT' 'X' ' ' ' ' 7 '转换例程', 320 gt_fieldcat_fields1 gt_f4_fields1 'EMPHASIZE' 'X' ' ' 'X' 6 '列颜色', 321 gt_fieldcat_fields1 gt_f4_fields1 'SCRTEXT_L' 'X' ' ' ' ' 20 '字段描述'. 322 gs_layout-grid_title = '字段设置【该表格中的所有字段都会出现在SELECT中,查询字段出现在选择屏幕中,输出字段出现在ALV中】'. 323 CALL METHOD go_alv_fields1->set_table_for_first_display 324 EXPORTING 325 it_toolbar_excluding = gt_exclude 326 is_layout = gs_layout 327 CHANGING 328 it_outtab = gt_fields1 329 it_fieldcatalog = gt_fieldcat_fields1. 330 331 d_build_fieldcat: 332 gt_fieldcat_fields2 gt_f4_fields2 'FIELDNAME' 'X' ' ' ' ' 15 '字段名', 333 gt_fieldcat_fields2 gt_f4_fields2 'QFIELDNAME' 'X' ' ' 'X' 8 '单位字段', 334 gt_fieldcat_fields2 gt_f4_fields2 'CFIELDNAME' 'X' ' ' 'X' 8 '货币字段', 335 gt_fieldcat_fields2 gt_f4_fields2 'REF_TABLE' 'X' ' ' ' ' 12 '参照表', 336 gt_fieldcat_fields2 gt_f4_fields2 'REF_FIELD' 'X' ' ' ' ' 15 '参照字段', 337 gt_fieldcat_fields2 gt_f4_fields2 'CONVEXIT' 'X' ' ' ' ' 7 '转换例程', 338 gt_fieldcat_fields2 gt_f4_fields2 'EMPHASIZE' 'X' ' ' 'X' 6 '列颜色', 339 gt_fieldcat_fields2 gt_f4_fields2 'SCRTEXT_L' 'X' ' ' ' ' 20 '字段描述'. 340 gs_layout-grid_title = '附加字段【如:汇总字段、合并字段等】'. 341 CALL METHOD go_alv_fields2->set_table_for_first_display 342 EXPORTING 343 it_toolbar_excluding = gt_exclude 344 is_layout = gs_layout 345 CHANGING 346 it_outtab = gt_fields2 347 it_fieldcatalog = gt_fieldcat_fields2. 348 349 "注册事件 350 go_alv_tables->register_f4_for_fields( EXPORTING it_f4 = gt_f4_tables ). 351 go_alv_joins->register_f4_for_fields( EXPORTING it_f4 = gt_f4_joins ). 352 go_alv_fields1->register_f4_for_fields( EXPORTING it_f4 = gt_f4_fields1 ). 353 go_alv_fields2->register_f4_for_fields( EXPORTING it_f4 = gt_f4_fields2 ). 354 go_alv_tables->register_edit_event( EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_modified ). 355 go_alv_joins->register_edit_event( EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_modified ). 356 go_alv_fields1->register_edit_event( EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_modified ). 357 go_alv_fields2->register_edit_event( EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_modified ). 358 359 AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_prog. 360 PERFORM f4_prog. 361 362 AT SELECTION-SCREEN. 363 go_alv_tables->check_changed_data( ). 364 go_alv_joins->check_changed_data( ). 365 go_alv_fields1->check_changed_data( ). 366 go_alv_fields2->check_changed_data( ). 367 368 g_indxid = p_prog && 'RG'. 369 ok_code = sy-ucomm. 370 CLEAR sy-ucomm. 371 CASE ok_code. 372 WHEN 'FC01'. 373 EXPORT tables = gt_tables joins = gt_joins fields1 = gt_fields1 fields2 = gt_fields2 TO DATABASE indx(st) ID g_indxid. 374 WHEN 'FC02'. 375 IMPORT tables = gt_tables joins = gt_joins fields1 = gt_fields1 fields2 = gt_fields2 FROM DATABASE indx(st) ID g_indxid. 376 PERFORM alv_refresh_display. 377 WHEN 'FC03'. 378 PERFORM download. 379 WHEN 'FC04'. 380 PERFORM upload. 381 PERFORM alv_refresh_display. 382 WHEN 'GEN'. 383 PERFORM check. 384 CHECK g_flag_error IS INITIAL. 385 PERFORM process_data. 386 PERFORM generate. 387 ENDCASE. 388 389 *&---------------------------------------------------------------------* 390 *& Form alv_prepare_toolbar 391 *&---------------------------------------------------------------------* 392 * text 393 *----------------------------------------------------------------------* 394 FORM alv_prepare_toolbar TABLES pt_exclude TYPE ui_functions. 395 REFRESH: pt_exclude. 396 397 APPEND cl_gui_alv_grid=>mc_fc_maximum TO pt_exclude. 398 APPEND cl_gui_alv_grid=>mc_fc_minimum TO pt_exclude. 399 APPEND cl_gui_alv_grid=>mc_fc_subtot TO pt_exclude. 400 APPEND cl_gui_alv_grid=>mc_fc_sum TO pt_exclude. 401 APPEND cl_gui_alv_grid=>mc_fc_average TO pt_exclude. 402 APPEND cl_gui_alv_grid=>mc_mb_sum TO pt_exclude. 403 APPEND cl_gui_alv_grid=>mc_mb_subtot TO pt_exclude. 404 APPEND cl_gui_alv_grid=>mc_fc_sort_asc TO pt_exclude. 405 APPEND cl_gui_alv_grid=>mc_fc_sort_dsc TO pt_exclude. 406 APPEND cl_gui_alv_grid=>mc_fc_find TO pt_exclude. 407 APPEND cl_gui_alv_grid=>mc_fc_filter TO pt_exclude. 408 APPEND cl_gui_alv_grid=>mc_fc_print TO pt_exclude. 409 APPEND cl_gui_alv_grid=>mc_fc_print_prev TO pt_exclude. 410 APPEND cl_gui_alv_grid=>mc_mb_export TO pt_exclude. 411 APPEND cl_gui_alv_grid=>mc_fc_graph TO pt_exclude. 412 APPEND cl_gui_alv_grid=>mc_mb_export TO pt_exclude. 413 APPEND cl_gui_alv_grid=>mc_mb_view TO pt_exclude. 414 APPEND cl_gui_alv_grid=>mc_fc_detail TO pt_exclude. 415 APPEND cl_gui_alv_grid=>mc_fc_help TO pt_exclude. 416 APPEND cl_gui_alv_grid=>mc_fc_info TO pt_exclude. 417 APPEND cl_gui_alv_grid=>mc_mb_variant TO pt_exclude. 418 APPEND cl_gui_alv_grid=>mc_fc_refresh TO pt_exclude. 419 APPEND cl_gui_alv_grid=>mc_fc_check TO pt_exclude. 420 APPEND cl_gui_alv_grid=>mc_fc_loc_copy TO pt_exclude. 421 * APPEND cl_gui_alv_grid=>mc_fc_loc_insert_row TO pt_exclude. 422 * APPEND cl_gui_alv_grid=>mc_fc_loc_delete_row TO pt_exclude. 423 APPEND cl_gui_alv_grid=>mc_fc_loc_copy_row TO pt_exclude. 424 * APPEND cl_gui_alv_grid=>mc_fc_loc_append_row TO pt_exclude. 425 APPEND cl_gui_alv_grid=>mc_fc_loc_undo TO pt_exclude. 426 APPEND cl_gui_alv_grid=>mc_fc_loc_cut TO pt_exclude. 427 APPEND cl_gui_alv_grid=>mc_mb_paste TO pt_exclude. 428 ENDFORM. "alv_prepare_toolbar 429 *&---------------------------------------------------------------------* 430 *& Form alv_prepare_layout 431 *&---------------------------------------------------------------------* 432 * text 433 *----------------------------------------------------------------------* 434 * -->PS_LAYOUT text 435 *----------------------------------------------------------------------* 436 FORM alv_prepare_layout CHANGING ps_layout TYPE lvc_s_layo. 437 ps_layout-zebra = 'X'. 438 ps_layout-sel_mode = 'A'. 439 ps_layout-smalltitle = 'X'. 440 ENDFORM. "alv_prepare_layout 441 *&---------------------------------------------------------------------* 442 *& Form handle_toolbar 443 *&---------------------------------------------------------------------* 444 * text 445 *----------------------------------------------------------------------* 446 FORM handle_toolbar USING e_object TYPE REF TO cl_alv_event_toolbar_set 447 e_interactive TYPE char1. 448 DATA: ls_toolbar TYPE stb_button. 449 450 ls_toolbar-function = 'IMPORT'. 451 ls_toolbar-icon = icon_import. 452 ls_toolbar-text = '导入表格字段'. 453 ls_toolbar-quickinfo = '导入表格字段'. 454 APPEND ls_toolbar TO e_object->mt_toolbar. 455 CLEAR: ls_toolbar. 456 457 ls_toolbar-function = 'ALL'. 458 ls_toolbar-text = '输出:全选'. 459 ls_toolbar-quickinfo = '全部输出'. 460 APPEND ls_toolbar TO e_object->mt_toolbar. 461 CLEAR: ls_toolbar. 462 463 ls_toolbar-function = 'NONE'. 464 ls_toolbar-text = '输出:取消全选'. 465 ls_toolbar-quickinfo = '全部不输出'. 466 APPEND ls_toolbar TO e_object->mt_toolbar. 467 CLEAR: ls_toolbar. 468 ENDFORM. "handle_toolbar 469 *&---------------------------------------------------------------------* 470 *& Form handle_user_command 471 *&---------------------------------------------------------------------* 472 * text 473 *----------------------------------------------------------------------* 474 FORM handle_user_command USING e_ucomm. 475 DATA: l_astable TYPE tabname, 476 l_tabname TYPE tabname, 477 lt_dfies_tab TYPE TABLE OF dfies WITH HEADER LINE. 478 479 ok_code = e_ucomm. 480 CLEAR e_ucomm. 481 482 CASE ok_code. 483 WHEN 'IMPORT'. 484 "选择表 485 PERFORM f4_table CHANGING l_astable. 486 CHECK l_astable IS NOT INITIAL. 487 488 "获取真实表名 489 READ TABLE gt_tables WITH KEY astable = l_astable INTO gs_table. 490 IF sy-subrc = 0. 491 l_tabname = gs_table-tabname. 492 ELSE. 493 l_tabname = l_astable. 494 ENDIF. 495 496 "获取字段 497 CALL FUNCTION 'DDIF_FIELDINFO_GET' 498 EXPORTING 499 tabname = l_tabname 500 langu = sy-langu 501 TABLES 502 dfies_tab = lt_dfies_tab[] 503 EXCEPTIONS 504 not_found = 1 505 internal_error = 2 506 OTHERS = 3. 507 CHECK sy-subrc = 0. 508 509 "添加到ALV 510 LOOP AT lt_dfies_tab. 511 CHECK lt_dfies_tab-fieldname <> 'MANDT'. 512 CLEAR: gs_field1. 513 gs_field1-astable = l_astable. 514 gs_field1-fieldname = lt_dfies_tab-fieldname. 515 gs_field1-scrtext_l = lt_dfies_tab-fieldtext. 516 gs_field1-ref_table = l_tabname. 517 gs_field1-ref_field = lt_dfies_tab-fieldname. 518 APPEND gs_field1 TO gt_fields1. 519 ENDLOOP. 520 521 go_alv_fields1->refresh_table_display( ). 522 523 WHEN 'ALL'. 524 gs_field1-display = 'X'. 525 MODIFY gt_fields1 FROM gs_field1 TRANSPORTING display WHERE display = ''. 526 go_alv_fields1->refresh_table_display( ). 527 WHEN 'NONE'. 528 gs_field1-display = ''. 529 MODIFY gt_fields1 FROM gs_field1 TRANSPORTING display WHERE display = 'X'. 530 go_alv_fields1->refresh_table_display( ). 531 ENDCASE. 532 ENDFORM. "handle_user_command 533 *&---------------------------------------------------------------------* 534 *& Form handle_f4 535 *&---------------------------------------------------------------------* 536 * text 537 *----------------------------------------------------------------------* 538 FORM handle_f4 USING e_fieldname TYPE lvc_fname 539 e_fieldvalue TYPE lvc_value 540 es_row_no TYPE lvc_s_roid 541 er_event_data TYPE REF TO cl_alv_event_data 542 et_bad_cells TYPE lvc_t_modi. 543 DATA: ls_row TYPE lvc_s_row, 544 ls_col TYPE lvc_s_col, 545 ls_modi TYPE lvc_s_modi, 546 l_tabname TYPE tabname, 547 l_fieldtext TYPE fieldtext, 548 l_ref_table TYPE lvc_rtname, 549 l_ref_field TYPE lvc_rfname. 550 FIELD-SYMBOLS: <lt_modi> TYPE lvc_t_modi. 551 552 er_event_data->m_event_handled = 'X'. 553 554 CASE e_fieldname. 555 WHEN 'TABNAME'. 556 PERFORM f4_dd_table(rsaqddic) USING 'SAPLAQJD_CNTRL' 557 '0300' 558 'G_DYN_0300-TNAME' 559 CHANGING e_fieldvalue. "搜索帮助代码,来于SQVI中“插入表”的搜索帮助 560 561 WHEN 'TAB1' OR 'TAB2' OR 'ASTABLE'. 562 PERFORM f4_table CHANGING e_fieldvalue. 563 564 WHEN 'FIELD1' OR 'FIELD2' OR 'FIELDNAME'. 565 go_alv_tables->check_changed_data( ). 566 567 IF e_fieldname = 'FIELD1'. 568 READ TABLE gt_joins INDEX es_row_no-row_id INTO gs_join. 569 CHECK gs_join-tab1 IS NOT INITIAL. 570 l_tabname = gs_join-tab1. 571 ELSEIF e_fieldname = 'FIELD2'. 572 READ TABLE gt_joins INDEX es_row_no-row_id INTO gs_join. 573 CHECK gs_join-tab2 IS NOT INITIAL. 574 l_tabname = gs_join-tab2. 575 ELSEIF e_fieldname = 'FIELDNAME'. 576 READ TABLE gt_fields1 INDEX es_row_no-row_id INTO gs_field1. 577 CHECK gs_field1-astable IS NOT INITIAL. 578 l_tabname = gs_field1-astable. 579 l_fieldtext = gs_field1-scrtext_l. 580 l_ref_table = gs_field1-ref_table. 581 l_ref_field = gs_field1-ref_field. 582 ENDIF. 583 584 READ TABLE gt_tables WITH KEY astable = l_tabname INTO gs_table. 585 IF sy-subrc = 0. 586 l_tabname = gs_table-tabname. 587 ENDIF. 588 589 PERFORM f4_field USING l_tabname CHANGING e_fieldvalue l_fieldtext l_ref_table l_ref_field. 590 591 WHEN 'QFIELDNAME' OR 'CFIELDNAME'. 592 PERFORM f4_field_in_itab CHANGING e_fieldvalue. 593 594 WHEN 'EMPHASIZE'. 595 PERFORM f4_color CHANGING e_fieldvalue. 596 597 WHEN OTHERS. 598 EXIT. 599 ENDCASE. 600 601 ASSIGN er_event_data->m_data->* TO <lt_modi>. 602 ls_modi-row_id = es_row_no-row_id." 603 ls_modi-fieldname = e_fieldname. 604 ls_modi-value = e_fieldvalue. 605 APPEND ls_modi TO <lt_modi>. 606 IF e_fieldname = 'FIELDNAME'. 607 ls_modi-row_id = es_row_no-row_id." 608 ls_modi-fieldname = 'SCRTEXT_L'. 609 ls_modi-value = l_fieldtext. 610 APPEND ls_modi TO <lt_modi>. 611 612 ls_modi-row_id = es_row_no-row_id." 613 ls_modi-fieldname = 'REF_TABLE'. 614 ls_modi-value = l_ref_table. 615 APPEND ls_modi TO <lt_modi>. 616 617 ls_modi-row_id = es_row_no-row_id." 618 ls_modi-fieldname = 'REF_FIELD'. 619 ls_modi-value = l_ref_field. 620 APPEND ls_modi TO <lt_modi>. 621 ENDIF. 622 623 ENDFORM. "handle_f4 624 *&---------------------------------------------------------------------* 625 *& Form F4_PROG 626 *&---------------------------------------------------------------------* 627 * 程序名称的搜索帮助(同SE38) 628 *----------------------------------------------------------------------* 629 FORM f4_prog . 630 DATA: lt_dynpfields TYPE TABLE OF dynpread WITH HEADER LINE. 631 632 lt_dynpfields-fieldname = 'P_PROG'. 633 APPEND lt_dynpfields. 634 635 CALL FUNCTION 'DYNP_VALUES_READ' 636 EXPORTING 637 dyname = sy-repid 638 dynumb = sy-dynnr 639 TABLES 640 dynpfields = lt_dynpfields[]. 641 642 READ TABLE lt_dynpfields INDEX 1. 643 p_prog = lt_dynpfields-fieldvalue. 644 645 CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4' 646 EXPORTING 647 object_type = 'PROG' 648 object_name = p_prog 649 suppress_selection = 'X' 650 IMPORTING 651 object_name_selected = p_prog 652 EXCEPTIONS 653 cancel = 01. 654 ENDFORM. " F4_PROG 655 *&---------------------------------------------------------------------* 656 *& Form PROCESS_DATA 657 *&---------------------------------------------------------------------* 658 * 处理数据 659 *----------------------------------------------------------------------* 660 FORM process_data . 661 DATA: l_tabname TYPE tabname, 662 l_as_flag TYPE c. 663 664 LOOP AT gt_fields1 INTO gs_field1. 665 "取真实表名 666 READ TABLE gt_tables WITH KEY astable = gs_field1-astable INTO gs_table. 667 IF sy-subrc = 0. 668 l_tabname = gs_table-tabname. 669 l_as_flag = 'X'. 670 ELSE. 671 l_tabname = gs_field1-astable. 672 l_as_flag = ''. 673 ENDIF. 674 675 "根据单选和多选情况,确定选择条件的参数 676 IF gs_field1-query = 'X'. 677 IF gs_field1-asfield IS INITIAL. 678 gs_field1-sel_field = gs_field1-fieldname. 679 ELSE. 680 gs_field1-sel_field = gs_field1-asfield. 681 ENDIF. 682 683 IF gs_field1-single = 'X'. 684 gs_field1-sel_field = 'P_' && gs_field1-sel_field. 685 ELSE. 686 gs_field1-sel_field = 'S_' && gs_field1-sel_field. 687 ENDIF. 688 ENDIF. 689 690 "确定SQL字段的名称 691 IF l_as_flag = ''. 692 gs_field1-sql_field = l_tabname && '~' && gs_field1-fieldname. 693 ELSE. 694 gs_field1-sql_field = gs_field1-astable && '~' && gs_field1-fieldname. 695 ENDIF. 696 697 "确定显示字段的名称 698 IF gs_field1-asfield IS INITIAL. 699 gs_field1-out_field = gs_field1-fieldname. 700 ELSE. 701 gs_field1-out_field = gs_field1-asfield. 702 "SQL字段别名处理 703 CONCATENATE gs_field1-sql_field 'AS' gs_field1-asfield INTO gs_field1-sql_field SEPARATED BY space. 704 ENDIF. 705 706 "确定参照字段的名称 707 gs_field1-typ_field = l_tabname && '-' && gs_field1-fieldname. 708 709 gs_field1-mark = '"' && gs_field1-scrtext_l. 710 SHIFT gs_field1-mark RIGHT BY 10 PLACES. 711 MODIFY gt_fields1 FROM gs_field1 TRANSPORTING sel_field sql_field out_field typ_field mark. 712 ENDLOOP. 713 714 gt_query = gt_fields1. 715 DELETE gt_query WHERE query = ''. 716 SORT gt_query STABLE BY query_pos. 717 718 LOOP AT gt_fields2 INTO gs_field2. 719 IF gs_field2-ref_table IS INITIAL. 720 gs_field2-typ_field = gs_field2-ref_field. 721 ELSE. 722 gs_field2-typ_field = gs_field2-ref_table && '-' && gs_field2-ref_field. 723 ENDIF. 724 MODIFY gt_fields2 FROM gs_field2 TRANSPORTING typ_field. 725 ENDLOOP. 726 ENDFORM. " PROCESS_DATA 727 728 *&---------------------------------------------------------------------* 729 *& Form generate 730 *&---------------------------------------------------------------------* 731 * 生成程序 732 *----------------------------------------------------------------------* 733 FORM generate. 734 REFRESH gt_codes. 735 736 CHECK p_prog(1) = 'Y' OR p_prog(1) = 'Z'. 737 738 IF strlen( p_prog ) > 20. 739 MESSAGE '程序名长度不能超过20' TYPE 'E' DISPLAY LIKE 'I'. 740 ENDIF. 741 742 SELECT SINGLE progname INTO p_prog FROM reposrc WHERE progname = p_prog. 743 IF sy-subrc = 0. 744 * MESSAGE '程序已经存在' TYPE 'E' DISPLAY LIKE 'I'. 745 ENDIF. 746 747 "程序名 748 PERFORM gen_report_name. 749 "TABLES 750 PERFORM gen_tables_clause. 751 "SELECTION-SCREEN 752 PERFORM gen_selection_screen. 753 "类型定义 754 PERFORM gen_types. 755 "数据定义 756 PERFORM gen_data_defination. 757 "初始化 758 PERFORM gen_initialization. 759 "START-OF-SELECTION 760 PERFORM gen_start_of_selection. 761 "FORM GET_DATA 762 PERFORM gen_form_get_data. 763 "FORM PROCESS_DATA 764 PERFORM gen_form_process_data. 765 "FORM BUILD_FIELDCAT 766 PERFORM gen_form_build_fieldcat. 767 "FORM DISPLAY_DATA 768 PERFORM gen_form_display_data. 769 "FORM PF_STATUS_ALV 770 PERFORM gen_form_pf_status_alv. 771 "FORM USER_COMMAND_ALV 772 PERFORM gen_form_user_command_alv. 773 774 INSERT REPORT p_prog FROM gt_codes. 775 ENDFORM. "GENERATE 776 *&---------------------------------------------------------------------* 777 *& Form GEN_REPORT_NAME 778 *&---------------------------------------------------------------------* 779 * text 780 *----------------------------------------------------------------------* 781 FORM gen_report_name . 782 CONCATENATE 'REPORT' p_prog INTO g_code SEPARATED BY space. 783 g_code = g_code && '.'. 784 append_code: g_code, ''. 785 ENDFORM. " GEN_REPORT_NAME 786 *&---------------------------------------------------------------------* 787 *& Form GEN_TABLES_CLAUSE 788 *&---------------------------------------------------------------------* 789 * text 790 *----------------------------------------------------------------------* 791 FORM gen_tables_clause . 792 DATA: lt_tables TYPE TABLE OF typ_table. 793 794 lt_tables = gt_tables. 795 SORT lt_tables BY tabname. 796 DELETE ADJACENT DUPLICATES FROM lt_tables COMPARING tabname. 797 798 g_code = 'TABLES:'. 799 LOOP AT lt_tables INTO gs_table. 800 CONCATENATE g_code gs_table-tabname INTO g_code SEPARATED BY space. 801 IF sy-tabix = lines( lt_tables ). 802 g_code = g_code && '.'. 803 ELSE. 804 g_code = g_code && ','. 805 ENDIF. 806 ENDLOOP. 807 append_code: g_code, ''. 808 ENDFORM. " GEN_TABLES_CLAUSE 809 *&---------------------------------------------------------------------* 810 *& Form GEN_SELECTION_SCREEN 811 *&---------------------------------------------------------------------* 812 * text 813 *----------------------------------------------------------------------* 814 FORM gen_selection_screen . 815 append_code 'SELECTION-SCREEN BEGIN OF BLOCK 001 WITH FRAME TITLE TEXT-001.'. 816 817 LOOP AT gt_query INTO gs_query. 818 IF gs_query-single = 'X'. 819 CONCATENATE 'PARAMETERS' gs_query-sel_field 'TYPE' gs_query-typ_field INTO g_code SEPARATED BY space. 820 ELSE. 821 CONCATENATE 'SELECT-OPTIONS' gs_query-sel_field 'FOR' gs_query-typ_field INTO g_code SEPARATED BY space. 822 ENDIF. 823 g_code = g_code && '.' && gs_query-mark. 824 append_code g_code. 825 ENDLOOP. 826 827 append_code 'SELECTION-SCREEN END OF BLOCK 001.'. 828 append_code ''. 829 ENDFORM. " GEN_SELECTION_SCREEN 830 *&---------------------------------------------------------------------* 831 *& Form GEN_TYPES 832 *&---------------------------------------------------------------------* 833 * text 834 *----------------------------------------------------------------------* 835 FORM gen_types . 836 DATA: l_mark TYPE c LENGTH 60. 837 838 append_code: 839 'TYPES:', 840 ' BEGIN OF TYP_DATA,'. 841 LOOP AT gt_fields1 INTO gs_field1. 842 CONCATENATE gs_field1-out_field 'TYPE' gs_field1-typ_field INTO g_code SEPARATED BY space. 843 g_code = g_code && ',' && gs_field1-mark. 844 SHIFT g_code RIGHT BY 4 PLACES. 845 append_code g_code. 846 ENDLOOP. 847 848 LOOP AT gt_fields2 INTO gs_field2. 849 CONCATENATE gs_field2-fieldname 'TYPE' gs_field2-typ_field INTO g_code SEPARATED BY space. 850 l_mark = '"' && gs_field2-scrtext_l. 851 SHIFT l_mark RIGHT BY 10 PLACES. 852 g_code = g_code && ',' && l_mark. 853 SHIFT g_code RIGHT BY 4 PLACES. 854 append_code g_code. 855 ENDLOOP. 856 857 append_code: ' END OF TYP_DATA.', ''. 858 ENDFORM. " GEN_TYPES 859 *&---------------------------------------------------------------------* 860 *& Form GEN_DATA_DEFINATION 861 *&---------------------------------------------------------------------* 862 * text 863 *----------------------------------------------------------------------* 864 FORM gen_data_defination . 865 append_code: 866 ' DATA:', 867 ' GT_DATA TYPE TABLE OF TYP_DATA,', 868 ' GS_DATA TYPE TYP_DATA,', 869 ' GT_FIELDCAT TYPE LVC_T_FCAT,', 870 ' GS_FIELDCAT TYPE LVC_S_FCAT,', 871 ' GS_LAYOUT TYPE LVC_S_LAYO.', 872 ''. 873 ENDFORM. " GEN_DATA_DEFINATION 874 *&---------------------------------------------------------------------* 875 *& Form GEN_INITIALIZATION 876 *&---------------------------------------------------------------------* 877 * text 878 *----------------------------------------------------------------------* 879 FORM gen_initialization . 880 append_code 'INITIALIZATION.'. 881 LOOP AT gt_query INTO gs_query. 882 g_code = ' %_' && gs_query-sel_field && '_%_APP_%-TEXT'. 883 g_code = g_code && ' = ''' && gs_query-scrtext_l && '''.'. 884 append_code g_code. 885 ENDLOOP. 886 append_code ''. 887 ENDFORM. " GEN_INITIALIZATION 888 *&---------------------------------------------------------------------* 889 *& Form GEN_START_OF_SELECTION 890 *&---------------------------------------------------------------------* 891 * text 892 *----------------------------------------------------------------------* 893 FORM gen_start_of_selection . 894 append_code: 895 'START-OF-SELECTION.', 896 ' PERFORM GET_DATA.', 897 ' PERFORM PROCESS_DATA.', 898 ' PERFORM DISPLAY_DATA.', 899 ''. 900 ENDFORM. " GEN_START_OF_SELECTION 901 *&---------------------------------------------------------------------* 902 *& Form GEN_FORM_GET_DATA 903 *&---------------------------------------------------------------------* 904 * text 905 *----------------------------------------------------------------------* 906 FORM gen_form_get_data . 907 DATA: l_joinfield TYPE string, 908 l_tabname TYPE tabname, 909 l_join_counts TYPE i, 910 l_index TYPE i. 911 912 append_code: 913 '*&---------------------------------------------------------------------*', 914 '*& FORM GET_DATA ', 915 '*&---------------------------------------------------------------------*', 916 '* 获取数据 ', 917 '*----------------------------------------------------------------------*', 918 'FORM GET_DATA. '. 919 920 "SELECT字段 921 append_code ' SELECT'. 922 LOOP AT gt_fields1 INTO gs_field1. 923 g_code = gs_field1-sql_field && gs_field1-mark. 924 SHIFT g_code RIGHT BY 4 PLACES. 925 append_code g_code. 926 ENDLOOP. 927 IF gt_fields2 IS INITIAL. 928 append_code ' INTO TABLE GT_DATA'. 929 ELSE. 930 append_code ' INTO CORRESPONDING FIELDS OF TABLE GT_DATA'. 931 ENDIF. 932 933 "FROM语句 934 READ TABLE gt_tables INDEX 1 INTO gs_table. 935 CONCATENATE 'FROM' gs_table-tabname INTO g_code SEPARATED BY space. 936 IF gs_table-astable IS NOT INITIAL. 937 CONCATENATE g_code 'AS' gs_table-astable INTO g_code SEPARATED BY space. 938 ENDIF. 939 SHIFT g_code RIGHT BY 4 PLACES. 940 append_code g_code. 941 942 "JOIN语句 943 LOOP AT gt_tables INTO gs_table FROM 2. 944 IF gs_table-leftjoin = 'X'. 945 CONCATENATE ' LEFT JOIN' gs_table-tabname INTO g_code SEPARATED BY space. 946 ELSE. 947 CONCATENATE ' INNER JOIN' gs_table-tabname INTO g_code SEPARATED BY space. 948 ENDIF. 949 950 IF gs_table-astable IS INITIAL. 951 l_tabname = gs_table-tabname. 952 ELSE. 953 l_tabname = gs_table-astable. 954 CONCATENATE g_code 'AS' l_tabname INTO g_code SEPARATED BY space. 955 ENDIF. 956 957 CONCATENATE g_code 'ON' INTO g_code SEPARATED BY space. 958 959 CLEAR: l_join_counts. 960 LOOP AT gt_joins INTO gs_join WHERE tab1 = l_tabname. 961 ADD 1 TO l_join_counts. 962 IF l_join_counts > 1. 963 CONCATENATE g_code 'AND' INTO g_code SEPARATED BY space. 964 ENDIF. 965 966 l_joinfield = gs_join-tab1 && '~' && gs_join-field1. 967 CONCATENATE g_code l_joinfield '=' INTO g_code SEPARATED BY space. 968 969 IF gs_join-tab2 IS INITIAL. 970 l_joinfield = gs_join-field2. 971 ELSE. 972 l_joinfield = gs_join-tab2 && '~' && gs_join-field2. 973 ENDIF. 974 CONCATENATE g_code l_joinfield INTO g_code SEPARATED BY space. 975 ENDLOOP. 976 append_code g_code. 977 ENDLOOP. 978 979 "WHERE语句 980 LOOP AT gt_query INTO gs_query. 981 l_index = sy-tabix. 982 983 g_code = gs_query-astable && '~' && gs_query-fieldname. 984 IF l_index = 1. 985 CONCATENATE ' WHERE' g_code INTO g_code SEPARATED BY space. 986 ELSE. 987 CONCATENATE ' AND' g_code INTO g_code SEPARATED BY space. 988 ENDIF. 989 IF gs_query-single = 'X'. 990 CONCATENATE g_code '=' gs_query-sel_field INTO g_code SEPARATED BY space. 991 ELSE. 992 CONCATENATE g_code 'IN' gs_query-sel_field INTO g_code SEPARATED BY space. 993 ENDIF. 994 995 IF l_index = lines( gt_query ). 996 g_code = g_code && '.'. 997 ENDIF. 998 999 append_code g_code. 1000 ENDLOOP. 1001 1002 append_code 'ENDFORM. "GET_DATA'. 1003 ENDFORM. " GEN_FORM_GET_DATA 1004 *&---------------------------------------------------------------------* 1005 *& Form GEN_FORM_PROCESS_DATA 1006 *&---------------------------------------------------------------------* 1007 * text 1008 *----------------------------------------------------------------------* 1009 FORM gen_form_process_data . 1010 append_code: 1011 '*&---------------------------------------------------------------------*', 1012 '*& FORM PROCESS_DATA ', 1013 '*&---------------------------------------------------------------------*', 1014 '* 处理数据 ', 1015 '*----------------------------------------------------------------------*', 1016 'FORM PROCESS_DATA. ', 1017 ' ', 1018 'ENDFORM. "PROCESS_DATA '. 1019 ENDFORM. "GEN_FORM_PROCESS_DATA 1020 *&---------------------------------------------------------------------* 1021 *& Form GEN_FORM_BUILD_FIELDCAT 1022 *&---------------------------------------------------------------------* 1023 * text 1024 *----------------------------------------------------------------------* 1025 FORM gen_form_build_fieldcat . 1026 append_code: 1027 '*&---------------------------------------------------------------------*', 1028 '*& Form BUILD_FIELDCAT ', 1029 '*&---------------------------------------------------------------------*', 1030 '* TEXT ', 1031 '*----------------------------------------------------------------------*', 1032 'FORM BUILD_FIELDCAT USING P_FIELDNAME TYPE FIELDNAME ', 1033 ' P_QFIELDNAME TYPE LVC_QFNAME ', 1034 ' P_CFIELDNAME TYPE LVC_CFNAME ', 1035 ' P_REF_TABLE TYPE LVC_RTNAME ', 1036 ' P_REF_FIELD TYPE LVC_RFNAME ', 1037 ' P_CONVEXIT TYPE CONVEXIT ', 1038 ' P_EMPHASIZE TYPE LVC_EMPHSZ ', 1039 ' P_SCRTEXT_L TYPE SCRTEXT_L. ', 1040 ' GS_FIELDCAT-FIELDNAME = P_FIELDNAME. ', 1041 ' GS_FIELDCAT-QFIELDNAME = P_QFIELDNAME. ', 1042 ' GS_FIELDCAT-CFIELDNAME = P_CFIELDNAME. ', 1043 ' GS_FIELDCAT-REF_TABLE = P_REF_TABLE. ', 1044 ' GS_FIELDCAT-REF_FIELD = P_REF_FIELD. ', 1045 ' GS_FIELDCAT-CONVEXIT = P_CONVEXIT. ', 1046 ' GS_FIELDCAT-EMPHASIZE = P_EMPHASIZE. ', 1047 ' GS_FIELDCAT-SCRTEXT_L = P_SCRTEXT_L. ', 1048 ' GS_FIELDCAT-COLDDICTXT = ''L''. ', 1049 ' APPEND GS_FIELDCAT TO GT_FIELDCAT. ', 1050 ' CLEAR: GS_FIELDCAT. ', 1051 'ENDFORM. "BUILD_FIELDCAT '. 1052 ENDFORM. " GEN_FORM_BUILD_FIELDCAT 1053 *&---------------------------------------------------------------------* 1054 *& Form GEN_FORM_DISPLAY_DATA 1055 *&---------------------------------------------------------------------* 1056 * text 1057 *----------------------------------------------------------------------* 1058 FORM gen_form_display_data . 1059 append_code: 1060 '*&---------------------------------------------------------------------*', 1061 '*& FORM DISPLAY_DATA ', 1062 '*&---------------------------------------------------------------------*', 1063 '* 显示数据 ', 1064 '*----------------------------------------------------------------------*', 1065 'FORM DISPLAY_DATA. '. 1066 1067 "FIELDCAT 1068 LOOP AT gt_fields1 INTO gs_field1 WHERE display = 'X'. 1069 g_code = ' PERFORM BUILD_FIELDCAT USING ''' && 1070 gs_field1-out_field && ''' ''' && 1071 gs_field1-qfieldname && ''' ''' && 1072 gs_field1-cfieldname && ''' ''' && 1073 gs_field1-ref_table && ''' ''' && 1074 gs_field1-ref_field && ''' ''' && 1075 gs_field1-convexit && ''' ''' && 1076 gs_field1-emphasize && ''' ''' && 1077 gs_field1-scrtext_l && '''.'. 1078 append_code g_code. 1079 ENDLOOP. 1080 LOOP AT gt_fields2 INTO gs_field2. 1081 g_code = ' PERFORM BUILD_FIELDCAT USING ''' && 1082 gs_field2-fieldname && ''' ''' && 1083 gs_field2-qfieldname && ''' ''' && 1084 gs_field2-cfieldname && ''' ''' && 1085 gs_field2-ref_table && ''' ''' && 1086 gs_field2-ref_field && ''' ''' && 1087 gs_field2-convexit && ''' ''' && 1088 gs_field2-emphasize && ''' ''' && 1089 gs_field2-scrtext_l && '''.'. 1090 append_code g_code. 1091 ENDLOOP. 1092 append_code ''. 1093 1094 "LAYOUT 1095 append_code: 1096 ' gs_layout-cwidth_opt = ''X''.', 1097 ' gs_layout-zebra = ''X''.', 1098 ''. 1099 1100 append_code: 1101 ' CALL FUNCTION ''REUSE_ALV_GRID_DISPLAY_LVC'' ', 1102 ' EXPORTING ', 1103 ' I_CALLBACK_PROGRAM = SY-REPID ', 1104 '" I_CALLBACK_PF_STATUS_SET = ''PF_STATUS_ALV'' ', 1105 ' I_CALLBACK_USER_COMMAND = ''USER_COMMAND_ALV'' ', 1106 ' IT_FIELDCAT_LVC = GT_FIELDCAT ', 1107 ' IS_LAYOUT_LVC = GS_LAYOUT ', 1108 ' I_DEFAULT = ''X'' ', 1109 ' I_SAVE = ''A'' ', 1110 ' TABLES ', 1111 ' T_OUTTAB = GT_DATA ', 1112 ' EXCEPTIONS ', 1113 ' OTHERS = 1. '. 1114 "ALV展示 1115 append_code 'ENDFORM. "DISPLAY_DATA'. 1116 ENDFORM. " GEN_FORM_DISPLAY_DATA 1117 *&---------------------------------------------------------------------* 1118 *& Form GEN_FORM_PF_STATUS_ALV 1119 *&---------------------------------------------------------------------* 1120 * text 1121 *----------------------------------------------------------------------* 1122 FORM gen_form_pf_status_alv . 1123 append_code: 1124 '**&---------------------------------------------------------------------*', 1125 '**& FORM PF_STATUS_ALV ', 1126 '**&---------------------------------------------------------------------*', 1127 '** TEXT ', 1128 '**----------------------------------------------------------------------*', 1129 '*FORM PF_STATUS_ALV USING RT_EXTAB TYPE SLIS_T_EXTAB . ', 1130 '* SET PF-STATUS ''STATUS_ALV'' EXCLUDING RT_EXTAB. ', 1131 '*ENDFORM. "PF_STATUS_ALV '. 1132 ENDFORM. " GEN_FORM_PF_STATUS_ALV 1133 *&---------------------------------------------------------------------* 1134 *& Form GEN_FORM_USER_COMMAND_ALV 1135 *&---------------------------------------------------------------------* 1136 * text 1137 *----------------------------------------------------------------------* 1138 FORM gen_form_user_command_alv . 1139 append_code: 1140 '*&---------------------------------------------------------------------*', 1141 '*& FORM USER_COMMAND_ALV ', 1142 '*&---------------------------------------------------------------------*', 1143 '* TEXT ', 1144 '*----------------------------------------------------------------------*', 1145 'FORM USER_COMMAND_ALV USING R_UCOMM LIKE SY-UCOMM ', 1146 ' RS_SELFIELD TYPE SLIS_SELFIELD. ', 1147 ' CASE R_UCOMM. ', 1148 ' WHEN ''&IC1''. ', 1149 ' CASE RS_SELFIELD-FIELDNAME. ', 1150 ' WHEN ''''. ', 1151 '* CHECK RS_SELFIELD-VALUE IS NOT INITIAL. ', 1152 '* SET PARAMETER ID ''MBN'' FIELD RS_SELFIELD-VALUE. ', 1153 '* CALL TRANSACTION ''MB03'' AND SKIP FIRST SCREEN. ', 1154 ' ENDCASE. ', 1155 ' ENDCASE. ', 1156 'ENDFORM. "USER_COMMAND_ALV '. 1157 ENDFORM. " GEN_FORM_USER_COMMAND_ALV 1158 *&---------------------------------------------------------------------* 1159 *& Form f4_table 1160 *&---------------------------------------------------------------------* 1161 * text 1162 *----------------------------------------------------------------------* 1163 FORM f4_table CHANGING p_tabname. 1164 DATA: lt_return TYPE TABLE OF ddshretval WITH HEADER LINE. 1165 DATA: BEGIN OF lt_tables OCCURS 0, 1166 astable TYPE tabname, 1167 tabname TYPE tabname, 1168 END OF lt_tables. 1169 1170 go_alv_tables->check_changed_data( ). 1171 1172 LOOP AT gt_tables INTO gs_table. 1173 IF gs_table-astable IS INITIAL. 1174 lt_tables-astable = gs_table-tabname. 1175 ELSE. 1176 lt_tables-astable = gs_table-astable. 1177 ENDIF. 1178 1179 lt_tables-tabname = gs_table-tabname. 1180 APPEND lt_tables. 1181 ENDLOOP. 1182 1183 CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' 1184 EXPORTING 1185 retfield = 'ASTABLE' 1186 window_title = '选择' 1187 value_org = 'S' 1188 TABLES 1189 value_tab = lt_tables[] 1190 return_tab = lt_return[]. 1191 1192 IF lt_return[] IS NOT INITIAL. 1193 READ TABLE lt_return INDEX 1. 1194 p_tabname = lt_return-fieldval. 1195 ENDIF. 1196 ENDFORM. "f4_table 1197 *&---------------------------------------------------------------------* 1198 *& Form f4_field 1199 *&---------------------------------------------------------------------* 1200 * text 1201 *----------------------------------------------------------------------* 1202 FORM f4_field USING p_tabname TYPE tabname 1203 CHANGING p_fieldname p_fieldtext p_ref_table p_ref_field. 1204 DATA: lt_return TYPE TABLE OF ddshretval WITH HEADER LINE, 1205 lt_dfies_tab TYPE TABLE OF dfies WITH HEADER LINE, 1206 BEGIN OF lt_fields OCCURS 0, 1207 fieldname TYPE fieldname, 1208 fieldtext TYPE fieldtext, 1209 keyflag TYPE keyflag, 1210 datatype TYPE dynptype, 1211 leng TYPE ddleng, 1212 decimals TYPE decimals, 1213 END OF lt_fields. 1214 1215 CALL FUNCTION 'DDIF_FIELDINFO_GET' 1216 EXPORTING 1217 tabname = p_tabname 1218 langu = sy-langu 1219 TABLES 1220 dfies_tab = lt_dfies_tab[] 1221 EXCEPTIONS 1222 not_found = 1 1223 internal_error = 2 1224 OTHERS = 3. 1225 1226 CHECK sy-subrc = 0. 1227 1228 DELETE lt_dfies_tab WHERE fieldname = 'MANDT'. 1229 LOOP AT lt_dfies_tab. 1230 lt_fields-fieldname = lt_dfies_tab-fieldname. 1231 lt_fields-fieldtext = lt_dfies_tab-fieldtext. 1232 lt_fields-keyflag = lt_dfies_tab-keyflag . 1233 lt_fields-datatype = lt_dfies_tab-datatype . 1234 lt_fields-leng = lt_dfies_tab-leng . 1235 lt_fields-decimals = lt_dfies_tab-decimals . 1236 APPEND lt_fields. 1237 ENDLOOP. 1238 "调用F4 1239 CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' 1240 EXPORTING 1241 retfield = 'FIELDNAME' 1242 window_title = '选择' 1243 value_org = 'S' 1244 TABLES 1245 value_tab = lt_fields[] 1246 return_tab = lt_return[]. 1247 1248 IF lt_return[] IS NOT INITIAL. 1249 READ TABLE lt_return INDEX 1. 1250 p_fieldname = lt_return-fieldval. 1251 READ TABLE lt_fields WITH KEY fieldname = p_fieldname. 1252 p_fieldtext = lt_fields-fieldtext. 1253 p_ref_table = p_tabname. 1254 p_ref_field = p_fieldname. 1255 ENDIF. 1256 ENDFORM. "f4_field 1257 *&---------------------------------------------------------------------* 1258 *& Form F4_FIELD_IN_ITAB 1259 *&---------------------------------------------------------------------* 1260 * GT_FIELDS的字段 1261 *----------------------------------------------------------------------* 1262 FORM f4_field_in_itab CHANGING p_fieldname. 1263 DATA: lt_return TYPE TABLE OF ddshretval WITH HEADER LINE, 1264 BEGIN OF lt_fields OCCURS 0, 1265 fieldname TYPE fieldname, 1266 fieldtext TYPE fieldtext, 1267 END OF lt_fields. 1268 1269 LOOP AT gt_fields1 INTO gs_field1. 1270 IF gs_field1-asfield IS INITIAL. 1271 lt_fields-fieldname = gs_field1-fieldname. 1272 ELSE. 1273 lt_fields-fieldname = gs_field1-asfield. 1274 ENDIF. 1275 lt_fields-fieldtext = gs_field1-scrtext_l. 1276 APPEND lt_fields. 1277 ENDLOOP. 1278 1279 LOOP AT gt_fields2 INTO gs_field2. 1280 lt_fields-fieldname = gs_field2-fieldname. 1281 lt_fields-fieldtext = gs_field2-scrtext_l. 1282 APPEND lt_fields. 1283 ENDLOOP. 1284 "调用F4 1285 CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' 1286 EXPORTING 1287 retfield = 'FIELDNAME' 1288 window_title = '选择' 1289 value_org = 'S' 1290 TABLES 1291 value_tab = lt_fields[] 1292 return_tab = lt_return[]. 1293 1294 IF lt_return[] IS NOT INITIAL. 1295 READ TABLE lt_return INDEX 1. 1296 p_fieldname = lt_return-fieldval. 1297 ENDIF. 1298 ENDFORM. " F4_FIELD_IN_ITAB 1299 *&---------------------------------------------------------------------* 1300 *& Form f4_color 1301 *&---------------------------------------------------------------------* 1302 * text 1303 *----------------------------------------------------------------------* 1304 * -->P_COLOR text 1305 *----------------------------------------------------------------------* 1306 FORM f4_color CHANGING p_color. 1307 DATA: 1308 lt_fieldcat TYPE TABLE OF slis_fieldcat_alv, 1309 ls_fieldcat TYPE slis_fieldcat_alv, 1310 ls_layout TYPE slis_layout_alv. 1311 1312 CLEAR: gt_color, gt_color[]. 1313 DO 7 TIMES. 1314 gt_color-color = gt_color-value = 'C' && sy-index && '00'. APPEND gt_color. 1315 gt_color-color = gt_color-value = 'C' && sy-index && '01'. APPEND gt_color. 1316 gt_color-color = gt_color-value = 'C' && sy-index && '10'. APPEND gt_color. 1317 ENDDO. 1318 1319 ls_fieldcat-fieldname = 'VALUE'. 1320 ls_fieldcat-seltext_l = '颜色码'. 1321 APPEND ls_fieldcat TO lt_fieldcat. 1322 1323 ls_layout-box_fieldname = 'SEL'. 1324 ls_layout-info_fieldname = 'COLOR'. 1325 1326 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' 1327 EXPORTING 1328 i_callback_program = sy-repid 1329 i_callback_user_command = 'USER_COMMAND_COLOR' 1330 is_layout = ls_layout 1331 it_fieldcat = lt_fieldcat 1332 i_screen_start_column = 130 1333 i_screen_start_line = 5 1334 i_screen_end_column = 150 1335 i_screen_end_line = 25 1336 TABLES 1337 t_outtab = gt_color[]. 1338 1339 READ TABLE gt_color WITH KEY sel = 'X'. 1340 p_color = gt_color-value. 1341 ENDFORM. "f4_color 1342 *&---------------------------------------------------------------------* 1343 *& Form USER_COMMAND_COLOR 1344 *&---------------------------------------------------------------------* 1345 * text 1346 *----------------------------------------------------------------------* 1347 FORM user_command_color USING r_ucomm LIKE sy-ucomm 1348 rs_selfield TYPE slis_selfield. 1349 DATA: lt_color LIKE TABLE OF gt_color. 1350 CASE r_ucomm. 1351 WHEN '&ONT'. 1352 lt_color[] = gt_color[]. 1353 DELETE lt_color WHERE sel = ''. 1354 IF lines( lt_color ) <> 1. 1355 MESSAGE '请选择一个行项目' TYPE 'E'. 1356 ENDIF. 1357 WHEN '&IC1'. 1358 gt_color-sel = 'X'. 1359 MODIFY gt_color INDEX rs_selfield-tabindex TRANSPORTING sel. 1360 LEAVE TO SCREEN 0. 1361 ENDCASE. 1362 ENDFORM. "USER_COMMAND_COLOR 1363 *&---------------------------------------------------------------------* 1364 *& Form download 1365 *&---------------------------------------------------------------------* 1366 * 下载到Excel 1367 *----------------------------------------------------------------------* 1368 FORM download. 1369 DATA: l_file TYPE string, 1370 l_path TYPE string, 1371 l_fullpath TYPE string, 1372 l_action TYPE i. 1373 1374 CALL METHOD cl_gui_frontend_services=>file_save_dialog 1375 EXPORTING 1376 default_file_name = l_file 1377 CHANGING 1378 filename = l_file 1379 path = l_path 1380 fullpath = l_fullpath 1381 user_action = l_action. 1382 1383 CHECK l_action = 0. 1384 1385 PERFORM create_excel_app. 1386 PERFORM open_workbook USING l_fullpath. 1387 1388 * =========TABLES========== 1389 CALL METHOD OF 1390 go_book 1391 'Sheets' = go_sheet 1392 EXPORTING 1393 #1 = 'TABLES'. 1394 IF sy-subrc <> 0. 1395 MESSAGE '打开TABLES工作表失败' TYPE 'E'. 1396 ENDIF. 1397 1398 LOOP AT gt_tables INTO gs_table. 1399 g_row = sy-tabix + 1. 1400 PERFORM set_cell_value USING g_row 1 gs_table-tabname. 1401 IF gs_table-leftjoin = 'X'. 1402 PERFORM set_cell_value USING g_row 2 1. 1403 ENDIF. 1404 PERFORM set_cell_value USING g_row 3 gs_table-astable. 1405 ENDLOOP. 1406 CALL METHOD cl_gui_cfw=>flush. 1407 1408 * =========JOINS========== 1409 CALL METHOD OF 1410 go_book 1411 'Sheets' = go_sheet 1412 EXPORTING 1413 #1 = 'JOINS'. 1414 IF sy-subrc <> 0. 1415 MESSAGE '打开JOINS工作表失败' TYPE 'E'. 1416 ENDIF. 1417 1418 LOOP AT gt_joins INTO gs_join. 1419 g_row = sy-tabix + 1. 1420 PERFORM set_cell_value USING g_row 1 gs_join-tab1. 1421 PERFORM set_cell_value USING g_row 2 gs_join-field1. 1422 PERFORM set_cell_value USING g_row 3 gs_join-tab2. 1423 PERFORM set_cell_value USING g_row 4 gs_join-field2. 1424 ENDLOOP. 1425 CALL METHOD cl_gui_cfw=>flush. 1426 1427 * =========FIELDS1========== 1428 CALL METHOD OF 1429 go_book 1430 'Sheets' = go_sheet 1431 EXPORTING 1432 #1 = 'FIELDS1'. 1433 IF sy-subrc <> 0. 1434 MESSAGE '打开FIELDS1工作表失败' TYPE 'E'. 1435 ENDIF. 1436 1437 LOOP AT gt_fields1 INTO gs_field1. 1438 g_row = sy-tabix + 1. 1439 PERFORM set_cell_value USING g_row 1 gs_field1-astable. 1440 PERFORM set_cell_value USING g_row 2 gs_field1-fieldname. 1441 PERFORM set_cell_value USING g_row 3 gs_field1-asfield. 1442 IF gs_field1-query = 'X'. 1443 PERFORM set_cell_value USING g_row 4 1. 1444 ENDIF. 1445 PERFORM set_cell_value USING g_row 5 gs_field1-query_pos. 1446 IF gs_field1-single = 'X'. 1447 PERFORM set_cell_value USING g_row 6 1. 1448 ENDIF. 1449 IF gs_field1-display = 'X'. 1450 PERFORM set_cell_value USING g_row 7 1. 1451 ENDIF. 1452 PERFORM set_cell_value USING g_row 8 gs_field1-qfieldname. 1453 PERFORM set_cell_value USING g_row 9 gs_field1-cfieldname. 1454 PERFORM set_cell_value USING g_row 10 gs_field1-ref_table. 1455 PERFORM set_cell_value USING g_row 11 gs_field1-ref_field. 1456 PERFORM set_cell_value USING g_row 12 gs_field1-convexit. 1457 PERFORM set_cell_value USING g_row 13 gs_field1-emphasize. 1458 PERFORM set_cell_value USING g_row 14 gs_field1-scrtext_l. 1459 ENDLOOP. 1460 CALL METHOD cl_gui_cfw=>flush. 1461 1462 * =========FIELDS2========== 1463 CALL METHOD OF 1464 go_book 1465 'Sheets' = go_sheet 1466 EXPORTING 1467 #1 = 'FIELDS2'. 1468 IF sy-subrc <> 0. 1469 MESSAGE '打开FIELDS2工作表失败' TYPE 'E'. 1470 ENDIF. 1471 1472 LOOP AT gt_fields2 INTO gs_field2. 1473 g_row = sy-tabix + 1. 1474 PERFORM set_cell_value USING g_row 1 gs_field2-fieldname. 1475 PERFORM set_cell_value USING g_row 2 gs_field2-qfieldname. 1476 PERFORM set_cell_value USING g_row 3 gs_field2-cfieldname. 1477 PERFORM set_cell_value USING g_row 4 gs_field2-ref_table. 1478 PERFORM set_cell_value USING g_row 5 gs_field2-ref_field. 1479 PERFORM set_cell_value USING g_row 6 gs_field2-convexit. 1480 PERFORM set_cell_value USING g_row 7 gs_field2-emphasize. 1481 PERFORM set_cell_value USING g_row 8 gs_field2-scrtext_l. 1482 ENDLOOP. 1483 CALL METHOD cl_gui_cfw=>flush. 1484 1485 CALL METHOD OF 1486 go_book 1487 'SAVE'. 1488 SET PROPERTY OF go_excel 'Visible' = 1. 1489 1490 MESSAGE '已下载到Excel文件中,请查看' TYPE 'S'. 1491 ENDFORM. "download 1492 *&---------------------------------------------------------------------* 1493 *& Form upload 1494 *&---------------------------------------------------------------------* 1495 * 从Excel上载 1496 *----------------------------------------------------------------------* 1497 FORM upload. 1498 DATA: lt_list TYPE TABLE OF spopli WITH HEADER LINE, 1499 l_answer TYPE c, 1500 lt_filetable TYPE filetable WITH HEADER LINE, 1501 l_rc TYPE i, 1502 l_action TYPE i, 1503 l_flag_close TYPE c. 1504 1505 IF go_excel IS NOT INITIAL. 1506 lt_list-varoption = '从刚下载的Excel文件上载'. APPEND lt_list. 1507 lt_list-varoption = '选择新的Excel文件进行上载'. APPEND lt_list. 1508 1509 CALL FUNCTION 'POPUP_TO_DECIDE_LIST' 1510 EXPORTING 1511 textline1 = '如果还未关闭已经下载的Excel,可以选择从该Excel文件上载' 1512 titel = '选择' 1513 IMPORTING 1514 answer = l_answer 1515 TABLES 1516 t_spopli = lt_list[]. 1517 1518 CHECK l_answer <> 'A'. 1519 ENDIF. 1520 1521 IF go_excel IS INITIAL OR l_answer = 2. 1522 CALL METHOD cl_gui_frontend_services=>file_open_dialog 1523 EXPORTING 1524 default_extension = 'XLS' 1525 default_filename = '*.xls;*.xlsx' 1526 file_filter = 'Excel File (*.xls;*.xlsx)' 1527 multiselection = '' 1528 CHANGING 1529 file_table = lt_filetable[] 1530 rc = l_rc 1531 user_action = l_action 1532 EXCEPTIONS 1533 file_open_dialog_failed = 1 1534 cntl_error = 2 1535 error_no_gui = 3 1536 not_supported_by_gui = 4 1537 OTHERS = 5. 1538 1539 CHECK l_action = 0. 1540 1541 PERFORM create_excel_app. 1542 1543 READ TABLE lt_filetable INDEX 1. 1544 PERFORM open_workbook USING lt_filetable-filename. 1545 1546 l_flag_close = 'X'. 1547 ENDIF. 1548 1549 CLEAR: gt_tables, gt_joins, gt_fields1, gt_fields2. 1550 1551 * =========TABLES========== 1552 CALL METHOD OF 1553 go_book 1554 'Sheets' = go_sheet 1555 EXPORTING 1556 #1 = 'TABLES'. 1557 IF sy-subrc <> 0. 1558 MESSAGE '打开TABLES工作表失败' TYPE 'E'. 1559 ENDIF. 1560 1561 WHILE 1 = 1. 1562 CLEAR: gs_table. 1563 g_row = sy-index + 1. 1564 PERFORM get_cell_value USING g_row 1 CHANGING gs_table-tabname. 1565 IF gs_table-tabname IS INITIAL. 1566 EXIT. 1567 ENDIF. 1568 PERFORM get_cell_value USING g_row 2 CHANGING gs_table-leftjoin. 1569 IF gs_table-leftjoin = '1'. 1570 gs_table-leftjoin = 'X'. 1571 ELSE. 1572 gs_table-leftjoin = ''. 1573 ENDIF. 1574 PERFORM get_cell_value USING g_row 3 CHANGING gs_table-astable. 1575 APPEND gs_table TO gt_tables. 1576 ENDWHILE. 1577 1578 * =========JOINS========== 1579 CALL METHOD OF 1580 go_book 1581 'Sheets' = go_sheet 1582 EXPORTING 1583 #1 = 'JOINS'. 1584 IF sy-subrc <> 0. 1585 MESSAGE '打开JOINS工作表失败' TYPE 'E'. 1586 ENDIF. 1587 1588 WHILE 1 = 1. 1589 CLEAR: gs_join. 1590 g_row = sy-index + 1. 1591 PERFORM get_cell_value USING g_row 1 CHANGING gs_join-tab1. 1592 IF gs_join-tab1 IS INITIAL. 1593 EXIT. 1594 ENDIF. 1595 PERFORM get_cell_value USING g_row 2 CHANGING gs_join-field1. 1596 PERFORM get_cell_value USING g_row 3 CHANGING gs_join-tab2. 1597 PERFORM get_cell_value USING g_row 4 CHANGING gs_join-field2. 1598 APPEND gs_join TO gt_joins. 1599 ENDWHILE. 1600 1601 * =========FIELDS1========== 1602 CALL METHOD OF 1603 go_book 1604 'Sheets' = go_sheet 1605 EXPORTING 1606 #1 = 'FIELDS1'. 1607 IF sy-subrc <> 0. 1608 MESSAGE '打开FIELDS1工作表失败' TYPE 'E'. 1609 ENDIF. 1610 1611 WHILE 1 = 1. 1612 CLEAR: gs_field1. 1613 g_row = sy-index + 1. 1614 PERFORM get_cell_value USING g_row 1 CHANGING gs_field1-astable. 1615 IF gs_field1-astable IS INITIAL. 1616 EXIT. 1617 ENDIF. 1618 PERFORM get_cell_value USING g_row 2 CHANGING gs_field1-fieldname. 1619 PERFORM get_cell_value USING g_row 3 CHANGING gs_field1-asfield. 1620 PERFORM get_cell_value USING g_row 4 CHANGING gs_field1-query. 1621 IF gs_field1-query = '1'. 1622 gs_field1-query = 'X'. 1623 ELSE. 1624 gs_field1-query = ''. 1625 ENDIF. 1626 PERFORM get_cell_value USING g_row 5 CHANGING gs_field1-query_pos. 1627 PERFORM get_cell_value USING g_row 6 CHANGING gs_field1-single. 1628 IF gs_field1-single = '1'. 1629 gs_field1-single = 'X'. 1630 ELSE. 1631 gs_field1-single = ''. 1632 ENDIF. 1633 PERFORM get_cell_value USING g_row 7 CHANGING gs_field1-display. 1634 IF gs_field1-display = '1'. 1635 gs_field1-display = 'X'. 1636 ELSE. 1637 gs_field1-display = ''. 1638 ENDIF. 1639 PERFORM get_cell_value USING g_row 8 CHANGING gs_field1-qfieldname. 1640 PERFORM get_cell_value USING g_row 9 CHANGING gs_field1-cfieldname. 1641 PERFORM get_cell_value USING g_row 10 CHANGING gs_field1-ref_table. 1642 PERFORM get_cell_value USING g_row 11 CHANGING gs_field1-ref_field. 1643 PERFORM get_cell_value USING g_row 12 CHANGING gs_field1-convexit. 1644 PERFORM get_cell_value USING g_row 13 CHANGING gs_field1-emphasize. 1645 PERFORM get_cell_value USING g_row 14 CHANGING gs_field1-scrtext_l. 1646 APPEND gs_field1 TO gt_fields1. 1647 ENDWHILE. 1648 1649 * =========FIELDS2========== 1650 CALL METHOD OF 1651 go_book 1652 'Sheets' = go_sheet 1653 EXPORTING 1654 #1 = 'FIELDS2'. 1655 IF sy-subrc <> 0. 1656 MESSAGE '打开FIELDS2工作表失败' TYPE 'E'. 1657 ENDIF. 1658 1659 WHILE 1 = 1. 1660 CLEAR: gs_field2. 1661 g_row = sy-index + 1. 1662 PERFORM get_cell_value USING g_row 1 CHANGING gs_field2-fieldname. 1663 IF gs_field2-fieldname IS INITIAL. 1664 EXIT. 1665 ENDIF. 1666 PERFORM get_cell_value USING g_row 2 CHANGING gs_field2-qfieldname. 1667 PERFORM get_cell_value USING g_row 3 CHANGING gs_field2-cfieldname. 1668 PERFORM get_cell_value USING g_row 4 CHANGING gs_field2-ref_table. 1669 PERFORM get_cell_value USING g_row 5 CHANGING gs_field2-ref_field. 1670 PERFORM get_cell_value USING g_row 6 CHANGING gs_field2-convexit. 1671 PERFORM get_cell_value USING g_row 7 CHANGING gs_field2-emphasize. 1672 PERFORM get_cell_value USING g_row 8 CHANGING gs_field2-scrtext_l. 1673 APPEND gs_field2 TO gt_fields2. 1674 ENDWHILE. 1675 1676 IF l_flag_close = 'X'. 1677 CALL METHOD OF 1678 go_book 1679 'Close'. 1680 CALL METHOD OF 1681 go_excel 1682 'QUIT'. 1683 FREE OBJECT: go_sheet, go_book, go_books, go_excel. 1684 ENDIF. 1685 1686 MESSAGE '上载完成' TYPE 'S'. 1687 ENDFORM. "upload 1688 *&---------------------------------------------------------------------* 1689 *& Form create_excel_app 1690 *&---------------------------------------------------------------------* 1691 * text 1692 *----------------------------------------------------------------------* 1693 FORM create_excel_app. 1694 IF go_excel IS INITIAL. 1695 CREATE OBJECT go_excel 'Excel.Application'. 1696 IF sy-subrc <> 0. 1697 MESSAGE '创建Excel程序失败' TYPE 'E'. 1698 ENDIF. 1699 ENDIF. 1700 ENDFORM. "create_excel_app 1701 *&---------------------------------------------------------------------* 1702 *& Form open_workbook 1703 *&---------------------------------------------------------------------* 1704 * text 1705 *----------------------------------------------------------------------* 1706 FORM open_workbook USING p_path. 1707 CALL METHOD OF 1708 go_excel 1709 'Workbooks' = go_books. 1710 CALL METHOD OF 1711 go_books 1712 'Open' = go_book 1713 EXPORTING 1714 #1 = p_path. 1715 IF sy-subrc <> 0. 1716 MESSAGE '打开Excel文件失败' TYPE 'E'. 1717 ENDIF. 1718 ENDFORM. "open_workbook 1719 *&---------------------------------------------------------------------* 1720 *& Form set_cell_value 1721 *&---------------------------------------------------------------------* 1722 * text 1723 *----------------------------------------------------------------------* 1724 FORM set_cell_value USING p_row TYPE i 1725 p_col TYPE i 1726 p_value. 1727 g_row = p_row. 1728 g_col = p_col. 1729 g_value = p_value. 1730 1731 CALL METHOD OF 1732 go_sheet 1733 'CELLS' = go_cell 1734 NO 1735 FLUSH 1736 1737 EXPORTING 1738 #1 = g_row 1739 #2 = g_col. 1740 SET PROPERTY OF go_cell 'Value' = g_value NO FLUSH. 1741 ENDFORM. "set_cell_value 1742 *&---------------------------------------------------------------------* 1743 *& Form get_cell_value 1744 *&---------------------------------------------------------------------* 1745 * text 1746 *----------------------------------------------------------------------* 1747 FORM get_cell_value USING p_row TYPE i 1748 p_col TYPE i 1749 CHANGING p_value. 1750 CALL METHOD OF 1751 go_sheet 1752 'CELLS' = go_cell 1753 EXPORTING 1754 #1 = p_row 1755 #2 = p_col. 1756 GET PROPERTY OF go_cell 'Value' = p_value. 1757 ENDFORM. "get_cell_value 1758 *&---------------------------------------------------------------------* 1759 *& Form CHECK 1760 *&---------------------------------------------------------------------* 1761 * text 1762 *----------------------------------------------------------------------* 1763 FORM check . 1764 DATA: l_index TYPE i VALUE 1, 1765 l_index1 TYPE i, 1766 l_index2 TYPE i, 1767 l_tabix TYPE i, 1768 l_len TYPE i, 1769 l_off TYPE i, 1770 l_msg TYPE string, 1771 l_flag TYPE c, 1772 ls_dd02l TYPE dd02l, 1773 BEGIN OF lt_astable OCCURS 0, 1774 astable TYPE tabname, 1775 tabname TYPE tabname, 1776 index TYPE i, 1777 END OF lt_astable, 1778 BEGIN OF lt_asfield OCCURS 0, 1779 fieldname TYPE fieldname, 1780 END OF lt_asfield, 1781 BEGIN OF lt_syst OCCURS 0, 1782 fieldname TYPE fieldname, 1783 END OF lt_syst. 1784 1785 DEFINE d_store_message. 1786 g_flag_error = 'X'. 1787 call function 'MESSAGE_STORE' 1788 exporting 1789 arbgb = '00' 1790 msgty = 'E' 1791 txtnr = '001' 1792 msgv1 = l_msg 1793 msgv2 = '' 1794 msgv3 = '' 1795 msgv4 = '' 1796 zeile = l_index. 1797 l_index = l_index + 1. 1798 END-OF-DEFINITION. 1799 1800 SELECT fieldname INTO TABLE lt_syst FROM dd03l WHERE tabname = 'SYST' ORDER BY fieldname. 1801 LOOP AT lt_syst. 1802 lt_syst-fieldname = 'SY-' && lt_syst-fieldname. 1803 MODIFY lt_syst. 1804 ENDLOOP. 1805 1806 CALL FUNCTION 'MESSAGES_INITIALIZE'. 1807 CLEAR g_flag_error. 1808 1809 "表清单校验 1810 LOOP AT gt_tables INTO gs_table. 1811 l_tabix = sy-tabix. 1812 SELECT SINGLE * INTO ls_dd02l FROM dd02l WHERE tabname = gs_table-tabname AND as4vers = 'A'. 1813 IF sy-subrc <> 0. 1814 l_msg = '表清单:行' && l_tabix && ',表或视图' && gs_table-tabname && '不存在或未激活'. 1815 d_store_message. 1816 ELSEIF ls_dd02l-tabclass = 'CLUSTER'. 1817 IF lines( gt_tables ) > 1. 1818 l_msg = '表清单:行' && l_tabix && ',不能使用簇表' && gs_table-tabname. 1819 d_store_message. 1820 ENDIF. 1821 ELSEIF ls_dd02l-tabclass = 'VIEW'. 1822 IF ls_dd02l-viewclass <> 'D'. 1823 l_msg = '表清单:行' && l_tabix && ',视图' && gs_table-tabname && '不是数据库视图'. 1824 d_store_message. 1825 ENDIF. 1826 ENDIF. 1827 1828 IF gs_table-astable IS NOT INITIAL. 1829 IF 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' NA gs_table-astable(1). 1830 l_msg = '表清单:行' && l_tabix && ',别名' && gs_table-astable && '必须以字母开头'. 1831 d_store_message. 1832 ENDIF. 1833 lt_astable-astable = gs_table-astable. 1834 lt_astable-tabname = gs_table-tabname. 1835 ADD 1 TO lt_astable-index. 1836 APPEND lt_astable. 1837 ELSE. 1838 lt_astable-astable = gs_table-tabname. 1839 lt_astable-tabname = gs_table-tabname. 1840 ADD 1 TO lt_astable-index. 1841 APPEND lt_astable. 1842 ENDIF. 1843 ENDLOOP. 1844 1845 SORT lt_astable BY astable. 1846 DELETE ADJACENT DUPLICATES FROM lt_astable COMPARING astable. 1847 IF lines( lt_astable ) <> lines( gt_tables ). 1848 l_msg = '表清单:存在重复的表名或表别名'. 1849 d_store_message. 1850 ENDIF. 1851 1852 "表关联校验 1853 LOOP AT gt_joins INTO gs_join. 1854 l_tabix = sy-tabix. 1855 CLEAR: l_index1, l_index2. 1856 1857 IF gs_join-tab1 IS INITIAL OR gs_join-field1 IS INITIAL. 1858 l_msg = '表关联:行' && l_tabix && ',表1和字段1不能为空'. 1859 d_store_message. 1860 ELSE. 1861 READ TABLE lt_astable WITH KEY astable = gs_join-tab1 BINARY SEARCH. 1862 IF sy-subrc <> 0. 1863 l_msg = '表关联:行' && l_tabix && ',表1-' && gs_join-tab1 && '不存在'. 1864 d_store_message. 1865 ELSE. 1866 l_index1 = lt_astable-index. 1867 PERFORM check_field_exist USING lt_astable-tabname gs_join-field1 CHANGING l_flag. 1868 IF l_flag = 'X'. 1869 l_msg = '表关联:行' && l_tabix && ',表1-' && gs_join-tab1 && '中字段' && gs_join-field1 &&'不存在或未激活'. 1870 d_store_message. 1871 ENDIF. 1872 ENDIF. 1873 ENDIF. 1874 1875 IF gs_join-tab2 IS INITIAL. "校验特定值 1876 IF gs_join-field2 IS INITIAL. 1877 l_msg = '表关联:行' && l_tabix && ',字段2或特定值不存在'. 1878 d_store_message. 1879 ELSEIF gs_join-field2(1) <> ''''. 1880 READ TABLE lt_syst WITH KEY fieldname = gs_join-field2 BINARY SEARCH TRANSPORTING NO FIELDS. 1881 IF sy-subrc <> 0. 1882 l_msg = '表关联:行' && l_tabix && ',特定值' && gs_join-field2 && '填写错误,只能为SYST中字段或常数'. 1883 d_store_message. 1884 ENDIF. 1885 ELSE. 1886 l_len = strlen( gs_join-field2 ). 1887 IF l_len = 1. 1888 l_msg = '表关联:行' && l_tabix && ',特定值' && gs_join-field2 && '填写错误,只能为SYST中字段或常数'. 1889 d_store_message. 1890 ELSE. 1891 l_off = l_len - 1. 1892 IF gs_join-field2+l_off(1) <> ''''. 1893 l_msg = '表关联:行' && l_tabix && ',特定值' && gs_join-field2 && '填写错误,只能为SYST中字段或常数'. 1894 d_store_message. 1895 ENDIF. 1896 ENDIF. 1897 ENDIF. 1898 ELSE. 1899 READ TABLE lt_astable WITH KEY astable = gs_join-tab2 BINARY SEARCH. 1900 IF sy-subrc <> 0. 1901 l_msg = '表关联:行' && l_tabix && ',表2-' && gs_join-tab2 && '不存在'. 1902 d_store_message. 1903 ELSE. 1904 l_index2 = lt_astable-index. 1905 PERFORM check_field_exist USING lt_astable-tabname gs_join-field2 CHANGING l_flag. 1906 IF l_flag = 'X'. 1907 l_msg = '表关联:行' && l_tabix && ',表2-' && gs_join-tab2 && '中字段' && gs_join-field2 &&'不存在或未激活'. 1908 d_store_message. 1909 ELSE. 1910 IF l_index1 < l_index2 AND l_index1 > 0. 1911 l_msg = '表关联:行' && l_tabix && ',请遵循约定:表1-' && gs_join-tab1 && '在“表清单”位置需要在表2-' && gs_join-tab2 && '以下'. 1912 d_store_message. 1913 ENDIF. 1914 ENDIF. 1915 ENDIF. 1916 ENDIF. 1917 ENDLOOP. 1918 1919 "字段重复性校验 1920 LOOP AT gt_fields1 INTO gs_field1. 1921 IF gs_field1-asfield IS INITIAL. 1922 lt_asfield-fieldname = gs_field1-fieldname. 1923 ELSE. 1924 lt_asfield-fieldname = gs_field1-asfield. 1925 ENDIF. 1926 APPEND lt_asfield. 1927 CLEAR lt_asfield. 1928 ENDLOOP. 1929 1930 LOOP AT gt_fields2 INTO gs_field2. 1931 lt_asfield-fieldname = gs_field2-fieldname. 1932 APPEND lt_asfield. 1933 CLEAR lt_asfield. 1934 ENDLOOP. 1935 1936 SORT lt_asfield BY fieldname. 1937 DELETE ADJACENT DUPLICATES FROM lt_asfield COMPARING fieldname. 1938 IF lines( lt_asfield ) <> lines( gt_fields1 ) + lines( gt_fields2 ). 1939 l_msg = '字段设置、附加字段:存在重复的字段名或字段别名'. 1940 d_store_message. 1941 ENDIF. 1942 1943 "字段设置 1944 READ TABLE gt_fields1 WITH KEY query = 'X' TRANSPORTING NO FIELDS. 1945 IF sy-subrc <> 0. 1946 l_msg = '字段设置:请至少设置一个查询条件'. 1947 d_store_message. 1948 ENDIF. 1949 READ TABLE gt_fields1 WITH KEY display = 'X' TRANSPORTING NO FIELDS. 1950 IF sy-subrc <> 0. 1951 l_msg = '字段设置:请至少设置一个输出字段'. 1952 d_store_message. 1953 ENDIF. 1954 LOOP AT gt_fields1 INTO gs_field1. 1955 l_tabix = sy-tabix. 1956 IF gs_field1-astable IS INITIAL OR gs_field1-fieldname IS INITIAL. 1957 l_msg = '字段设置:行' && l_tabix && ',表和字段不能为空'. 1958 ELSE. 1959 READ TABLE lt_astable WITH KEY astable = gs_field1-astable BINARY SEARCH. 1960 IF sy-subrc <> 0. 1961 l_msg = '字段设置:行' && l_tabix && ',表' && gs_field1-astable && '不存在'. 1962 d_store_message. 1963 ELSE. 1964 PERFORM check_field_exist USING lt_astable-tabname gs_field1-fieldname CHANGING l_flag. 1965 IF l_flag = 'X'. 1966 l_msg = '字段设置:行' && l_tabix && ',表' && gs_field1-astable && '中字段' && gs_field1-fieldname &&'不存在或未激活'. 1967 d_store_message. 1968 ENDIF. 1969 ENDIF. 1970 ENDIF. 1971 IF gs_field1-asfield IS NOT INITIAL. 1972 IF 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' NA gs_field1-asfield(1). 1973 l_msg = '字段设置:行' && l_tabix && ',字段' && gs_field1-fieldname && '的别名' && gs_field1-asfield && '必须以字母开头'. 1974 d_store_message. 1975 ENDIF. 1976 ENDIF. 1977 IF gs_field1-ref_table IS NOT INITIAL. 1978 SELECT SINGLE tabname INTO gs_field1-ref_table FROM dd02l WHERE tabname = gs_field1-ref_table AND as4vers = 'A'. 1979 IF sy-subrc <> 0. 1980 l_msg = '字段设置:行' && l_tabix && ',字段' && gs_field1-fieldname && '的参照表' && gs_field1-ref_table && '不存在或未激活'. 1981 d_store_message. 1982 ELSEIF gs_field1-ref_field IS NOT INITIAL. 1983 PERFORM check_field_exist USING gs_field1-ref_table gs_field1-ref_field CHANGING l_flag. 1984 IF l_flag = 'X'. 1985 l_msg = '字段设置:行' && l_tabix && ',字段' && gs_field1-fieldname && '的参照表' && gs_field1-ref_table && '中参照字段' && gs_field1-ref_field &&'不存在或未激活'. 1986 d_store_message. 1987 ENDIF. 1988 ENDIF. 1989 ELSE. 1990 IF gs_field1-ref_field IS NOT INITIAL. 1991 SELECT SINGLE rollname INTO gs_field1-ref_field FROM dd04l WHERE rollname = gs_field1-ref_field AND as4vers = 'A'. 1992 IF sy-subrc <> 0. 1993 l_msg = '字段设置:行' && l_tabix && ',字段' && gs_field1-fieldname && '的参照字段(数据元素)' && gs_field1-ref_field &&'不存在或未激活'. 1994 d_store_message. 1995 ENDIF. 1996 ENDIF. 1997 ENDIF. 1998 IF gs_field1-qfieldname IS NOT INITIAL. 1999 READ TABLE lt_asfield WITH KEY fieldname = gs_field1-qfieldname BINARY SEARCH TRANSPORTING NO FIELDS. 2000 IF sy-subrc <> 0. 2001 l_msg = '字段设置:行' && l_tabix && ',字段' && gs_field1-fieldname && '的单位字段' && gs_field1-qfieldname &&'不存在'. 2002 d_store_message. 2003 ENDIF. 2004 ENDIF. 2005 IF gs_field1-cfieldname IS NOT INITIAL. 2006 READ TABLE lt_asfield WITH KEY fieldname = gs_field1-cfieldname BINARY SEARCH TRANSPORTING NO FIELDS. 2007 IF sy-subrc <> 0. 2008 l_msg = '字段设置:行' && l_tabix && ',字段' && gs_field1-fieldname && '的货币字段' && gs_field1-cfieldname &&'不存在'. 2009 d_store_message. 2010 ENDIF. 2011 ENDIF. 2012 ENDLOOP. 2013 2014 "附加字段 2015 LOOP AT gt_fields2 INTO gs_field2. 2016 l_tabix = sy-tabix. 2017 IF gs_field2-ref_table IS NOT INITIAL. 2018 SELECT SINGLE tabname INTO gs_field2-ref_table FROM dd02l WHERE tabname = gs_field2-ref_table AND as4vers = 'A'. 2019 IF sy-subrc <> 0. 2020 l_msg = '附加字段:行' && l_tabix && ',字段' && gs_field2-fieldname && '的参照表' && gs_field2-ref_table && '不存在或未激活'. 2021 d_store_message. 2022 ELSEIF gs_field2-ref_field IS NOT INITIAL. 2023 PERFORM check_field_exist USING gs_field2-ref_table gs_field2-ref_field CHANGING l_flag. 2024 IF l_flag = 'X'. 2025 l_msg = '附加字段:行' && l_tabix && ',字段' && gs_field2-fieldname && '的参照表' && gs_field2-ref_table && '中参照字段' && gs_field2-ref_field &&'不存在或未激活'. 2026 d_store_message. 2027 ENDIF. 2028 ENDIF. 2029 ELSE. 2030 IF gs_field2-ref_field IS NOT INITIAL. 2031 SELECT SINGLE rollname INTO gs_field2-ref_field FROM dd04l WHERE rollname = gs_field2-ref_field AND as4vers = 'A'. 2032 IF sy-subrc <> 0. 2033 l_msg = '附加字段:行' && l_tabix && ',字段' && gs_field2-fieldname && '的参照字段(数据元素)' && gs_field2-ref_field &&'不存在或未激活'. 2034 d_store_message. 2035 ENDIF. 2036 ELSE. 2037 l_msg = '附加字段:行' && l_tabix && ',字段' && gs_field2-fieldname && '的参照属性必须指定'. 2038 d_store_message. 2039 ENDIF. 2040 ENDIF. 2041 IF gs_field2-qfieldname IS NOT INITIAL. 2042 READ TABLE lt_asfield WITH KEY fieldname = gs_field2-qfieldname BINARY SEARCH TRANSPORTING NO FIELDS. 2043 IF sy-subrc <> 0. 2044 l_msg = '附加字段:行' && l_tabix && ',字段' && gs_field2-fieldname && '的单位字段' && gs_field2-qfieldname &&'不存在'. 2045 d_store_message. 2046 ENDIF. 2047 ENDIF. 2048 IF gs_field2-cfieldname IS NOT INITIAL. 2049 READ TABLE lt_asfield WITH KEY fieldname = gs_field2-cfieldname BINARY SEARCH TRANSPORTING NO FIELDS. 2050 IF sy-subrc <> 0. 2051 l_msg = '附加字段:行' && l_tabix && ',字段' && gs_field2-fieldname && '的货币字段' && gs_field2-cfieldname &&'不存在'. 2052 d_store_message. 2053 ENDIF. 2054 ENDIF. 2055 ENDLOOP. 2056 2057 IF g_flag_error = 'X'. 2058 CALL FUNCTION 'MESSAGES_SHOW'. 2059 ENDIF. 2060 ENDFORM. " CHECK 2061 *&---------------------------------------------------------------------* 2062 *& Form ALV_REFRESH_DISPLAY 2063 *&---------------------------------------------------------------------* 2064 * text 2065 *----------------------------------------------------------------------* 2066 FORM alv_refresh_display . 2067 go_alv_tables->refresh_table_display( ). 2068 go_alv_joins->refresh_table_display( ). 2069 go_alv_fields1->refresh_table_display( ). 2070 go_alv_fields2->refresh_table_display( ). 2071 ENDFORM. " ALV_REFRESH_DISPLAY 2072 *&---------------------------------------------------------------------* 2073 *& Form check_field_exist 2074 *&---------------------------------------------------------------------* 2075 * text 2076 *----------------------------------------------------------------------* 2077 FORM check_field_exist USING p_tabname TYPE tabname 2078 p_fieldname TYPE fieldname 2079 CHANGING p_flag TYPE c. 2080 DATA: l_fieldname TYPE fieldname. 2081 2082 CLEAR p_flag. 2083 SELECT SINGLE fieldname INTO l_fieldname 2084 FROM dd03l 2085 WHERE tabname = p_tabname 2086 AND fieldname = p_fieldname 2087 AND as4local = 'A'. 2088 CHECK sy-subrc <> 0. 2089 p_flag = 'X'. 2090 ENDFORM. "check_field_exist
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/17971.html