TYPE-POOLS SLIS.
DATA:BEGIN OF ITAB OCCURS 0,
MATNR TYPE MATNR,
INDEX TYPE SYINDEX, "计数器字段
END OF ITAB.
FIELD-SYMBOLS: LIKE ITAB.
DATA:T_CAT TYPE SLIS_T_FIELDCAT_ALV,
S_CAT TYPE SLIS_FIELDCAT_ALV.
DATA:T_EVENT_EXIT TYPE SLIS_T_EVENT_EXIT,
S_EVENT_EXIT TYPE SLIS_EVENT_EXIT.
SELECT MATNR INTO TABLE ITAB FROM MARA UP TO 20 ROWS.
CLEAR S_EVENT_EXIT.
S_EVENT_EXIT-UCOMM = '&OUP'.
S_EVENT_EXIT-AFTER = 'X'.
APPEND S_EVENT_EXIT TO T_EVENT_EXIT.
CLEAR S_EVENT_EXIT.
S_EVENT_EXIT-UCOMM = '&ODN'.
S_EVENT_EXIT-AFTER = 'X'.
APPEND S_EVENT_EXIT TO T_EVENT_EXIT.
CLEAR S_CAT.
S_CAT-FIELDNAME = 'INDEX'.
S_CAT-SELTEXT_M = '序号'.
APPEND S_CAT TO T_CAT.
CLEAR S_CAT.
S_CAT-FIELDNAME = 'MATNR'.
S_CAT-SELTEXT_M = '物料编号'.
S_CAT-OUTPUTLEN = 18.
APPEND S_CAT TO T_CAT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = T_CAT
IT_EVENT_EXIT = T_EVENT_EXIT
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->U_UCOMM text
* -->US_SELFIELDtext
*---------------------------------------------------------------------*
FORM USER_COMMAND USING U_UCOMM TYPE SY-UCOMM
US_SELFIELD TYPE SLIS_SELFIELD.
CASE U_UCOMM.
***执行ALV工具栏的排序按钮时
WHEN '&OUP' OR '&ODN'.
LOOP AT ITAB ASSIGNING .
-INDEX = SY-TABIX.
ENDLOOP.
ENDCASE.
ENDFORM. "USER_COMMAND
阅读(1135) | 评论(1) | 转发(0) |