Skip to end of metadata
Go to start of metadata

In order to insert a report heading in to the ALV grid you need to perform the following steps:
1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include 'top-of-page' FORM
2. Create 'top-of-page' FORM

Check the following code:

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    I_CALLBACK_PROGRAM     = GD_REPID
    I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE' "see FORM
    IS_LAYOUT              = GD_LAYOUT
    IT_FIELDCAT            = FIELDCATALOG[]
    I_SAVE                 = 'X'
  TABLES
    T_OUTTAB               = IT_EKKO
  EXCEPTIONS
    PROGRAM_ERROR          = 1
    OTHERS                 = 2.
 
 
FORM TOP-OF-PAGE.
*ALV Header declarations
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
WA_HEADER TYPE SLIS_LISTHEADER,
T_LINE LIKE WA_HEADER-INFO,
LD_LINES TYPE I,
LD_LINESC(10) TYPE C.
*TITLE
WA_HEADER-TYP = 'H'.
WA_HEADER-INFO = 'EKKO Table Report'.
APPEND WA_HEADER TO T_HEADER.
CLEAR WA_HEADER.
*DATE
WA_HEADER-TYP = 'S'.
WA_HEADER-KEY = 'Date: '.
CONCATENATE SY-DATUM+6(2) '.'
SY-DATUM+4(2) '.'
SY-DATUM(4) INTO WA_HEADER-INFO. "todays date
APPEND WA_HEADER TO T_HEADER.
CLEAR: WA_HEADER.
*TOTAL NO. OF RECORDS SELECTED
DESCRIBE TABLE IT_EKKO LINES LD_LINES.
LD_LINESC = LD_LINES.
CONCATENATE 'Total No. of Records Selected: ' LD_LINESC
INTO T_LINE SEPARATED BY SPACE.
WA_HEADER-TYP = 'A'.
WA_HEADER-INFO = T_LINE.
APPEND WA_HEADER TO T_HEADER.
CLEAR: WA_HEADER, T_LINE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
  EXPORTING
    IT_LIST_COMMENTARY = T_HEADER.
I_LOGO = 'Z_LOGO'.
ENDFORM.                    "APPLICATION_SERVER

 

 

  •  

1 Comment

  1. Former Member

    Hi, I have to make one report related with FI, i have written code but its not showing output as well as header pls ckeck the below code and correct me.

    REPORT  ZPAN105.
    TABLES: BSIS,KNC1.
    TYPE-POOLS: SLIS.
    TYPES: BEGIN OF t_BSIS,
           BUKRS TYPE BSIS-BUKRS,
           GJAHR TYPE BSIS-GJAHR,
           MONAT TYPE BSIS-MONAT,
           HKONT TYPE BSIS-HKONT,
           SHKZG TYPE BSIS-SHKZG,
          END OF t_BSIS.
    DATA: IT_BSIS TYPE STANDARD TABLE OF t_BSIS WITH HEADER LINE,
           WA_BSIS TYPE T_BSIS.
    DATA: Opening_bal TYPE p DECIMALS 2.
    **ALV DATA DECLARTION
    DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
          gd_tab_group type slis_t_sp_group_alv,
          GD_LAYOUT    TYPE SLIS_LAYOUT_ALV,
          GD_REPID     LIKE SY-REPID.
    *data declaration for sorting.
    data : it_sortcat   type slis_sortinfo_alv occurs 1,
           wa_sort like line of it_sortcat.
    data :  i_list_comments type slis_t_listheader.
    *header
    data: t_header type slis_t_listheader,
          wa_header type slis_listheader,
          t_line like wa_header-info,
          ld_lines type i,
          ld_linesc(10) type c.
    PARAMETERS: P_COCOD TYPE BSIS-BUKRS,
                P_FYEAR TYPE BSIS-GJAHR.
    SELECT-OPTIONS: PO_PER FOR BSIS-MONAT,
                    GL_AC FOR  BSIS-HKONT.
    select bukrs gjahr monat hkont shkzg from bsis into corresponding fields of IT_bsis
    where monat in po_per.
    endselect.
      FIELDCATALOG-FIELDNAME   = 'BUKRS'.
      FIELDCATALOG-SELTEXT_M   = 'Company Code'.
      FIELDCATALOG-COL_POS     = 0.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'GJAHR'.
      FIELDCATALOG-SELTEXT_M   = 'Fiscal year'.
      FIELDCATALOG-COL_POS     = 1.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'MONAT'.
      FIELDCATALOG-SELTEXT_M   = 'Period'.
      FIELDCATALOG-COL_POS     = 2.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'HKONT'.
      FIELDCATALOG-SELTEXT_M   = 'GL Account'.
      FIELDCATALOG-COL_POS     = 3.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
      FIELDCATALOG-FIELDNAME   = 'SHKZG'.
      FIELDCATALOG-SELTEXT_M   = 'D/C indicator'.
      FIELDCATALOG-COL_POS     = 4.
      APPEND FIELDCATALOG TO FIELDCATALOG.
      CLEAR  FIELDCATALOG.
    *GD_REPID = SY-REPID.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
       I_CALLBACK_PROGRAM                = 'zpan105'
    *   I_CALLBACK_PF_STATUS_SET          = ' '
    *   I_CALLBACK_USER_COMMAND           = ' user_command '
       I_CALLBACK_TOP_OF_PAGE            = 'top-of-page'
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = ' '
    *    I_GRID_TITLE                      = V_GRIDTITLE
    *   I_GRID_SETTINGS                    =
       IS_LAYOUT                          = GD_LAYOUT
       IT_FIELDCAT                        = FIELDCATALOG[]
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
    *   IT_SORT                           = it_sortcat
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
       I_DEFAULT                         = 'X'
       I_SAVE                             = 'A'
    *   IS_VARIANT                         = G_VARIANT
    *   IT_EVENTS                         =
    *   IT_EVENT_EXIT                     =
    *   IS_PRINT                          =
    *   IS_REPREP_ID                      =
    *   I_SCREEN_START_COLUMN             = 0
    *   I_SCREEN_START_LINE               = 0
    *   I_SCREEN_END_COLUMN               = 0
    *   I_SCREEN_END_LINE                 = 0
    *   IT_ALV_GRAPHICS                   =
    *   IT_HYPERLINK                      =
    *   IT_ADD_FIELDCAT                   =
    *   IT_EXCEPT_QINFO                   =
    *   I_HTML_HEIGHT_TOP                 =
    *   I_HTML_HEIGHT_END                 =
    * IMPORTING
    *   E_EXIT_CAUSED_BY_CALLER           =
    *   ES_EXIT_CAUSED_BY_USER            =
      TABLES
        t_outtab                          = it_bsis
    * EXCEPTIONS
    *   PROGRAM_ERROR                     = 1
    *   OTHERS                            = 2
              .
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    *ALV Header declarations
    Form top-of-page.
    * Title
      wa_header-typ  = 'S'.
      wa_header-info = 'GL Balance as per GR 55'.
      append wa_header to t_header.
      clear wa_header.
    * Date
    *  wa_header-typ  = 'S'.
    *  wa_header-key = 'Date: '.
    *  CONCATENATE  sy-datum+6(2) '.'
    *               sy-datum+4(2) '.'
    *               sy-datum(4) INTO wa_header-info.   "todays date
    *  append wa_header to t_header.
    *  clear: wa_header.
      endform.
    FORM top.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        it_list_commentary       = t_header.
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    .
    endform.
    *&---------------------------------------------------------------------*

    *& Report  ZPAN105                                                     *

    *&                                                                     *

    *&---------------------------------------------------------------------*

    *&                                                                     *

    *&                                                                     *

    *&---------------------------------------------------------------------*

    REPORT  ZPAN105.

    TABLES: BSIS,KNC1.

    TYPE-POOLS: SLIS.

    TYPES: BEGIN OF t_BSIS,

           BUKRS TYPE BSIS-BUKRS,

           GJAHR TYPE BSIS-GJAHR,

           MONAT TYPE BSIS-MONAT,

           HKONT TYPE BSIS-HKONT,

           SHKZG TYPE BSIS-SHKZG,

          END OF t_BSIS.

    DATA: IT_BSIS TYPE STANDARD TABLE OF t_BSIS WITH HEADER LINE,

           WA_BSIS TYPE T_BSIS.

    DATA: Opening_bal TYPE p DECIMALS 2.

    **ALV DATA DECLARTION

    DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

          gd_tab_group type slis_t_sp_group_alv,

          GD_LAYOUT    TYPE SLIS_LAYOUT_ALV,

          GD_REPID     LIKE SY-REPID.

    *data declaration for sorting.

    data : it_sortcat   type slis_sortinfo_alv occurs 1,

           wa_sort like line of it_sortcat.

    data :  i_list_comments type slis_t_listheader.

    *header

    data: t_header type slis_t_listheader,

          wa_header type slis_listheader,

          t_line like wa_header-info,

          ld_lines type i,

          ld_linesc(10) type c.

    PARAMETERS: P_COCOD TYPE BSIS-BUKRS,

                P_FYEAR TYPE BSIS-GJAHR.

    SELECT-OPTIONS: PO_PER FOR BSIS-MONAT,

                    GL_AC FOR  BSIS-HKONT.

    select bukrs gjahr monat hkont shkzg from bsis into corresponding fields of IT_bsis

    where monat in po_per.

    endselect.

      FIELDCATALOG-FIELDNAME   = 'BUKRS'.

      FIELDCATALOG-SELTEXT_M   = 'Company Code'.

      FIELDCATALOG-COL_POS     = 0.

      APPEND FIELDCATALOG TO FIELDCATALOG.

      CLEAR  FIELDCATALOG.

      FIELDCATALOG-FIELDNAME   = 'GJAHR'.

      FIELDCATALOG-SELTEXT_M   = 'Fiscal year'.

      FIELDCATALOG-COL_POS     = 1.

      APPEND FIELDCATALOG TO FIELDCATALOG.

      CLEAR  FIELDCATALOG.

      FIELDCATALOG-FIELDNAME   = 'MONAT'.

      FIELDCATALOG-SELTEXT_M   = 'Period'.

      FIELDCATALOG-COL_POS     = 2.

      APPEND FIELDCATALOG TO FIELDCATALOG.

      CLEAR  FIELDCATALOG.

      FIELDCATALOG-FIELDNAME   = 'HKONT'.

      FIELDCATALOG-SELTEXT_M   = 'GL Account'.

      FIELDCATALOG-COL_POS     = 3.

      APPEND FIELDCATALOG TO FIELDCATALOG.

      CLEAR  FIELDCATALOG.

      FIELDCATALOG-FIELDNAME   = 'SHKZG'.

      FIELDCATALOG-SELTEXT_M   = 'D/C indicator'.

      FIELDCATALOG-COL_POS     = 4.

      APPEND FIELDCATALOG TO FIELDCATALOG.

      CLEAR  FIELDCATALOG.

    *GD_REPID = SY-REPID.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

     EXPORTING

    *   I_INTERFACE_CHECK                 = ' '

    *   I_BYPASSING_BUFFER                = ' '

    *   I_BUFFER_ACTIVE                   = ' '

       I_CALLBACK_PROGRAM                = 'zpan105'

    *   I_CALLBACK_PF_STATUS_SET          = ' '

    *   I_CALLBACK_USER_COMMAND           = ' user_command '

       I_CALLBACK_TOP_OF_PAGE            = 'top-of-page'

    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '

    *   I_CALLBACK_HTML_END_OF_LIST       = ' '

    *   I_STRUCTURE_NAME                  =

    *   I_BACKGROUND_ID                   = ' '

    *    I_GRID_TITLE                      = V_GRIDTITLE

    *   I_GRID_SETTINGS                    =

       IS_LAYOUT                          = GD_LAYOUT

       IT_FIELDCAT                        = FIELDCATALOG[]

    *   IT_EXCLUDING                      =

    *   IT_SPECIAL_GROUPS                 =

    *   IT_SORT                           = it_sortcat

    *   IT_FILTER                         =

    *   IS_SEL_HIDE                       =

       I_DEFAULT                         = 'X'

       I_SAVE                             = 'A'

    *   IS_VARIANT                         = G_VARIANT

    *   IT_EVENTS                         =

    *   IT_EVENT_EXIT                     =

    *   IS_PRINT                          =

    *   IS_REPREP_ID                      =

    *   I_SCREEN_START_COLUMN             = 0

    *   I_SCREEN_START_LINE               = 0

    *   I_SCREEN_END_COLUMN               = 0

    *   I_SCREEN_END_LINE                 = 0

    *   IT_ALV_GRAPHICS                   =

    *   IT_HYPERLINK                      =

    *   IT_ADD_FIELDCAT                   =

    *   IT_EXCEPT_QINFO                   =

    *   I_HTML_HEIGHT_TOP                 =

    *   I_HTML_HEIGHT_END                 =

    * IMPORTING

    *   E_EXIT_CAUSED_BY_CALLER           =

    *   ES_EXIT_CAUSED_BY_USER            =

      TABLES

        t_outtab                          = it_bsis

    * EXCEPTIONS

    *   PROGRAM_ERROR                     = 1

    *   OTHERS                            = 2

              .

    IF sy-subrc <> 0.

    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    *ALV Header declarations

    Form top-of-page.

    * Title

      wa_header-typ  = 'S'.

      wa_header-info = 'GL Balance as per GR 55'.

      append wa_header to t_header.

      clear wa_header.

    * Date

    *  wa_header-typ  = 'S'.

    *  wa_header-key = 'Date: '.

    *  CONCATENATE  sy-datum+6(2) '.'

    *               sy-datum+4(2) '.'

    *               sy-datum(4) INTO wa_header-info.   "todays date

    *  append wa_header to t_header.

    *  clear: wa_header.

      endform.

    FORM top.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

      EXPORTING

        it_list_commentary       = t_header.

    *   I_LOGO                   =

    *   I_END_OF_LIST_GRID       =

    .

    endform.