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

top of page in ALV

HI

can any one tell me how do i display some few lines text just above my alv grid using reuse_alv_grid_display function module...

with example will be helpful

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

11 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 10:53 AM

    Hi ginni,

    here are the steps for top of page.reward points if helpful.

    • work area and internal table for top of page.

    DATA: it_list_top_of_page TYPE slis_t_listheader,

    it_events TYPE slis_t_event,

    gs_layout TYPE slis_layout_alv,

    lwa_line TYPE slis_listheader.

    • constant to store top of page

    CONSTANTS: gc_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

    PERFORM eventtab_build USING it_events[].

    PERFORM list_header USING it_list_top_of_page[].

    PERFORM layout_build USING gs_layout.

    PERFORM display.

    FORM eventtab_build USING lit_events TYPE slis_t_event.

    DATA: lit_alv_event TYPE slis_alv_event.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    i_list_type = 0

    IMPORTING

    et_events = lit_events.

    READ TABLE lit_events WITH KEY name = slis_ev_top_of_page

    INTO lit_alv_event.

    IF sy-subrc = 0.

    MOVE gc_formname_top_of_page TO lit_alv_event-form.

    APPEND lit_alv_event TO lit_events.

    ENDIF.

    ENDFORM. "EVENTTAB_BUILD

    FORM list_header USING lt_top_of_page TYPE slis_t_listheader.

    CLEAR lwa_line.

    lwa_line-typ = 'S'.

    lwa_line-key = description for field.

    lwa_line-info = <field name or date ot time, etc> .

    APPEND lwa_line TO lt_top_of_page.

    lwa_line-key = description for field.

    lwa_line-info = <field name or date ot time, etc>.

    APPEND lwa_line TO lt_top_of_page.

    CLEAR lwa_line.

    lwa_line-typ = 'S'.

    lwa_line-key = description for field.

    lwa_line-info = sy-datum.

    APPEND lwa_line TO lt_top_of_page.

    CLEAR lwa_line.

    lwa_line-typ = 'S'.

    lwa_line-key = description for field.

    lwa_line-info = sy-uname.

    APPEND lwa_line TO lt_top_of_page.

    ENDFORM. "COMMENT_BUILD

    FORM top_of_page.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    it_list_commentary = it_list_top_of_page.

    ENDFORM. "TOP_OF_PAGE

    &----


    *& Form LAYOUT_BUILD

    &----


    ----


    • -->LS_LAYOUT for zebra pattern between records

    ----


    FORM layout_build USING ls_layout TYPE slis_layout_alv.

    ls_layout-zebra = c_x.

    ENDFORM. "LAYOUT_BUILD

    &----


    *& Form display

    &----


    • text

    ----


    FORM display.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = sy-repid

    is_layout = gs_layout

    it_fieldcat = it_fieldcat

    it_events = it_events[]

    TABLES

    t_outtab = lit_field

    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.

    ENDFORM. "display

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 09, 2007 at 10:43 AM

    hi,

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

    code is there, juts copy paste.

    rgds

    Anver

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 10:44 AM
    *&---------------------------------------------------------------------*
    *& Report  Y_TOP_PAGE                                                  *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    *&                                                                     *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    
    REPORT  y_top_page                              .
    
    TABLES : mara.
    TYPE-POOLS: slis.
    
    DATA : w_repid LIKE sy-repid.
      w_repid = sy-repid.
    
    DATA : BEGIN OF it_mara OCCURS 0,
           matnr LIKE mara-matnr,
           END OF it_mara.
    
    *layout
    DATA: wa_layout           TYPE SLIS_LAYOUT_ALV.
    *field catalog
    DATA: it_fieldcat_wrt_off TYPE slis_t_fieldcat_alv,
          wa_fieldcat_wrt_off TYPE slis_fieldcat_alv.
    
    START-OF-SELECTION.
    
      SELECT matnr FROM mara INTO CORRESPONDING FIELDS OF TABLE it_mara.
    
    END-OF-SELECTION.
    
    
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
         i_program_name               = w_repid
       I_INTERNAL_TABNAME           = 'IT_MARA'
    *     i_structure_name             = 'IT_MARA'
    *   I_CLIENT_NEVER_DISPLAY       = 'X'
       I_INCLNAME                   = w_repid
    *   I_BYPASSING_BUFFER           =
    *   I_BUFFER_ACTIVE              =
        CHANGING
          ct_fieldcat                  = it_fieldcat_wrt_off[]
       EXCEPTIONS
         inconsistent_interface       = 1
         program_error                = 2
         OTHERS                       = 3
                .
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program     = w_repid
          i_callback_top_of_page = 'TOP-OF-PAGE'
          is_layout              = wa_layout
          it_fieldcat            = it_fieldcat_wrt_off
        TABLES
          t_outtab               = it_mara
        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  TOP-OF-PAGE                                                 *
    *-------------------------------------------------------------------*
    * ALV Report Header                                                 *
    *-------------------------------------------------------------------*
    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 = 'CHANDU 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.                    "top-of-page
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 09, 2007 at 10:46 AM

    Hi,

    for top of page in ALV, declare the events in the FM 'REUSE_ALV_GRID_DISPLAY'.

    write the form for top of page and call FM 'REUSE_ALV_COMMENTARY_WRITE' in this.

    For activating the events, call the FM 'REUSE_ALV_EVENTS_GET'

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = G_REPID

    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

    IT_FIELDCAT = T_FIELDCAT

    IT_EVENTS = T_EVENT

    TABLES

    T_OUTTAB = T_CREDIT

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2

    .

    FORM FORM_TOP_OF_PAGE.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = T_LISTHEADER

    • I_LOGO =

    • I_END_OF_LIST_GRID =

    .

    ENDFORM. "FORM_TOP_OF_PAGE

    FORM EVENT .

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    I_LIST_TYPE = 0

    IMPORTING

    ET_EVENTS = T_EVENT

    EXCEPTIONS

    LIST_TYPE_WRONG = 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 F_HEADERLIST .

    IF T_CREDIT[] IS NOT INITIAL.

    "Title

    WA_LISTHEADER-TYP = 'H'.

    WA_LISTHEADER-INFO = TEXT-T00. "'Purchasing Card Billing Report - By

    "Cardholder'

    APPEND WA_LISTHEADER TO T_LISTHEADER.

    CLEAR: WA_LISTHEADER.

    WA_LISTHEADER-TYP = 'S'.

    WA_LISTHEADER-KEY = TEXT-T01. "'Company Code:'.

    WA_LISTHEADER-INFO = P_BUKRS.

    APPEND WA_LISTHEADER TO T_LISTHEADER.

    CLEAR: WA_LISTHEADER.

    WA_LISTHEADER-TYP = 'S'.

    WA_LISTHEADER-KEY = TEXT-T02 . "'Page No. :'.

    WA_LISTHEADER-INFO = SY-PAGNO .

    APPEND WA_LISTHEADER TO T_LISTHEADER.

    CLEAR: WA_LISTHEADER.

    WA_LISTHEADER-TYP = 'S'.

    WA_LISTHEADER-KEY = TEXT-T03. "'Run Date'.

    CONCATENATE SY-DATUM+4(2) '/'

    SY-DATUM+6(2) '/'

    SY-DATUM(4) INTO WA_LISTHEADER-INFO. "todays date

    APPEND WA_LISTHEADER TO T_LISTHEADER.

    CLEAR: WA_LISTHEADER.

    ENDIF.

    ENDFORM. " F_HEADERLIST

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 10:46 AM

    hi

    you can use REUSE_ALV_COMMENTARY_WRITE.

    example:

    DATA:   wa_variant LIKE disvariant                ,   "Variant
            wa_fieldcat TYPE slis_fieldcat_alv        ,
            it_fieldcat TYPE slis_t_fieldcat_alv      ,
            wa_layout   TYPE slis_layout_alv          ,
            wa_print    TYPE slis_print_alv           ,
            it_sort     TYPE slis_t_sortinfo_alv      ,
            it_sp_group TYPE slis_t_sp_group_alv      ,
            it_events   TYPE slis_t_event             ,
            it_list_top_of_page TYPE slis_t_listheader,
            w_title1    TYPE lvc_title,
            w_datum LIKE sy-datum.
    DATA slis_ev_top_of_page  TYPE slis_formname VALUE 'TOP_OF_PAGE'.
    DATA w_top_of_page  TYPE slis_formname VALUE 'TOP_OF_PAGE'.   " for top of page
    DATA it_event  TYPE slis_t_event.
    
    INITIALIZATION.
    
      PERFORM eventtab_build USING it_event[].
    
    START-OF-SELECTION.
    
    
    select * into corresponding fields of table
    it_bkpf from bkpf where
    bukrs = pr_bukrs and
    belnr = pr_belnr and
    gjahr = pr_gjahr.
    
      PERFORM fieldcat.
      PERFORM display_data.
    
    
    END-OF-SELECTION.
    
    
    
    
    FORM eventtab_build USING rt_events TYPE slis_t_event.
    *"Registration of events to happen during list display
      DATA: ls_event TYPE slis_alv_event.
    * to get the events
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = rt_events.
      READ TABLE rt_events WITH KEY name = slis_ev_top_of_page
                               INTO ls_event.
      IF sy-subrc = 0.
        MOVE w_top_of_page TO ls_event-form.
        APPEND ls_event TO rt_events.
      ENDIF.
    ENDFORM.                    "eventtab_build
    
    *&---------------------------------------------------------------------*
    *&      Form  fieldcat
    *&---------------------------------------------------------------------*
    
    FORM fieldcat .
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname = 'BUKRS'.
      wa_fieldcat-seltext_m   = text-023 .
      APPEND wa_fieldcat TO it_fieldcat.
    
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname = 'BELNR'.
      wa_fieldcat-seltext_m   = text-014 .
      APPEND wa_fieldcat TO it_fieldcat.
    
    
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname = 'GJAHR'.
      wa_fieldcat-seltext_m   = text-001 .
      APPEND wa_fieldcat TO it_fieldcat.
    
    ENDFORM.                    "fieldcat
    
    
    
    
    
    *&---------------------------------------------------------------------*
    *&      Form  display_data
    *&---------------------------------------------------------------------*
    
    FORM display_data .
      PERFORM comment_build USING gt_list_top_of_page[].
    
      wa_layout-info_fieldname = 'LINE_COLOR'. " Line Color
      wa_print-no_coverpage = 'X'.
      wa_print-no_print_listinfos = 'X'.  " Remove the default first page.
    
    
    *  to get thr grid display
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = sy-repid
          i_background_id    = 'ALV_BACKGROUND'
          is_layout          = wa_layout
          it_fieldcat        = it_fieldcat
          i_default          = 'X'
          i_save             = 'A'
          it_events          = it_event[]
          is_print           = wa_print
        TABLES
          t_outtab           = it_bkpf
        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.
    
    
    ENDFORM.                    " eventtab_build
    
    *&---------------------------------------------------------------------*
    *&      Form  comment_build
    *&---------------------------------------------------------------------*
    
    FORM comment_build USING lt_top_of_page TYPE  slis_t_listheader.
      DATA: ls_line TYPE slis_listheader.
      CLEAR ls_line.
      ls_line-typ  = 'H'.
    * to get the company text
    
      DATA w_name(50) TYPE c.
    
      ls_line-info = 'BKPF Accounting Header'.
    
      APPEND ls_line TO lt_top_of_page.
    
      CLEAR ls_line.
      ls_line-typ  = 'S'.
    
      ls_line-info = 'Report'.
    
      APPEND ls_line TO lt_top_of_page.
    ENDFORM.                    "comment_build
    
    
    *&---------------------------------------------------------------------*
    *&      Form  top_of_page
    *&---------------------------------------------------------------------*
    *      to print at top of page
    *----------------------------------------------------------------------*
    FORM top_of_page.
    * to pass the comment bulid for the top of page into the alv
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = gt_list_top_of_page.
    ENDFORM.                    "top_of_page
    

    thanks

    pavan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 10:47 AM

    hi

    you can use REUSE_ALV_COMMENTARY_WRITE.

    example:

    DATA:   wa_variant LIKE disvariant                ,   "Variant
            wa_fieldcat TYPE slis_fieldcat_alv        ,
            it_fieldcat TYPE slis_t_fieldcat_alv      ,
            wa_layout   TYPE slis_layout_alv          ,
            wa_print    TYPE slis_print_alv           ,
            it_sort     TYPE slis_t_sortinfo_alv      ,
            it_sp_group TYPE slis_t_sp_group_alv      ,
            it_events   TYPE slis_t_event             ,
            it_list_top_of_page TYPE slis_t_listheader,
            w_title1    TYPE lvc_title,
            w_datum LIKE sy-datum.
    DATA slis_ev_top_of_page  TYPE slis_formname VALUE 'TOP_OF_PAGE'.
    DATA w_top_of_page  TYPE slis_formname VALUE 'TOP_OF_PAGE'.   " for top of page
    DATA it_event  TYPE slis_t_event.
    
    INITIALIZATION.
    
      PERFORM eventtab_build USING it_event[].
    
    START-OF-SELECTION.
    
    
    select * into corresponding fields of table
    it_bkpf from bkpf where
    bukrs = pr_bukrs and
    belnr = pr_belnr and
    gjahr = pr_gjahr.
    
      PERFORM fieldcat.
      PERFORM display_data.
    
    
    END-OF-SELECTION.
    
    
    
    
    FORM eventtab_build USING rt_events TYPE slis_t_event.
    *"Registration of events to happen during list display
      DATA: ls_event TYPE slis_alv_event.
    * to get the events
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = rt_events.
      READ TABLE rt_events WITH KEY name = slis_ev_top_of_page
                               INTO ls_event.
      IF sy-subrc = 0.
        MOVE w_top_of_page TO ls_event-form.
        APPEND ls_event TO rt_events.
      ENDIF.
    ENDFORM.                    "eventtab_build
    
    *&---------------------------------------------------------------------*
    *&      Form  fieldcat
    *&---------------------------------------------------------------------*
    
    FORM fieldcat .
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname = 'BUKRS'.
      wa_fieldcat-seltext_m   = text-023 .
      APPEND wa_fieldcat TO it_fieldcat.
    
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname = 'BELNR'.
      wa_fieldcat-seltext_m   = text-014 .
      APPEND wa_fieldcat TO it_fieldcat.
    
    
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname = 'GJAHR'.
      wa_fieldcat-seltext_m   = text-001 .
      APPEND wa_fieldcat TO it_fieldcat.
    
    ENDFORM.                    "fieldcat
    
    
    
    
    
    *&---------------------------------------------------------------------*
    *&      Form  display_data
    *&---------------------------------------------------------------------*
    
    FORM display_data .
      PERFORM comment_build USING gt_list_top_of_page[].
    
      wa_layout-info_fieldname = 'LINE_COLOR'. " Line Color
      wa_print-no_coverpage = 'X'.
      wa_print-no_print_listinfos = 'X'.  " Remove the default first page.
    
    
    *  to get thr grid display
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = sy-repid
          i_background_id    = 'ALV_BACKGROUND'
          is_layout          = wa_layout
          it_fieldcat        = it_fieldcat
          i_default          = 'X'
          i_save             = 'A'
          it_events          = it_event[]
          is_print           = wa_print
        TABLES
          t_outtab           = it_bkpf
        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.
    
    
    ENDFORM.                    " eventtab_build
    
    *&---------------------------------------------------------------------*
    *&      Form  comment_build
    *&---------------------------------------------------------------------*
    
    FORM comment_build USING lt_top_of_page TYPE  slis_t_listheader.
      DATA: ls_line TYPE slis_listheader.
      CLEAR ls_line.
      ls_line-typ  = 'H'.
    * to get the company text
    
      DATA w_name(50) TYPE c.
    
      ls_line-info = 'BKPF Accounting Header'.
    
      APPEND ls_line TO lt_top_of_page.
    
      CLEAR ls_line.
      ls_line-typ  = 'S'.
    
      ls_line-info = 'Report'.
    
      APPEND ls_line TO lt_top_of_page.
    ENDFORM.                    "comment_build
    
    
    *&---------------------------------------------------------------------*
    *&      Form  top_of_page
    *&---------------------------------------------------------------------*
    *      to print at top of page
    *----------------------------------------------------------------------*
    FORM top_of_page.
    * to pass the comment bulid for the top of page into the alv
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = gt_list_top_of_page.
    ENDFORM.                    "top_of_page
    

    thanks

    pavan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 10:52 AM

    Hi Ginni,

    If you want a single line then use i_grid_title in the function module.

    if you want more lines then i will send you the steps for top of page soon.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 10:55 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 10:59 AM

    HI,

    FORM TOP-OF-PAGE.

    call function 'REUSE_ALV_COMMENTARY_WRITE'

    exporting

    it_list_commentary = i_list_comments

    i_logo = 'SUN_TEST_LOGO1'.

    • I_END_OF_LIST_GRID =

    • I_ALV_FORM =

    ENDFORM.

    pASS TOP-OF-PAGE TO THE EXPORTING PARAMETER IN THE fm

    REUSE_ALV_GRID_DISPLAY.

    rEGARDS,

    KEERTHI

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 05:16 AM

    Hi Ginni,

    c_x is a constant with value X. i thought it is self explanatory that c_x is a constant and value as x so i didnot specify there.Couldn't reply yesterday soon about this.

    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.