Top-of-page

Hi Experts ,
                I am using alv grid in my report. In the output .. my field have long text and the text is chopped. what should i do to see full text in my output.
How to do subtotals in my report. i have used the form for the subtotals. but its not working. is anything am doing wrong... please help me.
FORM sub_total CHANGING
  p_total TYPE any
  p_subtot_text TYPE slis_subtot_text.
  IF p_subtot_text-criteria = 'WRBTR'.
    p_subtot_text-display_text_for_subtotal = 'Plant level total'(010).
  ENDIF.
ENDFORM.                    " sub_total
Regards,
sirish
Correct answers will be rewarded with full points.

hi,
check this sample program.it will give u subtotal,total along with text.
REPORT ZGM_ALV_SUBTOTAL_TEXT .
*& Table declaration
TABLES: ekko.
*& Type pool declaration
TYPE-POOLS: slis. " Type pool for ALV
*& Selection screen
SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.
*& Type declaration
Type declaration for internal table to store EKPO data
TYPES: BEGIN OF x_data,
ebeln TYPE char30, " Document no.
ebelp TYPE ebelp, " Item no
matnr TYPE matnr, " Material no
matnr1 TYPE matnr, " Material no
werks TYPE werks_d, " Plant
werks1 TYPE werks_d, " Plant
ntgew TYPE entge, " Net weight
gewe TYPE egewe, " Unit of weight
END OF x_data.
*& Internal table declaration
DATA:
i_ekpo TYPE STANDARD TABLE OF x_data INITIAL SIZE 0,
Internal table for storing field catalog information
i_fieldcat TYPE slis_t_fieldcat_alv,
Internal table for Top of Page info. in ALV Display
i_alv_top_of_page TYPE slis_t_listheader,
Internal table for ALV Display events
i_events TYPE slis_t_event,
Internal table for storing ALV sort information
i_sort TYPE slis_t_sortinfo_alv,
i_event TYPE slis_t_event.
*& Work area declaration
DATA:
wa_ekko TYPE x_data,
wa_layout TYPE slis_layout_alv,
wa_events TYPE slis_alv_event,
wa_sort TYPE slis_sortinfo_alv.
*& Constant declaration
CONSTANTS:
c_header TYPE char1
VALUE 'H', "Header in ALV
c_item TYPE char1
VALUE 'S'.
*& Start-of-selection event
START-OF-SELECTION.
Select data from ekpo
SELECT ebeln " Doc no
ebelp " Item
matnr " Material
matnr " Material
werks " Plant
werks " Plant
ntgew " Quantity
gewei " Unit
FROM ekpo
INTO TABLE i_ekpo
WHERE ebeln IN s_ebeln
AND ntgew NE '0.00'. IF sy-subrc = 0.
SORT i_ekpo BY ebeln ebelp matnr .
ENDIF.
To build the Page header
PERFORM sub_build_header. "* To prepare field catalog
PERFORM sub_field_catalog. "* Perform to populate the layout structure
PERFORM sub_populate_layout."* Perform to populate the sort table.
PERFORM sub_populate_sort."* Perform to populate ALV event
PERFORM sub_get_event.
END-OF-SELECTION.
Perform to display ALV report
PERFORM sub_alv_report_display.
*& Form sub_build_header
To build the header
No Parameter
FORM sub_build_header .
Local data declaration
DATA: l_system TYPE char10 , "System id
l_r_line TYPE slis_listheader, "Hold list header
l_date TYPE char10, "Date
l_time TYPE char10, "Time
l_success_records TYPE i, "No of success records
l_title(300) TYPE c. " Title
Title Display
l_r_line-typ = c_header. " header
l_title = 'Test report'(001).
l_r_line-info = l_title.
APPEND l_r_line TO i_alv_top_of_page.
CLEAR l_r_line.
Run date Display
CLEAR l_date.
l_r_line-typ = c_item. " Item
WRITE: sy-datum TO l_date MM/DD/YYYY.
l_r_line-key = 'Run Date :'(002).
l_r_line-info = l_date.
APPEND l_r_line TO i_alv_top_of_page.
CLEAR: l_r_line,
l_date.ENDFORM. " sub_build_header
*& Form sub_field_catalog
Build Field Catalog
No Parameter
FORM sub_field_catalog .
Build Field Catalog
PERFORM sub_fill_alv_field_catalog USING: '01' '01' 'EBELN'
'I_EKPO' 'L'
'Doc No'(003) ' ' ' ' ' ' ' ', '01' '02' 'EBELP' 'I_EKPO' 'L'
'Item No'(004) 'X' 'X' ' ' ' ', '01' '03' 'MATNR' 'I_EKPO' 'L'
'Material No'(005) 'X' 'X' ' ' ' ', '01' '03' 'MATNR1' 'I_EKPO'
'L'
'Material No'(005) ' ' ' ' ' ' ' ',
'01' '04' 'WERKS' 'I_EKPO' 'L'
'Plant'(006) 'X' 'X' ' ' ' ', '01' '04' 'WERKS1' 'I_EKPO' 'L'
'Plant'(006) ' ' ' ' ' ' ' ', '01' '05' 'NTGEW' 'I_EKPO' 'R'
'Net Weight'(007) ' ' ' ' 'GEWE' 'I_EKPO'.ENDFORM.
" sub_field_catalog*&----
*& Form sub_fill_alv_field_catalog
*& For building Field Catalog
*& p_rowpos Row position
*& p_colpos Col position
*& p_fldnam Fldname
*& p_tabnam Tabname
*& p_justif Justification
*& p_seltext Seltext
*& p_out no out
*& p_tech Technical field
*& p_qfield Quantity field
*& p_qtab Quantity table
FORM sub_fill_alv_field_catalog USING p_rowpos TYPE sycurow
p_colpos TYPE sycucol
p_fldnam TYPE fieldname
p_tabnam TYPE tabname
p_justif TYPE char1
p_seltext TYPE dd03p-scrtext_l
p_out TYPE char1
p_tech TYPE char1
p_qfield TYPE slis_fieldname
p_qtab TYPE slis_tabname.
Local declaration for field
catalog
DATA: wa_lfl_fcat TYPE slis_fieldcat_alv.
wa_lfl_fcat-row_pos = p_rowpos. "Row
wa_lfl_fcat-col_pos = p_colpos. "Column
wa_lfl_fcat-fieldname = p_fldnam. "Field Name
wa_lfl_fcat-tabname = p_tabnam. "Internal Table Name
wa_lfl_fcat-just = p_justif. "Screen Justified
wa_lfl_fcat-seltext_l = p_seltext. "Field Text
wa_lfl_fcat-no_out = p_out. "No output
wa_lfl_fcat-tech = p_tech. "Technical field
wa_lfl_fcat-qfieldname = p_qfield. "Quantity unit
wa_lfl_fcat-qtabname = p_qtab .
"Quantity table
IF p_fldnam = 'NTGEW'.
wa_lfl_fcat-do_sum = 'X'.
ENDIF.
APPEND wa_lfl_fcat TO i_fieldcat.
CLEAR wa_lfl_fcat.
ENDFORM.
" sub_fill_alv_field_catalog*&----
*& Form sub_populate_layout
Populate ALV layout
No Parameter
FORM sub_populate_layout . CLEAR wa_layout.
wa_layout-colwidth_optimize = 'X'.
" Optimization of Col width
ENDFORM. " sub_populate_layout*&----
*& Form sub_populate_sort
Populate ALV sort table
No Parameter
FORM sub_populate_sort .
Sort on material
wa_sort-spos = '01' .
wa_sort-fieldname = 'MATNR'.
wa_sort-tabname = 'I_EKPO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort .
CLEAR wa_sort.
Sort on plant
wa_sort-spos = '02'.
wa_sort-fieldname = 'WERKS'.
wa_sort-tabname = 'I_EKPO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort .
CLEAR wa_sort.
ENDFORM.
" sub_populate_sort*&----
*& Form sub_get_event
Get ALV grid event and pass the form name to subtotal_text
event
No Parameter
FORM sub_get_event .
CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE
'SUBTOTAL_TEXT'. DATA: l_s_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 4
IMPORTING
et_events = i_event
EXCEPTIONS
list_type_wrong = 0
OTHERS = 0.
Subtotal
READ TABLE i_event INTO l_s_event
WITH KEY name = slis_ev_subtotal_text.
IF sy-subrc = 0.
MOVE c_formname_subtotal_text TO l_s_event-form.
MODIFY i_event FROM l_s_event INDEX sy-tabix.
ENDIF.ENDFORM.
" sub_get_event*&----
*& Form sub_alv_report_display
For ALV Report Display
No Parameter
FORM sub_alv_report_display .
DATA: l_repid TYPE syrepid .
l_repid = sy-repid .
This function module for displaying the ALV
report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
i_callback_top_of_page = 'SUB_ALV_TOP_OF_PAGE'
is_layout = wa_layout
it_fieldcat = i_fieldcat
it_sort = i_sort
it_events = i_event
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = i_ekpo
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc 0.
MESSAGE i000 WITH 'Error in ALV report display'(055).
ENDIF.
ENDFORM.
" sub_alv_report_display*&----
FORM sub_alv_top_of_page
Call ALV top of page
No parameter
FORM sub_alv_top_of_page. "#EC CALLED*
*To write header for the ALV
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_alv_top_of_page.
ENDFORM.
"alv_top_of_page*&----
*& Form subtotal_text
Build subtotal text
P_total Total
p_subtot_text Subtotal text info
FORM subtotal_text CHANGING
p_total TYPE any
p_subtot_text TYPE slis_subtot_text.
Material level sub total
IF p_subtot_text-criteria = 'MATNR'.
p_subtot_text-display_text_for_subtotal
= 'Material level total'(009).
ENDIF.
Plant level sub total
IF p_subtot_text-criteria = 'WERKS'.
p_subtot_text-display_text_for_subtotal = 'Plant level total'(010).
ENDIF.
ENDFORM. "subtotal_textSelection screen:

Similar Messages

  • Field in Alv Top-of-page

    How to pass field in Alv Top-of-page
    Edited by: Deepak  Mathrani on Aug 12, 2008 12:40 PM
    <THREAD LOCKED. Please read the [Rules of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement] to discover why>
    Edited by: Mike Pokraka on Aug 12, 2008 2:58 PM

    Hi
    sample program
    *& Report  ZNNR_ALVSAMPLE
    REPORT  znnr_alvsample NO STANDARD PAGE HEADING.
    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.
    *Start-of-selection.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      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'.        "Display column total
      fieldcatalog-datatype     = 'CURR'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      fieldcatalog-EDIT = 'X'.
      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'(001)  "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_XEVENTS
                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.

  • How To Print Field Value in TOP-OF-PAGE During Line Selection.

    How To Print Field Value in TOP-OF-PAGE During Line Selection when double click on field.

    (If my memory serves me well (not used for long time ago)
    Assign values to system fields sy-tvar0 - sy-tvar9, they will replace the placeholders "&0" through "&9" in the list headers and column headers.
    TOP-OF-PAGE DURING LINE-SELECTION.
         WRITE: / 'Interactive Report &3'.
      WRITE record-vbeln TO sy-tvar3.
    Regards,
    Raymond

  • Top Of Page not triggering in ALV

    Hi
    I am using ALV List Disaply. I have a itab that has 2000 Rows. When i scoll down, the header appears at the top always. Now i added the following code to trigger a Top of Page Event.
    FORM xevents.
      CLEAR xs_event.
      xs_event-name = slis_ev_top_of_page.
      xs_event-form = 'XTOP_OF_PAGE'.
      APPEND xs_event TO gt_xevents.
      CLEAR xs_event.
    ENDFORM.
    FORM xtop_of_page.
    BREAK-POINT.
      WRITE: / 'X_TOP_OF_PAGE'.
    ENDFORM.
      CALL FUNCTION 'REUSE_ALV_LIST_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_STRUCTURE_NAME               =
         is_layout                      = st_layout
         it_fieldcat                    = fieldcat[]
        IT_EXCLUDING                   =
        IT_SPECIAL_GROUPS              =
        IT_SORT                        =
         it_filter                      = filttab[]
        IS_SEL_HIDE                    =
        I_DEFAULT                      = 'X'
        I_SAVE                         = ' '
        IS_VARIANT                     =
          it_events                      = gt_xevents
        IT_EVENT_EXIT                  =
        IS_PRINT                       =
        IS_REPREP_ID                   =
        I_SCREEN_START_COLUMN          = 0
        I_SCREEN_START_LINE            = 0
        I_SCREEN_END_COLUMN            = 0
        I_SCREEN_END_LINE              = 0
      IMPORTING
        E_EXIT_CAUSED_BY_CALLER        =
        ES_EXIT_CAUSED_BY_USER         =
        TABLES
          t_outtab                       = alv_tab[]
      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.

    this  may  be help u ....
    t_gt_events type slis_t_event,
    form display_alv.
      v_repid = sy-repid.
      sort vit_final by flag vbeln .
    perform get_top_of_page using t_gt_events[].
          gs_keyinfo-header01 = 'DISPO'.
          gs_keyinfo-item01 = 'DISPO'.
      call function 'REUSE_ALV_LIST_DISPLAY'
        exporting
            I_INTERFACE_CHECK        = ' '
             i_callback_program        = v_repid
            I_CALLBACK_PF_STATUS_SET = ' '
            I_CALLBACK_USER_COMMAND  = ' '
            I_STRUCTURE_NAME         =
             is_layout                = vfl_layout
             it_fieldcat               = vit_fieldcat
            IT_EXCLUDING             =
              it_special_groups       =
             it_sort                  = vit_sort
            IT_FILTER                =
            IS_SEL_HIDE              =
            I_DEFAULT                = 'X'
            I_SAVE                   = ' '
            IS_VARIANT               = ' '
             IT_EVENTS                = t_gt_events[]
            IT_EVENT_EXIT            =
            IS_PRINT                 =
            IS_REPREP_ID             =
            I_SCREEN_START_COLUMN    = 0
            I_SCREEN_START_LINE      = 0
            I_SCREEN_END_COLUMN      = 0
            I_SCREEN_END_LINE        = 0
            I_BYPASSING_BUFFER       =
            I_BUFFER_ACTIVE          =
       IMPORTING
        tables
                t_outtab               = vit_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
    *&      Form  get_top_of_page
          text
    -->  p1        text
    <--  p2        text
    form get_top_of_page using t_gt_events type slis_t_event.
    data: ls_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
           exporting
                i_list_type = 0
           importing
                et_events   = t_gt_events.
      read table t_gt_events with key name = slis_ev_top_of_page
                               into ls_event.
      move c_formtop  to ls_event-form.
      append ls_event to t_gt_events.
    endform.                    " get_top_of_page

  • Top of page system fields

    How to use Top of page system fields like sy-tvar0 to sy-tvar1
    thanks in advance
    Rishi

    Hello ,
    in the standard title you can have &0 ... &n. The program must put the values to fields SY-TVAR0 to SY-TVARN.
    see this sample:
    Pass the variables for the list heading
    MOVE SY-Title TO SY-TVAR0.
    MOVE SY-Datum TO SY-TVAR1.
    MOVE SY-Pagno TO SY-TVAR2.
    From output screen: System>List>List Header
    Click on first white line and enter the following title to the yellow box: Title: &0…………… Date: &1………. Page No: &2......
    Hope its what you mean.
    Vasanth

  • Display data on top of page and sort issue. Pls help

    Hi guys,
    I need some help. I can't seem to get the code to work. Below is my code to display the ALV. It works fine but I want it to print some top of page details according to the SORT (grouping) but the sort isn't even working?
    http://i987.photobucket.com/albums/ae354/runningandrew/2010/Other_Random/Screenshot1.jpg
    HEre is screenshot of the output
    Sales Order Number : 1100001541      
    Purchase Order Number : 4500352015   
    Distributor Number : 20061            <====
    Ship To Name : ALPHA EZZ EL ARAB CO.,
    Order Date : 29.04.2010              
    Delivery Date : 29.04.2010           
    There should be another one printing  but its not.
    Sales Order Number : 1100001542       <=====
    Purchase Order Number : 4500352015   
    Distributor Number : 20063            <=====
    Ship To Name : ALPHA EZZ EL ARAB CO.,
    Order Date : 29.04.2010              
    Delivery Date : 29.04.2010           
    My it_report structure is
    BEGIN OF t_report,
             ebeln      TYPE bapivbeln-vbeln,
             purch_no   TYPE bstnk,
             kunnr      TYPE kunnr,
             wename1    TYPE name1_gp,
             order_date TYPE edatu_vbak,
             vdate      TYPE vbak-vdatu,
             matnr      TYPE matnr,
             matnr_txt  TYPE arktx,
             qty        TYPE kwmeng,
           END OF t_report.
    Here are the sort fields
    PERFORM add_sort_key USING: 'EBELN'      'X'    'X',
                                  'PURCH_NO'   'X'    'X',
                                  'KUNNR'      'X'    'X'.
    FORM add_sort_key  USING  pv_field    TYPE any
                              pv_ascen    TYPE any
                              pv_group    TYPE any.
      it_alv_sort-fieldname = pv_field.
      it_alv_sort-up        = pv_ascen.
      it_alv_sort-group     = pv_group.
      APPEND it_alv_sort.
      CLEAR it_alv_sort.
      it_sort_new-fieldname = pv_field.
      APPEND it_sort_new.
      CLEAR it_sort_new.
    ENDFORM.                    " ADD_SORT_KEY
    Here is my display ALV part
    v_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
        EXPORTING
          i_callback_program = v_repid.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
          EXPORTING
            is_layout                  = l_alv_layout
            it_fieldcat                = it_alv_fieldcat[]
            i_tabname                  = c_it_report
            it_events                  = it_alv_events[]
            it_sort                    = it_sort_new[]
          TABLES
            t_outtab                   = it_report
    Edited by: Slow ABAPer on Apr 29, 2010 5:43 AM

    Hi,
    You should always put the code in the tags as :
    for it to be displayed as proper code.
    With Regards,
    Samreen.

  • 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>

  • 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.

  • Alv-top-of-page

    Hi all,
    In my alv report,when Iam executing top of page is shown only once,but when Iam checking print preview it being dispalyed twice,when Iam comming back to normal view it is shown 4 times.
    why Iam getting this type of error.can any one tell me what may be wrong.
    regards.

    hi,
    think you are not refreshing the data
    try to clear all the work areas and refresh all internal tables
    shiva

  • Alv top of page date chopped

    Hi Experts,
                 In my Alv report top-of-page, i have a date . with name "Open Items As key Date" but i cant see
    full text and if the date is 11.07.2008. its showing 11.07.20. so how to do this.
    Correct answers will be fully rewarded.
    Regards
    Sunita.

    Hi,
    data : lv_bldat(10) type c.
    write p_bldat to lv_bldat.
    pass  lv_bldat inside of p_bldat.
    What about this thread
    ALV Top-Of -Page Display  No respose for this.
    If u got the solution close the THREAD.
    Thanks,
    Durai.V
    Edited by: Durai V on Jul 11, 2008 12:04 PM

  • ALV Top of Page is not displaying

    Hi,
    in this program TOP OF PAGE is displaying as empty
    * Tables
    TABLES:/irm/ipsipart.
    * Type pools
    TYPE-POOLS slis.
    * Types
    TYPES:BEGIN OF typ_ipsipart,
          depcode  TYPE /irm/ip_depcode,
          partid   TYPE /irm/ip_ktonr,
          endda    TYPE /irm/ip_pedat,
          begda    TYPE /irm/ip_pbdat,
          END OF typ_ipsipart.
    TYPES:BEGIN OF typ_pa0000,
          pernr    TYPE persno,
          endda    TYPE endda,
          begda    TYPE begda,
          massn    TYPE massn,
          massg    TYPE massg,
          stat2    TYPE stat2,
          partid   TYPE /irm/ip_ktonr,
          END OF typ_pa0000.
    TYPES:BEGIN OF typ_pa0001,
          pernr    TYPE persno,
          endda    TYPE endda,
          ename    TYPE ename,
          END OF typ_pa0001.
    TYPES:BEGIN OF typ_pernr,
          pernr    TYPE persno,
          END OF typ_pernr.
    TYPES:BEGIN OF typ_a942,
          zzpersnr TYPE persno,
          END OF typ_a942.
    TYPES:BEGIN OF typ_a943,
          zzpersnr TYPE persno,
          END OF typ_a943.
    TYPES:BEGIN OF typ_a976,
          zzpersnr TYPE persno,
          END OF typ_a976.
    TYPES:BEGIN OF typ_final,
          pernr    TYPE persno,
          ename    TYPE ename,
          begda    TYPE begda,
          statx(9) TYPE c,
          mgtxt    TYPE mgtxt,
          depcode  TYPE /irm/ip_depcode,
          begda_c  TYPE /irm/ip_pbdat,
          endda_c  TYPE /irm/ip_pedat,
          END OF typ_final.
    TYPES:BEGIN OF typ_t530t,
          massn    TYPE massn,
          massg    TYPE massg,
          mgtxt    TYPE mgtxt,
          END OF typ_t530t.
    * Internal Tables
    DATA:it_a942     TYPE TABLE OF typ_a942,
         it_a943     TYPE TABLE OF typ_a943,
         it_a976     TYPE TABLE OF typ_a976,
         it_pernr    TYPE TABLE OF typ_pernr,
         it_pa0000   TYPE TABLE OF typ_pa0000,
         it_pa0001   TYPE TABLE OF typ_pa0001,
         it_ipsipart TYPE TABLE OF typ_ipsipart,
         it_final    TYPE TABLE OF typ_final,
         it_t530t    TYPE TABLE OF typ_t530t.
    * Work areas
    DATA:wa_a942     TYPE typ_a942,
         wa_a943     TYPE typ_a943,
         wa_a976     TYPE typ_a976,
         wa_pernr    TYPE typ_pernr,
         wa_pa0000   TYPE typ_pa0000,
         wa_pa0001   TYPE typ_pa0001,
         wa_ipsipart TYPE typ_ipsipart,
         wa_final    TYPE typ_final,
         wa_t530t    TYPE typ_t530t.
    * Constants
    CONSTANTS:c_stat2 TYPE stat2 VALUE '0',
              c_statx(9) TYPE c  VALUE 'Withdrawn',
              c_endda TYPE endda VALUE '99991231',
              c_ptype TYPE /irm/ip_patype VALUE 'PE',
              c_kappl TYPE kappl VALUE 'V',
              c_ysam  TYPE kschl VALUE 'YSAM',
              c_ysdm  TYPE kschl VALUE 'YSDM',
              c_yssm  TYPE kschl VALUE 'YSSM',
              c_ysse  TYPE kschl VALUE 'YSSE',
              c_sprsl TYPE spras VALUE 'E'.
    * Variables
    DATA:v_begda TYPE begda,
         v_endda TYPE endda.
    DATA:v_variant   LIKE disvariant,
         v_save(1)   TYPE c,
         v_repid TYPE sy-repid.
    * ALV Declaraion Part
    * FIELD CATALOG DECLARATION                                        *****
    DATA:it_fcat TYPE slis_t_fieldcat_alv,
         wa_fcat TYPE slis_fieldcat_alv.
    * ALV SORT INFORMATION                                             *****
    DATA:wa_sort TYPE slis_sortinfo_alv,
         it_sort TYPE slis_t_sortinfo_alv.
    *ALV LAYOUT INFORMATION                                            *****
    DATA:wa_layout TYPE slis_layout_alv.
    *ALV TOOLBAR EXCLUDING                                             *****
    DATA:it_excluding TYPE slis_t_extab,
         wa_excluding TYPE slis_extab.
    * Selection Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:s_pernr  FOR /irm/ipsipart-partid,
                   s_date   FOR /irm/ipsipart-begda OBLIGATORY NO-EXTENSION,
                   s_depcod FOR /irm/ipsipart-depcode.
    SELECTION-SCREEN END OF BLOCK b1.
    * At Selection Screen
    AT SELECTION-SCREEN.
      IF NOT s_date-low IS INITIAL AND s_date-high IS NOT INITIAL.
        READ TABLE s_date INDEX 1.
        v_begda = s_date-low.
        v_endda = s_date-high.
      ENDIF.
      IF s_date-low IS INITIAL AND s_date-high IS NOT INITIAL.
        READ TABLE s_date INDEX 1.
        v_begda = s_date-high.
        v_endda = s_date-high.
      ENDIF.
      IF s_date-low IS NOT INITIAL AND s_date-high IS INITIAL.
        READ TABLE s_date INDEX 1.
        v_begda = s_date-low.
        v_endda = s_date-low.
      ENDIF.
    * Start of selection
    START-OF-SELECTION.
      break vkreddy1x.
      PERFORM get_data.
      PERFORM move_data_to_finalitab.
      IF NOT it_final[] IS INITIAL.
        PERFORM field_catalog TABLES it_final
                              USING it_fcat[]
                                    wa_fcat.
        PERFORM alv_sort_info USING it_sort[]
                                    wa_sort.
        PERFORM alv_layout_build USING wa_layout.
        PERFORM alv_toolbar_excluding USING it_excluding[]
                                            wa_excluding.
        PERFORM load-variant     USING v_variant v_repid v_save.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program     = v_repid
            i_callback_top_of_page = 'TOP_OF_PAGE'
            is_layout              = wa_layout
            it_fieldcat            = it_fcat
            it_excluding           = it_excluding
            it_sort                = it_sort
            i_save                 = v_save
            is_variant             = v_variant
          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.
      ELSE.
        PERFORM info_msg.
      ENDIF.
    *&      Form  GET_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM get_data .
      SELECT zzpersnr FROM a942 INTO TABLE it_a942 WHERE kappl  = c_kappl
                                                   AND   kschl  = c_ysdm
                                                   AND   datbi >= v_begda
                                                   AND   datab <= v_endda.
      IF sy-subrc EQ 0.
        SORT it_a942 BY zzpersnr.
        DELETE ADJACENT DUPLICATES FROM it_a942 COMPARING zzpersnr.
        LOOP AT it_a942 INTO wa_a942.
          MOVE wa_a942-zzpersnr TO wa_pernr-pernr.
          APPEND wa_pernr TO it_pernr.
          CLEAR:wa_pernr,wa_a942.
        ENDLOOP.
      ENDIF.
      SELECT zzpersnr FROM a943 INTO TABLE it_a943 WHERE kappl  = c_kappl
                                                   AND  ( kschl = c_ysam
                                                       OR kschl = c_ysse )
                                                   AND   datbi >= v_begda
                                                   AND   datab <= v_endda.
      IF sy-subrc EQ 0.
        SORT it_a943 BY zzpersnr.
        DELETE ADJACENT DUPLICATES FROM it_a943 COMPARING zzpersnr.
        LOOP AT it_a943 INTO wa_a943.
          MOVE wa_a943-zzpersnr TO wa_pernr-pernr.
          APPEND wa_pernr TO it_pernr.
          CLEAR:wa_pernr,wa_a943.
        ENDLOOP.
      ENDIF.
      SELECT zzpersnr FROM a976 INTO TABLE it_a976 WHERE kappl  = c_kappl
                                                   AND   kschl  = c_yssm
                                                   AND   datbi >= v_begda
                                                   AND   datab <= v_endda.
      IF sy-subrc EQ 0.
        SORT it_a976 BY zzpersnr.
        DELETE ADJACENT DUPLICATES FROM it_a976 COMPARING zzpersnr.
        LOOP AT it_a976 INTO wa_a976.
          MOVE wa_a976-zzpersnr TO wa_pernr-pernr.
          APPEND wa_pernr TO it_pernr.
          CLEAR:wa_pernr,wa_a976.
        ENDLOOP.
      ENDIF.
      SORT it_pernr BY pernr.
      DELETE ADJACENT DUPLICATES FROM it_pernr COMPARING pernr.
      IF NOT it_pernr[] IS INITIAL.
        SELECT pernr endda begda massn massg stat2 FROM pa0000
                                                   INTO TABLE it_pa0000
                                                   FOR ALL ENTRIES IN it_pernr
                                                   WHERE pernr = it_pernr-pernr
                                                   AND endda >= v_begda
                                                   AND begda <= v_endda
                                                   AND stat2 = c_stat2.
      ENDIF.
      LOOP AT it_pa0000 INTO wa_pa0000.
        wa_pa0000-partid = wa_pa0000-pernr.
        MODIFY TABLE it_pa0000 FROM wa_pa0000 .
      ENDLOOP.
      IF NOT it_pa0000[] IS INITIAL.
        SELECT depcode partid endda begda FROM /irm/ipsipart
                                INTO CORRESPONDING FIELDS OF TABLE it_ipsipart
                                FOR ALL ENTRIES IN it_pa0000
                                WHERE nrart = c_ptype
                                           AND partid = it_pa0000-partid
                                           AND endda >= it_pa0000-begda
                                           AND begda <= it_pa0000-endda.
        SELECT pernr ename FROM pa0001 INTO TABLE it_pa0001
                                       FOR ALL ENTRIES IN it_pa0000
                                       WHERE pernr = it_pa0000-pernr
                                       AND endda   = c_endda.
        SELECT mgtxt FROM t530t INTO TABLE it_t530t
                                FOR ALL ENTRIES IN it_pa0000
                                WHERE sprsl = c_sprsl
                                AND massn = it_pa0000-massn
                                AND massg   = it_pa0000-massg.
      ENDIF.
    ENDFORM.                    " GET_DATA
    *&      Form  MOVE_DATA_TO_ITAB
    FORM move_data_to_finalitab .
      LOOP AT it_pa0000 INTO wa_pa0000.
        MOVE wa_pa0000-pernr TO wa_final-pernr.
        MOVE wa_pa0000-begda TO wa_final-begda.
        IF wa_pa0000-stat2 = c_stat2.
          MOVE c_statx TO wa_final-statx.
        ENDIF.
        READ TABLE it_pa0001 INTO wa_pa0001 WITH KEY pernr = wa_pa0000-pernr.
        IF sy-subrc EQ 0.
          MOVE wa_pa0001-ename TO wa_final-ename.
        ENDIF.
        READ TABLE it_t530t INTO wa_t530t WITH KEY massn = wa_pa0000-massn
                                                   massg = wa_pa0000-massg.
        IF sy-subrc EQ 0.
          MOVE wa_t530t-mgtxt TO wa_final-mgtxt.
        ENDIF.
        READ TABLE it_ipsipart INTO wa_ipsipart WITH KEY
                                                   partid = wa_pa0000-partid.
        IF sy-subrc EQ 0.
          MOVE wa_ipsipart-depcode TO wa_final-depcode.
          MOVE wa_ipsipart-begda TO wa_final-begda_c.
          MOVE wa_ipsipart-endda TO wa_final-endda_c.
        ENDIF.
        APPEND wa_ipsipart TO it_ipsipart.
        CLEAR wa_ipsipart.
      ENDLOOP.
    ENDFORM.                    " MOVE_DATA_TO_ITAB
    *&      Form  FIELD_CATALOG
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM field_catalog TABLES p_it_final  LIKE it_final
                       USING  p_it_fcat   TYPE slis_t_fieldcat_alv
                              p_wa_fcat   TYPE slis_fieldcat_alv.
      CLEAR p_wa_fcat.
      p_wa_fcat-col_pos   = '1'.
      p_wa_fcat-tabname   = p_it_final.
      p_wa_fcat-fieldname = 'PERNR'.
      p_wa_fcat-key       = 'X'.
      p_wa_fcat-seltext_l = 'Personnel Number'.
      p_wa_fcat-seltext_m = 'Personnel No.'.
      p_wa_fcat-seltext_s = 'Pers.No.'.
      APPEND p_wa_fcat TO p_it_fcat.
      CLEAR p_wa_fcat.
      p_wa_fcat-col_pos   = '2'.
      p_wa_fcat-tabname   = p_it_final.
      p_wa_fcat-fieldname = 'ENAME'.
      p_wa_fcat-key       = 'X'.
      p_wa_fcat-seltext_l = 'Employee Name'.
      p_wa_fcat-seltext_m = 'Emp Name'.
      p_wa_fcat-seltext_s = 'Name'.
      APPEND p_wa_fcat TO p_it_fcat.
      CLEAR p_wa_fcat.
      p_wa_fcat-col_pos   = '3'.
      p_wa_fcat-tabname   = p_it_final.
      p_wa_fcat-fieldname = 'BEGDA'.
      p_wa_fcat-key       = ' '.
      p_wa_fcat-seltext_l = 'Termination start date'.
      p_wa_fcat-seltext_m = 'Term start date'.
      p_wa_fcat-seltext_s = 'Term start date'.
      APPEND p_wa_fcat TO p_it_fcat.
      CLEAR p_wa_fcat.
      p_wa_fcat-col_pos   = '4'.
      p_wa_fcat-tabname   = p_it_final.
      p_wa_fcat-fieldname = 'MGTXT'.
      p_wa_fcat-seltext_l = 'Reason f.action text'.
      p_wa_fcat-seltext_m = 'Reason for action'.
      p_wa_fcat-seltext_s = 'Act.reason'.
      APPEND p_wa_fcat TO p_it_fcat.
      CLEAR p_wa_fcat.
      p_wa_fcat-col_pos   = '5'.
      p_wa_fcat-tabname   = p_it_final.
      p_wa_fcat-fieldname = 'STATX'.
      p_wa_fcat-seltext_l = 'Employment status text'.
      p_wa_fcat-seltext_m = 'Employment status'.
      p_wa_fcat-seltext_s = 'Employment status'.
      APPEND p_wa_fcat TO p_it_fcat.
      CLEAR p_wa_fcat.
      p_wa_fcat-col_pos   = '6'.
      p_wa_fcat-tabname   = p_it_final.
      p_wa_fcat-fieldname = 'DEPCODE'.
      p_wa_fcat-seltext_l = 'Deployment Code'.
      p_wa_fcat-seltext_m = 'Deployment Code'.
      p_wa_fcat-seltext_s = 'Dep. Code'.
      APPEND p_wa_fcat TO p_it_fcat.
      CLEAR p_wa_fcat.
      p_wa_fcat-col_pos   = '7'.
      p_wa_fcat-tabname   = p_it_final.
      p_wa_fcat-fieldname = 'BEGDA_C'.
      p_wa_fcat-seltext_l = 'Participation Start Date'.
      p_wa_fcat-seltext_m = 'Participation Start'.
      p_wa_fcat-seltext_s = 'Start Date'.
      APPEND p_wa_fcat TO p_it_fcat.
      CLEAR p_wa_fcat.
      p_wa_fcat-col_pos   = '8'.
      p_wa_fcat-tabname   = p_it_final.
      p_wa_fcat-fieldname = 'ENDDA_C'.
      p_wa_fcat-seltext_l = 'Participation End Date'.
      p_wa_fcat-seltext_m = 'Participation End'.
      p_wa_fcat-seltext_s = 'End Date'.
      APPEND p_wa_fcat TO p_it_fcat.
    ENDFORM.                    " FIELD_CATALOG
    *&      Form  ALV_SORT_INFO
    *       text
    *      -->P_IT_SORT[]  text
    *      -->P_WA_SORT  text
    FORM alv_sort_info  USING   p_it_sort TYPE slis_t_sortinfo_alv
                                p_wa_sort TYPE slis_sortinfo_alv .
      p_wa_sort-fieldname = 'PERNR'.
      p_wa_sort-up = 'X'.
      APPEND p_wa_sort TO p_it_sort.
    ENDFORM.                    " ALV_SORT_INFO
    *&      Form  ALV_LAYOUT_BUILD
    FORM alv_layout_build  CHANGING p_wa_layout TYPE slis_layout_alv.
      p_wa_layout-no_input          = 'X'.
      p_wa_layout-colwidth_optimize = 'X'.
    ENDFORM.                    " ALV_LAYOUT_BUILD
    *&      Form  ALV_TOOLBAR_EXCLUDING
    *       text
    FORM alv_toolbar_excluding  USING   p_it_excluding TYPE slis_t_extab
                                        p_wa_excluding TYPE slis_extab.
      p_wa_excluding-fcode = '&GRAPH'.
      APPEND p_wa_excluding TO p_it_excluding.
      p_wa_excluding-fcode = '&ABC'.
      APPEND p_wa_excluding TO p_it_excluding.
      p_wa_excluding-fcode = '%SL'.
      APPEND p_wa_excluding TO p_it_excluding.
    ENDFORM.                    " ALV_TOOLBAR_EXCLUDING
    *&      Form  LOAD-VARIANT
    FORM load-variant  USING    p_v_variant STRUCTURE disvariant
                                p_v_repid
                                p_v_save.
      CLEAR p_v_variant.
      p_v_variant-report = p_v_repid.
      p_v_save = 'A'.
    ENDFORM.                    " LOAD-VARIANT
    *&      Form  info_msg
    *       text
    FORM info_msg .
      MESSAGE i016(rp) WITH 'No Data Selected for the Selection Criteria'.
    ENDFORM.                    "info_msg
    *&      Form  top_of_page
    *       text
    FORM top_of_page.
      DATA:it_listhead TYPE slis_t_listheader.
      DATA:wa_listhead TYPE slis_listheader.
      wa_listhead-typ = 'H'.
      wa_listhead-info = 'Withdrawn Employees Still Active on Commission Plan'.
      APPEND wa_listhead TO it_listhead.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = it_listhead.
    ENDFORM.                    "top_of_page

    Hello,
    You try in this way you will get the solution
    data:
        y_i_events     TYPE STANDARD TABLE OF slis_alv_event,
    constants:
    y_k_top_of_page TYPE slis_alv_event-name VALUE 'TOP_OF_PAGE',
    y_k_top_of_form TYPE slis_alv_event-form VALUE 'Y_F_TOP_OF_FORM'.
        PERFORM y_f_build_events CHANGING  y_i_events.
    FORM y_f_build_events  CHANGING y_li_events TYPE STANDARD TABLE.
      DATA :  y_lwa_events   TYPE slis_alv_event.
      y_lwa_events-name = y_k_top_of_page.
      y_lwa_events-form = y_k_top_of_form.
      APPEND y_lwa_events TO y_li_events.
      CLEAR y_lwa_events.
    ENDFORM.                    " y_f_BUILD_EVENTS
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = y_lv_progname
          is_layout          = y_wa_layout
          it_fieldcat        = y_i_fieldcat[]
          it_events          = y_i_events
        TABLES
          t_outtab           = y_i_error
        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 y_f_top_of_form .
    *To display the date in dd mm yyyy formate
      CLEAR y_v_date.
      MOVE: sy-datum TO y_v_date.
      y_wa_header-typ = y_k_h.
      CONCATENATE text-h01 y_v_date+6(2)
                           y_v_date+4(2)
                           y_v_date+0(4)
                           INTO y_wa_header-info
                           SEPARATED BY space.
      APPEND y_wa_header TO y_i_listheader.
      CLEAR y_wa_header.
    *Top of page
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = y_i_listheader[].
      REFRESH y_i_listheader[].
    ENDFORM.                    " y_f_top_of_form
    Try this you we get the top-of-page.

  • ALV top of page - heading depending upon list output

    Hi All,
    My alv grid report shows the report containing vendor account group and some other details.
    My requirement is to get the page break for every new vendor account group and also print the vendor account group description at the top of the list (in header section).
    I have achieved this by using * in sort table for page break and in top of page , I am reading the vendor acct grp desc table to print the header based on index sy-pagno.
    But this solution is only working in print preview mode. If I print the output, actual page breaks are getting applied and I am not getting the desired output as logic using sy-pagno is giving wrong output.
    My question is is there any way to get the current list in the top of page event? So that depending upon the displayed vendor acct grp per page, I will print its description?
    OR is there any other way to achieve this functionality?

    Any suggestions?

  • ALV - Top of Page Trigger for Each New Page

    Hi Abapers,
    I am using the sortinfo_alv to get page break for each customer.Now my client is asking to display the cutomer name in the top of page insted in the main table. how will i do this .
    I am using alv_commentary_write to display the top of page data.
    Awaiting for reply.
    Regards,
    Rahul

    Hi
    Follow the below steps.
    Include the two forms in your program
    Pass event internal table parameter to FM ALV display.
    Declare the ALV parameter in Declaration part.
    DATA: i_events TYPE slis_t_event.            "(IT) for populating events
               g_header TYPE slis_t_listheader,  "Header for alv
           g_events TYPE slis_alv_event,     "Struc for populating events
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         it_events                         = i_events
    *&      Form  EVENTTAB_BUILD
    *    Building Events table For ALV
    *      -->P_T_EVENTS[]  text
    FORM eventtab_build USING p_i_events.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                i_list_type     = 0
           IMPORTING
                et_events       = i_events
           EXCEPTIONS
                list_type_wrong = 1
                OTHERS          = 2.
      CLEAR: g_events.
      READ TABLE i_events INTO g_events
           WITH KEY name = 'TOP_OF_PAGE'. "slis_ev_top_of_page.
      IF sy-subrc = 0.
        MOVE 'TOP_OF_PAGE' TO g_events-form.
        MODIFY i_events FROM g_events INDEX sy-tabix TRANSPORTING form.
        CLEAR g_events.
      ENDIF.
    ENDFORM.                    " EVENTTAB_BUILD
    *&      Form  top_of_page
    *    Header Data Population
    FORM top_of_page.
      DATA: l_htext TYPE slis_listheader,
            l_text(200) TYPE c,
            ld_lines TYPE i,
            ld_linesc(9) TYPE c.
      REFRESH g_header.
    ****************TOP OF PAGE HEADINGS****************************
    * For Headers, Key is not printed and is irrelevant. Will not cause
    * a syntax error, but is not used.
    * TYP:  Indicator: Header
      l_htext-typ = 'H'.     "H = Header,S = selection,a = action
      CONCATENATE 'Planned Order: -' s_plnum-low 'To' s_plnum-high
      INTO l_text SEPARATED BY space.
    * INFO: Information
      l_htext-info = l_text.
      APPEND l_htext TO g_header.
    * FM for dispalying text at Top of Page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                it_list_commentary = g_header
                i_logo =
                   'ENJOYSAP_LOGO'. " From transaction "OAOR"
    *     I_END_OF_LIST_GRID       =
    ENDFORM.                    "TOP_OF_PAGE

  • ALV top-of-page remove scroll bar

    Hi!
    In my ALV i have a header with some information and a logo. With the logo it creates a vertical scroll bar. I can't reduce the size of the logo because it as to be that size.
    So...i've been searching for some way to remove the scroll bar from the header, butt i didn't found anything that could help me.
    I'm using 'REUSE_ALV_GRID_DISPLAY' with i_callback_top_of_page   = 'TOP-OF-PAGE'. And in form top-of-page i use
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = t_header
          i_logo             = 'LOGO'.
    to call the logo.
    Is there a way to remove or set the header to a fix size?
    Thanks in advance,
       RT

    Hi!
    In my ALV i have a header with some information and a logo. With the logo it creates a vertical scroll bar. I can't reduce the size of the logo because it as to be that size.
    So...i've been searching for some way to remove the scroll bar from the header, butt i didn't found anything that could help me.
    I'm using 'REUSE_ALV_GRID_DISPLAY' with i_callback_top_of_page   = 'TOP-OF-PAGE'. And in form top-of-page i use
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = t_header
          i_logo             = 'LOGO'.
    to call the logo.
    Is there a way to remove or set the header to a fix size?
    Thanks in advance,
       RT

  • ALV TOP-OF-PAGE not popping up

    Hi I am working on ALV and I am trying to use Top-of-page functionality but somehow it's not popping up when I am trying to execute my report and just empty space is showing at the top of report. Following is my code:
    perform data.
    perform build_field_catalog.
    perform top_of_page.
    perform display_alv.
    FORM TOP_OF_PAGE .
      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.
    Report Heading
      wa_header-typ  = 'H'.
      wa_header-info = 'TEST 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.
    Time
      wa_header-typ  = 'S'.
      wa_header-key = 'Time: '.
      CONCATENATE  sy-uzeit(2) ':'
                   sy-uzeit+2(2) ':'
                   sy-uzeit+4(2) INTO wa_header-info.   "System time
      append wa_header to t_header.
      clear: wa_header.
    Total No. of Records Selected
      describe table it_output 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.
    FORM DISPLAY_ALV_REPORT .
    call function 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program     = gd_repid
          i_callback_top_of_page = 'TOP-OF-PAGE'
          is_layout              = gd_layout
          it_fieldcat            = fieldcatalog[]
          i_save                 = 'A'
        TABLES
          t_outtab               = it_output
        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
    thanks,
    Rajeev
    ENDFORM.                    " TOP_OF_PAGE

    hi check this example..
    REPORT ZTUFI091 .
    *& 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-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.
    regards,
    venkat

  • ALV top of page error

    Hi All,
    I have the same issue as mentioned in the thread
    ALV - Top of Page Error
    Please let me know the solution
    Thanks
    Bala Duvvuri
    Moderator message: please describe the problem in your own thread, do not have people clicking on links first.
    Edited by: Thomas Zloch on Mar 22, 2011 9:59 AM

    Solved by self

Maybe you are looking for

  • Can I use the same recovery discs to restore Windows on multiple same model laptops?

    Sir me & my brother have HP dv6 pavilion 3210us same model with preinstalled win7 Home Premium unfortunately my brothers laptop HDD change in to dynamic we can't boot to original system restore.But i have recovery media dvd seperate for my laptop can

  • Missing the filter function in the new version of Spotify? Come over here.

    Hi folks, Many of you have requested we re-add an option to filter from artist, album and playlist pages in Spotify. We're considering this feature for newer versions of the application but we're investigating the best solution. Therefore, we have a

  • Style Drawer "Sticks"

    When I choose to start a new document from a template, the new document appears to zoom toward me from the Template Chooser. But the style drawer seems to appear at the bottom of my screen just behind the Pages icon on the dock and grow to full size

  • Is there a way to import a cd into itunes library unchecked by default?

    I'm in the process of importing all of my cd's into itunes library, but I want the tunes unchecked in the library so they won't automatically update into my ipod. Right now I've got itunes set up to automatically import a cd I insert and then eject o

  • [calendario] XML Juan Muro

    Hola Juan ante todo felicitarte por las mejoras del calendario... Comentar sin embargo que he detectado el siguiente problema: Si pongo multiline y en el xml pongo de <br> parece ser ke se emborracha pues desaparecen la mayoría de días de contenido y