Subtotal  function in ALV report

Hi, experts,
I got a problem when creating an ALV report about billing document.
This ALV report include following info:
Billing date
Billing doc no.
Customer no.
Customer name
Material no.
Material name
Condition name
Qty
Unit price
Amount
Tax amount
Invoice total
The logic of subtotal for this report is:
In same billing document no.
1. If condition name=A, then subtotal Qty, Amount, Invoice total by material no.
2. If condition name ≠A, then subtotal Qty, Amount , Invoice total by condition name
Is it possible? How can I achieve it?

Hi,
Please find details on how to modify ALV report below:
/people/ravikumar.allampallam/blog/2005/12/05/need-a-way-to-change-appearance-of-a-standard-existing-alv-report
<b>Reward if helpful.</b>

Similar Messages

  • Problem with subtotal calculation in ALV reports

    Hi All,
       I am doing one program for calculating subtoals in ALV . For this i want to display subtotal text at each envey subtotal 's row.
    For that i have created one form 'SUB_SUBTOT_TEXT' and it has given to IT_EVENTS-FORM. But SUB_SUBTOT_TEXT Form is not called by IT_EVENTS event.
    what are all the mandatories for displaying subtotal text.
    Can any one please help me.
    Thanks in Advance.

    Hi Sree,
    *& Table declaration
    &----TABLES: ekko.&----
    *& Type pool declaration
    TYPE-POOLS: slis. " Type pool for ALV&----
    *& Selection screen
    SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.&----
    *& Type declaration
    &----* Type declaration for internal table to store EKPO data
    TYPES: BEGIN OF x_data,
           ebeln  TYPE char30,  " Document no.
           ebelp  TYPE ebelp,   " Item no
           matnr  TYPE matnr,   " Material no
           matnr1 TYPE matnr,   " Material no
           werks  TYPE werks_d, " Plant
           werks1 TYPE werks_d, " Plant
           ntgew  TYPE entge,   " Net weight
           gewe   TYPE egewe,   " Unit of weight                          
           END OF x_data.&----
    *& Internal table declaration
    DATA:* Internal table to store EKPO data
      i_ekpo TYPE STANDARD TABLE OF x_data INITIAL SIZE 0,
    Internal table for storing field catalog information
      i_fieldcat TYPE slis_t_fieldcat_alv,
    Internal table for Top of Page info. in ALV Display
      i_alv_top_of_page TYPE slis_t_listheader,
    Internal table for ALV Display events
      i_events TYPE slis_t_event,
    Internal table for storing ALV sort information
      i_sort TYPE  slis_t_sortinfo_alv,
      i_event TYPE slis_t_event.&----
    *& Work area declaration
    &----DATA:
      wa_ekko TYPE x_data,
      wa_layout     TYPE slis_layout_alv,
      wa_events         TYPE slis_alv_event,
      wa_sort TYPE slis_sortinfo_alv.&----
    *& Constant declaration
    &----CONSTANTS:
       c_header   TYPE char1
                  VALUE 'H',                    "Header in ALV
       c_item     TYPE char1
                  VALUE 'S'.&----
    *& Start-of-selection event
    &----START-OF-SELECTION.* Select data from ekpo
      SELECT ebeln " Doc no
             ebelp " Item
             matnr " Material
             matnr " Material
             werks " Plant
             werks " Plant
             ntgew " Quantity
             gewei " Unit
             FROM ekpo
             INTO TABLE i_ekpo
             WHERE ebeln IN s_ebeln
             AND ntgew NE '0.00'.  IF sy-subrc = 0.
        SORT i_ekpo BY ebeln ebelp matnr .
      ENDIF.* To build the Page header
      PERFORM sub_build_header.* To prepare field catalog
      PERFORM sub_field_catalog.* Perform to populate the layout structure
      PERFORM sub_populate_layout.* Perform to populate the sort table.
      PERFORM sub_populate_sort.* Perform to populate ALV event
      PERFORM sub_get_event.END-OF-SELECTION.* Perform to display ALV report
      PERFORM sub_alv_report_display.
    *&      Form  sub_build_header
          To build the header
          No Parameter
    FORM sub_build_header .* Local data declaration
      DATA: l_system     TYPE char10 ,          "System id
            l_r_line     TYPE slis_listheader,  "Hold list header
            l_date       TYPE char10,           "Date
            l_time       TYPE char10,           "Time
            l_success_records TYPE i,           "No of success records
            l_title(300) TYPE c.                " Title
    Title  Display
      l_r_line-typ = c_header.               " header
      l_title = 'Test report'(001).
      l_r_line-info = l_title.
      APPEND l_r_line TO i_alv_top_of_page.
      CLEAR l_r_line.* Run date Display
      CLEAR l_date.
      l_r_line-typ  = c_item.                " Item
      WRITE: sy-datum  TO l_date MM/DD/YYYY.
      l_r_line-key = 'Run Date :'(002).
      l_r_line-info = l_date.
      APPEND l_r_line TO i_alv_top_of_page.
      CLEAR: l_r_line,
             l_date.ENDFORM.                    " sub_build_header
    *&      Form  sub_field_catalog
          Build Field Catalog
          No Parameter
    FORM sub_field_catalog .*  Build Field Catalog
      PERFORM sub_fill_alv_field_catalog USING:     '01' '01' 'EBELN' 'I_EKPO' 'L'
         'Doc No'(003) ' ' ' ' ' ' ' ',     '01' '02' 'EBELP' 'I_EKPO' 'L'
         'Item No'(004) 'X' 'X' ' ' ' ',     '01' '03' 'MATNR' 'I_EKPO' 'L'
         'Material No'(005) 'X' 'X' ' ' ' ',     '01' '03' 'MATNR1' 'I_EKPO' 'L'
         'Material No'(005) ' ' ' ' ' ' ' ',
         '01' '04' 'WERKS' 'I_EKPO' 'L'
         'Plant'(006) 'X' 'X' ' ' ' ',     '01' '04' 'WERKS1' 'I_EKPO' 'L'
         'Plant'(006) ' ' ' ' ' ' ' ',     '01' '05' 'NTGEW' 'I_EKPO' 'R'
         'Net Weight'(007) ' ' ' ' 'GEWE' 'I_EKPO'.ENDFORM.                    " sub_field_catalog&----
    *&     Form  sub_fill_alv_field_catalog
    *&     For building Field Catalog
    *&     p_rowpos   Row position
    *&     p_colpos   Col position
    *&     p_fldnam   Fldname
    *&     p_tabnam   Tabname
    *&     p_justif   Justification
    *&     p_seltext  Seltext
    *&     p_out      no out
    *&     p_tech     Technical field
    *&     p_qfield   Quantity field
    *&     p_qtab     Quantity table
    FORM sub_fill_alv_field_catalog  USING  p_rowpos    TYPE sycurow
                                            p_colpos    TYPE sycucol
                                            p_fldnam    TYPE fieldname
                                            p_tabnam    TYPE tabname
                                            p_justif    TYPE char1
                                            p_seltext   TYPE dd03p-scrtext_l
                                            p_out       TYPE char1
                                            p_tech      TYPE char1
                                            p_qfield    TYPE slis_fieldname
                                            p_qtab      TYPE slis_tabname.* Local declaration for field catalog
      DATA: wa_lfl_fcat    TYPE  slis_fieldcat_alv.  wa_lfl_fcat-row_pos        =  p_rowpos.     "Row
      wa_lfl_fcat-col_pos        =  p_colpos.     "Column
      wa_lfl_fcat-fieldname      =  p_fldnam.     "Field Name
      wa_lfl_fcat-tabname        =  p_tabnam.     "Internal Table Name
      wa_lfl_fcat-just           =  p_justif.     "Screen Justified
      wa_lfl_fcat-seltext_l      =  p_seltext.    "Field Text
      wa_lfl_fcat-no_out         =  p_out.        "No output
      wa_lfl_fcat-tech           =  p_tech.       "Technical field
      wa_lfl_fcat-qfieldname     =  p_qfield.     "Quantity unit
      wa_lfl_fcat-qtabname       =  p_qtab .      "Quantity table  IF p_fldnam = 'NTGEW'.
        wa_lfl_fcat-do_sum  = 'X'.
      ENDIF.
      APPEND wa_lfl_fcat TO i_fieldcat.
      CLEAR wa_lfl_fcat.
    ENDFORM.                    " sub_fill_alv_field_catalog&----
    *&      Form  sub_populate_layout
          Populate ALV layout
          No Parameter
    FORM sub_populate_layout .  CLEAR wa_layout.
      wa_layout-colwidth_optimize = 'X'." Optimization of Col widthENDFORM.                    " sub_populate_layout&----
    *&      Form  sub_populate_sort
          Populate ALV sort table
          No Parameter
    FORM sub_populate_sort .* Sort on material
      wa_sort-spos = '01' .
      wa_sort-fieldname = 'MATNR'.
      wa_sort-tabname = 'I_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO i_sort .
      CLEAR wa_sort.* Sort on plant
      wa_sort-spos = '02'.
      wa_sort-fieldname = 'WERKS'.
      wa_sort-tabname = 'I_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO i_sort .
      CLEAR wa_sort.
    ENDFORM.                    " sub_populate_sort&----
    *&      Form  sub_get_event
          Get ALV grid event and pass the form name to subtotal_text
          event
          No Parameter
    FORM sub_get_event .
      CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE
    'SUBTOTAL_TEXT'.  DATA: l_s_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 4
        IMPORTING
          et_events       = i_event
        EXCEPTIONS
          list_type_wrong = 0
          OTHERS          = 0.* Subtotal
      READ TABLE i_event  INTO l_s_event
                        WITH KEY name = slis_ev_subtotal_text.
      IF sy-subrc = 0.
        MOVE c_formname_subtotal_text TO l_s_event-form.
        MODIFY i_event FROM l_s_event INDEX sy-tabix.
      ENDIF.ENDFORM.                    " sub_get_event&----
    *&      Form  sub_alv_report_display
          For ALV Report Display
          No Parameter
    FORM sub_alv_report_display .
      DATA: l_repid TYPE syrepid .
      l_repid = sy-repid .* This function module for displaying the ALV report
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = l_repid
          i_callback_top_of_page   = 'SUB_ALV_TOP_OF_PAGE'
          is_layout                = wa_layout
          it_fieldcat              = i_fieldcat
          it_sort = i_sort
          it_events                = i_event
          i_default                = 'X'
          i_save                   = 'A'
        TABLES
          t_outtab                 = i_ekpo
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
       MESSAGE i000 WITH 'Error in ALV report display'(055).
      ENDIF.ENDFORM.                    " sub_alv_report_display&----
          FORM sub_alv_top_of_page
          Call ALV top of page
          No parameter
    ----FORM sub_alv_top_of_page.                                   "#EC CALLED* To write header for the ALV
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = i_alv_top_of_page.
    ENDFORM.                    "alv_top_of_page&----
    *&      Form  subtotal_text
          Build subtotal text
          P_total  Total
          p_subtot_text Subtotal text info
    FORM subtotal_text CHANGING
                   p_total TYPE any
                   p_subtot_text TYPE slis_subtot_text.
    Material level sub total
      IF p_subtot_text-criteria = 'MATNR'.
        p_subtot_text-display_text_for_subtotal
        = 'Material level total'(009).
      ENDIF.* Plant level sub total
      IF p_subtot_text-criteria = 'WERKS'.
        p_subtot_text-display_text_for_subtotal = 'Plant level total'(010).
      ENDIF.
    ENDFORM.                    "subtotal_text
    Hopes its helpful.
    Regards,
    Raj.

  • Average function in ALV Report

    Hi ,
    I am doing Subtotal in ALV by Grouping the Fields. Instead of Using Subtotal i want to Use Average of
    (Total / Quantity) in AlV. Is there any function availabile for doing Average in ALV Reports.
    Point will be definately awarded .\
    Kamal

    >  I am doing Subtotal in ALV by Grouping the Fields. Instead of Using Subtotal i want to Use Average of
    > (Total / Quantity) in AlV. Is there any function availabile for doing Average in ALV Reports.
    >
    It is possible to show the Average using the FIELDCATALOG-DO_SUM = 'C'. for the column/field which you want the Average.
    FIELDCATALOG-DO_SUM = 'C'. "<-----Avergage
    Read the Rules , Don't use Forbidden words...

  • How to add the dril down functionality in alv report.

    Hi All,
    I have a ALV report and now i want to add drill down functionality in this ALV report.
    See my code below:
    FORM f0002_build_field_catalog.
    Build the field catalog
    CLEAR ws_layout.
    ws_layout-colwidth_optimize = 'X'.
    ws_layout-edit = ' '.
      ws_field_catalog-col_pos = '1'.
      ws_field_catalog-fieldname = 'BUKRS'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l = 'Company Code'.
      ws_field_catalog-seltext_m = 'CCode'.
      ws_field_catalog-seltext_s = 'CCode'.
    ws_field_catalog-fix_column = 'X'.
    ws_field_catalog = 'X'.
    ws_fieldcat-ref_tabname  = 'VBKPF'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '2'.
      ws_field_catalog-fieldname = 'BELNR'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Document no.'.
      ws_field_catalog-hotspot = 'V'.
      ws_field_catalog-seltext_m    = 'Doc.no.'.
      ws_field_catalog-seltext_s    = 'Doc.no.'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '3'.
      ws_field_catalog-fieldname = 'GJAHR'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Year'.
      ws_field_catalog-seltext_m    = 'Year'.
      ws_field_catalog-seltext_s    = 'Year'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '4'.
      ws_field_catalog-fieldname = 'BSTAT'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Status'.
      ws_field_catalog-seltext_m    = 'Status'.
      ws_field_catalog-seltext_s    = 'Status'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '5'.
      ws_field_catalog-fieldname = 'FLAG'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Open/Cleared'.
      ws_field_catalog-seltext_m    = 'Open/Cleared'.
      ws_field_catalog-seltext_s    = 'Open/Cleared'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '6'.
      ws_field_catalog-fieldname = 'BLART'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Doc.Type.'.
      ws_field_catalog-seltext_m    = 'Doc.Type'.
      ws_field_catalog-seltext_s    = 'Doc.Type'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '7'.
      ws_field_catalog-fieldname = 'WRBTR'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Total Amount'.
      ws_field_catalog-seltext_m    = 'Total Amount'.
      ws_field_catalog-seltext_s    = 'Total Amount'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '8'.
      ws_field_catalog-fieldname = 'WAERS'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Currency.'.
      ws_field_catalog-seltext_m    = 'Currency'.
      ws_field_catalog-seltext_s    = 'Currency'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '9'.
      ws_field_catalog-fieldname = 'LIFNR'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Vendor'.
      ws_field_catalog-seltext_m    = 'Vendor'.
      ws_field_catalog-seltext_s    = 'Vendor'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '10'.
      ws_field_catalog-fieldname = 'NAME1'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Vendor Name'.
      ws_field_catalog-seltext_m    = 'Name 1'.
      ws_field_catalog-seltext_s    = 'Name 1'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '11'.
      ws_field_catalog-fieldname = 'UZAWE'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Payment Method Supplement'.
      ws_field_catalog-seltext_m    = 'PmtMthSuppl'.
      ws_field_catalog-seltext_s    = 'PmtMthSuppl'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '12'.
      ws_field_catalog-fieldname = 'XBLNR'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Reference'.
      ws_field_catalog-seltext_m    = 'Ref. No.'.
      ws_field_catalog-seltext_s    = 'Ref. No.'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
    g_variant-report  = sy-repid.
       CLEAR struct_extab.
      MOVE '&XPA' TO struct_extab-fcode.
      APPEND struct_extab TO i_extab.
      MOVE '&OMP' TO struct_extab-fcode.
      APPEND struct_extab TO i_extab.
    Display the list
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
          i_callback_program      = ws_repid
          i_callback_user_command = 'HANDLE_USER_COMMAND'
         is_layout               = ws_layout
          it_fieldcat             = lt_fieldcat[]
          it_excluding            = i_extab[]
         i_default                = 'X'
         i_save                  =  'U'  "For user variants
         is_variant              = g_variant
        TABLES
          t_outtab                = i_output.
    ENDFORM.                    "f0002_build_field_catalog
    *&      Form  f0038_pf_status
          text
         -->I_EXTAB    text
    FORM f0038_pf_status USING i_extab TYPE slis_t_extab.       "#EC CALLED
      CLEAR struct_extab.
      MOVE '&XPA' TO struct_extab-fcode.
      APPEND struct_extab TO i_extab.
      MOVE '&OMP' TO struct_extab-fcode.
      APPEND struct_extab TO i_extab.
      SET PF-STATUS 'Z_PFSTATUS2' EXCLUDING i_extab.
    ENDFORM.                     "f0038_pf_status
    Pls tell me how i use this below dril down ability functionality in my code.
    See the requirement below.
    The Document Number, aka Accounting Document Number (BELNR) of each row will take the user to the appropriate document to edit as follows:
    For Parked documents:-
    If VBKPF-AWTYP (Reference Procedure) = “RMRP”, then the drilldown functionality should be to MIR4 using the Object ID in VBKPF- AWKEY. In this scenario the Object ID represents a Invoice Document Number, not an Accounting Document Number. Not the Object ID is a combination of Invoice Document Number and Fiscal Year
    If VBKPF-AWTYP = Any other value, then the drilldown functionality should be to FBV2 using the Object ID in VBKPF-AWKEY. In this scenario the Object ID represents a true Accounting Document Number. Note the Object ID is a combination of Company Code (VBKPF-BUKRS), Accounting Document Number (VBKPF-BELNR) and Fiscal Year (VBKPF-GJAHR)
    For Posted, not Cleared documents:-
    Drilldown ability should be to FB02. The combination of Company Code (BSIK-BUKRS), Accounting Document Number (BSIK-BELNR) and Fiscal Year (BSIK-GJAHR) will be used to open/drilldown to the correct document in FB02.
    For Cleared documents:-
    Drilldown ability should be to FB03. The combination of Company Code (BSIK-BUKRS), Accounting Document Number (BSIK-BELNR) and Fiscal Year (BSIK-GJAHR) will be used to open/drilldown to the correct document in FB03.
    Its very urgent, pls help on this.
    Thanks!
    Vipin

    Pls refer :
    https://wiki.sdn.sap.com/wiki/display/Snippets/ABAPInteractiveALVwithCallTransaction%28usingParameterID%29
    https://wiki.sdn.sap.com/wiki/display/Snippets/ABAPInteractiveALV+Program
    Regards,
    Anish Thomas
    Pls reward all useful answers

  • Set select one of the cell in subtotal row in ALV report

    Dear all,
    I have a ALV report that has subtotal amount by Vendor ID.
    I want to set the selection at vendor ID column (same row with subtotal).
    I tried both set_selected_cell() and set_current_cell() methods, the cell selected is incorrect. It doesnt seem to be able to select any cell at the same row of SUBTOTAL.
    lr_selections = ref_table->get_selections( ).
          lt_current_cell = lr_selections->get_current_cell( ).
          lt_current_cell-row = lt_current_cell-row.
          lt_current_cell-columnname = 'LIFNR'.
          lr_selections->set_current_cell( lt_current_cell ).
    Please help. Thanks.

    HP should provide tested recovery DVD every note book user. along with note book.
    That is solution
    fws1 wrote:
    I neglected to add that the system is configured exactly as from the factory, save a few added programs and user files. No hardware changes or OS up or downgrade. The hard drive was corrupted by some type of root virus and had to be fully reformatted. I did the format manually as well as let the HP Recovery disks. Same result either way. The recovery program, after the failure,  prompts user to insert a flash drive and creates some file, but HP has no info on the file creation or what to do with said file!  
    fws1 wrote:
    I neglected to add that the system is configured exactly as from the factory, save a few added programs and user files. No hardware changes or OS up or downgrade. The hard drive was corrupted by some type of root virus and had to be fully reformatted. I did the format manually as well as let the HP Recovery disks. Same result either way. The recovery program, after the failure,  prompts user to insert a flash drive and creates some file, but HP has no info on the file creation or what to do with said file!  

  • Handle back functionality in ALV report

    Hi,
    I have created the alv report which has 2 button on the report display, if you select any of them it will display other 2 reports.
    here i am facing problem in handling the BACK functionality.
    i.e after the navigations between the 2nd and 3rd reports, at which ever screen, if i press BACK then it has to come to 1st report.
    kindly guide.

    what have you used for the BACK button
    when 'BACK'.
      SET SCREEN 0.

  • Problem in performing subtotaling in ABAP ALV Report for GL Account ID

    Hi,
    I had developed a report in which i am displayng data on the basis of GL Account in a ALV Report. I want to display the sub-totaling on the different series of GL Account (i..e. 100000,400000 etc..) but at present this fucntionality is not possible right now. Is there method of doing it?

    Hi,
    Thanks ,i had solved the problem by taking a variable type string and the assigning the GL A/C ID in it and it is showing the data accuarately as per requierment..
    Thanks everybody for valueable response.
    Problem Solved.

  • Short dump while doing subtotal in the ALV report

    Hi All,
    I am getting run time error while doing the sub total and total in the ALV .
    error is "MESSAGE_TYPE_X" and
    discription is  "The current application program detected a situation which really
    should not occur. Therefore, a termination with a short dump was
    triggered on purpose by the key word MESSAGE (type X)."
    Can anyone help me regarding this.
    My alv field catog is like below
      DATA: ls_fieldcat TYPE slis_fieldcat_alv,
            ls_sort     TYPE SLIS_SORTINFO_ALV.
      CLEAR:ls_fieldcat,
            ls_sort.
      REFRESH ot_fieldcat.
      ls_fieldcat-FIELDNAME   = 'LEASE_NUMBER'.
      ls_fieldcat-SELTEXT_M   = 'Lease Number'(001).
      ls_fieldcat-COL_POS     = 0.
      ls_fieldcat-OUTPUTLEN   = 10.
      ls_fieldcat-DO_SUM      = 'X'.
      ls_fieldcat-KEY         = 'X'.
      APPEND ls_fieldcat TO ot_fieldcat.
      CLEAR  ls_fieldcat.
      ls_fieldcat-FIELDNAME   = 'LEASE_TYPE'.
      ls_fieldcat-SELTEXT_M   = 'Lease Type'(002).
      ls_fieldcat-COL_POS     = 1.
      ls_fieldcat-OUTPUTLEN   = 5.
      APPEND ls_fieldcat TO ot_fieldcat.
      CLEAR  ls_fieldcat.
      ls_fieldcat-FIELDNAME   = 'LEGACY_NUM'.
      ls_fieldcat-SELTEXT_M   = 'Legacy Contract No'(003).
      ls_fieldcat-COL_POS     = 2.
      ls_fieldcat-OUTPUTLEN   = 10.
      APPEND ls_fieldcat TO ot_fieldcat.
      CLEAR  ls_fieldcat.
      ls_fieldcat-FIELDNAME   = 'CUSTOMER'.
      ls_fieldcat-SELTEXT_M   = 'Customer'(004).
      ls_fieldcat-COL_POS     = 3.
      APPEND ls_fieldcat TO ot_fieldcat.
      CLEAR  ls_fieldcat.
      ls_fieldcat-FIELDNAME   = 'STATUS'.
      ls_fieldcat-SELTEXT_M   = 'Status'(017).
      ls_fieldcat-COL_POS     = 16.
      ls_fieldcat-OUTPUTLEN   = 10.
      APPEND ls_fieldcat TO ot_fieldcat.
      CLEAR  ls_fieldcat.
      ls_fieldcat-FIELDNAME   = 'GATEIN_DT'.
      ls_fieldcat-SELTEXT_M   = 'Gate In Date'(018).
      ls_fieldcat-COL_POS     = 17.
      ls_fieldcat-OUTPUTLEN   = 10.
      APPEND ls_fieldcat TO ot_fieldcat.
      CLEAR  ls_fieldcat.
      ls_fieldcat-FIELDNAME   = 'SVALUE'.
      ls_fieldcat-COL_POS     = 18.
      ls_fieldcat-DO_SUM      = 'X'.
      ls_fieldcat-OUTPUTLEN   = 12.
      APPEND ls_fieldcat TO ot_fieldcat.
      CLEAR  ls_fieldcat.
    DATA SORTING AND SUBTOTAL
      CLEAR ls_sort.
      ls_sort-FIELDNAME = 'LEASE_NUMBER'.
      ls_sort-SPOS      = 0.
      ls_sort-UP        = 'X'.
      ls_sort-SUBTOT    = 'X'.
      APPEND ls_sort TO GT_SORT.
    If i coment the code relate dto 'SVALUE' i am getting output without sub total and total.
    if i uncomment the same then I am getting short dump.

    Hi,
    Try this coding,
    TYPE-POOLS: SLIS.                      " ALV GLOBAL TYPES
    *      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
    Regards,
    Nikhil.

  • Field should not display in the subtotal row in ALV report after sorting .

    we have a requirement, after sorting and subtotaling, the output in ALV is -
    vbeln        amount1  amount2  amount3
    123           11              12            13
    123           12             13             14
    123           23             25             27 
    133           11              12            13
    133           12             13             14
    133           23             25             27
    Now the customer wants the ALV outpput in this fashion -
    123           11              12            13
    123           12             13             14
                     23             25             27    --->123 (vbeln) should not come in subtotaling row
    133           11              12            13
    133           12             13             14
                      23             25             27--->133(vbeln) should not come in subtotaling row

    Hi,
    if it helps you could create a hierachy. In this way you can define the field catalog for the lines and for the subtotal columns. The only thing is that you would always show the subtotal rows.
    You have references of hierachy alvs in
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c060fcb4-2c62-2b10-d2b2-f32407a5cc6f
    ALV Hierarchy
    alv hierarchy
    In this case it also sorts
    Sorting for ALV hierarchy
    I hope it helps.
    Edited by: Oscar Pecharroman on Aug 2, 2010 1:13 PM

  • Drill Down functionality in ALV Report

    Hi Experts,
    Gud Afternoon..!!!
    My Requirement: I have to display a report in ALV and if user click on vbeln the screen should go to transaction code VA43 for that particular contract.
    I used the below code,
    FORM user_command  USING r_ucomm LIKE sy-ucomm
                            rs_selfield TYPE slis_selfield.
    data:  w_vbeln type vbak-vbeln.
      IF r_ucomm EQ '&IC1' .   " Click value of hot spot
        CASE rs_selfield-fieldname.
          WHEN 'VBELN'.
            w_vbeln =  rs_selfield-value.
            SET PARAMETER ID 'AUN' FIELD w_vbeln.
            CALL TRANSACTION 'VA43' AND SKIP FIRST SCREEN.
        ENDCASE.
      ELSEIF r_ucomm EQ 'CANC'
            OR r_ucomm EQ 'BACK'
            OR r_ucomm EQ 'EXIT'.
        LEAVE PROGRAM.
      ENDIF.
    ENDFORM.                    " user_command
    I am getting error message in VA43 initial screen as "Enter the doc. no"
    Plz help me in this. Thanks in Advance..!!!
    Regards,
    Vadhu...

    Hi,
    Thanks Aakash Banga, Rimpa Abhishek..!!!
    I got the solution with help of SDN. The Solution as follows,
    FORM user_command  USING r_ucomm LIKE sy-ucomm
                            rs_selfield TYPE slis_selfield.
      DATA:  w_vbeln TYPE vbak-vbeln.
      IF r_ucomm EQ '&IC1' .   " Click value of hot spot
        CASE rs_selfield-fieldname.
          WHEN 'VBELN'.
            w_vbeln =  rs_selfield-value.
            REFRESH t_bdcdata.
            CLEAR t_bdcdata.
            t_bdcdata-program  = 'SAPMV45A'.
            t_bdcdata-dynpro   = '102'.
            t_bdcdata-dynbegin = 'X'.
            APPEND t_bdcdata TO t_bdcdata.
            CLEAR t_bdcdata.
            t_bdcdata-fnam = 'BDC_CURSOR'.
            t_bdcdata-fval = 'VBAK-VBELN'.
            APPEND t_bdcdata TO t_bdcdata.
            CLEAR t_bdcdata.
            t_bdcdata-fnam = 'BDC_OKCODE'.
            t_bdcdata-fval = '=SUCH'.
            APPEND t_bdcdata TO t_bdcdata.
            CLEAR t_bdcdata.
            t_bdcdata-fnam = 'VBAK-VBELN'.
            t_bdcdata-fval = w_vbeln.
            APPEND t_bdcdata TO t_bdcdata.
            CLEAR t_bdcdata.
            t_bdcdata-program  = 'SAPMV45A'.
            t_bdcdata-dynpro   = '4001'.
            t_bdcdata-dynbegin = 'X'.
            APPEND t_bdcdata TO t_bdcdata.
            CALL TRANSACTION 'VA43' USING t_bdcdata MODE 'P' .
            CALL TRANSACTION 'VA43' AND SKIP FIRST SCREEN.
        ENDCASE.
      ELSEIF r_ucomm EQ 'CANC'
            OR r_ucomm EQ 'BACK'
            OR r_ucomm EQ 'EXIT'.
        LEAVE PROGRAM.
      ENDIF.
    ENDFORM.                    " user_command
    Thanks & Regards,
    Vadhu Duraisami

  • Enhancing print functionality for ALV report

    Our client requires a special Print at click button in few reports and screens in such a way that there is no effort in setting page sizes etc. 
    For one particular report, there are many columns.  When I try to use List -> Print, only first few columns are printed.  I want that all the columns are printed in landscape manner in different pages and the first column is repeated in both pages (it is frozen in report). 
    How to make these happen?

    HI,
    You can try following steps,
    1) Goto transaction SPAD and create Page formate according to your requirement.
    2) Create format and copy action from standard format.
    3) create device type
    4) assign that device type to custamize output type.
    When ever you take print out of that ALV use your custamize Output Type

  • How to display subtotal text in alv report for particular group of values

    Hi,
    if material number falls 1 to 10 then i considered be calculate and display subtotal qty amount with subtotal text " Total of the mat1" and if material number falls 11 to 20 then again i need to be claculate and display subtotal qty amount with subtotal text "total of the mat2". if material number falls 21 to 30 then i don't want to display any subtotal and At last grand total also is not required.
    Please help me asap

    just check the thread...
    Can we modify a sub-total in ALV

  • Subtotal in Dynamic ALV

    Hi,
    Please tell how to perform Subtotal in dynamic ALV Report.
    Normal Subtotal functionality(the one which is used for static ALV report ) is not working for that.
    Thanks.

    Hi,
    Please tell how to perform Subtotal in dynamic ALV Report.
    Normal Subtotal functionality(the one which is used for static ALV report ) is not working for that.
    Thanks.

  • Subtracting in ALV report

    i have a FI report where i am showing Assets and liabilities value in ALV format, i m using ALV grid layout. there i can easily add those values, but my problem is i have to subtract liabilities value from Assets value, but in ALV i do not find any option to Subtract values between those criteria. so my question is: Is there any option or function in ALV report where we can Subtract, multiply, division between the values in the table?

    hiiiiiiiiiiiiiii
    try to do this
    multiply any one of field by -1
    for ex: 
    loop at itab.
          multiply  itab_field  by -1.
        endloop
    and then add in alv report may this subtracted
    or
    initialize substraction field in itab
    do substracion of these tow fields append the result to itab and display it
    if u want substraction at last
    write in loop
    at last of itab
    do substraction
    i think ,
    may this solve ur problenm

  • ALV Report Toolbar

    Hey All,
    in my ALV report I am not able to see standard toolbar. I have copied the same using SE80 and when I check my program in SE80 it shows the Standard Toolbar to be there. Can someone help me how to add the same.
    Also I am using standard function based ALV report and in that I need to add additional button once my report is visible. I know this question may have been asked upteen time. But I am not able to resolve the above two problems so if someone can help me it will be great help.
    Siddhartha

    Hi All,
    My first problem of toolbar not visible has been solved. Now In the toolbar copied in my code I added a button and labeled it as inactive" I would like to call a function on click of it which will do the further processing. The code snippets which I have used are as follows:
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM       = LW_REPID
         I_CALLBACK_PF_STATUS_SET = G_STATUS
          I_CALLBACK_html_top_of_page = L_C_html_top
          I_CALLBACK_USER_COMMAND  = G_USER_COMMAND
         IT_EVENTS                = I_EVENTS[]
          IT_FIELDCAT              = I_FLD_CAT
          IS_LAYOUT                = PRT_LAYOUT
          IT_SORT                  = IT_SORT
        TABLES
          T_OUTTAB                 = T_OUTPUT[].
    Now the button which I have created in my standard toolbar is not visible in the report. So can someone tell me what I am missing.
    Also while creating button what are the required things to be provided and how this button will be linked so that on click of it a required Form will be called.
    Thanks once again to Max_Bianchi and Sum_it2.
    Siddhartha

Maybe you are looking for

  • How can I prevent Firefox from cutting off the title of a webpage for use as a file name when printing/saving as PDF if there's a / in it?

    Like it says in the question - when I try to print/save a webpage as a PDF, Firefox (version 36.0, Windows 8.1 64bit, German) usually uses the page's title as the file name. Slashes are, of course, not allowed in file names, but instead of just leavi

  • ADF 11g - How to do save-cascade?

    Hello, Suppose that I have entities PurchaseOrder (1) <-> (*) PurchaseItem, how do I create PurchaseOrder and related PurchaseItem in one transaction? (much like cascade=PERSIST in JPA). Any examples? Thanks before. Rgds, Rudi

  • Very urgent! Basic informations

    Hello! My question are very easy : I just need some definitions for a report! What does the TBS_SYSTEM, the TBS_RBS, the TBS_TEMP? Some easy definitions would be great! What is an instance (with easy sentences...)? Thank you very much for your help!

  • Quality of pdfs and colour separations for printing purposes

    Having created a 44 page document in Pages, I have exported it as a pdf file so that it can be commercially printed as an A5 magazine. I have used the 'best' option in exporting it as a pdf, but have no idea if that function conforms to PDF-X1A speci

  • Finder/Leopard Freezing overnight.

    This happens most often in the morning when I leave the machine on overnight to use some non peek bandwith. When I go to check the computer in the morning it shows the time as being some point in the middle of the night. I try and start an applicatio