Pages

Thursday, 18 April 2013

ALV REPORT WITH HEADER

ALV REPORT WITH HEADER 

REPORT  ZR_ALV1.
TYPE-POOLSSLIS.
*----------------------------------------------------------------------*
*     Data Decalaration
*----------------------------------------------------------------------*
DATAIKNA1 TYPE TABLE OF KNA1.
DATAG_REPID TYPE SY-REPID.
DATAIT_LISTHEADER TYPE SLIS_T_LISTHEADER,
      WA_LISTHEADER TYPE SLIS_LISTHEADER.
*----------------------------------------------------------------------*
*     START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
  G_REPID SY-REPID.

  SELECT FROM KNA1 INTO TABLE IKNA1.

  PERFORM BUILD_ALV_HEADER.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM     G_REPID
      I_CALLBACK_TOP_OF_PAGE 'TOP_OF_PAGE'
      I_STRUCTURE_NAME       'KNA1'
    TABLES
      T_OUTTAB               IKNA1.

*&---------------------------------------------------------------------*
*&      Form  BUILD_ALV_HEADER
*&---------------------------------------------------------------------*
FORM BUILD_ALV_HEADER .

*  Type H is used to display headers i.e. big font
  WA_LISTHEADER-TYP  'H'.
  WA_LISTHEADER-INFO ='Customer Details'.
  APPEND WA_LISTHEADER TO IT_LISTHEADER.
  CLEAR WA_LISTHEADER.

*  Type S is used to display key and value pairs
  WA_LISTHEADER-TYP 'S'.
  WA_LISTHEADER-KEY 'Date :' .
  CONCATENATE  SY-DATUM+6(2)
               SY-DATUM+4(2)
               SY-DATUM(4)
               INTO WA_LISTHEADER-INFO
               SEPARATED BY '/'.
  APPEND WA_LISTHEADER TO IT_LISTHEADER.
  CLEAR WA_LISTHEADER.

*  Type A is used to display italic font
  WA_LISTHEADER-TYP 'A'.
  WA_LISTHEADER-INFO ='SAP ALV Report'.
  APPEND WA_LISTHEADER TO IT_LISTHEADER.
  CLEAR WA_LISTHEADER.
ENDFORM.                    " BUILD_ALV_HEADER
*&---------------------------------------------------------------------*
*&      Form  top_of_page
*&---------------------------------------------------------------------*
FORM TOP_OF_PAGE.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      IT_LIST_COMMENTARY IT_LISTHEADER.

ENDFORM.                    "top_of_page

RESULT:


1 comment: