如何给表维护视图创建选择画面[VIEW_RANGETAB_TO_SELLIST]

通常SAP系统中的表维护视图(sm30)把所有数据都显示在一个屏幕上,没有筛选,如下,左图是sm30,右图是SE11中的表数据显示。

abap-selection-screen-tmg-1_thumb

如何要按条件进行筛选,要用到VIEW_RANGETAB_TO_SELLIST创建筛选条件内表,

b

例子程序如下:

简单介绍:

1, 先创建一个选择画面包含3个range ,s_id,s_name, s_place,

2, 调用VIEW_RANGETAB_TO_SELLIST创建sm30的筛选条件内表gt_seltab,三个条件之间是and关系。

3, 调用VIEW_MAINTENANCE_CALL显示表维护视图

REPORT ZTEST_SM30.
TABLES: zemployee.
CONSTANTS: c_view  TYPE   char30  VALUE 'ZEMPLOYEE',
           c_u     TYPE   char1   VALUE 'U',
           c_and   TYPE   char3   VALUE 'AND'.
DATA: gt_seltab    TYPE STANDARD TABLE OF vimsellist.
DATA: g_fieldname  TYPE vimsellist-viewfield.
DATA: gt_exclude   TYPE TABLE OF vimexclfun,
      gwa_exclude  TYPE vimexclfun.

SELECT-OPTIONS: s_id    FOR zemployee-id,
                s_name  FOR zemployee-name,
                s_place FOR zemployee-place.

*Add ID column to selection criteria of Table maintenanace view
g_fieldname = 'ID'.

CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST'
  EXPORTING
    fieldname          = g_fieldname
    append_conjunction = c_and
  TABLES
    sellist            = gt_seltab
    rangetab           = s_id.

*Add Name column to selection criteria of Table maintenanace view
g_fieldname = 'NAME'.

CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST'
  EXPORTING
    fieldname          = g_fieldname
    append_conjunction = c_and
  TABLES
    sellist            = gt_seltab
    rangetab           = s_name.

*Add Place column to selection criteria of Table maintenanace view
g_fieldname = 'PLACE'.

CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST'
  EXPORTING
    fieldname          = g_fieldname
    append_conjunction = c_and
  TABLES
    sellist            = gt_seltab
    rangetab           = s_place.

* Call to the 'VIEW_MAINTENANCE_CALL' function module
CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
  EXPORTING
    action         = c_u
    view_name      = c_view
  TABLES
    dba_sellist    = gt_seltab.

运行结果:

选择画面输入筛选条件LONDON,

abap-selection-screen-tmg-2_thumb

表维护视图只显示LONDON的数据。

abap-selection-screen-tmg-3_thumb

以上。

posted @ 2019-08-30 16:44  真的是很难  阅读(1298)  评论(0编辑  收藏  举报