Creating 2 header in ALV (Urgent!)

Hello... i have aproblem right now. i want to create report using ALV grid and i'm using OO method, the problem is, i want to create 2 header in the same screen,
for example
[header1]                              [header2]
name place                             name  place
but i don't know how to create them, i don't want to use split container is there another way to create it.
And for the header it's dynamic based on my selection at the selection screen. so if in selection screen header 1 i fill try1 and in header 2 i fill try2, then the result will be:
try1                                     try2
name place                             name  place
Can u gice me the sample code, i'll really appreciate if u do, thx.

Hi,
Welcome to SDN!!!!!!!!!!!!!
I think you can do this while building your FIELDCATALOG.
Look at the sample code.......
  call function 'REUSE_ALV_GRID_DISPLAY'
     exporting
       i_callback_program      = i_repid
       i_callback_user_command = 'USER_COMMAND_PERNR'
       it_fieldcat             = header
       is_layout               = gt_layout
       i_callback_top_of_page  = 'TOP-OF-PAGE1'
       i_grid_title            = xyz
       it_sort                 = gt_sort[]
       i_default               = 'X'
       i_save                  = 'U'
       is_variant              = gt_variant
       it_events               = gt_events
      tables
       t_outtab                = t_output.
  clear t_output.
*******Building Fieldcatlog***********
  clear ls_fieldcat.
  ls_fieldcat-fieldname  = 'NAME'.
  ls_fieldcat-col_pos    = 1.
  ls_fieldcat-seltext_l  = text-t01.
  ls_fieldcat-outputlen  = 8.
  ls_fieldcat-fix_column = 'X'.
ls_fieldcat-key        = 'X'.
  append ls_fieldcat to header.
  clear ls_fieldcat.
  ls_fieldcat-fieldname  = 'PLACE'.
  ls_fieldcat-col_pos    = 2.
  ls_fieldcat-seltext_l  = text-t02.
  ls_fieldcat-outputlen  = 40.
  ls_fieldcat-fix_column = 'X'.
   ls_fieldcat-just       = 'C'.
  append ls_fieldcat to header.
  clear ls_fieldcat.
  ls_fieldcat-fieldname  = 'NAME1'.
  ls_fieldcat-col_pos    = 3.
  ls_fieldcat-seltext_l  = text-t03.
  ls_fieldcat-outputlen  = 40.
   ls_fieldcat-just       = 'C'.
  append ls_fieldcat to header.
  clear ls_fieldcat.
  ls_fieldcat-fieldname  = 'PLACE1'.
  ls_fieldcat-col_pos    = 4.
  ls_fieldcat-seltext_l  = text-t04.
  ls_fieldcat-outputlen  = 10.
   ls_fieldcat-just       = 'C'.
  append ls_fieldcat to header.
  clear ls_fieldcat.
here in your Internal table differentiate your coloumns such a way the data while passing to FM it will not be a problem.
Thanks.
If this helps you reward with points.
Message was edited by: Deepak

Similar Messages

  • How To Create Header in ALV List Report

    Hi All,
    I want to create a Header for <b>MY ALV List Report</b>!
    How can i achieve the same. It should come above <b>ALV</b>.
    ALV report i had already written and it is coming correctly.
    Heading should look like this:
    <i>1st Line</i>
    <b>PROGRAM NAME: XXXXXX      CLIENT: XXXXXXXXXX   PAGE:XX</b>
    <i>2nd Line</i>
    <b>RUN DATE/TIME: XXXXX - XXXX     REPORT NAME/HEADER</b>
    How can i acheive the same in <b>ALV List Report</b>!
    I am amking use of <b>REUSE_ALV_LIST_DISPLAY</b> Function module.
    Thanks in advance.
    Thanks & Regards,
    Prasad.

    Hi Prasad,
    Use the sample code specified below as the guideline. For more info. refer to the documentation of the FM 'REUSE_ALV_COMMENTARY_WRITE'.
    DATA: first(01) type c,
    events type slis_t_event,
    gt_list_top_of_page type slis_t_listheader,
    ls_event type slis_alv_event.
    initialization.
    call function 'REUSE_ALV_EVENTS_GET'
    EXPORTING
    I_LIST_TYPE = 0
    IMPORTING
    ET_EVENTS = events
    EXCEPTIONS
    LIST_TYPE_WRONG = 1
    OTHERS = 2.
    read table events with key name = 'TOP_OF_PAGE'
    into ls_event.
    if sy-subrc = 0.
    move: 'TOP_OF_PAGE' to ls_event-form.
    append ls_event to events.
    clear ls_event.
    endif.
    End of additions
    Start-of-selection
    START-OF-SELECTION.
    Top-of-page
    TOP-OF-PAGE.
    PERFORM TOP_OF_PAGE.
    FORM TOP_OF_PAGE .
    data: ls_line type slis_listheader.
    if first is initial.
    ls_line-typ = 'S'.
    ls_line-key = 'Run Date :'.
    write: sy-datum to ls_line-key+10 mm/dd/yyyy.
    ls_line-info = 'Billing Date:'.
    write: s_fkdat-low to ls_line-info+15 mm/dd/yyyy.
    ls_line-info+28 = 'To'.
    write s_fkdat-high to ls_line-info+32 mm/dd/yyyy.
    append ls_line to gt_list_top_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = gt_list_top_of_page.
    first = 'N'.
    else.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = gt_list_top_of_page.
    endif.
    ENDFORM. " top_of_page
    <b>Please mark helpful answer.</b>
    Regards,
    Amit Mishra

  • Alv  grid : is it possible to create 2 header lines  ?

    alv  grid : is it possible to create 2 header lines  ?
    for example  :
    open year            close year
    from 2006            until   2008
    data
    data
    data
    data
    i know that i can do so in alv list  , but is it possible in alv
    grid ( with screen )   ?

    No, this is not supported by the ALV Grid control.
    Regards,
    Rich Heilman

  • How to create check box in ALV Reports?

    how to create check box in ALV Reports?

    Hi
    check the report  BCALV_TEST_GRID_EDITABLE
    or
    check this report
    REPORT ZRFC346_TST.
    TABLES:SFLIGHT,RL034.
    TYPE-POOLS:SLIS.
    INCLUDE:<ICON>,<SYMBOL>.
    DATA: G_REPID          LIKE SY-REPID,
          G_FIELDCAT       TYPE SLIS_T_FIELDCAT_ALV,
          G_IT_SORT        TYPE SLIS_T_SORTINFO_ALV,
          G_LAYOUT         TYPE SLIS_LAYOUT_ALV,
          G_TABNAME_HEADER TYPE SLIS_TABNAME,
          G_TABNAME_ITEM   TYPE SLIS_TABNAME,
          G_KEYINFO        TYPE SLIS_KEYINFO_ALV,
          G_VARIANT        LIKE DISVARIANT,
          G_EXTAB          TYPE SLIS_T_EXTAB,
          I_SLIS_EXIT_BY_USER TYPE SLIS_EXIT_BY_USER.
    DATA: XEVENT         TYPE SLIS_T_EVENT,
          AEVENT         TYPE SLIS_ALV_EVENT,
          VARIANT        LIKE DISVARIANT,
          LAYOUT         TYPE SLIS_LAYOUT_ALV,
          ASP_GROUP      TYPE SLIS_SP_GROUP_ALV,
          GT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV,
          EXTAB          TYPE SLIS_T_EXTAB WITH HEADER LINE,
          XFIELD         TYPE SLIS_T_FIELDCAT_ALV,
          AFIELD         TYPE SLIS_FIELDCAT_ALV,
          G_SUCOMM      LIKE SY-UCOMM,
          G_SELFLD       TYPE SLIS_SELFIELD.
    DATA: SAV_SY_REPID      LIKE SY-REPID.
    CONSTANTS: CON_SFLIGHT TYPE LVC_FNAME VALUE 'SFLIGHT',
               CON_DISPLAY_FULL TYPE I VALUE 3.
    Data to be displayed
    DATA: BEGIN OF GT_SFLIGHT OCCURS 0.
            INCLUDE STRUCTURE SFLIGHT.
    DATA:ACTIVATE(1).
    DATA: END OF GT_SFLIGHT.
    INITIALIZATION.
    *........Initialisierung...............................................
      PERFORM INITIALIZATION_RL034.
    *........Field cata....................................................
      PERFORM FIELD_CAT.
    *........SPECIAL GROUP.................................................
      PERFORM E07_SP_GROUP_BUILD USING GT_SP_GROUP[].
    START-OF-SELECTION.
    Selection
      SELECT * FROM SFLIGHT INTO TABLE GT_SFLIGHT.
    *........ALV CALL.......................................................
      PERFORM ALV_CALL.
      PERFORM USER_COMMAND_LOCAL USING G_SUCOMM G_SELFLD.
          FORM USER_COMMAND_LOCAL                                       *
    -->  G_UCOMM                                                       *
    -->  G_SELFIELD                                                    *
    FORM USER_COMMAND_LOCAL USING G_UCOMM LIKE SY-UCOMM
                                  G_SELFIELD TYPE SLIS_SELFIELD.
      CASE G_UCOMM.
        WHEN 'ACT'.
      ENDCASE.
    ENDFORM.
          FORM ALV_CALL                                                 *
    FORM ALV_CALL.
    Call ABAP List Viewer (ALV)
    G_LAYOUT-BOX_FIELDNAME = 'ACTIVATE'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
                 EXPORTING
                I_BACKGROUND_ID         = 'ALV_BACKGROUND'
                   I_BYPASSING_BUFFER                = SPACE
                   I_BUFFER_ACTIVE                   = SPACE
                    I_CALLBACK_PROGRAM                = SAV_SY_REPID
                    I_CALLBACK_PF_STATUS_SET          = 'STATUS'
                   I_CALLBACK_USER_COMMAND           = 'USER_COMMAND_LOCAL'
                I_CALLBACK_TOP_OF_PAGE            = ' '
                I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
                I_CALLBACK_HTML_END_OF_LIST       = ' '
                 I_STRUCTURE_NAME                  = 'SFLIGHT'
                I_BACKGROUND_ID                   = ' '
                I_GRID_TITLE                      =
                I_GRID_SETTINGS                   =
                  IS_LAYOUT                         = G_LAYOUT
                  IT_FIELDCAT                       = XFIELD[]
                IT_EXCLUDING                      =
                  IT_SPECIAL_GROUPS                 = GT_SP_GROUP[]
                IT_SORT                           =
                IT_FILTER                         =
                 IS_SEL_HIDE                       = 'X'
                I_DEFAULT                         = 'X'
                  I_SAVE                            = 'A'
                IS_VARIANT                        =
                 IT_EVENTS                         = XEVENT
                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
                IT_ALV_GRAPHICS                   =
                IT_ADD_FIELDCAT                   =
                IT_HYPERLINK                      =
                I_HTML_HEIGHT_TOP                 =
                I_HTML_HEIGHT_END                 =
                IT_EXCEPT_QINFO                   =
              IMPORTING
                E_EXIT_CAUSED_BY_CALLER           =
                ES_EXIT_CAUSED_BY_USER            =
                  TABLES
                    T_OUTTAB                          = GT_SFLIGHT
              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.
          FORM status                                                   *
    -->  EXTAB                                                         *
    FORM STATUS USING EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'STAT' EXCLUDING EXTAB.
    ENDFORM.                               " STATUS
    *&      Form  INITIALIZATION_RL034
          text
    -->  p1        text
    <--  p2        text
    FORM INITIALIZATION_RL034.
      SAV_SY_REPID = SY-REPID.
    ENDFORM.                    " INITIALIZATION_RL034
    *&      Form  DEFINE_EVENTS_RL034
          text
    -->  p1        text
    <--  p2        text
    FORM DEFINE_EVENTS_RL034.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = XEVENT.
       exceptions
            list_type_wrong = 1
            others          = 2.
    ENDFORM.                    " DEFINE_EVENTS_RL034
    *&      Form  FIELD_CAT
          text
    -->  p1        text
    <--  p2        text
    FORM FIELD_CAT.
      DATA: LS_FCAT TYPE SLIS_FIELDCAT_ALV,
            L_LIN   TYPE I.
      REFRESH XFIELD.
           1. per Default eingeblendete Felder                          *
    *........Ikone/Symbol..................................................
      CLEAR AFIELD.
      DATA: LS1_FCAT TYPE SLIS_FIELDCAT_ALV,
            L_LIN1   TYPE I.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                I_STRUCTURE_NAME       = CON_SFLIGHT
                I_BYPASSING_BUFFER     = SPACE
                I_BUFFER_ACTIVE        = SPACE
           CHANGING
                CT_FIELDCAT            = XFIELD
           EXCEPTIONS
                INCONSISTENT_INTERFACE = 1
                PROGRAM_ERROR          = 2
                OTHERS                 = 3.
      DESCRIBE TABLE XFIELD LINES L_LIN1.
      ADD 1 TO L_LIN1.
      CLEAR LS_FCAT.
      LS1_FCAT-FIELDNAME = 'ACTIVATE'.
      LS1_FCAT-CHECKBOX  = 'X'.
    LS1_FCAT-KEY       = 'X'.
      LS1_FCAT-INPUT     = 'X'.
      LS1_FCAT-EDIT     = 'X'.
      LS1_FCAT-INTTYPE   = 'C'.
      LS1_FCAT-DATATYPE  = 'CHAR'.
      LS1_FCAT-INTLEN    = 1.
      LS1_FCAT-COL_POS   = L_LIN1.
      LS1_FCAT-SELTEXT_S = LS1_FCAT-FIELDNAME.
      LS1_FCAT-SELTEXT_M = LS1_FCAT-FIELDNAME.
      LS1_FCAT-SELTEXT_L = LS1_FCAT-FIELDNAME.
      LS1_FCAT-SP_GROUP = 'A'.
      APPEND LS1_FCAT TO XFIELD.
      ADD 1 TO L_LIN.
    ENDFORM.                    " FIELD_CAT
    FORM E07_SP_GROUP_BUILD USING E07_LT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV.
      DATA: LS_SP_GROUP TYPE SLIS_SP_GROUP_ALV.
      CLEAR  LS_SP_GROUP.
      LS_SP_GROUP-SP_GROUP = 'A'.
      LS_SP_GROUP-TEXT     = 'SPECIAL'.
      APPEND LS_SP_GROUP TO E07_LT_SP_GROUP.
    ENDFORM.
    Regards
    Shiva

  • 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

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

  • Variable header in ALV

    Hi all,
    I want to print variable text in the top-of-page in the ALV.
    Suppose, I am making customer wise sales report.
    A new page is triggered when customer changes. I have done this.
    I want to print customer name and code in the top of page  whenever the customer changes. I have done coding for this like I have made list header which changes when the customer changes.It is working well when the user sees the report output on the screen but when he prints it , the headers are not printed.
    Please give me the solution of this problem.
    Thnaks and Regards
    Gurpreet Singh

    Check that whether u
    <b>handle_print_top_of_page</b>
    Or else it wont work.
    Sample for TOP-OF-PAGE and PRINT-TOP-OF-PAGE
    * Class definition :
    *       CLASS v_lcl_event_receiver DEFINITION
    CLASS v_lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_print_top_of_page FOR EVENT print_top_of_page OF
                                           cl_gui_alv_grid,
        handle_top_of_page FOR EVENT top_of_page OF
                                     cl_gui_alv_grid.
    ENDCLASS.
    *       CLASS V_LCL_EVENT_RECEIVER IMPLEMENTATION
    CLASS v_lcl_event_receiver IMPLEMENTATION.
      METHOD handle_print_top_of_page.
        IF sy-pagno = 1.
            PERFORM top_of_page.
        ENDIF.
      ENDMETHOD.
      METHOD handle_top_of_page.
          PERFORM top_of_page.
      ENDMETHOD.
    ENDCLASS.
    DATA:        v_event_receiver      TYPE REF TO v_lcl_event_receiver.
    FORM top_of_page.
      WRITE: text-020,
    ENDFORM.                    " top_of_page
    <u>In PBo of the screen</u>
       DATA: v_split            TYPE REF TO cl_gui_easy_splitter_container,
             v_contnr_top       TYPE REF TO cl_gui_container,
             v_contnr_bot       TYPE REF TO cl_gui_container,
             v_grid_02          TYPE REF TO cl_gui_alv_grid,
             v_html             TYPE REF TO cl_dd_document,
             v_text20(255)      TYPE c,
             v_text16(255)      TYPE c,
    FORM f9000_objects_create.
      IF cl_gui_alv_grid=>offline( ) IS INITIAL.
    Create a container
        CREATE OBJECT o_dockingcontainer
          EXPORTING
            ratio                       = '95'
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            others                      = 6.
        IF sy-subrc NE 0.
          MESSAGE i000 WITH text-e01."Error in creating Docking container
          LEAVE LIST-PROCESSING.
        ENDIF.
        CREATE OBJECT v_split
             EXPORTING
               parent            = o_dockingcontainer
    *          ORIENTATION       = 0
               sash_position     = 25
               with_border       = 0
             EXCEPTIONS
               cntl_error        = 1
               cntl_system_error = 2
               others            = 3.
        IF sy-subrc NE 0.
          MESSAGE i000 WITH text-e01."Error in creating Docking container
          LEAVE LIST-PROCESSING.
        ENDIF.
    *   Get the containers of the splitter control
        v_contnr_top = v_split->top_left_container.
        v_contnr_bot = v_split->bottom_right_container.
        CREATE OBJECT o_alvgrid
       EXPORTING
         i_parent = o_dockingcontainer.
    *   Create an instance of alv control
        CREATE OBJECT o_alvgrid
             EXPORTING i_parent = v_contnr_bot.
    *   Object for display of selection parameters in HTML top container
        CREATE OBJECT v_html
             EXPORTING
               style = 'ALV_GRID'.
    *   Must be after the SET HANDLER for TOP_OF_PAGE and foreground only
        CALL METHOD o_alvgrid->list_processing_events
                         EXPORTING i_event_name = 'TOP_OF_PAGE'
                                   i_dyndoc_id  = v_html.
        v_text20 = text-020(summary Record counts)Any text.
        CALL METHOD v_html->add_gap
                    EXPORTING
                      width         = 120.
        CALL METHOD v_html->add_text
               EXPORTING
                 text          = v_text20.
        CALL METHOD v_html->new_line.
    ** Display Text-016
        v_text16 = text-016.
        CALL METHOD v_html->add_gap
                    EXPORTING
                      width         = 1.
        CALL METHOD v_html->add_text
               EXPORTING
                 text          = v_text16.
        v_text16 = v_sap_recon.
        CALL METHOD v_html->add_gap
                    EXPORTING
                      width         = 1.
        CALL METHOD v_html->add_text
               EXPORTING
                 text          = v_text16.
        CALL METHOD v_html->new_line.
    <b>* Display the data
       CALL METHOD v_html->display_document
          EXPORTING
             parent             = v_contnr_top.
    *   Handle the event
       CALL METHOD o_alvgrid->list_processing_events
                            EXPORTING i_event_name = 'PRINT_TOP_OF_PAGE'.</b>
    IN PBO while populating in the output table
    FORM f9004_display_data TABLES   p_report_tab
                                     p_fieldcat.
      CALL METHOD o_alvgrid->set_table_for_first_display
        EXPORTING
           is_variant                    = w_variant
           i_save                        = c_a
           is_layout                     = w_layout
        CHANGING
           it_outtab                     = p_report_tab[]
           it_fieldcatalog               = p_fieldcat[]
        EXCEPTIONS
           invalid_parameter_combination = 1
           program_error                 = 2
           too_many_lines                = 3
           OTHERS                        = 4.
      IF sy-subrc <> 0.
        MESSAGE i000 WITH text-e06."Error in ALV report display
        LEAVE LIST-PROCESSING.
      ENDIF.
    * Create object
      IF v_event_receiver IS INITIAL.
        CREATE OBJECT v_event_receiver.
      ENDIF.
      SET HANDLER v_event_receiver->handle_print_top_of_page FOR o_alvgrid.
    <b>  SET HANDLER v_event_receiver->handle_top_of_page FOR o_alvgrid</b>.
    Hope this helps u.

  • Restrict Height of Header in ALV screen

    Hi,
    I have created ALV Tree using custom container. Now i want to rstrict the Height of the top of page as top of page containes too many rows hence in the whole report only the Header is displayed.
    Can you tell me the method for to rstrict the Height of Header on Tree ALV screen.
    CREATE OBJECT l_custom_container
          EXPORTING
                container_name = l_tree_container_name
          EXCEPTIONS
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5.
        IF sy-subrc <> 0.
          MESSAGE e003 WITH 'ERROR'.                            "#EC NOTEXT
        ENDIF.
      ENDIF.
    create tree control
      CREATE OBJECT obj_tree1
        EXPORTING
            parent              = l_custom_container
            node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
            item_selection      = 'X'
            no_html_header      = ''
            no_toolbar          = ''
        EXCEPTIONS
            cntl_error                   = 1
            cntl_system_error            = 2
            create_error                 = 3
            lifetime_error               = 4
            illegal_node_selection_mode  = 5
            failed                       = 6
            illegal_column_name          = 7.
      IF sy-subrc <> 0.
        MESSAGE e003 WITH 'ERROR'.                              "#EC NOTEXT
      ENDIF.
    create Hierarchy-header
      DATA l_hierarchy_header TYPE treev_hhdr.
      PERFORM ztest_buildhhead CHANGING l_hierarchy_header.
    create info-table for html-header
      DATA: lt_list_commentary TYPE slis_t_listheader.
      PERFORM f7800_build_comment CHANGING
                     lt_list_commentary.
    repid for saving variants
      DATA: ls_variant TYPE disvariant.
      ls_variant-report = sy-repid.
    create emty tree-control
      CALL METHOD obj_tree1->set_table_for_first_display
        EXPORTING
          is_hierarchy_header = l_hierarchy_header
          it_list_commentary  = lt_list_commentary
          i_background_id     = 'ALV_BACKGROUND'
          i_save              = 'A'
          is_variant          = ls_variant
        CHANGING
          it_outtab           = i_final2
          it_fieldcatalog     = i_fieldcat.      "table must be empty !!
    *&      Form  f7800_build_comment
          text
         <--P_LIT_LIST_COMMENTARY  text
    FORM f7800_build_comment  CHANGING  pt_list_commentary TYPE slis_t_listheader.
      DATA: lt_line  TYPE slis_listheader,
            lwa_date TYPE t_date .
      CLEAR lt_line.
    Heading
      lt_line-typ  = c_h.
      lt_line-info = 'Cash Position Report'(024).
      APPEND lt_line TO pt_list_commentary.
    Current Date
      CLEAR lt_line.
      lt_line-typ  = c_s.
      lt_line-key  = 'Date:'(022).
      lwa_date     =   sy-datum .
      CONCATENATE lwa_date-month '/' lwa_date-date '/' lwa_date-year
                                    INTO lt_line-info .
      CLEAR lwa_date .
      APPEND lt_line TO pt_list_commentary.
    Current Time
      lt_line-key  = 'Time:'(023).
      lt_line-info = sy-timlo.
      APPEND lt_line TO pt_list_commentary.
    Forest City Name
      CLEAR lt_line.
      lt_line-typ  = c_a.
      lt_line-info = 'Forest City'(021).
      APPEND lt_line TO pt_list_commentary.
    Selection Parameters
      CLEAR lt_line.
      lt_line-typ  = c_s.
      lt_line-key  = 'For Selection :'(010).
      APPEND lt_line TO pt_list_commentary.
      LOOP AT s_bukrs .
        CLEAR lt_line.
        lt_line-typ  = c_s.
        lt_line-key  = 'Facilitator Company Code :'(001).
        IF NOT s_bukrs-high IS INITIAL .
          CONCATENATE s_bukrs-low ' TO '  s_bukrs-high
                                    INTO lt_line-info
                                    SEPARATED BY space      .
        ELSE .
          lt_line-info = s_bukrs-low.
        ENDIF .
        APPEND lt_line TO pt_list_commentary.
      ENDLOOP .
      CLEAR lt_line.
      lt_line-typ  = c_s.
      lt_line-key  = 'Run Date :'(013).
      lwa_date = p_zfbdt .
      CONCATENATE lwa_date-month '/' lwa_date-date '/' lwa_date-year
                                    INTO lt_line-info .
      APPEND lt_line TO pt_list_commentary.
      LOOP AT s_prctr .
        CLEAR lt_line.
        lt_line-typ  = c_s.
        lt_line-key  = 'Profit Center :'(014).
        IF NOT s_prctr-high IS INITIAL .
          CONCATENATE s_prctr-low ' TO '  s_prctr-high
                                    INTO lt_line-info
                                    SEPARATED BY space .
        ELSE .
          lt_line-info = s_prctr-low .
        ENDIF.
        APPEND lt_line TO pt_list_commentary.
      ENDLOOP .
    ENDFORM.                    " f7800_build_comment
    Regards,
    Deepthi.

    Hi ,
    no_html_header      = 'X'
    Use this option to hide html header. Than use cl_gui_splitter to split screen into 2 parts.
    For the upper part of the screen , use cl_dd_document class to add your necessary top of page content. The other one contains alv tree.
    Set the height of splitter by thids method ;
    call method splitter->set_row_height
        exporting
          id     = 1
          height = 13.

  • 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

  • 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

  • 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

  • Showing header for ALV tree

    Hi Friends,
    I want to show header for ALV tree.
    Can anybody help me?
    Thanks,
    Rohit

    Hi,
    Go through this code sample:
    U  should give form name in i_callback_top_of_page pararameter of function:
    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_html_end_of_list = 'END_OF_LIST_HTML'
    i_grid_title = outtext
    is_layout = gd_layout
    it_fieldcat = fieldcatalog[]
    and create a form like this :
    wa_header-typ = 'S'.
    wa_header-key = 'Report '.
    Concatenate sy-repid 'Date : '
    v_date into wa_header-info
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    wa_header-info = sy-repid.
    append wa_header to t_header.
    clear wa_header.
    wa_header-typ = 'S'.
    wa_header-key = 'Report Des '.
    wa_header-info = 'ABAP Report templet'.
    append wa_header to t_header.
    clear wa_header.
    wa_header-typ = 'S'.
    wa_header-key = 'SYS ID : '.
    wa_header-info = sy-sysid.
    append wa_header to t_header.
    clear wa_header.
    wa_header-typ = 'S'.
    wa_header-key = 'Client '.
    wa_header-info = sy-mandt.
    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.
    wa_header-typ = 'S'.
    wa_header-key = 'Run Time '.
    CONCATENATE sy-uzeit(2) '.'
    sy-uzeit+4(2) '.'
    sy-uzeit+2(2) INTO wa_header-info.
    append wa_header to t_header.
    clear wa_header.
    wa_header-typ = 'S'.
    wa_header-key = 'User ID '.
    wa_header-info = sy-uname.
    append wa_header to t_header.
    clear wa_header.
    Total No. of Records Selected
    describe table it_marav 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 = 'logo.gif'.
    endform. "top-of-page
    note : this is populated using FM REUSE_ALV_COMMENTARY_WRITE.
    Hope this will he;lp u.
    Jogdand M B

  • Changing the status of heading in ALV

    HI Gurus,
    I am creating a ALV report program. When I execute the statements (with select options and parameters only)
    I get the output selection screen. But the header comes as the report program name like ZRR_ALV_LIST..
    But I need to change this to some other text of my choice.
    Please help me on this.
    Thanks & Regards,
    Gopinath GS.
    Edited by: Gopigs on May 20, 2011 8:35 AM
    Moderator Message: Basic Question.
    Edited by: kishan P on May 20, 2011 12:31 PM

    This is the simple code that I have done.
    REPORT  zrr_alv_list NO STANDARD PAGE HEADING.
    TABLES:anla.
    TYPE-POOLS: slis.
    SELECTION-SCREEN BEGIN OF BLOCK b100 WITH FRAME TITLE text-bl0.
    SELECT-OPTIONS: s_bukrs FOR anla-bukrs,
                    s_anln1 FOR anla-anln1,
                    s_anln2 for anla-anln2.
      PARAMETERS: p_date LIKE anla-erdat.
    SELECTION-SCREEN END OF BLOCK b100.
    When I execute I get the selection screen. But the header of the selection screen gives the report program name 'zrr_alv_list'.
    Instead i need to put up the header as 'ALV LIST DISPLAY'.
    Also one more query I got just now.
    How can I get the current fiscal year end date and default it to the Parameters field p_date??
    Gs.
    Edited by: Gopigs on May 20, 2011 9:00 AM

Maybe you are looking for