首先创建表维护 ZYKTFI0063B,然后通过以下程序调用SM30
*&---------------------------------------------------------------------*
*& Report ZFIR0137
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zfir0137.
INCLUDE zfir0137_top.
INCLUDE zfir0137_sel.
START-OF-SELECTION.
CALL FUNCTION 'VIEW_GET_DDIC_INFO'
EXPORTING
viewname = 'ZYKTFI0063B'
TABLES
sellist = gt_dba_sellist
x_header = gt_x_header
x_namtab = gt_x_namtab
EXCEPTIONS
no_tvdir_entry = 1
table_not_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST' "添加第一个筛选条件
EXPORTING
fieldname = 'BUKRS'
TABLES
sellist = gt_dba_sellist
rangetab = s_bukrs.
CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST' "添加第二个筛选条件
EXPORTING
fieldname = 'GJAHR'
append_conjunction = 'AND'
TABLES
sellist = gt_dba_sellist
rangetab = s_gjahr.
CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST' "添加第三个筛选条件
EXPORTING
fieldname = 'MONAT'
append_conjunction = 'AND'
TABLES
sellist = gt_dba_sellist
rangetab = s_monat.
CALL FUNCTION 'VIEW_ENQUEUE'
EXPORTING
view_name = 'ZYKTFI0063B'
action = 'E'
enqueue_mode = 'E'
EXCEPTIONS
foreign_lock = 1
system_failure = 2
table_not_found = 5
client_reference = 7.
IF sy-subrc NE 0.
MESSAGE 'Data locked by' && sy-msgv1 TYPE 'S' DISPLAY LIKE 'E'.
RETURN.
ENDIF.
" tabix是根据上面函数VIEW_GET_DDIC_INFO找到的位置,不要乱填tabix,不然会出异常或者筛选不生效
LOOP AT gt_dba_sellist ASSIGNING FIELD-SYMBOL(<fs_dba>).
CASE <fs_dba>-viewfield.
WHEN 'BUKRS'.
<fs_dba>-tabix = 2.
WHEN 'GJAHR'.
<fs_dba>-tabix = 3.
WHEN 'MONAT'.
<fs_dba>-tabix = 4.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
CALL FUNCTION 'VIEW_MAINTENANCE'
EXPORTING
view_action = 'U'
view_name = 'ZYKTFI0063B'
complex_selconds_used = 'X'
TABLES
dba_sellist = gt_dba_sellist
dpl_sellist = gt_dba_sellist
excl_cua_funct = gt_excl_cua_funct
x_header = gt_x_header
x_namtab = gt_x_namtab
EXCEPTIONS
missing_corr_number = 1
no_database_function = 2
no_editor_function = 3
no_value_for_subset_ident = 4
OTHERS = 5.
CALL FUNCTION 'VIEW_ENQUEUE'
EXPORTING
view_name = 'ZYKTFI0063B'
action = 'D'
enqueue_mode = 'E'
EXCEPTIONS
foreign_lock = 1
system_failure = 2
table_not_found = 5
client_reference = 7.
*&---------------------------------------------------------------------*
*& 包含 ZFIR0137_TOP
*&---------------------------------------------------------------------*
TABLES:zyktfi0063b .
DATA:gt_dba_sellist TYPE TABLE OF vimsellist,
gt_excl_cua_funct TYPE TABLE OF vimexclfun,
gt_x_header TYPE TABLE OF vimdesc,
gt_x_namtab TYPE TABLE OF vimnamtab,
gt_dpl_sellist TYPE TABLE OF vimsellist.
DATA:lockuser TYPE sy-uname,
answer(1) TYPE c.
*&---------------------------------------------------------------------*
*& 包含 ZFIR0137_SEL
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Selection Screen/选择屏幕
*&---------------------------------------------------------------------*
*&---选择屏幕块
SELECTION-SCREEN BEGIN OF BLOCK blk01 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:s_bukrs FOR zyktfi0063b-bukrs MODIF ID m4 NO-EXTENSION NO INTERVALS,
s_gjahr FOR zyktfi0063b-gjahr MODIF ID m4 NO-EXTENSION NO INTERVALS,
s_monat FOR zyktfi0063b-monat MODIF ID m4 NO-EXTENSION NO INTERVALS.
SELECTION-SCREEN END OF BLOCK blk01.
标签:FUNCTION,gt,&--------------------------------------------------------------- From: https://www.cnblogs.com/lsjy/p/18543431