Insert a new total line - ALV GRID

Hi Experts!
I need to insert a new total line in a ALV. I'm using the class CL_GUI_ALV_GRID. The total's line "normal" is displayed right, but I want to insert a new total line and that line will receive the total entries number.
Can u help me, please?
I'll reward points!
Best Regards,
Caíque Escaler
Edited by: Caíque Escaler on Feb 8, 2008 6:07 PM

Please check program BCALV_GRID_VERIFY
May this will help you out.

Similar Messages

  • How to insert new record in ALV GRID?

    Hi all,
       I am displaying ztable data into grid format using method  SET_TABLE_FOR_FIRST_DISPLAY of Class CL_GUI_ALV_GRID using OOPS concept.now i want to insert a new record into ALV grid?
    If anyone has tried then please tell me?
    Thanks and Regards,
    Arpita

    Hi Avinash,
    Thanks for replay.
    My problem is solved.i did it as follows.
    HANDLE_DATA_CHANGED
          FOR EVENT DATA_CHANGED OF CL_GUI_ALV_GRID
               IMPORTING ER_DATA_CHANGED
                           E_UCOMM.
    METHOD HANDLE_DATA_CHANGED.
    LOOP AT ER_DATA_CHANGED->MT_GOOD_CELLS INTO WA_GOOD_CELLS.
    CASE WA_GOOD_CELLS-FIELDNAME.
      WHEN 'ZCARRID'.
          CALL METHOD ER_DATA_CHANGED->GET_CELL_VALUE
              EXPORTING
                I_ROW_ID = WA_GOOD_CELLS-ROW_ID
                I_FIELDNAME = WA_GOOD_CELLS-FIELDNAME
              IMPORTING
                E_VALUE = ZCARRID1.
         WA_FLI-ZCARRID = ZCARRID1.
    ENDMETHOD.
    Using method CALL METHOD ER_DATA_CHANGED->GET_CELL_VALUE,
    i am reading individual values and assinning it to WA and then insert into ZTBALE.
    Thanks,
    Arpita

  • Totals and Sub-Totals in ALV GRID

    Could anyone advice, how to display sub-totals and totals in ALV Grid(using FM).
    Ex:           value1    value2
                      100        50
                      200        50
        subtotal   300      100
        total                    400
    Thanks in advance...

    Refer below demo code and see perform Sort_list..
    it wil serve ur purpose.
    REPORT  ZGILL_ALV    message-id rp                           .
    type-pools slis.
    tables: zgill_main,zgill_details.
    data z_fieldcat type slis_t_fieldcat_alv.
    data begin of itab occurs 0.
    DATA ICON TYPE ICON-ID.
         include structure zgill_main.
    data salary like zgill_details-salary.
    data end of itab.
    *data itab1 like table of itab with header line.
    data : WA_SORT TYPE SLIS_SORTINFO_ALV,
           IT_SORT TYPE SLIS_T_SORTINFO_ALV,
           WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
           IT_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
           WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    PARAMETERS: p_list  radiobutton group A1,
                P_GRID  RADIOBUTTON GROUP A1.
    SELECT-OPTIONS: S_PERNR FOR ZGILL_MAIN-PERNR.
    start-of-selection.
    perform fill_itab.
    perform sort_list.
    **************Start of scenario without container******************************************
    *********Method 1***********
    perform fill_fieldcat.  " Manuallly Preparing Fiedl Catalog
    *********Method 2***********
    *perform fill_fieldcat1 changing z_fieldcat.   "Preparing field catalog with merge function
    perform display_alv.
    *****************end of scenario without container*****************************************
    *&      Form  fill_itab
          text
    -->  p1        text
    <--  p2        text
    form fill_itab .
    *select * from zgill_main up to 20 rows INTO CORRESPONDING FIELDS OF TABLE itab.
    *ITAB1[] = ITAB[].
    select apernr aname aorg adob b~salary INTO CORRESPONDING FIELDS OF TABLE itab
           from zgill_main as a join zgill_details as b on apernr = bpernr
           WHERE A~PERNR IN S_PERNR.
    LOOP AT ITAB.
    IF ITAB-PERNR < 1111.
    ITAB-ICON = '@08@'.
    ELSEIF ITAB-PERNR > 1111 AND ITAB-PERNR < 11111111.
    ITAB-ICON = '@09@'.
    ELSEIF ITAB-PERNR GE 11111111.
    ITAB-ICON = '@0A@'.
    ENDIF.
    MODIFY ITAB INDEX SY-TABIX.
    ENDLOOP.
    endform.                    " fill_itab
    *&      Form  display_alv
          text
    -->  p1        text
    <--  p2        text
    form display_alv .
    data repid like sy-repid.
    REPID = SY-REPID.
    WA_LAYOUT-ZEBRA = 'X'.
    WA_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'.
    WA_LAYOUT-SUBTOTALS_TEXT = 'SUBTOTAL'.
    WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.
    IF P_GRID = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = repid
       IT_FIELDCAT                       = IT_FIELDTAB
       IT_SORT                           = IT_SORT
       IS_LAYOUT                         = WA_LAYOUT
    TABLES
        t_outtab                          = itab[]
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2.
    IF sy-subrc <> 0.
       message e016 with 'Error in Display'.
    ENDIF.
    ELSEIF P_LIST = 'X'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = repid
       IT_FIELDCAT                       = IT_FIELDTAB
       IT_SORT                           = IT_SORT
       IS_LAYOUT                         = WA_LAYOUT
    TABLES
        t_outtab                          = itab[]
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2.
    IF sy-subrc <> 0.
       message e016 with 'Error in Display'.
    ENDIF.
    ENDIF.
    endform.                    " display_alv
    *&      Form  fill_fieldcat1
          text
    -->  p1        text
    <--  p2        text
    form fill_fieldcat1  changing d_fcat type slis_t_fieldcat_alv.
    data repid like sy-repid.
    data d_fcat1 type slis_t_fieldcat_alv with header line.
    REPID = SY-REPID.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = repid
       I_INTERNAL_TABNAME           = 'ITAB'
       I_STRUCTURE_NAME             = 'ZGILL_MAIN'
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_INCLNAME                   =
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
    CHANGING
        ct_fieldcat                  = d_fcat[]
    EXCEPTIONS
       INCONSISTENT_INTERFACE       = 1
       PROGRAM_ERROR                = 2
       OTHERS                       = 3.
    IF sy-subrc <> 0.
       message e016 with 'Error in preparing fiedl catalog'.
    ENDIF.
    loop at d_fcat into d_fcat1.
    case d_fcat1-fieldname.
    when 'NAME'.
    d_fcat1-reptext_ddic = 'Emp Name'.
    MODIFY D_FCAT FROM D_FCAT1.
    WHEN 'PERNR'.
    d_fcat1-reptext_ddic = 'Emp Num'.
    MODIFY D_FCAT FROM D_FCAT1.
    WHEN 'ORG'.
    d_fcat1-reptext_ddic = 'Org Unit'.
    MODIFY D_FCAT FROM D_FCAT1.
    endcase.
    clear d_fcat1.
    endloop.
    endform.                    " fill_fieldcat1
    *&      Form  sort_list
          text
    -->  p1        text
    <--  p2        text
    form sort_list .
    CLEAR WA_SORT.
    WA_SORT-FIELDNAME = 'DOB'.
    WA_SORT-SPOS = '1'.
    WA_SORT-UP = 'X'.
    WA_SORT-SUBTOT = 'X'.
    APPEND WA_SORT TO IT_SORT.
    CLEAR WA_SORT.
    WA_SORT-FIELDNAME = 'NAME'.
    WA_SORT-SPOS = '1'.
    WA_SORT-UP = 'X'.
    APPEND WA_SORT TO IT_SORT.
    CLEAR WA_SORT.
    endform.                    " sort_list
    *&      Form  fill_fieldcat
          text
    -->  p1        text
    <--  p2        text
    form fill_fieldcat .
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'ICON'.
    WA_FIELDCAT-SELTEXT_L = 'TRAFFIC'.
    WA_FIELDCAT-ICON = 'X'.
    WA_FIELDCAT-ddictxt = 'l'.
    WA_FIELDCAT-COL_POS = 1.
    WA_FIELDCAT-OUTPUTLEN = 10.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'PERNR'.
    WA_FIELDCAT-SELTEXT_L = 'EMP NUMBER'.
    WA_FIELDCAT-ddictxt = 'l'.
    WA_FIELDCAT-COL_POS = 2.
    WA_FIELDCAT-OUTPUTLEN = 10.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    when 'maktx'.
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'NAME'.
    WA_FIELDCAT-SELTEXT_L = 'EMP NAME'.
    WA_FIELDCAT-ddictxt = 'l'.
    WA_FIELDCAT-COL_POS = 3.
    WA_FIELDCAT-OUTPUTLEN = 15.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'ORG'.
    WA_FIELDCAT-SELTEXT_L = 'ORG UNIT'.
    WA_FIELDCAT-COL_POS = 4.
    WA_FIELDCAT-OUTPUTLEN = 10.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'DOB'.
    WA_FIELDCAT-SELTEXT_L = 'BIRTH DATE'.
    WA_FIELDCAT-COL_POS = 5.
    WA_FIELDCAT-OUTPUTLEN = 12.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'SALARY'.
    WA_FIELDCAT-SELTEXT_L = 'SALARY'.
    WA_FIELDCAT-COL_POS = 6.
    WA_FIELDCAT-OUTPUTLEN = 25.
    WA_FIELDCAT-do_sum = 'X'.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    endform.                    " fill_fieldcat

  • Edit new record in ALV grid

    Hi experts,
    I have developed <b>normal</b> ALV. There is an option( Insert row) to add new row in the grid.Now, i wanted to enter values in the new row.
    If i make EDIT = 'X' in the fieldcatalog it opens up all of the existing records , which I don't want. I want to enter values in new row only.
    if i use something like
      data: wa_stg like gt_stage occurs 0 with header line,
      lt_celltab type lvc_t_styl,
      ls_celltab type lvc_s_styl.
      loop at gt_stage into wa_stg.
        ls_celltab-fieldname = 'FISTL'.
        ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
        insert ls_celltab into table lt_celltab.
        wa_stg-celltab[] = lt_celltab[].
        modify gt_stage from wa_stg transporting celltab.
        clear: ls_celltab, lt_celltab.
      endloop.
    i cant use
      call method gv_grid->set_table_for_first_display
        exporting
          is_layout       = gs_layout
        changing
          it_outtab       = gt_stage[]
          it_fieldcatalog = i_fieldcat.
    because it is for OO.
    Is there anyway to do this?
    reward guaranteed,
    Thanks

    Hi kaki,
    From your code, it looks like Your ARE using OOPS for your ALV.
    Check this link:
    http://help.sap.com/saphelp_erp2004/helpdata/en/0a/b55312d30911d2b467006094192fe3/content.htm
    Check this sample program:
    http://sapabap.iespana.es/sapabap/sap/reports/alv_grid.htm
    Regards,
    Ravi
    Message was edited by:
            Ravi Kanth Talagana

  • Regarding subtotals and new page in ALV Grid

    Hi All,
    I have 5 employees in my internal table and each employee having five records.
    Now iam displaying total employees in ALV grid and calculating their totals at the end of the hole records.
    But i need to display the sub totals for each employee and i need new page for each employee.
    means  1) New page for each employye
                2) sub totals for each employee
                3) grand total for all employees
    How can i proceed for this requirement in ALV grid?

    For subtotals first you need to set the do_sum = 'X' in the fieldcatalog for the columns you want totals.
    fieldcat-fieldname = 'ABC'.
    fieldcat-do_sum = 'X'.
    Append fieldcat to it_fieldcat,
    for subtotals you need to populate the SORT table.
    sort-fieldname = 'EMPLOYEE'.
    sort-up = 'X'.
    sort-group = '*'.  "<----- this is for new page
    "you can view new page in preview / print /
    "if you are using the list function
    sort-subtot = 'X'.
    append sort to it_sort.
    pass this it_sort to it_sort of the alv function.

  • Sub total in ALV GRID using oops concept

    Hi,
    If Plant (VBAP-WERKS) is not the same for all items on a Sales Order (VBAK-VBELN is the same for al items) then create a separate line on the report for each different plant specified in the line items.  Copy all fields from the original order line except for plant and Net Value.  Net Value should be the total of item Net Values for all items with the same plant in the order.
    Example:
    Data:
    Order----                     Item-             Plant-                                     Net Value---
    123----          010-               3467-                      100.00---
    123----          020-               7865-                      50.00---
    123----          030-               3467-                     80.50---
    Report:
    Order-                     Plant-                  Net Value---
    123-          3467-                  180.50---
    123-          7865-                   50.00----
    I need to dispaly the Report format in ALV Grid using oops concept...
    no need of calling any function modules.
    Regards,
    Nithya

    Hi
    Here is example code
    This is the method to be called:
    get_subtotals
    Use
    Returns the current subtotals of the ALV Grid Control. Having created totals for at least one column, users can calculate at most nine subtotals. The list is sorted by the values of one or several columns (called the subtotals column). If a value is changed in the subtotals column, the subtotal is displayed (this is also referred to as control level change).
    Integration
    Before you access the subtotals value, you use the method get_sort_criteria to get the sort table . One row of this table describes properties of a column in the output table.
    • If the field SUBTOT is set for a column in this table, the column is a subtotals column.
    • The field SPOS then indicates at which level (see below) the subtotal has been calculated.
    • The field FIELDNAME contains the name of the subtotals column in the output table.
    Based on this information, you specifically access the values of the tables passed (using reference variables COLLECT01 to COLLECT09).
    Features
    CALL METHOD <ref. var. to CL_GUI_ALV_GRID>->get_subtotals
    IMPORTING
    EP_COLLECT00 = <reference variable of type REF TO DATA>
    EP_COLLECT01 = <reference variable of type REF TO DATA>
    EP_COLLECT02 = <reference variable of type REF TO DATA>
    EP_COLLECT03 = <reference variable of type REF TO DATA>
    EP_COLLECT04 = <reference variable of type REF TO DATA>
    EP_COLLECT05 = <reference variable of type REF TO DATA>
    EP_COLLECT06 = <reference variable of type REF TO DATA>
    EP_COLLECT07 = <reference variable of type REF TO DATA>
    EP_COLLECT08 = <reference variable of type REF TO DATA>
    EP_COLLECT09 = <reference variable of type REF TO DATA>
    ET_GROUPLEVELS = <ínternal table of type LVC_T_GRPL>.
    In order to access the values of EP_COLLECT00 to EP_COLLECT09, you use ASSIGN to dereference the relevant reference variable in a field symbol of your output table type (see below).
    Parameters
    Meaning
    EP_COLLECT00
    Points to the totals line. Since there is only one totals line which, in addition, has a unique totalling area, no further information is available for this table in table ET_GROUPLEVELS.
    get_subtotals
    EP_COLLECT01 to EP_COLLECT09
    Point to the subtotals line. For each subtotals level, there is one reference variable. Each of these variables points to an internal table that has the type of the output table. EP_COLLECT01 points to the subtotal at the hightest level, while EP_COLLECT02 points to the subtotal at the second highest level, and so on. The levels are derived from the sort priority (field SPOS in the sort table ). The column by which the data was sorted first, is the highest subtotals level.
    ET_GROUPLEVELS
    Manages all indexes for the individual control levels. The fields of the table have the following meaning:
    • INDEX_FROM, INDEX_TO: Rows of the output table for which the subtotal was created
    • LEVEL: Subtotals level (see above)
    • COUNTER: Number of rows for which the subtotal was created
    • COMPRESS: For this subtotals line, the user has hidden the associated rows.
    • COLLECT: Indicates the subtotals table (01-09) in which the values are stored
    For an overview, see Methods of Class CL_GUI_ALV_GRID
    Activities

  • Split Totals on ALV Grid

    Hi all,
    When displaying totals in a column of an ALV Grid (objects methodology) my totals are split. For example, if I have 5 rows with values in the column being summed of 100, 20, 300, 40 and 500; I end up with 3 total lines at the end of the list of 120, 300 and 540. The column being summed is a QUAN field (EKPO-MENGE). I have tried the NO_UTSPLIT parameter in the layout, and have tried referencing the UoM in the fieldcatalog for the field being summed with no success. Any ideas?
    Regards,
    Randy

    Hi
      As amit said, sum of the field is triggered at other fields, you can change in the output of this ALV list,
    if have the GUI status as STANDARD or MAIN,
    you will get the following in the menu bar, prerequest before,
    1. u should have a sum field in the outlist.
    2. u should have subtotal.
    Now follow the steps in the menu,
    1. Go to setting --> Choose Summary level --> Define drildown. 
    Now u can change the sub total level based on the sort conditions.
    Regards,
    prabhu rajesh.

  • New Page in ALV GRID display.

    HI Experts,
    I have a requirement of displaying top of page and corresponding detailed records for specific combination of top of page(say plant,material,batch etc). Again for the next combination I need repeated header and detail list.
    I guess I have to use NEW PAGE to get this.
    However, I am using the REUSE ALV GRID DISPLAY for which the sort table does not display as required.
    Could you please help me  on this?
    In addition could you please suggest how to use NEW page in report without using OOPS concept.
    Please reply.
    Thanks,
    Suchi.

    Hi,
    1.Put a pushbutton  on the ALV o/p say 'Next'.
    2. Now in the user comand routine you have to change the  table contents u supply to reuse_alv_commentary write, also fill the o/p internal table with data corresponding to ur specific combination and supply to reuse_alv_grid_display.
    3.In the user comand routine u have  slis_selfield.
    4.It contains a component refresh, mark it as 'X'.( slis_selfield-refresh = 'X'.)
    5.No need of new page or calling reus_alv_grid_display number of times.
    Regards,
    Phani.

  • Total in ALV Grid

    I have data like currency and amounts and i want to display that amount as a total in alv display..
    i used do_sum = x whle building fieldcat but itsdisplaying it currencywise like sub total...instead i want to total for all currencies and display it..
    please guide

    See the following example in this example  WAERS is CUKY type
    DATA: BEGIN OF ITAB OCCURS 0,
           BELNR LIKE BSEG-BELNR,
           GJAHR TYPE I,
           WRBTR TYPE I,
           WAERS LIKE BKPF-WAERS,
           TOTAL TYPE P,
          END OF ITAB.
    DATA: LAYOUT     TYPE SLIS_LAYOUT_ALV,
          IT_EVENTS  TYPE SLIS_T_EVENT,
          FCAT       TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
          REC_FCAT   TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
    START-OF-SELECTION.
      FCAT-COL_POS       = 1.
      FCAT-FIELDNAME     = 'BELNR'.
      FCAT-TABNAME       = 'ITAB'.
      FCAT-REF_FIELDNAME = 'BELNR'.
      FCAT-REF_TABNAME   = 'BSEG'.
      APPEND FCAT.
      FCAT-COL_POS       = 2.
      FCAT-FIELDNAME     = 'GJAHR'.
      FCAT-TABNAME       = 'ITAB'.
      FCAT-REF_FIELDNAME = 'GJAHR'.
      FCAT-DATATYPE      = 'INT4'.
      FCAT-INTTYPE       = 'I'.
      FCAT-DO_SUM        = 'X'.
    APPEND FCAT.
      FCAT-COL_POS       = 3.
      FCAT-FIELDNAME     = 'WRBTR'.
      FCAT-TABNAME       = 'ITAB'.
      FCAT-DATATYPE      = 'INT4'.
      FCAT-INTTYPE       = 'I'.
      FCAT-DO_SUM        = 'X'.
      APPEND FCAT.
    FCAT-COL_POS       = 4.
      FCAT-FIELDNAME     = 'TOTAL'.
      FCAT-TABNAME       = 'ITAB'.
    *  FCAT-DATATYPE      = 'INT4'.
      FCAT-INTTYPE       = 'P'.
      FCAT-DO_SUM        = 'X'.
      APPEND FCAT.
      DO 10 TIMES.
        ITAB-WRBTR = SY-INDEX.
        ITAB-GJAHR = SY-INDEX + 1.
       ITAB-TOTAL = ITAB-WRBTR / ITAB-GJAHR.
        APPEND ITAB.
      ENDDO.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
        EXPORTING
          I_CALLBACK_PROGRAM = 'Z_TOT_ALV'.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          IS_LAYOUT   = LAYOUT
          IT_FIELDCAT = FCAT[]
          I_TABNAME   = 'ITAB'
          IT_EVENTS   = IT_EVENTS[]
        TABLES
          T_OUTTAB    = ITAB[].
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
    Edited by: kk.adhvaryu on Apr 5, 2010 9:23 AM

  • New Problem with ALV grid

    Hi,
    I am working an ALV grid in my report. after executing my report ALV grid is displaying all columns with all records. But if i am trying to see print priview or if i am trying to do export to spreadsheet, many columns are missing & records also jumbling from their exact places.
    Why it is coming like this? can u help me. .
    Thanks
    vishnu

    Hi,
    if i am trying to do export to spreadsheet, many columns are missing & records also jumbling from their exact places.
    Regarding on your query, You will write a query as select query
    I.e.., select a query corresponding coloumns and reterive the data
    Then check through an select corresponding coloums
    Then solved your problem.
    Regards,
    Sekhar

  • How to divide 2 columns totals in ALv grid

    Hi All,
    i developed alv report & displayed totals. now i need to divide those totals and display as another column total.
    anyone please suggest.
    col1    col2    col3
    tot1     tot2     tot3
    tot3 = tot2 / tot1.
    thanks,

    Hi,
    For this, in HTML_TOP_OF_PAGE or  TOP_OF_PAGE first you need to get global reference variable for GRID
    for getting reference call FM GET_GLOBALS_FROM_SLVC_FULLSCR.
    By using this reference  call method GET_SUBTOTALS it will get the all total into Internal Table .
    Using Field Symbols u can calculate. Still u have any problem i will help u further .
    Regards,
    Ravindra.

  • Totas and sub totals in ALV grid display

    Hi all,
    how can I get the total for an integer field in internal table. I am using the following code, but unable to display the total. Can anyone give the reason for the same.
    Thank you,
    Usha
    REPORT  ZTEST_SUB                               .
    TABLES : vbak.
    TYPE-POOLS: slis.
    SELECT-OPTIONS :  s_vkorg FOR vbak-vkorg,
                      s_kunnr FOR vbak-kunnr,
                      s_vbeln FOR vbak-vbeln.
    SELECTION-SCREEN :  SKIP,
                        BEGIN OF LINE,
                        COMMENT 5(27) v_1 FOR FIELD p_max.
                        PARAMETERS p_max(2) TYPE n DEFAULT '2' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    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.
    DATA:  BEGIN OF gt_vbak OCCURS 0,
             vkorg LIKE vbak-vkorg,
             kunnr LIKE vbak-kunnr,
             vbeln LIKE vbak-vbeln,
             test  type I,
           END OF gt_vbak.
    START-OF-SELECTION.
      PERFORM f_read_data.
      loop at gt_vbak.
      gt_vbak-test = 1.
      modify gt_vbak.
    endloop.
      PERFORM f_display_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.
    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-ref_FIELDname = &2.
        ls_fieldcat-do_sum      = &3.
        ls_fieldcat-cfieldname  = &4.
        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.
        ls_sort-group     = '*'.
        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' 'VKORG' '' ''.
            m_fieldcat 'KUNNR' '' ''  ''.
            m_fieldcat 'VBELN' '' ''  ''.
            m_fieldcat 'TEST'  '' 'X'  ''.
           m_sort 'VKORG' ''.
           m_sort 'KUNNR' ''.
           m_sort 'VBELN' ''.
            m_sort 'TEST'  'X'.
            ls_layout-cell_merge = 'X'.
            LS_LAYOUT-WINDOW_TITLEBAR = 'test window'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       IS_LAYOUT                         = ls_layout
       IT_FIELDCAT                       = lt_fieldcat
       IT_SORT                           = lt_sort
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        T_OUTTAB                          = gt_vbak
    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.

    hi
    REPORT ZTEST_SUB .
    TABLES : vbak.
    TYPE-POOLS: slis.
    SELECT-OPTIONS : s_vkorg FOR vbak-vkorg,
    s_kunnr FOR vbak-kunnr,
    s_vbeln FOR vbak-vbeln.
    SELECTION-SCREEN : SKIP,
    BEGIN OF LINE,
    COMMENT 5(27) v_1 FOR FIELD p_max.
    PARAMETERS p_max(2) TYPE n DEFAULT '2' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    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.
    DATA: BEGIN OF gt_vbak OCCURS 0,
    vkorg LIKE vbak-vkorg,
    kunnr LIKE vbak-kunnr,
    vbeln LIKE vbak-vbeln,
    test type I,
    END OF gt_vbak.
    START-OF-SELECTION.
    PERFORM f_read_data.
    loop at gt_vbak.
    gt_vbak-test = 1.
    modify gt_vbak.
    endloop.
    PERFORM f_display_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.
    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-ref_FIELDname = &2.
    ls_fieldcat-do_sum = &3.
    ls_fieldcat-cfieldname = &4.
    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.
    ls_sort-group = '*'.
    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' 'VKORG' '' ''.
    m_fieldcat 'KUNNR' '' '' ''.
    m_fieldcat 'VBELN' '' '' ''.
    m_fieldcat 'TEST' '' 'X' ''.
    m_sort 'VKORG' ''.
    m_sort 'KUNNR' ''.
    <b> m_sort 'VBELN' 'X'.</b>
    *m_sort 'TEST' 'X'.
    ls_layout-cell_merge = 'X'.
    LS_LAYOUT-WINDOW_TITLEBAR = 'test window'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    IS_LAYOUT = ls_layout
    IT_FIELDCAT = lt_fieldcat
    IT_SORT = lt_sort
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    T_OUTTAB = gt_vbak
    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.
    Message was edited by: Ashok Parupalli

  • Subtotal in ALV grid for a particular type and Grand total in ALV

    Hi,
    I need to have sub total for a particular type(eg: goods, services).. and grand total at end in ALV grid..
    ALV output required as below:
    Type     VAT registration number     Country      Total Gross Amounts       Total Tax Amounts       Total Amount, ex-tax
    Goods     ATU12345678     AT                  222.42      0         222.42
    Goods     NL123456789B02     NL               3,417.00      0      3,417.00
         Goods Total                    3,639.42                -         3,639.42
    Services     ATU12345678     AT               2,342.34      0      2,342.34
    Services     NL123456789B02     NL                  223.33      0         223.33
         Services Total                    2,565.67                -         2,565.67
         Grand Total                    6,205.09                -         6,205.09
    Let me as to how to achieve the above type in ALV grid...
    Regards
    Shiva

    check this link..
    Grand Totals in ALV grid disply function module
    or do like this..
    REPORT  ZALVTESTFORSUBTOTAL.
    tables:pa0008.
    type-pools:slis.
    types:begin of ty_pa0008,
          pernr like pa0008-pernr,
          begda like pa0008-begda,
          endda like pa0008-endda,
          ansal like pa0008-ansal,
          lga01 like pa0008-lga01,
          bet01 like pa0008-bet01,
          end of ty_pa0008.
    data:it_pa0008 type standard table of ty_pa0008 with header line.
    data:it_fieldcat type SLIS_T_FIELDCAT_ALV,
         wa_fieldcat type slis_fieldcat_alv,
         it_layout type slis_layout_alv,
         WA_events TYPE slis_alv_event,
         it_events TYPE slis_t_event.
    select-options:s_pernr for pa0008-pernr.
    start-of-selection.
    perform getD_data.
    perform disp_alv.
    *&      Form  getD_data
          text
    -->  p1        text
    <--  p2        text
    form getD_data .
    select pernr
           begda
           endda
           ansal
           lga01
           bet01
           from pa0008
           into table it_pa0008
           where pernr in s_pernr.
    sort it_pa0008 by pernr begda descending.
    endform.                    " getD_data
    *&      Form  disp_alv
          text
    -->  p1        text
    <--  p2        text
    form disp_alv .
    wa_fieldcat-fieldname = 'PERNR'.
    wa_FIELDCAT-REPTEXT_DDIC = 'Personnel no'.
    *WA_FIELDCAT-no_subtotals = 'X'.
    append wa_fieldcat to it_fieldcat.
    clear wa_fieldcat.
    wa_fieldcat-fieldname = 'BEGDA'.
    wa_FIELDCAT-REPTEXT_DDIC = 'Start date'.
    append wa_fieldcat to it_fieldcat.
    clear wa_fieldcat.
    wa_fieldcat-fieldname = 'ENDDA'.
    wa_FIELDCAT-REPTEXT_DDIC = 'End date'.
    append wa_fieldcat to it_fieldcat.
    clear wa_fieldcat.
    wa_fieldcat-fieldname = 'ANSAL'.
    wa_FIELDCAT-REPTEXT_DDIC = 'Annula salary'.
    wa_fieldcat-do_sum = 'X'.
    append wa_fieldcat to it_fieldcat.
    clear wa_fieldcat.
    wa_fieldcat-fieldname = 'LGA01'.
    wa_FIELDCAT-REPTEXT_DDIC = 'Wage Type'.
    append wa_fieldcat to it_fieldcat.
    clear wa_fieldcat.
    wa_fieldcat-fieldname = 'BET01'.
    wa_FIELDCAT-REPTEXT_DDIC = 'Amount for wagetype'.
    append wa_fieldcat to it_fieldcat.
    clear wa_fieldcat.
    DATA: sort TYPE slis_sortinfo_alv,
    it_sort TYPE slis_t_sortinfo_alv.
    sort-fieldname = 'PERNR'.
    sort-subtot = 'X'.
    SORT-UP = 'X'.
    APPEND sort TO it_sort.
    *sort-fieldname = 'BEGDA'.
    *SORT-NO_SUBTOTS = 'X'.
    *APPEND sort TO it_sort.
    IT_layout-totals_text = 'total text'.
    IT_layout-subtotals_text = 'Subtotal text'.
    *WA_EVENTS-NAME = 'SUBTOTAL TEXT'.
    *WA_EVENTS-FORM = 'SUBTOTAL TEXT'.
    *APPEND WA_EVENTS TO IT_EVENTS.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM             = sy-repid
       IS_LAYOUT                      = it_LAYOUT
       IT_FIELDCAT                    = IT_FIELDCAT
       it_sort                        = it_sort
      it_events                      = it_events
       TABLES
        t_outtab                       = it_pa0008 .
    endform.                    " disp_alv

  • Mix AVG and Total for the same column in ALV grid

    Hi,
    We are using CL_GUI_ALV_GRID=>SET_TABLE_FOR_FIRST_DISPLAY, and I'd like to know if the following situation is possible.
    Let's say we have a column which contains a number of hours, and we set it up to subtotal by period, but as an average rather than a total (DO_SUM = "C"). This is not a problem so far.
    The problem is that we'd like for the "Grand Total" at the bottom of the ALV grid to total all of the subtotal averages, instead of calculating an average.
    Ex:
    Period            Hours
    2010/01           6.0
    2010/02           7.0
    2010/03           2.0
                    5.0  (This is an average... 6.0 + 7.0 + 2.0 / 3)
    2011/01          12.0
    2011/02           5.0
    2011/03           4.0
                    7.0  (This is an average... 12.0 + 5.0 + 4.0 / 3)
                12.0 (We want this to be a total of 5.0 + 7.0)
    So we want the "grand total" line to be 12.0 which is the sum, but it currently comes out as an average.
    Therefore we're looking to average at the sub total level, but we want a total of the subtotal levels at the grand total level for the same column.
    Thanks,
    Denis

    Refer to the suggestion given by Naimesh here Can we modify a sub-total in ALV making use of function GET_GLOBALS_FROM_SLVC_FULLSCR and the method GET_SUBTOTALS. You can see the parameter ep_collect01 refered in case of subtotals. Can you please check ep_collect00 for grand total in your case.
    As said about EP_COLLECT00,here goes a classic example Modify grand total in ALV GRID
    BR
    Keshav
    Edited by: Keshav.T on Sep 21, 2011 9:39 AM

  • Total problem in Exporting ALV GRID to Excel

    Hi all,
    I have manipulated the Total of ALV Grid by using GET_SUBTOTALS and REFRESH method of CL_GUI_ALV_GRID. The ALV Output is also correct. When i export to Excel,only the Original total is displaying not the calculated one. How to download the exact output which is displaying in the ALV Grid to Excel.
    Please help me out to solve this.
    Thanks,
    Ramesh

    DEAR,
    AS U WANT UPLOAD WITH THE SUB TOTAL YOU TRY THIS.
    FIRST to get subtotal in ALV output you select at least one column of total and then press ctrl + F6 . u will see the sub total .
    and now how to download it so press  ctrl + shift + F9 .
    now screen appears and select second option ie spreadsheet and press enter
    now a screen appear  in wich u have to give file name.
    so double click on search button of file name . click on desktop  give ur file name as u want suppose zreport u have given.
    and save type = excel file.
    now save it and then generate it your output bytes will be transmitted .
    now u can see in your desktop in your file name . ur output with subtotal.
    regards
    navin

Maybe you are looking for

  • To download the print format and mail it on giving a range of customers

    Hai i have a smartform attached program to a report. my selection screen contains only customer number (in range) and sales office code. on executing the program will generate a printfile file for each customers. i posted this question already and go

  • IPod Classic no longer syncs all video podcasts

    My iPod Classic 30 GB used to play Onion News Network and TED videos, no problem. Now I get a message when I try to sync them that says 'Cannot be played on your iPod.' These are TED videos dating back to 2009, and similarly old Onion News Network vi

  • Problem with Oracle Native Sequencing - please help!!

    Hello I am migrating from 3.6.5 to 10.1.3.1 (huge jump). And have a problem with sequencing. When I create new object Toplink does not pick up Sequence object name from the descriptor. When I see generated SQL it shows: SELECT .NEXTVAL FROM DUAL Each

  • NEED HELP Search with SAF/TREX

    Hello Gurus, I have to work on standard screen in that they are fetching database and extracting the data by using CL_CRM_EI_IIA_QUERY_UI class. In this calss they are using SET_QUERY, GET_QUERY, GET_TEXT_QUERY, SET_TEXT_QUERY,CREATE_TEXT_EDITOR meth

  • Cd burner not burning

    hi, my emac is not reading blank cd-r's...it is reading previously burned cd's but when I insert a new blank cd to burn I get a 'medium write error' message...I have tried various brands [maxell, sony, imation, tdk]...does anyone know what could be t