带多行标题的alv_list

 

REPORT  z_alv_multi_title_lines NO STANDARD PAGE HEADING.
*---ALV
TYPE-POOLS slis.
DATAl_events TYPE slis_t_event,
      gs_layout TYPE slis_layout_alv,
      fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
      eventcat TYPE slis_t_event WITH HEADER LINE.
DATAl_variant TYPE TABLE OF disvariant WITH HEADER LINE.

DATABEGIN OF itb_output OCCURS 0,
        field1 LIKE mseg-menge,
        field2 LIKE mseg-menge,
        field3 LIKE mseg-menge,
        field4 LIKE mseg-menge,
      END OF itb_output.

START-OF-SELECTION.
  PERFORM eventtab_build CHANGING l_events.
  PERFORM input_data.
  PERFORM write_data.

*&---------------------------------------------------------------------*
*&      Form  write_data
*&---------------------------------------------------------------------*
FORM write_data .
  PERFORM get_fieldcat.

  gs_layout-zebra 'X' .

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      i_callback_program sy-repid
      is_layout          gs_layout
      is_variant         l_variant
      it_fieldcat        fieldcat[]
      it_events          eventcat[]
    TABLES
      t_outtab           itb_output[]
    EXCEPTIONS
      program_error      1
      OTHERS             2.
ENDFORM.                    " write_data
*&---------------------------------------------------------------------*
*&      Form  GET_FIELDCAT
*&---------------------------------------------------------------------*
FORM get_fieldcat.
  CLEAR fieldcat.
  fieldcat-tabname 'ITAB_OUTPUT'.
  fieldcat-fieldname 'FIELD1'.
  fieldcat-col_pos   1.
  fieldcat-seltext_l '出库1'.
  fieldcat-key 'X'.
  fieldcat-outputlen 11.
  APPEND fieldcat.

  CLEAR fieldcat.
  fieldcat-tabname 'ITAB_OUTPUT'.
  fieldcat-fieldname 'FIELD2'.
  fieldcat-col_pos   10.
  fieldcat-seltext_l '出库2'.
  fieldcat-key 'X'.
  fieldcat-outputlen 10.
  APPEND fieldcat.

  CLEAR fieldcat.
  fieldcat-tabname 'ITAB_OUTPUT'.
  fieldcat-fieldname 'FIELD3'.
  fieldcat-col_pos   10.
  fieldcat-seltext_l '入库1'.
  fieldcat-key 'X'.
  fieldcat-outputlen 10.
  APPEND fieldcat.

  CLEAR fieldcat.
  fieldcat-tabname 'ITAB_OUTPUT'.
  fieldcat-fieldname 'FIELD4'.
  fieldcat-col_pos   10.
  fieldcat-seltext_l '入库2'.
  fieldcat-key ''.
  fieldcat-outputlen 10.
  APPEND fieldcat.
ENDFORM.                    " GET_FIELDCAT

*&---------------------------------------------------------------------*
*&      Form  EVENTTAB_BUILD
*&---------------------------------------------------------------------*
FORM eventtab_build CHANGING p_events TYPE slis_t_event.
  DATA l_event TYPE LINE OF  slis_t_event.
*---get all events of alv.
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      i_list_type     "reuse_alv_list_display,see the details in function doc.
    IMPORTING
      et_events       p_events
    EXCEPTIONS
      list_type_wrong 1
      OTHERS          2.
*---build alv event itable.
  READ TABLE p_events INTO l_event WITH KEY name 'AFTER_LINE_OUTPUT'.
  eventcat-name  l_event-name.
  eventcat-form 'AFTER_LINE_OUTPUT'.
  APPEND eventcat.
  READ TABLE p_events INTO l_event WITH KEY name 'TOP_OF_PAGE'.
  eventcat-name  l_event-name.
  eventcat-form 'F_TOP_OF_PAGE'.
  APPEND eventcat.
ENDFORM.                    " EVENTTAB_BUILD
*&--------------------------------------------------------------------*
*&      Form  AFTER_LINE_OUTPUT
*&--------------------------------------------------------------------*
*   输出ALV的表头,手动配置这些
*---------------------------------------------------------------------*
FORM after_line_output USING gs_lineinfo TYPE slis_lineinfo.
  DATATYPE i.
  DATAd(394TYPE .
  DATAl_line(398TYPE c.
  DESCRIBE FIELD OUTPUT-LENGTH i.
  IF gs_lineinfo-tabindex 1.
    MODIFY LINE LINE VALUE FROM sy-uline(gs_lineinfo-linsz).
    MODIFY LINE LINE FORMAT COLOR 7.
    CLEAR l_line.
    l_line    sy-vline.
    l_line+9  '总出库'.
    l_line+20 sy-vline.
    l_line+30 '总入库'.
    l_line+39 sy-vline.

    MODIFY LINE LINE VALUE FROM l_line.

  ENDIF.
ENDFORM.                    "AFTER_LINE_OUTPUT
*&--------------------------------------------------------------------*
*&      Form  F_TOP_OF_PAGE
*&--------------------------------------------------------------------*
*     给ALV表头输出预留行空间
*---------------------------------------------------------------------*
FORM f_top_of_page.
  WRITE / sy-uline,
          / sy-uline.
ENDFORM.                    "F_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*&      Form  input_data
*&---------------------------------------------------------------------*
FORM input_data .
  itb_output-field1 100 .
  itb_output-field2 200 .

  itb_output-field3 300 .
  itb_output-field4 400 .

  APPEND itb_output .
ENDFORM.                    " input_data

你可能感兴趣的:(带多行标题的alv_list)