上篇文章已经写了简单使用TOP_OF_PAGE参数。

这次加一个logo:

效果:

ALV DMEO 10:REUSE_ALV_GRID_DISPLAY TOP_OF_PAGE 显示L_java


首先上载图片:

OAOR

ALV DMEO 10:REUSE_ALV_GRID_DISPLAY TOP_OF_PAGE 显示L_java_02

ALV DMEO 10:REUSE_ALV_GRID_DISPLAY TOP_OF_PAGE 显示L_java_03

双击,上载图片。



 

DATA:GT_DATA                TYPE TABLE OF  SPFLI.

DATA:GS_LAYOUT              TYPE SLIS_LAYOUT_ALV.
DATA:CT_FIELDCAT            TYPE  SLIS_T_FIELDCAT_ALV.
DATA:GT_FIELDCATALOG        TYPE SLIS_T_FIELDCAT_ALV .
DATA:LS_CT_FIELDCAT         LIKE LINE OF CT_FIELDCAT.
DATA:LS_IT_FIELDCATALOG     LIKE LINE OF GT_FIELDCATALOG.
DATA:LV_ALV_STRUCTURE TYPE DD02L-TABNAME VALUE 'ZLMS_ALV'.
DATA: G_GRID_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

START-OF-SELECTION.

  SELECT * FROM SPFLI INTO  TABLE GT_DATA.

  CLEAR CT_FIELDCAT[].
  CLEAR GT_FIELDCATALOG[].

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      I_STRUCTURE_NAME       = LV_ALV_STRUCTURE
    CHANGING
      CT_FIELDCAT            = CT_FIELDCAT
    EXCEPTIONS
      INCONSISTENT_INTERFACE = 1
      PROGRAM_ERROR          = 2
      OTHERS                 = 3.
  IF SY-SUBRC <> 0.

  ENDIF.



  LOOP AT CT_FIELDCAT INTO LS_CT_FIELDCAT .
    MOVE-CORRESPONDING LS_CT_FIELDCAT TO LS_IT_FIELDCATALOG.

    LS_IT_FIELDCATALOG-SELTEXT_L = LS_CT_FIELDCAT-SELTEXT_L.
    LS_IT_FIELDCATALOG-SELTEXT_M = LS_CT_FIELDCAT-SELTEXT_M.
    LS_IT_FIELDCATALOG-SELTEXT_S = LS_CT_FIELDCAT-SELTEXT_S.

    LS_IT_FIELDCATALOG-DDICTXT ='L'.
    APPEND LS_IT_FIELDCATALOG TO GT_FIELDCATALOG.
  ENDLOOP.


  GS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
  GS_LAYOUT-ZEBRA = 'X'.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_DEFAULT              = 'X'
      I_SAVE                 = 'X'
      I_CALLBACK_PROGRAM     = SY-REPID  "当前程序
      I_CALLBACK_TOP_OF_PAGE = 'FRM_COMMENT_BUILD'
      I_GRID_TITLE           = 'SAP干货铺测试'
      IS_LAYOUT              = GS_LAYOUT
      IT_FIELDCAT            = GT_FIELDCATALOG
*     I_STRUCTURE_NAME       = 'SPFLI'
    TABLES
      T_OUTTAB               = GT_DATA
    EXCEPTIONS
      PROGRAM_ERROR          = 1
      OTHERS                 = 2.

  IF SY-SUBRC <> 0.
* Implement suitable error handling here
  ENDIF.

*&---------------------------------------------------------------------*
*&      Form  COMMENT_BUILD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM FRM_COMMENT_BUILD .

  DATA: LS_LINE TYPE SLIS_LISTHEADER.
  CLEAR G_GRID_TOP_OF_PAGE[].
  CLEAR LS_LINE.
  LS_LINE-TYP  = 'H'.  " H = Header, S = Selection, A = Action
  LS_LINE-INFO  =  'SAP干货铺测试'.
  APPEND LS_LINE TO G_GRID_TOP_OF_PAGE.

  CLEAR LS_LINE.
  LS_LINE-TYP  = 'S'.
*  LS_LINE-KEY  = 'SAP干货铺'.

  CONCATENATE  'SAP干货铺测试日期:'SY-DATUM
              INTO LS_LINE-INFO  .

  APPEND LS_LINE TO G_GRID_TOP_OF_PAGE.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      IT_LIST_COMMENTARY = G_GRID_TOP_OF_PAGE
      I_LOGO             = 'ZLM_LOGO'.  "LOGO object key 大写

ENDFORM.                    " COMMENT_BUILD