ALV表头HTML实现

时间:2021-02-07 04:39:26
FORM frm_html_top_of_page USING cl_dd TYPE REF TO cl_dd_document.
DATA: m_p TYPE i.
DATA: m_buff TYPE string.
DATA:m_kunnr TYPE string.
DATA:m_bukrs TYPE string. SELECT SINGLE name1 INTO m_kunnr FROM kna1 WHERE kunnr IN s_kunnr.
CONCATENATE '客户:' m_kunnr '对账单' INTO m_kunnr.
*表头其实完全可以是一个html文件,自己使用html语言进行格式控制
m_buff = '<html>'. CALL METHOD cl_dd->html_insert
EXPORTING
contents = m_buff
CHANGING
position = m_p. SELECT SINGLE butxt INTO m_bukrs FROM t001 WHERE bukrs IN s_bukrs. CONCATENATE '<center><H2>' m_bukrs '</H2></Center>' INTO m_buff. CALL METHOD cl_dd->html_insert
EXPORTING
contents = m_buff
CHANGING
position = m_p. CONCATENATE '<center><H3>' m_kunnr '</H3></Center>' INTO m_buff. CALL METHOD cl_dd->html_insert
EXPORTING
contents = m_buff
CHANGING
position = m_p. CONCATENATE '<center>对账日期:' sy-datum+() '年' sy-datum+() '月' sy-datum+() '日' '</Center>' INTO m_buff. CALL METHOD cl_dd->html_insert
EXPORTING
contents = m_buff
CHANGING
position = m_p. m_buff = '</html>'. CALL METHOD cl_dd->html_insert
EXPORTING
contents = m_buff
CHANGING
position = m_p. gv_company_name = m_bukrs.
gv_customer_name = m_kunnr.
gv_date = '对账日期:' && sy-datum+() && '年' && sy-datum+() && '月' && sy-datum+() && '日'.
ENDFORM.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'FRM_PF_STATUS'
i_callback_user_command = 'FRM_USER_COMMAND'
i_callback_html_top_of_page = 'FRM_HTML_TOP_OF_PAGE'
is_layout = ls_layout
it_fieldcat = gt_fieldcat
* IT_SORT = GT_SORT
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = gt_show
EXCEPTIONS
program_error =
OTHERS = .
IF sy-subrc <> .
* Implement suitable error handling here
ENDIF.