ALV: conditional total / subtotal calculation

Dear colleagues,
I am using the REUSE_ALV_GRID_DISPLAY_LVC function. My ALV has character columns only. There are 5 key columns and up to 120 day columns (one per day). The day columns containing "real character" values or blank. Does anybody know if it is possible to implement the following requirement? And if yes, how?
The toolbar should contain the total and subtotal button. When (i.e.) the subtotal button is pressed, for every day column the number of cells containing "real characters" (not blank only) should be displayed grouped by the marked key col. ?
Thank you for your help,
Peter

Hi,
You need to have an field which is an integer type i.e. type i in the structure and make the subtotal as 'X' in the Field layout.
Thanks & Regards
Sarves Sombhatla

Similar Messages

  • How to find out the total, subtotal in alv report

    hi dears,
    how to find out the total, subtotal in alv report?
    pls tell me logic ,
    i will be waiting for eply
    regards
    eswar

    Hi,
    <b>ALV Grid List with sub-totals</b>
    REPORT z_demo_alv_sort.
    * This program lists orders (VBAK) with sort and sub-total for        *
    * 'sold-to-party' (KUNNR) and 'Sales organization' (VKORG)            *
    TABLES : vbak.
    TYPE-POOLS: slis.                      " ALV Global types
    SELECT-OPTIONS :
      s_vkorg FOR vbak-vkorg,              " Sales organization
      s_kunnr FOR vbak-kunnr,              " Sold-to party
      s_vbeln FOR vbak-vbeln.              " Sales document
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
    PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    DATA:
      BEGIN OF gt_vbak OCCURS 0,
        vkorg LIKE vbak-vkorg,             " Sales organization
        kunnr LIKE vbak-kunnr,             " Sold-to party
        vbeln LIKE vbak-vbeln,             " Sales document
        netwr LIKE vbak-netwr,             " Net Value of the Sales Order
        waerk LIKE vbak-waerk,             " Document currency
      END OF gt_vbak.
    INITIALIZATION.
      v_1 = 'Maximum of records to read'.
    START-OF-SELECTION.
      PERFORM f_read_data.
      PERFORM f_display_data.
    *      Form  f_read_data
    FORM f_read_data.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
               FROM vbak
                 UP TO p_max ROWS
              WHERE kunnr IN s_kunnr
                AND vbeln IN s_vbeln
                AND vkorg IN s_vkorg.
    ENDFORM.                               " F_READ_DATA
    *      Form  f_display_data
    FORM f_display_data.
      DEFINE m_fieldcat.
        add 1 to ls_fieldcat-col_pos.
        ls_fieldcat-fieldname   = &1.
        ls_fieldcat-ref_tabname = 'VBAK'.
        ls_fieldcat-do_sum      = &2.
        ls_fieldcat-cfieldname  = &3.
        append ls_fieldcat to lt_fieldcat.
      END-OF-DEFINITION.
      DEFINE m_sort.
        add 1 to ls_sort-spos.
        ls_sort-fieldname = &1.
        ls_sort-up        = 'X'.
        ls_sort-subtot    = &2.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
      DATA:
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv,
        lt_sort     TYPE slis_t_sortinfo_alv,
        ls_sort     TYPE slis_sortinfo_alv,
        ls_layout   TYPE slis_layout_alv.
      m_fieldcat 'VKORG' ''  ''.
      m_fieldcat 'KUNNR' ''  ''.
      m_fieldcat 'VBELN' ''  ''.
      m_fieldcat 'NETWR' 'X' 'WAERK'.
      m_fieldcat 'WAERK' ''  ''.
      m_sort 'VKORG' 'X'.                  " Sort by vkorg and subtotal
      m_sort 'KUNNR' 'X'.                  " Sort by kunnr and subtotal
      m_sort 'VBELN' ''.                   " Sort by vbeln
      ls_layout-cell_merge = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                is_layout   = ls_layout
                it_fieldcat = lt_fieldcat
                it_sort     = lt_sort
           TABLES
                t_outtab    = gt_vbak.
    ENDFORM.                               " F_DISPLAY_DATA
    ***************** END OF PROGRAM Z_DEMO_ALV_SORT **********************
    Regards
    Sudheer

  • Total/Subtotal Icon in ALV GRID

    Hi;
    i have an ALV GRID that is already sorted and data is shown ordered in the grid:
    Sort Documento
      wa_sort-spos = '1' .
      wa_sort-fieldname = 'MBLNR'.
      wa_sort-tabname = 'ITAB'.
      wa_sort-up = 'X'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO i_sort .
      CLEAR wa_sort.
    But, i need to subtotal by a column and i do this:
      gt_fieldcat-seltext_l = 'Cant_entregada'.
      gt_fieldcat-fieldname = 'MENGE'.
      gt_fieldcat-ref_tabname = 'itab'.
      gt_fieldcat-outputlen = 14.
      gt_fieldcat-do_sum = 'X'.
      APPEND gt_fieldcat. CLEAR gt_fieldcat.
    Menge is data type Integer because the Key User doesn´t want decimal places.
    And ,
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
         i_callback_program                = g_repid
         is_layout                         = gs_layout
         it_fieldcat                       = gt_fieldcat[]
          it_sort                          = i_sort
          i_default                        = 'X'
          i_save                           = 'A'
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = itab
    EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2
    So data in the grid is ordered by Document number, but the total/subtotal button is not displayed.
    i've been lookin other posts about the same, but i don´t see any difference with my code.
    Any help.
    David Fúnez
    Tegucigalpa, Honduras

    i found the answer..jus added this line :   gt_fieldcat-datatype = 'INT4'.
    gt_fieldcat-seltext_l = 'Cant_entregada'.
      gt_fieldcat-fieldname = 'MENGE'.
      gt_fieldcat-ref_tabname = 'itab'.
      gt_fieldcat-outputlen = 14.
      gt_fieldcat-do_sum = 'X'.
      gt_fieldcat-datatype = 'INT4'.
      APPEND gt_fieldcat. CLEAR gt_fieldcat.
    Now buttons are displayed...

  • To activate total & subtotal button in ALV by class

    Hi,
    Kindly suggest how to activate total & subtotal button in ALV by class. I have used layout configuration by lvc_s_layo.
    gs_layout type lvc_s_layo.
    Ashutosh Kumar

    Dears,
    Do_SUM is not available in gs_layout type lvc_s_layo.
    Its working only in function module REUSE_ALV_LIST_DISPLAY.
    How to use in class ALV.
    FORM SUB_CREATE_FIELDCATALOG .
    THIS BELOW FIELD IS EDITABLE
    PERFORM APPEND_FIELDCAT USING:'MATNR'
                                  'Material No.'
                                  'CHAR'
                                  '30'
    PERFORM APPEND_FIELDCAT USING:'MATKL'
                                  'DOCUMENT TYPE'
                                  'CHAR'
                                  '10'
    PERFORM APPEND_FIELDCAT USING:''
                                  'CHAR'
                                  '4'
                                  'C610'
          PERFORM APPEND_FIELDCAT USING:'NTGEW'
                                  'NET WT'
                                  'P'
                                  '10'
                                  'C610'
                                  'X'.
        PERFORM APPEND_FIELDCAT USING:'VOLTO'
                                  'VOLUME'
                                  'P'
                                  '10'
                                  'C610'
                                  'X'.
         PERFORM APPEND_FIELDCAT USING:'VPREH'
                                  'COST'
                                  'P'
                                  '10'
                                  'C610'
    ENDFORM.                    " SUB_CREATE_FIELDCATALOG
    *&      FORM  APPEND_FIELDCAT
          TEXT
         -->P_0116   TEXT
         -->P_0117   TEXT
         -->P_0118   TEXT
         -->P_0119   TEXT
         -->P_0120   TEXT
         -->P_10     TEXT
    FORM APPEND_FIELDCAT  USING    P_114
                                   P_115
                                   P_116
                                   P_117
                                   P_118
                                   P_119.
      CLEAR GT_FIELDCAT_LVC.
      GT_FIELDCAT_LVC-FIELDNAME = P_114.
      GT_FIELDCAT_LVC-COLTEXT = P_115.
      GT_FIELDCAT_LVC-DATATYPE = P_116.
      GT_FIELDCAT_LVC-OUTPUTLEN    = P_117.
      GT_FIELDCAT_LVC-EMPHASIZE = P_118.
      GT_FIELDCAT_LVC-do_sum = P_119.
       append gt_fieldcat_lvc.

  • Total/subtotal Alv object oriented

    Hi,
    How can I active icon of total/subtotal in alv grid object?
    it is disabled.
    Thanks!

    Hi,
    You need to have an field which is an integer type i.e. type i in the structure and make the subtotal as 'X' in the Field layout.
    Thanks & Regards
    Sarves Sombhatla

  • Passing the Total/Subtotal Text in ALV

    Hi All,
    I would like to know is there any chance with ALV to pass Total/Subtotal Text.
    PS:I'm not looking for the text ls_layout-totals_text = 'Grand Total'.
    ls_layout-subtotals_text = 'SubTotal'.
    What i'm looking for is In My below Output:
    112365               TDS Windsor Sequencing                           
    112365               TDS Windsor Sequencing                           
    112365               TDS Windsor Sequencing                           
    * Total  <Group text>  "Here My   total amount is showing                                                         
    112313               Operations and Engineering                       
    * Total   <Group text>      "Here My   total amount is showing                                                         
    112363               DCX Windsor                                      
    * Total      <Group text>            "Here My   total amount is showing                                                                               
    ** Subtotal <Group text>   "Here My  "SUB total" amount is showing of above three totals
    I've <Group text> in My Final ALV one of field, but need to show at the place of <Group text> in above output.
    PS:And For Totals/Subtotals i'm using standard function of ALV by passing IT_SORT(which is in Reuse_Alv..FM)
    Any Hints?
    Thank You,
    Cheers,
    Amit.

    Hi Amit,
      Please check this example..I used the event BEFORE_LINE_OUTPUT to populate the subtotal texts
    dynamically..Used the Field-symbols technique to populate the subtotals text...Hope this is what you
    are looking for.
    TYPE-POOLS: slis,kkblo.
    DATA: BEGIN OF wa,
            vbeln TYPE vbeln,
            posnr TYPE posnr,
            matnr TYPE matnr,
            netpr TYPE netpr,
            waerk TYPE waerk,
            text  TYPE char20,
          END OF wa.
    DATA: BEGIN OF wa_vbak,
            vbeln TYPE vbeln,
          END OF wa_vbak.
    DATA: i_event   TYPE slis_t_event,
          t_sort    TYPE slis_t_sortinfo_alv,
          s_sort    TYPE LINE OF slis_t_sortinfo_alv,
          l_s_event TYPE LINE OF slis_t_event.
    DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
    DATA: s_layout       TYPE slis_layout_alv.
    DATA: v_repid        TYPE syrepid.
    DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
    DATA: itab1          LIKE TABLE OF wa.
    DATA: itab           LIKE TABLE OF wa_vbak.
    START-OF-SELECTION.
    * Field catalog populate.
      s_fieldcatalog-col_pos = '1'.
      s_fieldcatalog-fieldname = 'VBELN'.
      s_fieldcatalog-rollname = 'VBELN'.
      s_fieldcatalog-outputlen = '12'.
      APPEND s_fieldcatalog TO t_fieldcatalog.
      CLEAR: s_fieldcatalog.
      s_fieldcatalog-col_pos = '2'.
      s_fieldcatalog-fieldname = 'POSNR'.
      s_fieldcatalog-rollname = 'POSNR'.
      APPEND s_fieldcatalog TO t_fieldcatalog.
      CLEAR: s_fieldcatalog.
      s_fieldcatalog-col_pos = '3'.
      s_fieldcatalog-fieldname = 'MATNR'.
      s_fieldcatalog-rollname = 'MATNR'.
      APPEND s_fieldcatalog TO t_fieldcatalog.
      CLEAR: s_fieldcatalog.
      s_fieldcatalog-col_pos = '4'.
      s_fieldcatalog-fieldname = 'NETPR'.
      s_fieldcatalog-ref_tabname = 'VBAP'.
      s_fieldcatalog-ref_fieldname = 'NETPR'.
      s_fieldcatalog-do_sum = 'X'.
      APPEND s_fieldcatalog TO t_fieldcatalog.
      CLEAR: s_fieldcatalog.
    * Get vbak
      SELECT vbeln UP TO 100 ROWS
      FROM
      vbak
      INTO TABLE itab.
      IF NOT itab[] IS INITIAL.
    * Get vbap
        SELECT vbeln posnr matnr netpr waerk arktx
        FROM vbap
        INTO TABLE itab1
        FOR ALL ENTRIES IN itab
        WHERE vbeln = itab-vbeln.
      ENDIF.
      v_repid = sy-repid.
    * Build sort internal table.
      s_sort-spos      = '1'.
      s_sort-fieldname = 'VBELN'.
      s_sort-tabname  = 'ITAB1'.
      s_sort-up = 'X'.
      s_sort-subtot = 'X'.
      s_sort-group = 'UL'.
      APPEND s_sort TO t_sort.
    * Get alv events.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 2
        IMPORTING
          et_events       = i_event
        EXCEPTIONS
          list_type_wrong = 0
          OTHERS          = 0.
    * Before line output.
      READ TABLE i_event  INTO l_s_event
                        WITH KEY name = 'BEFORE_LINE_OUTPUT'.
      IF sy-subrc = 0.
        MOVE 'BEFORE_LINE_OUTPUT' TO l_s_event-form.
        MODIFY i_event FROM l_s_event INDEX sy-tabix.
      ENDIF.
    * Populate dummy text.
      s_layout-subtotals_text = 'Dummy'.
    * Init
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
        EXPORTING
          i_callback_program = v_repid.
    * Append
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          is_layout                  = s_layout
          it_fieldcat                = t_fieldcatalog
          i_tabname                  = 'ITAB1'
          it_events                  = i_event
          it_sort                    = t_sort
        TABLES
          t_outtab                   = itab1
        EXCEPTIONS
          program_error              = 1
          maximum_of_appends_reached = 2
          OTHERS                     = 3.
    * Display
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
    *&      Form  BEFORE_LINE_OUTPUT
    *       text
    *      -->GS_LINEINFO  text
    FORM before_line_output USING gs_lineinfo TYPE kkblo_lineinfo.
      FIELD-SYMBOLS: <fs_layout>  TYPE kkblo_layout.
      ASSIGN ('(SAPLKKBL)GT_STACK-IS_LAYOUT') TO <fs_layout>.
      CHECK sy-subrc = 0.
    * Check if it is subtotal line.
      CHECK gs_lineinfo-subtot = 'X'.
    * Get the text
      READ TABLE itab1 INTO wa INDEX gs_lineinfo-sumindex.
      IF sy-subrc = 0.
        <fs_layout>-subtotals_text = wa-text.
      ENDIF.
    ENDFORM.                    "BEFORE_LINE_OUTPUT
    Thanks
    Naren

  • ALV Block List Subtotal

    I have an ALV Block List and in the block list there are multiple currencies and amounts. When i use the subtotal button the expected output is to display calculated total amounts for each of the currencies.
    Whats actually happening is that the total is returning an X.
    Please note that i have used the field catalog field of cfieldname for the amount.
    I also noticed that this only happens when using ALV Block List but when the same thing is done in ALV List totals are being calculated by currency as expected.

    I am having the same problem. Does anyone have the answer?
    Regards,
    Greg

  • Is there any functionality for AVERAGE in ALV, like do_sum, subtot?

    Hi Experts,
    In my_alv report, am doing sub/totals for prices, by using do_sum, subtot functions.........fine. But, I need to do/display the AVERAGE value for Discount % column?
    Is there any functionality for AVERAGE in ALV, like do_sum, subtot?
    thanq

    hi
    check these links out
    http://www.sapfans.com/forums/viewtopic.php?t=20386
    http://www.sapfans.com/forums/viewtopic.php?t=85191
    http://www.sapfans.com/forums/viewtopic.php?t=88401
    http://www.sapfans.com/forums/viewtopic.php?t=17335
    regards
    vijay
    reward points if helpful

  • Query regarding condition type value calculation in VA05

    Dear Gurus,
    We had maintained one condition type Z*** where we had declared the condition type as follows:
    Condition class - Prices
    Calculation type - Quantity
    Plus/Minus - A (positive).
    We had maintained the condition table as :
    Price = 200 USD per 10 EA
    Lower limit = uppler limit = 0.
    When we are calculating the price in the sales document, the system is taking the price of 10 units as 200 USD correctly.
    But in VA05 screen, the confirmed net value for 10 units is shown as 10*200 = 2000 USD which is wrong.
    Can anybody throw a light on how the confirmed net value for VA05 screen is calculated.
    regards,
    Krishna

    If it is representing the value of the condition type, then it is a new field customised by your technical team. Standard VA05 doesnot represent the value of any condition type. So please check with your developer, may be there is a problem in their program.

  • Alv grid total overflow

    hi all,
    I have an overflow error in alv total field.
    first i filled alv grid using et_table_for_first_display, again i changed itab data
    and use refresh_table_display to refresh data.
    the alv contains total fields in field catalog.... when i try to 'refresh_table_display '
    it comes an over flow error is coming and it comes every sort of records.. how can i trap this error ..??
    thanks and regards
    Jose

    Hi Anup,
    While using ALV with OOP methodology, you can create an extra row for giving the sum of any field.
    In the field catalog, there is a component named 'DO_SUM', if set, will give the total value for the field.
    In the method where you fill the field catalog , just add this component.
    eg:
    form catalog_fill changing p_field_catalog.
    data ls_fcat type lvc_s_fcat .
    ls_fcat-fieldname = 'CARRID' .
    ls_fcat-inttype = 'C' .
    ls_fcat-outputlen = '20' .
    ls_fcat-coltext = 'Carrier ID' .
    ls_fcat-web_field = 'carrid_handle'.
    ls_fcat-edit = 'X'.
    *ls_fcat-emphasize = 'C310'.   "needed for column coloring
    append ls_fcat to field_catalog .
    clear ls_fcat .
    ls_fcat-fieldname = 'FLDATE' .
    ls_fcat-ref_table = 'SFLIGHT' .
    ls_fcat-ref_table = 'FLDATE' .
    ls_fcat-outputlen = '20' .
    <b>ls_fcat-do_sum = 'X'.</b>
    ls_fcat-coltext = 'Flight Date' .
    ls_fcat-web_field = 'fldate_handle'.
    append ls_fcat to field_catalog .
    clear ls_fcat .
    ls_fcat-fieldname = 'PRICE' .
    ls_fcat-ref_table = 'SFLIGHT' .
    ls_fcat-ref_table = 'PRICE' .
    ls_fcat-outputlen = '20' .
    ls_fcat-coltext = 'Airfare' .
    append ls_fcat to field_catalog .
    endform.
    In this way, you can get the total of any field in ALV.
    Regards,
    SP.

  • Manual Excise condition type with calculation type as FIXED AMOUNT

    Dear Gurus,
    I have used a manual excise condition (JMAN) in my pricing procedure the difference is that I've changed its calcultaion type to FIXED AMOUNT.
    And in the same pricing procedure I have also got a percentage based Excise condition (ZEXC).
    And in any transaction either of the one that is JMAN or ZEXC will be used.
    The Manual Excise condition is used basically when the raw material sale takes place. The requirement is as such that they should be able to enter the duty value in INR and not in percentage. Please go through the example below
    *(For Example I am procuring raw material of 100 kg worth 10000 at 8% of excise duty. Excise duty will be 800 for 10000rs. So it will be 8 rs per KG.
    And now suppose I am utilizing 80 kg for production and want to sell remaining 20 kg. the Excise duty charged should be 160 rs. considering the rate per unit is 8rs.)*
    In this case user wants to enter the value in INR and not in percentage.
    And normally for the finished goods the percentage based condition is used.
    Now what my issue is that how will I copy the value from JMAN to ZEXC at the raw material sale. otherwise my finished good sales is happening without any problem.
    For this should I use any routine to copy the values from ZMAN to ZEXC??
    Or rather is it possible that I could copy values from a condition type whose calculation type is FIXED AMOUNT to other condition whose calculation type is percentage.
    How should I go ahead with this??
    Please guide me.
    Any answers??
    Cant Do it this way??
    Thanks & Regards
    Anand.k
    Edited by: anand k on Jul 8, 2009 6:38 AM
    Edited by: anand k on Jul 8, 2009 1:04 PM

    Check the condtion value in condition type UTXJ . If the JMOD value is 10% of UTXJ then assessable value should have been maintained for the Material and Plant combination in J1ID. This is due to Routine 351 maintined in pricing procedure for the condition type UTXJ
    check and confirm
    Senthils

  • Use of group conditions in subtotal KZWIW

    Hi,
    I have a specific trouble in the use of group condition in sales order and billing.
    Condition Z001 is a group condition and should also update field kzwi2 as base information for condition Z002
    Condition Z002 is not a group condition and is  calculated based on informations stored in kzwi2. 
    When creating a document, the field kzwi2 is not updated directly (because Z001 is a group conditions) and the price should be redeterminated manually in order to allow the document to be considered as complete.
    Is there any settings that can avoir the manual recalculation of the price?
    Many thanks in advance,
    Nathalie Winand

    Hi Nathalie:
    See Note 1022966 - FAQ for the 'Subto' column (KZWIW) in the pricing procedure
    Perhaps it will help you
    Regards
    Eduardo

  • Reports with all functionality (sorting,total,subtotal,download)

    Hi,
    We require that all the actions which we can perform on the Reports available in SAP environment should also be available in the EP Platform.
    Eg
           sorting,total,subtotal,download.
    Thanks.

    Hi,
    We require that all the actions which we can perform on the Reports available in SAP environment should also be available in the EP Platform.
    Eg
           sorting,total,subtotal,download.
    Thanks.

  • How to Implement Condition-Based Tax Calculation in R/3 for Mexico

    Is there a manual, or some type of guide to implementing condition-based tax calculation in R/3 for Mexico?
    Kind regards,
    Mark Walker

    Hey Mark,
    Check the following link for mexico taxes, may be helpful to you..
    http://help.sap.com/printdocu/core/Print46c/EN/data/pdf/CAINTMX/CAINTMX.pdf
    Thanks
    Prasada

  • Condition class and calculation type missing for conditions downloaded from

    Hi All,
      I have downloaded all the condition types from R/3 using dnl custcndall
    I have even downloaded the following using r3as
    dnl_cust_cnd
    dnl_cust_prc
    dnl_cust_price
    But I have noticed that for the downloaded condition types, condition class and calculation types are missing. Please suggest.

    I have faced the same issue recently.
    The solution is in adapter object DNL_CUST_CNDALL for table T685 and other tables for T685 in that objet put the filters for condition type
    for ex: KSCHL eq PR00
    This sure will work.
    But you have to set this filter for all tables T685*
    Thanks
    Sarabjeet

Maybe you are looking for