Skip to Content
author's profile photo Former Member
Former Member

ALV Header Line

can i add 2 header lines in ALV Reporting, if so then how give example.

abhishek suppal

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Jul 25, 2005 at 11:32 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 25, 2005 at 11:37 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 25, 2005 at 11:39 AM

    Hi,

    Search for this topic in Forum,

    header-for-alv-report

    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_enhanced.htm

    Best Regards,

    Anjali

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 25, 2005 at 11:46 AM

    Hi,

    Copy the following code and execute, it will work fine.

    TYPE-POOLS: slis.
    
    DATA: BEGIN OF i_data OCCURS 0,
            qmnum      LIKE qmel-qmnum,
            qmart      LIKE qmel-qmart,
            qmtxt      LIKE qmel-qmtxt,
            ws_row     TYPE i,
            ws_char(5) TYPE c,
            chk,
          END OF i_data.
    
    DATA: report_id  LIKE sy-repid.
    DATA: ws_title   TYPE lvc_title VALUE 'An ALV Report'.
    DATA: i_layout   TYPE slis_layout_alv.
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: i_events   TYPE slis_t_event.
    DATA: i_header   TYPE slis_t_listheader.
    
    SELECT qmnum
           qmart
           qmtxt
           INTO TABLE i_data
           FROM qmel
           WHERE qmnum <= '00030000010'.
    
    
    LOOP AT i_data.
      i_data-ws_row = sy-tabix.
      i_data-ws_char = 'AAAAA'.
      MODIFY i_data.
    ENDLOOP.
    
    report_id = sy-repid.
    PERFORM f1000_layout_init CHANGING i_layout.
    PERFORM f2000_fieldcat_init CHANGING i_fieldcat.
    PERFORM f3000_build_header CHANGING i_header.
    
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
       i_callback_program                = report_id
       i_grid_title                      = ws_title
       is_layout                         = i_layout
       it_fieldcat                       = i_fieldcat
       i_save                            = 'A'
      TABLES
        t_outtab                          = i_data
     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.
    
    *&---------------------------------------------------------------------*
    *&      Form  F1000_Layout_Init
    *&---------------------------------------------------------------------*
    
    FORM f1000_layout_init USING i_layout TYPE slis_layout_alv.
    
      CLEAR i_layout.
      i_layout-colwidth_optimize = 'X'.
      i_layout-edit = 'X'.
    
    ENDFORM.                    " F1000_Layout_Init
    *&---------------------------------------------------------------------*
    *&      Form  f2000_fieldcat_init
    *&---------------------------------------------------------------------*
    FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv.
    
      DATA: line_fieldcat TYPE slis_fieldcat_alv.
    
      CLEAR line_fieldcat.
      line_fieldcat-fieldname = 'QMNUM'.     " The field name and the table
      line_fieldcat-tabname   = 'I_DATA'.    " name are the two minimum req.
      line_fieldcat-key       = 'X'.  " Specifies the column as a key (Blue)
      line_fieldcat-seltext_m = 'Notification No.'. " Column Header
      APPEND line_fieldcat TO i_fieldcat.
    
      CLEAR line_fieldcat.
      line_fieldcat-fieldname = 'QMART'.
      line_fieldcat-ref_tabname = 'I_DATA'.
      line_fieldcat-hotspot = 'X'.           " Shows the field as a hotspot.
      line_fieldcat-seltext_m = 'Notif Type'.
      APPEND line_fieldcat TO i_fieldcat.
    
      CLEAR line_fieldcat.
      line_fieldcat-fieldname = 'QMTXT'.
      line_fieldcat-tabname   = 'I_DATA'.
      line_fieldcat-seltext_m = 'Description'.
      APPEND line_fieldcat TO i_fieldcat.
    
      CLEAR line_fieldcat.
      line_fieldcat-fieldname = 'WS_ROW'.
      line_fieldcat-tabname   = 'I_DATA'.
      line_fieldcat-seltext_m = 'Row Number'.
      APPEND line_fieldcat TO i_fieldcat.
    
      CLEAR line_fieldcat.
      line_fieldcat-fieldname = 'WS_CHAR'.
      line_fieldcat-tabname   = 'I_DATA'.
      line_fieldcat-seltext_l = 'Test Character Field'.
      line_fieldcat-datatype  = 'CHAR'.
      line_fieldcat-outputlen = '15'.     " You can specify the width of a
      APPEND line_fieldcat TO i_fieldcat. " column.
    
      CLEAR line_fieldcat.
      line_fieldcat-fieldname = 'CHK'.
      line_fieldcat-tabname   = 'I_DATA'.
      line_fieldcat-seltext_l = 'Checkbox'.
      line_fieldcat-checkbox  = 'X'.      " Display this field as a checkbox
      line_fieldcat-edit      = 'X'.      " This option ensures that you can
      " edit the checkbox. Else it will
      " be protected.
      APPEND line_fieldcat TO i_fieldcat.
    
    ENDFORM.                    " f2000_fieldcat_init
    
    *&---------------------------------------------------------------------*
    *&      Form  f3000_build_header
    *&---------------------------------------------------------------------*
    
    FORM f3000_build_header USING i_header TYPE slis_t_listheader.
    
      DATA: gs_line TYPE slis_listheader.
    
      CLEAR gs_line.
      gs_line-typ  = 'H'.
      gs_line-info = 'This is line of type HEADER'.
      APPEND gs_line TO i_header.
    
      CLEAR gs_line.
      gs_line-typ  = 'S'.
      gs_line-key  = 'STATUS 1'.
      gs_line-info = 'This is line of type STATUS'.
      APPEND gs_line TO i_header.
    
      gs_line-key  = 'STATUS 2'.
      gs_line-info = 'This is also line of type STATUS'.
      APPEND gs_line TO i_header.
    
      CLEAR gs_line.
      gs_line-typ  = 'A'.
      gs_line-info = 'This is line of type ACTION'.
      APPEND gs_line TO i_header.
    
    ENDFORM.                    " f3000_build_header
    
    

    Cheers,

    Venkat

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.