使用
REUSE_ALV_GRID_DISPLAY_LVC设置显示的字体
Example:
REPORT ZLM_TEST_008 .
* Include for all style values
INCLUDE 《CL_ALV_CONTROL》 .
DATA : I_FLIGHT TYPE STANDARD TABLE OF SFLIGHT .
DATA : I_FIELDS TYPE LVC_T_FCAT .
FIELD-SYMBOLS : 《WA_FIELDS》 TYPE LVC_S_FCAT .
* Select data
SELECT * FROM SFLIGHT
INTO TABLE I_FLIGHT
UP TO 100 ROWS .
CHECK SY -SUBRC = 0 .
* Get field catalog
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
CHANGING
CT_FIELDCAT = I_FIELDS
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3 .
IF SY -SUBRC = 0 .
* Changing the style of field catalog
LOOP AT I_FIELDS ASSIGNING 《WA_FIELDS》 .
IF SY -TABIX > 4 .
《WA_FIELDS》 -STYLE = ALV_STYLE_FONT_ITALIC .
ELSE .
《WA_FIELDS》 -STYLE = ALV_STYLE_FONT_BOLD .
ENDIF .
ENDLOOP .
ENDIF .
* Calling the FM to display ALV report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
* I_GRID_TITLE = 'Style demo'(001)
IT_FIELDCAT_LVC = I_FIELDS
TABLES
T_OUTTAB = I_FLIGHT
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 .
* Include for all style values
INCLUDE 《CL_ALV_CONTROL》 .
DATA : I_FLIGHT TYPE STANDARD TABLE OF SFLIGHT .
DATA : I_FIELDS TYPE LVC_T_FCAT .
FIELD-SYMBOLS : 《WA_FIELDS》 TYPE LVC_S_FCAT .
* Select data
SELECT * FROM SFLIGHT
INTO TABLE I_FLIGHT
UP TO 100 ROWS .
CHECK SY -SUBRC = 0 .
* Get field catalog
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
CHANGING
CT_FIELDCAT = I_FIELDS
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3 .
IF SY -SUBRC = 0 .
* Changing the style of field catalog
LOOP AT I_FIELDS ASSIGNING 《WA_FIELDS》 .
IF SY -TABIX > 4 .
《WA_FIELDS》 -STYLE = ALV_STYLE_FONT_ITALIC .
ELSE .
《WA_FIELDS》 -STYLE = ALV_STYLE_FONT_BOLD .
ENDIF .
ENDLOOP .
ENDIF .
* Calling the FM to display ALV report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
* I_GRID_TITLE = 'Style demo'(001)
IT_FIELDCAT_LVC = I_FIELDS
TABLES
T_OUTTAB = I_FLIGHT
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 .
注:因为单尖括号会被html解析,所以使用书名号《》代替
至于具体的style:
欢迎关注订阅号:SAP学习记录 (SAPlearning )