Doubt in Alv Report Coloumn Heading

Hi Gurus
I want to print 2 coloumn headings in ALv Report.
For eg: 1st line coloumn heading contains
              Name   Number        Date      status
            2nd line coloumn heading contains under status
                          Active      Incative            
Then if my list size is not enough to show the full details. so i can cut it in 2 lines
    if my list contains 20 coloumns
    i have to put 10 coloumns in first line
    then remaning 10 coloums in second line.
i want the solution for both the questions.
Help me.
Regards.
Bhuvana.

For the first issue
Use Top of Page Event to write a simple list which will act as a header for the alv list.
Second issue:
In the fieldcat,
Position all the first 10 coloums row_pos = 1
Position all the next 10 coloums row_pos = 2
Regards,
Lijo Joseph
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Feb 14, 2008 12:35 PM

Similar Messages

  • In ALV Report output heading is printing twice.

    Hi Experts,
    Im working on ALV Reports.
    Im printing header text by using listheader and commentary write function module.
    the problem is when i sort any column in ALV ouput the heading is printing twice.
    Again if i sort the column the heading is printed is 4 times.
    so if anybody knows the solution how we can avoid repetition of heading ,
    Please reply me as soon as possible.
    regards
    Imrangs.

    Hi Noorie,
    Thanks a lot.
    Your answer is perfect.
    Bye.
    Regards,
    Imran

  • Problem in alv report coumn header in the background while using salv

    Hi  all,
            now i am working on  alv report for this i have used salv i mean oops alv ,So here i am facing one issue while executing the report  in background
            the report column headers are not displaying properly as it is displaying in front end.
           In the back ground it is always displaying column header as data element field label short text. i have written a code to pick the long text
           but it is working fine if run the report in the frontend where as in the backgroiund it is always displaying short text but it is wrong.
    here i am attaching the output screen shots in front end and background.

    Hi Satish,
    I have tried this scenario with Reuse ALV grid 1st i found the same issue as u said in background job,
    then i set in field catalog as,
    wa_fcat-ddictxt = 'L'. Now its working fine. L stands for long text.
    Before...
    After...
    For LVC u can try the below fields in fieldcatlog.
    COLDDICTXT = 'L'.
    SELDDICTXT = 'L'

  • Some doubts in alv report

    how can i page breakin alv report ?
    what are the types of variants and events in alv report?
    how to hide field in alv?
    how to change standard pf status in alv reports?
    plz give me sample program for how to use variants in alv?
    <THREAD LOCKED. Please stop asking interview questions. There is already a lot of information out there, refer to the [Rules of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement] on how to ask a good question and learn to search>
    Edited by: Mike Pokraka on Oct 15, 2008 4:52 PM

    how can i page breakin alv report ?
    - Yes... using NEW-PAGE
    what are the types of variants and events in alv report?
    - DATA: g_variant LIKE disvariant.
    - DATA: gt_eventos          TYPE slis_t_event.
    how to hide field in alv?
    - When you define the field catalog mark this field ls_fieldcat-no_out = 'X'.
    how to change standard pf status in alv reports?
    CLEAR ls_extab.
    ls_extab-fcode = 'ZASSIG'.
    APPEND ls_extab TO extab.
    SET PF-STATUS 'Z09_STATUS' EXCLUDING extab.

  • Doubt on ALV report

    Hi gurus,
         For all of your support , I written the ALV report.Now the field is editable. But the problem is I need to save that field value what we edited.
           Actual requirment is we have some materials list.of vehicles... Those vechicles will move to repair after some days. Then in repair location, the user will enter some comments about that material like when it will be replaced like..That note data need to be saved.. When ever the users will execute the same report once again, that saved data will be appear..
          Please suggest me on this issue..
        Thanks in Advance
    Thanks and Regards
    Siri...

    Hi,
    chk out this..
    http://help.sap.com/saphelp_47x200/helpdata/en/39/27ae3a061d522ae10000000a114084/frameset.htm
    Regards,
    Arunsri

  • Doubt on ALV report download to EXCEL

    Hi All,
    i have written a report with ALV_GRID FM, by default we get the option to download the output to excel. But when we click on the download to excel, it displays the output
    in the frist page, but it also opens so many pages like
    format, header, pivot,sub1,sub1....etc.
    Pls. check the SAP standard report BCALV_TEST_FULLSCREEN, does the same thing when we do download to excel.
    How can i avoid opening so many pages in excel?
    Thanks for the help.
    Sekar

    Hi ,
    prabhu here , i think check the FM wheather u r passing all these to FM. for Excel keep export.param: --> i_save only and check.
    regards
    prabhu

  • How to add field to the header for FBL5N ALV report

    Hi,
       I need to add fields to the customer line item display ALV report(FBL5N) header part.Right now there are four fields in the header like customer, company code, name and city, after that I need to add first name last name and phone no. Can any one tell me where exactly I need to add and populate there fields to be appear in ALV output list.
    Thanks in Advance
    Swapna

    Yes I have tried, I have place a break point in that perform but it does not stop. I think that is not the correct place to added and populate fields. That routine is for populate selection screen ranges single and multiple values and parameters only.
    Thanks
    Swapna

  • Related to ALV Report

    Hi All,
    I have a doubt in ALV report.
    there is an output which consists of four fields.
    1.Employee
    2.Organizational Unit
    3.Required Compliance Training Not Completed (the specific course (D))
    4.% Compliant*
    Output should be:
       1        2            3               4
    1.a        b            c               d
                              e
                               f
    I mean there is a single row  for 4 fields.
    and in only 3 rd column  there are again 3 rows.
    how to display this.
    1..4 are columns
    a...f are data .
    Please tell me.
    Thanks,
    Geetha.

    Hi All,
    I have a doubt in ALV report.
    there is an output which consists of four fields.
    1.Employee
    2.Organizational Unit
    3.Required Compliance Training Not Completed (the specific course (D))
    4.% Compliant*
    Output should be:
       1        2            3               4
    1.a        b            c               d
                              e
                               f
    I mean there is a single row  for 4 fields.
    and in only 3 rd column  there are again 3 rows.
    how to display this.
    1..4 are columns
    a...f are data .
    Please tell me.
    Thanks,
    Geetha.

  • Download a ALV report without repetitive headers and footers.

    Hi,
    I have an ALV report with header and footer. When I download the report into excel, after every 30 (approx) records there is a header and a footer. But I do not need it.
    I need header only once and footer only once in the excel sheet. Please let me know how to achieve it.
    Thanks
    Krishna

    Hi Manish,
    if sy-pagno EQ 1 or sy-batch = 'X'.
      Call the top-of-page event code.
    endif.
    I don't think it can work as it calls the top-of-page at each page in batch mode. Better code should be something like :
    if sy-pagno EQ 1.
      Call the top-of-page event code.
    endif.
    Note : for a generic solution, I think the page number is not automatically page number 1 (for example, if we use a cover page or have printed something else before). So we'd should better use a global variable (first_time) set to 'X' just before CALL FUNCTION 'REUSE_ALV_LIST...' :
    IF first_time = 'X'.
      Call the top-of-page event code.
      CLEAR first_time.
    ENDIF.
    To All,
    I really made a big confusion in my previous answers, which were in fact about column headings (how to print them only once). Sorry about that.
    Sandra

  • Doubt regarding editable ALV report using Classes

    I need to create an ALV report and make few fields editable
    and i need to update the changes  to the corresponding database tables
    for that please suggest me some idea or provide me sample code for that
    urgent

    Hi ramesh,
    Please check this example program. I think it will help for some extent.
    [code]&----
    *& Report  ZSUMA_INTERACTIVEREPORT                                     *
    report zsuma_interactivereport.
    tables: vbak.
    data :gr_alvgrid type ref to cl_gui_alv_grid,
          gr_cc_name type scrfname value 'CC_ALV',
          gr_ccontainer type ref to cl_gui_custom_container,
          gr_fieldcat type lvc_t_fcat,
          gr_layout type lvc_s_layo,
          gr_sort type lvc_t_sort,
          gr_get_cell type lvc_t_cell,
          gr_set_cell type lvc_t_cell,
          gr_hyper type lvc_t_hype,
          gr_drop_down type lvc_t_drop,
          is_variant type disvariant,
          line_number type lvc_s_roid-row_id,
          line(5) type c ,
          cell_value type lvc_value.
    data: begin of it_vbak occurs 0,
          vbeln type vbak-vbeln,
          erdat like vbak-erdat,
          erzet like vbak-erzet,
          netwr like vbak-netwr,
          waerk like vbak-waerk,
    *Below field is useful for making the entire row with different colors.
    it must be a char of 4.and layout-info_fname should populate with
    *this field.
          rowcolor(4) type c,
    *Below field is useful for making the INDIVIDUAL CELL with different
    *colors.for this we have to include structure of type lvc_t_scol.
    *layout-ctab_fname should be populate with this field.
          cellcolor type lvc_t_scol,
    *below field is added for for providing the hyperlinks to perticular
    *field. at the time of field catalog , it_fcatalog-web_field should be
    *populate with this field.
          vbeln_hyper type int4,
    *For displaying one cell as button.we have to declare one styles
    *internal table .it has to be populate.at layout structure this table
    *name has to be populate at layout-stylename.
         cellstyle type lvc_t_styl,
          end of it_vbak.
    *&   SELECTION SCREEN
    selection-screen begin of block b1 with frame title text-001.
    select-options s_vbeln for vbak-vbeln.
    selection-screen end of block b1.
    start-of-selection.
    select vbeln
           erdat
           erzet
           netwr
           waerk
           from vbak
           into corresponding fields of table it_vbak
           where vbeln in s_vbeln.
    data: wa_cellcolor type lvc_s_scol,
          wa_style type lvc_s_styl.
    loop at it_vbak.
    FOR ROW COLORING
    if sy-tabix = 1.
    it_vbak-rowcolor = 'C511'.
    FOR PUTTING THE HYPERLINKS ON VBELN FIELD
    it_vbak-vbeln_hyper = '1'.
    modify it_vbak.
    endif.
    FOR CELL COLORING
    if sy-tabix = 2.
    wa_cellcolor-fname = 'ERZET'.
    wa_cellcolor-color-col = '6'.
    wa_cellcolor-color-int = '1'.
    wa_cellcolor-color-inv = '1'.
    append wa_cellcolor to it_vbak-cellcolor.
    modify it_vbak index 2.
    endif.
    FOR DISPLAYING THE CELL AS A BUTTON
    clear it_vbak-cellstyle.
    at last.
    read table it_vbak index sy-tabix.
    wa_style-fieldname = 'NETWR'.
    wa_style-style = cl_gui_alv_grid=>mc_style_button.
    append wa_style to it_vbak-cellstyle .
    modify it_vbak .
    endat.
    endloop.
    if not it_vbak[] is initial.
      call screen 100.
    endif.
    *CLASS DEFINITION FOR HANDLING THE EVENTS IN ALV GRID
    class gr_event_handler definition.
    public section.
    methods:handle_hotspot_click
                  for event hotspot_click of cl_gui_alv_grid
                   importing e_row_id e_column_id es_row_no.
    endclass.
    *CLASS IMPLEMENTATIONFOR HANDLING THE EVENTS IN ALV GRID
    class gr_event_handler implementation.
    method handle_hotspot_click.
    perform handle_hotspot_click using e_row_id e_column_id es_row_no.
    endmethod.
    endclass.
    *&      Form  BUILDING_FIELDCATALOG
          text
         <--P_GR_FIELDCAT  text
    form building_fieldcatalog  changing p_gr_fieldcat type lvc_t_fcat.
    data s_fieldcat type lvc_s_fcat.
    s_fieldcat-fieldname = 'VBELN'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '1'.
    s_fieldcat-coltext   = 'DOCCUMENT NO.'.
    s_fieldcat-key   = ' '.
    s_fieldcat-emphasize = 'C511'.
    s_fieldcat-web_field = 'VBELN_HYPER'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'ERDAT'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '2'.
    s_fieldcat-coltext   = 'REC CREATE DATE.'.
    s_fieldcat-emphasize = 'C311'.
    s_fieldcat-hotspot = 'X'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'ERZET'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '3'.
    s_fieldcat-coltext   = 'TIME ENTRY.'.
    *S_FIELDCAT-EMPHASIZE = 'C311'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'NETWR'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '4'.
    s_fieldcat-emphasize = 'C311'.
    s_fieldcat-coltext   = 'NET WEIGHT.'.
    s_fieldcat-do_sum   = 'X'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'WAERK'.
    s_fieldcat-outputlen = '5'.
    s_fieldcat-col_pos   = '5'.
    s_fieldcat-emphasize = 'C511'.
    s_fieldcat-coltext   = 'CURR.'.
    FOR PUTTING THE DROP DOWN BOX.
    s_fieldcat-drdn_hndl = '1'.
    s_fieldcat-edit = 'X'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    endform.                    " BUILDING_FIELDCATALOG
    *&      Form  CREATE_CCONTAINER_INSTANCE
          text
    -->  p1        text
    <--  p2        text
    form create_ccontainer_instance .
    create object gr_ccontainer
    exporting
    container_name              = gr_cc_name
    exceptions
    cntl_error                  = 1
    cntl_system_error           = 2
    create_error                = 3
    lifetime_error              = 4
    lifetime_dynpro_dynpro_link = 5
    others                      = 6
    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.                    " CREATE_CCONTAINER_INSTANCE
    *&      Form  CREATE_ALVGRID_INSTANCE
          text
    -->  p1        text
    <--  p2        text
    form create_alvgrid_instance .
    create object gr_alvgrid
      exporting
        i_parent          = gr_ccontainer
      exceptions
        error_cntl_create = 1
        error_cntl_init   = 2
        error_cntl_link   = 3
        error_dp_create   = 4
        others            = 5
    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.                    " CREATE_ALVGRID_INSTANCE
    *&      Form  DISPLAYING_ALVGRID
          text
    -->  p1        text
    <--  p2        text
    form displaying_alvgrid .
    call method gr_alvgrid->set_table_for_first_display
      exporting
       I_BUFFER_ACTIVE               =
       I_BYPASSING_BUFFER            =
       I_CONSISTENCY_CHECK           =
       I_STRUCTURE_NAME              =
        is_variant                    = is_variant
        i_save                        = 'A'
       I_DEFAULT                     = 'X'
        is_layout                     = gr_layout
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
       IT_TOOLBAR_EXCLUDING          =
        it_hyperlink                  = gr_hyper
       IT_ALV_GRAPHICS               =
       IT_EXCEPT_QINFO               =
      changing
        it_outtab                     = it_vbak[]
        it_fieldcatalog               = gr_fieldcat
       it_sort                       = gr_sort
       IT_FILTER                     =
    EXCEPTIONS
       INVALID_PARAMETER_COMBINATION = 1
       PROGRAM_ERROR                 = 2
       TOO_MANY_LINES                = 3
       others                        = 4
    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 METHOD GR_ALVGRID->GET_FRONTEND_LAYOUT
    IMPORTING
       ES_LAYOUT = GR_LAYOUT
    *GR_LAYOUT-GRID_TITLE = 'HAI ALV'.
    *CALL METHOD GR_ALVGRID->SET_FRONTEND_LAYOUT
    EXPORTING
       IS_LAYOUT = GR_LAYOUT
    endform.                    " DISPLAYING_ALVGRID
    *&      Form  REFRESH_DISPLAY_TABLE
          text
    -->  p1        text
    <--  p2        text
    form refresh_display_table .
    call method gr_alvgrid->refresh_table_display
    EXPORTING
       IS_STABLE      =
       I_SOFT_REFRESH =
      exceptions
        finished       = 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.                    " REFRESH_DISPLAY_TABLE
    *&      Form  SETTING_LAYOUT
          text
         <--P_GR_LAYOUT  text
    form setting_layout  changing p_gr_layout type lvc_s_layo.
    p_gr_layout-grid_title = 'ALV GRID USING ABAP OBJECTS'.
    p_gr_layout-zebra = 'X'.
    p_gr_layout-no_toolbar = ''.
    p_gr_layout-sel_mode = 'D'.
    p_gr_layout-info_fname = 'ROWCOLOR'.
    p_gr_layout-ctab_fname = 'CELLCOLOR'.
    p_gr_layout-stylefname = 'CELLSTYLE'.
    endform.                    " SETTING_LAYOUT
    *&      Module  STATUS_0100  OUTPUT
          text
    module status_0100 output.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.
    set pf-status 'MENU'.
    if gr_alvgrid is initial.
    *CREATING THE CONTAINER INSTANCE BY SENDING THE CONTAINER NAME( IT HAS
    *TO COINSIDE WITH COSTUM CONTROL NAME OF TRANSACTION SCREEN
    perform create_ccontainer_instance.
    perform create_alvgrid_instance.
    *VARIANT POPULATION.
    perform setting_variants changing is_variant.
    *BELOW FORM IS USEFUL TO FILL THE HYPER LINK TABLE AND WE PASS THAT
    *TABLE TO 'IT_HYPERLINK' PARAMETER IN FIRST DISPLAY METHOD.
    perform setting_hyperlinks_field changing gr_hyper.
    *TO MAKE THE COLOUMN AS DROP DOWN.
    perform setting_dropdown_column changing gr_drop_down.
    perform building_fieldcatalog changing gr_fieldcat.
    perform setting_layout changing gr_layout.
    perform setting_sorting changing gr_sort.
    perform setting_cells changing gr_set_cell.
    perform displaying_alvgrid.
    *PERFORM GETTING_CELL_DETAILS CHANGING GR_GET_CELL. " IT IS NOT WORKING
                                                 FOR ME AND I HAVE DOUBT .
    perform creating_event_object.
    *PERFORM REFRESH_DISPLAY_TABLE.
    endif.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    module user_command_0100 input.
    case sy-ucomm.
      when 'BACK'.
      leave to screen 000.
      endcase.
    endmodule.                 " USER_COMMAND_0100  INPUT
    *&      Form  SETTING_SORTING
          text
         <--P_GR_SORT  text
    form setting_sorting  changing p_gr_sort type lvc_t_sort.
    data: lr_sort type lvc_s_sort.
    lr_sort-spos = '1'.
    lr_sort-fieldname = 'VBELN'.
    lr_sort-up = 'X'.
    append lr_sort to p_gr_sort.
    lr_sort-spos = '2'.
    lr_sort-fieldname = 'ERDAT'.
    lr_sort-up = 'X'.
    append lr_sort to p_gr_sort.
    endform.                    " SETTING_SORTING
    *&      Form  GETTING_CELL_DETAILS
          text
         <--P_GR_GET_CELL  text
    form getting_cell_details  changing p_gr_get_cell.
    call method gr_alvgrid->get_selected_cells
      importing
        et_cell = p_gr_get_cell
    *CELL_VALUE = P_GR_GET_CELL-VALUE.
    endform.                    " GETTING_CELL_DETAILS
    *&      Form  SETTING_CELLS
          text
         <--P_GR_SET_CELL  text
    form setting_cells  changing p_gr_set_cell type lvc_t_cell.
    data:s_gr_set_cell type lvc_s_cell.
    s_gr_set_cell-col_id-fieldname = 'NETWR'.
    s_gr_set_cell-row_id-index = '3'.
    append s_gr_set_cell to p_gr_set_cell.
    call method gr_alvgrid->set_selected_cells
      exporting
        it_cells = p_gr_set_cell.
    endform.                    " SETTING_CELLS
    *&      Form  SETTING_HYPERLINKS_FIELD
          text
         <--P_GR_HYPER  text
    form setting_hyperlinks_field  changing p_gr_hyper type lvc_t_hype.
    data: is_hype type lvc_s_hype.
    is_hype-handle = '1'.
    is_hype-href = 'HTTP://WWW.GOOGLE.CO.IN'.
    append is_hype to p_gr_hyper.
    is_hype-handle = '2'.
    is_hype-href = 'HTTP://SDN.SAP.COM'.
    append is_hype to p_gr_hyper.
    endform.                    " SETTING_HYPERLINKS_FIELD
    *&      Form  SETTING_DROPDOWN_COLUMN
          text
         <--P_GR_DROP_DOWN  text
    form setting_dropdown_column  changing p_gr_drop_down type lvc_t_drop.
    data: wa_drop type lvc_s_drop.
    wa_drop-handle = '1'.
    wa_drop-value = '$'.
    append wa_drop to p_gr_drop_down.
    wa_drop-handle = '1'.
    wa_drop-value = 'Rs'.
    append wa_drop to p_gr_drop_down.
    wa_drop-handle = '1'.
    wa_drop-value = 'CUR'.
    append wa_drop to p_gr_drop_down.
    call method gr_alvgrid->set_drop_down_table
      exporting
        it_drop_down       = p_gr_drop_down
       IT_DROP_DOWN_ALIAS =
    endform.                    " SETTING_DROPDOWN_COLUMN
    *&      Form  SETTING_VARIANTS
          text
         <--P_IS_VARIANT  text
    form setting_variants  changing p_is_variant type disvariant.
    p_is_variant-report = sy-repid.
    endform.                    " SETTING_VARIANTS
    *&      Form  HANDLE_HOTSPOT_CLICK
          text
         -->P_E_ROW  text
         -->P_E_COLUMN  text
         -->P_E_ROW_NO  text
    form handle_hotspot_click  using    p_e_row_id type lvc_s_row
                                        p_e_column_id type lvc_s_col
                                        p_es_row_no type lvc_s_roid.
    read table it_vbak index p_es_row_no-row_id.
    if sy-subrc = 0 and p_e_column_id-fieldname = 'ERDAT'.
    line = p_es_row_no-row_id.
    line_number = p_es_row_no-row_id.
    leave to screen 200.
    endif.
    endform.                    " HANDLE_HOTSPOT_CLICK
    *&      Form  CREATING_EVENT_OBJECT
          text
    -->  p1        text
    <--  p2        text
    form creating_event_object .
    data event_handle type ref to gr_event_handler.
    create object event_handle.
    set handler event_handle->handle_hotspot_click for gr_alvgrid.
    endform.                    " CREATING_EVENT_OBJECT
    *&      Module  STATUS_0200  OUTPUT
          text
    module status_0200 output.
      set pf-status 'BB'.
    SET TITLEBAR 'xxx'.
    *LINE = LINE_NUMBER.
    endmodule.                 " STATUS_0200  OUTPUT
    *&      Module  USER_COMMAND_0200  INPUT
          text
    module user_command_0200 input.
    if sy-ucomm = 'BACK'.
    leave to screen 100.
    endif.
    endmodule.                 " USER_COMMAND_0200  INPUT[/code]
    Reward points if helpful
    Thanks,
    Suma.

  • In ALV report doubt

    Hi Expart,
    In ALV report ,what is the work of
    1) REUSE_ALV_VARIANT_DEFAULT_GET function module
    2) SLIS_LAYOUT_ALV
    Regards
    Bhabani

    Hi,
    1.SELECTING THE VARIANTS FOR INITIAL LIST DISPLAY (DEFAULT VARIANT)
    The variants in the list display can be both user-specific and general. The user can programmatically set the initial (default) variant for list display.
    The default variant can be found using the function module 'REUSE_ALV_VARIANT_DEFAULT_GET'.
    Sample code:
    CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
           EXPORTING
                i_save     = variant save condition ( A=all, U = user-specific )
           CHANGING
                cs_variant = internal table containing the program name (and the default variant---optional )
           EXCEPTIONS
                not_found  = 2.
    2.A layout is build for the report output list description USING the internal table declared above (I_LAYOUT).
    Output list description structure.
         The parameters are described under the following heads:
    •     Display options
    •     Exceptions
    •     Totals
    •     Interaction
    •     Detail screen
    •     Display variants (only for hierarchical-sequential lists)
    •     Color
    •     Other
    The layout table is of type slis_layout_alv_spec and has the following fields:
    Reward,if useful.
    Thanks,
    Chandu

  • Column Heading are not displayed in ALV Report using CL_SALV_DISPLAY?

    Hi,
       I am using CL_SALV_DISPLAY class to display data. I Created an Internal Table Dynamically based fieldcatalog which was prepared based data at run time. When i displayed data using CL_SALC_DISPALY data is display in output but column headings are not displayed.
    can anyone suggest me how to display heading in ALV using CL_SALV_DISPLAY class, My code is
          CLASS lcl_report DEFINITION
    CLASS lcl_report DEFINITION.
      PUBLIC SECTION.
        METHODS:
          display  IMPORTING l_table  TYPE string
                             l_fcat   TYPE string.
    ENDCLASS.                    "lcl_report DEFINITION
          CLASS lcl_report IMPLEMENTATION
    CLASS lcl_report IMPLEMENTATION.
      METHOD display.
        DATA: gr_table   TYPE REF TO cl_salv_table.
        DATA: gr_columns TYPE REF TO cl_salv_columns_table,
              gr_column  TYPE REF TO cl_salv_column_table,
              ls_fcat    TYPE slis_fieldcat_alv.
        DATA: gr_display TYPE REF TO cl_salv_display_settings.
        DATA: l_o_functions TYPE REF TO cl_salv_functions_list,
              l_field    TYPE string.
        FIELD-SYMBOLS : <fs_table>    TYPE STANDARD TABLE,
                        <ft_fcat>     TYPE STANDARD TABLE.
    Get the ALV object refering to the output table
        ASSIGN (l_table) TO <fs_table>.
        ASSIGN (l_fcat)  TO <ft_fcat>.
        TRY.
            cl_salv_table=>factory(
              IMPORTING
                r_salv_table = gr_table
              CHANGING
                t_table      = <fs_table> ).
          CATCH cx_salv_msg.                                "#EC NO_HANDLER
        ENDTRY.
    Add basic default functionality in the ALV report
    Functions
        l_o_functions = gr_table->get_functions( ).
        l_o_functions->set_all( abap_true ).
        gr_columns = gr_table->get_columns( ).
        gr_columns->set_headers_visible( abap_true ).
    Display the list
        gr_table->display( ).
      ENDMETHOD.                    "extract
    ENDCLASS.                    "lcl_report IMPLEMENTATION
    *& start-of-selection declaration
    START-OF-SELECTION.
      PERFORM :
      get store codes
        get_storecodes    USING      p_stfile
                          CHANGING   it_t001w,
      fetching mard data
        read_mard_data,
      preparing fieldcatalog for Final Data
        create_filedcat   USING      it_t001w
                                     it_site
                          CHANGING   it_fieldcat,
      preparing structure & internal table for Final Data
        create_final_table_structure  USING  it_fieldcat,
      prepare output data
        prepare_final_data.
    *& end-of-selection declaration
    END-OF-SELECTION.
      PERFORM :
      display data
        display_data    USING l_table
                              l_fcat.
    *&      Form  get_storecodes
    FORM get_storecodes  USING    p_p_stfile
                         CHANGING p_it_t001w  LIKE it_t001w[].
      DATA  :
    internal table for RAW
      lt_raw    TYPE truxs_t_text_data,
      rs_site   LIKE LINE OF rt_site,
      l_index   LIKE sy-tabix.
      FIELD-SYMBOLS :
    field symbol for it_t001w
      <fs_t001w>   LIKE LINE OF p_it_t001w.
    calling function module to get Stores Data from File
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
          i_line_header        = 'X'
          i_tab_raw_data       = lt_raw
          i_filename           = p_p_stfile
        TABLES
          i_tab_converted_data = p_it_t001w[]
        EXCEPTIONS
          conversion_failed    = 1
          OTHERS               = 2.
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
      SORT p_it_t001w BY werks.
      CLEAR rs_site.
      rs_site-sign   = 'I'.
      rs_site-option = 'EQ'.
      rs_site-low    = p_dccode.
      APPEND rs_site TO rt_site.
      IF it_t001w[] IS NOT INITIAL.
        LOOP AT p_it_t001w ASSIGNING <fs_t001w>.
          l_index   = sy-tabix.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = <fs_t001w>-werks
            IMPORTING
              output = <fs_t001w>-werks.
          MODIFY p_it_t001w FROM <fs_t001w> INDEX l_index.
          IF <fs_t001w>-werks GE s_site-low AND <fs_t001w>-werks LE s_site-high.
          append site to ranges
            CLEAR rs_site.
            rs_site-sign   = 'I'.
            rs_site-option = 'EQ'.
            rs_site-low    = <fs_t001w>-werks.
            APPEND rs_site TO rt_site.
            CONTINUE.
          ENDIF.
        ENDLOOP.
        SORT p_it_t001w BY werks.
        SORT rt_site.
      ENDIF.
    ENDFORM.                    " get_storecodes
    *&      Form  create_final_table_structure
    FORM create_filedcat   USING    p_it_t001w      LIKE it_t001w[]
                                    p_it_site       LIKE it_site[]
                           CHANGING p_it_fieldcat   LIKE it_fieldcat[].
      FIELD-SYMBOLS :
    field symbol for p_it_t001w
      <fs_t001w>     LIKE LINE OF p_it_t001w,
    field symbol for p_it_site
      <fs_site>      LIKE LINE OF p_it_site.
      DATA :
    fieldname
      l_fieldname    TYPE slis_fieldname,
    workarea for site ranges
      rs_site        LIKE LINE OF rt_site.
      CLEAR : l_fieldname, rs_site.
      l_fieldname    = p_dccode.
      PERFORM
    prepare fieldcatalog
      build_fieldcatalog USING :   'MTART'      'CHAR'        '5'  ,
                                   'MTBEZ'      'CHAR'        '25' ,
                                   'MATKL'      'CHAR'        '6'  ,
                                   'WGBEZ'      'CHAR'        '20' ,
                                   'MATNR'      'CHAR'        '18' ,
                                   'MAKTX'      'CHAR'        '30' ,
                                    l_fieldname 'CHAR'        '17' .
    create header for excel
      PERFORM create_excel_header USING  : 'Division',
                                           'Divsion Description',
                                           'MC Code',
                                           'MC Description',
                                           'Article',
                                           'Article Description',
                                            l_fieldname.
    loop for creating fieldcatalog
      LOOP AT it_site ASSIGNING <fs_site>.
        READ TABLE it_t001w ASSIGNING <fs_t001w> WITH KEY werks = <fs_site>-werks
                                                                  BINARY SEARCH.
        IF sy-subrc = 0           AND <fs_t001w> IS ASSIGNED AND
           <fs_site> IS ASSIGNED  AND <fs_site>-stock GT 0.
          CLEAR : l_fieldname, rs_site.
          l_fieldname    = <fs_site>-werks.
        prepare fieldcatalog
          PERFORM build_fieldcatalog USING : l_fieldname    'CHAR'   '17'.
        create header for excel
          PERFORM create_excel_header USING  l_fieldname  .
          CONTINUE.
        ENDIF.
      ENDLOOP.
      l_fcat  = 'it_fieldcat[]'.
    ENDFORM.                    " create_final_table_structure
    *&      Form  build_fieldcatalog
    FORM build_fieldcatalog  USING    p_fieldname      TYPE slis_fieldname
                                      p_datatype       TYPE datatype_d
                                      p_length         TYPE intlen.
      DATA : ls_fieldcat    LIKE LINE OF it_fieldcat.
      CLEAR  : ls_fieldcat.
      ls_fieldcat-fieldname   = p_fieldname.
      ls_fieldcat-datatype    = p_datatype.
      ls_fieldcat-intlen      = p_length.
      APPEND ls_fieldcat TO it_fieldcat.
    ENDFORM.                    " build_fieldcatalog
    *&      Form  create_final_table_structure
    FORM create_final_table_structure  USING    p_it_fieldcat.
    Create dynamic internal table and assign to FS
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fieldcat
        IMPORTING
          ep_table        = t_table.
      ASSIGN t_table->*  TO <ft_final>.
    ENDFORM.                    " create_final_table_structure
    *&      Form  create_excel_header
    FORM create_excel_header  USING    p_p_fieldname.
      DATA : ls_header  LIKE LINE OF it_header.
      CLEAR ls_header.
      ls_header-col_name  = p_p_fieldname.
      APPEND ls_header TO it_header.
    ENDFORM.                    " create_excel_header
    *&      Form  prepare_final_data
    FORM prepare_final_data .
      DATA          : l_matnr       LIKE g_matnr,
                      l_werks       LIKE g_werks,
                      l_index       LIKE sy-tabix.
      FIELD-SYMBOLS : <fs_mard>     LIKE LINE OF it_mard.
    Getting No. of Lines in IT_MARD internal table
      DESCRIBE TABLE it_mard LINES g_lines.
      LOOP AT it_mard ASSIGNING <fs_mard>.
        l_index    = sy-tabix.
        IF l_matnr IS INITIAL.
          l_matnr  = <fs_mard>-matnr.
          CLEAR : l_werks.
          l_werks    = <fs_mard>-werks.
          UNASSIGN : <fs_value>, <fs_final>.
        Create dynamic work area and assign to FS
          CREATE DATA t_line LIKE LINE OF <ft_final>.
          ASSIGN t_line->*   TO <fs_final>.
          ASSIGN COMPONENT 'MATNR'  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>        = <fs_mard>-matnr.
          ASSIGN COMPONENT l_werks  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>        = <fs_value> + <fs_mard>-labst.
        getting Article Type,MC & its Descriptions
          PERFORM get_other_data    USING     l_matnr
                                              l_werks.
        ELSEIF l_matnr <> <fs_mard>-matnr.
          APPEND <fs_final> TO <ft_final>.
          CLEAR l_matnr.
          l_matnr  = <fs_mard>-matnr.
          CLEAR : l_werks.
          l_werks    = <fs_mard>-werks.
          UNASSIGN : <fs_value>, <fs_final>.
        Create dynamic work area and assign to FS
          CREATE DATA t_line LIKE LINE OF <ft_final>.
          ASSIGN t_line->*   TO <fs_final>.
          ASSIGN COMPONENT 'MATNR'  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>        = <fs_mard>-matnr.
          ASSIGN COMPONENT l_werks  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>        = <fs_value> + <fs_mard>-labst.
        getting Article Type,MC & its Descriptions
          PERFORM get_other_data    USING     l_matnr
                                             l_werks.
        ELSE.
          CLEAR : l_werks.
          l_werks    = <fs_mard>-werks.
          ASSIGN COMPONENT l_werks  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>        = <fs_value> + <fs_mard>-labst.
        ENDIF.
        IF l_index = g_lines.
          APPEND <fs_final> TO <ft_final>.
        ENDIF.
      ENDLOOP.
      l_table  = '<ft_final>[]'.
    ENDFORM.                    " prepare_final_data
    *&      Form  get_other_data
    FORM get_other_data  USING    p_l_matnr
                                  p_l_werks.
      FIELD-SYMBOLS : <fs_mara>     LIKE LINE OF it_mara,
                      <fs_t023t>    LIKE LINE OF it_t023t,
                      <fs_t134t>    LIKE LINE OF it_t134t,
                      <fs_makt>     LIKE LINE OF it_makt.
      READ TABLE it_mara ASSIGNING <fs_mara> WITH KEY matnr = p_l_matnr.   " BINARY SEARCH.
      IF sy-subrc = 0 AND <fs_mara> IS ASSIGNED.
        ASSIGN COMPONENT 'MTART'  OF STRUCTURE <fs_final> TO <fs_value>.
        <fs_value>        = <fs_mara>-mtart.
        ASSIGN COMPONENT 'MATKL'  OF STRUCTURE <fs_final> TO <fs_value>.
        <fs_value>        = <fs_mara>-matkl.
        READ TABLE it_makt  ASSIGNING <fs_makt>  WITH KEY matnr =  <fs_mara>-matnr   BINARY SEARCH.
        IF sy-subrc = 0 AND <fs_makt> IS ASSIGNED.
          ASSIGN COMPONENT 'MAKTX'  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>        = <fs_makt>-maktx.
        ENDIF.
        READ TABLE it_t023t ASSIGNING <fs_t023t> WITH KEY matkl = <fs_mara>-matkl  BINARY SEARCH.
        IF sy-subrc = 0 AND <fs_t023t> IS ASSIGNED.
          ASSIGN COMPONENT 'WGBEZ'  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>      = <fs_t023t>-wgbez.
        ENDIF.
        READ TABLE it_t134t ASSIGNING <fs_t134t> WITH KEY mtart = <fs_mara>-mtart  BINARY SEARCH.
        IF sy-subrc = 0 AND <fs_t134t> IS ASSIGNED.
          ASSIGN COMPONENT 'MTBEZ'  OF STRUCTURE <fs_final> TO <fs_value>.
          <fs_value>      = <fs_t134t>-mtbez.
        ENDIF.
      ENDIF.
    ENDFORM.                    " get_other_data
    *&      Form  display_data
          text
    FORM display_data  USING    p_l_table
                                p_l_fcat.
      DATA:
    Variable for Object Creation
      o_report TYPE REF TO lcl_report.
      CREATE OBJECT o_report.
      o_report->display( EXPORTING l_table = p_l_table
                                   l_fcat  = p_l_fcat ).
    ENDFORM.                    " display_data

    I don't know how to read the code you pasted or I would have checked this myself.
    Do your fields in the internal table reference dictionary objects or elementary types? If not using dictionary types, the column names will be blank by default. If you can't change your fields to be dictionary types, you can try this to change the column names:
    I made a method inside my local class to add the names:
            call method set_colname
              EXPORTING iv_tab = alv_tab
                        iv_colid = 'xxxx'  "fieldname from the table
                        iv_stxt = text-t54
                        iv_mtxt = text-t55
                        iv_ltxt = text-t55.
    METHOD set_colname .
      data:
              alv_cols type REF TO cl_salv_columns_table,
              alv_col type REF TO cl_salv_column.
      TRY .
    *... Change fieldnames
            call METHOD iv_tab->get_columns RECEIVING value = alv_cols.
            call method alv_cols->get_column EXPORTING columnname = iv_colid RECEIVING value = alv_col.
            IF iv_stxt <> ''.
              CALL METHOD alv_col->set_short_text EXPORTING value = iv_stxt.
            ENDIF.
            IF iv_mtxt <> ''.
              CALL METHOD alv_col->set_medium_text EXPORTING value = iv_mtxt.
            ENDIF.
            IF iv_ltxt <> ''.
              CALL METHOD alv_col->set_long_text EXPORTING value = iv_ltxt.
            ENDIF.
       CATCH cx_salv_not_found.
      ENDTRY.
    ENDMETHOD. "set_colname

  • Change Column Heading in ALV Report

    Hi,
    I have developed a ALV Report, showing correct output.
    Problem is that Column Heading is not showing correct...means it is showing as per field name. But We want to change as per our understand. i.e. One column heading is like Unrestricted Stock but we want Unrestricted Stock...(BILF is an indicator)..
    We have write in the code..
    FORM build_fieldcat10.
      CLEAR fieldcat_ln.
      ADD 1 TO col_pos.
      fieldcat_ln-ref_tabname = 'MARD'.
      fieldcat_ln-fieldname   = 'LABST'.
      fieldcat_ln-seltext_m   = 'BILF Unrest.Stock'.
      fieldcat_ln-key         = space.
      fieldcat_ln-do_sum      = space.
      fieldcat_ln-col_pos     = col_pos.
      fieldcat_ln-no_out      = space.
      fieldcat_ln-qfieldname  = space.
      fieldcat_ln-hotspot     = space.
      APPEND fieldcat_ln TO fieldcat.
    ENDFORM.                    " BUILD_FIELDCAT1
    But after change the selection text...not showing correct text..How can i change Column heading???
    Please help me..

    Thanks a lot dear..
    My problem resolved by using SCRTEXT_L.

  • Header prob. in ALV report

    Hi All,
    Hope you all are doing fine!!!
    In the below program am trying to print the top-of-page/header in alv report,,but am unable to do it..
    Am working on 4.6c version,,,,,its working fine in ECC 6.0 but i really dont understand why its not working in 4.6c...AM JUST PASTING THE ALV PART...!!!
    Pls. do the needful
    REPORT yjack  LINE-SIZE 132
                    LINE-COUNT 65
                    NO STANDARD PAGE HEADING.
    DATA: /sie/swe_ag0_rdo TYPE /sie/swe_ag0_rdo,
          wa_tvko TYPE tvko,
          /sie/swe_ag0_raa TYPE /sie/swe_ag0_raa,
          wa_kna1 TYPE kna1,
          wa_t001 TYPE t001,
          wa_tvkot TYPE tvkot,
          /sie/swe_ag0_con TYPE /sie/swe_ag0_con,
          /sie/swe_ag0_r02 TYPE /sie/swe_ag0_r02.
    TYPES: BEGIN OF ty_itab,
             bukrs TYPE /sie/swe_ag0_rdo-bukrs,
             vkorg TYPE /sie/swe_ag0_rdo-vkorg,
             zclpr TYPE /sie/swe_ag0_rdo-zclpr,
             zcdaz TYPE /sie/swe_ag0_rdo-zcdaz,
             vbeln TYPE /sie/swe_ag0_rdo-vbeln,
             posnr TYPE /sie/swe_ag0_rdo-posnr,
             vbtyp TYPE /sie/swe_ag0_rdo-vbtyp,
             zidag TYPE /sie/swe_ag0_rdo-zidag,
             zimpp TYPE /sie/swe_ag0_rdo-zimpp,
             zimco TYPE /sie/swe_ag0_rdo-zimco,
             zimmg TYPE /sie/swe_ag0_rdo-zimmg,
             fkdat TYPE /sie/swe_ag0_rdo-fkdat,
             zstre TYPE /sie/swe_ag0_rdo-zstre,
             vtweg TYPE /sie/swe_ag0_rdo-vtweg,
             kunrg TYPE /sie/swe_ag0_rdo-kunrg,
          END OF ty_itab.
    TYPES: BEGIN OF ty_itab2,
             bukrs TYPE /sie/swe_ag0_rdo-bukrs,
             vkorg TYPE /sie/swe_ag0_rdo-vkorg,
             zcdaz TYPE /sie/swe_ag0_rdo-zcdaz,
             fkdat TYPE /sie/swe_ag0_rdo-fkdat,
             vbeln TYPE /sie/swe_ag0_rdo-vbeln,
             zimpp TYPE /sie/swe_ag0_rdo-zimpp,
             zimco(5) TYPE p DECIMALS 2,
             zimmg(5) TYPE p DECIMALS 2,
             resid(6) TYPE p DECIMALS 2,
             kunrg TYPE /sie/swe_ag0_rdo-kunrg,
             name1 TYPE kna1-name1,
          END OF ty_itab2.
    type-pools: slis.
    types: begin of ty_final,
           bukrs type char29,
           vkorg type char24,
           mese  type char17,
           gjahr type gjahr,
           agent type char45,
           vbeln type vbeln,
           fkdat type fkdat,
           zimpp type /SIE/SWE_AG0_ZIMPP,
           zimco type /SIE/SWE_AG0_ZIMCO,
           zimmg type /SIE/SWE_AG0_ZIMMG,
           resid(5) TYPE p DECIMALS 2,
           kunrg type kunrg,
           name1 type NAME1_GP,
           end of ty_final.
    data: it_final type table of ty_final,
          wa_final type ty_final,
          g_bukrs(29) type c,
          g_vkorg(24) type c.
    data: it_fieldcat type slis_t_fieldcat_alv,
          it_layout type slis_layout_alv,
          it_list_top_of_page type slis_t_listheader,
          it_events type slis_t_event,
          wa_events type slis_alv_event,
          it_headings type slis_t_listheader,
          wa_headings type slis_listheader.
    constants: c_h type c value 'H',
               c_s type c value 'S'.
    field-symbols: <fs_final> type ty_final.
    DATA: it_itab TYPE TABLE OF ty_itab,
          it_itab2 TYPE TABLE OF ty_itab2,
          wa_itab TYPE ty_itab,
          wa_itab2 TYPE ty_itab2.
    DATA: wa_app TYPE ty_itab.
    DATA: w_var TYPE c VALUE '1',
          w_com_mese(9) TYPE c,
          w_flag_st TYPE c.
    $$ Selection-screen
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN BEGIN OF BLOCK parametri WITH FRAME TITLE text-001.
    BEG MOD ESX00596 IMS:100276414 TR:SWIK9A04W7 11.04.2007
    *PARAMETERS: p_bukrs LIKE /sie/swe_ag0_rdo-bukrs OBLIGATORY.
    *PARAMETERS: p_vkorg LIKE /sie/swe_ag0_rdo-vkorg OBLIGATORY.
    PARAMETERS: p_bukrs TYPE /sie/swe_ag0_rdo-bukrs OBLIGATORY.
    PARAMETERS: p_vkorg TYPE /sie/swe_ag0_rdo-vkorg OBLIGATORY.
    SELECT-OPTIONS: s_zcdaz FOR /sie/swe_ag0_rdo-zcdaz OBLIGATORY
                            MATCHCODE OBJECT /sie/swe_ag0_zaa.
    PARAMETERS: mese(2) TYPE n OBLIGATORY,
                anno TYPE /sie/swe_ag0_rdo-gjahr OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK parametri.
    SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: c1 AS CHECKBOX.
    SELECTION-SCREEN COMMENT 8(31) text-006 FOR FIELD c1.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN: END OF BLOCK b1.
    DATA: w_cd_a   TYPE /sie/swe_ag0_rdo-vtweg,
          w_cd_gen TYPE /sie/swe_ag0_rdo-vtweg,
          w_cd_di  TYPE /sie/swe_ag0_rdo-vtweg,
          w_cd_re  TYPE /sie/swe_ag0_rdo-vtweg,
          w_cd_te  TYPE /sie/swe_ag0_rdo-vtweg,
          w_cd_ca  TYPE /sie/swe_ag0_rdo-vtweg.
    INITIALIZATION.
      PERFORM selezione_hard_coding.
    $$ At selection-screen
    AT SELECTION-SCREEN.
      PERFORM controlli.
    $$ Top-of-page
    TOP-OF-PAGE.
      PERFORM top_of_page.
    $$ Start-of-selection
    START-OF-SELECTION.
      perform build_events.
      PERFORM carica_itab.
      PERFORM carica_itab2.
      PERFORM stampa.
    END-OF-SELECTION.
    IF C1 EQ 'X'.
    perform fill-fieldcatalog.
    perform display_alv.
    ENDIF.
    *&      Form  fill-fieldcatalog
          text
    -->  p1        text
    <--  p2        text
    form fill-fieldcatalog.
    data: l_fieldcat TYPE slis_fieldcat_alv.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'BUKRS'.
          l_fieldcat-col_pos       = 1.
          l_fieldcat-seltext_l     = 'Company'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'VKORG'.
          l_fieldcat-col_pos       = 2.
          l_fieldcat-seltext_l     = 'Comm. Organization'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'MESE'.
          l_fieldcat-col_pos       = 3.
          l_fieldcat-seltext_l     = 'Month'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'GJAHR'.
          l_fieldcat-col_pos       = 4.
          l_fieldcat-seltext_l     = 'Year'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'AGENT'.
          l_fieldcat-col_pos       = 5.
          l_fieldcat-seltext_l     = 'AGENT'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'VBELN'.
          l_fieldcat-col_pos       = 6.
          l_fieldcat-seltext_l     = 'Invoice'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'FKDAT'.
          l_fieldcat-col_pos       = 7.
          l_fieldcat-seltext_l     = 'Date'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'ZIMPP'.
          l_fieldcat-col_pos       = 8.
          l_fieldcat-seltext_l     = 'Taxable'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'ZIMCO'.
          l_fieldcat-col_pos       = 9.
          l_fieldcat-seltext_l     = 'Tot.Comm.'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'ZIMMG'.
          l_fieldcat-col_pos       = 10.
          l_fieldcat-seltext_l     = 'Settle'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'RESID'.
          l_fieldcat-col_pos       = 11.
          l_fieldcat-seltext_l     = 'Accruing'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'KUNRG'.
          l_fieldcat-col_pos       = 12.
          l_fieldcat-seltext_l     = 'Cust.Code'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'NAME1'.
          l_fieldcat-col_pos       = 13.
          l_fieldcat-seltext_l     = 'Company Name'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
    endform.                    " fill-fieldcatalog
    *&      Form  display_alv
          text
    -->  p1        text
    <--  p2        text
    form display_alv.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = sy-repid
       I_CALLBACK_TOP_OF_PAGE            = 'PRINT_HEADING'
       IS_LAYOUT                         = it_layout
       IT_FIELDCAT                       = it_fieldcat
       IT_EVENTS                         = it_events
      TABLES
        t_outtab                          = it_final
    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  build_events
          text
         -->P_IT_EVENTS[]  text
    form build_events.
    clear wa_events.
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
       I_LIST_TYPE           = 0
    IMPORTING
       ET_EVENTS             = it_events.
    read table it_events into wa_events with key name = 'TOP_OF_PAGE'.
    if sy-subrc eq 0.
    wa_events-form = 'PRINT_HEADING'.
    modify it_events from wa_events transporting form
        where name = 'TOP_OF_PAGE'.
    endif.
    endform.                    " build_events
    form PRINT_HEADING.
    clear wa_headings.
    wa_headings-typ = 'H'.
    wa_headings-info = 'DEMO FOR ALV!!!'.
    append wa_headings to it_headings.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        it_list_commentary       = it_headings.
    endform.
    Thanks n Regards
    Jack

    Hi friend,
    I think u have to remove below lines in your program because FM 'REUSE_ALV_GRID_DISPLAY' will call directly Form 'PRINT_HEADING'   for TOP-OF-PAGE event through table 'it_events' :
    Remove lines:
        TOP-OF-PAGE.
        PERFORM top_of_page.
    Also remove the parameter
    I_CALLBACK_TOP_OF_PAGE = 'PRINT_HEADING' in  FM 'REUSE_ALV_GRID_DISPLAY'
    Also put a breakpoint in your program in the line,
    START-OF-SELECTION.
    perform build_events.
    See whether 'form' 'name' gets populated in table 'it_events'  or not.
    See sample report and compare.
    REPORT zawi_assign3 NO STANDARD PAGE HEADING.
    TYPE-POOLS: slis.
    DATA: BEGIN OF gt_outtab OCCURS 0.
            INCLUDE STRUCTURE ekpo.
    DATA: END OF gt_outtab,
          gs_layout TYPE slis_layout_alv,
          g_exit_caused_by_caller,
          gs_exit_caused_by_user TYPE slis_exit_by_user,
          g_repid LIKE sy-repid.
    DATA:
        gt_events      TYPE slis_t_event,
        gt_list_top_of_page TYPE slis_t_listheader,
        g_status_set   TYPE slis_formname VALUE 'PF_STATUS_SET',
        g_user_command TYPE slis_formname VALUE 'USER_COMMAND',
        g_top_of_page  TYPE slis_formname VALUE 'TOP_OF_PAGE',
        g_top_of_list  TYPE slis_formname VALUE 'TOP_OF_LIST',
        g_end_of_list  TYPE slis_formname VALUE 'END_OF_LIST'.
    DATA: gs_variant LIKE disvariant,
          g_save.
    INITIALIZATION.
      g_repid = sy-repid.
      PERFORM layout_init USING gs_layout.
      PERFORM eventtab_build USING gt_events[].
      gs_variant-report = g_repid.
      g_save           = 'X'.
    START-OF-SELECTION.
      PERFORM select_data TABLES gt_outtab.
    END-OF-SELECTION.
      PERFORM comment_build USING gt_list_top_of_page[].
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
             i_background_id    = 'ALV_BACKGROUND'
             i_buffer_active    = 'X'
             i_callback_program = g_repid
             i_structure_name   = 'ekpo'
             is_layout          = gs_layout
             i_save             = g_save
             is_variant         = gs_variant
             it_events          = gt_events[]
        IMPORTING
             e_exit_caused_by_caller = g_exit_caused_by_caller
             es_exit_caused_by_user  = gs_exit_caused_by_user
        TABLES
             t_outtab = gt_outtab
        EXCEPTIONS
             program_error = 1
             OTHERS        = 2.
      IF sy-subrc = 0.
        IF g_exit_caused_by_caller = 'X'.
        ELSE.
          IF gs_exit_caused_by_user-back = 'X'.
          ELSE.
            IF gs_exit_caused_by_user-exit = 'X'.
            ELSE.
              IF gs_exit_caused_by_user-cancel = 'X'.
              ELSE.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.
      ELSE.
      ENDIF.
    FORM select_data TABLES rt_outtab LIKE gt_outtab[].
      SELECT * FROM ekpo INTO CORRESPONDING FIELDS
                       OF TABLE rt_outtab
                       UP TO 00030 ROWS.
    ENDFORM.                    "SELECT_DATA
    FORM layout_init USING rs_layout TYPE slis_layout_alv.
      rs_layout-detail_popup      = 'X'.
      rs_layout-edit = 'X'.
    ENDFORM.                    "LAYOUT_INIT
    FORM eventtab_build USING rt_events TYPE slis_t_event.
    *"Registration of events to happen during list display
      DATA: ls_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = rt_events.
      READ TABLE rt_events WITH KEY name = slis_ev_top_of_page
                               INTO ls_event.
      IF sy-subrc = 0.
        MOVE g_top_of_page TO ls_event-form.
        APPEND ls_event TO rt_events.
      ENDIF.
    ENDFORM.                    "EVENTTAB_BUILD
    FORM top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          i_logo             = 'ENJOYSAP_LOGO'
          it_list_commentary = gt_list_top_of_page.
    ENDFORM.                    "TOP_OF_PAGE
    FORM comment_build USING lt_top_of_page TYPE
                                            slis_t_listheader.
      DATA: ls_line TYPE slis_listheader.
      CLEAR ls_line.
      ls_line-typ  = 'H'.
      ls_line-info = text-100.
      APPEND ls_line TO lt_top_of_page.
      CLEAR ls_line.
      ls_line-typ  = 'S'.
      ls_line-key  = 'Program'.
      ls_line-info = sy-repid.
      APPEND ls_line TO lt_top_of_page.
      CLEAR ls_line.
      ls_line-typ  = 'S'.
      ls_line-key  = 'User'.
      ls_line-info = sy-uname.
      APPEND ls_line TO lt_top_of_page.
    ENDFORM.                    "COMMENT_BUILD
    Might solve your problem.
    Thanks.
    Edited by: Sap Fan on Feb 20, 2009 9:50 AM
    Edited by: Sap Fan on Feb 20, 2009 9:52 AM
    Edited by: Sap Fan on Feb 20, 2009 9:54 AM

  • Issue in displaying header details in ALV report

    Hi,
    I have used slis_t_listheader and REUSE_ALV_COMMENTARY_WRITE to display the header details in ALV report.I want the details to be displayed as below.
    Requester : ----------------------                                                                               Page: 1
    Program: -----------------------                                                                                Date:---------
                                                                     Title of Report
    But when I use the structure slis_t_listheader to display the header details,all the fields are coming one below the other.
    How can I get the fields as shown in the above format
    Edited by: Abaper12345 on Jun 25, 2009 7:54 AM

    Hi,
    Go through following code... its showing the data exactly the way you want....
    REPORT  TEST3.
    TYPE-POOLS:slis.
    TABLES:MARA.
    *Type Declaration
    TYPES:BEGIN OF t_mara,
          matnr TYPE mara-matnr,
          ersda TYPE mara-ersda,
          ernam TYPE mara-ernam,
          END OF t_mara.
    *Internal Table
    data:it_mara type standard table of t_mara.
    *Work Area
    data:wa_mara type t_mara.
    DATA:i_repid TYPE sy-repid .
    i_repid = sy-repid.
    *Declaration for field catalog
    DATA : fcat TYPE slis_t_fieldcat_alv,
           wa_fcat TYPE slis_fieldcat_alv.
    *Declaration for Layout
    data : WA_LAYOUT type SLIS_LAYOUT_ALV.
    *Initializing ColumnWidth_Optimize For Layout
      WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    START-OF-SELECTION
    START-OF-SELECTION.
    *Fetching data into internal tables
      PERFORM get_data.
    *Buil Fieldcatalog
      PERFORM build_fcat.
    *Display ALV Report
      PERFORM alv_display.
    *Build Fieldcat
    FORM build_fcat .
      wa_fcat-tabname = 'IT_MARA'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-inttype = 'C'.
      wa_fcat-seltext_m = 'Material Number'.
      wa_fcat-outputlen = 25.
      wa_fcat-col_pos = 1.
      APPEND wa_fcat TO fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'IT_MARA'.
      wa_fcat-fieldname = 'ERSDA'.
      wa_fcat-inttype = 'C'.
      wa_fcat-seltext_m = 'Date'.
      wa_fcat-outputlen = 25.
      wa_fcat-col_pos = 1.
      APPEND wa_fcat TO fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'IT_MARA'.
      wa_fcat-fieldname = 'ERNAM'.
      wa_fcat-inttype = 'C'.
      wa_fcat-seltext_m = 'User'.
      wa_fcat-outputlen = 25.
      wa_fcat-col_pos = 1.
      APPEND wa_fcat TO fcat.
      CLEAR wa_fcat.
      endform.
    *&      Form  GET_DATA
          text
    -->  p1        text
    <--  p2        text
    form GET_DATA .
    select matnr ersda ernam from mara into table it_mara.
    endform.                    " GET_DATA
    *&      Form  ALV_DISPLAY
          text
    -->  p1        text
    <--  p2        text
    form ALV_DISPLAY .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       I_CALLBACK_PROGRAM                = i_repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
       I_CALLBACK_HTML_TOP_OF_PAGE       = 'HTML_TOP_OF_PAGE'
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       IT_FIELDCAT                       = fcat
      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.
    endform.                    " ALV_DISPLAY
    *&      Form  html_top_of_page " I_CALLBACK_HTML_TOP_OF_PAGE  "
    FORM html_top_of_page USING document TYPE REF TO cl_dd_document.
    CALL METHOD document->add_text
      EXPORTING
        text          = 'Program'
        sap_color     = document->list_group
        sap_fontstyle = document->standard
       sap_emphasis  = document->strong.
    CALL METHOD document->new_line
      EXPORTING
        repeat = 1
    CALL METHOD document->add_text
      EXPORTING
        text          = 'Requester'
        sap_color     = document->list_group
        sap_fontstyle = document->standard
       sap_emphasis  = document->strong.
    CALL METHOD document->new_line
      EXPORTING
        repeat = 1
    CALL METHOD document->add_gap
      EXPORTING
         width      = 125
    CALL METHOD document->add_text
      EXPORTING
        text          = 'This Is Test Data'
        sap_color     = document->list_group
       sap_fontsize  = document->LARGE
       sap_fontstyle = document->standard
       sap_emphasis  = document->strong.
    ENDFORM.                    "HTML_TOP_OF_PAGE
    Thanks & Regards
    Ashu SIngh

Maybe you are looking for