abap编程中alv的显示代码如下:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS' "GUI状态
I_CALLBACK_USER_COMMAND = 'USER_COMMAND' "回调方法
IS_LAYOUT = GS_LAYOUT "布局
IT_FIELDCAT = GT_FIELDCAT[] "字段
I_SAVE = 'A'
TABLES
T_OUTTAB = GT_DATA[] "被alv显示的内表
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
我们最终要的效果是如下所示:
如何做到呢?
TYPES:BEGIN OF ITAB_DATA,
MATNR TYPE MARC-MATNR,"物料编码
MAKTX TYPE MAKT-MAKTX,"物料描述
SEL(1), "被显示的内表,添加一个专用字段
END OF ITAB_DATA.
DATA: GT_DATA TYPE STANDARD TABLE OF ITAB_DATA.
FORM FRM_GET_LAYOUT .
CLEAR GS_LAYOUT.
GS_LAYOUT-ZEBRA = 'X'.
GS_LAYOUT-DETAIL_POPUP = 'X'.
GS_LAYOUT-NO_SUBTOTALS = ''.
GS_LAYOUT-BOX_FIELDNAME = 'SEL'. "指定这个字段为【选择块】
ENDFORM.