最近看了几个选择屏幕上用Docking容器做PARENT的例子,发现Docking容器只是定义了,并没有实例,就可以拿来用。把下例红色的部分注释掉,完全不会影响程序的执行。
REPORT ztest.
TABLES tdwst.
PARAMETERS p TYPE i.
DATA:BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE tdwst.
DATA:mark TYPE i,
END OF itab.
DATA:wa_fcat TYPE lvc_s_fcat,
it_fcat TYPE lvc_t_fcat,
init.
DATA:l_dock TYPE REF TO cl_gui_docking_container,
l_grid TYPE REF TO cl_gui_alv_grid.
AT SELECTION-SCREEN OUTPUT.
IF init IS INITIAL.
init = 'X'.
CREATE OBJECT l_dock
EXPORTING
side = 4
ratio = 80.
CREATE OBJECT l_grid
EXPORTING
i_parent = l_dock.
SELECT * INTO TABLE itab FROM tdwst UP TO 10 ROWS.
***不显示结构中某些字段
CLEAR wa_fcat.
wa_fcat-fieldname = 'CVLANG'.
wa_fcat-no_out = 'X'.
APPEND wa_fcat TO it_fcat.
***增加结构中没有的字段
CLEAR wa_fcat.
wa_fcat-fieldname = 'MARK'.
wa_fcat-coltext = 'MARK'.
wa_fcat-col_pos = 1.
wa_fcat-emphasize = 'C510'.
APPEND wa_fcat TO it_fcat.
CALL METHOD l_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'TDWST'
CHANGING
it_outtab = itab[]
it_fieldcatalog = it_fcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
阅读(922) | 评论(0) | 转发(0) |