点击此处---> 群内免费提供SAP练习系统(在群公告中)
加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)
REPORT ALV.
TYPES BEGIN OF TY_ALV.
INCLUDE TYPE BKPF.
TYPES: FSTYLE TYPE LVC_T_STYL,
CELLCOL TYPE LVC_T_SCOL,
COLOR TYPE CHAR4,
ICON TYPE ICON_D,"
MSG TYPE CHAR255,
STATUS TYPE CHAR2,
SEL.
TYPES END OF TY_ALV.
DATA GT_ALV TYPE TABLE OF TY_ALV.
DATA GS_ALV TYPE TY_ALV.
DEFINE BUTTON.
CLEAR L_FIELDNAME.
CONCATENATE 'US_ALV-' &1 INTO L_FIELDNAME.
ASSIGN (L_FIELDNAME) TO .
IF SY-SUBRC = 0.
READ TABLE US_ALV-FSTYLE TRANSPORTING NO FIELDS WITH KEY FIELDNAME = &1
STYLE = CL_GUI_ALV_GRID=>MC_STYLE_BUTTON.
IF SY-SUBRC = 0.
DELETE US_ALV-FSTYLE WHERE FIELDNAME = &1 AND STYLE = CL_GUI_ALV_GRID=>MC_STYLE_BUTTON.
CLEAR .
ENDIF.
LV_STYLEROW-FIELDNAME = &1.
LV_STYLEROW-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_BUTTON.
INSERT LV_STYLEROW INTO TABLE US_ALV-FSTYLE.
= &2.
ENDIF.
END-OF-DEFINITION.
FIELD-SYMBOLS .
DEFINE HOTS.
CLEAR L_FIELDNAME.
CONCATENATE 'US_ALV-' &1 INTO L_FIELDNAME.
ASSIGN (L_FIELDNAME) TO .
IF SY-SUBRC = 0.
IF NE '0' OR IS NOT INITIAL.
LV_STYLEROW-FIELDNAME = &1.
LV_STYLEROW-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_HOTSPOT.
INSERT LV_STYLEROW INTO TABLE US_ALV-FSTYLE.
ENDIF.
ENDIF.
END-OF-DEFINITION.
START-OF-SELECTION.
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_ALV
FROM BKPF
UP TO 10 ROWS.
FIELD-SYMBOLS LIKE GS_ALV.
LOOP AT GT_ALV ASSIGNING .
PERFORM SUB_CHECK_ALV USING .
ENDLOOP.
*&---------------------------------------------------------------------*
*& Form SUB_CHECK_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ text
*----------------------------------------------------------------------*
FORM SUB_CHECK_ALV USING US_ALV LIKE GS_ALV..
DATA LV_STYLEROW TYPE LVC_S_STYL.
DATA LS_CELLCOLOR TYPE LVC_S_SCOL . " 单元格颜色结构
DATA LV_TABIX TYPE SY-TABIX.
DATA L_FIELDNAME TYPE STRING.
IF US_ALV-BELNR IS NOT INITIAL.
HOTS 'BELNR'.
ENDIF.
BUTTON 'ICON1' '@K1@'.
ENDFORM. " SUB_CHECK_ALV
实例: