Reuse alv merge

what is the use of function module reuse alv field catalog merge

Field catalog with field descriptions
2.7.1. Description
Field catalog containing descriptions of the list output fields (usually a subset of the internal output table fields). A field catalog is required for every ALV list output.
The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the REUSE_ALV_FIELDCATALOG_MERGE module
See also the documentation of the function module REUSE_ALV_FIELDCATALOG_MERGE.
The minimal field catalog is documented under 'default'. The caller can use the other optional parameters to assign output attributes to a field which differ from the default.
A field catalog need not be built-up and passed explicitly only under the following conditions:
• The internal table to be output has the same structure as a Data Dictionary structure which is referred to in the internal table declaration using LIKE or INCLUDE STRUCTURE.
• all fields in this structure are to be output
• the structure name is passed to ALV in the parameter I_STRUCTURE_NAME.
See also the documentation of the IMPORTING paramter I_STRUCTURE_NAME.
more info
DEFININING OUTPUT CHARACTERISTICS: PREPARING DISPLAY FIELDS CATALOG
A field catalog is prepared using the internal table (I_FIELDCAT) of type SLIS_T_FIELDCAT_ALV. Field catalog containing descriptions of the list output fields (usually a subset of the internal output table fields).
A field catalog is required for every ALV list output to add desired functionality (i.e. Key, Hotspot, Specific headings, Justify, Col. position etc) to certain fields of the output. If not mentioned specifically, then the defaults are taken. The possible values and defaults are listed below.
The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the REUSE_ALV_FIELDCATALOG_MERGE module.
The minimal field catalog is documented below. This can be done in a routine using a local variable. The user can use the other optional parameters to assign output attributes to different fields in the output, which differ from the default.
Check...
Re: What is the use of REUSE_ALV_FIELDCATALOG_MERGE?
Re: FM: REUSE_ALV_GRID_DISPLAY and  REUSE_ALV_FIELDCATALOG_MERGE
award points and try to close threads...
Message was edited by:
        Ramesh Babu Chirumamilla

Similar Messages

  • ALV Report row grey-out (disable) dynamically -- REUSE ALV!!!

    Hello All,
    Well again a quick question...
    Am using REUSE ALV method to display the ALV report.
    Dynamically by selecting a row in the list (using the checkbox) and by pressing a button on application tool bar, the selected row should be greyed-out(disabled), that is it should not be anymore editable!
    How is it possible?
    Any kind of inputs regarding this will be damn damn helpful.
    Thanks in advance!
    Cheers, Sundar.

    Hi,
    The above solution 1 will be only applicable if using OO ALV!
    above solution 2 will disable the entire column, and then again i need to call the "REUSE ALV"... which i don't want to.. as it opens another screen above the same screen and i have to close it twice!
    I know it is possible to grey out the selected row using OO ALV... i want to know if it is possible in REUSE ALV???
    Keep shooting please....
    Thanks!
    Regards,
    Sundar

  • REUSE ALV -- To make a row grey out (disable/non-editable) dynamically!!!

    Hello All,
    Well again a quick question...
    Am using REUSE ALV method to display the ALV report. There are few fields which i've made editable while building the field catalog!
    Now by, Dynamically by selecting a row in the list (using the checkbox) and by pressing a button on application tool bar, the selected row should be greyed-out(disabled), that is it should not be anymore editable!
    How is it possible?
    Any kind of inputs regarding this will be damn damn helpful.
    Thanks in advance!
    Cheers, Sundar.

    Hi,
    The above solution 1 will be only applicable if using OO ALV!
    above solution 2 will disable the entire column, and then again i need to call the "REUSE ALV"... which i don't want to.. as it opens another screen above the same screen and i have to close it twice!
    I know it is possible to grey out the selected row using OO ALV... i want to know if it is possible in REUSE ALV???
    Keep shooting please....
    Thanks!
    Regards,
    Sundar

  • Call Reuse ALV Twice - Is it possible?

    Hi,
    I have a requirement wherein I need to develop two alv display with header. The 2nd alv display will be issued once the user clicks a custom button from the 1st alv display. However, I the display in the 2nd alv is from the 1st alv display. I have checked the field catalog and internal table in the 2nd reuse alv grid. But I cant seem to figure what is wrong, do I need to use some function module to refresh the output? Any input is welcome.
    Thanks & Regards,
    Mawi

    Hi,
    Step 1>First create a PF-STATUS<for the custom button that you have to click>
    Step 2>Call that PF-STATUS from your first REUSE_ALV_GRID_DISPLAY in the following way:-
                 set the parameter like this way
                 i_callback_pf_status_set          = 'PF_STATUS_SET'
               Now create a subroutine for that
                 FORM pf_status_set USING rt_extab  TYPE slis_t_extab.
                    SET PF-STATUS 'ZSTANDARD' OF PROGRAM 'ZSAR_ASSGN1_GRIDALV'.
                ENDFORM.                    "pf_status_set
    Step 3>Set another parameter
                 i_callback_user_command           = 'USER_COMMAND'
                Now for that also create a subroutine like this:-
                  FORM user_command USING I_r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
                <here you put all the subroutine necessary to create the second ALV>
                 EndForm.
    Hope in this way you get your solution.
    Regards.
    Sarbajit.

  • Tooltip in reuse alv..

    hi
               in reuse alv grid is there any option for tooltip..
    as in classes alv u have coltext for display and  seltext for tooltip
    can i do this in reuse alv grid....
    if yes plz tell me how....

    Hi Neha,
    Please refer the link,
    tooltip on alv reports
    Regards,
    Hema.
    Reward points if it is useful.

  • Merge cells in reuse alv

    Hello gurus.
    Please help me with merging cells.
    I need to merge some cells in alv grid. To create grid i use reuse_alv FM. For example it is needed to merge all cells in several rows. What should i do ? I think that there should be some manipulations with fieldcatalog but i don't know the correct ones.
    Thanks.
    regards,
    alex.

    If you would like to merge cells,  meaning that you want to hide repeating values in a certain column, then you can simply sort by that column. 
    report zrich_0004
           no standard page heading.
    type-pools slis.
    data: fieldcat type slis_t_fieldcat_alv.
    data: sort     type slis_t_sortinfo_alv.
    data: begin of ivbap occurs 0,
           vbeln type vbap-vbeln,
           kunnr type vbak-kunnr,
           vkorg type vbak-vkorg,
           netwr type vbap-netwr,
          end of ivbap.
    * Selection Screen
    start-of-selection.
      select vbak~vbeln vbak~kunnr vbak~vkorg vbap~netpr
                  into table ivbap
                          from vbak
                             inner join vbap
                                on vbak~vbeln = vbap~vbeln
                                      up to 100 rows.
      perform write_report.
    *  WRITE_REPORT
    form write_report.
      data: tmp_sort type line of slis_t_sortinfo_alv.
      data: fc_tmp type slis_fieldcat_alv .
    * Build feildcat
      clear fc_tmp. refresh fieldcat.
      fc_tmp-reptext_ddic    = 'Sales Org'.
      fc_tmp-fieldname  = 'VKORG'.
      fc_tmp-tabname   = 'IVBAP'.
      fc_tmp-outputlen  = '4'.
      append fc_tmp to fieldcat.
      clear fc_tmp.
      fc_tmp-reptext_ddic    = 'Customer'.
      fc_tmp-fieldname  = 'KUNNR'.
      fc_tmp-tabname   = 'IVBAP'.
      fc_tmp-outputlen  = '10'.
      append fc_tmp to fieldcat.
      clear fc_tmp.
      fc_tmp-reptext_ddic    = 'SD DOC'.
      fc_tmp-fieldname  = 'VBELN'.
      fc_tmp-tabname   = 'IVBAP'.
      fc_tmp-outputlen  = '10'.
      append fc_tmp to fieldcat.
      clear fc_tmp.
      fc_tmp-reptext_ddic    = 'Net'.
      fc_tmp-fieldname  = 'NETWR'.
      fc_tmp-tabname   = 'IVBAP'.
      fc_tmp-outputlen  = '15'.
      fc_tmp-datatype = 'QUAN'.
      append fc_tmp to fieldcat.
    * Build sort table
      clear sort. refresh sort.
      clear tmp_sort.
      tmp_sort-fieldname = 'VKORG'.
      tmp_sort-tabname   = 'IALV'.
      tmp_sort-up        = 'X'.
      append tmp_sort to sort.
    * CALL ABAP LIST VIEWER (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                it_sort     = sort
                it_fieldcat = fieldcat
           tables
                t_outtab    = ivbap.
    endform.
    Regards,
    Rich Heilman

  • Reuse alv hierseq list display pgm doubt

    can anyone tell me s my coding s write or not becos in the report output i cannot view the line item details but it s gettign populated in the itab
    REPORT ZTEST_1.
    TABLES: KNB1,BSID.
    TYPE-POOLS: SLIS.
    *TYPES:BEGIN OF TYP_OUTPUT.
    INCLUDE STRUCTURE ZRFPOSXEXT.
    *TYPES:END OF TYP_OUTPUT.
    TYPES:BEGIN OF TYP_BSEG,
    bukrs like bsid-bukrs,
    kunnr like bsid-kunnr,
    zuonr like bsid-zuonr,
    belnr like bsid-belnr,
    bldat like bsid-bldat,
    xblnr like bsid-xblnr,
    blart like bsid-blart,
    dmbtr like bsid-dmbtr,
    aufnr like bsid-aufnr,
    vbel2 like bsid-vbel2,
    posn2 like bsid-posn2,
    END OF TYP_BSEG.
    TYPES:BEGIN OF TYP_VBRP,
    VBELN LIKE VBRP-VBELN,
    AUBEL LIKE VBRP-AUBEL,
    AUPOS LIKE VBRP-AUPOS,
    VKGRP LIKE VBRP-VKGRP,
    TDNAME LIKE STXH-TDNAME,
    TDLINE LIKE TLINE-TDLINE,
    END OF TYP_VBRP.
    data: wa_vbrp type typ_vbrp.
    DATA:
    *GT_HEADER_TABLE TYPE TYP_OUTPUT OCCURS 0 WITH HEADER LINE,
    GT_ITEM_TABLE TYPE TYP_VBRP OCCURS 0 WITH HEADER LINE.
    DATA: IT_BSEG TYPE TYP_BSEG OCCURS 0 WITH HEADER LINE.
    Define fieldcatalog
    DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    Callback program
    DATA: G_REPID LIKE SY-REPID.
    List layout description
    DATA: GS_LAYOUT TYPE SLIS_LAYOUT_ALV.
    Group order criterium
    DATA: GS_KEYINFO TYPE SLIS_KEYINFO_ALV.
    Layout *
    Definition for field choice screen **
    GS_LAYOUT-HEADER_TEXT = 'HEADER'.
    GS_LAYOUT-ITEM_TEXT = 'ITEM'.
    GS_LAYOUT-DEFAULT_ITEM = 'X'.
    Initialization fieldcatalog ***
    G_REPID = SY-REPID.
    PERFORM FIELDCAT_INIT USING GT_FIELDCAT[].
    Data selection ***
    PERFORM SELECT_DATA.
    Define keyinfo as sort group definition ***
    CLEAR GS_KEYINFO.
    GS_KEYINFO-HEADER01 = 'BELNR'. "idenify header and item
    GS_KEYINFO-ITEM01 = 'VBELN'.
    Call function to list display (hier-seq) ***
    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = G_REPID
    IS_LAYOUT = GS_LAYOUT
    IT_FIELDCAT = GT_FIELDCAT[]
    I_TABNAME_HEADER = 'GT_HEADER_TABLE'
    I_TABNAME_HEADER = 'IT_BSEG'
    I_TABNAME_ITEM = 'GT_ITEM_TABLE'
    I_STRUCTURE_NAME_HEADER = <STRUCTURE_NAME_HEADER>
    I_STRUCTURE_NAME_ITEM = <STRUCTURE_NAME_ITEM>
    IS_KEYINFO = GS_KEYINFO
    TABLES
    T_OUTTAB_HEADER = GT_HEADER_TABLE
    T_OUTTAB_HEADER = IT_BSEG
    T_OUTTAB_ITEM = GT_ITEM_TABLE
    EXCEPTIONS
    PROGRAM_ERROR = 1.
    FORMS ***
    FORM FIELDCAT_INIT USING RT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    Deviations of group fields to be merged *
    Initialize group field(s) of header table **
    CLEAR LS_FIELDCAT.
    ls_fieldcat-col_pos = 1.
    LS_FIELDCAT-TABNAME = 'IT_BSEG'.
    LS_FIELDCAT-FIELDNAME = 'BLART'.
    LS_FIELDCAT-KEY = 'X'. " sets key field
    LS_FIELDCAT-SELTEXT_M = 'DOC TYPE'.
    LS_FIELDCAT-OUTPUTLEN = 2.
    APPEND LS_FIELDCAT TO gt_fieldcat.
    CLEAR LS_FIELDCAT.
    ls_fieldcat-col_pos = 2.
    LS_FIELDCAT-TABNAME = 'IT_BSEG'.
    LS_FIELDCAT-FIELDNAME = 'BLDAT'.
    LS_FIELDCAT-KEY = 'X'. " sets key field
    LS_FIELDCAT-SELTEXT_M = 'DOC DATE'.
    LS_FIELDCAT-OUTPUTLEN = 8.
    APPEND LS_FIELDCAT TO gt_fieldcat.
    CLEAR LS_FIELDCAT.
    ls_fieldcat-col_pos = 3.
    LS_FIELDCAT-TABNAME = 'IT_BSEG'.
    LS_FIELDCAT-FIELDNAME = 'BELNR'.
    LS_FIELDCAT-KEY = 'X'. " sets key field
    LS_FIELDCAT-SELTEXT_M = 'ACC DOC NO'.
    LS_FIELDCAT-OUTPUTLEN = 10.
    APPEND LS_FIELDCAT TO gt_fieldcat.
    CLEAR LS_FIELDCAT.
    ls_fieldcat-col_pos = 4.
    LS_FIELDCAT-TABNAME = 'IT_BSEG'.
    LS_FIELDCAT-FIELDNAME = 'XBLNR'.
    LS_FIELDCAT-KEY = 'X'. " sets key field
    LS_FIELDCAT-SELTEXT_M = 'REFERENCE'.
    LS_FIELDCAT-OUTPUTLEN = 16.
    APPEND LS_FIELDCAT TO gt_fieldcat.
    CLEAR LS_FIELDCAT.
    ls_fieldcat-col_pos = 5.
    LS_FIELDCAT-TABNAME = 'IT_BSEG'.
    LS_FIELDCAT-FIELDNAME = 'ZUONR'.
    LS_FIELDCAT-KEY = 'X'. " sets key field
    LS_FIELDCAT-SELTEXT_M = 'ASSGNMENT NO'.
    LS_FIELDCAT-OUTPUTLEN = 19.
    APPEND LS_FIELDCAT TO gt_fieldcat.
    CLEAR LS_FIELDCAT.
    ls_fieldcat-col_pos = 6.
    LS_FIELDCAT-TABNAME = 'IT_BSEG'.
    LS_FIELDCAT-FIELDNAME = 'DMBTR'.
    LS_FIELDCAT-KEY = 'X'. " sets key field
    LS_FIELDCAT-SELTEXT_M = 'AMT N LOC CURR'.
    LS_FIELDCAT-OUTPUTLEN = 13.
    APPEND LS_FIELDCAT TO gt_fieldcat.
    Initialize keyfield(s) of item table **
    CLEAR LS_FIELDCAT.
    ls_fieldcat-col_pos = 7.
    LS_FIELDCAT-TABNAME = 'GT_ITEM_TABLE'.
    LS_FIELDCAT-FIELDNAME = 'AUPOS'.
    LS_FIELDCAT-TECH = 'X'. " sets technical field
    LS_FIELDCAT-SELTEXT_M = 'LINE ITEM'.
    LS_FIELDCAT-OUTPUTLEN = 6.
    APPEND LS_FIELDCAT TO gt_fieldcat.
    CLEAR LS_FIELDCAT.
    ls_fieldcat-col_pos = 8.
    LS_FIELDCAT-TABNAME = 'GT_ITEM_TABLE'.
    LS_FIELDCAT-FIELDNAME = 'TDLINE'.
    LS_FIELDCAT-TECH = 'X'. " sets technical field
    LS_FIELDCAT-SELTEXT_M = 'OI NOTES'.
    LS_FIELDCAT-OUTPUTLEN = 132.
    APPEND LS_FIELDCAT TO gt_fieldcat.
    Hidden field(s) of tables (header and/or item) **
    CLEAR LS_FIELDCAT.
    ls_fieldcat-tabname = '<header/item_table_name>'.
    LS_FIELDCAT-FIELDNAME = '<GROUP_FIELD_NAME>'.
    LS_FIELDCAT-NO_OUT = 'X'. "sets hidden field
    APPEND LS_FIELDCAT TO RT_FIELDCAT.
    ENDFORM. "fieldcat_init
    FORM SELECT_DATA.
    data: begin of wa_olino,
    tdname like stxh-tdname,
    tdline like tline-tdline,
    end of wa_olino.
    data: it_olino like wa_olino occurs 0 with header line.
    data: begin of wa_stxh,
    tdname like stxh-tdname,
    end of wa_stxh.
    data: it_stxh like wa_stxh occurs 0 with header line.
    data: begin of wa_lines.
    include structure ztline.
    data: end of wa_lines.
    data: IT_LINES LIKE wa_lines OCCURS 0 WITH HEADER LINE.
    select bukrs kunnr zuonr belnr bldat xblnr blart dmbtr aufnr vbel2
    posn2
    from bsid
    into table it_bseg
    where kunnr in so_wlkun
    and bukrs in so_wlbuk.
    select vbeln aubel aupos vkgrp
    from vbrp
    into table gt_item_table
    for all entries in it_bseg
    where vbeln = it_bseg-belnr.
    sort gt_item_table by aubel aupos.
    loop at gt_item_table into wa_vbrp.
    concatenate wa_vbrp-aubel wa_vbrp-aupos into wa_olino-tdname.
    wa_vbrp-tdname = wa_olino-tdname.
    modify gt_item_table from wa_vbrp.
    append wa_olino to it_olino.
    endloop.
    select tdname from stxh into corresponding fields of table it_stxh
    for all entries in it_olino
    where tdobject = 'VBBP'
    and tdname = it_olino-tdname
    and tdid = '0002'
    and tdspras = 'EN'.
    data: j type i,k_lines type i..
    sort it_stxh by tdname.
    *sort it_output by tdname.
    describe table GT_ITEM_TABLE lines k_lines.
    *loop at it_output into wa_output. "where blart = '1Z'.
    loop at gt_item_table into wa_vbrp.
    loop at it_stxh where tdname = wa_vbrp-tdname.
    read table it_stxh.
    CALL FUNCTION 'ZREAD_TEXT_1'
    EXPORTING
    CLIENT = SY-MANDT
    ID = '0002'
    LANGUAGE = SY-LANGU
    NAME = IT_STXH-tdname
    OBJECT = 'VBBP'
    ARCHIVE_HANDLE = 0
    LOCAL_CAT = ' '
    IMPORTING
    HEADER =
    TABLES
    LINES = IT_LINES
    EXCEPTIONS
    ID = 1
    LANGUAGE = 2
    NAME = 3
    NOT_FOUND = 4
    OBJECT = 5
    REFERENCE_CHECK = 6
    WRONG_ACCESS_TO_ARCHIVE = 7
    OTHERS = 8
    *data: I type i.
    if sy-subrc = 0.
    loop at it_lines.
    it_lines-tdname = wa_vbrp-tdname.
    modify it_lines. "from wa_lines.
    endloop.
    loop at it_lines.
    *i = sy-tfill.
    wa_vbrp-tdline = it_lines.
    if sy-tabix = 1.
    modify gt_item_table from wa_vbrp.
    else.
    append wa_vbrp to gt_item_table.
    endif.
    clear it_lines-tdline.
    endloop.
    endif.
    endloop.
    if sy-tabix = k_lines.
    exit.
    endif.
    endloop.
    sort it_olino by tdname.
    ENDFORM. " select_data

    Hi,
    Go thru the following Example program. It can solve ur problem..
    *& Report         : ZASSG_ALV_JAYARAM3
    *& Title          : Hierarchical sequential ALV report
    *& Author         :
    *& Created on     : *& Request        :
    *& Desription     : Generates a Hierarchial sequental ALV report to list
                      out Billing details.
    *&                     Modification Log
    *& Mod #    Author               Date         Requested by
    *&       Reason for Change
    *& 00 #
    REPORT ZASSG_ALV_JAYARAM3 NO STANDARD PAGE HEADING
                                         LINE-SIZE 132
                                         LINE-COUNT 64
                                        MESSAGE-ID Z00.
    *..Type Definitions for ALV Report
    TYPE-POOLS SLIS.
    Table/Structure declarations.                                        *
    TABLES : VBRK,   " Billing: Header Data
             VBRP,   " Billing: Item Data
             T001,   " Comapny Codes
             TVKOT,  " Sales Organizations: Texts
             MAKT.   " Material Descriiptions
    *.. Internal Tables declaration                                        *
    *----- Internal table to store billing docs which are not cancelled
    DATA : BEGIN OF IT_VBRK OCCURS 0,
             VBELN LIKE VBRK-VBELN,    " Billing document
             WAERK LIKE VBRK-WAERK,    " SD document currency
             VKORG LIKE VBRK-VKORG,    " Sales organization
             VTEXT LIKE TVKOT-VTEXT,   " Sales organization text
             FKDAT LIKE VBRK-FKDAT,    " Billing date
             BUKRS LIKE VBRK-BUKRS,    " Company Code
             BUTXT LIKE T001-BUTXT,    " Company Code text
             NETWR LIKE VBRK-NETWR,    " Net value in document currency
           END OF IT_VBRK.
    *-----Internal table to stroe ITEM DETAILS
    DATA: BEGIN OF IT_VBRP OCCURS 0,
           VBELN2 LIKE VBRP-VBELN,     " Billing document
            POSNR LIKE VBRP-POSNR,     " Billing item
            FKIMG LIKE VBRP-FKIMG,     " Actual billed quantity
            VRKME LIKE VBRP-VRKME,     " Sales unit
            NETWR LIKE VBRP-NETWR,     " Net value of the billing item
            MATNR LIKE VBRP-MATNR,     " Material number
            ARKTX LIKE VBRP-ARKTX,     " Short text for sales order item
    END OF IT_VBRP.
                       Variable / Flag Declerations                      *
    DATA : FG_COLOR    VALUE ' ',  " FLAG TO CHANGE THE COLOR OF THE RECORD
           FG_NO_DATA  VALUE ' '.  " FLAG TO CHECK THE DATA
    DATA : V_REPID   TYPE SYREPID.
                         ALV Type declaration                            *
    DATA : IT_FIELDCAT TYPE STANDARD TABLE OF
                       SLIS_FIELDCAT_ALV  WITH HEADER LINE.
    DATA : IT_SORT TYPE SLIS_T_SORTINFO_ALV,
           WA_SORT TYPE SLIS_SORTINFO_ALV.
    DATA : IT_EVENT TYPE SLIS_T_EVENT,
           WA_EVENT LIKE LINE OF IT_EVENT.
    DATA : IT_HEADINGS TYPE STANDARD TABLE OF
                       SLIS_LISTHEADER WITH HEADER LINE.
    DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA : WA_KEYINFO TYPE SLIS_KEYINFO_ALV.
    Selection Screen.                                                    *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS :  S_VBELN FOR VBRK-VBELN,            " Billing doc no
                      S_FKDAT FOR VBRK-FKDAT OBLIGATORY, " Billing date
                      S_MATNR FOR VBRP-MATNR.            " Material no
    SELECTION-SCREEN END OF BLOCK B1.
    Event:Initialization                                                 *
    INITIALIZATION.
      V_REPID = SY-REPID.
      S_FKDAT-LOW  = SY-DATUM - 200.
      S_FKDAT-HIGH = SY-DATUM.
      APPEND S_FKDAT.
    AT Selection Screen.                                                 *
    AT SELECTION-SCREEN.
      PERFORM VALIDATE_VBELN.
      PERFORM VALIDATE_MATNR.
    Event: Start-of-Selection                                            *
    START-OF-SELECTION.
      PERFORM GET_VBRK_DATA.
      PERFORM GET_VBRP_DATA.
    Event: End-of-Selection                                            *
    END-OF-SELECTION.
      PERFORM GET_EVENTS.
      PERFORM FIELDCATALOG.
      PERFORM LIST_DISPLAY.
                             FORM DEFINITIONS                            *
    *&      Form  list_display
          text
    -->  p1        text
    <--  p2        text
    FORM LIST_DISPLAY.
      WA_LAYOUT-INFO_FIELDNAME = 'COLOR'.
      WA_LAYOUT-TOTALS_TEXT = 'GRAND TOTAL'.
      WA_LAYOUT-ZEBRA = 'X'.
      WA_LAYOUT-KEY_HOTSPOT = 'X'.
      WA_KEYINFO-HEADER01 = 'VBELN'.
      WA_KEYINFO-ITEM01 = 'VBELN2'.
      CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
        EXPORTING
       I_INTERFACE_CHECK              = ' '
          I_CALLBACK_PROGRAM             = V_REPID
       I_CALLBACK_PF_STATUS_SET       = ' '
       I_CALLBACK_USER_COMMAND        = ' '
          IS_LAYOUT                      = WA_LAYOUT
          IT_FIELDCAT                    = IT_FIELDCAT[]
       IT_EXCLUDING                   =
       IT_SPECIAL_GROUPS              =
          IT_SORT                        = IT_SORT
       IT_FILTER                      =
       IS_SEL_HIDE                    =
       I_SCREEN_START_COLUMN          = 0
       I_SCREEN_START_LINE            = 0
       I_SCREEN_END_COLUMN            = 0
       I_SCREEN_END_LINE              = 0
       I_DEFAULT                      = 'X'
       I_SAVE                         = ' '
       IS_VARIANT                     =
       IT_EVENTS                      =
       IT_EVENT_EXIT                  =
          I_TABNAME_HEADER              = 'IT_VBRK'
          I_TABNAME_ITEM                = 'IT_VBRP'
       I_STRUCTURE_NAME_HEADER        =
       I_STRUCTURE_NAME_ITEM          =
          IS_KEYINFO                    = WA_KEYINFO
       IS_PRINT                       =
       IS_REPREP_ID                   =
       I_BUFFER_ACTIVE                =
       I_BYPASSING_BUFFER             =
    IMPORTING
       E_EXIT_CAUSED_BY_CALLER        =
       ES_EXIT_CAUSED_BY_USER         =
        TABLES
          T_OUTTAB_HEADER               = IT_VBRK
          T_OUTTAB_ITEM                 = IT_VBRP
    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.                    " list_display
    *&      Form  fieldcatalog
          text
    -->  p1        text
    <--  p2        text
    FORM FIELDCATALOG.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
          I_PROGRAM_NAME             = V_REPID
          I_INTERNAL_TABNAME         = 'IT_VBRK'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
          I_INCLNAME                 = V_REPID
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
        CHANGING
          CT_FIELDCAT                = IT_FIELDCAT[]
       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.
    *..Changing the fieldcatlog as required
      LOOP AT IT_FIELDCAT.
        CASE IT_FIELDCAT-FIELDNAME.
          WHEN 'VBELN'.
            IT_FIELDCAT-SELTEXT_L = 'Billing doc no'.
            IT_FIELDCAT-SELTEXT_M = 'Bill No'.
            IT_FIELDCAT-SELTEXT_S = 'Bill'.
            IT_FIELDCAT-OUTPUTLEN = '15'.
            MODIFY IT_FIELDCAT TRANSPORTING SELTEXT_L
                                            SELTEXT_M
                                            SELTEXT_S
                                            OUTPUTLEN
                                      WHERE FIELDNAME = 'VBELN'.
          WHEN 'WAERK'.
            IT_FIELDCAT-SELTEXT_L = 'SD document Currency'.
            IT_FIELDCAT-SELTEXT_M = 'Document Currency'.
            IT_FIELDCAT-SELTEXT_S = 'Currency'.
            IT_FIELDCAT-OUTPUTLEN = '15'.
            MODIFY IT_FIELDCAT TRANSPORTING SELTEXT_L
                                            SELTEXT_M
                                            SELTEXT_S
                                      WHERE FIELDNAME = 'WAERK'.
          WHEN 'VKORG'.
            IT_FIELDCAT-SELTEXT_L = 'Sales Organisation'.
            IT_FIELDCAT-SELTEXT_M = 'Sales Org'.
            IT_FIELDCAT-SELTEXT_S = 'S,Org'.
            IT_FIELDCAT-OUTPUTLEN = '15'.
            MODIFY IT_FIELDCAT TRANSPORTING SELTEXT_L
                                            SELTEXT_M
                                            SELTEXT_S
                                      WHERE FIELDNAME = 'VKORG'.
          WHEN 'VTEXT'.
            IT_FIELDCAT-SELTEXT_L = 'Sales Organisation Name'.
            IT_FIELDCAT-SELTEXT_M = 'Sales Org Text'.
            IT_FIELDCAT-SELTEXT_S = 'S,Org'.
            IT_FIELDCAT-OUTPUTLEN = '30'.
            MODIFY IT_FIELDCAT TRANSPORTING SELTEXT_L
                                            SELTEXT_M
                                            SELTEXT_S
                                      WHERE FIELDNAME = 'VTEXT'.
          WHEN 'FKDAT'.
            IT_FIELDCAT-SELTEXT_L = 'Billing Date'.
            IT_FIELDCAT-SELTEXT_M = 'Bill.Date'.
            IT_FIELDCAT-SELTEXT_S = 'BDate'.
            IT_FIELDCAT-OUTPUTLEN = '15'.
            MODIFY IT_FIELDCAT TRANSPORTING SELTEXT_L
                                            SELTEXT_M
                                            SELTEXT_S
                                      WHERE FIELDNAME = 'FKDAT'.
          WHEN 'BUKRS'.
            IT_FIELDCAT-SELTEXT_L = 'Company Code'.
            IT_FIELDCAT-SELTEXT_M = 'Company'.
            IT_FIELDCAT-SELTEXT_S = 'Comp'.
            IT_FIELDCAT-OUTPUTLEN = '15'.
            MODIFY IT_FIELDCAT TRANSPORTING SELTEXT_L
                                            SELTEXT_M
                                            SELTEXT_S
                                      WHERE FIELDNAME = 'BUKRS'.
          WHEN 'BUTXT'.
            IT_FIELDCAT-SELTEXT_L = 'Company Name'.
            IT_FIELDCAT-SELTEXT_M = 'Comp Text'.
            IT_FIELDCAT-SELTEXT_S = 'Comp'.
            IT_FIELDCAT-OUTPUTLEN = '25'.
            MODIFY IT_FIELDCAT TRANSPORTING SELTEXT_L
                                            SELTEXT_M
                                            SELTEXT_S
                                      WHERE FIELDNAME = 'BUTXT'.
          WHEN 'NETWR'.
            IT_FIELDCAT-SELTEXT_L = 'Net value in docu currency'.
            IT_FIELDCAT-SELTEXT_M = 'Net value in currency'.
            IT_FIELDCAT-SELTEXT_S = 'Net Value'.
            IT_FIELDCAT-OUTPUTLEN = '20'.
            IT_FIELDCAT-DO_SUM    = 'X'.
            MODIFY IT_FIELDCAT TRANSPORTING SELTEXT_L
                                            SELTEXT_M
                                            SELTEXT_S
                                            DO_SUM
                                      WHERE FIELDNAME = 'NETWR'.
        ENDCASE.
      ENDLOOP.
      PERFORM FIELDCAT_SECLIST.
    ENDFORM.                    " fieldcatalog
    *&      Form  sort_tab
          text
    -->  p1        text
    <--  p2        text
    FORM SORT_TAB.
      CLEAR WA_SORT.
      WA_SORT-FIELDNAME = 'VBELN'.
      WA_SORT-SPOS = '1'.
      WA_SORT-UP = 'X'.
      WA_SORT-SUBTOT = 'X'.
      APPEND WA_SORT TO IT_SORT.
    ENDFORM.                    " sort_tab
    *&      Form  get_events
          text
    -->  p1        text
    <--  p2        text
    FORM GET_EVENTS.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE     = 1
           IMPORTING
                ET_EVENTS       = IT_EVENT
           EXCEPTIONS
                LIST_TYPE_WRONG = 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.
      READ TABLE IT_EVENT INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
      WA_EVENT-FORM = 'DISPLAY_HEADER'.
      MODIFY IT_EVENT FROM WA_EVENT INDEX SY-TABIX.
    ENDFORM.                    " get_events
    *&      Form  DISPLAY_HEADER
          text
    -->  p1        text
    <--  p2        text
    FORM DISPLAY_HEADER.
      WRITE : /3   'Date : ',
               10  SY-DATUM USING EDIT MASK '__/__/____',
               35  'Intelligroup Asia Pvt. Ltd',
               80  'Time : ',
               90  SY-UZEIT,
              /3   'User : ',
               10  SY-UNAME,
               30  SY-TITLE,
               80  'Page  : ',
               90 SY-PAGNO.
    ENDFORM.                    " DISPLAY_HEADER
    *&      Form  VALIDATE_VBELN
          text
    -->  p1        text
    <--  p2        text
    FORM VALIDATE_VBELN.
    Validating Billing doc no
      SELECT VBELN
        INTO VBRK-VBELN
       UP TO 1 ROWS
        FROM VBRK
       WHERE VBELN IN S_VBELN.
      ENDSELECT.
      IF SY-SUBRC NE 0.
        MESSAGE E010. " Invalid billing doc no
      ENDIF.
    ENDFORM.                    " VALIDATE_VBELN
    *&      Form  VALIDATE_MATNR
          text
    -->  p1        text
    <--  p2        text
    FORM VALIDATE_MATNR.
    Validating material no
      SELECT MATNR
        INTO VBRP-MATNR
       UP TO 1 ROWS
        FROM VBRP
       WHERE MATNR IN S_MATNR.
      ENDSELECT.
      IF SY-SUBRC NE 0.
        MESSAGE E018.    " Invalid material number
      ENDIF.
    ENDFORM.                    " VALIDATE_MATNR
    *&      Form  GET_VBRK_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM GET_VBRK_DATA.
    To get Billing doc detials based on selections
      SELECT V~VBELN
             V~WAERK
             V~VKORG
             V~FKDAT
             V~BUKRS
             V~NETWR
             T~VTEXT
             C~BUTXT
        INTO CORRESPONDING FIELDS OF TABLE IT_VBRK
        FROM VBRK AS V
       INNER JOIN VBRP AS P
          ON VVBELN = PVBELN
       INNER JOIN TVKOT AS T
          ON VVKORG = TVKORG
       INNER JOIN T001 AS C
          ON VBUKRS = CBUKRS
       WHERE V~VBELN IN S_VBELN
         AND V~FKDAT IN S_FKDAT
         AND P~MATNR IN S_MATNR.
      SORT IT_VBRK.
      DELETE ADJACENT DUPLICATES FROM IT_VBRK COMPARING VBELN.
      IF SY-SUBRC NE 0.
        FG_NO_DATA = 'X'.
      ENDIF.
    ENDFORM.                    " GET_VBRK_DATA
    *&      Form  GENERATE_SECLIST
          text
    -->  p1        text
    <--  p2        text
    FORM GENERATE_SECLIST USING R_UCOMM     LIKE SY-UCOMM
                                RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN '&IC1'. "DOUBLE CLICK
          READ TABLE IT_VBRK INDEX RS_SELFIELD-TABINDEX.
      ENDCASE.
    ENDFORM.                    " GENERATE_SECLIST
    *&      Form  FIELDCAT_SECLIST
          text
    -->  p1        text
    <--  p2        text
    FORM FIELDCAT_SECLIST.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
         EXPORTING
            I_PROGRAM_NAME           = V_REPID
            I_INTERNAL_TABNAME       = 'IT_VBRP'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
            I_INCLNAME               = V_REPID
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
          CHANGING
            CT_FIELDCAT              = IT_FIELDCAT[]
         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.
    *..Changing the fieldcatlog as required
      LOOP AT IT_FIELDCAT.
        CASE IT_FIELDCAT-FIELDNAME.
          WHEN 'VBELN2'.
             IT_FIELDCAT-NO_OUT = 'X'.
             IT_FIELDCAT-KEY = SPACE.
             MODIFY IT_FIELDCAT TRANSPORTING NO_OUT
                                             KEY
                                      WHERE FIELDNAME = 'VBELN2'.
          WHEN 'POSNR'.
            IT_FIELDCAT-SELTEXT_L = 'Billing Iem no'.
            IT_FIELDCAT-SELTEXT_M = 'Bill Item No'.
            IT_FIELDCAT-SELTEXT_S = 'Item No'.
            IT_FIELDCAT-OUTPUTLEN = '15'.
            MODIFY IT_FIELDCAT TRANSPORTING SELTEXT_L
                                            SELTEXT_M
                                            SELTEXT_S
                                            OUTPUTLEN
                                      WHERE FIELDNAME = 'POSNR'.
          WHEN 'FKIMG'.
            IT_FIELDCAT-SELTEXT_L = 'Actual billed quantity'.
            IT_FIELDCAT-SELTEXT_M = 'Billed Quantity'.
            IT_FIELDCAT-SELTEXT_S = 'Bill.Qty'.
            IT_FIELDCAT-OUTPUTLEN = '15'.
            MODIFY IT_FIELDCAT TRANSPORTING SELTEXT_L
                                            SELTEXT_M
                                            SELTEXT_S
                                      WHERE FIELDNAME = 'FKIMG'.
          WHEN 'VRKME'.
            IT_FIELDCAT-SELTEXT_L = 'Sales Unit'.
            IT_FIELDCAT-SELTEXT_M = 'Sale unit'.
            IT_FIELDCAT-SELTEXT_S = 'S.Unit'.
            IT_FIELDCAT-OUTPUTLEN = '15'.
            MODIFY IT_FIELDCAT TRANSPORTING SELTEXT_L
                                            SELTEXT_M
                                            SELTEXT_S
                                      WHERE FIELDNAME = 'VRKME'.
          WHEN 'NETWR'.
            IT_FIELDCAT-SELTEXT_L = 'Net value in docu currency'.
            IT_FIELDCAT-SELTEXT_M = 'Net value in currency'.
            IT_FIELDCAT-SELTEXT_S = 'Net Value'.
            IT_FIELDCAT-OUTPUTLEN = '20'.
            IT_FIELDCAT-DO_SUM    = 'X'.
            MODIFY IT_FIELDCAT TRANSPORTING SELTEXT_L
                                            SELTEXT_M
                                            SELTEXT_S
                                            DO_SUM
                                     WHERE FIELDNAME = 'NETWR'.
          WHEN 'MATNR'.
            IT_FIELDCAT-SELTEXT_L = 'Material Number'.
            IT_FIELDCAT-SELTEXT_M = 'Mat. Number'.
            IT_FIELDCAT-SELTEXT_S = 'Mat. No'.
            IT_FIELDCAT-OUTPUTLEN = '30'.
            MODIFY IT_FIELDCAT TRANSPORTING SELTEXT_L
                                            SELTEXT_M
                                            SELTEXT_S
                                      WHERE FIELDNAME = 'MATNR'.
          WHEN 'ARKTX'.
            IT_FIELDCAT-SELTEXT_L = 'Text for sales order item'.
            IT_FIELDCAT-SELTEXT_M = 'Sale Order Text'.
            IT_FIELDCAT-SELTEXT_S = 'SO Item text'.
            IT_FIELDCAT-OUTPUTLEN = '30'.
            MODIFY IT_FIELDCAT TRANSPORTING SELTEXT_L
                                            SELTEXT_M
                                            SELTEXT_S
                                      WHERE FIELDNAME = 'ARKTX'.
        ENDCASE.
      ENDLOOP.
    ENDFORM.                    " FIELDCAT_SECLIST
    *&      Form  GET_VBRP_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM GET_VBRP_DATA.
      SELECT VBELN
             POSNR
             FKIMG
             VRKME
             NETWR
             MATNR
             ARKTX
        INTO TABLE IT_VBRP
        FROM VBRP
         FOR ALL ENTRIES IN IT_VBRK
       WHERE VBELN EQ IT_VBRK-VBELN.
    ENDFORM.                    " GET_VBRP_DATA

  • Big problem with ALV - Merge

    Hi,
    I have an internal table like this:
    TKNUM|VSART|KUNNR
    123444|A_____|AAAA
    123444|A_____|BBBB
    123444|A_____|CCCC
    456777|A_____|DDDD
    456777|A_____|EEEE
    456777|A_____|AAAA
    If i use alv with merge (tknum, vsart) i have this:
    TKNUM|VSART |KUNNR
    123444|A_____|AAAA
    ______|______|BBBB
    ______|______|CCCC
    456777|______|DDD
    ______|______|EEEE
    ______|______|AAAA
    But what i want is this:
    TKNUM| VSART|KUNNR
    123444|A_____|AAAA
    ______|______|BBBB
    ______|______|CCCC
    456777|A_____|DDDD
    ______|______|EEEE
    ______|______|AAAA
    Any ideas?

    hi,
    you need to build sort table based on tknum and vasrt.
    check this demo program code..
    REPORT BALVST02 NO STANDARD PAGE HEADING.
    * ALV
    TYPE-POOLS: SLIS.
    * DB-Table
    TABLES SFLIGHT.
    * Includes
    INCLUDE <ICON>.
    INCLUDE <SYMBOL>.
    CONSTANTS:
    GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
    DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
          GS_LAYOUT   TYPE SLIS_LAYOUT_ALV,
          GS_PRINT    TYPE SLIS_PRINT_ALV,
          GT_SORT     TYPE SLIS_T_SORTINFO_ALV,
          GT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV,
          GT_EVENTS   TYPE SLIS_T_EVENT.
    * Data to be displayed
    DATA: BEGIN OF GT_SFLIGHT OCCURS 0.
            INCLUDE STRUCTURE SFLIGHT.
    DATA: ADD1,
          CARRNAME LIKE SCARR-CARRNAME,
          BOX,
          LIGHTS.
    DATA: END OF GT_SFLIGHT.
    DATA: G_REPID LIKE SY-REPID.
    DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
    * Report Selections
    SELECT-OPTIONS CARRID FOR SFLIGHT-CARRID.
    SELECT-OPTIONS CONNID FOR SFLIGHT-CONNID.
    SELECT-OPTIONS FLDATE FOR SFLIGHT-FLDATE.
    SELECTION-SCREEN SKIP 1.
    * Parameters
    PARAMETERS: P_MAXROW TYPE I DEFAULT 30.
    SELECTION-SCREEN SKIP 1.
    * Variante
    SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE TEXT-006.
    PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.
    SELECTION-SCREEN END OF BLOCK 0.
    * Layout
    SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME TITLE TEXT-060.
    PARAMETERS:
                P_ZEBRA  AS CHECKBOX DEFAULT ' ',
                P_NOCOLH AS CHECKBOX DEFAULT ' ',
                P_NOVLIN AS CHECKBOX DEFAULT ' ',
                P_COLOPT AS CHECKBOX DEFAULT ' ',
                P_KEYHOT AS CHECKBOX DEFAULT ' ',
                P_NOINPT AS CHECKBOX DEFAULT ' ',
                P_MERGE  AS CHECKBOX DEFAULT ' '.
    SELECTION-SCREEN END OF BLOCK A.
    SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME TITLE TEXT-061.
    PARAMETERS:
                P_LIGHTS AS CHECKBOX DEFAULT ' ',
                P_LIGHTC AS CHECKBOX DEFAULT ' '.
    SELECTION-SCREEN END OF BLOCK B.
    SELECTION-SCREEN BEGIN OF BLOCK C WITH FRAME TITLE TEXT-062.
    PARAMETERS:
                P_BEFORE AS CHECKBOX DEFAULT ' ',
                P_TOTONL AS CHECKBOX DEFAULT ' ',
                P_TOTEXT(60),
                P_STTEXT(60).
    SELECTION-SCREEN END OF BLOCK C.
    SELECTION-SCREEN BEGIN OF BLOCK D WITH FRAME TITLE TEXT-063.
    PARAMETERS:
                P_GPCE   AS CHECKBOX DEFAULT ' ',
                P_CHKBOX AS CHECKBOX DEFAULT ' ',
                P_DETPOP AS CHECKBOX DEFAULT ' '.
    SELECTION-SCREEN END OF BLOCK D.
    SELECTION-SCREEN BEGIN OF BLOCK E WITH FRAME TITLE TEXT-064.
    PARAMETERS:
                P_PRINT  AS CHECKBOX DEFAULT ' ',
                P_NOSINF AS CHECKBOX DEFAULT ' ',
                P_NOCOVE AS CHECKBOX DEFAULT ' ',
                P_NONEWP AS CHECKBOX DEFAULT ' ',
                P_NOLINF AS CHECKBOX DEFAULT ' ',
                P_RESERV TYPE I.
    SELECTION-SCREEN END OF BLOCK E.
    DATA:       G_BOXNAM TYPE SLIS_FIELDNAME VALUE  'BOX',
                P_F2CODE LIKE SY-UCOMM       VALUE  '&ETA',
                P_LIGNAM TYPE SLIS_FIELDNAME VALUE  'LIGHTS',
                G_SAVE(1) TYPE C,
                G_DEFAULT(1) TYPE C,
                G_EXIT(1) TYPE C,
                GX_VARIANT LIKE DISVARIANT,
                G_VARIANT LIKE DISVARIANT.
    INITIALIZATION.
      G_REPID = SY-REPID.
      PERFORM E01_FIELDCAT_INIT  USING GT_FIELDCAT[].
      PERFORM E03_EVENTTAB_BUILD USING GT_EVENTS[].
      PERFORM E04_COMMENT_BUILD  USING GT_LIST_TOP_OF_PAGE[].
      PERFORM E06_T_SORT_BUILD   USING GT_SORT[].
      PERFORM E07_SP_GROUP_BUILD USING GT_SP_GROUP[].
    * Schalter Varianten benutzerspezifisch/allgemein speicherbar setzen
    * Set Options: save variants userspecific or general
      G_SAVE = 'A'.
      PERFORM VARIANT_INIT.
    * Get default variant
      GX_VARIANT = G_VARIANT.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
           EXPORTING
                I_SAVE     = G_SAVE
           CHANGING
                CS_VARIANT = GX_VARIANT
           EXCEPTIONS
                NOT_FOUND  = 2.
      IF SY-SUBRC = 0.
        P_VARI = GX_VARIANT-VARIANT.
      ENDIF.
    * Process on value request
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
      PERFORM F4_FOR_VARIANT.
    * PAI
    AT SELECTION-SCREEN.
      PERFORM PAI_OF_SELECTION_SCREEN.
    START-OF-SELECTION.
      PERFORM SELECTION.
    END-OF-SELECTION.
      PERFORM E05_LAYOUT_BUILD USING GS_LAYOUT.     "wg. Parameters
      PERFORM E08_PRINT_BUILD  USING GS_PRINT.      "wg. Parameters
    * Call ABAP/4 List Viewer
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                I_BACKGROUND_ID         = 'ALV_WALLPAPER2'
                I_CALLBACK_PROGRAM      = G_REPID
                I_CALLBACK_HTML_TOP_OF_PAGE = 'HTML_TOP_OF_PAGE'
                I_STRUCTURE_NAME        = 'SFLIGHT'
                IS_LAYOUT               = GS_LAYOUT
                IT_FIELDCAT             = GT_FIELDCAT[]
    *           IT_EXCLUDING            =
                IT_SPECIAL_GROUPS       = GT_SP_GROUP[]
                IT_SORT                 = GT_SORT[]
    *           IT_FILTER               =
    *           IS_SEL_HIDE             =
    *           i_default               = g_default
                I_SAVE                  = G_SAVE
                IS_VARIANT              = G_VARIANT
                IT_EVENTS               = GT_EVENTS[]
    *           IT_EVENT_EXIT           =
                IS_PRINT                = GS_PRINT
    *           I_SCREEN_START_COLUMN   = 0
    *           I_SCREEN_START_LINE     = 0
    *           I_SCREEN_END_COLUMN     = 0
    *           I_SCREEN_END_LINE       = 0
    *      IMPORTING
    *           E_EXIT_CAUSED_BY_CALLER =
           TABLES
                T_OUTTAB                = GT_SFLIGHT.
    *       FORM E01_FIELDCAT_INIT                                        *
    *  -->  E01_LT_FIELDCAT                                               *
    FORM E01_FIELDCAT_INIT USING E01_LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
      DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
      CLEAR LS_FIELDCAT.
    * LS_FIELDCAT-COL_POS      = 1.
      LS_FIELDCAT-FIELDNAME    = 'ADD1'.
      LS_FIELDCAT-REPTEXT_DDIC = '?'.
      LS_FIELDCAT-OUTPUTLEN    = 1.
      LS_FIELDCAT-NO_OUT       = 'X'.
      LS_FIELDCAT-INPUT        = 'X'.
      LS_FIELDCAT-SP_GROUP = 'A'.
      APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME    = 'CARRNAME'.
      LS_FIELDCAT-COL_POS      = 2.
      LS_FIELDCAT-KEY          = 'X'.
      LS_FIELDCAT-KEY_SEL      = 'X'.
      LS_FIELDCAT-REF_TABNAME    = 'SCARR'.
      APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME    = 'SEATSOCC'.
      LS_FIELDCAT-DO_SUM       = 'X'.
      APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME    = 'PRICE'.
      LS_FIELDCAT-DO_SUM       = 'X'.
      APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-COL_POS      = 1.
      LS_FIELDCAT-FIELDNAME    = 'CARRID'.
    * ls_fieldcat-ref_fieldname    = 'SFLIGHT'.
      LS_FIELDCAT-TEXT_FIELDNAME = 'CARRNAME'.
    * append ls_fieldcat to e01_lt_fieldcat.
    * clear ls_fieldcat.
      LS_FIELDCAT-FIELDNAME    = 'CARRID'.
      LS_FIELDCAT-KEY_SEL      = 'X'.
      LS_FIELDCAT-NO_OUT       = 'X'.
      LS_FIELDCAT-OUTPUTLEN    = 7.
      APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
    ENDFORM.
    *       FORM E02_DATA_ADD                                             *
    *  -->  E02_LT_SFLIGHT                                                *
    FORM E02_DATA_ADD TABLES E02_LT_SFLIGHT STRUCTURE GT_SFLIGHT.
      LOOP AT E02_LT_SFLIGHT.
        IF SY-TABIX > 10.
          E02_LT_SFLIGHT-ADD1 = 'A'.
          E02_LT_SFLIGHT-BOX  = 'X'.
          E02_LT_SFLIGHT-LIGHTS = '3'.
        ELSE.
          IF SY-TABIX = 1.
            E02_LT_SFLIGHT-LIGHTS = '2'.
          ELSE.
            E02_LT_SFLIGHT-LIGHTS = '1'.
          ENDIF.
        ENDIF.
        MODIFY E02_LT_SFLIGHT.
      ENDLOOP.
    ENDFORM.
    *       FORM E03_EVENTTAB_BUILD                                       *
    *  -->  E03_LT_EVENTS                                                 *
    FORM E03_EVENTTAB_BUILD USING E03_LT_EVENTS TYPE SLIS_T_EVENT.
      DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = E03_LT_EVENTS.
      READ TABLE E03_LT_EVENTS WITH KEY NAME =  SLIS_EV_TOP_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO E03_LT_EVENTS.
      ENDIF.
    ENDFORM.
    *       FORM E04_COMMENT_BUILD                                        *
    *  -->  E04_LT_TOP_OF_PAGE                                            *
    FORM E04_COMMENT_BUILD USING E04_LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
      DATA: LS_LINE TYPE SLIS_LISTHEADER.
    * Listenüberschrift: Typ H
      CLEAR LS_LINE.
      LS_LINE-TYP  = 'H'.
    * LS_LINE-KEY:  not used for this type
      LS_LINE-INFO = TEXT-100.
      APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
    * Kopfinfo: Typ S
      CLEAR LS_LINE.
      LS_LINE-TYP  = 'S'.
      LS_LINE-KEY  = TEXT-101.
      LS_LINE-INFO = TEXT-102.
      APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
      LS_LINE-KEY  = TEXT-103.
      LS_LINE-INFO = TEXT-104.
      APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
    * Aktionsinfo: Typ A
      CLEAR LS_LINE.
      LS_LINE-TYP  = 'A'.
    * LS_LINE-KEY:  not used for this type
      LS_LINE-INFO = TEXT-105.
      APPEND LS_LINE TO  E04_LT_TOP_OF_PAGE.
    ENDFORM.
    *       FORM E05_LAYOUT_BUILD                                         *
    *  <->  E05_LS_LAYOUT                                                 *
    FORM E05_LAYOUT_BUILD USING E05_LS_LAYOUT TYPE SLIS_LAYOUT_ALV.
      E05_LS_LAYOUT-F2CODE            = P_F2CODE.
      E05_LS_LAYOUT-ZEBRA             = P_ZEBRA.
      E05_LS_LAYOUT-CELL_MERGE        = P_MERGE.
      E05_LS_LAYOUT-COLWIDTH_OPTIMIZE = P_COLOPT.
      IF P_CHKBOX = 'X'.
        E05_LS_LAYOUT-BOX_FIELDNAME     = G_BOXNAM.
      ELSE.
        E05_LS_LAYOUT-BOX_FIELDNAME     = SPACE.
      ENDIF.
      E05_LS_LAYOUT-NO_INPUT          = P_NOINPT.
      E05_LS_LAYOUT-NO_VLINE          = P_NOVLIN.
      E05_LS_LAYOUT-NO_COLHEAD        = P_NOCOLH.
      IF P_LIGHTS = 'X' OR P_LIGHTC = 'X'.
        E05_LS_LAYOUT-LIGHTS_FIELDNAME = P_LIGNAM.
      ELSE.
        CLEAR E05_LS_LAYOUT-LIGHTS_FIELDNAME.
      ENDIF.
      IF P_BEFORE = 'X'.
        E05_LS_LAYOUT-TOTALS_BEFORE_ITEMS = 'X'.
      ENDIF.
      IF P_GPCE = 'X'.
        E05_LS_LAYOUT-GROUP_CHANGE_EDIT = 'X'.
      ENDIF.
      E05_LS_LAYOUT-LIGHTS_CONDENSE = P_LIGHTC.
      E05_LS_LAYOUT-TOTALS_TEXT       = P_TOTEXT.
      E05_LS_LAYOUT-SUBTOTALS_TEXT    = P_STTEXT.
      E05_LS_LAYOUT-TOTALS_ONLY       = P_TOTONL.
      E05_LS_LAYOUT-KEY_HOTSPOT       = P_KEYHOT.
      E05_LS_LAYOUT-DETAIL_POPUP      = P_DETPOP.
    ENDFORM.
    *       FORM E06_T_SORT_BUILD                                         *
    *  -->  E06_LT_SORT                                                   *
    FORM E06_T_SORT_BUILD USING E06_LT_SORT TYPE SLIS_T_SORTINFO_ALV.
      DATA: LS_SORT TYPE SLIS_SORTINFO_ALV.
    * ls_sort-fieldname = 'CARRID'.
    * ls_sort-spos      = 1.
    * ls_sort-up        = 'X'.
    * ls_sort-subtot    = 'X'.
    * append ls_sort to e06_lt_sort.
      CLEAR LS_SORT.
      LS_SORT-FIELDNAME = 'CARRNAME'.
      LS_SORT-SPOS      = 1.
      LS_SORT-UP        = 'X'.
    * ls_sort-subtot    = 'X'.
      APPEND LS_SORT TO E06_LT_SORT.
      APPEND LS_SORT TO E06_LT_SORT.
      LS_SORT-FIELDNAME = 'CONNID'.
      LS_SORT-SPOS      = 2.
      LS_SORT-UP        = 'X'.
    * ls_sort-subtot    = 'X'.
      APPEND LS_SORT TO E06_LT_SORT.
    ENDFORM.
    *       FORM E07_SP_GROUP_BUILD                                       *
    *  -->  E07_LT_SP_GROUP                                               *
    FORM E07_SP_GROUP_BUILD USING E07_LT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV.
      DATA: LS_SP_GROUP TYPE SLIS_SP_GROUP_ALV.
      CLEAR  LS_SP_GROUP.
      LS_SP_GROUP-SP_GROUP = 'A'.
      LS_SP_GROUP-TEXT     = TEXT-005.
      APPEND LS_SP_GROUP TO E07_LT_SP_GROUP.
    ENDFORM.
    *       FORM E08_PRINT_BUILD                                          *
    *  -->  E08_LS_PRINT                                                  *
    FORM E08_PRINT_BUILD USING E08_LS_PRINT TYPE SLIS_PRINT_ALV.
      E08_LS_PRINT-PRINT              = P_PRINT.
      E08_LS_PRINT-NO_PRINT_SELINFOS  = P_NOSINF.
      E08_LS_PRINT-NO_COVERPAGE       = P_NOCOVE.
      E08_LS_PRINT-NO_NEW_PAGE        = P_NONEWP.
      E08_LS_PRINT-NO_PRINT_LISTINFOS = P_NOLINF.
      E08_LS_PRINT-RESERVE_LINES      = P_RESERV.
      E08_LS_PRINT-PRINT              = P_PRINT.
    ENDFORM.
    *       FORM SELECTION                                                *
    FORM SELECTION.
    * select * from sflight into corresponding fields of table gt_sflight
    *                                             up to p_maxrow rows
    *                                             where carrid in carrid
    *                                             and   connid in connid
    *                                             and   fldate in fldate.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_SFLIGHT FROM
                    ( SFLIGHT LEFT JOIN SCARR
                      ON SFLIGHT~CARRID = SCARR~CARRID )
                                                  UP TO P_MAXROW ROWS
                                    WHERE SFLIGHT~CARRID IN CARRID
                                    AND   SFLIGHT~CONNID IN CONNID
                                    AND   SFLIGHT~FLDATE IN FLDATE.
      PERFORM E02_DATA_ADD TABLES GT_SFLIGHT.
    ENDFORM.
    *       FORM TOP_OF_PAGE                                              *
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
    *           i_logo             = 'HTMLCNTL_TESTHTM2_SAPLOGO'
                I_LOGO             = 'ENJOYSAP_LOGO'
                IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
    ENDFORM.
    *       FORM F4_FOR_VARIANT                                           *
    FORM F4_FOR_VARIANT.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
           EXPORTING
                IS_VARIANT          = G_VARIANT
                I_SAVE              = G_SAVE
    *           it_default_fieldcat =
           IMPORTING
                E_EXIT              = G_EXIT
                ES_VARIANT          = GX_VARIANT
           EXCEPTIONS
                NOT_FOUND = 2.
      IF SY-SUBRC = 2.
        MESSAGE ID SY-MSGID TYPE 'S'      NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ELSE.
        IF G_EXIT = SPACE.
          P_VARI = GX_VARIANT-VARIANT.
        ENDIF.
      ENDIF.
    ENDFORM.
    *&      Form  PAI_OF_SELECTION_SCREEN
    *       text
    FORM PAI_OF_SELECTION_SCREEN.
      IF NOT P_VARI IS INITIAL.
        MOVE G_VARIANT TO GX_VARIANT.
        MOVE P_VARI TO GX_VARIANT-VARIANT.
        CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
             EXPORTING
                  I_SAVE     = G_SAVE
             CHANGING
                  CS_VARIANT = GX_VARIANT.
        G_VARIANT = GX_VARIANT.
      ELSE.
        PERFORM VARIANT_INIT.
      ENDIF.
    ENDFORM.                               " PAI_OF_SELECTION_SCREEN
    *&      Form  VARIANT_INIT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM VARIANT_INIT.
      CLEAR G_VARIANT.
      G_VARIANT-REPORT = G_REPID.
    ENDFORM.                               " VARIANT_INIT
    FORM HTML_TOP_OF_PAGE USING R_DYDO TYPE REF TO CL_DD_DOCUMENT.
    ENDFORM.                               " VARIANT_INIT

  • ABAP WD: ALV merge cells

    Hello,
    I have a hierarchical ALV. I need to merge some cells in it.
    For instance, there is a column name: Brand Name. There are multiple rows that have same brand name, let's say SONY.
    Is it possible to merge these cells that have same brand name? If so what should I use?
    Thank you.
    Best Regards,
    Georgy Norkin

    Hi,
    Go through the links,
    Merging cells of a table in Webdynpro
    merging cells in table
    Regards,
    Azaz.

  • Filter option is not working in Reuse alv grid

    Hi all,
    Filter option is not working in alv grid properly.
    if i choose one particular field for filter option .it is working .but another field it is not working though it contains different values.please give the answer.whether i have to pass filter option throuogh reuse_alv _grid or not.thanks in advance
    raj

    Hi raja,
    1. The search/filter is
       CASE SENSITIVE
    2. U can give *
       to search for pattern.
      (IN THAT CASE, it is NOT Case Sensitive)
    regards,
    amit m.

  • Reuse ALV - Only subtotals on first view...how

    Hello
    This is how my current report looks like.
    [http://www.filedump.net/dumped/200809021357031220356701.png]
    Want I want is the first column to be collapsed on first view. The help file had this to say:
    subtot
    'X' = Subtotals for control level changes
    o comp (INTERNAL USE ONLY)
    o expa
    Prequisite:
    IT_SORT-SUBTOT = 'X', that is, the sort criterion is also the
    subtotals criterion.
    If no complete breakdown but only a breakdown to totals level n that
    can be further expanded by the user should be displayed when the
    list is output for the first time, you must set the indicator for
    the totals level criterion of level n.
    I do not understand that part, and haven't found any threads that cover this. I'd de thankful if somebody could help me out.
    bye
    Here is my current code:
    *& Report ZDEMO_ALVGRID *
    *& Example of a simple ALV Grid Report *
    *& The basic requirement for this demo is to display a number of *
    *& fields from the EKKO table. *
    REPORT zdemo_alvgrid .
    TABLES: ekko.
    type-pools: slis. "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
    ebeln TYPE ekpo-ebeln,
    ebelp TYPE ekpo-ebelp,
    statu TYPE ekpo-statu,
    aedat TYPE ekpo-aedat,
    matnr TYPE ekpo-matnr,
    menge TYPE ekpo-menge,
    meins TYPE ekpo-meins,
    netpr TYPE ekpo-netpr,
    peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
    wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
    gd_tab_group type slis_t_sp_group_alv,
    gd_layout type slis_layout_alv,
    gd_repid like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    DATA: T_SORT TYPE SLIS_T_SORTINFO_ALV.
    DATA: S_SORT LIKE LINE OF T_SORT.
    S_SORT-SPOS = '0'.
    S_SORT-FIELDNAME = 'EBELN'. "VENDOR field name.
    S_SORT-UP = 'X'.
    S_SORT-SUBTOT = 'X'.
    APPEND S_SORT TO T_SORT.
    *S_SORT-SPOS = '1'.
    *S_SORT-FIELDNAME = 'GL ACCOUNT FIELD NAME'.
    *S_SORT-UP = 'X'.
    *S_SORT-SUBTOT = 'X'.
    *APPEND S_SORT TO T_SORT.
    perform display_alv_report.
    *& Form BUILD_FIELDCATALOG
    "    * Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    "    * There are a number of ways to create a fieldcat.
    "    * For the purpose of this example i will build the fieldcatalog
    "manualy
    "    * by populating the internal table fields individually and then
    "    * appending the rows. This method can be the most time consuming
    "but can
    "    * also allow you more control of the final product."
    "    * Beware though, you need to ensure that all fields required are
    "    * populated. When using some of functionality available via ALV,
    "such as
    "    * total. You may need to provide more information than if you were
    "    * simply displaying the result
    "    * I.e. Field type may be required in-order for
    "    * the 'TOTAL' function to work.
    fieldcatalog-fieldname = 'EBELN'.
    fieldcatalog-seltext_m = 'Purchase Order'.
    fieldcatalog-col_pos = 0.
    fieldcatalog-outputlen = 10.
    fieldcatalog-emphasize = 'X'.
    fieldcatalog-key = 'X'.
    "    * fieldcatalog-do_sum = 'X'.
    "    * fieldcatalog-no_zero = 'X'.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'EBELP'.
    fieldcatalog-seltext_m = 'PO Item'.
    fieldcatalog-col_pos = 1.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'STATU'.
    fieldcatalog-seltext_m = 'Status'.
    fieldcatalog-col_pos = 2.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'AEDAT'.
    fieldcatalog-seltext_m = 'Item change date'.
    fieldcatalog-col_pos = 3.
    *fieldcatalog-key = 'X'.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'MATNR'.
    fieldcatalog-seltext_m = 'Material Number'.
    fieldcatalog-col_pos = 4.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'MENGE'.
    fieldcatalog-seltext_m = 'PO quantity'.
    fieldcatalog-col_pos = 5.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'MEINS'.
    fieldcatalog-seltext_m = 'Order Unit'.
    fieldcatalog-col_pos = 6.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'NETPR'.
    fieldcatalog-seltext_m = 'Net Price'.
    fieldcatalog-col_pos = 7.
    fieldcatalog-outputlen = 15.
    fieldcatalog-do_sum = 'X'. "Display column total
    fieldcatalog-datatype = 'CURR'.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'PEINH'.
    fieldcatalog-seltext_m = 'Price Unit'.
    fieldcatalog-col_pos = 8.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    endform. " BUILD_FIELDCATALOG
    *& Form BUILD_LAYOUT
    "    * Build layout for ALV grid report
    form build_layout.
    gd_layout-no_input = 'X'.
    gd_layout-colwidth_optimize = 'X'.
    gd_layout-totals_text = 'Totals'(201).
    gd_layout-totals_only = 'X'.
    *gd_layout-totals_only = 'X'.
    "    * gd_layout-f2code = 'DISP'. "Sets fcode for when double
    "    * "click(press f2)
    "    * gd_layout-zebra = 'X'.
    "    * gd_layout-group_change_edit = 'X'.
    "    * gd_layout-header_text = 'helllllo'.
    endform. " BUILD_LAYOUT
    *& Form DISPLAY_ALV_REPORT
    "    * Display report using ALV grid
    form display_alv_report.
    gd_repid = sy-repid.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
    i_callback_program = gd_repid
    "    * i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
    "    * i_callback_user_command = 'USER_COMMAND'
    "    * i_grid_title = outtext
    is_layout = gd_layout
    it_fieldcat = fieldcatalog[]
    it_sort = T_SORT
    "    * it_special_groups = gd_tabgroup
    "    * IT_EVENTS = GT_XEVENTS
    i_save = 'X'
    "    * is_variant = z_template
    tables
    t_outtab = it_ekko
    exceptions
    program_error = 1
    others = 2.
    if sy-subrc = 0.
    "    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    "    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endform. " DISPLAY_ALV_REPORT
    *& Form DATA_RETRIEVAL
    "    * Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
    from ekpo
    into table it_ekko.
    endform. " DATA_RETRIEVAL

    Hello
    The layout is defined in gd_layout.
    I'm not sure if I understand.
    The program does show the subtotals already. But I want a collapsed view like this.
    http://www.filedump.net/dumped/200809021450331220359886.png

  • XML download of REUSE ALV Grid's Output

    Hi,
    I have a ALV Report from which I can download the report into a XML file.
    I need the XML download to happen automatically along with the report display.
    Please suggest how I can do this.
    Thanks,
    Suryakiran D.

    HI,
    try these function modules.
    LIST_DOWNLOAD
    LIST_DOWNLOAD_HTML
    Regards,
    HRA

  • REUSE ALV - different layouts

    Hi Gurus,
    iam having an ALV report with an ALV display. Form this ALV on click of a button i will navigate to another ALV display.(both ALV's are called within the same program).
    Now my problem is with Layout functionalities:
    If a layout is saved in the first ALV, then if i go to second ALV and go for the Layout selection, all the layouts saved in the first ALV are coming in the second ALV.
    If the user selects a layout of the first alv, obvoiusly, no data will be displayed in the second ALV.
    So is there anywy i can go for fresh set of layout's for the two ALV's separately..
    (as per my knowledge, the layouts are stored based on the Program name in the database, so if i go to layout option in both the ALV,s... so the common alv's are coming in both displays's.)
    the above  issue is causing problems to the user...
    iam passing the below data for the ALV..
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = sy-repid
          i_callback_pf_status_set = pfstatus
          i_callback_user_command  = c_usercomm1
          i_callback_top_of_page   = l_v_top
          i_grid_title             = text-064
          is_layout                = fp_wa_layout
          it_fieldcat              = fp_i_fieldcat1
          i_default                = c_x
          i_save                   = 'A'
        TABLES
          t_outtab                 = fp_i_item1
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 1.
    so can anyone of you give me a suggestion for different layouts for different ALV's.
    one more point: in the selection screen... iam using
    SELECTION-SCREEN ULINE.  
    which is displaying a black line between the select options.
    Now can this color of the black line be changes to grey or white.
    Also can a Line can be drawn between two selection fields without wasting the space between the fields(as there are many fields in the selection). the above command is consuming one row. i dont want to waste that space.. so can anyone give code for the same...
    Thanks & regards..
    Chaitanya..

    Hello,
    U can populate the below fields of the two layouts  variant structures;
    U can find GROUP and HANDLE fields , Just give different names so that u can have different layouts based on u r variants as the above field values distinguish between the alyuts.
    Check this link
    Re: Change layout button in ALV Grids
    Regards
    Edited by: shishupalreddy ramreddy on Jun 26, 2009 3:55 AM

  • F4 Help value in Edit mode in Reuse ALV FM

    I did an extensive search in this forum, but i cudnt find the answer i am looking for.
    I am using Normal Dialog screen in which user validate the screen and hit the save button.
    I need to show this values in Pop-up ( I have called the FM reusee alv_grid_display).
    In the display one of field is editable and i am showing F4 help for the editable field.
    User clicks any value from F4help, i need to store the value selected in my custom table .
    User command does not register that event.
    How to register that event when user clicks the f4 help, i am getting F4 help already and able to select the value too.I
    need to store that selected value.
    Please dont recomment using OO already i have used the classed for display and again calling nornal diaglog screen and for validation i need to call pop-up in same screen ( Used alv FM screen ).
    Please let me know your answer ASAP.

    Thank you very much,
    during testing I have recognized, that the buttons in the toolbar are new functions, because of the edit mode.
    So I have put all the new button into the excluding list. It worked!
    Thanks again!
    Andreas

  • Reuse alv grid filter & sellect all handle

    Hi all,
    In REUSE_ALV_GRID_DISPLY FM after output
    i have a collum check boxes. Now i used select all option then it select all records & check boxes in internaltable.
    but i have when i filter some records then i apply select all in alv it not select perticular records when i filterd i
    it select all records in internal table.
    how to handle this one.
    my requirement is.
    when i filter records in alv FM then i am apply select all option, it select only those front displya records only selcted.
    not all records in internal table.
    Thank u,
    Vijay.G

    hello,
    write code at user command for select all button - pass 'X to all check box filed
    AND
    refresh the alv list / gird through...function moudle
    Thanks

Maybe you are looking for