如何通过cl_dd_document来实现在ALV中输出标题头

样例代码:
REPORT  ZTEST4.

TABLES : t001.
TYPE-POOLS: slis.

DATA : w_repid LIKE sy-repid.
TYPES : BEGIN OF ty_comp.
        INCLUDE STRUCTURE t001.
TYPES : END OF ty_comp.

DATA: wa_layout  TYPE slis_layout_alv.

DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
      wa_fieldcat TYPE slis_fieldcat_alv.

DATA : it_comp TYPE TABLE OF ty_comp.

INITIALIZATION.
  w_repid = sy-repid.

START-OF-SELECTION.

  SELECT * FROM t001 INTO TABLE it_comp.

END-OF-SELECTION.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name         = w_repid
      i_internal_tabname     = 'IT_COMP'
      I_STRUCTURE_NAME       = 'T001'
      i_inclname             = w_repid
    CHANGING
      ct_fieldcat            = it_fieldcat[]
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program          = w_repid
      i_callback_html_top_of_page = 'HTML_TOP_OF_PAGE'
      is_layout                   = wa_layout
      it_fieldcat                 = it_fieldcat
    TABLES
      t_outtab                    = it_comp
    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 =  'Company Code Data'.
  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_emphasis = 'Strong'.

  CALL METHOD document->add_gap
    EXPORTING
      width = 2.

  text = sy-uname.
  CALL METHOD document->add_text
    EXPORTING
      text      = text
      sap_style = 'Key'.

  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'.

  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.   "Draw  an underLine
ENDFORM.                    "HTML_TOP_OF_PAGE

效果图如下:

image 

相关连接: http://blog.csdn.net/compassbutton/archive/2007/04/13/1563739.aspx

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值