PERFORM ADD.
IS_LAYOUT_LVC-CWIDTH_OPT = 'X'.
IS_LAYOUT_LVC-SEL_MODE = 'A'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT_LVC = IS_LAYOUT_LVC
IT_FIELDCAT_LVC = IT_FIELDCAT_LVC[] "每列的标题,值
I_SAVE = 'A'
TABLES
T_OUTTAB = GT_EXCEL "要显示的表名称
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM PF_STATUS USING L_ALV_EXCL TYPE STANDARD TABLE..
SET PF-STATUS 'ZALV'. ”引入ZALV状态
ENDFORM.
FORM ADD.
DEFINE ADD_FIELD.
ls_fieldcat_lvc-FIELDNAME = &1.
ls_fieldcat_lvc-TABNAME = &2.
ls_fieldcat_lvc-datatype = &3.
ls_fieldcat_lvc-inttype = &4.
ls_fieldcat_lvc-intlen = &5.
ls_fieldcat_lvc-coltext = &6.
ls_fieldcat_lvc-decimals = &7.
if ls_fieldcat_lvc-FIELDNAME = 'MARK'.
ls_fieldcat_lvc-CHECKBOX = 'X'.
ls_fieldcat_lvc-edit = 'X'.
endif.
append ls_fieldcat_lvc to it_fieldcat_lvc.
clear: ls_fieldcat_lvc.
END-OF-DEFINITION.
ADD_FIELD:'MARK' 'GT_EXCEL' 'C' 'C' '50' '' ''.