ALV show subtotal

i have a ALV report, i would like to show subtotal in the report.
The following filed will appear in my report.
Customer, Material, Description, Price1, Price2, Price3, Average Price.
I want to group by customer, then sum the price1, price2, price and sumup average price / total of item.
How can i do that in ALV. Thanks.

Hi,
Steps
1) For the fields price1 & price2 have DO_SUM = 'X' in the field catalog internal table.
2) Prepare a sort internal table with the customer field..
DATA: T_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA: S_SORT LIKE LINE OF T_SORT.
S_SORT-SPOS = '1'.
S_SORT-FIELDNAME = 'KUNNR'.   "Customer field name.
S_SORT-UP = 'X'.
S_SORT-SUBTOT = 'X'.
APPEND S_SORT TO T_SORT.
3)
Pass the internal table T_SORT to the parameter IT_SORT when calling the Function module.
Thanks
Naren

Similar Messages

  • Alv show in report but when see in spool (after run background job) there i

    my program have some error when i run result alv show in report but when see in spool (after run background job) there is no data, (other program can see result in spool)
    Please help
    here is some example of my program
    ********************************declare internal table*****************************
    internal table output for BDC
    data : begin of t_output occurs 0,
    bukrs type anla-bukrs,
    anln1 type anla-anln1,
    anln2 type anla-anln2,
    zugdt type anla-zugdt,
    result(70) type c,
    end of t_output.
    *****get data from loop********************************
      loop at t_anla.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
             EXPORTING
                  INPUT  = t_anla-anln1
             IMPORTING
                  OUTPUT = t_anla-anln1.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
             EXPORTING
                  INPUT  = t_anla-anln2
             IMPORTING
                  OUTPUT = t_anla-anln2.
    check record is correct or not
        select single bukrs anln1 anln2 zugdt
        into w_output
        from anla
        where bukrs = t_anla-bukrs and
        anln1 = t_anla-anln1 and
        anln2 = t_anla-anln2
       zugdt = '00000000'
    if record is correct
        if sy-subrc = 0 and w_output-zugdt = '00000000'.
          w_output-bukrs = t_anla-bukrs.
          w_output-anln1 = t_anla-anln1.
          w_output-anln2 = t_anla-anln2.
          w_output-result = 'Yes : this asset can delete'.
          append w_output to t_output.
    if record is not correct
        elseif sy-subrc = 0 and w_output-zugdt <> '00000000'.
    there is error record  this asset have value already
          v_have_error = 'X'.
          w_output-bukrs = t_anla-bukrs.
          w_output-anln1 = t_anla-anln1.
          w_output-anln2 = t_anla-anln2.
          w_output-result = 'Error : this asset have value already'.
          append w_output to t_output.
        else.
    there is error record this asset donot exist in table anla
          v_have_error = 'X'.
          w_output-bukrs = t_anla-bukrs.
          w_output-anln1 = t_anla-anln1.
          w_output-anln2 = t_anla-anln2.
          w_output-result = 'Error : this asset doest not exist'.
          append w_output to t_output.
        endif.
    *end of check record is correct or not
        clear w_output.
      endloop.
    ******************************show data in ALV***************************************************
    show data from file in ALV
      perform display_report_ALV.
    *&      Form  display_report_ALV
    form display_report_ALV.
      DATA: LT_FIELD_CAT TYPE SLIS_T_FIELDCAT_ALV,
          LT_EVENTS TYPE SLIS_T_EVENT,
          LV_REPID LIKE SY-REPID.
      PERFORM ALV_DEFINE_FIELD_CAT USING LT_FIELD_CAT.
      PERFORM ALV_HEADER_BUILD USING T_LIST_TOP_OF_PAGE[].
      PERFORM ALV_EVENTTAB_BUILD USING LT_EVENTS[].
      LV_REPID = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM = LV_REPID
                IT_FIELDCAT        = LT_FIELD_CAT
                I_SAVE             = 'A'
                IT_EVENTS          = LT_EVENTS[]
           TABLES
                T_OUTTAB           = t_output
           EXCEPTIONS
                PROGRAM_ERROR      = 1
                OTHERS             = 2.
      IF SY-SUBRC NE 0.
        WRITE: / 'Return Code : ', SY-SUBRC,
          'from FUNCTION REUSE_ALV_GRID_DISPLAY'.
      ENDIF.
    endform.
    *&      Form  alv_define_field_cat
          text
         -->P_LT_FIELD_CAT  text
    FORM ALV_DEFINE_FIELD_CAT USING  TB_FCAT TYPE SLIS_T_FIELDCAT_ALV.
      DATA: WA_FIELDCAT LIKE LINE OF TB_FCAT,
        LV_COL_POS TYPE I.
      DEFINE FIELD_CAT.
        CLEAR WA_FIELDCAT.
        ADD 1 TO LV_COL_POS.
        WA_FIELDCAT-FIELDNAME = &1.
        WA_FIELDCAT-REF_TABNAME = &2.
        WA_FIELDCAT-COL_POS = LV_COL_POS.
        WA_FIELDCAT-KEY = &3.
        WA_FIELDCAT-NO_OUT = &4.
        WA_FIELDCAT-REF_FIELDNAME = &5.
        WA_FIELDCAT-DDICTXT = 'M'.
        IF NOT &6 IS INITIAL.
          WA_FIELDCAT-SELTEXT_L = &6.
          WA_FIELDCAT-SELTEXT_M = &6.
          WA_FIELDCAT-SELTEXT_S = &6.
        ENDIF.
        WA_FIELDCAT-DO_SUM = &7.
        WA_FIELDCAT-OUTPUTLEN = &8.
        APPEND WA_FIELDCAT TO TB_FCAT.
      END-OF-DEFINITION.
      FIELD_CAT  'BUKRS'  'ANLA'     'X' '' 'BUKRS' 'Company Code' '' ''.
      FIELD_CAT  'ANLN1'  'ANLA'     'X' '' 'ANLN1' 'Asset Number' '' ''.
      FIELD_CAT  'ANLN2'  'ANLA'     'X' '' 'ANLN2' 'Asset Sub Number' '' ''.
    FIELD_CAT  'ATEXT'   'T5EAE'     'X' '' 'ATEXT' 'Result' '' ''.
      FIELD_CAT  'RESULT'  ''     'X' '' 'RESULT' 'RESULT' '' ''.
    ENDFORM.                    " alv_define_field_cat

    Hi,
    Check this code..
    FORM display_report_alv.
      DATA: lt_field_cat TYPE slis_t_fieldcat_alv,
      lt_events TYPE slis_t_event,
      lv_repid LIKE sy-repid.
      PERFORM alv_define_field_cat USING lt_field_cat.
      PERFORM alv_header_build USING t_list_top_of_page[].
      PERFORM alv_eventtab_build USING lt_events[].
      lv_repid = sy-repid.
      IF sy-batch EQ 'X'.  ----> " System Field for Backgroud..if Background use list display
        CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
          EXPORTING
            i_callback_program = lv_repid
            it_fieldcat        = lt_field_cat
            i_save             = 'A'
            it_events          = lt_events[]
          TABLES
            t_outtab           = t_output
          EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.
      ELSE.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program = lv_repid
            it_fieldcat        = lt_field_cat
            i_save             = 'A'
            it_events          = lt_events[]
          TABLES
            t_outtab           = t_output
          EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.
      ENDIF.
      IF sy-subrc NE 0.
        WRITE: / 'Return Code : ', sy-subrc,
        'from FUNCTION REUSE_ALV_GRID_DISPLAY'.
      ENDIF.
    ENDFORM.                    "display_report_ALV

  • How to show subtotal and total of groups in ssrs

    I am making an SSRS report in following format:
        DIVISION  
              SECTOR  
                    DEPARTMENT
    Division contain Sector and Sector contain Department so resulting report becomes something like following. A figure is being shown against each Department and I want to show SUBTOTAL of each Sector right against Sector column (by adding all Department coming
    under it) and then show TOTAL of Division (by adding all Department or all Sector) at the end. How do I show these totals? 
        Division1
             Sector1               SUBTOTAL HERE (for e.g. 19,000)
                  Department1      10,000
                  Department2      9,000
             Sector2               SUBTOTAL HERE  (for e.g. 8,000)
                  Department3      8,000
             Sector3               SUBTOTAL HERE  (for e.g. 13,000)
                  Department4      10,000
                  Department5      1,000
                  Department6      2,000
                                   TOTAL HERE  (for e.g. 40,000)
        Division2
             Sector4               SUBTOTAL HERE (for e.g. 3,500)
                  Department7      3,500
                                   TOTAL HERE (for e.g. 3,500)
    My report is displaying all divisions, sectors and departments with figures like above (I am using groups ) but how do I display SUBTOTAL and TOTAL?

    Hi ,
    You can use add total in this case.
    use below link;
    http://msdn.microsoft.com/en-in/library/ms170712.aspx
    To add totals to a report
        Switch to Design view.
        Right-click the data region cell that contains the field [LineTotal], and click Add Total.
        This adds a row with a sum of the dollar amount for each order.
        Right-click the cell that contains the field [Qty], and click Add Total.
        This adds a sum of the quantity for each order to the totals row.
        In the empty cell to the left of Sum[Qty], type the label "Order Total".
    To add a daily total to a report
        Right-click the Order cell, point to Add Total, and click After.
        This adds a new row containing sums of the quantity and dollar amount for each day, and the label "Total" in the Order column.
        Type the word Daily before the word Total in the same cell, so it reads Daily Total.
        Select the Daily Total cell, the two Sum cells and the empty cell between them.
    To add a grand total to a report
        Right-click the Date cell, point to Add Total, and click After.
        This adds a new row containing sums of the quantity and dollar amount for the entire report, and the Total label in the Date column.
        Type the word Grand before the word Total in the same cell, so it reads Grand Total.
        Select the Grand Total cell, the two Sum cells and the empty cells between them.
    Thanks
    Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem.

  • ALV Grid  Subtotal text and Total text display

    Hello ABAPGuru's
    I want to display the subtotal and Total texts. alv grid program runing on background.
    Regards
    Sweety(Sri)

    Hello Neil,
    Here I have attached my routines.anyway my confusion. I have wrote the routine subtotal_text .but i am not passing ALV GRID FM.
    *&      Form  eventtab_build
    &----       This is used to get the list of events
    ----      <--RI_EVENTS  Internal table
    FORM eventtab_build  CHANGING ri_events TYPE slis_t_event.
    Structure for event handling.
      DATA: rs_event TYPE slis_alv_event.
    Returns table of possible events for a list type.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = ri_events.  " Table of events to perform
    Read the internal table with the TOP_OF_PAGE and move the
    form name to the internal table
      READ TABLE ri_events
        WITH KEY name = slis_ev_top_of_page INTO rs_event.
      IF sy-subrc = 0.
        MOVE c_formname TO rs_event-form.              " Form name
        MODIFY ri_events FROM rs_event
           INDEX sy-tabix.                  " Top of page event
      ENDIF.
      READ TABLE ri_events
         WITH KEY name = slis_ev_end_of_page INTO rs_event.
      IF sy-subrc = 0.
        MOVE c_form_eop_name TO rs_event-form.              " Form name
        MODIFY ri_events FROM rs_event
           INDEX sy-tabix.                  " Top of page event
      ENDIF.
      READ TABLE ri_events
          WITH KEY name = slis_ev_subtotal_text INTO rs_event.
      IF sy-subrc = 0.
        MOVE c_formname_subtotal_text TO rs_event-form.     " Formname
        MODIFY ri_events FROM rs_event
           INDEX sy-tabix.                  " Top of page event
      ENDIF.
    *&-- Delete all unneeded events:
    DELETE ri_events  WHERE form IS INITIAL.
    ENDFORM.                    " eventtab_build
    *&      Form  SUBTOTAL_TEXT
          text
    -->  p1        text
    <--  p2        text
    FORM SUBTOTAL_TEXT USING  ep_subtot_line     TYPE  type_data
                              e_event_data       TYPE  slis_subtot_text.
      IF NOT e_event_data-criteria IS INITIAL.
      E_EVENT_DATA-DISPLAY_TEXT_FOR_SUBTOTAL = 'Account Total'.
       ENDIF.
    ENDFORM.                    "SUBTOTAL_TEXT
    *&      Form  initialise_layout
          Initialise Layout
    FORM initialise_layout .
      i_layout-colwidth_optimize = c_x.
      i_layout-group_change_edit = c_x.
    *i_layout-subtotals_text = ' a'.
      i_layout-detail_popup   = c_x.
    i_layout-zebra          = c_x.
      i_layout-no_vline       = 'X'.
      i_layout-no_hline       = 'X'.
      i_layout-totals_text = 'Account Total'.
    ENDFORM.                    " initialise_layout
    Call the function module to display the report
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program     = v_program
          i_callback_top_of_page = 'TOP_OF_PAGE'       "Top Of Page
          is_layout              = i_layout
          it_fieldcat            = i_fieldtab
          it_sort                = i_sort
          it_events              = i_events         " Events
          is_print               = i_print
          i_default              = c_x
          i_save                 = c_save
          is_variant             = v_variant
        TABLES
          t_outtab               = i_data
        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.
    Regards
    Sweety (Sri)

  • ALV display subtotal only on one column

    Hi Everyone,
    I'm trying to display in alv format a report that has the % in the subtotals only. (I still need the individual lines, but not the percentage on them, just on the subtotal).
    Can anyone suggest how to do this, for example, by working out the percentage on each line, and hiding the contents except for the subtotals. Or calculating the percentage on the subtotal line. Below is an example of what I'm after.
    a     X     1
    b     X     2
    c     X     3
    X subtotal     6     21.43%
    d     Y     4
    e     Y     5
    f     Y     6
    g     Y     7
    Y subtotal     22     78.57%
    Grand total     28
    Thank you
    Tim

    Hi Vinod,
    Thank you for your reply.
    Thats the part I've already figured out. I'm after how to display only the subtotals for the percentage on the ALV.
    regards
    Tim

  • Query on ALV List Subtotal texts

    Hi,
    I am using the FM REUSE_ALV_LIST_DISPLAY and my internal table would have data categorized by for ex. two company codes 1000 and 2000.
    My requirement is for the subtotal text to display something like this during the subtotals-
    Total: 1000 <Company code text for 1000>
    instead of the existing
    <w_fieldcat-seltext_> 1000.
    I have tried changing the field seltext_l in the  fieldcat for the first field 'BUKRS', which is working. But i need the changed value of the company code (i.e. like "Total: 2000 <company code text for 2000>" at the next summation level, which i am unable to get as the fieldcat modifications do not reflect in between the ALV list.
    I have also tried changing layout-subtotals_text, but of no use.
    Any pointers/help would be useful.
    Thanks in advance,
    Daksh.

    You need activate the event for SUBTOTAL TEXT and handle the text in there. There is a sample program in BCALV which does the same, take a look at that.
    Regards,
    Ravi
    Note : Please mark all the helpful answers

  • Inconsistency in ALV grid subtotal

    I have an oops ALV grid where I am doing subtotal by a particular column called 'PRDHA'. But my subtotal seems very inconsistent. It is grouping non-similar PRDHA's as one PRDHA.
    My assumption was that perhaps I need to sort the internal table (which in my case is a field symbol - <gt_tabletotal>) by that column 'PRDHA'. Is this right ? Please correct me if this assumption is right.
    Also this internal table is a dynamic internal table number of columns depend on certain conditions.
    How do I sort <gt_tabletotal> by PRDHA ?
    wa_sort2-fieldname = 'PRDHA'.
        wa_sort2-up = 'X'.
        wa_sort2-subtot = 'X'.
        append wa_sort2 to gt_sort.
      call method o_grid->set_table_for_first_display
        exporting
          is_variant      = gx_variant
          i_save          = 'A'
          is_layout       = gs_layout
        changing
          it_fieldcatalog = it_fldcat
          it_sort         = gt_sort[]
          it_outtab       = <gt_tabletotal>.
    (I am trying to subtotal by PRDHA. The row with '*' indicates the subtotal line and you see inconsistency )
    Report as is :
    Plant     Cont.  PRDHA   Material                     Desc.
    2001     021     18/10R     33200-1866043     AHDC 24/4.3oz AW BS&P     CS     0.000
         *         11/16T                                                                                     0.000
    2001     021     18/10R     33200-1866450     AHDC 24/4.3oz AW Brillnt Sprkl Gel     CS     0.000
    2001     021     18/10R     33200-2784000     AHDC 121g/24ct Enamel Care Korea     CS     0.000
    2001     021     18/10S     33200-1805330     AHDC 24/6.0oz Complete X-White     CS     8,100.000
         *       18/10R                                                                                    0.000
    2001     021     18/10S     33200-1877030     AHDC 24/6.0oz TC Peroxicare     CS     0.000
    2001     021     18/10S     33200-1886030     AHDC 24/6.0oz Peroxicare     CS     5,400.000
    2001     021     18/10S     33200-2781501     AHDC 178gr/24ct Complete Care Korea     CS     0.000
    2001     021     18/1M5     33130-1008010     AHDC 12/75ml Email Diamant Replenium     CS     0.000
         *         18/10S                                                                                           13,500.000

    Found it on my own.
    data : field(5) value 'PRDHA' .
    assign field to <prdha>.  
    sort <gt_tabletotal> ascending by (<prdha>).
    (If I dont sort the table by PRDHA, subtotal is inconsistent ).

  • ALV - Sort - Subtotal

    hi,
    Can u pls tell me what is the use of subtotal in sort exactly with an example of records..
    I need to work out with this..in ALV.
    will be rewarded.
    Thankx in adv

    REPORT ZALV.
    TYPE-POOLS: SLIS.
    DATA: G_REPID LIKE SY-REPID,
    GS_PRINT            TYPE SLIS_PRINT_ALV,
    GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
    GT_EVENTS           TYPE SLIS_T_EVENT,
    GT_SORT             TYPE SLIS_T_SORTINFO_ALV,
    GS_LAYOUT           TYPE SLIS_LAYOUT_ALV,
    GT_FIELDCAT         TYPE SLIS_T_FIELDCAT_ALV,
    FIELDCAT_LN LIKE LINE OF GT_FIELDCAT,
    COL_POS TYPE I.
    DATA: BEGIN OF ITAB,
      FIELD1(5) TYPE C,
      FIELD2(5) TYPE C,
      FIELD3(5) TYPE P DECIMALS 2,
    END OF ITAB.
    DATA: BEGIN OF ITAB1 OCCURS 0.
      INCLUDE STRUCTURE ITAB.
    DATA: END OF ITAB1.
    DATA: BEGIN OF ITAB_FIELDCAT OCCURS 0.
      INCLUDE STRUCTURE ITAB.
    DATA: END OF ITAB_FIELDCAT.
    Print Parameters
    PARAMETERS:
                P_PRINT  AS CHECKBOX DEFAULT ' ', "PRINT IMMEDIATE
                P_NOSINF AS CHECKBOX DEFAULT 'X', "NO SELECTION INFO
                P_NOCOVE AS CHECKBOX DEFAULT ' ', "NO COVER PAGE
                P_NONEWP AS CHECKBOX DEFAULT ' ', "NO NEW PAGE
                P_NOLINF AS CHECKBOX DEFAULT 'X', "NO PRINT LIST INFO
                P_RESERV TYPE I.                  "NO OF FOOTER LINE
    INITIALIZATION.
    G_REPID = SY-REPID.
    PERFORM PRINT_BUILD    USING GS_PRINT.      "Print PARAMETERS
    START-OF-SELECTION.
    TEST DATA
    MOVE 'TEST1' TO ITAB1-FIELD1.
    MOVE 'TEST1' TO ITAB1-FIELD2.
    MOVE '10.00' TO ITAB1-FIELD3.
    APPEND ITAB1.
    MOVE 'TEST2' TO ITAB1-FIELD1.
    MOVE 'TEST2' TO ITAB1-FIELD2.
    MOVE '20.00' TO ITAB1-FIELD3.
    APPEND ITAB1.
    DO 50 TIMES.
      APPEND ITAB1.
    ENDDO.
    END-OF-SELECTION.
    PERFORM BUILD.
    PERFORM EVENTTAB_BUILD CHANGING GT_EVENTS.
    PERFORM COMMENT_BUILD  CHANGING GT_LIST_TOP_OF_PAGE.
    PERFORM CALL_ALV.
    FORM BUILD.
    DATA FIELD CATALOG
    Explain Field Description to ALV
    DATA: FIELDCAT_IN TYPE SLIS_FIELDCAT_ALV.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME = 'FIELD1'.
    FIELDCAT_LN-TABNAME   = 'ITAB1'.
    *FIELDCAT_LN-NO_OUT    = 'X'.  "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
    FIELDCAT_LN-KEY       = ' '.   "SUBTOTAL KEY
    FIELDCAT_LN-NO_OUT    = ' '.
    FIELDCAT_LN-SELTEXT_L = 'HEAD1'.
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME = 'FIELD2'.
    FIELDCAT_LN-TABNAME   = 'ITAB1'.
    FIELDCAT_LN-NO_OUT    = 'X'.
    FIELDCAT_LN-SELTEXT_L = 'HEAD2'.
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME     = 'FIELD3'.
    FIELDCAT_LN-TABNAME       = 'ITAB1'.
    FIELDCAT_LN-REF_FIELDNAME = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
    FIELDCAT_LN-REF_TABNAME   = 'MSEG'.  "<- REF TABLE IN THE DICTIONNARY
    FIELDCAT_LN-NO_OUT        = ' '.
    FIELDCAT_LN-DO_SUM        = 'X'.   "SUM UPON DISPLAY
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    DATA SORTING AND SUBTOTAL
    DATA: GS_SORT TYPE SLIS_SORTINFO_ALV.
    CLEAR GS_SORT.
    GS_SORT-FIELDNAME = 'FIELD1'.
    GS_SORT-SPOS      = 1.
    GS_SORT-UP        = 'X'.
    GS_SORT-SUBTOT    = 'X'.
    APPEND GS_SORT TO GT_SORT.
    CLEAR GS_SORT.
    GS_SORT-FIELDNAME = 'FIELD2'.
    GS_SORT-SPOS      = 2.
    GS_SORT-UP        = 'X'.
    *GS_SORT-SUBTOT    = 'X'.
    APPEND GS_SORT TO GT_SORT.
    ENDFORM.
    FORM CALL_ALV.
    ABAP List Viewer
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = G_REPID
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
    I_STRUCTURE_NAME = 'ITAB1'
    IS_LAYOUT =  GS_LAYOUT
    IT_FIELDCAT = GT_FIELDCAT[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
      IT_SORT = GT_SORT[]
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
      IT_EVENTS = GT_EVENTS[]
    IT_EVENT_EXIT =
      IS_PRINT = GS_PRINT
    IS_REPREP_ID =
    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 =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    T_OUTTAB = ITAB1
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2.
    ENDFORM.
    HEADER FORM
    FORM EVENTTAB_BUILD CHANGING LT_EVENTS TYPE SLIS_T_EVENT.
    CONSTANTS:
    GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
    *GC_FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
      DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = LT_EVENTS.
      READ TABLE 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 LT_EVENTS.
      ENDIF.
    define END_OF_PAGE event
    READ TABLE LT_EVENTS WITH KEY NAME =  SLIS_EV_END_OF_PAGE
                             INTO LS_EVENT.
    IF SY-SUBRC = 0.
      MOVE GC_FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
      APPEND LS_EVENT TO LT_EVENTS.
    ENDIF.
    ENDFORM.
    FORM COMMENT_BUILD CHANGING GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
      DATA: GS_LINE TYPE SLIS_LISTHEADER.
      CLEAR GS_LINE.
      GS_LINE-TYP  = 'H'.
      GS_LINE-INFO = 'HEADER 1'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
      CLEAR GS_LINE.
      GS_LINE-TYP  = 'S'.
      GS_LINE-KEY  = 'STATUS 1'.
      GS_LINE-INFO = 'INFO 1'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
      GS_LINE-KEY  = 'STATUS 2'.
      GS_LINE-INFO = 'INFO 2'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
    CLEAR GS_LINE.
    GS_LINE-TYP  = 'A'.
    GS_LINE-INFO = 'ACTION'.
    APPEND GS_LINE TO  GT_TOP_OF_PAGE.
    ENDFORM.
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
      WRITE: SY-DATUM, 'Page No', SY-PAGNO LEFT-JUSTIFIED.
    ENDFORM.
    FORM END_OF_PAGE.
      WRITE at (sy-linsz) sy-pagno CENTERED.
    ENDFORM.
    PRINT SETTINGS
    FORM PRINT_BUILD USING LS_PRINT TYPE SLIS_PRINT_ALV.
      LS_PRINT-PRINT              = P_PRINT.  "PRINT IMMEDIATE
      LS_PRINT-NO_PRINT_SELINFOS  = P_NOSINF. "NO SELECTION INFO
      LS_PRINT-NO_COVERPAGE       = P_NOCOVE. "NO COVER PAGE
      LS_PRINT-NO_NEW_PAGE        = P_NONEWP.
      LS_PRINT-NO_PRINT_LISTINFOS = P_NOLINF. "NO PRINT LIST INFO
      LS_PRINT-RESERVE_LINES      = P_RESERV.
    ENDFORM.
    *END OF ZALV PROGRAM
    Check this program...
    Regards,
    Pavan

  • Alv hierarchy subtotal in 2 fields

    Hi gurus,
    First, thanks to all those who helped me with my first problem. I have a new question, still regarding subtotal.
    The client now wants to have a subtotal in alv hierarchy per vendor and purchase doc. My output displays a subtotal per purchase doc only. Client wants to have an output that would look like this:
    VENDOR     
    PURCH DOC        PO AMT.
    1
    410000001            1000
    410000001             2000
    410000001            3000   (subtotal  per purch doc)
    410000002            100
    410000002            100     (subtotal per purch doc)
    1                          3100   (subtotal per vendor)
    2
    420000001            500
    420000001            300
    420000001            800       (subtotal per purch doc)
    2                          800       (subtotal per vendor)
    TOTAL                  3900
    Here's an excerpt of my code:
    FORM build_fcat using p_type changing p_fcat.
    data lt_fcat type slis_t_fieldcat_alv.
    field-symbols <fs_fcat> like line of lt_fcat.
    lt_fcat = p_fcat.
    loop at lt_fcat assigning <fs_fcat>.
    <fs_fcat>-ddictxt = 'L'.
    case <fs_fcat>-fieldname.
    when 'LIFNR'.
    <fs_fcat>-seltext_l = 'VENDOR'.
    <fs_fcat>-tabname = 'I_HEADER'.
    <fs_fcat>-key = 'X'.
    <fs_fcat>-outputlen = 15.
    modify lt_fcat from <fs_fcat>.
    when 'EBELN'.
    <fs_fcat>-seltext_l = 'PURCH DOC'.
    <fs_fcat>-tabname = 'I_ITEM'.
    <fs_fcat>-key = 'X'.
    <fs_fcat>-outputlen = 12.
    modify lt_fcat from <fs_fcat>.
    when 'RLWRT'.
    <fs_fcat>-seltext_l = 'PO AMT.'.
    <fs_fcat>-tabname = 'I_ITEM'.
    <fs_fcat>-datatype = 'CURR'.
    <fs_fcat>-ref_fieldname = 'WAERS'.
    <fs_fcat>-ref_tabname = 'I_ITEM'.
    <fs_fcat>-do_sum = 'X'.
    <fs_fcat>-outputlen = 15.
    modify lt_fcat from <fs_fcat>.
    endcase.
    endloop.
    p_fcat = lt_fcat.
    ENDFORM.
    FORM build_fsort changing p_fsort.
    data lt_sort type slis_t_sortinfo_alv.
    data ls_sort like line of lt_sort.
    ls_sort-spos = 1.
    ls_sort-fieldname = 'EBELN'.
    ls_sort-tabname = 'I_HEADER'.
    ls_sort-up = 'X'.
    ls_sort-subtot = 'X'.
    append ls_sort to lt_sort.
    clear ls_sort.
    ls_sort-spos = 2.
    ls_sort-fieldname = 'LIFNR'.
    ls_sort-tabname = 'I_HEADER'.
    ls_sort-up = 'X'.
    ls_sort-subtot = 'X'.
    append ls_sort to lt_sort.
    clear ls_sort.
    p_fsort = lt_fsort.
    ENDFORM.
    FORM modify_key changing p_keyinfo type slis_keyinfo_alv.
    clear p_keyinfo.
    p_keyinfo-header01 = 'LIFNR'.
    p_keyinfo-item01 = 'LIFNR'.
    p_keyinfo-header02 = 'EBELN'.
    p_keyinfo-item02 = 'EBELN'.
    ENDFORM.
    Is there a way to meet the client's expected output?
    Thanks in advance for all the help and advises.
    Points will be rewarded.

    Sorry I didn't include that earlier. I'm using Citrix so copy-paste of codes outside Citrix is not allowed. I'll just type a shorter version of my it here.
    data: begin of i_item occurs 0,
               lifnr like ekko-lifnr,
               name1 like-lfa1-name1,
               ebeln like ekpo_ebeln,
               po_dat like ekko-bedat,
               rlwrt like ekko-rlwrt,
               waers like ekko-waers,
               dmbtr like ekko-dmbtr,
             end of i_item.
    data wa_item like line of i_item,
    data: begin of i_header occurs 0,
               lifnr like lfa1-lifnr,
               name1 like lfa1-name1,
               ebeln like ekpo-ebeln,
            end of i_header.
    data wa_header like line of i_header.

  • ALV - show blank cell if numeric value is zero

    Hi
    I have an ALV with serveral numeric and decimal fields.
    Is it possible without a lot of effort (like assigning a separate cell with the visibilty attribute for each cell) to hide the cell content if the value is zero instead of showing 0 or 0,00 and so on .
    Thanks
    Thomas

    >
    Thomas Jetzinger wrote:
    > Hi
    >
    > I have an ALV with serveral numeric and decimal fields.
    >
    > Is it possible without a lot of effort (like assigning a separate cell with the visibilty attribute for each cell) to hide the cell content if the value is zero instead of showing 0 or 0,00 and so on .
    >
    > Thanks
    > Thomas
    I have a feeling that a cell variant or dynamic manipulation of visibility is going to be the correct answer.  The data type rules will always fire for the conversion exit on output.  You could maybe create a custom domain with its onw conversion exit but I would think that would actually lead to more work than just using hte cell variant/visibility property.

  • ALV Grid - Subtotal

    Hi  All,
    I am using ALV GRID's Sort catalog.
    I want to display the subtotals which are greater than 10,000.
    Is there any way in doing this.
    Please guide me.
    Thanks.
    Albert

    Hi albert,
    Check this,
    Step 1
    Define an internal table of type SLIS_T_EVENT, and a work area of type SLIS_ALV_EVENT.
    DATA:     T_EVENT TYPE SLIS_T_EVENT,
         W_EVENT TYPE SLIS_ALV_EVENT.
    Step 2
    Append AFTER-LINE-OUTPUT event to the internal table T_EVENT.
    CLEAR W_EVENT.
    W_EVENT-FORM = SLIS_EV_AFTER_LINE_OUTPUT.
    W_EVENT-NAME = SLIS_EV_AFTER_LINE_OUTPUT.
    APPEND W_EVENT TO T_EVENT.
    Step 3
    The totals are displayed in the output in the form AFTER_LINE_OUTPUT, which corresponds to the event AFTER_LINE_OUTPUT. The sub routine uses the parameter P_RS_LINEINFO, which contains settings for totals’ lines. The actual totals output is displayed using the WRITE ad FORMAT statements.
    FORM AFTER_LINE_OUTPUT
      USING P_RS_LINEINFO TYPE SLIS_LINEINFO.
    Declaration Of Local Variables
      DATA: L_SUCCESS TYPE WRBTR,     "Total For Successful Entries
            L_ERROR   TYPE WRBTR,     "Total For Unsuccessful Entries
            L_COUNT   TYPE I.         "No. Of lines in table T_OUTPUT
    Getting The No Of Lines In The Table T_OUTPUT
      DESCRIBE TABLE T_OUTPUT LINES L_COUNT.
    Displaying the totals after the last record of the Internal
    Table T_OUTPUT
      IF P_RS_LINEINFO-TABINDEX = L_COUNT.
      Loop At The Internal Table T_OUTPUT
        LOOP AT T_OUTPUT INTO W_OUTPUT.
          IF W_OUTPUT-SFLAG = C_CHECKED.
          Calculate Total For Unsuccessful Entries
            L_ERROR = L_ERROR + W_OUTPUT-WRBTR.
          ELSE.
          Calculate Total For Successful Entries
            L_SUCCESS = L_SUCCESS + W_OUTPUT-WRBTR.
          ENDIF.
        Clear The Work Area W_OUTPUT
          CLEAR W_OUTPUT.
        ENDLOOP.
      Set The Format For The Total Line Display
        ULINE AT (P_RS_LINEINFO-LINSZ).        "Dynamic Line Size
        FORMAT INTENSIFIED COLOR COL_TOTAL ON. "Setting the color
                                               "For the total row
                                               "As Yellow
        WRITE : /    SY-VLINE,                 "Vertical Line
                     TEXT-017,                 "Caption For Total
    "Sum of Successful           
    "Entries          
                  33 L_SUCCESS,                "Total Of Successful
                                               "Entries
                     C_USD.                    "Currency Type USD
        POSITION     P_RS_LINEINFO-LINSZ.      "Dynamic Line Size
        WRITE :      SY-VLINE.                 "Vertical Line
        ULINE AT     (P_RS_LINEINFO-LINSZ).    "Dynamic Line Size
        WRITE : /    SY-VLINE ,                "Vertical Line
                     TEXT-018,                 "Caption For Total
    "Sum of Successful           
    "Entries
                  33 L_ERROR,                  "Total Of Unsuccessful
                                               "Entries
                     C_USD.                    "Currency Type USD
        POSITION     P_RS_LINEINFO-LINSZ.      "Dynamic Line Size
        WRITE :      SY-VLINE.                 "Vertical Line
        FORMAT COLOR OFF.                      "Color Setting Off
      ENDIF.
    ENDFORM.                                   "AFTER_LINE_OUTPUT
    Step 4
    The table T_EVENT is passed to the function 'REUSE_ALV_LIST_DISPLAY' while displaying the ALV Report.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
          I_CALLBACK_PROGRAM = L_REPID    "Program Name
          IS_LAYOUT          = W_LAYOUT   "Layout of the Report
          IT_FIELDCAT        = T_FIELDCAT "Field Catalog for Report
          IT_EVENTS          = T_EVENT    "For setting the events
       TABLES
          T_OUTTAB           = T_OUTPUT   "Report data Internal Table
       EXCEPTIONS
          PROGRAM_ERROR      = 1
          OTHERS             = 2.

  • ALV Grid - Subtotal & total to be shown at the top of the table

    Hi,
    I am using function module 'REUSE_ALV_GRID_DISPLAY' to display a table, and I count subtotals and total for some fields. The total is always shown at the bottom of the table, and subtotals are always shown after the rows that subtotals are calculated for. Is there a way to make it so that the total is always shown at the top of the table, and subtotals are shown before the rows that subtotals are calculated for?
    Thank you,
    Jake Alexander

    GW_LAYOUT-TOTALS_BEFORE_ITEMS = 'X'.
    Regards
    Sreekanth

  • Hide total, but show subtotal in classic report with breaks

    Hi,
    Is it possible to use the sum function for a report with a break, but not display the total sum? I have a financial report with a break on currency. But I don't want to display the total sum, because it is meaningless.
    I don't have a clue how to fix this.
    Jacob

    Hi Jacob,
    I'm not sure of your overall target but perhaps this will help: http://apex.oracle.com/pls/otn/f?p=31517:86:3502666127312777
    Mike

  • Regarding user interface in subtotal line of ALV grid, ensure points

    Hi,
    I have 3 fields,
    A= vendor , B = freight , C = Cost PMT
    When the vendor get changed, My Grid is showing subtotal of B i.e freight.
    Now my requirement is, in the same subtotal line, I want average of C (Cost PMT) field.
    So how we can interact with the subtotal line of the ALV grid.
    Pleas reply!!!!   & have ur points.
    cheers

    Read the documentation of FM ICON_CREATE, the purpose of the Function module is entirely different from what you are using it for.
    To print Icons in ALV (Using FMs ) all you need to do is to send the Icon name in the field.
    Also parameters TEXT and INFO of FM ICON_CREATE seem to be flags, that are appended to the icon name so that when you set it on the screen the appropriate info or Text is shown.

  • How to subtotal and sort in ABAL webdynrp ALV?

    Hi Experts,
       In my ALV table I have CARRID and PRICE.
       I want to sort the data by CARRID and then group the data based on CARRID and get price subtotal of it.
       I also want a grand total of the price.
       How to programatically subtotal and sort in ABAL webdynrp ALV?
       Please provide sample code snippet if possible.
    Thanks
    Gopal
    Edited by: gopalkrishna baliga on Oct 26, 2010 1:30 PM

    Hi Gopal,
    Didn't you get solution with your earlier post?
    How to show Subtotal in webdynpro ALV(ABAP)? Kindly help!
    Regards,
    Vikram

Maybe you are looking for