Dynamic Header in ALV output

Hi All,
I have requirement like below
i have company code in the selection screen as select options.
i need to give the output in such a way that
suppose the end user given the company code as 100 110 120 then  i need to display in the
<b>header section</b>
100 - description
and in list (body) the should contain the records related to 100(Company code ) only
in the next page
<b>header section</b> contains the
110 - description
and in the ALV list needs to contain only the records related to 110.
and so on.
Please help me how to proceed; I have bit knowledge in container programming.
Thanks in Advance
Chand

Hi,
I did something very similar to your requirement.
There is a predefined event for Reuse_alv_list_display called 'BEFORE_LINE_OUTPUT'. In the event table, you have to specify the <event>-name = 'BEFORE_LINE_OUTPUT' and the <event>-form = 'ALV_BEFORE_LINE_OUTPUT'.
Then you need a form like
FORM alv_before_line_output
  USING ps_lineinfo TYPE kkblo_lineinfo.                    "#EC CALLED
  FIELD-SYMBOLS:
    <prot> TYPE typ_prot.
  READ TABLE gt_prot INDEX ps_lineinfo-tabindex
    ASSIGNING <prot>.
  CHECK g_file_no <> <prot>-file_no.
  g_file_no = <prot>-file_no.
  NEW-PAGE.
ENDFORM.                    "alv_before_line_output
In my program the global table displayed in ALV was gt_prot (of line type typ_prot) and the requirement was to start a new page for each file processed. The form stores the file processed in
g_file_no. If a new file is processed, a NEW-PAGE will trigger the TOP_OF_PAGE event of the alv. I will not copy the form here because we also issued some statistical values, system and user informations and so on.
But I hope you get it done.
The only remaining issue may be that the before_line_output event will cost some time because it is triggered for every output line. But my report was still quite fast.
regards,
Clemens

Similar Messages

  • Repetition of header in ALV output once excel download is selected

    Hi Experts,
    I have alv report where I use FM as below
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program     = w_repid
          i_callback_top_of_page = 'TOP-OF-PAGE'  "see FORM
          is_layout              = l_layout
          it_fieldcat            = lt_fieldcat
          it_sort                = l_sort
          i_save                 = 'X'
        TABLES
          t_outtab               = itab
        EXCEPTIONS
          program_error          = 1
          OTHERS                 = 2.  IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    and top of page as below
    FORM top-of-page.
    * Title
      w_header-typ  = 'H'.
      w_header-info = text-033.
      APPEND w_header TO t_header.
      CLEAR w_header.
    * Report Name
      w_header-typ  = 'S'.
      w_header-key = text-034.
      w_header-info =  sy-repid.
      APPEND w_header TO t_header.
      CLEAR w_header.
    * Date
      w_header-typ  = 'S'.
      w_header-key = text-035.
      CONCATENATE  sy-datum6(2) '.'+
                   sy-datum4(2) '.'+
                   sy-datum(4) INTO w_header-info.
      APPEND w_header TO t_header.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = t_header.
    ENDFORM.                    "top-of-page
    Its displaying well in output, but when I select excel download, the header is getting printed 4 times in the alv output and in the excel download it is printing twice. Please advise how to keep the header once. Note : I am not using any paging concept, simple header at the top.
    Please advise.
    Regards,
    Kiran.

    Hi kiran,
    While creating top-of-page,
    You have to refresh your header internal table before populating it with data i.e,
    FORM TOP.
    Refresh IT_HEADER                   -->with this the header text will not get repeatedly printed
    WA_HEADER-TYP = 'S'.
    WA_HEADER-KEY = TEXT-001.
    WA_HEADER-INFO = SY-REPID.
    APPEND WA_HEADER TO IT_HEADER.
    CLEAR WA_HEADER.
    WA_HEADER-TYP = 'S'.
    WA_HEADER-KEY = TEXT-002.
    WA_HEADER-INFO = SY-UNAME.
    APPEND WA_HEADER TO IT_HEADER.
    CLEAR WA_HEADER.
    WA_HEADER-TYP = 'S'.
    WA_HEADER-KEY = TEXT-003.
    WA_HEADER-INFO = SY-DATUM.
    APPEND WA_HEADER TO IT_HEADER.
    CLEAR WA_HEADER.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        it_list_commentary       = IT_HEADER
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    ENDFORM.
    Hope it helps you
    Regards
    Mansi

  • Dynamic header in ALV

    Hi gurus,
    header must be populate on change of every new PO Number.
    how do i do it in ALV.

    Hi
    Look at the sample code.
    TYPE-POOLS: abap,
                col.
    *& Dynamic Table
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
                   <dyn_wa>,
                   <fs>.
    DATA: gt_dyn          TYPE REF TO data,
          gw_dyn          TYPE REF TO data,
          r_table         TYPE REF TO cl_salv_table,
          r_header        TYPE REF TO cl_salv_form_element,
          r_footer        TYPE REF TO cl_salv_form_element,
          r_columns_table TYPE REF TO cl_salv_columns_table,
          r_column_table  TYPE REF TO cl_salv_column_table,
          r_datadescr     TYPE REF TO cl_abap_datadescr,
          r_structdescr   TYPE REF TO cl_abap_structdescr,
          gw_component    TYPE abap_componentdescr,
          gt_component    TYPE abap_component_tab.
    START-OF-SELECTION.
      PERFORM build_dynamic_table.
      PERFORM get_data.
    END-OF-SELECTION.
      PERFORM display_report.
    *&      Form  build_dynamic_table
    FORM build_dynamic_table .
      DATA: l_idx    TYPE c,
            l_desc   TYPE char50,
            l_hslxx  TYPE p LENGTH 5 DECIMALS 2,
            lt_color TYPE lvc_t_scol.
    Column 1
      r_datadescr ?= cl_abap_datadescr=>describe_by_data( l_desc ).
      gw_component-name = 'COLUMN'.
      gw_component-type = r_datadescr.
      APPEND gw_component TO gt_component.
    Column 2 - Types of color for each line
    Do not display this column
      r_datadescr ?= cl_abap_datadescr=>describe_by_data( lt_color ).
      gw_component-name = 'COLOR'.
      gw_component-type = r_datadescr.
      APPEND gw_component TO gt_component.
      DO 5 TIMES.
        l_idx = sy-index.
        r_datadescr ?= cl_abap_datadescr=>describe_by_data( l_hslxx ).
        CONCATENATE 'COL' l_idx INTO gw_component-name.
        gw_component-type = r_datadescr.
        APPEND gw_component TO gt_component.
      ENDDO.
      TRY.
          r_structdescr = cl_abap_structdescr=>create( p_components = gt_component ).
        CATCH cx_sy_struct_creation .
          WRITE: / 'CX_SY_STRUCT_CREATION ERROR'.
      ENDTRY.
    Fill the table with data from GT_DATA
      CREATE DATA gw_dyn TYPE HANDLE r_structdescr.
      ASSIGN gw_dyn->* TO <dyn_wa>.
      CREATE DATA gt_dyn LIKE STANDARD TABLE OF <dyn_wa>.
      ASSIGN gt_dyn->* TO <dyn_table>.
    ENDFORM.                    " build_dynamic_table
    *&      Form  get_data
    FORM get_data .
    select statement
    ENDFORM.                    " get_data
    *&      Form  display_report
    FORM display_report .
      PERFORM display_header.   " Display ALV Header
      PERFORM display_footer.   " DIsplay ALV Footer
      PERFORM fill_data.        " Fill data
      PERFORM set_color.        " Set color
      PERFORM display_list.     " Display the ALV
    ENDFORM.                    " display_report
    *&      Form  display_header
    FORM display_header .
      DATA: lr_grid   TYPE REF TO cl_salv_form_layout_grid.
      CREATE OBJECT lr_grid.
      lr_grid->create_text(
        row    = 1
        column = 1
        text   = 'Header Line 1' ).
      lr_grid->create_text(
        row    = 2
        column = 1
        text   = 'Header Line 2' ).
      r_header = lr_grid.
    ENDFORM.                    " display_header
    *&      Form  display_footer
    FORM display_footer .
      DATA: lr_grid   TYPE REF TO cl_salv_form_layout_grid.
      CREATE OBJECT lr_grid.
      lr_grid->create_text(
        row    = 1
        column = 1
        text   = text-266 ).
      lr_grid->create_text(
        row    = 2
        column = 1
        text   = text-267 ).
      r_footer = lr_grid.
    ENDFORM.                    " display_footer
    *&      Form  set_color
    FORM set_color.
      DATA: lt_color TYPE lvc_t_scol,
            ls_color LIKE LINE OF lt_color,
            l_idx    TYPE sy-tabix.
      FIELD-SYMBOLS: <fs_color>.
      LOOP AT <dyn_table> INTO <dyn_wa>.
        l_idx = sy-tabix.
        ASSIGN COMPONENT 'COLOR' OF STRUCTURE <dyn_wa> TO <fs_color>.
        ls_color-color-col = col_total.
       ls_color-color-col = col_normal.
       ls_color-color-col = col_group.
        APPEND ls_color TO lt_color.
        <fs_color> = lt_color.
        MODIFY <dyn_table> FROM <dyn_wa> INDEX l_idx.
        UNASSIGN: <fs_color>.
      ENDLOOP.
    ENDFORM.                    " set_color
    *&      Form  display_list
    FORM display_list.
      DATA: r_display TYPE REF TO cl_salv_display_settings.
    Prepare the internal table for display
      cl_salv_table=>factory(
        EXPORTING
          list_display   = 'X'
        IMPORTING
          r_salv_table   = r_table
        CHANGING
          t_table        = <dyn_table> ).
    Set report page title
      r_table->set_top_of_list( r_header ).
    Set report footer
      r_table->set_end_of_list( r_footer ).
      r_display = r_table->get_display_settings( ).
    r_display->set_vertical_lines( ' ' ).
    Assign all the column names
      PERFORM set_column_attr.
    Display the report
      r_table->display( ).
    ENDFORM.                    " display_list
    *&      Form  set_column_attr
    FORM set_column_attr.
      DATA: l_idx     TYPE c,
            l_text(4) TYPE c,
            colname   TYPE lvc_fname,
            outps     TYPE scrtext_s,
            outpm     TYPE scrtext_m,
            outpl     TYPE scrtext_l.
      r_columns_table = r_table->get_columns( ).
    r_columns_table->set_headers_visible( abap_false ).
    column 2
    set color column
      r_columns_table->set_color_column( 'COLOR' ).
      DO 5 TIMES.
        l_idx = sy-index.
        CONCATENATE 'COL' l_idx INTO colname.
        outps = colname.
        outpm = colname.
        outpl = colname.
        r_column_table ?= r_columns_table->get_column( colname ).
        r_column_table->set_optimized( value  = abap_true ).
        r_column_table->set_alignment( value  = 1 ).
        r_column_table->set_zero( value  = space ).
        r_column_table->set_short_text( outps ).
        r_column_table->set_medium_text( outpm ).
        r_column_table->set_long_text( outpl ).
      ENDDO.
    ENDFORM.                    "set_column_attr
    *&      Form  fill_data
    FORM fill_data .
      DATA:  l_idx TYPE c,
             l_col  TYPE string.
      DO 5 TIMES.
        l_idx = sy-index.
        CONCATENATE 'COL' l_idx INTO l_col.
        ASSIGN COMPONENT l_col OF STRUCTURE <dyn_wa> TO <fs>.
        <fs> = 0.
        UNASSIGN <fs>.
      ENDDO.
      DO 5 TIMES.
        l_idx = sy-index.
        ASSIGN COMPONENT 'COLUMN' OF STRUCTURE <dyn_wa> TO <fs>.
        CONCATENATE 'Row' l_idx INTO <fs> SEPARATED BY space.
        UNASSIGN <fs>.
        APPEND <dyn_wa> TO <dyn_table>.
      ENDDO.
    ENDFORM.                    " fill_data
    Hope it helps.

  • Displaying Client standard header in ALV output

    Hi everybody,
    I am displaying the ALV report.
    On the top-of-page Client standard header has to display.
    Can any one suggest me how to achive this.
    Thanks in advance.
    Karunakar

    Hi Dilip,
    Here is a simple template:
    FORM top_of_page USING cl_dd TYPE REF TO cl_dd_document.
      DATA: l_string TYPE sdydo_text_element.
      l_string = sy-title.
      CALL METHOD cl_dd->add_text
        EXPORTING text      = l_string
                  sap_style = 'HEADING'.
      CALL METHOD cl_dd->new_line.
    * ...you could use several calls to "cl_dd->new_line"
    * and "cl_dd->add_text" to get your heading lines, no
    * matter how many they are
    ENDFORM.                    " top_of_page
    Then of course you should call the ALV:
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_html_top_of_page       = 'TOP_OF_PAGE'
    You can also insert images (with "call method l_logo->add_picture", if you define "data: l_logo type ref to cl_dd_area") or even split the heading vertically (by using "call method cl_dd->vertical_split".
    I hope it helps. BR,
    Alvaro

  • Dynamic header in oo-alv

    Hi
    I have a requirement to display  Dynamical  header in ALV.
    I am displaying the SUM of my list in ALV header . This I am able to do , as I can calculate before displaying ALV for the first time.
    But when the user filters the list the SUM should change according to the new entries displayed after filtering .
    How can i do this .
    Line: -
    All the helpful answers will be rewarded for sure.
    Thanks.
    Regards,
    Sandeep.

             fieldname type slis_fieldname,
             tabname type slis_tabname,
             seltext(40),
             valuf(80),
             valut(80),
             valuf_int(80),
             valut_int(80),
             sign0(1),
             sign_icon(4),
             optio(2),
             stype(1),
             decimals like dfies-decimals,
             intlen like dfies-intlen,
             convexit like dfies-convexit,
             edit_mask type slis_edit_mask,
             lowercase like dfies-lowercase,
             inttype like dfies-inttype,
             datatype like dfies-datatype,
             exception(1) type c,
             no_sign(1) type c,
             or(1) type c,
             order type order,
             cqvalue(5) type c,
             ref_fieldname like dfies-fieldname,
             ref_tabname like dfies-tabname,
             ddic_outputlen like dfies-outputlen,
    The following are the example code for filter settings.
              lv_filter-fieldname = u2018FIELDNAMEu2019.
              lv_filter-valuf_int =  u2018VALUEu2019.
              lv_filter-sign0     = u2018SIGNu2019.
              lv_filter-optio     = u2018OPTIONu2019.
              APPEND lv_filter TO gt_filter_list.
    Where gt_filter_list is of type slis_t_filter_alv.
    This populated internal table is then passed as the import parameter u2018it_filteru2019 of the display ALV FM.
    I hope this help u...!

  • Assigning Column Headers Dynamically in ALV output

    Hello Experts,
    I have to create dynamic column headers based on the user input on the selection-screen. Basically users enter the period and the ALV output has to create the column headers dynamically for that along with some standard columns.
    For eg, The selection screen is like this:
    From:  'Q4' '2009'
    To      'Q2'  '2011'.
    Then I have to create 12 columns for the months and rest for the Quarters.
    Then the output will be like this:
    Material, Description,10/09, 11/09, 12/09, 01/10, 02/10, 03/10, 04/10, 05/10, 06/10, 07/10, 08/10, 09/10, Q4/10, Q1/11, Q2/11
    I have built the logic to determine the number of colums for the periods based on input.
    By reading other posts, I have learnt that I have to use call method cl_alv_table_create=>create_dynamic_table to get the functionality.
    I have also looked at program BCALV_TABLE_CREATE for some help. It only has column headers in increasing order. But I am not able to understand How to pass the Column Header Label (for eg 10/09 or Q1/10) to the fieldcat dynamically.
    Is there any blog/sample prog close to my req? Can anybody please please help me. I grealy appreciate it.
    Thanks.

    Hi Lope,
    You need to filll column heading based on dynamic internal table column names.
    In your final internal table, you will have some column names like '1009, 1109, 1209' .
    While filling fieldcatalog you need to put your logic for column heading text.
    If column name is 1009, concatenate '10 '  '/'   '09', or calculate the quarter 10 falls into ,and display Q4/09.
    Regards,
    Nisha Vengal.

  • ALV Dynamic header

    LAYOUT FORMAT
    Program Title
    Client Name     Run Date/Time :
    Program            : Program Name
    User ID              : Page                  : X of Y
    Pernr:                                                            
    Name:
    IC Number:
    RBAF / Reference Number:
    Rank:
    Service:
    Unit:
    Sub Unit:
    No.|  Position| Leave Taken| From|Leave Taken To| Type of Leave|
    Leave Entitlement| No. Of Leave Taken|     Present Balance of Leave|
    Please help to program dynamic alv header for above format. I have used page break on Pernr but the header is not coming according to pernr. Though I managed
    dynamic header when we press Print Preview. But that is not a solution.

    Hi,
    I did something very similar to your requirement.
    There is a predefined event for Reuse_alv_list_display called 'BEFORE_LINE_OUTPUT'. In the event table, you have to specify the <event>-name = 'BEFORE_LINE_OUTPUT' and the <event>-form = 'ALV_BEFORE_LINE_OUTPUT'.
    Then you need a form like
    FORM alv_before_line_output
      USING ps_lineinfo TYPE kkblo_lineinfo.                    "#EC CALLED
      FIELD-SYMBOLS:
        <prot> TYPE typ_prot.
      READ TABLE gt_prot INDEX ps_lineinfo-tabindex
        ASSIGNING <prot>.
      CHECK g_file_no <> <prot>-file_no.
      g_file_no = <prot>-file_no.
      NEW-PAGE.
    ENDFORM.                    "alv_before_line_output
    In my program the global table displayed in ALV was gt_prot (of line type typ_prot) and the requirement was to start a new page for each file processed. The form stores the file processed in
    g_file_no. If a new file is processed, a NEW-PAGE will trigger the TOP_OF_PAGE event of the alv. I will not copy the form here because we also issued some statistical values, system and user informations and so on.
    But I hope you get it done.
    The only remaining issue may be that the before_line_output event will cost some time because it is triggered for every output line. But my report was still quite fast.
    regards,
    Clemens

  • Dynamic header in oo alv print_top_of_page based on current line

    I would expect this to be a common problem with the solution easily to google/find, but somehow...
    dynamic header generation during alv print_top_of_page:
    - i print an oo alv grid, sorted by kunnr
    - for each new kunnr a new page
    -> now I want during print-out to: at each top of page, read the first (or any) line of the current page, i.e. the current kunnr, and select data on basis of that kunnr to be written to the header.
    My problem is that sy-tabix is not being filled correctly (always 1).
    Strange thing is that in another report with a non-dynamic itab to display, sy-tabix is actuall being filled more or less correctly. (with the minor drawback that on the first page the tabix might not be 1 but more likely to be 2; but that's easy to fix and for the next pages sy-tabix is correct)
    Kind regards, A
    baanbrecher

    In the handle_print_top_of_page method, use :
    FIELD-SYMBOLS : <lv_line> TYPE ANY.
    ASSIGN ('(SAPLKKBL)G_INDEX') TO <lv_line>.
    if <lv_line> = 0. "First time, G_INDEX is equal to zero
       <lv_line> = 1.
    endif.
    So in <lv_line> you will always have the good index of your table.

  • Addiing additional data in header of excel output  of alv excel dowload.

    Hi Experts,
    I want to set(print) some additional data in header(with table header) of excel output of alv standard functionality(Export to Microsoft Excel) in webdynpro abap.
    any suggesions...
    Reg,
    Rajesh.

    OLE is the solution but not very performance oriented. Search for details in SDN

  • How to get check box in alv output

    hi gurus
    can anyone explian me how to get check box in alv output
    it should not be a pop up window
    i want to get in output itself
    tahnk you
    regards
    kals.

    Hi
    by using rs_selfield
    ty to call dynamic subroutine..
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield. "#EC CALLED
    read table rs-selfield with key cond = 'X'
    endform.
    see the below example
    REPORT Z_GET_REFRESH no standard page heading.
    type-pools : slis.
    tables : makt,
    mara.
    data : i_fieldcat type slis_t_fieldcat_alv.
    CONSTANTS :
    gc_refresh TYPE syucomm VALUE '&REFRESH'.
    data : begin of i_makt occurs 0,
    matnr like makt-matnr,
    maktx like makt-maktx,
    end of i_makt.
    data : v_repid like sy-repid,
    g_user_command type slis_formname value 'USER_COMMAND',
    g_status_set type slis_formname value 'SET_PF_STATUS',
    lt_event_exit TYPE slis_t_event_exit,
    ls_event_exit TYPE slis_event_exit.
    DATA:LC_GLAY TYPE LVC_S_GLAY.
    select-options s_matnr for mara-matnr .
    start-of-selection.
    select matnr maktx from makt into table i_makt
    where matnr in s_matnr.
    end-of-selection.
    Fill the fieldcatlog
    perform fill_field.
    Call the FM
    perform call_fm.
    *& Form fill_field
    text
    --> p1 text
    <-- p2 text
    FORM fill_field.
    data wa_fieldcat type slis_fieldcat_alv.
    clear : wa_fieldcat.
    wa_fieldcat-tabname = 'I_MAKT'.
    wa_fieldcat-fieldname = 'MATNR'.
    wa_fieldcat-outputlen = '18'.
    wa_fieldcat-seltext_l = 'Material #'.
    wa_fieldcat-col_pos = '1'.
    append wa_fieldcat to i_fieldcat.
    clear : wa_fieldcat.
    wa_fieldcat-tabname = 'I_MAKT'.
    wa_fieldcat-fieldname = 'MAKTX'.
    wa_fieldcat-outputlen = '40'.
    wa_fieldcat-seltext_l = 'Material Desc'.
    wa_fieldcat-col_pos = '2'.
    append wa_fieldcat to i_fieldcat.
    ENDFORM. " fill_field
    *& Form call_fm
    text
    --> p1 text
    <-- p2 text
    FORM call_fm.
    v_repid = sy-repid.
    LC_GLAY-EDT_CLL_CB = 'X'.
    CLEAR ls_event_exit.
    ls_event_exit-ucomm = gc_refresh. " Refresh
    ls_event_exit-after = 'X'.
    APPEND ls_event_exit TO lt_event_exit.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = v_repid
    I_CALLBACK_PF_STATUS_SET = g_status_set
    I_CALLBACK_USER_COMMAND = g_user_command
    I_CALLBACK_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_END_OF_LIST = ' '
    I_STRUCTURE_NAME =
    I_BACKGROUND_ID = ' '
    I_GRID_TITLE =
    I_GRID_SETTINGS = LC_GLAY
    IS_LAYOUT =
    IT_FIELDCAT = i_fieldcat
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    IT_EVENTS =
    IT_EVENT_EXIT = lt_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 = i_makt
    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. " call_fm
    FORM USER_COMMAND *
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield. "#EC CALLED
    data i_RSPARAMS like RSPARAMS occurs 0.
    CASE R_UCOMM.
    WHEN '&IC1'.
    read table i_makt index rs_selfield-tabindex.
    SET PARAMETER ID 'MAT' FIELD i_makt-matnr.
    if not i_makt-matnr is initial.
    call transaction 'MM02' and skip first screen.
    endif.
    when '&REFRESH'.
    CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
    EXPORTING
    CURR_REPORT = v_repid
    IMPORTING
    SP =
    TABLES
    SELECTION_TABLE = i_RSPARAMS
    EXCEPTIONS
    NOT_FOUND = 1
    NO_REPORT = 2
    OTHERS = 3
    IF SY-SUBRC 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    submit z_get_refresh with selection-table i_RSPARAMS.
    rs_selfield-refresh = 'X'.
    ENDCASE.
    MOVE '&REFRESH' TO r_ucomm.
    ENDFORM.
    FORM set_pf_status *
    FORM SET_PF_STATUS USING rt_extab TYPE slis_t_extab.
    DELETE Rt_extab WHERE fcode = gc_refresh.
    SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'
    EXCLUDING Rt_extab.
    *SET PF-STATUS 'STANDARD' EXCLUDING rt_extab.
    SET TITLEBAR sy-tcode.
    ENDFORM.

  • ALV Output to Excel file

    Hi All,
    I am downloading the ALV output to Excel file.I am making use of  LIST--->EXPORT--->SPREADSHEET option.
    My list is having Header, Footer, sub totals and totals.When i transfer the list i am facing following problems
    1.Even i am getting the empty columns betweeen my output.
    2.In the Place of sub totals i am getting astericks
    3.On the top of the records downloaded,"DYNAMIC LIST DISPLAY" is found.I want to avoid this text on the top
    Thanks,
    Ravee...

    Hello Vinod,
    1.I am getting the empty columns betweeen my output.
    I am having 16 columns in the ALV output,but i got 19 columns in my excel file.
    2.In the Place of sub totals i am getting astericks.
    Generally there is no possibility to download the sub totals.i am using LIST->EXPORT->SPREADSHEET.
                     I am having the sub totals in my output.
    *You would have noticed the' * ' for sub total and ' ** ' for grand totals values.*These sub total & total values are not downloaded but these asterisks are carried to excel file.
    3.On the top of the records downloaded,"DYNAMIC LIST DISPLAY" is found.I want to avoid this text on the top.
    I am using the application tool bar icon only.Still i am getting the same.
    Thanks,
    Ravee...

  • Transpose ALV output format in Vertical

    Hi ,
      I want to transpose the ALV output. For this i have coded like below, but there is no output displaying.Please check the below code & advise me where to write our own fielcatalog & how to write the fieldcatogue.
    TABLES:EKKO,EKPO.
    TYPE-POOLS: SLIS.
    TYPES:BEGIN OF PH_TY,
    PH_EBELN LIKE EKKO-EBELN,
    PH_AEDAT LIKE EKKO-AEDAT,
    PH_LIFNR LIKE EKKO-LIFNR,
    PH_SUBMI LIKE EKKO-SUBMI,
    PH_EKORG LIKE EKKO-EKORG,
    END OF PH_TY.
    DATA: PH_ITAB TYPE STANDARD TABLE OF PH_TY.
    DATA: L_COL TYPE SY-TABIX,
          L_STRUCTURE TYPE REF TO DATA,
          L_DYNTABLE TYPE REF TO DATA,
          WA_LVC_CAT TYPE LVC_S_FCAT,
          LT_LVC_CAT TYPE LVC_T_FCAT,
          LT_FIELDCATALOGUE TYPE SLIS_T_FIELDCAT_ALV,
          WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
          LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
          LT_LAYOUT TYPE SLIS_LAYOUT_ALV.
    FIELD-SYMBOLS : <HEADER> TYPE ANY,
                    <DYNHEADER> TYPE ANY,
                    <DYNDATA> TYPE ANY,
                    <LS_TABLE> TYPE ANY,
                    <DYNAMICTABLE> TYPE STANDARD TABLE,
                    <IT_TABLE> TYPE STANDARD TABLE.
    SELECTION-SCREEN:BEGIN OF BLOCK B1.
    SELECT-OPTIONS:P_EBELN FOR EKKO-EBELN,
                   P_LIFNR FOR EKKO-LIFNR,
                   P_MATNR FOR EKPO-MATNR.
    SELECTION-SCREEN END OF BLOCK B1.
    INITIALIZATION.
    START-OF-SELECTION.
      CREATE DATA L_DYNTABLE TYPE STANDARD TABLE OF PH_TY WITH NON-UNIQUE DEFAULT KEY.
      ASSIGN L_DYNTABLE->* TO <IT_TABLE>.
      SELECT EBELN AEDAT LIFNR SUBMI EKORG FROM EKKO
                      INTO TABLE <IT_TABLE> WHERE EBELN IN P_EBELN
                      AND LIFNR IN P_LIFNR.
      WA_LVC_CAT-FIELDNAME = 'COLUMNTEXT'.
      WA_LVC_CAT-REF_TABLE = 'LVC_S_DETA'.
      APPEND WA_LVC_CAT TO LT_LVC_CAT.
      WA_FIELDCAT-FIELDNAME = 'COLUMNTEXT'.
      WA_FIELDCAT-REF_TABNAME = 'LVC_S_DETA'.
      WA_FIELDCAT-KEY = 'X'.
      APPEND WA_FIELDCAT TO LT_FIELDCAT.
    *  WA_FIELDCAT-TABNAME = 'IT_TABLE'.
    *  WA_FIELDCAT-FIELDNAME = 'PH_EBELN'.
    *  WA_FIELDCAT-SELTEXT_M = 'PO'.
    *  APPEND WA_FIELDCAT TO LT_FIELDCAT.
    *  CLEAR WA_FIELDCAT.
      DESCRIBE TABLE <IT_TABLE>.
      DO
      SY-TFILL TIMES.
        WRITE SY-INDEX TO WA_LVC_CAT-FIELDNAME LEFT-JUSTIFIED.
        CONCATENATE 'VALUE' WA_LVC_CAT-FIELDNAME INTO WA_LVC_CAT-FIELDNAME.
        WA_LVC_CAT-REF_FIELD = 'VALUE'.
        WA_LVC_CAT-REF_TABLE = 'LVC_S_DETA'.
        APPEND WA_LVC_CAT TO LT_LVC_CAT.
        CLEAR WA_FIELDCAT.
        WA_FIELDCAT-FIELDNAME = WA_LVC_CAT-FIELDNAME.
        WA_FIELDCAT-REF_FIELDNAME = 'VALUE'.
        WA_FIELDCAT-REF_TABNAME = 'LVC_S_DETA'.
        APPEND WA_FIELDCAT TO LT_FIELDCAT.
      ENDDO.
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG = LT_LVC_CAT
        IMPORTING
          EP_TABLE        = L_DYNTABLE.
      ASSIGN L_DYNTABLE->* TO <DYNAMICTABLE>.
      CREATE DATA L_STRUCTURE LIKE LINE OF <DYNAMICTABLE>.
      ASSIGN L_STRUCTURE->* TO <HEADER>.
      CREATE DATA L_STRUCTURE LIKE LINE OF <IT_TABLE>.
      ASSIGN L_STRUCTURE->* TO <LS_TABLE>.
      DESCRIBE TABLE LT_FIELDCATALOGUE.
      DO SY-TFILL TIMES.
        IF SY-INDEX = 1.
        READ TABLE LT_FIELDCATALOGUE INTO WA_FIELDCAT INDEX 1.
        ENDIF.
        ASSIGN COMPONENT 1 OF STRUCTURE <HEADER> TO <DYNHEADER>.
        IF SY-SUBRC NE 0. EXIT .ENDIF.
        READ TABLE LT_FIELDCATALOGUE INTO WA_FIELDCAT INDEX SY-INDEX.
        <DYNHEADER> = WA_FIELDCAT-SELTEXT_M.
        IF <DYNHEADER> IS INITIAL.
        <DYNHEADER> = WA_FIELDCAT-FIELDNAME.
        ENDIF.
        LOOP AT <IT_TABLE> INTO <LS_TABLE>.
          L_COL = SY-TABIX + 1.
          ASSIGN COMPONENT SY-INDEX OF STRUCTURE <LS_TABLE> TO <DYNDATA>.
          IF SY-SUBRC NE 0. EXIT .
          ENDIF.
          ASSIGN COMPONENT L_COL OF STRUCTURE <HEADER> TO <DYNHEADER>.
          IF SY-SUBRC NE 0.
          EXIT .
          ENDIF.
          WRITE <DYNDATA> TO <DYNHEADER> LEFT-JUSTIFIED.
        ENDLOOP.
        APPEND <HEADER> TO <DYNAMICTABLE>.
      ENDDO.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          IS_LAYOUT   = LT_LAYOUT
          IT_FIELDCAT = LT_FIELDCAT
        TABLES
          T_OUTTAB    = <DYNAMICTABLE>.

    Hi,
    Please go thorugh the below sample code , Commenting is done for your easy understanding.
    TYPE-POOLS: slis."*Declarations for ALV, dynamic table and col no for transpose
    DATA:    l_col    TYPE sy-tabix,
             l_structure   TYPE REF TO data,
             l_dyntable    TYPE REF TO data,
             wa_lvc_cat  TYPE lvc_s_fcat,
             lt_lvc_cat  TYPE lvc_t_fcat,
             lt_fieldcatalogue     TYPE slis_t_fieldcat_alv,
             wa_fieldcat TYPE slis_fieldcat_alv,
             lt_fieldcat TYPE slis_t_fieldcat_alv,
             lt_layout   TYPE slis_layout_alv."*Field symbols declarations
    FIELD-SYMBOLS :
      <header>    TYPE ANY,
      <dynheader> TYPE ANY,
      <dyndata>   TYPE ANY,
      <ls_table>      TYPE ANY,
      <dynamictable>      TYPE STANDARD TABLE,
      <it_table> TYPE STANDARD TABLE."*Input the name of the table
    PARAMETERS p_table TYPE dd02l-tabname OBLIGATORY."*Initialization event
    INITIALIZATION."*Start of selection event
    START-OF-SELECTION."* Create internal table of dynamic type
      CREATE DATA l_dyntable TYPE STANDARD TABLE OF (p_table)
                           WITH NON-UNIQUE DEFAULT KEY.
      ASSIGN l_dyntable->* TO <it_table>."*select statement to select data from the table as input into
    *our dynamic internal table.
    *Here i have restricted only till 5 rows.
    *You can set a variable and give no of rows to be fetched
    *The variable can be set in your select statement  SELECT * INTO CORRESPONDING FIELDS OF TABLE <it_table>
                   FROM (p_table) up to 5 rows."*Fieldcatalogue definitions
      wa_lvc_cat-fieldname = 'COLUMNTEXT'.
      wa_lvc_cat-ref_table = 'LVC_S_DETA'.
      APPEND wa_lvc_cat TO lt_lvc_cat.  wa_fieldcat-fieldname = 'COLUMNTEXT'.
      wa_fieldcat-ref_tabname = 'LVC_S_DETA'.
      wa_fieldcat-key  = 'X'..
      APPEND wa_fieldcat TO lt_fieldcat.  DESCRIBE TABLE <it_table>.  DO sy-tfill TIMES.
      For each line, a column 'VALUEx' is created in the fieldcatalog
      Build Fieldcatalog
        WRITE sy-index TO wa_lvc_cat-fieldname LEFT-JUSTIFIED.
        CONCATENATE 'VALUE' wa_lvc_cat-fieldname
               INTO wa_lvc_cat-fieldname.
        wa_lvc_cat-ref_field = 'VALUE'.
        wa_lvc_cat-ref_table = 'LVC_S_DETA'.
        APPEND wa_lvc_cat TO lt_lvc_cat.
      Build Fieldcatalog
        CLEAR wa_fieldcat.
        wa_fieldcat-fieldname = wa_lvc_cat-fieldname.
        wa_fieldcat-ref_fieldname = 'VALUE'.
        wa_fieldcat-ref_tabname = 'LVC_S_DETA'.
        APPEND wa_fieldcat TO lt_fieldcat.
      ENDDO."* Create dynamic internal table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = lt_lvc_cat
        IMPORTING
          ep_table        = l_dyntable.  ASSIGN l_dyntable->* TO <dynamictable>."* Create structure as structure of the internal table
      CREATE DATA l_structure LIKE LINE OF <dynamictable>.
      ASSIGN l_structure->* TO <header>."* Create structure = structure of the internal table
      CREATE DATA l_structure LIKE LINE OF <it_table>.
      ASSIGN l_structure->* TO <ls_table>."* Create field catalog from our table structure
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = p_table
        CHANGING
          ct_fieldcat            = lt_fieldcatalogue
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.  DESCRIBE TABLE lt_fieldcatalogue."* Fill the internal to display <dynamictable>
      DO sy-tfill TIMES.
        IF sy-index = 1.
          READ TABLE lt_fieldcatalogue INTO wa_fieldcat INDEX 1.
        ENDIF.
      For each field of it_table
        ASSIGN COMPONENT 1 OF STRUCTURE <header> TO <dynheader>.
        IF sy-subrc NE 0. EXIT .ENDIF.
        READ TABLE lt_fieldcatalogue INTO wa_fieldcat INDEX sy-index.
      Fill 1st column
        <dynheader> = wa_fieldcat-seltext_m.
        IF <dynheader> IS INITIAL.
          <dynheader> = wa_fieldcat-fieldname.
        ENDIF."*Filling the other columns
        LOOP AT <it_table> INTO <ls_table>.
          l_col = sy-tabix + 1.
          ASSIGN COMPONENT sy-index OF STRUCTURE <ls_table> TO <dyndata>.
          IF sy-subrc NE 0. EXIT .ENDIF.
          ASSIGN COMPONENT l_col OF STRUCTURE <header> TO
    <dynheader>.
          IF sy-subrc NE 0. EXIT .ENDIF.
          WRITE <dyndata> TO <dynheader> LEFT-JUSTIFIED.
        ENDLOOP.
        APPEND <header> TO <dynamictable>.
      ENDDO."*Layout for ALV output
      lt_layout-zebra = 'X'.
      lt_layout-no_colhead = 'X'..
      lt_layout-colwidth_optimize ='X'.
      lt_layout-window_titlebar = 'ALV GRID TRANSPOSED'."*ALV Grid output for display
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          is_layout   = lt_layout
          it_fieldcat = lt_fieldcat
        TABLES
          t_outtab    = <dynamictable>.
    Regards,
    Arun

  • Dynamic selection in ALV report

    Hi Guru's
    I have cpoied a standatrd program(RFBILA00) into Z-program.
    I need to display the profit centre from dynamic selection in ALV header  output when profit centre is selected.If not no need to display it.
    Please do the needful.
    Thanks,
    Sunil.

    hi,
    Refer to the link,
    http://www.abapcode.info/2007/06/dynamic-selection-on-alv-at-run-time.html
    This may help you.
    Regards
    Sumit Aagrwal

  • Total is not getting displayed in the ALV output.

    Hi,
    Total is not getting displayed in the ALV output.
    I m using :REUSE_ALV_BLOCK_LIST_APPEND & REUSE_ALV_BLOCK_LIST_DISPLAY
    Are  there any issues with it as the same settings are working fine with REUSE_ALV_LIST_DISPLAY
    source code:
    DATA: layout TYPE slis_layout_alv,
          IT_eventS  TYPE slis_t_event,
          fcat   TYPE slis_t_fieldcat_alv WITH HEADER LINE,
          rec_fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
    TYPES: BEGIN OF ty_tab,
          belnr TYPE dberchz-belnr,
          belzart TYPE dberchz-belzart,
          net TYPE dberchz-nettobtr,
          END OF ty_tab.
    DATA: lt_tab TYPE STANDARD TABLE OF ty_tab.
    SELECT belnr belzart nettobtr
      FROM dberchz
      INTO TABLE lt_tab[]
    WHERE belnr eq '000000000001'.
      if sy-subrc ne 0.
      ENDIF.
    *  defining layout
    layout-colwidth_optimize = 'X'.
    layout-def_status = 'X'.
    *defning event
    *event
    *defining field catalog
    fcat-col_pos = 1.
    fcat-fieldname = 'BELNR'.
    fcat-tabname  = 'LT_TAB'.
    APPEND fcat.
    fcat-col_pos = 2.
    fcat-fieldname = 'BELZART'.
    fcat-tabname  = 'LT_TAB'.
    APPEND fcat.
    fcat-col_pos = 3.
    fcat-fieldname = 'NET'.
    fcat-tabname  = 'LT_TAB'.
    fcat-do_sum = 'X'.
    APPEND fcat.
    *calling alv
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
      EXPORTING
        i_callback_program             = 'YZ_PLR'
    *   I_CALLBACK_PF_STATUS_SET       = ' '
    *   I_CALLBACK_USER_COMMAND        = ' '
    *   IT_EXCLUDING                   =
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
        is_layout                        = layout
        it_fieldcat                      = fcat[]
        i_tabname                        = 'LT_TAB'
        it_events                        = IT_EVENTS[]
    *   IT_SORT                          =
    *   I_TEXT                           = ' '
      tables
        t_outtab                         = lt_tab[]
    * EXCEPTIONS
    *   PROGRAM_ERROR                    = 1
    *   MAXIMUM_OF_APPENDS_REACHED       = 2
    *   OTHERS                           = 3
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
    Thanks,
    Gaurav

    Hi
    No I don't think, this is my code (based on your code) and it works fine:
    TYPE-POOLS SLIS.
    DATA: BEGIN OF LT_TAB OCCURS 0,
           BELNR LIKE BSEG-BELNR,
           GJAHR LIKE BSEG-GJAHR,
           WRBTR LIKE BSEG-WRBTR,
           WAERS LIKE BKPF-WAERS,
          END OF LT_TAB.
    DATA: LAYOUT     TYPE SLIS_LAYOUT_ALV,
          IT_EVENTS  TYPE SLIS_T_EVENT,
          FCAT       TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
          REC_FCAT   TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
    START-OF-SELECTION.
      FCAT-COL_POS       = 1.
      FCAT-FIELDNAME     = 'BELNR'.
      FCAT-TABNAME       = 'LT_TAB'.
      FCAT-REF_FIELDNAME = 'BELNR'.
      FCAT-REF_TABNAME   = 'BSEG'.
      APPEND FCAT.
      FCAT-COL_POS       = 2.
      FCAT-FIELDNAME     = 'GJAHR'.
      FCAT-TABNAME       = 'LT_TAB'.
      FCAT-REF_FIELDNAME = 'GJAHR'.
      FCAT-REF_TABNAME   = 'BSEG'.
      APPEND FCAT.
      FCAT-COL_POS       = 3.
      FCAT-FIELDNAME     = 'WRBTR'.
      FCAT-TABNAME       = 'LT_TAB'.
      FCAT-CFIELDNAME    = 'WAERS'.
      FCAT-REF_FIELDNAME = 'WRBTR'.
      FCAT-REF_TABNAME   = 'BSEG'.
      FCAT-DO_SUM        = 'X'.
      APPEND FCAT.
      FCAT-COL_POS       = 4.
      FCAT-FIELDNAME     = 'WAERS'.
      FCAT-TABNAME       = 'LT_TAB'.
      FCAT-REF_FIELDNAME = 'WAERS'.
      FCAT-REF_TABNAME   = 'BKPF'.
      FCAT-DO_SUM        = SPACE.
      APPEND FCAT.
      SELECT * FROM BSEG INTO CORRESPONDING FIELDS OF TABLE LT_TAB
        WHERE BUKRS = 'MAAB'
          AND BELNR = '0000000001'.
      LT_TAB-WAERS = 'EUR'.
      MODIFY LT_TAB FROM LT_TAB TRANSPORTING WAERS WHERE WAERS = SPACE.
    *CALLING ALV
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
        EXPORTING
          I_CALLBACK_PROGRAM = 'ZPROVAMAX5'.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          IS_LAYOUT   = LAYOUT
          IT_FIELDCAT = FCAT[]
          I_TABNAME   = 'LT_TAB'
          IT_EVENTS   = IT_EVENTS[]
        TABLES
          T_OUTTAB    = LT_TAB[].
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
    I've also inserted a currency field
    Max

  • I am not getting the headings of the fields in ALV output.

    I am not getting ALV out put but  the headings of the fields in ALV output.
    Please see my below code .
    TYPES : BEGIN OF ty_zgxmit.
              INCLUDE STRUCTURE zgxmit.
    TYPES : END OF ty_zgxmit.
    DATA : gt_zgxmit TYPE TABLE OF ty_zgxmit.
    *&      Form  alv_display                                              *
    This subroutine is to display the out put in ALV.                    *
    FORM alv_display .
    Local data
      DATA: y_x          LIKE boole  VALUE 'X'.
    DATA: lt_fieldcat  TYPE slis_t_fieldcat_alv.
      DATA: lf_fieldcat  TYPE slis_fieldcat_alv.
      DATA: lh_index     LIKE lf_fieldcat-col_pos.
    For variant
    DATA: ws_repid LIKE sy-repid,
          g_save TYPE c VALUE 'A',
          g_exit TYPE c,
          g_variant LIKE disvariant,
          gx_variant LIKE disvariant.
      For 1st field.( RPT_LOC )
        CLEAR lf_fieldcat.
        lf_fieldcat-fieldname = 'RPT_LOC'.
        lf_fieldcat-tabname = 'GT_ZGXMIT'.
        lf_fieldcat-ref_tabname = 'RPT_LOC'.
        lf_fieldcat-ref_fieldname = 'ZGXMIT'.
        lh_index = lh_index + 1.
        lf_fieldcat-col_pos = lh_index.
        lf_fieldcat-key = y_x.
        lf_fieldcat-no_sum = y_x.
        APPEND lf_fieldcat TO lt_fieldcat.
    For 2nd field.( BAL_XMIT )
        CLEAR lf_fieldcat.
        lf_fieldcat-fieldname = 'BAL_XMIT'.
        lf_fieldcat-tabname = 'GT_ZGXMIT'.
        lf_fieldcat-ref_tabname = 'BAL_XMIT'.
        lf_fieldcat-ref_fieldname = 'ZGXMIT'.
        lh_index = lh_index + 1.
        lf_fieldcat-col_pos = lh_index.
        lf_fieldcat-key = y_x.
        lf_fieldcat-no_sum = y_x.
        APPEND lf_fieldcat TO lt_fieldcat.
    For 3rd field.( INC_XMIT )
        CLEAR lf_fieldcat.
        lf_fieldcat-fieldname = 'INC_XMIT'.
        lf_fieldcat-tabname = 'GT_ZGXMIT'.
        lf_fieldcat-ref_tabname = 'INC_XMIT'.
        lf_fieldcat-ref_fieldname = 'ZGXMIT'.
        lh_index = lh_index + 1.
        lf_fieldcat-col_pos = lh_index.
        lf_fieldcat-key = y_x.
        lf_fieldcat-no_sum = y_x.
        APPEND lf_fieldcat TO lt_fieldcat.
    For 4th field.( Z500_XMIT )
        CLEAR lf_fieldcat.
        lf_fieldcat-fieldname = 'Z500_XMIT'.
        lf_fieldcat-tabname = 'GT_ZGXMIT'.
        lf_fieldcat-ref_tabname = 'Z500_XMIT'.
        lf_fieldcat-ref_fieldname = 'ZGXMIT'.
        lh_index = lh_index + 1.
        lf_fieldcat-col_pos = lh_index.
        lf_fieldcat-key = y_x.
        lf_fieldcat-no_sum = y_x.
        APPEND lf_fieldcat TO lt_fieldcat.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program       = 'ZJV_2245'
                it_fieldcat              = lt_fieldcat
           TABLES
                t_outtab                 = gt_zgxmit
           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

    You can force the headings like so.
    CLEAR lf_fieldcat.
    lf_fieldcat-fieldname = 'RPT_LOC'.
    lf_fieldcat-tabname = 'GT_ZGXMIT'.
    lf_fieldcat-ref_tabname = 'RPT_LOC'.
    lf_fieldcat-ref_fieldname = 'ZGXMIT'.
    lf_fieldcat-reptext_ddic  = 'Whatever Heading'.    "<-  Right here
    lh_index = lh_index + 1.
    lf_fieldcat-col_pos = lh_index.
    lf_fieldcat-key = y_x.
    lf_fieldcat-no_sum = y_x.
    APPEND lf_fieldcat TO lt_fieldcat.
    Regards,
    Rich Heilman

Maybe you are looking for