Top of page in ALV

Hi all,
we are using an ALV in a report, the ALV comes out fine with a "top of page" and everything, but when we try to print it on a printer the section "top of page" does not appear, is this supposed to be normal? if not how can i solve it?

Haku,
I guess you are using REUSE_ALV_LIST_DISPLAY. Try using REUSE_ALV_GRID_DISPLAY. This will give you header in Print also.
I remeber solving that problem in this way.
Thanks
Krishna

Similar Messages

  • How to declare top of page in alv report

    hi guru
    how to declare top of page in alv report
    thanks
    subhasis

    Hi,
    check this simple program.
    REPORT ZBHALV_LIST.
    TABLES:MARA.
    SELECT-OPTIONS: MATNR FOR MARA-MATNR.
    DATA:BEGIN OF ITAB OCCURS 0,
    MATNR LIKE MARA-MATNR,
    ERSDA LIKE MARA-ERSDA,
    MTART LIKE MARA-MTART,
    MBRSH LIKE MARA-MBRSH,
    END OF ITAB.
    SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE MATNR
    IN MATNR.
    TYPE-POOLS SLIS.
    DATA:FCAT TYPE slis_t_fieldcat_alv.
    DATA:LAYOUT TYPE slis_layout_alv.
    DATA:EVE TYPE slis_t_event WITH HEADER LINE.
    DATA:HEAD TYPE slis_t_listheader WITH HEADER LINE.
    DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
    SORT-UP = 'X'.
    SORT-SPOS = 1.
    SORT-FIELDNAME = 'ERSDA'.
    SORT-tabname = 'MARA'.
    APPEND SORT.
    SORT-SPOS = 2.
    SORT-FIELDNAME = 'MTART'.
    SORT-tabname = 'MARA'.
    APPEND SORT.
    EVE-NAME = 'TOP_OF_PAGE'.
    EVE-FORM = 'TOPOFPAGE'.
    APPEND EVE.
    EVE-NAME = 'TOP_OF_LIST'.
    EVE-FORM = 'TOPOFLIST'.
    APPEND EVE.
    EVE-NAME = 'END_OF_LIST'.
    EVE-FORM = 'ENDOFLIST'.
    APPEND EVE.
    LAYOUT-ZEBRA = 'X'.
    LAYOUT-no_hline = 'X'.
    LAYOUT-NO_VLINE = 'X'.
    LAYOUT-window_titlebar = 'MATERIAL DETAILS'.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = SY-REPID
    I_INTERNAL_TABNAME = 'ITAB'
    I_STRUCTURE_NAME =
    I_CLIENT_NEVER_DISPLAY = 'X'
    I_INCLNAME = SY-REPID
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE =
    CHANGING
    CT_FIELDCAT = FCAT
    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_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FCAT
    IT_SORT = SORT[]
    IT_EVENTS = EVE[]
    TABLES
    T_OUTTAB = ITAB .
    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 TOPOFPAGE.
    REFRESH HEAD.
    HEAD-TYP = 'H'.
    HEAD-INFO = 'MATERIALS'.
    APPEND HEAD.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = HEAD[]
    I_LOGO =
    I_END_OF_LIST_GRID =
    ENDFORM.
    FORM TOPOFLIST.
    REFRESH HEAD.
    HEAD-TYP = 'H'.
    HEAD-INFO = 'MATERIALS-LISTTOP'.
    APPEND HEAD.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = HEAD[]
    I_LOGO =
    I_END_OF_LIST_GRID =
    ENDFORM.
    FORM ENDOFLIST.
    REFRESH HEAD.
    HEAD-TYP = 'H'.
    HEAD-INFO = 'MATERIALS-LISTEND'.
    APPEND HEAD.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = HEAD[]
    I_LOGO =
    I_END_OF_LIST_GRID =
    ENDFORM.
    Regards,
    Priyanka.

  • How i can show the selection screen input field in the top of page in alv

    hi ,
              how i can show the selection screen input field in the top of page in alv  grid output.
    tell me the process

    Hi,
    excample from my program:
    FORM topof_page.
      DATA: l_it_header   TYPE TABLE OF slis_listheader WITH HEADER LINE,
            l_info        LIKE l_it_header-info.
      DATA: l_it_textpool TYPE TABLE OF textpool WITH HEADER LINE.
      DATA: l_key LIKE l_it_textpool-key.
      READ TEXTPOOL c_repid INTO l_it_textpool LANGUAGE sy-langu.
      DEFINE m_selinfo.
        if not &1 is initial.
          clear l_it_header.
          l_it_header-typ   = 'S'.
          l_key = '&1'.
          translate l_key to upper case.
          read table l_it_textpool with key key = l_key.
          if sy-subrc = 0.
            shift l_it_textpool-entry left deleting leading space.
            l_it_header-key = l_it_textpool-entry  .
          endif.
          loop at &1.
            case &1-option.
              when 'EQ'
                or 'BT'
                or 'CP'.
                write &1-low to l_it_header-info.
              when others.
                write &1-low to l_it_header-info.
                concatenate &1-option
                            l_it_header-info
                       into l_it_header-info
                       separated by space.
            endcase.
            if not &1-high is initial.
              write &1-high to l_info left-justified.
              concatenate l_it_header-info
                          l_info
                     into l_it_header-info
                     separated by space.
            endif.
            if &1-sign = 'E'.
              concatenate ']'
                          l_it_header-info
                     into l_it_header-info.
            endif.
            append l_it_header.
            clear: l_it_header-key,
                   l_it_header-info.
          endloop.
        endif.
      END-OF-DEFINITION.
      m_selinfo: s_trmdat,
                 s_trmext,
                 s_trmint,
                 s_fkdat,
                 s_delno,
                 s_vbeln,
                 s_deact,
                 s_kdmat.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                it_list_commentary = l_it_header[].
    ENDFORM.
    I hope, this will help you.
    Regards
    Nicole

  • Space in Top of page on alv header

    Hi Experts,
    I do have a query on ALV , Can you please help me in solving my problem.
    Here goes my query...
    I have to develop a ALV where on the top of page i have to display two fields as shown in below which was highlighted in the screen
    http://img410.imageshack.us/my.php?image=op2sn9.jpg
    But i'm getting output as shown below screen
    http://img410.imageshack.us/my.php?image=op1ut4.jpg
    I have tried with space and all other alternatives but i'm unable to get the desired output.
    Can i have any sample code for the same
    Regards
    Nanda

    Hi,
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
    ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    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,
          gt_events     type slis_t_event,
          gd_prntparams type slis_print_alv.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform build_events.
    perform build_print_params.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material No'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    *  gd_layout-totals_only        = 'X'.
    *  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
    *                                         "click(press f2)
    *  gd_layout-zebra             = 'X'.
    *  gd_layout-group_change_edit = 'X'.
    *  gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
                i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
                it_events               = gt_events
                is_print                = gd_prntparams
                i_save                  = 'X'
    *            is_variant              = z_template
           tables
                t_outtab                = it_ekko
           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_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    * up to 10 rows
      from ekpo
      into table it_ekko.
    endform.                    " DATA_RETRIEVAL
    * 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 = '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.
    *       FORM USER_COMMAND                                          *
    *       --> R_UCOMM                                                *
    *       --> RS_SELFIELD                                            *
    FORM user_command USING r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    * Check function code
      CASE r_ucomm.
        WHEN '&IC1'.
    *   Check field clicked on within ALVgrid report
        IF rs_selfield-fieldname = 'EBELN'.
    *     Read data table, using index of row user clicked on
          READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
    *     Set parameter ID for transaction screen field
          SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
    *     Sxecute transaction ME23N, and skip initial data entry screen
          CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
        ENDIF.
      ENDCASE.
    ENDFORM.
    *&      Form  BUILD_EVENTS
    *       Build events table
    form build_events.
      data: ls_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
           exporting
                i_list_type = 0
           importing
                et_events   = gt_events[].
      read table gt_events with key name =  slis_ev_end_of_page
                               into ls_event.
      if sy-subrc = 0.
        move 'END_OF_PAGE' to ls_event-form.
        append ls_event to gt_events.
      endif.
        read table gt_events with key name =  slis_ev_end_of_list
                               into ls_event.
      if sy-subrc = 0.
        move 'END_OF_LIST' to ls_event-form.
        append ls_event to gt_events.
      endif.
    endform.                    " BUILD_EVENTS
    *&      Form  BUILD_PRINT_PARAMS
    *       Setup print parameters
    form build_print_params.
      gd_prntparams-reserve_lines = '3'.   "Lines reserved for footer
      gd_prntparams-no_coverpage = 'X'.
    endform.                    " BUILD_PRINT_PARAMS
    *&      Form  END_OF_PAGE
    form END_OF_PAGE.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      write: sy-uline(50).
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    *&      Form  END_OF_LIST
    form END_OF_LIST.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    Try with this sample
    Regards
    Krishna

  • Desired text in top of page in ALV

    Hi All,
    Due to some technaical requirement user want to convert sapscript form into ALV GRID report.
    Can we show some text in right justified mode, some in left justified mode, some in center, some in bold character, etc.
    in top of page in ALV.
    Edited by: Lalit Singh on Nov 3, 2009 6:08 AM

    Hi,
        You can use the Following Code Sample For using the Top of Page in your Report For ALV
    *&      Form  TOP-OF-PAGE
          Header To ALV GRID
    FORM top-of-page.
      DATA: it_header TYPE slis_t_listheader,
            wa_header TYPE slis_listheader.
    *-Title
      wa_header-typ = 'H'.
      wa_header-info = text-004.
      APPEND wa_header TO it_header.
      CLEAR wa_header.
    *-Date
      wa_header-typ = 'S'.
      wa_header-key = text-005.
      CONCATENATE sy-datum+6(2) '.'
                  sy-datum+4(2) '.'
                  sy-datum(4) INTO wa_header-info.
      APPEND wa_header TO it_header.
      CLEAR wa_header.
      wa_header-typ = 'S'.
      wa_header-key = text-006.
      CONCATENATE sy-uzeit(2) ':'
                  sy-uzeit+2(2) ':'
                  sy-uzeit+4(2) INTO wa_header-info. "todays date
      APPEND wa_header TO it_header.
      CLEAR: wa_header.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = it_header.
    ENDFORM.                    "TOP-OF-PAGE
    wih this ALV Function Module
    *-Grid Display
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program     = sy-repid
            i_callback_top_of_page = 'TOP-OF-PAGE'
            i_structure_name       = 'WA_FC_FINAL'
            i_grid_title           = text-003
            is_layout              = wa_layout
            it_fieldcat            = it_fieldcat
            i_default              = 'X'
            i_save                 = c_a
            is_variant             = it_variant
          TABLES
            t_outtab               = it_fc_final
          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.                              " IF sy-subrc <> 0.
    Regards,
    Richa Tripathi.

  • Adding Legends on TOP-OF-PAGE in alv

    Hi All,
    How can I add legends on top-of -page in ALV. This would include a colored cell and a text on what it depicts.
    Thanks in advance ..
    Edited by: aeterminator on Jun 16, 2011 11:09 AM

    Thanks Marcin..

  • How to give colors to the top-of-page in ALV Grid

    How to give colors to the top-of-page in ALV Grid
    in table GT_LIST_TOP_OF_PAGE i am filling 3 rows ,i need 3 different colors to be displyed on top-of-page(one color to one row)
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    I_LOGO = 'ENJOYSAP_LOGO'
    IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
    please help mee

    HI Kranthi,
    Check out teh foll. link,
    http://www.sapfans.com/forums/viewtopic.php?t=52107
    Hope this helps.

  • How to devide the top of page in alv grid display

    hi all
    in the alv grid display am getting the page number and total number of pages in the left hand side
    but what i need is i need in the right hand side
    how to get that

    Hi,
    PLease refer to the code below:
    *& Report  ZDEMO_ALVGRID                                               *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic requirement for this demo is to display a number of       *
    *& fields from the EKKO table.                                         *
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    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,
          gt_events     type slis_t_event,
          gd_prntparams type slis_print_alv.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform build_events.
    perform build_print_params.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-do_sum      = 'X'.
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    *  gd_layout-totals_only        = 'X'.
    *  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
    *                                         "click(press f2)
    *  gd_layout-zebra             = 'X'.
    *  gd_layout-group_change_edit = 'X'.
    *  gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
                i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
                it_events               = gt_events
                is_print                = gd_prntparams
                i_save                  = 'X'
    *            is_variant              = z_template
           tables
                t_outtab                = it_ekko
           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_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    endform.                    " DATA_RETRIEVAL
    * 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 = '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.
    *       FORM USER_COMMAND                                          *
    *       --> R_UCOMM                                                *
    *       --> RS_SELFIELD                                            *
    FORM user_command USING r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    * Check function code
      CASE r_ucomm.
        WHEN '&IC1'.
    *   Check field clicked on within ALVgrid report
        IF rs_selfield-fieldname = 'EBELN'.
    *     Read data table, using index of row user clicked on
          READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
    *     Set parameter ID for transaction screen field
          SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
    *     Sxecute transaction ME23N, and skip initial data entry screen
          CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
        ENDIF.
      ENDCASE.
    ENDFORM.
    *&      Form  BUILD_EVENTS
    *       Build events table
    form build_events.
      data: ls_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
           exporting
                i_list_type = 0
           importing
                et_events   = gt_events[].
      read table gt_events with key name =  slis_ev_end_of_page
                               into ls_event.
      if sy-subrc = 0.
        move 'END_OF_PAGE' to ls_event-form.
        append ls_event to gt_events.
      endif.
        read table gt_events with key name =  slis_ev_end_of_list
                               into ls_event.
      if sy-subrc = 0.
        move 'END_OF_LIST' to ls_event-form.
        append ls_event to gt_events.
      endif.
    endform.                    " BUILD_EVENTS
    *&      Form  BUILD_PRINT_PARAMS
    *       Setup print parameters
    form build_print_params.
      gd_prntparams-reserve_lines = '3'.   "Lines reserved for footer
      gd_prntparams-no_coverpage = 'X'.
    endform.                    " BUILD_PRINT_PARAMS
    *&      Form  END_OF_PAGE
    form END_OF_PAGE.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      write: sy-uline(50).
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    *&      Form  END_OF_LIST
    form END_OF_LIST.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    Thanks,
    Sriram Ponna.

  • How to trigger top-of-page in ALV Grid

    How to trigger Top-Of-Page in ALV Grid...
    can any one plese send the sample code...
    thanks.

    here is sample code. try this. u need to build an internal table and then call function commentary write and pass that internal table.
    *&      Form  TOP_OF_PAGE
          Top_of_page
    FORM top-of-page.                                           "#EC CALLED
    *ALV Header declarations
      DATA: lit_header TYPE slis_t_listheader,
            lwa_header TYPE slis_listheader.
    Title
      lwa_header-typ  = 'H'.
      lwa_header-info = text-013.
      APPEND lwa_header TO lit_header.
      CLEAR lwa_header.
    BOM Number
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
        EXPORTING
          input  = p_matnr
        IMPORTING
          output = gv_matnr.
    Pass BOM number
      lwa_header-typ  = 'S'.
      lwa_header-key = text-014.
      lwa_header-info = gv_matnr .
      APPEND lwa_header TO lit_header.
      CLEAR: lwa_header ,
             gv_matnr .
    BOM description
      lwa_header-typ  = 'S'.
      lwa_header-key = text-015 .
      lwa_header-info = gv_maktx .
      APPEND lwa_header TO lit_header.
      CLEAR: lwa_header.
    start/end date format MM/DD/YY
      lwa_header-typ  = 'S'.
      lwa_header-key = text-016 .
      CONCATENATE s_erdat-low+4(2) '/'
                  s_erdat-low+6(2) '/'
                  s_erdat-low(4) ' - '
                  s_erdat-high+4(2) '/'
                  s_erdat-high+6(2) '/'
                  s_erdat-high(4)
                  INTO lwa_header-info.
      APPEND lwa_header TO lit_header.
      CLEAR: lwa_header.
    Run Date of Report format MM/DD/YY
      lwa_header-typ  = 'S'.
      lwa_header-key = text-017 .
      CONCATENATE  sy-datum+4(2) '/'
                   sy-datum+6(2) '/'
                   sy-datum(4) INTO lwa_header-info .
      APPEND lwa_header TO lit_header.
      CLEAR: lwa_header.
    call function REUSE_ALV_COMMENTARY_WRITE to use TOP_OF_PAGE event.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = lit_header.
    ENDFORM .                              " FORM top-of-page.

  • TOP OF PAGE in ALV Grid Display in ECC 6.0

    Hi,
    I have an issue with top of page in Alv grid display
    in ECC 6.0. I searched  the forum for this, but
    couldnt fine any solution.
    I am using Reuse_alv_commentary_write to display the header.
    It's working fine in 4.7E but the same code is not working in
    ECC 6.0. The header is shown as  empty.
    I tried to execute some other programs with same FM and
    even standard SAP Prgrms too, even they raise the same issue
    the top of page is empty.
    Please suggest any other FM or approach to use in ECC 6.0 to get the top of page.
    Thanks in advance
    Kaavya.

    hiii
    use following code
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
    *     I_INTERFACE_CHECK                 = ' '
    *     I_BYPASSING_BUFFER                = ' '
    *     I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = sy-repid
    *     I_CALLBACK_PF_STATUS_SET          = ' '
    *     I_CALLBACK_USER_COMMAND           = ' '
         I_CALLBACK_TOP_OF_PAGE            = 'F0020_TOP_OF_PAGE'
    *     I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *     I_CALLBACK_HTML_END_OF_LIST       = ' '
         i_structure_name                  = 'I_OUTPUT'
    *     I_BACKGROUND_ID                   = ' '
    *     I_GRID_TITLE                      =
    *     I_GRID_SETTINGS                   =
    *     IS_LAYOUT                       = wa_layout
         it_fieldcat           = i_fieldcat
    *     IT_EXCLUDING                      =
    *     IT_SPECIAL_GROUPS                 =
    *     IT_SORT                           =
    *     IT_FILTER                         =
    *     IS_SEL_HIDE                       =
         i_default                         = 'X'
         i_save                            = 'X'
         is_variant                        = wa_variant
    *     IT_EVENTS                         =
    *     IT_EVENT_EXIT                     =
    *     IS_PRINT                          =
    *     IS_REPREP_ID                      =
    *     I_SCREEN_START_COLUMN             = 0
    FORM f0020_top_of_page.
      DATA: i_listheader TYPE slis_t_listheader WITH HEADER LINE,
            w_date like sy-datum.
      move:
        'H'   TO i_listheader-typ,
        '                 Corporation'   TO i_listheader-info.
    *    text-021    TO i_listheader-info.
    *write: 'Camtura Corporations'.
      APPEND i_listheader.
      WRITE sy-datum TO w_date.
      move:
        'S'   TO i_listheader-typ,
        'Execution date'   TO i_listheader-key,
        w_date     TO i_listheader-info.
      APPEND i_listheader.
    regards
    twinkal

  • Top-of-page in ALV  AND table

    hy folks, i read many topics about the top of page in alv but none answered to my problem, i have an alv_grid with top of page, but i need to put before the alv grid another table.
    is it possible to use
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
         it_list_commentary       = tb_top.
    ENDFORM.                   
    i mean if tb_top is a table?

    hi,
    use the following code
    DATA:  it_event TYPE slis_t_event,
              wa_event TYPE slis_alv_event.
    FORM create_event .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    * EXPORTING
    *   I_LIST_TYPE           = 0
       IMPORTING
         et_events             = it_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.
      READ TABLE it_event INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.
      wa_event-form = 'TOP_OF_PAGE'.
      MODIFY it_event FROM wa_event INDEX sy-tabix..
      CLEAR wa_event.
    ENDFORM         
                                       "create_event
    FORM top_of_page.
    DATA:LV_DATE TYPE SY-DATUM,
          LV_DATE1(10) TYPE C.
          LV_DATE = SY-DATUM.
       CONCATENATE LV_DATE4(2) '/' LV_DATE6(2) '/' LV_DATE+0(4) INTO LV_DATE1.
      REFRESH it_header.
      CLEAR l_string.
      l_string = 'HEADER TEXT'(hd2).
      wa_header-typ = 'H'.
      wa_header-info = l_string.
      APPEND wa_header TO it_header.
      CLEAR wa_header.
      wa_header-typ = 'S'.
      wa_header-key = 'DATE' .
      wa_header-info = LV_DATE1.
      APPEND wa_header TO it_header.
      CLEAR wa_header.
      wa_header-typ = 'S'.
      wa_header-key = 'USER NAME' .
      wa_header-info = SY-UNAME.
      APPEND wa_header TO it_header.
      CLEAR wa_header.
    "**********FM TO WRITE THE HEADER ON THE LIST******
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = it_header
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    ENDFORM.                    "top_of_page
    FORM display_alv .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
          it_events                         = it_event
       TABLES
          t_outtab                          = it_final
       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_ALV
    hope this helps
    Regards
    Ritesh J

  • Top of page in ALV reports

    hi all ,
    please let me know that ,can we use write statement to display top of page in ALV.if not suggest alternative.
    thanks in advance.
    janardhan.

    Hi Janajana,
    Here is the code. Reward points if it helps you.
    REPORT ZALV_SAMPLE.
    *                 NO STANDARD PAGE HEADING
    *                 LINE-COUNT 58
    *                 LINE-SIZE  220.
    TYPE-POOLS: SLIS.                     "for 'REUSE_ALV...list&grids'
    * TABLES                                                               *
    TABLES: KNA1.      "General Data in Customer Master
    * Internal data                                                        *
    DATA: BEGIN OF LT_ALVTABLE OCCURS 0,
            KUNNR LIKE KNA1-KUNNR,
            NAME1 LIKE KNA1-NAME1,
            NAME2 LIKE KNA1-NAME2,
            STRAS LIKE KNA1-STRAS,
            PSTLZ LIKE KNA1-PSTLZ,
            ORT01 LIKE KNA1-ORT01,
            UMSA1 LIKE KNA1-UMSA1,
            KTOKD LIKE KNA1-KTOKD,
          END OF LT_ALVTABLE.
    * data-statements that are necessary for the use of the ALV-grid
    DATA:  GT_XEVENTS     TYPE SLIS_T_EVENT.
    DATA:  XS_EVENT       TYPE SLIS_ALV_EVENT.
    DATA:  REPID          TYPE SY-REPID.
    DATA:  ZTA_PRINT      TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
    DATA:  LO_LAYOUT      TYPE SLIS_LAYOUT_ALV.
    DATA:  LO_ITABNAME    TYPE SLIS_TABNAME.
    DATA:  LS_VARIANT     TYPE DISVARIANT.
    * Initialization                                                       *
    INITIALIZATION.
    * Parameters and select-options                                        *
       SELECT-OPTIONS SO_KUNNR FOR KNA1-KUNNR DEFAULT '2000' TO '2300'.
       SELECT-OPTIONS SO_NAME  FOR KNA1-NAME1.
       PARAMETERS: PA_PSTCD AS CHECKBOX       DEFAULT 'X'.
       PARAMETERS: PA_VAR   AS CHECKBOX       DEFAULT 'X'.
    * Start of main program                                                *
    START-OF-SELECTION.
       PERFORM SELECT_RECORDS.
       PERFORM PRINT_ALVLIST.
    END-OF-SELECTION.
    *&      Form  select_records
    FORM SELECT_RECORDS.
       SELECT * FROM KNA1 INTO CORRESPONDING FIELDS OF LT_ALVTABLE
         WHERE KUNNR IN SO_KUNNR
           AND NAME1 IN SO_NAME.
         APPEND LT_ALVTABLE.
       ENDSELECT.
    ENDFORM.                              " select_records
    *&      Form  print_alvlist
    FORM PRINT_ALVLIST.
       REPID = SY-REPID.
       LO_ITABNAME = 'LT_ALVTABLE'.        "NB: ONLY USE CAPITALS HERE!
    * Fill the variables of the ALV-grid.
       PERFORM SET_LAYOUT USING LO_LAYOUT. "Change layout-settings
       PERFORM SET_EVENTS USING GT_XEVENTS."Set the events (top-page etc)
       PERFORM FILL_STRUCTURE.             "Read the structure of the itab
       PERFORM MODIFY_STRUCTURE.           "Modify itab's field-properties
    * Sort the table
       SORT LT_ALVTABLE BY KUNNR.
    * Present the table using the ALV-grid.
       CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
            EXPORTING
                 I_CALLBACK_PROGRAM = REPID
                 IT_FIELDCAT        = ZTA_PRINT[]
                 IS_LAYOUT          = LO_LAYOUT
                 IT_EVENTS          = GT_XEVENTS
                 I_SAVE             = 'A'
                 IS_VARIANT         = LS_VARIANT
            TABLES
                 T_OUTTAB           = LT_ALVTABLE.
    ENDFORM.                              " print_alvlist
    *&      Form  SET_LAYOUT
    FORM SET_LAYOUT USING PA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    * Minimize the columnwidth
      PA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    * Give the table a striped pattern
      PA_LAYOUT-ZEBRA             = 'X'.
    * Set the text of the line with totals
      PA_LAYOUT-TOTALS_TEXT       = 'Total:'.
    * Set the text of the line with subtotals
      PA_LAYOUT-SUBTOTALS_TEXT    = 'Subtotal:'.
    * Set the variant, as requested via the checkbox
      IF PA_VAR = 'X'.
        LS_VARIANT-VARIANT = '/ZLAYOUT'.
      ELSE.
        CLEAR LS_VARIANT-VARIANT.
      ENDIF.
    ENDFORM.                              " SET_LAYOUT
    *&     Form Set_events
    *      Appends the values of the events to the events-variable that is
    *      used by REUSE_ALV_LIST_DISPLAY
    FORM SET_EVENTS USING PA_EVENTS TYPE SLIS_T_EVENT.
       XS_EVENT-NAME = SLIS_EV_TOP_OF_LIST.
       XS_EVENT-FORM = 'XTOP_OF_LIST'.
       APPEND XS_EVENT TO PA_EVENTS.
       XS_EVENT-NAME = SLIS_EV_END_OF_LIST.
       XS_EVENT-FORM = 'XEND_OF_LIST'.
       APPEND XS_EVENT TO PA_EVENTS.
       XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.
       XS_EVENT-FORM = 'XTOP_OF_PAGE'.
       APPEND XS_EVENT TO PA_EVENTS.
       XS_EVENT-NAME = SLIS_EV_END_OF_PAGE.
       XS_EVENT-FORM = 'XEND_OF_PAGE'.
       APPEND XS_EVENT TO PA_EVENTS.
    ENDFORM.
    *&      Form  XTOP_OF_LIST
    FORM XTOP_OF_LIST.
       DATA LO_DATE(8).
       CONCATENATE SY-DATUM+6(2) '.'
                   SY-DATUM+4(2) '.'
                   SY-DATUM+2(2)
              INTO LO_DATE.
       WRITE: AT  1 'Report:'(T01), 20 'Reportname'(T02).
       WRITE: AT 50 'Date:'(T03), LO_DATE.
       NEW-LINE.
       WRITE: AT  1 'Abap-name report: '(T04), SY-REPID.
       WRITE: AT 50 'Page:'(T05), SY-CPAGE.
    ENDFORM.                              "xtop_of_list
    *&      Form  XEND_OF_LIST
    FORM XEND_OF_LIST.
       WRITE: 'Footer of the list'(002).
    ENDFORM.                              "xend_of_list
    *&      Form  XTOP_OF_PAGE
    FORM XTOP_OF_PAGE.
       WRITE:/ 'Top of the page.'(003).
    *()*Here your selection-criteria can be printed
    ENDFORM.                              "xtop-of-page
    *&      Form  XEND_OF_PAGE
    FORM XEND_OF_PAGE.
        WRITE:/ 'End of the page.'(004).
    ENDFORM.                              "xtop-of-page
    *&      Form  FILL_STRUCTURE
    FORM FILL_STRUCTURE.
       CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
            EXPORTING
                 I_PROGRAM_NAME     = REPID
                 I_INTERNAL_TABNAME = LO_ITABNAME
                 I_INCLNAME         = 'ZALV_SAMPLE'
            CHANGING
                 CT_FIELDCAT        = ZTA_PRINT[].
    ENDFORM.                              " FILL_STRUCTURE
    *&      Form  MODIFY_STRUCTURE
    *       Set the fieldproperties to your wishes
    FORM MODIFY_STRUCTURE.
       LOOP AT ZTA_PRINT.
         CLEAR ZTA_PRINT-KEY.
         CASE ZTA_PRINT-FIELDNAME.
           WHEN 'KUNNR'.                  "Klantnummer
             ZTA_PRINT-COL_POS = 0.
             ZTA_PRINT-SELTEXT_S = 'Cstm'(H01).
             ZTA_PRINT-SELTEXT_M = 'Customer'(H01).
             ZTA_PRINT-SELTEXT_L = 'Customer is king'(H01).
           WHEN 'NAME1'.                   "Name1
             ZTA_PRINT-COL_POS = 1.
           WHEN 'NAME2'.                   "Name 2 (now set to invisible)
             ZTA_PRINT-COL_POS = 2.
             ZTA_PRINT-NO_OUT = 'X'.
           WHEN 'STRAS'.                   "Month
             ZTA_PRINT-COL_POS = 3.
           WHEN 'PSTLZ'.                   "Postcode
             ZTA_PRINT-COL_POS = 4.
             IF PA_PSTCD = ''.
               ZTA_PRINT-NO_OUT = 'X'.
             ELSE.
               CLEAR ZTA_PRINT-NO_OUT.
             ENDIF.
           WHEN 'ORT01'.                   "Stad
             ZTA_PRINT-COL_POS = 5.
           WHEN 'UMSA1'.                   "Annual sales
             ZTA_PRINT-COL_POS = 6.
           WHEN 'KTOKD'.                   "
             ZTA_PRINT-COL_POS = 7.
    *      when others.                   "set all other fields to invisible
    *        zta_print-no_out = 'X'.
         ENDCASE.
         MODIFY ZTA_PRINT.
       ENDLOOP.
    ENDFORM.                              " modify_structure
    Regards,
    Amit Mishra

  • Top of page in ALV GRID display

    Hi All,
    Is it possible to have a top of page in ALV grid display?
    If yes, then how?
    Thanks and Regards,
    Sirisha

    hi
    check out the following code:
    report  z_alv2 line-count 20.
    type-pools : slis.
    type-pools : icon.
    tables:
    lfa1, lfb1, lfm1.
    selection-screen begin of block b1  with frame title text-001.
    select-options:
    s_lifnr for lfa1-lifnr, "VENDOR
    s_bukrs for lfb1-bukrs, "COMPANY CODE
    s_ekorg for lfm1-ekorg, "PURCHASING ORGANIZATION
    s_ktokk for lfa1-ktokk. "ACCOUNT GROUP
    selection-screen end of block b1.
    selection-screen begin of block b2  with frame title text-002.
    parameters: r1 radiobutton group g1,
                r2 radiobutton group g1.
    selection-screen end of block b2.
    data:
          v_repid like sy-repid,
          begin of itab occurs 0,
          lifnr like lfa1-lifnr,
          bukrs like lfb1-bukrs,
          ekorg like lfm1-ekorg,
          ktokk like lfa1-ktokk,
          name1 like lfa1-name1,
          stras like lfa1-stras,
          ort01 like lfa1-ort01,
          regio like lfa1-regio,
          pfort like lfa1-pfort,
          pstlz like lfa1-pstlz,
          pstl2 like lfa1-pstl2,
          telf1 like lfa1-telf1,
          end of itab.
    data : itab_event type slis_t_event,
           wa_event   type slis_alv_event.
    data : itab_fld_cat  type slis_t_fieldcat_alv,
           wa_fldcat     type slis_fieldcat_alv.
    data : wa_layout     type slis_layout_alv.
    start-of-selection.
    *PERFORM GET_VARIANT.
    PERFORM data_validation.
      perform select_data.
      perform get_events using itab_event .
      perform fieldcatmerge.
      if r1 = 'X'.
        perform alvlistdisplay.
      elseif r2 = 'X' .
        perform alvgriddisplay.
      endif.
    *&      Form  DATA_VALIDATION
          text
    -->  p1        text
    <--  p2        text
    form data_validation .
      data: v_count type i.
      if s_lifnr is initial and
         s_bukrs is initial and
         s_ekorg is initial and
         s_ktokk is initial.
        message e000(z13325).
      Enter any value in the Selection Screen
      endif.
      select count(*) from lfa1 where lifnr in s_lifnr.
      if sy-subrc <> 0.
        message e000(z13325).
      Enter any value in the Selection Screen
      endif.
      select count(*) from lfb1 where lifnr in s_bukrs.
      if sy-subrc <> 0.
        message e000(z13325).
      Enter any value in the Selection Screen
      endif.
      select count(*) from lfm1 where lifnr in s_ekorg.
      if sy-subrc <> 0.
        message e000(z13325).
      Enter any value in the Selection Screen
      endif.
      select count(*) from lfa1 where lifnr in s_ktokk.
      if sy-subrc <> 0.
        message e000(z13325).
      Enter any value in the Selection Screen
      endif.
    endform.                    " DATA_VALIDATION
    *&      Form  SELECT_DATA
          text
    -->  p1        text
    <--  p2        text
    form select_data .
      select a~lifnr
             b~bukrs
             c~ekorg
             a~ktokk
             a~name1
             a~stras
             a~ort01
             a~regio
             a~pfort
             a~pstlz
             a~pstl2
             a~telf1
          into corresponding fields of table itab
          from lfa1 as a inner join lfb1 as b
                         on alifnr = blifnr
                         inner join lfm1 as c
                         on alifnr = clifnr
                         where a~lifnr in s_lifnr
                         and b~bukrs in s_bukrs
                         and c~ekorg in s_ekorg
                         and a~ktokk in s_ktokk.
      sort itab by lifnr bukrs ekorg.
    endform.                    " SELECT_DATA
    *&      Form  FIELDCATMERGE
          text
    -->  p1        text
    <--  p2        text
    form fieldcatmerge .
      v_repid = sy-repid.
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
       exporting
         i_program_name               =  v_repid
         i_internal_tabname           =  'ITAB'
        I_STRUCTURE_NAME             =
        I_CLIENT_NEVER_DISPLAY       = 'X'
         i_inclname                   = v_repid
        I_BYPASSING_BUFFER           =
        I_BUFFER_ACTIVE              =
        changing
          ct_fieldcat                  = itab_fld_cat
       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.
    endform.                    " FIELDCATMERGE
    *&      Form  ALVLISTDISPLAY
          text
    -->  p1        text
    <--  p2        text
    form alvlistdisplay .
      v_repid = sy-repid.
      call function 'REUSE_ALV_LIST_DISPLAY'
        exporting
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
          i_callback_program             = v_repid
      I_CALLBACK_PF_STATUS_SET       = ' '
      I_CALLBACK_USER_COMMAND        = ' '
      I_STRUCTURE_NAME               =
          is_layout                      = wa_layout
          it_fieldcat                    = itab_fld_cat
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
          i_default                      = 'X'
       I_SAVE                         = 'A'
      IS_VARIANT                     =
          it_events                      = itab_event
       IT_EVENT_EXIT                 = itab_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
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
        tables
          t_outtab                       = itab
    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.                    " ALVLISTDISPLAY
    *&      Form  ALVGRIDDISPLAY
          text
    -->  p1        text
    <--  p2        text
    form alvgriddisplay .
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
          i_callback_program                = v_repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
       I_GRID_TITLE                      = 'GRID DISPLAY'
      I_GRID_SETTINGS                   =
       IS_LAYOUT                         = WS_LAYOUT1
          it_fieldcat                       =  itab_fld_cat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
          it_events                         = itab_event
       IT_EVENT_EXIT                     = itab_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                          = itab
         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.                    " ALVGRIDDISPLAY
    *&      Form  GET_EVENTS
          text
    -->  p1        text
    <--  p2        text
    form get_events using itab_event type slis_t_event.
      call function 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      I_LIST_TYPE           = 0
       importing
          et_events             = itab_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.
    read table itab_event with key name = slis_ev_top_of_page into wa_event
      if sy-subrc = 0.
        wa_event-form = 'FRM_TOP_OF_PAGE'.
        modify itab_event from wa_event index sy-tabix.
      endif.
    endform.                    " GET_EVENTS
    *&      Form  FRM_TOP_OF_PAGE
          text
    form frm_top_of_page.
    write : 130 'Time:'  ,sy-uzeit  .
      write :/2 'User: ', sy-uname.
      write: 59 sy-title, 130 'Page:' , sy-pagno.
      write:/ 'this is swathi and this is top of page '.
    endform.                    "FRM_TOP_OF_PAGE
    Reward points if helpful.
    Regards
    Swathi

  • How to add interactive feature in top of page in ALV .

    Hi All ,
    There is immediate requirement , I have to add interactive feature in top of page in ALV grid .
    Can anyone sort this out ?
    Reward points will be given.

    hi,
    check this example:
    REPORT  ZSR_ALV_INTERACTIVE2.
    TYPE-POOLS: SLIS.
    *DATA DECLARATION.
    TYPES: BEGIN OF I_VBAK,
    VBELN TYPE VBELN_VA,
    AUGRU TYPE AUGRU,
    END OF I_VBAK.
    TYPES: BEGIN OF I_VBAP,
    VBELN TYPE VBELN_VA,
    AUGRU TYPE AUGRU,
    POSNR TYPE POSNR_VA,
    MATNR TYPE MATNR,
    ZMENG TYPE DZMENG,
    END OF I_VBAP.
    TYPES: BEGIN OF I_MAKT,
    MATNR TYPE MATNR,
    MAKTX TYPE MAKTX,
    END OF I_MAKT.
    TYPES: BEGIN OF I_LIPS,
    POSNR TYPE POSNR_VL,
    MATNR TYPE MATNR,
    LFIMG TYPE LFIMG,
    END OF I_LIPS.
    TYPES: BEGIN OF I_REASON,
    SPRAS TYPE SPRAS,
    AUGRU TYPE AUGRU,
    BEZEI TYPE BEZEI40,
    END OF I_REASON.
    TYPES: BEGIN OF I_VBPA,
    VBELN TYPE VBELN,
    PARVW TYPE PARVW,
    KUNNR TYPE KUNNR,
    END OF I_VBPA.
    TYPES: BEGIN OF I_KNA1,
    KUNNR TYPE KUNNR,
    NAME1 TYPE NAME1_GP,
    END OF I_KNA1.
    TYPES: BEGIN OF I_FINAL,
    VBELN TYPE VBELN_VA,
    POSNR TYPE POSNR_VA,
    MATNR TYPE MATNR,
    ZMENG TYPE DZMENG,
    MAKTX TYPE MAKTX,
    LFIMG TYPE LFIMG,
    SPRAS TYPE SPRAS,
    AUGRU TYPE AUGRU,
    BEZEI TYPE BEZEI40,
    PARVW TYPE PARVW,
    KUNNR TYPE KUNNR,
    NAME1 TYPE NAME1_GP,
    END OF I_FINAL.
    *INTERNAL TABLES
    DATA: IT_VBAK TYPE STANDARD TABLE OF I_VBAK.
    DATA: IT_VBAP TYPE STANDARD TABLE OF I_VBAP.
    DATA: IT_MAKT TYPE STANDARD TABLE OF I_MAKT.
    DATA: IT_LIPS TYPE STANDARD TABLE OF I_LIPS.
    DATA: IT_VBPA TYPE STANDARD TABLE OF I_VBPA.
    DATA: IT_KNA1 TYPE STANDARD TABLE OF I_KNA1.
    DATA: IT_FINAL TYPE STANDARD TABLE OF I_FINAL.
    DATA: IT_REASON TYPE STANDARD TABLE OF I_REASON.
    DATA : V_FLAG.
    *WORK AREA
    DATA: WA_VBAK TYPE I_VBAK.
    DATA: WA_VBAP TYPE I_VBAP.
    DATA: WA_MAKT TYPE I_MAKT.
    DATA: WA_LIPS TYPE I_LIPS.
    DATA: WA_VBPA TYPE I_VBPA.
    DATA: WA_KNA1 TYPE I_KNA1.
    DATA: WA_FINAL TYPE I_FINAL.
    DATA: WA_REASON TYPE I_REASON.
    *DATA DECLARATION.
    DATA: V_PROGNAME TYPE SY-REPID.
    DATA: V_VBELN TYPE VBAK-VBELN.
    DATA: V_GRIDTITLE TYPE LVC_TITLE.
    ***PARAMETERS: D_VARI LIKE DISVARIANT-VARIANT.
    *DATA: I_VARIANT LIKE DISVARIANT.
    *DATA: P_VARI LIKE DISVARIANT-VARIANT.
    *DATA DECLARATION FOR CATALOGS LAYOUT SORT EVENTCATALOG TOPOFPAGE.
    DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA: I_LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA: I_SORTINFO TYPE SLIS_T_SORTINFO_ALV.
    DATA: I_LISTHEADER TYPE SLIS_T_LISTHEADER.
    DATA: I_EVENTCAT TYPE SLIS_T_EVENT.
    INITIALIZATION.
      V_PROGNAME = SY-REPID.
      V_FLAG = SPACE.
    *SELECTION SCREEN
      SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-002.
      SELECT-OPTIONS: S_VBELN FOR V_VBELN.
      SELECTION-SCREEN END OF BLOCK BLK1.
    *AT SLECTION-SCREEN.
    AT SELECTION-SCREEN.
      PERFORM Z_VALIDATIONS.
    *START OF SELECTION.
    START-OF-SELECTION.
      PERFORM Z_SELECT.
      PERFORM CHECK_VALIDATION_FLAG.
      PERFORM Z_FIELDCAT USING I_FIELDCAT.
      PERFORM Z_LAYOUT.
      PERFORM Z_SORTINFO USING I_SORTINFO.
      PERFORM Z_EVENTCAT USING I_EVENTCAT.
      PERFORM Z_GRIDTITLE.
      PERFORM Z_LISTHEADER USING I_LISTHEADER.
      PERFORM Z_DISPLAY.
    *& Form Z_VALIDATIONS
    FORM Z_VALIDATIONS .
      SELECT VBELN INTO V_VBELN
      UP TO 1 ROWS
      FROM VBAK
      WHERE VBELN IN S_VBELN.
      ENDSELECT.
      IF SY-SUBRC <> 0.
        MESSAGE I002(SY) WITH 'No Records'.
        V_FLAG = 'X'.
      ENDIF.
    ENDFORM. " Z_VALIDATIONS
    *& Form Z_FIELDCAT
    FORM Z_FIELDCAT USING P_I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
      DATA: I_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    *VBAK-VELN
      I_FIELDCAT-COL_POS = '1'. " POSITION OF THE COLUMN.
      I_FIELDCAT-FIELDNAME = 'VBELN'. " FIELD FOR WHICH CATALOG ID FILLED.
      I_FIELDCAT-TABNAME = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD
    *BELONGS TO.
      I_FIELDCAT-KEY = 'X'. " SO THAT THIS FIELD IS NOT SCROLLABLE AND
    *HIDDABLE.
      I_FIELDCAT-JUST = 'C'. " FOR JUSTIFICATION.
      I_FIELDCAT-LZERO = 'X'. " OUTPUT WITH LEADING ZEROS.
      I_FIELDCAT-SELTEXT_L = 'SALES ORDER'. " LONG TEXT FOR HEADER.
      I_FIELDCAT-OUTPUTLEN = 15. " SET THE OUTPUT LENGTH.
      I_FIELDCAT-REF_TABNAME = 'VBAK'. " FOR F1 & F4 HELP AS REFERNCED TO
    *THE DDIC TABLE.
      APPEND I_FIELDCAT TO P_I_FIELDCAT.
    *VBAP-SPRAS
      I_FIELDCAT-COL_POS = '2'. " POSITION OF THE COLUMN.
      I_FIELDCAT-FIELDNAME = 'SPRAS'. " FIELD FOR WHICH CATALOG ID FILLED.
      I_FIELDCAT-TABNAME = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD
    *BELONGS TO.
      I_FIELDCAT-LZERO = 'X'. " OUTPUT WITH LEADING ZEROS.
      I_FIELDCAT-SELTEXT_L = 'LANGUAGE'. " LONG TEXT FOR HEADER.
      I_FIELDCAT-OUTPUTLEN = 5. " SET THE OUTPUT LENGTH.
      I_FIELDCAT-REF_TABNAME = 'TVAUT'. " FOR F1 & F4 HELP AS REFERNCED TO
    *TABLE.
      APPEND I_FIELDCAT TO P_I_FIELDCAT.
    *VBAP-AUGRU
      I_FIELDCAT-COL_POS = '3'. " POSITION OF THE COLUMN.
      I_FIELDCAT-FIELDNAME = 'AUGRU'. " FIELD FOR WHICH CATALOG ID FILLED.
      I_FIELDCAT-TABNAME = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD
    *BELONGS TO.
      I_FIELDCAT-LZERO = 'X'. " OUTPUT WITH LEADING ZEROS.
      I_FIELDCAT-SELTEXT_L = 'REASON'. " LONG TEXT FOR HEADER.
      I_FIELDCAT-OUTPUTLEN = 5. " SET THE OUTPUT LENGTH.
      I_FIELDCAT-REF_TABNAME = 'VBAK'. " FOR F1 & F4 HELP AS REFERNCED TO
    *TABLE.
      APPEND I_FIELDCAT TO P_I_FIELDCAT.
    *VBAP-bezei
      I_FIELDCAT-COL_POS = '4'. " POSITION OF THE COLUMN.
      I_FIELDCAT-FIELDNAME = 'BEZEI'. " FIELD FOR WHICH CATALOG ID FILLED.
      I_FIELDCAT-TABNAME = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD
    *BELONGS TO.
      I_FIELDCAT-LZERO = 'X'. " OUTPUT WITH LEADING ZEROS.
      I_FIELDCAT-SELTEXT_L = 'DESCRIPTION'. " LONG TEXT FOR HEADER.
      I_FIELDCAT-OUTPUTLEN = 20. " SET THE OUTPUT LENGTH.
      I_FIELDCAT-REF_TABNAME = 'TVAUT'. " FOR F1 & F4 HELP AS REFERNCED TO
    *TABLE.
      APPEND I_FIELDCAT TO P_I_FIELDCAT.
    *VBAP-POSNR
      I_FIELDCAT-COL_POS = '5'. " POSITION OF THE COLUMN.
      I_FIELDCAT-FIELDNAME = 'POSNR'. " FIELD FOR WHICH CATALOG ID FILLED.
      I_FIELDCAT-TABNAME = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD
    *BELONGS TO.
      I_FIELDCAT-LZERO = 'X'. " OUTPUT WITH LEADING ZEROS.
      I_FIELDCAT-SELTEXT_L = 'ITEM'. " LONG TEXT FOR HEADER.
      I_FIELDCAT-OUTPUTLEN = 8. " SET THE OUTPUT LENGTH.
      I_FIELDCAT-REF_TABNAME = 'VBAP'. " FOR F1 & F4 HELP AS REFERNCED TO
    *TABLE.
      APPEND I_FIELDCAT TO P_I_FIELDCAT.
    *VBAP-MATNR.
      I_FIELDCAT-COL_POS = '6'. " POSITION OF THE COLUMN.
      I_FIELDCAT-FIELDNAME = 'MATNR'. " FIELD FOR WHICH CATALOG ID FILLED.
      I_FIELDCAT-TABNAME = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD
    *BELONGS TO.
      I_FIELDCAT-LZERO = 'X'. " OUTPUT WITH LEADING ZEROS.
      I_FIELDCAT-SELTEXT_L = 'MATERIAL'. " LONG TEXT FOR HEADER.
      I_FIELDCAT-OUTPUTLEN = 10. " SET THE OUTPUT LENGTH.
      I_FIELDCAT-REF_TABNAME = 'VBAP'. " FOR F1 & F4 HELP AS REFERNCED TO
    *TABLE.
      APPEND I_FIELDCAT TO P_I_FIELDCAT.
    *VBAP-ZMENG
      I_FIELDCAT-COL_POS = '7'. " POSITION OF THE COLUMN.
      I_FIELDCAT-FIELDNAME = 'ZMENG'. " FIELD FOR WHICH CATALOG ID FILLED.
      I_FIELDCAT-TABNAME = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD
    *BELONGS TO.
      I_FIELDCAT-LZERO = 'X'. " OUTPUT WITH LEADING ZEROS.
      I_FIELDCAT-SELTEXT_L = 'QUANT'. " LONG TEXT FOR HEADER.
      I_FIELDCAT-OUTPUTLEN = 10. " SET THE OUTPUT LENGTH.
      I_FIELDCAT-REF_TABNAME = 'VBAP'. " FOR F1 & F4 HELP AS REFERNCED TO
    *TABLE.
      APPEND I_FIELDCAT TO P_I_FIELDCAT.
    *MAKT-MAKTX
      I_FIELDCAT-COL_POS = '8'. " POSITION OF THE COLUMN.
      I_FIELDCAT-FIELDNAME = 'MAKTX'. " FIELD FOR WHICH CATALOG ID FILLED.
      I_FIELDCAT-TABNAME = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD
    *BELONGS TO.
      I_FIELDCAT-LZERO = 'X'. " OUTPUT WITH LEADING ZEROS.
      I_FIELDCAT-SELTEXT_L = 'DESCRIPTION'. " LONG TEXT FOR HEADER.
      I_FIELDCAT-OUTPUTLEN = 20. " SET THE OUTPUT LENGTH.
      I_FIELDCAT-REF_TABNAME = 'MAKT'. " FOR F1 & F4 HELP AS REFERNCED TO
    *TABLE.
      APPEND I_FIELDCAT TO P_I_FIELDCAT.
    *LIPS-VBELN
      I_FIELDCAT-COL_POS = '9'. " POSITION OF THE COLUMN.
      I_FIELDCAT-FIELDNAME = 'VBELN'. " FIELD FOR WHICH CATALOG ID FILLED.
      I_FIELDCAT-TABNAME = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD
    *BELONGS TO.
      I_FIELDCAT-LZERO = 'X'. " OUTPUT WITH LEADING ZEROS.
      I_FIELDCAT-SELTEXT_L = 'DELIVERY'. " LONG TEXT FOR HEADER.
      I_FIELDCAT-OUTPUTLEN = 15. " SET THE OUTPUT LENGTH.
      I_FIELDCAT-REF_TABNAME = 'LIPS'. " FOR F1 & F4 HELP AS REFERNCED TO
    *TABLE.
      APPEND I_FIELDCAT TO P_I_FIELDCAT.
    *LIPS-LFIMG
      I_FIELDCAT-COL_POS = '10'. " POSITION OF THE COLUMN.
      I_FIELDCAT-FIELDNAME = 'LFIMG'. " FIELD FOR WHICH CATALOG ID FILLED.
      I_FIELDCAT-TABNAME = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD
    *BELONGS TO.
      I_FIELDCAT-LZERO = 'X'. " OUTPUT WITH LEADING ZEROS.
      I_FIELDCAT-DO_SUM = 'X'.
      I_FIELDCAT-SELTEXT_L = 'LFIMG'. " LONG TEXT FOR HEADER.
      I_FIELDCAT-OUTPUTLEN = 18. " SET THE OUTPUT LENGTH.
      I_FIELDCAT-REF_TABNAME = 'LIPS'. " FOR F1 & F4 HELP AS REFERNCED TO
    *TABLE.
      APPEND I_FIELDCAT TO P_I_FIELDCAT.
    *parvw
      I_FIELDCAT-COL_POS = '11'. " POSITION OF THE COLUMN.
      I_FIELDCAT-FIELDNAME = 'PARVW'. " FIELD FOR WHICH CATALOG ID FILLED.
      I_FIELDCAT-TABNAME = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD
    *BELONGS TO.
      I_FIELDCAT-LZERO = 'X'. " OUTPUT WITH LEADING ZEROS.
      I_FIELDCAT-SELTEXT_L = 'PARTNER FUN'. " LONG TEXT FOR HEADER.
      I_FIELDCAT-OUTPUTLEN = 18. " SET THE OUTPUT LENGTH.
      I_FIELDCAT-REF_TABNAME = 'VBPA'. " FOR F1 & F4 HELP AS REFERNCED TO
    *TABLE.
      APPEND I_FIELDCAT TO P_I_FIELDCAT.
    *KUNNR
      I_FIELDCAT-COL_POS = '12'. " POSITION OF THE COLUMN.
      I_FIELDCAT-FIELDNAME = 'KUNNR'. " FIELD FOR WHICH CATALOG ID FILLED.
      I_FIELDCAT-TABNAME = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD
    *BELONGS TO.
      I_FIELDCAT-LZERO = 'X'. " OUTPUT WITH LEADING ZEROS.
      I_FIELDCAT-SELTEXT_L = 'SHIP'. " LONG TEXT FOR HEADER.
      I_FIELDCAT-OUTPUTLEN = 18. " SET THE OUTPUT LENGTH.
      I_FIELDCAT-REF_TABNAME = 'VBPA'. " FOR F1 & F4 HELP AS REFERNCED TO
    *TABLE.
      APPEND I_FIELDCAT TO P_I_FIELDCAT.
    *NAME1
      I_FIELDCAT-COL_POS = '13'. " POSITION OF THE COLUMN.
      I_FIELDCAT-FIELDNAME = 'NAME1'. " FIELD FOR WHICH CATALOG ID FILLED.
      I_FIELDCAT-TABNAME = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD
    *BELONGS TO.
      I_FIELDCAT-LZERO = 'X'. " OUTPUT WITH LEADING ZEROS.
      I_FIELDCAT-SELTEXT_L = 'NAME'. " LONG TEXT FOR HEADER.
      I_FIELDCAT-OUTPUTLEN = 18. " SET THE OUTPUT LENGTH.
      I_FIELDCAT-REF_TABNAME = 'KNA1'. " FOR F1 & F4 HELP AS REFERNCED TO
    *TABLE.
      APPEND I_FIELDCAT TO P_I_FIELDCAT.
    ENDFORM. " Z_FIELDCAT
    *& Form Z_SELECT
    FORM Z_SELECT .
      SELECT VBELN
      AUGRU INTO CORRESPONDING FIELDS OF TABLE IT_VBAK
      FROM VBAK
      WHERE VBELN IN S_VBELN.
      IF SY-SUBRC = 0.
        SELECT VBELN
        POSNR
        MATNR
        ZMENG INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
        FROM VBAP
        FOR ALL ENTRIES IN IT_VBAK
        WHERE VBELN = IT_VBAK-VBELN.
        IF SY-SUBRC = 0.
          SELECT SPRAS
          AUGRU
          BEZEI INTO CORRESPONDING FIELDS OF TABLE IT_REASON
          FROM TVAUT
          FOR ALL ENTRIES IN IT_VBAK
          WHERE AUGRU = IT_VBAK-AUGRU.
          IF SY-SUBRC = 0.
            SELECT VBELN
            PARVW
            KUNNR INTO CORRESPONDING FIELDS OF TABLE IT_VBPA
            FROM VBPA
            FOR ALL ENTRIES IN IT_VBAK
            WHERE VBELN = IT_VBAK-VBELN.
            IF SY-SUBRC = 0.
              SELECT KUNNR
              NAME1 INTO CORRESPONDING FIELDS OF TABLE IT_KNA1
              FROM KNA1
              FOR ALL ENTRIES IN IT_VBPA
              WHERE KUNNR = IT_VBPA-KUNNR.
              IF SY-SUBRC = 0.
                SELECT POSNR
                MATNR
                LFIMG INTO CORRESPONDING FIELDS OF TABLE IT_LIPS
                FROM LIPS
                FOR ALL ENTRIES IN IT_VBAP
                WHERE POSNR = IT_VBAP-POSNR.
                IF SY-SUBRC = 0.
                  SELECT MATNR
                  MAKTX INTO CORRESPONDING FIELDS OF TABLE IT_MAKT
                  FROM MAKT
                  FOR ALL ENTRIES IN IT_VBAP
                  WHERE MATNR = IT_VBAP-MATNR.
                ENDIF.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.
      ELSE.
        MESSAGE I002(SY) WITH 'No Data found'.
        LEAVE LIST-PROCESSING.
      ENDIF.
      IF SY-SUBRC = 0.
        LOOP AT IT_VBAP INTO WA_VBAP.
          READ TABLE IT_VBAK INTO WA_VBAK WITH KEY VBELN = WA_VBAP-VBELN
    BINARY SEARCH.
          IF SY-SUBRC = 0.
    *MOVE DATA INTO IT_FINAL.
            MOVE: WA_VBAK-VBELN TO WA_FINAL-VBELN,
            WA_VBAK-AUGRU TO WA_FINAL-AUGRU,
            WA_VBAP-POSNR TO WA_FINAL-POSNR,
            WA_VBAP-MATNR TO WA_FINAL-MATNR,
            WA_VBAP-ZMENG TO WA_FINAL-ZMENG.
          ENDIF.
          READ TABLE IT_LIPS INTO WA_LIPS WITH KEY POSNR = WA_FINAL-POSNR
    BINARY SEARCH.
          IF SY-SUBRC = 0.
            MOVE: WA_LIPS-LFIMG TO WA_FINAL-LFIMG.
          ENDIF.
          READ TABLE IT_REASON INTO WA_REASON WITH KEY AUGRU =
    WA_FINAL-AUGRU BINARY SEARCH.
          IF SY-SUBRC = 0.
            MOVE: WA_REASON-SPRAS TO WA_FINAL-SPRAS,
            WA_REASON-BEZEI TO WA_FINAL-BEZEI.
          ENDIF.
          READ TABLE IT_MAKT INTO WA_MAKT WITH KEY MATNR = WA_FINAL-MATNR
    BINARY SEARCH.
          IF SY-SUBRC = 0.
            MOVE: WA_MAKT-MAKTX TO WA_FINAL-MAKTX.
          ENDIF.
          READ TABLE IT_VBPA INTO WA_VBPA WITH KEY VBELN = WA_FINAL-VBELN
    BINARY SEARCH.
          IF SY-SUBRC = 0.
            MOVE: WA_VBPA-PARVW TO WA_FINAL-PARVW,
            WA_VBPA-KUNNR TO WA_FINAL-KUNNR.
          ENDIF.
          READ TABLE IT_KNA1 INTO WA_KNA1 WITH KEY KUNNR = WA_FINAL-KUNNR
    BINARY SEARCH.
          IF SY-SUBRC = 0.
            MOVE: WA_KNA1-NAME1 TO WA_FINAL-NAME1.
          ENDIF.
          APPEND WA_FINAL TO IT_FINAL.
          CLEAR WA_FINAL.
        ENDLOOP.
      ENDIF.
    ENDFORM. " Z_SELECT
    *& Form Z_LAYOUT
    FORM Z_LAYOUT .
      I_LAYOUT-ZEBRA = 'X'.
      I_LAYOUT-TOTALS_TEXT = 'Total'(A00).
      I_LAYOUT-SUBTOTALS_TEXT = 'SubTotal'(A01).
      I_LAYOUT-BOX_TABNAME = 'IT_FINAL'.
    ENDFORM. " Z_LAYOUT
    *& Form Z_SORTINFO
    FORM Z_SORTINFO USING P_I_SORTINFO TYPE SLIS_T_SORTINFO_ALV.
      DATA: I_SORTINFO TYPE SLIS_SORTINFO_ALV.
      CLEAR I_SORTINFO.
      I_SORTINFO-SPOS = '1'.
      I_SORTINFO-FIELDNAME = 'VBELN'.
      I_SORTINFO-TABNAME = 'IT_FINAL'.
      I_SORTINFO-UP = 'X'.
      I_SORTINFO-GROUP = 'UL'. " I.E UNDERLINE AFTER EVERY GROUP
      I_SORTINFO-SUBTOT = 'X'.
      APPEND I_SORTINFO TO P_I_SORTINFO.
    ENDFORM. " Z_SORTINFO
    *& Form Z_EVENTCAT
    FORM Z_EVENTCAT USING P_I_EVENTCAT TYPE SLIS_T_EVENT.
      DATA: I_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          I_LIST_TYPE     = 0
        IMPORTING
          ET_EVENTS       = P_I_EVENTCAT
        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.
      CLEAR I_EVENT.
      READ TABLE P_I_EVENTCAT WITH KEY NAME = SLIS_EV_TOP_OF_PAGE INTO
      I_EVENT.
      IF SY-SUBRC = 0.
        MOVE 'TOP_OF_PAGE' TO I_EVENT-FORM.
        APPEND I_EVENT TO P_I_EVENTCAT.
      ENDIF.
      READ TABLE P_I_EVENTCAT WITH KEY NAME = SLIS_EV_PF_STATUS_SET INTO
    I_EVENT.
      IF SY-SUBRC = 0.
        MOVE 'SET_PF_STATUS' TO I_EVENT-FORM.
        APPEND I_EVENT TO P_I_EVENTCAT.
      ENDIF.
      CLEAR I_EVENT.
      READ TABLE P_I_EVENTCAT INTO I_EVENT WITH KEY NAME =
    SLIS_EV_USER_COMMAND .
      IF SY-SUBRC = 0.
        MOVE 'USER_COMMAND' TO I_EVENT-FORM.
        APPEND I_EVENT TO P_I_EVENTCAT.
      ENDIF.
    ENDFORM. " Z_EVENTCAT
    *& Form Z_DISPLAY
    FORM Z_DISPLAY .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
      I_CALLBACK_PROGRAM = V_PROGNAME
    *I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
      I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
      I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
      I_GRID_TITLE = V_GRIDTITLE
      I_SAVE = 'A'
      IS_LAYOUT = I_LAYOUT
      IT_FIELDCAT = I_FIELDCAT[]
      IT_SORT = I_SORTINFO
      IT_EVENTS = I_EVENTCAT
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
      TABLES
      T_OUTTAB = IT_FINAL
      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. " Z_DISPLAY
    *& Form Z_GRIDTITLE
    FORM Z_GRIDTITLE .
      V_GRIDTITLE = 'ALV FOR SALES ORDER DISPLAY'.
    ENDFORM. " Z_GRIDTITLE
    *TOP OF PAGE.
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY = I_LISTHEADER.
    ENDFORM. "TOP_OF_PAGE
    *MENU SETTINGS.
    FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'ALV_MENU'.
    ENDFORM. "SET_PF_STATUS
    *USER-COMMAND
    FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
      DATA : VBELN TYPE VBELN_VA.
      CASE P_UCOMM.
        WHEN 'BACK'.
          LEAVE PROGRAM.
        WHEN '&IC1'.
          CLEAR : VBELN.
          VBELN = RS_SELFIELD-VALUE.
          SET PARAMETER ID: 'AUN' FIELD VBELN.
          CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
      ENDCASE.
    ENDFORM. " USER_COMMAND
    *& Form Z_LISTHEADER
    FORM Z_LISTHEADER USING P_I_LISTHEADER TYPE SLIS_T_LISTHEADER.
      DATA: L_LISTHEADER TYPE SLIS_LISTHEADER.
      REFRESH P_I_LISTHEADER.
      CLEAR L_LISTHEADER.
      L_LISTHEADER-TYP = 'H'.
      L_LISTHEADER-INFO = TEXT-001.
      APPEND L_LISTHEADER TO P_I_LISTHEADER.
      CLEAR L_LISTHEADER.
      L_LISTHEADER-TYP = 'H'.
      L_LISTHEADER-INFO = TEXT-002.
      APPEND L_LISTHEADER TO P_I_LISTHEADER.
    ENDFORM. " Z_LISTHEADER
    *& Form check_validation_flag
    text
    --> p1 text
    <-- p2 text
    FORM CHECK_VALIDATION_FLAG .
      IF NOT V_FLAG IS INITIAL.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM. " check_validation_flag

  • How to give colors to the top-of-page in ALV List Display

    how to give colors to the top-of-page in ALV List Display....

    Check this blog.........
    It provides your required output...........
    /people/vijaybabu.dudla/blog/2006/07/21/topofpage-in-alv-using-clguialvgrid
    See the point 7 for complete code...
    Regards,
    Pavan

  • How to display values in top of page in ALV report

    Hai,
      This is my billing report program, i developed that object by using ALV but i could not able to use Top-of-page. please any one correct my code,
    *& Report  ZE0232_ALV_BILLING                                          *
    report  ze0232_alv_billing.
    type-pools: slis.
    data: repid like sy-repid.
    data: fieldcatalog type slis_t_fieldcat_alv,
          wa_fieldcatalog type slis_fieldcat_alv.
    data : ievent type slis_t_event,
    wevent type slis_alv_event.
    data: sal_text like tvkot-vtext,
          DIS_TEXT LIKE TVTWT-VTEXT,
          DIV_TEXT LIKE TSPAT-VTEXT.
    tables: vbrk.
    data: begin of i_vbrk occurs 0,
          vbeln like vbrk-vbeln,
          fkdat like vbrk-fkdat,
          erdat like vbrk-erdat,
          kunrg like vbrk-kunrg,
          name1 like kna1-name1,
          netwr like vbrk-netwr,
          stext like tvkot-vtext,
          dtext like tvtwt-vtext,
          divtext like tspat-vtext,
          end of i_vbrk.
    selection-screen begin of block billing with frame.
    parameters: salesorg like vbrk-vkorg.
    select-options: dischanl for vbrk-vtweg,
                    division for vbrk-spart,
                    bildat for vbrk-fkdat.
    selection-screen end of block billing.
    select vbeln fkdat erdat kunrg netwr from vbrk into corresponding fields of table i_vbrk where vkorg = salesorg
                                                                                    and vtweg in dischanl
                                                                                    and spart in division
                                                                                    and fkdat in bildat.
    select vtext from tvkot into sal_text where vkorg = salesorg and spras = 'EN'.
    endselect.
    select vtext from TVTWT into DIS_text where VTWEG IN dischanl and spras = 'EN'.
    endselect.
    select vtext from TSPAT into DIV_text where SPART IN DIVISION and spras = 'EN'.
    endselect.
    loop at i_vbrk.
      move: sal_text to i_vbrk-stext,
            DIS_TEXT TO I_VBRK-DTEXT,
            DIV_TEXT TO I_VBRK-DIVTEXT.
      modify i_vbrk.
    endloop.
    perform get_fieldcatalog.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
        i_callback_program                = repid
      I_GRID_TITLE                      =
        i_callback_top_of_page            = 'TOPS'
        it_fieldcat                       = fieldcatalog
      tables
        t_outtab                          = i_vbrk
    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  GET_FIELDCATALOG
          text
    <b>form tops.
      write :/ 'Hai Welcome'.
    endform.                    "tops</b>&----
    *&      Form  get_fieldcatalog
          text
    form get_fieldcatalog.
      wa_fieldcatalog-col_pos = '1'.
      wa_fieldcatalog-fieldname = 'VBELN'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'SALES DOCUMENT'.
    WA_fieldcatalog-rollname  = 'VBELN'.
      wa_fieldcatalog-hotspot   = 'X'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '2'.
      wa_fieldcatalog-fieldname = 'FKDAT'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'BILL DATE'.
    WA_fieldcatalog-rollname  = 'VBELN'.
    WA_fieldcatalog-hotspot   = 'X'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '3'.
      wa_fieldcatalog-fieldname = 'ERDAT'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'CREATED DATE'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '4'.
      wa_fieldcatalog-fieldname = 'KUNRG'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'CUSTOMER NO'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '5'.
      wa_fieldcatalog-fieldname = 'NAME1'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'CUSTOMER NAME'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '6'.
      wa_fieldcatalog-fieldname = 'NETWR'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'NET VALUE'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '7'.
      wa_fieldcatalog-fieldname = 'STEXT'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'SALES ORG'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '8'.
      wa_fieldcatalog-fieldname = 'DTEXT'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'DIS.CHANNEL'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '9'.
      wa_fieldcatalog-fieldname = 'DIVTEXT'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'DIVISION'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
    endform.                    "GET_FIELDCATALOG

    HI see this report
    you can know how to write TOP-OF_PAGE code
    and insert LOGO also
    *& Report  ZTEST_ALV_LOGO
    REPORT  ztest_alv_logo.
    TYPE-POOLS : slis.
    *ALV Formatting tables /structures
    DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: gt_events   TYPE slis_t_event.
    DATA: gs_layout   TYPE slis_layout_alv.
    DATA: gt_page     TYPE slis_t_listheader.
    DATA: gs_page     TYPE slis_listheader.
    DATA: v_repid     LIKE sy-repid.
    *ALV Formatting work area
    DATA: w_fieldcat TYPE slis_fieldcat_alv.
    DATA: w_events   TYPE slis_alv_event.
    DATA: gt_bsid TYPE TABLE OF bsid WITH HEADER LINE.
    INITIALIZATION.
      PERFORM build_events.
      PERFORM build_page_header.
    START-OF-SELECTION.
    *perform build_comment.     "top_of_page - in initialization at present
      SELECT * FROM bsid INTO TABLE gt_bsid UP TO 10 ROWS.
    *perform populate_for_fm using '1' '3' 'BUKRS' '8' 'GT_BSID' 'Whee'.
    *USING = Row, Column, Field name, display length, table name, heading
    *OR
      PERFORM build_fieldcat.
      gs_layout-zebra = 'X'.
    *top of page event does not work without I_callback_program
      v_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program                = v_repid
          i_structure_name                  = 'BSID'
       i_background_id                   = 'ALV_BACKGROUND'
          i_grid_title                      = 'This is the grid title'
      I_GRID_SETTINGS                   =
          is_layout                         = gs_layout
          it_fieldcat                       = gt_fieldcat[]
          it_events                         = gt_events[]
        TABLES
          t_outtab                          = gt_bsid.
    Form..............:  populate_for_fm
    Description.......:  Populates fields for function module used in ALV
    FORM populate_for_fm USING p_row
                               p_col
                               p_fieldname
                               p_len
                               p_table
                               p_desc.
      w_fieldcat-row_pos      = p_row.          "Row Position
      w_fieldcat-col_pos      = p_col.          "Column Position
      w_fieldcat-fieldname    = p_fieldname.    "Field name
      w_fieldcat-outputlen    = p_len.          "Column Lenth
      w_fieldcat-tabname      = p_table.        "Table name
      w_fieldcat-reptext_ddic = p_desc.         "Field Description
      w_fieldcat-input        = '1'.
      APPEND w_fieldcat TO gt_fieldcat.
      CLEAR w_fieldcat.
    ENDFORM.                    " populate_for_fm
    *&      Form  build_events
    FORM build_events.
      DATA: ls_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = gt_events.
      READ TABLE gt_events
                 WITH KEY name =  slis_ev_user_command
                 INTO ls_event.
      IF sy-subrc = 0.
        MOVE slis_ev_user_command TO ls_event-form.
        APPEND ls_event TO gt_events.
      ENDIF.
      READ TABLE gt_events
                 WITH KEY name =  slis_ev_top_of_page
                 INTO ls_event.
      IF sy-subrc = 0.
        MOVE slis_ev_top_of_page TO ls_event-form.
        APPEND ls_event TO gt_events.
      ENDIF.
    ENDFORM.                    " build_events
    *&      Form  USER_COMMAND
    When user command is called it uses 2 parameters. The itab
    passed to the ALV is in whatever order it currently is on screen.
    Therefore, you can read table itab index rs_selfield-tabindex to get
    all data from the table. You can also check r_ucomm and code
    accordingly.
    FORM user_command USING  r_ucomm     LIKE sy-ucomm
                             rs_selfield TYPE slis_selfield.
      READ TABLE gt_bsid INDEX rs_selfield-tabindex.
    error checking etc.
      SET PARAMETER ID 'KUN' FIELD gt_bsid-kunnr.
      CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
    ENDFORM.                    "user_command
    *&      Form  top_of_page
    Your own company logo can go here if it has been saved (OAOR)
    If the logo is larger than the size of the headings in gt_page,
    the window will not show full logo and will have a scroll bar. Thus,
    it is a good idea to have a standard ALV header if you are going to
    use logos in your top of page.
    FORM top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = gt_page
          i_logo             = 'ENJOYSAP_LOGO'.
    ENDFORM.                    "top_of_page
    *&      Form  build_fieldcat
    *Many and varied fields are available here. Have a look at documentation
    *for FM REUSE_ALV_LIST_DISPLAY and REUSE_ALV_FIELDCATALOG_MERGE
    FORM build_fieldcat.
      w_fieldcat-fieldname  = 'BUDAT'.
      w_fieldcat-seltext_m  = 'Dte pst'.
      w_fieldcat-ddictxt(1) = 'M'.
      w_fieldcat-edit = 'x'.
    Can change the position of fields if you do not want them in order
    of the DDIC or itab
    w_fieldcat-row_pos = '1'.
    w_fieldcat-col_pos = '10'.
      APPEND w_fieldcat TO gt_fieldcat.
      CLEAR w_fieldcat.
    ENDFORM.                    " build_fieldcat
    *&      Form  build_page_header
          gt_page is used in top of page (ALV subroutine - NOT event)
          *H = Header, S = Selection, A = Action
    FORM build_page_header.
    For Headers, Key is not printed and is irrelevant. Will not cause
    a syntax error, but is not used.
      gs_page-typ  = 'H'.
      gs_page-info = 'Header 1'.
      APPEND gs_page TO gt_page.
      gs_page-typ  = 'H'.
      gs_page-info = 'Header 2'.
      APPEND gs_page TO gt_page.
    For Selections, the Key is printed (bold). It can be anything up to 20
    bytes. It gets printed in order of code here, not by key value.
      gs_page-typ  = 'S'.
      gs_page-key  = 'And the winner is:'.
      gs_page-info = 'Selection 1'.
      APPEND gs_page TO gt_page.
      gs_page-typ  = 'S'.
      gs_page-key  = 'Runner up:'.
      gs_page-info = 'Selection 2'.
      APPEND gs_page TO gt_page.
    For Action, Key is also irrelevant.
      gs_page-typ  = 'A'.
      gs_page-info = 'Action goes here'.
      APPEND gs_page TO gt_page.
    ENDFORM.                    " build_page_header
    <b>Reward if useful</b>

Maybe you are looking for

  • Print on Epson printer font 17 cpi

    Hi, i have problems with printing report 6i on the printer epson dfx 8000. I want to print 210 chars in one line. Does somebody know how to do that ? (Edit .prt file ???). My OS is WinXp, which driver should i use, Generic or Epson ?

  • NameNotFoundException: CustomerBean not bound

    Hi, after making the JavaEE5 Dukesbank example work under Sun AS 9, I've tried the same under JBoss 4.2.0.CR1. It gives me the following error message: ERROR [JBossInjectionProvider] Injection failed on managed bean. javax.naming.NameNotFoundExceptio

  • PaintComponent, paint and repaint?

    Hi everybody, I am a little confused on the usage of these methods. I have two problems: I have a JPanel inside a Jframe. In order to draw a Line2D object on this panel, I have to overwrite the paintComponent() method of JPanel. This causes two probl

  • Programming the BACK button from a list

    Hi, I have a program that utilizes a selection-screen, a customized screen, and a list (leave to list-processing) respectively. What i want to know is how to enable the back buttom from the list to immediately go to the selection-screen instead of th

  • FXO Disconnect Problem

    Hello, I just would like to ask some ideas on FXO disconnect problem having a setup of FXO to FXO termination on both sites. I am using a VIC-2FXO-M2 on both Cisco 1760-V Router and these fxo ports are terminated to the PABX local.The voice port will