干货:
这里使用
I_CALLBACK_HTML_TOP_OF_PAGE = 'HTML_TOP_OF_PAGE'
参数做一个最简单的demo。
效果图:
REPORT ZLM_ALV012.
DATA:GT_DATA TYPE TABLE OF SPFLI.
DATA:GS_LAYOUT TYPE SLIS_LAYOUT_ALV.
START-OF-SELECTION.
"获取数据
SELECT * FROM SPFLI INTO TABLE GT_DATA.
"展示数据
GS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GS_LAYOUT-ZEBRA = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_HTML_TOP_OF_PAGE = 'HTML_TOP_OF_PAGE'
I_HTML_HEIGHT_TOP = 20 "控制表头栏目的初始高度
IS_LAYOUT = GS_LAYOUT
I_STRUCTURE_NAME = 'SPFLI'
TABLES
T_OUTTAB = GT_DATA
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
*&---------------------------------------------------------------------*
*& Form html_top_of_page
*&---------------------------------------------------------------------*
FORM HTML_TOP_OF_PAGE USING DOCUMENT TYPE REF TO CL_DD_DOCUMENT.
DATA: TEXT TYPE SDYDO_TEXT_ELEMENT.
TEXT = 'SAP干货铺测试'.
CALL METHOD DOCUMENT->ADD_TEXT
EXPORTING
TEXT = TEXT
SAP_STYLE = 'HEADING'.
CALL METHOD DOCUMENT->NEW_LINE.
CALL METHOD DOCUMENT->NEW_LINE.
"添加文本
TEXT = 'User Name : '.
CALL METHOD DOCUMENT->ADD_TEXT
EXPORTING
TEXT = TEXT
SAP_STYLE = CL_DD_DOCUMENT=>SUCCESS "底色 绿色
SAP_EMPHASIS = 'Strong'. "加粗
CALL METHOD DOCUMENT->ADD_GAP
EXPORTING
WIDTH = 2.
TEXT = SY-UNAME.
CALL METHOD DOCUMENT->ADD_TEXT
EXPORTING
TEXT = TEXT
SAP_STYLE = CL_DD_DOCUMENT=>WARNING "底色 红色色
SAP_COLOR = CL_DD_DOCUMENT=>LIST_TOTAL_INT
SAP_FONTSIZE = CL_DD_DOCUMENT=>LARGE
SAP_FONTSTYLE = CL_DD_DOCUMENT=>SERIF
SAP_EMPHASIS = CL_DD_DOCUMENT=>EMPHASIS.
" 10个空格
CALL METHOD DOCUMENT->ADD_GAP
EXPORTING
WIDTH = 10.
"添加图标
CALL METHOD DOCUMENT->ADD_ICON
EXPORTING
SAP_ICON = 'ICON_DATE'.
TEXT = 'Date : '.
CALL METHOD DOCUMENT->ADD_TEXT
EXPORTING
TEXT = TEXT
SAP_EMPHASIS = 'Strong'.
"两个空格
CALL METHOD DOCUMENT->ADD_GAP
EXPORTING
WIDTH = 2.
TEXT = SY-DATUM.
CALL METHOD DOCUMENT->ADD_TEXT
EXPORTING
TEXT = TEXT
SAP_STYLE = 'Key'.
"10空格
CALL METHOD DOCUMENT->ADD_GAP
EXPORTING
WIDTH = 10.
TEXT = 'Time : '.
CALL METHOD DOCUMENT->ADD_TEXT
EXPORTING
TEXT = TEXT
SAP_EMPHASIS = 'Strong'.
CALL METHOD DOCUMENT->ADD_GAP
EXPORTING
WIDTH = 2.
TEXT = SY-UZEIT.
CALL METHOD DOCUMENT->ADD_TEXT
EXPORTING
TEXT = TEXT
SAP_STYLE = 'Key'.
CALL METHOD DOCUMENT->NEW_LINE. "新行
CALL METHOD DOCUMENT->UNDERLINE. "下划线
"添加超链接
CALL METHOD DOCUMENT->ADD_LINK
EXPORTING
URL = 'https://mp.weixin.qq.com/s/7l7E1ZNYRnPNfezPZKRA8Q'
TOOLTIP = '欢迎访问干货铺'
TEXT = '双击访问SAP干货铺Debug系列文章'.
ENDFORM. "HTML_TOP_OF_PAGE