Sample code
========================================
REPORT ztest NO STANDARD PAGE HEADING.
* ALV
TYPE-POOLS: slis.
TYPES: BEGIN OF ty_data,
key TYPE char10,
text TYPE char40,
mark,
END OF ty_data.
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv,
gs_layout TYPE slis_layout_alv.
* Data to be displayed
DATA: gt_data TYPE TABLE OF ty_data WITH KEY key WITH HEADER LINE.
*---------------------------------------------------------------------*
INITIALIZATION.
PERFORM e01_fieldcat_init USING gt_fieldcat[].
.
*---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM selection.
*---------------------------------------------------------------------*
END-OF-SELECTION.
gs_layout-box_fieldname = 'MARK'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
TABLES
t_outtab = gt_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
*---------------------------------------------------------------------*
* --> E01_LT_FIELDCAT *
*---------------------------------------------------------------------*
FORM e01_fieldcat_init USING e01_lt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
* Key
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'KEY'.
ls_fieldcat-tabname = 'GT_DATA'.
ls_fieldcat-reptext_ddic = 'KEY'.
ls_fieldcat-outputlen = 10.
APPEND ls_fieldcat TO e01_lt_fieldcat.
* Text
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'TEXT'.
ls_fieldcat-tabname = 'GT_DATA'.
ls_fieldcat-reptext_ddic = 'Text'.
ls_fieldcat-outputlen = 40.
APPEND ls_fieldcat TO e01_lt_fieldcat.
ENDFORM. "e01_fieldcat_init
*---------------------------------------------------------------------*
* FORM SELECTION *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM selection.
gt_data-key = 'Group 1'. gt_data-text = 'This is group 1'. gt_data-mark = '0'.
APPEND gt_data.
gt_data-key = 'Group 1'. gt_data-text = 'This is group 1'. gt_data-mark = 'X'.
APPEND gt_data.
gt_data-key = 'Group 2'. gt_data-text = 'This is group 2'. gt_data-mark = '1'.
APPEND gt_data.
gt_data-key = 'Group 2'. gt_data-text = 'This is group 2'. gt_data-mark = space.
APPEND gt_data.
ENDFORM. "selection
阅读(644) | 评论(0) | 转发(0) |