Adding header to ALV

Hi Friends
I need to add header to ALV grid, pls tell me how to do it.
Thanx in advance,
Regards,
Venu.

*& Report  Y_TOP_PAGE                                                  *
REPORT  y_top_page                              .
TABLES : mara.
TYPE-POOLS: slis.
DATA : w_repid LIKE sy-repid.
  w_repid = sy-repid.
DATA : BEGIN OF it_mara OCCURS 0,
       matnr LIKE mara-matnr,
       END OF it_mara.
*layout
DATA: wa_layout           TYPE SLIS_LAYOUT_ALV.
*field catalog
DATA: it_fieldcat_wrt_off TYPE slis_t_fieldcat_alv,
      wa_fieldcat_wrt_off TYPE slis_fieldcat_alv.
START-OF-SELECTION.
  SELECT matnr FROM mara INTO CORRESPONDING FIELDS OF TABLE it_mara.
END-OF-SELECTION.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
   EXPORTING
     i_program_name               = w_repid
   I_INTERNAL_TABNAME           = 'IT_MARA'
*     i_structure_name             = 'IT_MARA'
*   I_CLIENT_NEVER_DISPLAY       = 'X'
   I_INCLNAME                   = w_repid
*   I_BYPASSING_BUFFER           =
*   I_BUFFER_ACTIVE              =
    CHANGING
      ct_fieldcat                  = it_fieldcat_wrt_off[]
   EXCEPTIONS
     inconsistent_interface       = 1
     program_error                = 2
     OTHERS                       = 3
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program     = w_repid
      i_callback_top_of_page = 'TOP-OF-PAGE'
      is_layout              = wa_layout
      it_fieldcat            = it_fieldcat_wrt_off
    TABLES
      t_outtab               = it_mara
    EXCEPTIONS
      program_error          = 1
      OTHERS                 = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
* Form  TOP-OF-PAGE                                                 *
* ALV Report Header                                                 *
FORM top-of-page.
*ALV Header declarations
  DATA: t_header TYPE slis_t_listheader,
        wa_header TYPE slis_listheader,
        t_line LIKE wa_header-info,
        ld_lines TYPE i,
        ld_linesc(10) TYPE c.
* Title
  wa_header-typ  = 'H'.
  wa_header-info = 'CHANDU REPORT'.
  APPEND wa_header TO t_header.
  CLEAR wa_header.
* Date
  wa_header-typ  = 'S'.
  wa_header-key = 'Date: '.
  CONCATENATE  sy-datum+6(2) '.'
               sy-datum+4(2) '.'
               sy-datum(4) INTO wa_header-info.   "todays date
  APPEND wa_header TO t_header.
  CLEAR: wa_header.
* Total No. of Records Selected
*  describe table it_ekko lines ld_lines.
*  ld_linesc = ld_lines.
*  concatenate 'Total No. of Records Selected: ' ld_linesc
*                    into t_line separated by space.
*  wa_header-typ  = 'A'.
*  wa_header-info = t_line.
*  append wa_header to t_header.
*  clear: wa_header, t_line.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = t_header.
*            i_logo             = 'Z_LOGO'.
ENDFORM.                    "top-of-page

Similar Messages

  • Adding header to alv(factory) in container

    Hi frends!
    How can I add a header to alv in container using factory method?

    You can use splitter. For example :
    REPORT  ZCE_TEST2.
    DATA: IT_FLIGHT TYPE TABLE OF SFLIGHT.
    DATA: OK_CODE LIKE SY-UCOMM,
    SAVE_OK LIKE SY-UCOMM.
    DATA:  G_CONTAINER TYPE SCRFNAME VALUE 'CONTROL',
    O_DYNDOC_ID  TYPE REF TO CL_DD_DOCUMENT,
    O_SPLITTER   TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
    O_PARENT_GRID TYPE REF TO CL_GUI_CONTAINER,
    O_PARENT_TOP TYPE REF TO CL_GUI_CONTAINER,
    O_HTML_CNTRL TYPE REF TO CL_GUI_HTML_VIEWER.
    CLASS LCL_EVENT_HANDLER DEFINITION .
    PUBLIC SECTION .
    METHODS:
    TOP_OF_PAGE FOR EVENT TOP_OF_PAGE
           OF CL_GUI_ALV_GRID
           IMPORTING E_DYNDOC_ID.
    ENDCLASS.             "lcl_event_handler DEFINITION
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    METHOD TOP_OF_PAGE.
    PERFORM EVENT_TOP_OF_PAGE USING O_DYNDOC_ID.
    ENDMETHOD.                            "top_of_page
    ENDCLASS.       "LCL_EVENT_HANDLER IMPLEMENTATION
    DATA: G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
          G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
    START-OF-SELECTION.
    SELECT *
    FROM SFLIGHT
    UP TO 20 ROWS
    INTO TABLE IT_FLIGHT.
    END-OF-SELECTION.
    IF NOT IT_FLIGHT[] IS INITIAL.
    CALL SCREEN 100.
    ELSE.
    MESSAGE  'NO DATA FOR THE SELECTION' TYPE 'I'.
    ENDIF.
    MODULE STATUS_0100 OUTPUT.
    SET PF-STATUS 'STATUS'.
    SET TITLEBAR 'TITLE'.
    IF G_CUSTOM_CONTAINER IS INITIAL.
    PERFORM CREATE_AND_INIT_ALV.
    ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    MODULE USER_COMMAND_0100 INPUT.
    CASE SY-UCOMM.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    FORM CREATE_AND_INIT_ALV .
    DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
    CREATE OBJECT G_CUSTOM_CONTAINER
    EXPORTING CONTAINER_NAME = G_CONTAINER.
    Create TOP-Document
    CREATE OBJECT O_DYNDOC_ID
    EXPORTING STYLE = 'ALV_GRID'.
    Create Splitter for custom_container
    CREATE OBJECT O_SPLITTER
    EXPORTING PARENT  = G_CUSTOM_CONTAINER
    ROWS    = 2
    COLUMNS = 1.
      CALL METHOD O_SPLITTER->GET_CONTAINER
        EXPORTING
        ROW = 1
        COLUMN = 1
        RECEIVING
        CONTAINER = O_PARENT_TOP.
      CALL METHOD O_SPLITTER->GET_CONTAINER
        EXPORTING
        ROW = 2
        COLUMN = 1
        RECEIVING
        CONTAINER = O_PARENT_GRID.
    Set height for g_parent_html
      CALL METHOD O_SPLITTER->SET_ROW_HEIGHT
        EXPORTING
        ID = 1
        HEIGHT = 5.
    CREATE OBJECT G_GRID
    EXPORTING I_PARENT = O_PARENT_GRID.
    CREATE OBJECT G_HANDLER.
    SET HANDLER G_HANDLER->TOP_OF_PAGE FOR G_GRID.
    *Calling the Method for ALV output
      CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
        I_STRUCTURE_NAME = 'SFLIGHT'
        CHANGING
        IT_OUTTAB = IT_FLIGHT[].
      CALL METHOD O_DYNDOC_ID->INITIALIZE_DOCUMENT
        EXPORTING
        BACKGROUND_COLOR = CL_DD_AREA=>COL_TEXTAREA.
    Processing events
      CALL METHOD G_GRID->LIST_PROCESSING_EVENTS
        EXPORTING
        I_EVENT_NAME = 'TOP_OF_PAGE'
        I_DYNDOC_ID = O_DYNDOC_ID.
    ENDFORM.                     "CREATE_AND_INIT_ALV
    FORM EVENT_TOP_OF_PAGE USING   DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT.
    DATA : DL_TEXT(255) TYPE C.  "Text
      CALL METHOD DG_DYNDOC_ID->ADD_TEXT
        EXPORTING
        TEXT = 'Flight Details'
        SAP_STYLE = CL_DD_AREA=>HEADING
        SAP_FONTSIZE = CL_DD_AREA=>LARGE
        SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
      CALL METHOD DG_DYNDOC_ID->ADD_GAP
        EXPORTING
        WIDTH = 200.
      CALL METHOD O_DYNDOC_ID->ADD_PICTURE
        EXPORTING
        PICTURE_ID = 'ENJOYSAP_LOGO'.
    Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
    CLEAR : DL_TEXT.
    program ID
    DL_TEXT = 'Program Name :'.
      CALL METHOD DG_DYNDOC_ID->ADD_GAP.
      CALL METHOD O_DYNDOC_ID->ADD_TEXT
        EXPORTING
        TEXT = DL_TEXT
        SAP_EMPHASIS = CL_DD_AREA=>HEADING
        SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
    CLEAR DL_TEXT.
    DL_TEXT = SY-REPID.
      CALL METHOD O_DYNDOC_ID->ADD_TEXT
        EXPORTING
        TEXT = DL_TEXT
        SAP_EMPHASIS = CL_DD_AREA=>HEADING
        SAP_COLOR = CL_DD_AREA=>LIST_NEGATIVE_INV.
    Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
    CLEAR : DL_TEXT.
    CLEAR : DL_TEXT.
    program ID
    DL_TEXT = 'User Name :'.
      CALL METHOD DG_DYNDOC_ID->ADD_GAP.
      CALL METHOD O_DYNDOC_ID->ADD_TEXT
        EXPORTING
        TEXT = DL_TEXT
        SAP_EMPHASIS = CL_DD_AREA=>HEADING
        SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
    CLEAR DL_TEXT.
    DL_TEXT = SY-UNAME.
      CALL METHOD O_DYNDOC_ID->ADD_TEXT
        EXPORTING
        TEXT = DL_TEXT
        SAP_EMPHASIS = CL_DD_AREA=>HEADING
        SAP_COLOR = CL_DD_AREA=>LIST_NEGATIVE_INV.
    Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
    CLEAR : DL_TEXT.
    Run Date
    DL_TEXT = 'Run Date :'.
      CALL METHOD DG_DYNDOC_ID->ADD_GAP.
      CALL METHOD O_DYNDOC_ID->ADD_TEXT
        EXPORTING
        TEXT = DL_TEXT
        SAP_EMPHASIS = CL_DD_AREA=>HEADING
        SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
    CLEAR DL_TEXT.
    Move date
    WRITE SY-DATUM TO DL_TEXT.
      CALL METHOD O_DYNDOC_ID->ADD_TEXT
        EXPORTING
        TEXT = DL_TEXT
        SAP_EMPHASIS = CL_DD_AREA=>HEADING
        SAP_COLOR = CL_DD_AREA=>LIST_NEGATIVE_INV.
    Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
    CLEAR : DL_TEXT.
    *Time
    DL_TEXT = 'Time :'.
      CALL METHOD DG_DYNDOC_ID->ADD_GAP.
      CALL METHOD O_DYNDOC_ID->ADD_TEXT
        EXPORTING
        TEXT = DL_TEXT
        SAP_EMPHASIS = CL_DD_AREA=>HEADING
        SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
    CLEAR DL_TEXT.
    Move time
    WRITE SY-UZEIT TO DL_TEXT.
      CALL METHOD O_DYNDOC_ID->ADD_TEXT
        EXPORTING
        TEXT = DL_TEXT
        SAP_EMPHASIS = CL_DD_AREA=>HEADING
        SAP_COLOR = CL_DD_AREA=>LIST_NEGATIVE_INV.
    Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
    PERFORM DISPLAY.
    ENDFORM.                    " EVENT_TOP_OF_PAGE
    FORM DISPLAY.
    Creating html control
      IF O_HTML_CNTRL IS INITIAL.
        CREATE OBJECT O_HTML_CNTRL
             EXPORTING
                  PARENT    = O_PARENT_TOP.
      ENDIF.
      CALL METHOD O_DYNDOC_ID->MERGE_DOCUMENT.
      O_DYNDOC_ID->HTML_CONTROL = O_HTML_CNTRL.
    Display document
      CALL METHOD O_DYNDOC_ID->DISPLAY_DOCUMENT
        EXPORTING
          REUSE_CONTROL      = 'X'
          PARENT             = O_PARENT_TOP
        EXCEPTIONS
          HTML_DISPLAY_ERROR = 1.
      IF SY-SUBRC NE 0.
      MESSAGE 'Error in displaying top-of-page' TYPE 'I'.
      ENDIF.
    ENDFORM.                    " display

  • Adding header in split alv using SALV

    Hello Champs,
    I have a requirement to display 6 diff reports in a screen. I have achieved it by using SALV(Split Container). Now I need to add header to each ALV report. The normal way of adding header in SALV doesnt work in the split ALV.
    Can someone help me with this.
    Thanks,
    Greg

    Hi, im experiencing the same situation right now, have you solved the problem? any inputs would be appreciated. thanks!

  • Editing a pdf form that I created. Adding header error msg "do not have sufficient permissions to perform this task"

    Editing a pdf form that I created. Adding header, currently the header only appears on page 1 of a 3 page pdf form.  I want it to appear on each page.  I am receiving the error msg "do not have sufficient permissions to perform this task"

    In Adobe Acrobat use a Action for this.

  • Multiple Heading in ALV Grid

    Hello ,
    I have a requirement to display Multiple heading in ALV Grid, I am using the Class 'cl_gui_alv_grid'. please let me know if you have Any suggestions.
    Ex:
    |                 Divison                     |     
    Sub D:1
    Sub D: 2
    Sub D: 3
        Like wise i have few more divisions to display and Under we need to display the Sub Division also .
    Thanks in Advance..  Waiting for your suggestions.
    With Best Regards
    Nags

    Hi,
    I had attempted to do it in the object oriented way, but found no ready solution, so I settled for the below solution.
    Please use the function REUSE_ALV_COMMENTARY_WRITE.
    This allows you to print multiple lines in the header.
    I had a requirement of showing 5 lines in the header.
    So i went on like:
    DATA: it_list_commentary TYPE slis_t_listheader,
               wa_list_commentary TYPE slis_listheader.
    wa_list_commentary-typ = 'H'.
    wa_list_commentary-info = <text>.
    APPEND wa_list_commentary TO it_list_commentary.
    wa_list_commentary-typ = 'S'.
    wa_list_commentary-info = <text>.
    APPEND wa_list_commentary TO it_list_commentary.
    I fed he internal table with all 5 lines like above.
    Finally I called the function.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = it_list_commentary.
    Regards,
    Prosenjit.
    Edited by: prosenjit chaudhuri on Jan 28, 2009 6:14 AM

  • Header in ALV Report

    Hi All,
    I want to print a report in the following manner:
    DATE:
    CLASS GROUP :
    MATNR   CLASS     ADSIZE
    123          c             col1
    124          c            col2
    156          c             col2
    DATE:
    CLASS GROUP :
    MATNR   CLASS     ADSIZE
    125         a            col3
    128         a            col4
    150          a             col5
    How do i do it...I am planning to do it with REUSE_ALV_LIST _DISPLAY...but i dont know how to print the header..plz help

    <b>Note : In the below   i am passing  my purchase  order Ebeln  with internal table to the Form header so that all purchase  order are passed to Header  by this way you can also pass it  .</b>
    <b>Add Title(heading) to ALV Grid</b>
    In order to insert a report heading in to the ALV grid you need to perform the following steps:
    1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include 'top-of-page' FORM
    2. Create 'top-of-page' FORM
    call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
                i_save                  = 'X'
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
    Form top-of-page.
    *ALV Header declarations
    data: t_header type slis_t_listheader,
          wa_header type slis_listheader,
          t_line like wa_header-info,
          ld_lines type i,
          ld_linesc(10) type c.
    * Title
      wa_header-typ  = 'H'.
      wa_header-info = EKKO-ebeln.
      append wa_header to t_header.
      clear wa_header.
    endform.
    reward points if it is usefull .....
    Girish

  • Header in alv grid using class

    Hello All,
        I developed alv grid using class method.
    First I created CREATE OBJECT GR_CCONTAINER
    then  CREATE OBJECT GR_ALVGRID
    then  PERFORM FIELD_CATALOG TABLES GT_FIELDCAT----
    for field catalog
        PERFORM LAYOUT CHANGING GS_LAYOUT.----
    for header
        p_gs_layout-grid_title = 'class method'.
      p_gs_layout-sel_mode = 'D'.
      APPEND P_GS_LAYOUT TO IT_LAYOUT.
    and finally CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
    the report is cooming fine but in header it comes only "class method".
    but i need also
    1. reporting date
    2. reporting time.
       can any body tell me how i can i put 2 more heading line
    Thanks,
    Rakesh

    Hi Dude,
    Please refer the below link how to handle  the header in alv using abap oo
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/abapObjects-ALVModel-UsingHeaderand+Footer
    Hope it clears,..............
    Thanks & Regards
    Ramakrishna Pathi

  • Header in alv pop up

    Hello,
    i need to dislay header as well as item details in an alv pop up. I am using FM REUSE_ALV_POPUP_TO_SELECT. but I am not able to get the header information. I am able to get the item details for a particular Purchase order number. I need to display purchase order number in the header of alv POPUP.
    how can i achieve this using the same FM?

    hi
    hope this wil help to u
    ...tables vbak.
    data it_vbak like vbak occurs 0 with header line.
    selection-screen begin of block b1 with frame.
    parameters: alv1 radiobutton group alv, "REUSE_ALV_LIST_DISPLAY
    alv2 radiobutton group alv, "REUSE_ALV_POPUP_TO_SELECT
    alv3 radiobutton group alv, "REUSE_ALV_GRID_DISPLAY
    alv4 radiobutton group alv. " NORMAL DISPLAY
    selection-screen end of block b1.
    select * from vbak
    into corresponding fields of table it_vbak
    up to 10 rows.
    if alv1 = 'X'. perform alv_func1.
    elseif alv2 = 'X'. perform alv_func2.
    elseif alv3 = 'X'. perform alv_func3.
    elseif alv4 = 'X'. perform norm.
    endif.
    **& Form ALV_FUNC1
    *form alv_func1 .
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
    i_structure_name = 'VBAK'
    tables
    t_outtab = it_vbak
    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. " ALV_FUNC1
    **& Form ALV_FUNC2
    *form alv_func2 .
    call function 'REUSE_ALV_POPUP_TO_SELECT'
    exporting
    i_title = 'SALES ORDER INFO'
    i_zebra = 'X'
    i_tabname = 1
    i_structure_name = 'vbak'
    tables
    t_outtab = it_vbak
    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. " ALV_FUNC2
    **& Form ALV_FUNC3
    *form alv_func3 .
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
    i_structure_name = 'vbak'
    i_grid_title = 'SALES ORDER INFO'
    tables
    t_outtab = it_vbak
    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. " ALV_FUNC3
    **& Form NORM
    *form norm .
    format intensified.
    skip 1.
    write: /'SALES DOC.',
    ' Created on ',
    ' Time',
    ' Created by',
    ' Valid from ',
    ' Sold-to party'.
    format intensified off. skip 2.
    loop at it_vbak.
    write: / it_vbak-vbeln,
    it_vbak-erdat,
    it_vbak-erzet,
    it_vbak-ernam,
    it_vbak-angdt,
    it_vbak-kunnr.
    endloop.
    endform. " NORM 
    Edited by: Nawanandana Edirisinghe on Sep 3, 2009 12:52 PM

  • Header in ALV grid

    Read the posted messages but still have some query regarding layout of Header in ALV grid. Using ALV Grid (not OO concept) in the report.
    - Can texts be printed in two sections in a single row like
    Name :                                 Designation:
    Age:                                   Cost Centre:
    - How to increse the row size of the header. Right now have to scroll to see the complete header.
    Looking forward for replies.
    Thanks
    anu

    The font size depends on what you have specified  for the parameter SLIS_LISTHEADER ( H = Header, S = Selection, A = Action are the valid values), I don't think we have selection of the font size as such.
    So, in your case you can specify Name / Designation as Header and Age / Cost Center as Selection so that they appear in different font.
    I am guessing you are using the function REUSE_ALV_COMMENTARY_WRITE, for writing the header.
    regards,
    Ravi
    Note : Please mark all the helpful answers

  • Header in ALV using Oops

    I need to display Table header in ALV using Oops.
    I need to data from 8 fields which I get in the run time of the program.
    I am new to Oops ALV, I have done a similar thing in normal ALV but not in oops.
    Detailed info required, Custom container settings as well.
    Thanks in Advance

    see this weblog TOP_OF_PAGE in ALV  Using CL_GUI_ALV_GRID

  • Table in Header of ALV

    Hi,
    I want to display header of alv grid in table format with rows and columns. Please suggest on the same. Points will be rewarded.

    hi,
         see the below code .this may help u .
    *Table declaration.
    TABLES:ZEMP_MST,ZDEPT_MST,ZDESG_MST,ZSL_TXN.
    *Varriable declaration.
    TYPE-POOLS SLIS.
    DATA : POS TYPE I.
    DATA  REPID  LIKE SY-REPID.
    DATA : F1 TYPE SLIS_T_FIELDCAT_ALV,
           F2 TYPE SLIS_FIELDCAT_ALV,
           L_LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA  L_POS TYPE I VALUE 1.               "position of the column
    DATA  GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    *DATA  GT_SORT TYPE SLIS_T_SORTINFO_ALV.
    data:  GT_EVENTS    TYPE SLIS_T_EVENT,
           FS_EVENTCAT LIKE LINE OF GT_EVENTs.
    *Internal table declaration.
    *DATA  BEGIN OF IT_SORT OCCURS 5.
         INCLUDE TYPE SLIS_SORTINFO_ALV.
    *DATA  END OF IT_SORT.
    DATA:BEGIN OF ITAB OCCURS 0,
          ZEMPNO    LIKE ZEMP_MST-ZEMPNO,
          ZEMPNAME  LIKE ZEMP_MST-ZEMPNAME,
          ZDEPTCD   LIKE ZEMP_MST-ZDEPTCD,
          ZDEPTNAME LIKE ZDEPT_MST-ZDEPTNAME,
          ZDESGCD   LIKE ZEMP_MST-ZDESGCD,
          ZDESGNAME LIKE ZDESG_MST-ZDESGNAME,
         END OF ITAB.
    REFRESH ITAB.CLEAR ITAB.
    START-OF-SELECTION.
    SELECT AZEMPNO AZEMPNAME AZDEPTCD BZDEPTNAME AZDESGCD CZDESGNAME
           FROM ZEMP_MST AS A
             INNER JOIN ZDEPT_MST AS B
               ON AZDEPTCD EQ BZDEPTCD
             INNER JOIN ZDESG_MST AS C
               ON AZDESGCD EQ CZDESGCD
           INTO CORRESPONDING FIELDS OF TABLE ITAB.
    IF SY-SUBRC <> 0.
       MESSAGE E899(M3) WITH 'No records'.
    ENDIF.
    perform f_build_eventcat.
    PERFORM LAYOUT.
    END-OF-SELECTION.
    *&      Form  LAYOUT
    FORM LAYOUT .
      PERFORM FCAT USING 'ZEMPNO'    'ITAB' '' 'Emp.No.'   'ZEMPNO'    'ZEMP_MST'  ''.
      PERFORM FCAT USING 'ZEMPNAME'  'ITAB' '' 'Emp. Name' 'ZEMPNAME'  'ZEMP_MST'  ''.
      PERFORM FCAT USING 'ZDEPTCD'   'ITAB' '' 'Dept.Code' 'ZDEPTCD'   'ZEMP_MST'  ''.
      PERFORM FCAT USING 'ZDEPTNAME' 'ITAB' '' 'Dept.Name' 'ZDEPTNAME' 'ZDEPT_MST' ''.
      PERFORM FCAT USING 'ZDESGCD'   'ITAB' '' 'Desg.Code' 'ZDESGCD'   'ZEMP_MST'  ''.
      PERFORM FCAT USING 'ZDESGNAME' 'ITAB' '' 'Desg.Name' 'ZDESGNAME' 'ZDESG_MST' ''.
    PERFORM LSORT USING  'ZEMPNO' 'IDATA' ''.
    PERFORM LSORT USING  'ZEMPNAME' 'IDATA' ''.
    MOVE IT_SORT[] TO GT_SORT[].
      REPID = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
             I_CALLBACK_PROGRAM       = REPID
             IT_FIELDCAT              = F1
            IT_SORT                  = GT_SORT
             I_SAVE                   = 'X'
             IT_EVENTS                = GT_EVENTS[]
         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.
    ENDFORM.                    " LAYOUT
    *&      Form  FCAT
    FORM FCAT USING P_FIELD P_TABLE P_SUM P_TEXT P_RFIELD P_RTABLE P_DISP.
      ADD 1 TO POS.
      F2-COL_POS       = POS.
      F2-FIELDNAME     = P_FIELD.
      F2-TABNAME       = P_TABLE.
      F2-SELTEXT_L     = P_TEXT.
      F2-REF_FIELDNAME = P_RFIELD.
      F2-REF_TABNAME   = P_RTABLE.
      F2-DO_SUM        = P_SUM.
      F2-NO_OUT        = P_DISP.
      APPEND F2 TO F1.
      CLEAR F2.
    ENDFORM.                " FCAT
    *&      Form  LSORT
    *FORM LSORT USING P_FIELD P_TABLE P_UP.
    ADD 1 TO L_POS.
    IT_SORT-SPOS      = L_POS.
    IT_SORT-FIELDNAME = P_FIELD.
    IT_SORT-TABNAME   = P_TABLE.
    IT_SORT-UP        = P_UP.
    APPEND IT_SORT.
    *ENDFORM.                    " LSORT
    FORM F_BUILD_EVENTCAT .
    CLEAR: GT_EVENTS.  REFRESH: GT_EVENTS.
      CLEAR: FS_EVENTCAT.
      FS_EVENTCAT-NAME = 'TOP_OF_PAGE'.
      FS_EVENTCAT-FORM = 'F_REPORT_HEADER_ALV'.
      APPEND FS_EVENTCAT TO GT_EVENTS.
      CLEAR: FS_EVENTCAT.
      FS_EVENTCAT-NAME = 'END_OF_LIST'.
      FS_EVENTCAT-FORM = 'F_WRITE_SUMMARY'.
      APPEND FS_EVENTCAT TO GT_EVENTS.
    ENDFORM.                    " F_BUILD_EVENTCAT
    FORM F_REPORT_HEADER_ALV.
    CALL FUNCTION 'Z_YHEAD_PRINT'
    EXPORTING
       TITLE1        = 'XYZ Limited'
       TITLE2        = 'Employee Master'
       TITLE3        = 'Created on '
       COLOR         = 'X'
    ENDFORM.
    *&      Form  F_WRITE_SUMMARY
          Write summary before exit
    FORM F_WRITE_SUMMARY .
    write:/ 'Welcome to XYZ Limited'.
    write:/ 'This is a test program to display Report in ALV Format'.
    ENDFORM.

  • Display selection screen details in the header of ALV

    hi..
    can someone please help me on how to display the data in the selection screen in the header in ALV?
    i hope someone can help me..thanks very much..

    Simple ALV report
    http://www.sapgenie.com/abap/controls/alvgrid.htm
    http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
    ALV
    1. Please give me general info on ALV.
    http://www.sapfans.com/forums/viewtopic.php?t=58286
    http://www.sapfans.com/forums/viewtopic.php?t=76490
    http://www.sapfans.com/forums/viewtopic.php?t=20591
    http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
    2. How do I program double click in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=11601
    http://www.sapfans.com/forums/viewtopic.php?t=23010
    3. How do I add subtotals (I have problem to add them)...
    http://www.sapfans.com/forums/viewtopic.php?t=20386
    http://www.sapfans.com/forums/viewtopic.php?t=85191
    http://www.sapfans.com/forums/viewtopic.php?t=88401
    http://www.sapfans.com/forums/viewtopic.php?t=17335
    4. How to add list heading like top-of-page in ABAP lists?
    http://www.sapfans.com/forums/viewtopic.php?t=58775
    http://www.sapfans.com/forums/viewtopic.php?t=60550
    http://www.sapfans.com/forums/viewtopic.php?t=16629
    5. How to print page number / total number of pages X/XX in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
    6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
    http://www.sapfans.com/forums/viewtopic.php?t=64320
    http://www.sapfans.com/forums/viewtopic.php?t=44477
    7. How can I set the cell color in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=52107
    8. How do I print a logo/graphics in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=81149
    http://www.sapfans.com/forums/viewtopic.php?t=35498
    http://www.sapfans.com/forums/viewtopic.php?t=5013
    9. How do I create and use input-enabled fields in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=84933
    http://www.sapfans.com/forums/viewtopic.php?t=69878
    10. How can I use ALV for reports that are going to be run in background?
    http://www.sapfans.com/forums/viewtopic.php?t=83243
    http://www.sapfans.com/forums/viewtopic.php?t=19224
    11. How can I display an icon in ALV? (Common requirement is traffic light icon).
    http://www.sapfans.com/forums/viewtopic.php?t=79424
    http://www.sapfans.com/forums/viewtopic.php?t=24512
    12. How can I display a checkbox in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=88376
    http://www.sapfans.com/forums/viewtopic.php?t=40968
    http://www.sapfans.com/forums/viewtopic.php?t=6919
    Go thru these programs they may help u to try on some hands on
    ALV Demo program
    BCALV_DEMO_HTML
    BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
    BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
    BCALV_GRID_DEMO Simple ALV Control Call Demo Program
    BCALV_TREE_DEMO Demo for ALV tree control
    BCALV_TREE_SIMPLE_DEMO
    BC_ALV_DEMO_HTML_D0100

  • Displaying a header on alv list

    hi there,
    i want to display a header on alv list.
    i have already used
    call method alvgrid->set_table_for_first_display
    regrads

    Hi,
    use the TOP_OF_PAGE event and add the event to the IT_EVENTS internal table..
    In the subroutine that is assigned to the event..
    FORM top_of_page.
            CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
              EXPORTING
                it_list_commentary = heading.
    ENDFORM.
    Thanks,
    Naren

  • Reg. lengh of header of alv grid.....have ur points.

    Hi all,
    -I want to show text on the right side of the header of ALV grid.
    -Secondly i have limit of around 60 characters in a line...i want to add more words in the same line.....
    <b>see the code...here..</b>
      wa_listheader-typ = 'S'.
      wa_listheader-info = 'THE FUNCTIONAL LOCATION WISE PERCENTAGE   IMPLEMENTAION'.
      APPEND wa_listheader TO it_listheader.
      CLEAR wa_listheader.
    <b>Thanx in advance..</b>
    Have ur points.
    Regards,
    pradeep phogat

    Try this
    WA_LINE-TYP = 'S'..----
    ><b>'H' to print in header</b>
    CONCATENATE 'THE FUNCTIONAL LOCATION WISE PERCENTAGE IMPLEMENTAION'.
    V_RYEAR INTO WA_LINE-INFO
       SEPARATED BY SPACE.
    APPEND WA_LINE TO IT_LIST_TOP_OF_PAGE.
    Thanks

  • Multiple line header for ALV

    I am using  CL_SALV_TABLE (List_Display = X) to create a ALV report. I am willing to change it to function module REUSE_ALV_LIST_DISPLAY if it serves my requirement.
    The header for the report needs to be multiple lines (8 lines). How can I accomplish this?
    I looked into the possibility of using TOP_OF_PAGE event but I will have to hard code the vertical positions of the headers and since it is ALV and you can remove columns at will, I dont think this solution will work. Also if the columns are optimized or output length changed by the user, the positioning of the headers will be ruined.
    Currently the header can only be of one line, how can we make the header to display a table of contents.
    H1-L1          H2-L1          H3-L1
    H1-L2          H2-L2          H3-L2
    H1-L3          H2-L3          H3-L3
    H1-L4          H2-L4          H3-L4
    H1-L5          H2-L5          H3-L5
    H1-L6          H2-L6          H3-L6
    H1-L7          H2-L7          H3-L7
    H1-L8          H2-L8          H3-L8
    Thank you.

    Please guide me hw to put internal table field at report header in ALV.
    this is my field catalog.
    wa_fieldcat-row_pos = 1.
      wa_fieldcat-col_pos = 1.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'VBELN'.
      wa_fieldcat-seltext_m = 'SalesOrderNo'.
      wa_fieldcat-outputlen = '10'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
    Also i wnt to total 4 field at header level and other is detail level.
    Please guide me hw to do.
    thnks
    Bhavesh

Maybe you are looking for

  • How to resolve preview when crashing on print?

    Preview crashing when asked to print pdf or ping files. Only adobe works to print but preview was much more convenient to use when it was working the same printer before. So I'd like it to stop crashing if possible. Should I delete and re download th

  • Flash Builder 4.7 + OSX 10.10 = :-(

    Problem Description: When attempting to use a Flash Builder File Dialogue Box under OSX 10.10 Yosemite will immediately crash the application. This bug now renders Flash Builder 100% useless on OSX 10.10! Steps to Reproduce: 1. Open Flash Builder 4.7

  • Error while creating database instance during PI instalation

    Hi Team, I am in the installation phase of SAP PI with MAXDB as back end.In the phase "create database instance" i am facing the following issue "An error occurred while processing option SAP EHP1 for SAP NetWeaver PI/Mobile/Banking 7.1 > MaxDB > SAP

  • Gmail attachment open in acrobat reader

    On android phone. Can not open attachment .pdf in acrobat reader, some other program opens. Question is, how to change so it always opens in acrobat like before?

  • How to clear model node input table data?

    hi experts,           i am developing one application, which updates database table. i am having one table having all claimids as column, in of view. when i click on any of the claimid, it moves to second details view of that claim id having header a