Subtotals and Totals In ALV Report

Hi Experts,
I have a problem in my current scenario,
I have 3 fields,
KUNNR, WAERS, DMBTR.
000001 USD         100.00
000001 USD         200.00
000002 USD         100.00
000002 USD         400.00
000002 EUR         300.00
000002 EUR         100.00
The above mentioned is the data I have in my internal table & in my ALV report as well, Which is fine...!
Now I need Subtotals for each customer,
Means for customer 000001 The subtotal is 300 (USD)
Means for customer 000002 The subtotal is 500 (USD)
Means for customer 000002 The subtotal is 400 (EUR)
At the end I need grand totals.
USD 800
EUR 400.
Currently My field catalog is given below.
    FIELDCATALOG-COL_POS     = COL_POS.
    FIELDCATALOG-FIELDNAME   = 'DMBTR'.
    FIELDCATALOG-SELTEXT_M   = TEXT-106.
    FIELDCATALOG-DO_SUM      = 'X'.
    APPEND FIELDCATALOG TO FIELDCATALOG.
    CLEAR  FIELDCATALOG.
what else I need to do for getting individual subtotals by currency and customers.
Thanks & regards,
Dileep .C

Hi Deelip,
FOR TOTAL:
there is a property of fieldcatalog, that is do_sum.
USE COED LIKE:
PERFORM fieldcat USING:
'1' 'KUNNR' 'I_MARD' 'CUSTOMER NO' ,
'2' 'DMBTR' 'I_MARD' 'CURRENCY' ,
FORM fieldcat USING value(p_0029)
value(p_0030)
value(p_0031)
value(p_0032)
wa_fieldcat-col_pos = p_0029.
wa_fieldcat-fieldname = p_0030.
wa_fieldcat-tabname = p_0031.
wa_fieldcat-reptext = p_0032.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO i_fieldcat.
ENDFORM. " FIELDCAT
in final output you will get the total of currency field.
FOR SUB TOTAL:
decleare: i_sort type standard table of slis_sortinfo_alv,
          wa_sort type slis_t_sortinfo_alv.
wa_sort-spos = '1'.
wa_sort-fieldname = 'KUNNR'.
wa_sort-tablename = 'i_final'
wa_sort-up = 'x'
wa_sort-subtot = 'X'.
wa_sort-spos = '2'.
wa_sort-fieldname = 'WAERS'.
wa_sort-tablename = 'i_final'
wa_sort-up = 'x'
wa_sort-subtot = 'X'.
append wa_tab to i_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fieldcat
it_sort = i_sort
Hope this can solve your pbs.
Regards,
Tutun

Similar Messages

  • Do not include some lines in Subtotals and totals in ALV

    Hello All,
    I am printing a report with all sale order details and Quantities( delveered ,conformed etc..) iam doing subtotals based on the material and Plant.
    In this if the document date is less than the SY-DATUM, we should not include the quantity into the subtotals and totals, Only the orders wiht doc date GQ to Sy-datum then display them..
    As of now I am using ALV grid display and doing the sums by 
    l_wa_fcat-do_sum = c_x. (field catalog) for the whole colom) but i want to avoid sum row from tehe calculation based on the condition.
    <b>Do we have any way to achive this, like if we want to have separate color for a purticular Cell then we add an extra field in outout table and we link this field with layout-coltab_fieldname in the same way or any other way if we have</b>.
    I will be  thankfull to if you can provide me your valuable suggesstions on this. it is very urgent. I am trying in all the ways from my side.

    Hi,
    see this code,
    Complete code for the ALV grid example
    This example shows and ALV grid with flights. After selecting a line a change button can be pushed to display a change screen. After the changes have been saved, the ALV grid screen is displayed again, and the grid is updated with the changes.
    The example shows:
    How to setup the ALV grid
    How to ste focus to the grid
    How to set the title of the grid
    How to allow a user to save and reuse a grid layout (Variant)
    How to customize the ALV grid toolbar
    Refresh the grid
    Set and get row selection and read line contents
    Make and exception field (Traffic light)
    Coloring a line
    Steps:
    Create screen 100 with the ALV grid. Remember to include an exit button
    Add a change button to the ALV grid toolbar
    Create screen 200 the Change screen
    The screens:
    The code:
       REPORT sapmz_hf_alv_grid .
    Type pool for icons - used in the toolbar
       TYPE-POOLS: icon.
       TABLES: zsflight.
    To allow the declaration of o_event_receiver before the
    lcl_event_receiver class is defined, decale it as deferred in the
    start of the program
       CLASS lcl_event_receiver DEFINITION DEFERRED.
    G L O B A L   I N T E R N  A L   T A B L E S
       *DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
    To include a traffic light and/or color a line the structure of the
    table must include fields for the traffic light and/or the color
       TYPES: BEGIN OF st_sflight.
               INCLUDE STRUCTURE zsflight.
          Field for traffic light
       TYPES:  traffic_light TYPE c.
          Field for line color
       types:  line_color(4) type c.
       TYPES: END OF st_sflight.
       TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
       DATA: gi_sflight TYPE tt_sflight.
    G L O B A L   D A T A
       DATA: ok_code         LIKE sy-ucomm,
        Work area for internal table
             g_wa_sflight    TYPE st_sflight,
        ALV control: Layout structure
             gs_layout       TYPE lvc_s_layo.
    Declare reference variables to the ALV grid and the container
       DATA:
         go_grid             TYPE REF TO cl_gui_alv_grid,
         go_custom_container TYPE REF TO cl_gui_custom_container,
         o_event_receiver    TYPE REF TO lcl_event_receiver.
       DATA:
    Work area for screen 200
         g_screen200 LIKE zsflight.
    Data for storing information about selected rows in the grid
       DATA:
    Internal table
         gi_index_rows TYPE lvc_t_row,
    Information about 1 row
         g_selected_row LIKE lvc_s_row.
    C L A S S E S
       CLASS lcl_event_receiver DEFINITION.
         PUBLIC SECTION.
           METHODS:
            handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
              IMPORTING
                e_object e_interactive,
            handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
              IMPORTING e_ucomm.
       ENDCLASS.
          CLASS lcl_event_receiver IMPLEMENTATION
       CLASS lcl_event_receiver IMPLEMENTATION.
         METHOD handle_toolbar.
    Event handler method for event toolbar.
           CONSTANTS:
    Constants for button type
             c_button_normal           TYPE i VALUE 0,
             c_menu_and_default_button TYPE i VALUE 1,
             c_menu                    TYPE i VALUE 2,
             c_separator               TYPE i VALUE 3,
             c_radio_button            TYPE i VALUE 4,
             c_checkbox                TYPE i VALUE 5,
             c_menu_entry              TYPE i VALUE 6.
           DATA:
               ls_toolbar  TYPE stb_button.
      Append seperator to the normal toolbar
           CLEAR ls_toolbar.
           MOVE c_separator TO ls_toolbar-butn_type..
           APPEND ls_toolbar TO e_object->mt_toolbar.
      Append a new button that to the toolbar. Use E_OBJECT of
      event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.
      This class has one attribute MT_TOOLBAR which is of table type
      TTB_BUTTON. The structure is STB_BUTTON
           CLEAR ls_toolbar.
           MOVE 'CHANGE'        TO ls_toolbar-function.
           MOVE  icon_change    TO ls_toolbar-icon.
           MOVE 'Change flight' TO ls_toolbar-quickinfo.
           MOVE 'Change'        TO ls_toolbar-text.
           MOVE ' '             TO ls_toolbar-disabled.
           APPEND ls_toolbar    TO e_object->mt_toolbar.
         ENDMETHOD.
         METHOD handle_user_command.
      Handle own functions defined in the toolbar
           CASE e_ucomm.
             WHEN 'CHANGE'.
               PERFORM change_flight.
           LEAVE TO SCREEN 0.
           ENDCASE.
         ENDMETHOD.
       ENDCLASS.
    S T A R T - O F - S E L E C T I O N.
       START-OF-SELECTION.
         SET SCREEN '100'.
       *&      Module  USER_COMMAND_0100  INPUT
       MODULE user_command_0100 INPUT.
         CASE ok_code.
           WHEN 'EXIT'.
             LEAVE TO SCREEN 0.
         ENDCASE.
       ENDMODULE.                 " USER_COMMAND_0100  INPUT
       *&      Module  STATUS_0100  OUTPUT
       MODULE status_0100 OUTPUT.
         DATA:
      For parameter IS_VARIANT that is sued to set up options for storing
      the grid layout as a variant in method set_table_for_first_display
           l_layout TYPE disvariant,
      Utillity field
           l_lines TYPE i.
    After returning from screen 200 the line that was selected before
    going to screen 200, should be selected again. The table gi_index_rows
    was the output table from the GET_SELECTED_ROWS method in form
    CHANGE_FLIGHT
         DESCRIBE TABLE gi_index_rows LINES l_lines.
         IF l_lines > 0.
           CALL METHOD go_grid->set_selected_rows
               EXPORTING
                 it_index_rows = gi_index_rows.
           CALL METHOD cl_gui_cfw=>flush.
           REFRESH gi_index_rows.
         ENDIF.
    Read data and create objects
         IF go_custom_container IS INITIAL.
      Read data from datbase table
           PERFORM get_data.
      Create objects for container and ALV grid
           CREATE OBJECT go_custom_container
             EXPORTING container_name = 'ALV_CONTAINER'.
           CREATE OBJECT go_grid
             EXPORTING
               i_parent = go_custom_container.
      Create object for event_receiver class
      and set handlers
           CREATE OBJECT o_event_receiver.
           SET HANDLER o_event_receiver->handle_user_command FOR go_grid.
           SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.
      Layout (Variant) for ALV grid
           l_layout-report = sy-repid. "Layout fo report
    Setup the grid layout using a variable of structure lvc_s_layo
      Set grid title
           gs_layout-grid_title = 'Flights'.
      Selection mode - Single row without buttons
      (This is the default  mode
           gs_layout-sel_mode = 'B'.
      Name of the exception field (Traffic light field) and the color
      field + set the exception and color field of the table
           gs_layout-excp_fname = 'TRAFFIC_LIGHT'.
           gs_layout-info_fname = 'LINE_COLOR'.
           LOOP AT gi_sflight INTO g_wa_sflight.
             IF g_wa_sflight-paymentsum < 100000.
          Value of traffic light field
               g_wa_sflight-traffic_light = '1'.
          Value of color field:
          C = Color, 6=Color 1=Intesified on, 0: Inverse display off
               g_wa_sflight-line_color    = 'C610'.
             ELSEIF g_wa_sflight-paymentsum => 100000 AND
                    g_wa_sflight-paymentsum < 1000000.
               g_wa_sflight-traffic_light = '2'.
             ELSE.
               g_wa_sflight-traffic_light = '3'.
             ENDIF.
             MODIFY gi_sflight FROM g_wa_sflight.
           ENDLOOP.
      Grid setup for first display
           CALL METHOD go_grid->set_table_for_first_display
             EXPORTING i_structure_name = 'SFLIGHT'
                       is_variant       = l_layout
                       i_save           = 'A'
                       is_layout        = gs_layout
             CHANGING  it_outtab        = gi_sflight.
       *-- End of grid setup -
      Raise event toolbar to show the modified toolbar
           CALL METHOD go_grid->set_toolbar_interactive.
      Set focus to the grid. This is not necessary in this
      example as there is only one control on the screen
           CALL METHOD cl_gui_control=>set_focus EXPORTING control = go_grid.
         ENDIF.
       ENDMODULE.                 " STATUS_0100  OUTPUT
       *&      Module  USER_COMMAND_0200  INPUT
       MODULE user_command_0200 INPUT.
         CASE ok_code.
           WHEN 'EXIT200'.
             LEAVE TO SCREEN 100.
             WHEN'SAVE'.
             PERFORM save_changes.
         ENDCASE.
       ENDMODULE.                 " USER_COMMAND_0200  INPUT
       *&      Form  get_data
       FORM get_data.
    Read data from table SFLIGHT
         SELECT *
           FROM zsflight
           INTO TABLE gi_sflight.
       ENDFORM.                    " load_data_into_grid
       *&      Form  change_flight
    Reads the contents of the selected row in the grid, ans transfers
    the data to screen 200, where it can be changed and saved.
       FORM change_flight.
         DATA:l_lines TYPE i.
         REFRESH gi_index_rows.
         CLEAR   g_selected_row.
    Read index of selected rows
         CALL METHOD go_grid->get_selected_rows
           IMPORTING
             et_index_rows = gi_index_rows.
    Check if any row are selected at all. If not
    table  gi_index_rows will be empty
         DESCRIBE TABLE gi_index_rows LINES l_lines.
         IF l_lines = 0.
           CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
                EXPORTING
                     textline1 = 'You must choose a line'.
           EXIT.
         ENDIF.
    Read indexes of selected rows. In this example only one
    row can be selected as we are using gs_layout-sel_mode = 'B',
    so it is only ncessary to read the first entry in
    table gi_index_rows
         LOOP AT gi_index_rows INTO g_selected_row.
           IF sy-tabix = 1.
            READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
           ENDIF.
         ENDLOOP.
    Transfer data from the selected row to screenm 200 and show
    screen 200
         CLEAR g_screen200.
         MOVE-CORRESPONDING g_wa_sflight TO g_screen200.
         LEAVE TO SCREEN '200'.
       ENDFORM.                    " change_flight
       *&      Form  save_changes
    Changes made in screen 200 are written to the datbase table
    zsflight, and to the grid table gi_sflight, and the grid is
    updated with method refresh_table_display to display the changes
       FORM save_changes.
         DATA: l_traffic_light TYPE c.
    Update traffic light field
    Update database table
         MODIFY zsflight FROM g_screen200.
    Update grid table , traffic light field and color field.
    Note that it is necessary to use structure g_wa_sflight
    for the update, as the screen structure does not have a
    traffic light field
         MOVE-CORRESPONDING g_screen200 TO g_wa_sflight.
         IF g_wa_sflight-paymentsum < 100000.
           g_wa_sflight-traffic_light = '1'.
      C = Color, 6=Color 1=Intesified on, 0: Inverse display off
           g_wa_sflight-line_color    = 'C610'.
         ELSEIF g_wa_sflight-paymentsum => 100000 AND
                g_wa_sflight-paymentsum < 1000000.
           g_wa_sflight-traffic_light = '2'.
           clear g_wa_sflight-line_color.
         ELSE.
           g_wa_sflight-traffic_light = '3'.
           clear g_wa_sflight-line_color.
         ENDIF.
         MODIFY gi_sflight INDEX g_selected_row-index FROM g_wa_sflight.
    Refresh grid
         CALL METHOD go_grid->refresh_table_display.
         CALL METHOD cl_gui_cfw=>flush.
         LEAVE TO SCREEN '100'.
       ENDFORM.                    " save_changes

  • Subtotal and total in alv report

    hi,
    i have an ALV REPORT,displaying the fields such as po item(ekpo-menge).but i am unable to perform total and sub total,it gives me a information message 'total cannot b performed'.
      can any one help me, how to total and subtotal.

    Hi,
    Please go through the following links. I am sure it will help you.
    <a href="http://www.sapfans.com/forums/viewtopic.php?t=20386">http://www.sapfans.com/forums/viewtopic.php?t=20386</a>
    <a href="http://www.sapfans.com/forums/viewtopic.php?t=85191">http://www.sapfans.com/forums/viewtopic.php?t=85191</a>
    <a href="http://www.sapfans.com/forums/viewtopic.php?t=88401">http://www.sapfans.com/forums/viewtopic.php?t=88401</a>
    Please reward helpful answer.
    Regards,
    Amit Mishra

  • ALV: how to display only subtotals and total rows in the output

    ALV: how to display only subtotals and total rows in the output
    i am getting output
    i am getting subtotals for respective fields
    but i want to display only subtotals and totals rows in the output
    i have tried the
    totals_only   parameter in slis_layout_alv
    but it is not working.

    hi,
    For TOTAL
    For the amount field / quantity field in the field catalog give DO_SUM = 'X'    for WHOLE total
    For SUBTOTAL
    For subtotal you will have to create an internal table sort..Let's say you want to do subtotal for each customer..
    DATA: lt_sort type SLIS_T_SORTINFO_ALV,
    ls_sort type slis_sortinfo_alv.
    CLEAR ls_sort.
    ls_sort-spos = 1.
    ls_sort-fieldname = 'Give the field name that you do the sum'.
    ls_sort-up = 'X'.
    ls_sort-subtot = 'X'.
    APPEND ls_sort TO lt_sort.
    fieldcatalog-do_dum = 'X'.
    for subtotals
    WA_SORT-FIELDNAME = 'ERSDA'.
    WA_SORT-SPOS = '2'.
    WA_SORT-UP = 'X'.
    WA_SORT-SUBTOTAL = 'X'.
    APPEND WA_SORT TO IT_SORT.
    Refer
    http://help.sap.com/saphelp_erp2004/helpdata/en/ee/c8e056d52611d2b468006094192fe3/content.htm
    http://sap.ittoolbox.com/groups/technical-functional/sap-dev/doesnt-function-event-subtotal_text-in-alv-713787
    regards,
    Prabhu
    reward if it is helpful

  • Sub total in ALV report.

    hello everyone,
    i am developing one ALV report and one problem is there.
    i want Material Group wise total on 1.Quantity 2. Asssessable value 3. Basic duty 4. Edu cess.
    Problem is all total are correct but when material group is different it repeat same total again. how to do total different material group wise?
    i am using this code...............
    *& Report  ZHP_EXCISE_INVOICE
    REPORT  zhp_excise_invoice NO STANDARD PAGE HEADING LINE-SIZE 150 MESSAGE-ID 00.
    TYPE-POOLS: slis.
    TABLES: j_1iexchdr,vbrk,vbrp,t001w,t023t,konv.
    DATA: BEGIN OF ithp_j_1iexchdr OCCURS 0,
           docyr LIKE j_1iexchdr-docyr,               "Year
           bukrs LIKE j_1iexchdr-bukrs,               "Company Code
           werks LIKE j_1iexchdr-werks,               "PLANT
           exdat LIKE j_1iexchdr-exdat,               "Excise Document Date
           rdoc  LIKE j_1iexchdr-rdoc,                "Reference Document 1
           preprn LIKE j_1iexchdr-preprn,             "Preprinted Serial Number
           kunag LIKE j_1iexchdr-kunag,               "Sold-to party
           kunwe LIKE j_1iexchdr-kunwe,               "Ship-to party
           exbed LIKE j_1iexchdr-exbed,               "Basic Excise Duty
           ecs LIKE j_1iexchdr-ecs,                   "Edu Cess amount
           status LIKE j_1iexchdr-status,             "Excise Document Status
           censtat LIKE j_1iexchdr-censtat,           "CENVAT Utilization status
           exccd LIKE j_1iexchdr-exccd,               "ECC Number
           trntyp LIKE j_1iexchdr-trntyp,             "Excise Transaction Type
           vbeln LIKE vbrk-vbeln,                   "Billing Document
           kzwi2 LIKE vbrp-kzwi2,                   "Assessable value
           fkimg LIKE vbrp-fkimg,                   "Actual billed quantity
           matkl LIKE vbrp-matkl,                   "Material group
           netwr LIKE vbrp-netwr,                   "Net value
           name1 LIKE t001w-name1,                  "Plant Name
           wgbez LIKE t023t-wgbez,                  "Material Group Desc.
           serial_no TYPE i,
           subtot1 TYPE vbrp-fkimg,
            price_per TYPE konv-kbetr,
            cash_disc TYPE konv-kwert,
            vol_disc TYPE konv-kwert,
            ***_value TYPE konv-kbetr,
            ***_value1 TYPE konv-kbetr,
            BASIC_DUTY1 TYPE konv-kwert,
            EDU_CESS1 TYPE konv-kwert,
          END OF ithp_j_1iexchdr.
    DATA : x TYPE i VALUE 0,
           y TYPE i VALUE 0.
    DATA: t_fillcat TYPE slis_t_fieldcat_alv,
          w_fillcat TYPE slis_fieldcat_alv,
          layout  TYPE slis_layout_alv,
          repid LIKE sy-repid.
    TYPES: BEGIN OF ty_itab,
          price_per TYPE konv-kbetr,
          basic_prc TYPE konv-kbetr,
          cash_disc TYPE konv-kwert,
          vol_disc TYPE konv-kwert,
          ***_value TYPE konv-kbetr,
        END OF ty_itab.
    DATA:it_itab TYPE ty_itab OCCURS 0 WITH HEADER LINE,
         wa_itab TYPE ty_itab.
    TYPES: BEGIN OF ty_konv,
          kschl TYPE konv-kschl,
          kbetr TYPE konv-kbetr,
          kwert TYPE konv-kwert,
          mwsk1 TYPE konv-mwsk1,
          knumv TYPE konv-knumv,
          kposn TYPE konv-kposn,
          END OF ty_konv.
    DATA: it_konv TYPE ty_konv OCCURS 0 WITH HEADER LINE,
         wa_konv TYPE ty_konv .
    TYPES: BEGIN OF ty_vbrk,
          fkdat TYPE vbrk-fkdat,
          fkart TYPE vbrk-fkart,
          knumv TYPE vbrk-knumv,
          vbeln TYPE vbrk-vbeln,
          vbtyp TYPE vbrk-vbtyp,
          bukrs TYPE vbrk-bukrs,
          kunrg TYPE vbrk-kunrg,
          END OF ty_vbrk.
    DATA: it_vbrk TYPE ty_vbrk OCCURS 0 WITH HEADER LINE,
         wa_vbrk TYPE ty_vbrk .
    TYPES : BEGIN OF ty_vbrp,
            werks TYPE vbrp-werks,
            spart TYPE vbrp-spart,
            vkbur TYPE vbrp-vkbur,
            matkl TYPE vbrp-matkl,
            vbeln TYPE vbrp-vbeln,
            posnr TYPE vbrp-posnr,
            vgbel TYPE vbrp-vgbel,
            matnr TYPE vbrp-matnr,
            brgew TYPE vbrp-brgew,
            fkimg TYPE vbrp-fkimg,
            vrkme TYPE vbrp-vrkme,
            netwr TYPE vbrp-netwr,
            arktx TYPE vbrp-arktx,
            aubel TYPE vbrp-aubel,
            kzwi1 TYPE vbrp-kzwi1,
            kzwi2 TYPE vbrp-kzwi2,
            kzwi4 TYPE vbrp-kzwi4,
            kzwi5 TYPE vbrp-kzwi5,
            kzwi6 TYPE vbrp-kzwi6,
            END OF ty_vbrp.
    DATA: it_vbrp TYPE ty_vbrp OCCURS 0 WITH HEADER LINE,
          wa_vbrp TYPE ty_vbrp.
    DATA: events   TYPE slis_t_event,
          gt_list_top_of_page TYPE slis_t_listheader.
         top_of_page  type slis_formname value 'TOP_OF_PAGE'.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: p_bukrs FOR j_1iexchdr-bukrs.
    SELECT-OPTIONS: p_exgrp FOR j_1iexchdr-exgrp.
    SELECT-OPTIONS: p_werks FOR j_1iexchdr-werks.
    SELECT-OPTIONS: p_matkl FOR vbrp-matkl.
    SELECT-OPTIONS: p_trntyp FOR j_1iexchdr-trntyp DEFAULT 'DLFC' NO INTERVALS.
    SELECT-OPTIONS: p_status FOR j_1iexchdr-status DEFAULT 'C' NO INTERVALS.
    SELECT-OPTIONS: p_cnstat FOR j_1iexchdr-censtat DEFAULT 'P' NO INTERVALS.
    SELECT-OPTIONS: p_exdat FOR j_1iexchdr-exdat OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1.
    repid = sy-repid.
    AT SELECTION-SCREEN ON p_bukrs.
      SELECT SINGLE * FROM j_1iexchdr WHERE bukrs IN p_bukrs.
      IF sy-subrc <> 0.
        MESSAGE e001 WITH 'No Table Entries Found'.
        EXIT.
      ENDIF.
    AT SELECTION-SCREEN ON p_werks.
      SELECT SINGLE * FROM j_1iexchdr WHERE werks IN p_werks.
      IF sy-subrc <> 0.
        MESSAGE e001 WITH 'No Table Entries Found'.
        EXIT.
      ENDIF.
    AT SELECTION-SCREEN ON p_matkl.
      SELECT SINGLE * FROM vbrp WHERE matkl IN p_matkl.
      IF sy-subrc <> 0.
        MESSAGE e001 WITH 'No Table Entries Found'.
        EXIT.
      ENDIF.
    AT SELECTION-SCREEN ON p_exdat.
      SELECT SINGLE * FROM j_1iexchdr WHERE exdat IN p_exdat.
      IF sy-subrc <> 0.
        MESSAGE e001 WITH 'No Table Entries Found'.
        EXIT.
      ENDIF.
    START-OF-SELECTION.
      PERFORM select.
      PERFORM fillcat.
      PERFORM display.
    END-OF-SELECTION.
    *&      Form  SELECT
          text
    -->  p1        text
    <--  p2        text
    FORM select .
    SELECT  DOCYR
             BUKRS
             WERKS
             EXDAT
             RDOC
             PREPRN
             KUNAG
             KUNWE
             EXBED
             ECS
             STATUS
             CENSTAT
    INTO CORRESPONDING FIELDS OF TABLE ITHP_J_1IEXCHDR
    FROM J_1IEXCHDR
    WHERE BUKRS IN P_BUKRS AND
           EXGRP IN P_EXGRP AND
           WERKS IN P_WERKS AND
           EXDAT IN P_EXDAT.
    SELECT   VBELN
             NETWR
    INTO CORRESPONDING FIELDS OF TABLE ITHP_VBRK
    FROM VBRK
    FOR ALL ENTRIES IN ITHP_J_1IEXCHDR
    WHERE VBELN EQ ITHP_J_1IEXCHDR-RDOC AND
          BUKRS EQ ITHP_J_1IEXCHDR-BUKRS AND
          KUNAG EQ ITHP_J_1IEXCHDR-KUNAG.
    SORT ITHP_J_1IEXCHDR BY DOCYR BUKRS WERKS EXDAT RDOC.
    SORT ITHP_VBRK BY VBELN.
      SELECT   a~docyr
               a~bukrs
               a~werks
               a~exdat
               a~rdoc
               a~preprn
               a~kunag
               a~kunwe
               a~exbed
               a~ecs
               a~status
               a~censtat
               a~exccd
               a~trntyp
               c~netwr
               c~kzwi2
               c~fkimg
               c~matkl
               d~name1
               e~wgbez
      INTO CORRESPONDING FIELDS OF TABLE ithp_j_1iexchdr
      FROM j_1iexchdr AS a INNER JOIN vbrk AS b ON ardoc = bvbeln
                           INNER JOIN vbrp AS c ON bvbeln = cvbeln
                           INNER JOIN t001w AS d ON awerks = dwerks
                           INNER JOIN t023t AS e ON cmatkl = ematkl
      WHERE a~bukrs IN p_bukrs AND
            a~exgrp IN p_exgrp AND
            a~werks IN p_werks AND
            c~matkl IN p_matkl AND
            a~trntyp IN p_trntyp AND
            a~status IN p_status AND
            a~censtat IN p_cnstat AND
            a~exdat IN p_exdat.
      SORT ithp_j_1iexchdr BY docyr bukrs werks exdat rdoc matkl.
    ENDFORM.                    " SELECT
    *&      Form  FILLCAT
          text
    -->  p1        text
    <--  p2        text
    FORM fillcat .
      DATA: subtot TYPE vbrp-fkimg.
      DATA: BASIC_DUTY TYPE konv-kwert.
      DATA: EDU_CESS TYPE konv-kwert.
      REFRESH it_vbrk.
      REFRESH it_konv.
      REFRESH it_vbrp.
      LOOP AT ithp_j_1iexchdr.
        SELECT fkdat fkart knumv vbeln vbtyp bukrs kunrg
          FROM vbrk INTO TABLE it_vbrk
          WHERE vbeln EQ ithp_j_1iexchdr-rdoc.
        SELECT kschl kbetr kwert mwsk1 knumv kposn FROM konv
          INTO TABLE it_konv FOR ALL ENTRIES IN it_vbrk
          WHERE knumv EQ it_vbrk-knumv.
        SELECT werks spart vkbur matkl vbeln posnr
          vgbel matnr brgew fkimg vrkme netwr
          arktx aubel  kzwi1 kzwi2 kzwi4 kzwi5
          kzwi6 FROM vbrp INTO TABLE it_vbrp FOR ALL
           ENTRIES IN it_vbrk
          WHERE vbeln EQ it_vbrk-vbeln.
        SORT it_vbrk BY vbeln knumv.
        SORT it_konv BY KSCHL knumv.
        SORT it_vbrp BY vbeln.
          LOOP AT it_konv.
          IF it_konv-kschl =  'ZASS'.
             LOOP AT it_konv.
                IF it_konv-kschl =  'ZPR0'.
                it_itab-***_value = it_konv-kwert.
                ithp_j_1iexchdr-***_value = it_itab-***_value.
                ADD ithp_j_1iexchdr-***_value TO ithp_j_1iexchdr-***_value1.
                ithp_j_1iexchdr-***_value1 = ithp_j_1iexchdr-***_value1 - ithp_j_1iexchdr-***_value.
                 MODIFY ithp_j_1iexchdr.
              ENDIF.
              IF it_konv-kschl =  'ZASS'.
                it_itab-***_value = it_konv-kwert.
                ithp_j_1iexchdr-***_value = it_itab-***_value.
                ADD ithp_j_1iexchdr-***_value TO ithp_j_1iexchdr-***_value1.
                MODIFY ithp_j_1iexchdr.
              ENDIF.
            ENDLOOP.
            EXIT.
           ENDIF.
          IF it_konv-kschl = 'PR00'.
            it_itab-***_value = it_konv-kwert.
            ithp_j_1iexchdr-***_value = it_itab-***_value.
            ADD ithp_j_1iexchdr-***_value TO ithp_j_1iexchdr-***_value1.
            MODIFY ithp_j_1iexchdr.
          ENDIF.
          IF it_konv-kschl =  'ZPR0'.
            LOOP AT it_konv.
              IF it_konv-kschl =  'ZASS'.
              EXIT.
             ENDIF.
                it_itab-***_value = it_konv-kwert.
                ithp_j_1iexchdr-***_value = it_itab-***_value.
                 ADD ithp_j_1iexchdr-***_value TO ithp_j_1iexchdr-***_value1.
                ithp_j_1iexchdr-***_value1 = ithp_j_1iexchdr-***_value1 - ithp_j_1iexchdr-***_value.
                  MODIFY ithp_j_1iexchdr.
              ENDIF.
              IF it_konv-kschl =  'ZPR0'.
                it_itab-***_value = it_konv-kwert.
                ithp_j_1iexchdr-***_value = it_itab-***_value.
                ADD ithp_j_1iexchdr-***_value TO ithp_j_1iexchdr-***_value1.
                MODIFY ithp_j_1iexchdr.
              ENDIF.
            ENDLOOP.
            EXIT.
          ENDIF.
               IF it_konv-kschl =  'JEXP'.
                   BASIC_DUTY = it_konv-kwert.
                   ADD BASIC_DUTY TO ithp_j_1iexchdr-BASIC_DUTY1.
                   MODIFY ithp_j_1iexchdr.
                ENDIF.
                IF it_konv-kschl =  'JECS'.
                   EDU_CESS = it_konv-kwert.
                   ADD EDU_CESS TO ithp_j_1iexchdr-EDU_CESS1.
                   MODIFY ithp_j_1iexchdr.
                ENDIF.
        ENDLOOP.
      ENDLOOP.
      LOOP AT ithp_j_1iexchdr.
        AT NEW rdoc.
          SUM.
          subtot = ithp_j_1iexchdr-fkimg.
        ENDAT.
        ithp_j_1iexchdr-subtot1 = subtot.
        MODIFY ithp_j_1iexchdr.
        AT NEW MATKL.
        ENDAT.
      ENDLOOP.
      DELETE ADJACENT DUPLICATES FROM ithp_j_1iexchdr.
      LOOP AT ithp_j_1iexchdr.
        x = x + 1.
        ithp_j_1iexchdr-serial_no = x.
        MODIFY ithp_j_1iexchdr.
      ENDLOOP.
      repid = sy-repid.
      DATA: col_pos TYPE i VALUE 0.
      col_pos = col_pos + 1.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = 'SERIAL_NO'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-seltext_s = 'Serial No'.
      w_fillcat-seltext_m = 'Serial No'.
      w_fillcat-seltext_l = 'Serial No'.
      w_fillcat-outputlen = 8.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = 'DOCYR'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-seltext_s = 'Year'.
      w_fillcat-seltext_m = 'Year'.
      w_fillcat-seltext_l = 'Year'.
      w_fillcat-outputlen = 5.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = 'WERKS'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-seltext_s = 'Plant'.
      w_fillcat-seltext_m = 'Plant'.
      w_fillcat-seltext_l = 'Plant'.
      w_fillcat-outputlen = 5.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = 'EXDAT'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-seltext_s = 'Doc. Date'.
      w_fillcat-seltext_m = 'Doc. Date'.
      w_fillcat-seltext_l = 'Doc. Date'.
      w_fillcat-outputlen = 10.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = 'RDOC'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-seltext_s = 'Ref. Document'.
      w_fillcat-seltext_m = 'Ref. Document'.
      w_fillcat-seltext_l = 'Ref. Document'.
      w_fillcat-outputlen = 11.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = 'PREPRN'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-seltext_s = 'Invoice No'.
      w_fillcat-seltext_m = 'Invoice No'.
      w_fillcat-seltext_l = 'Invoice No'.
      w_fillcat-outputlen = 11.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = 'SUBTOT1'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-do_sum = 'X'.
      w_fillcat-seltext_s = 'Quantity'.
      w_fillcat-seltext_m = 'Quantity'.
      w_fillcat-seltext_l = 'Quantity'.
      w_fillcat-outputlen = 13.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = '***_VALUE1'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-do_sum = 'X'.
      w_fillcat-seltext_s = 'Assessable value'.
      w_fillcat-seltext_m = 'Assessable value'.
      w_fillcat-seltext_l = 'Assessable value'.
      w_fillcat-outputlen = 15.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = 'BASIC_DUTY1'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-do_sum = 'X'.
      w_fillcat-seltext_s = 'Basic Duty'.
      w_fillcat-seltext_m = 'Basic Duty'.
      w_fillcat-seltext_l = 'Basic Duty'.
      w_fillcat-outputlen = 13.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = 'EDU_CESS1'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-do_sum = 'X'.
      w_fillcat-seltext_s = 'Edu Cess'.
      w_fillcat-seltext_m = 'Edu Cess'.
      w_fillcat-seltext_l = 'Edu Cess'.
      w_fillcat-outputlen = 13.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = 'KUNAG'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-seltext_s = 'Sold-to pt'.
      w_fillcat-seltext_m = 'Sold-to pt'.
      w_fillcat-seltext_l = 'Sold-to pt'.
      w_fillcat-outputlen = 10.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = 'KUNWE'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-seltext_s = 'Ship-to pt'.
      w_fillcat-seltext_m = 'Ship-to pt'.
      w_fillcat-seltext_l = 'Ship-to pt'.
      w_fillcat-outputlen = 10.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = 'STATUS'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-seltext_s = 'Doc. Status'.
      w_fillcat-seltext_m = 'Doc. Status'.
      w_fillcat-seltext_l = 'Doc. Status'.
      w_fillcat-outputlen = 8.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = 'CENSTAT'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-seltext_s = 'Cenvet status'.
      w_fillcat-seltext_m = 'Cenvet status'.
      w_fillcat-seltext_l = 'Cenvet status'.
      w_fillcat-outputlen = 8.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = 'MATKL'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-seltext_s = 'Mat. Grp'.
      w_fillcat-seltext_m = 'Mat. Grp'.
      w_fillcat-seltext_l = 'Mat. Grp'.
      w_fillcat-outputlen = 9.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
      col_pos = col_pos + 1.
      w_fillcat-fieldname = 'WGBEZ'.
      w_fillcat-tabname = 'ITHP_J_1IEXCHDR'.
      w_fillcat-col_pos = col_pos.
      w_fillcat-seltext_s = 'Mat. Grp Desc.'.
      w_fillcat-seltext_m = 'Mat. Grp Desc.'.
      w_fillcat-seltext_l = 'Mat. Grp Desc.'.
      w_fillcat-outputlen = 20.
      APPEND w_fillcat TO t_fillcat.
      CLEAR w_fillcat.
    ENDFORM.                    " FILLCAT
    *&      Form  DISPLAY
          text
    -->  p1        text
    <--  p2        text
    FORM display .
      DATA : lv_grid_title TYPE lvc_title.
      DATA: date1(10) TYPE c.
      DATA: tperiod(500) TYPE c,
            tperiod1(40) TYPE c,
            tperiod2(30) TYPE c,
            temp(25) TYPE c,
            temp1(35) TYPE c,
            temp2(25) TYPE c,
            temp3(25) TYPE c,
            temp4(60) TYPE c,
            temp5(100) TYPE c.
      CONCATENATE sy-datum6(2) sy-datum4(2) sy-datum+0(4)
                  INTO date1 SEPARATED BY '/'.
      CONCATENATE p_exdat-low6(2) p_exdat-low4(2) p_exdat-low+0(4)
                  INTO temp1 SEPARATED BY '/'.
      CONCATENATE p_exdat-high6(2) p_exdat-high4(2) p_exdat-high+0(4)
                  INTO temp2 SEPARATED BY '/'.
      CONCATENATE 'DUTY DEBIT STMT:'
                 temp1 'TO' temp2
                 INTO tperiod
                  SEPARATED BY space.
      IF ithp_j_1iexchdr-werks = '1000'.
        CONCATENATE tperiod  'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
                SEPARATED BY space.
      ELSEIF ithp_j_1iexchdr-werks = '1101'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSEIF  ithp_j_1iexchdr-werks = '1102'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSEIF ithp_j_1iexchdr-werks = '1103'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSEIF ithp_j_1iexchdr-werks = '1104'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSEIF ithp_j_1iexchdr-werks = '1201'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSEIF ithp_j_1iexchdr-werks = '1202'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSEIF ithp_j_1iexchdr-werks = '1203'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSEIF ithp_j_1iexchdr-werks = '1204'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSEIF ithp_j_1iexchdr-werks = '1205'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSEIF ithp_j_1iexchdr-werks = '1261'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSEIF ithp_j_1iexchdr-werks = '1301'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSEIF ithp_j_1iexchdr-werks = '1901'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSEIF ithp_j_1iexchdr-werks = '2000'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSEIF ithp_j_1iexchdr-werks = '2101'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSEIF ithp_j_1iexchdr-werks = '3000'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSEIF ithp_j_1iexchdr-werks = '3101'.
        CONCATENATE tperiod 'Plant :' ithp_j_1iexchdr-name1 'Ecc No :' ithp_j_1iexchdr-exccd INTO lv_grid_title
              SEPARATED BY space.
      ELSE.
        CONCATENATE tperiod ' ' INTO lv_grid_title
             SEPARATED BY space.
      ENDIF.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          percentage = 100
          text       = 'Generating Report ... '.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = 'REPID'
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
       i_grid_title                      = lv_grid_title
      I_GRID_SETTINGS                   =
         is_layout                         = layout
         it_fieldcat                       = t_fillcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
         i_default                         = 'X'
         i_save                            = 'X'
      IS_VARIANT                        =
      IT_EVENTS                         = events[]
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = ithp_j_1iexchdr
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " DISPLAY
    Thanks in Advance.....

    Hi himanshu,
    here i am sending some solution.
    just create a internal table and wa for IT_SORT in grid display(just like for field cat).
    Then u have to populate the internal table by fields for which u want subtotals.
    just follow this code.
    data:  i_sort type SLIS_T_SORTINFO_ALV,
            wa_sort type SLIS_SORTINFO_ALV.
    wa_sort-fieldname = 'quantity'.
    wa_sort-up = 'X'.
    wa_sort-subtotal = 'X'.
    append wa_sort to i_sort.
    Do the same thing for all fields.
    mention the internal table name in Grid display.
    I think this some what useful to u,
    Bye.

  • How to get total in ALV report in same Internal table?

    Data : Begin of it_data,
            kunnr type kunnr,
            name1 type name1,
            amt1  type btrt01, " CURR 15,2
           end of it_data.
    loop at it_data into wa_data
    endloop.      
    Hello friends,
    I am developing one ALV report with 20 rows.
    I have filled one internal table with some fileds like amount.
    I want to get total of all amount1 in AMT1 field.
    So, How to get total of amount in same internal table in ALV report ?
    It is ok if i get duplicate rows in internal table.
    Points 'll be awarded soon.
    Regards,
    NVM

    Hi Ronny,
    the alv output will display the sum at the last row.
    for this functionality u have do this logic.
    data: lw_fcat type slis_fieldcat_alv.
    data: lt_fcat type slis_t_fieldcat_alv/
    wa_fcat-fieldname = 'AMT1'.
    wa_fcat-tabname = 'ITAB'.
    wa_fcat-do_sum = 'X'.
    append wa_fcat to lt_fcat.
    and then pass it to reuse_alv_grid_display function,
    regards,
    Santosh Thorat

  • Only sub total in alv report

    hi,
    I have a report on ALV with sub totals for some fields, it is working fine but my requirement is whether i can get only the sub totals of that report.
    regards,
    Prabhu

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

  • Get total in ALV report

    Data : Begin of it_data,
    kunnr type kunnr,
    name1 type name1,
    amt1 type btrt01, " CURR 15,2
    end of it_data.
    loop at it_data into wa_data
    endloop.
    Hello friends,
    I am developing one ALV report with 20 rows.
    I have filled one internal table with some fileds like amount.
    I want to get total of all amount1 in AMT1 field.
    So, How to get total of amount in same internal table in ALV report ?
    It is ok if i get duplicate rows in internal table.
    note : i need not data in field catlog
    Points 'll be awarded soon.
    Regards,

    Hai,
    While Defining Field Catalog,Specify do_sum = 'X' for the field which you want the Total.Before that u have to sort that Values.
    JUST CHECK THIS SAMPLE PROG
    TABLES : STKO,STPO,MAKT,MAST.
    TYPE-POOLS : SLIS.
    DATA : BEGIN OF ISTKO OCCURS 0,
    STLNR LIKE STKO-STLNR,
    DATUV LIKE STKO-DATUV,
    MATNR LIKE MAST-MATNR,
    BMENG LIKE STKO-BMENG,
    BMEIN LIKE STKO-BMEIN,
    END OF ISTKO.
    DATA : BEGIN OF ISTPO OCCURS 0,
    STLNR LIKE STPO-STLNR,
    IDNRK LIKE STPO-IDNRK,
    MENGE LIKE STPO-MENGE,
    MEINS LIKE STPO-MEINS,
    MAKTX LIKE MAKT-MAKTX,
    END OF ISTPO.
    DATA : BEGIN OF IMAKT OCCURS 0,
    MATNR LIKE MAKT-MATNR,
    MAKTX LIKE MAKT-MAKTX,
    END OF IMAKT.
    DATA : BEGIN OF IMAST OCCURS 0,
    MATNR LIKE MAST-MATNR,
    STLNR LIKE MAST-STLNR,
    END OF IMAST.
    DATA : IFIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
    WFIELDCAT TYPE SLIS_FIELDCAT_ALV,
    ILAYOUT TYPE SLIS_LAYOUT_ALV,
    IKEYINFO TYPE SLIS_KEYINFO_ALV,
    IEVENT TYPE SLIS_T_EVENT,
    WEVENT TYPE SLIS_ALV_EVENT,
    ISORT TYPE SLIS_T_SORTINFO_ALV,
    WSORT TYPE SLIS_SORTINFO_ALV.
    PARAMETERS : P_NUM TYPE I DEFAULT 10.
    START-OF-SELECTION.
    PERFORM GETDATA.
    PERFORM GETHEADERMAT.
    PERFORM GET_MAT_DESC.
    PERFORM BUILD_FCAT_HEAD.
    PERFORM BUILD_FCAT_ITEM.
    PERFORM BUILD_KEYINFO.
    PERFORM BUILD_EVENT_TAB.
    PERFORM BUILD_SORT_TAB.
    PERFORM BUILD_LAYOUT.
    PERFORM DISPLAY_DATA.
    *& Form GETDATA
    text
    --> p1 text
    <-- p2 text
    FORM GETDATA .
    SELECT STLNR DATUV BMENG BMEIN INTO CORRESPONDING FIELDS OF TABLE ISTKO
    FROM STKO UP TO P_NUM ROWS.
    IF NOT ISTKO[] IS INITIAL.
    SELECT STLNR IDNRK MENGE MEINS INTO TABLE ISTPO FROM STPO FOR ALL ENTRIES IN ISTKO
    WHERE STLNR = ISTKO-STLNR AND POSTP = 'L'.
    ENDIF.
    ENDFORM. " GETDATA
    *& Form BUILD_FCAT_HEAD
    text
    --> p1 text
    <-- p2 text
    FORM BUILD_FCAT_HEAD .
    WFIELDCAT-TABNAME = 'ISTKO'.
    WFIELDCAT-FIELDNAME = 'STLNR'.
    WFIELDCAT-SELTEXT_L = 'BOM no'.
    WFIELDCAT-OUTPUTLEN = 15.
    APPEND WFIELDCAT TO IFIELDCAT.
    CLEAR WFIELDCAT.
    WFIELDCAT-TABNAME = 'ISTKO'.
    WFIELDCAT-FIELDNAME = 'DATUV'.
    WFIELDCAT-SELTEXT_L = 'BOM date'.
    WFIELDCAT-OUTPUTLEN = 15.
    APPEND WFIELDCAT TO IFIELDCAT.
    CLEAR WFIELDCAT.
    WFIELDCAT-TABNAME = 'ISTKO'.
    WFIELDCAT-FIELDNAME = 'MATNR'.
    WFIELDCAT-SELTEXT_L = 'Header mat no'.
    WFIELDCAT-OUTPUTLEN = 18.
    APPEND WFIELDCAT TO IFIELDCAT.
    CLEAR WFIELDCAT.
    WFIELDCAT-TABNAME = 'ISTKO'.
    WFIELDCAT-FIELDNAME = 'BMENG'.
    WFIELDCAT-SELTEXT_L = 'Base qty'.
    WFIELDCAT-OUTPUTLEN = 15.
    APPEND WFIELDCAT TO IFIELDCAT.
    CLEAR WFIELDCAT.
    WFIELDCAT-TABNAME = 'ISTKO'.
    WFIELDCAT-FIELDNAME = 'BMEIN'.
    WFIELDCAT-SELTEXT_L = 'UOM'.
    WFIELDCAT-OUTPUTLEN = 3.
    APPEND WFIELDCAT TO IFIELDCAT.
    CLEAR WFIELDCAT.
    ENDFORM. " BUILD_FCAT_HEAD
    *& Form BUILD_FCAT_ITEM
    text
    --> p1 text
    <-- p2 text
    FORM BUILD_FCAT_ITEM .
    WFIELDCAT-TABNAME = 'ISTPO'.
    WFIELDCAT-FIELDNAME = 'STLNR'.
    WFIELDCAT-SELTEXT_L = 'BOM no'.
    WFIELDCAT-NO_OUT = 'X'.
    *WFIELDCAT-HOTSPOT = 'X'.
    WFIELDCAT-OUTPUTLEN = 10.
    APPEND WFIELDCAT TO IFIELDCAT.
    CLEAR WFIELDCAT.
    WFIELDCAT-TABNAME = 'ISTPO'.
    WFIELDCAT-FIELDNAME = 'IDNRK'.
    WFIELDCAT-SELTEXT_L = 'Material no'.
    *WFIELDCAT-HOTSPOT = 'X'.
    WFIELDCAT-OUTPUTLEN = 18.
    APPEND WFIELDCAT TO IFIELDCAT.
    CLEAR WFIELDCAT.
    WFIELDCAT-TABNAME = 'ISTPO'.
    WFIELDCAT-FIELDNAME = 'MAKTX'.
    WFIELDCAT-SELTEXT_L = 'Material desc'.
    WFIELDCAT-JUST = 'C'.
    WFIELDCAT-OUTPUTLEN = 30.
    APPEND WFIELDCAT TO IFIELDCAT.
    CLEAR WFIELDCAT.
    WFIELDCAT-TABNAME = 'ISTPO'.
    WFIELDCAT-FIELDNAME = 'MENGE'.
    WFIELDCAT-SELTEXT_L = 'Item qty'.
    WFIELDCAT-OUTPUTLEN = 15.
    WFIELDCAT-DO_SUM = 'X'.
    APPEND WFIELDCAT TO IFIELDCAT.
    CLEAR WFIELDCAT.
    WFIELDCAT-TABNAME = 'ISTPO'.
    WFIELDCAT-FIELDNAME = 'MEINS'.
    WFIELDCAT-SELTEXT_L = 'UOM'.
    WFIELDCAT-OUTPUTLEN = 3.
    APPEND WFIELDCAT TO IFIELDCAT.
    CLEAR WFIELDCAT.
    ENDFORM. " BUILD_FCAT_ITEM
    *& Form BUILD_KEYINFO
    text
    --> p1 text
    <-- p2 text
    FORM BUILD_KEYINFO .
    IKEYINFO-HEADER01 = 'STLNR'.
    IKEYINFO-ITEM01 = 'STLNR'.
    ENDFORM. " BUILD_KEYINFO
    *& Form DISPLAY_DATA
    text
    --> p1 text
    <-- p2 text
    FORM DISPLAY_DATA .
    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_CALLBACK_PROGRAM = SY-REPID
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = 'USER_COM'
    IS_LAYOUT = ILAYOUT
    IT_FIELDCAT = IFIELDCAT[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT = ISORT
    IT_FILTER =
    IS_SEL_HIDE =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    IT_EVENTS = IEVENT[]
    IT_EVENT_EXIT =
    I_TABNAME_HEADER = 'ISTKO'
    I_TABNAME_ITEM = 'ISTPO'
    I_STRUCTURE_NAME_HEADER =
    I_STRUCTURE_NAME_ITEM =
    IS_KEYINFO = IKEYINFO
    IS_PRINT =
    IS_REPREP_ID =
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE =
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    T_OUTTAB_HEADER = ISTKO
    T_OUTTAB_ITEM = ISTPO
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. " DISPLAY_DATA
    *& Form GET_MAT_DESC
    text
    --> p1 text
    <-- p2 text
    FORM GET_MAT_DESC .
    IF NOT ISTPO[] IS INITIAL.
    SELECT MATNR MAKTX INTO TABLE IMAKT FROM MAKT FOR ALL ENTRIES IN ISTPO
    WHERE MATNR = ISTPO-IDNRK.
    ENDIF.
    LOOP AT ISTPO.
    READ TABLE IMAKT WITH KEY MATNR = ISTPO-IDNRK.
    IF SY-SUBRC = 0.
    ISTPO-MAKTX = IMAKT-MAKTX.
    ENDIF.
    MODIFY ISTPO.
    ENDLOOP.
    ENDFORM. " GET_MAT_DESC
    *& Form BUILD_LAYOUT
    text
    --> p1 text
    <-- p2 text
    FORM BUILD_LAYOUT .
    ILAYOUT-ZEBRA = 'X'.
    ILAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    ENDFORM. " BUILD_LAYOUT
    *FORM USER_COM USING PUCOM LIKE SY-UCOMM PSELFIELD TYPE SLIS_SELFIELD.
    *CASE PUCOM.
    *WHEN '&IC1'.
    SET PARAMETER ID 'MAT' FIELD PSELFIELD-VALUE.
    CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
    *ENDCASE.
    *ENDFORM.
    *& Form BUILD_EVENT_TAB
    text
    --> p1 text
    <-- p2 text
    FORM BUILD_EVENT_TAB .
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
    I_LIST_TYPE = 0
    IMPORTING
    ET_EVENTS = IEVENT
    EXCEPTIONS
    LIST_TYPE_WRONG = 1
    OTHERS = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    READ TABLE IEVENT INTO WEVENT WITH KEY NAME = 'TOP_OF_PAGE'.
    IF SY-SUBRC = 0.
    WEVENT-FORM = 'TOPOFPAGE'.
    MODIFY IEVENT FROM WEVENT INDEX SY-TABIX.
    ENDIF.
    ENDFORM. " BUILD_EVENT_TAB
    *& Form TOPOFPAGE
    text
    FORM TOPOFPAGE.
    DATA : ILISTHEAD TYPE SLIS_T_LISTHEADER,
    WLISTHEAD TYPE SLIS_LISTHEADER.
    WLISTHEAD-INFO = 'Its a test hierarchical sequential alv dispaly'.
    WLISTHEAD-TYP = 'H'.
    APPEND WLISTHEAD TO ILISTHEAD.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = ILISTHEAD
    I_LOGO = ''
    I_END_OF_LIST_GRID =
    ENDFORM.
    *& Form GETHEADERMAT
    text
    --> p1 text
    <-- p2 text
    FORM GETHEADERMAT .
    IF NOT ISTKO[] IS INITIAL.
    SELECT MATNR STLNR INTO TABLE IMAST FROM MAST FOR ALL ENTRIES IN ISTKO
    WHERE STLNR = ISTKO-STLNR.
    ENDIF.
    LOOP AT ISTKO.
    READ TABLE IMAST WITH KEY STLNR = ISTKO-STLNR.
    IF SY-SUBRC = 0.
    ISTKO-MATNR = IMAST-MATNR.
    ENDIF.
    MODIFY ISTKO.
    ENDLOOP.
    ENDFORM. " GETHEADERMAT
    *& Form BUILD_SORT_TAB
    text
    --> p1 text
    <-- p2 text
    FORM BUILD_SORT_TAB .
    WSORT-FIELDNAME = 'STLNR'.
    WSORT-TABNAME = 'ISTPO'.
    WSORT-UP = 'X'.
    WSORT-SUBTOT = 'X'.
    WSORT-GROUP = 'UL'.
    APPEND WSORT TO ISORT.
    ENDFORM. " BUILD_SORT_TAB

  • Total in alv report

    hi everyone!
    there is an alv report  that runs correctly in dev system
    and shows the totals in the alv report.
    when the request is being transport to qa system,
    the alv report doesn't shows the totals line at all.
    i tried to transport the report several times activating all the includes screens and so on but it still doesn't work.
    what might be the problem?
    thanks its very urgent
    yifat

    Hi Yifat,
    Have you created a variant for the total alv display.
    In that case try out the same in the qa system. If not, please send the code for field catalog and function module call.
    Thanks
    Vinod

  • Sub total wise Grand total in ALV report

    Dear All,
    I am displaying a list of material through material group wise so for each material i want to display sub-total for stock and grand total of stock(material group wise).Here it is adding up all the stock displayed for different AUOM(alternative unit of measure ) which is for same material so i want to pick only the sub-total and sum up in my Grand total.
    How to pick only the Sub-total Results and Add in ALV List for Grand total.
    Thanks & Regards,
    Arun.
    Edited by: Arun Kumaran on Sep 24, 2008 7:46 AM

    Hi arun,
    check these links
    total and subtotal in alv
    ALV SUBTOTAL
    Regards,
    Anirban

  • How to define what operation a tabular model do on subtotals and totals pivot to avg, min, max, not to the default sum

    When i make a pivot in Excel 2010 i can change the cell to give me AVG, MAX, MIN, not only SUM, but when i créate a pivot from a tabular model, these options are disabled,   i have posted a image, with a "tabla dinámica" or dynamic table
    in this case, i can see the functions that i want but when i use the tabular model as a source, the options average (promedio), is disabled.
    How i can enable this functions, or are a way to créate a formula for totals and subtotals, and other formula for detail in dax?
    Thanks in advance.

    Hi juliomrs,
    SSAS Tabular model doesn't let us to modify the aggregate function from the Client side. In this case, you need to create a new measure and use the function what you want inside the SSAS Tabular model.
    For more information regarding DAX functions, please see:
    DAX Function Reference:
    http://msdn.microsoft.com/en-us/library/ee634396.aspx
    Regards,
    Elvis Long
    TechNet Community Support

  • CUSTOMIZE FIELD TOTAL IN ALV REPORT

    Hi all,
    I am using ALV List display and calculating totals and subtotals. I have 3 columns and the totals are all displayed column-wise.
    But my requirement is that total of 3rd column should not be the sum of all the values in that column but it has to be ( total of column1 / total of column2 ). How can I replace already calculated total of column 3 by the value I get by custom logic. Please suggest me which event needs to be used and how to capture calculated total values of first 2 columns.
    Here is e.g.
    COL1                           COL2                         COL3
    1               |                       2                 |              0.5
    9               |                       3                 |               3
    10             |                      5                 |                3.5        -> VALUE DISPLAYED BY ALV TOTAL
    10             |                      5                 |               (10/5 = 2) -> VALUE REQUIRED TO BE DISPLAYED
    Waiting for your replies....
    Regards
    Vasu

    Check the following example:
    report z_tot_alv.
    TYPE-POOLS SLIS.
    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'.

  • Preview and Download in ALV report blank

    Dear All,
    I have a problem. When user preview and download to local save (txt, xls, etc) from report in ALV format, user get blank preview and blank file.
    I use 2 FM.
    1st i use FM REUSE_ALV_LIST_LAYOUT_INFO_GET to get fieldcat because user want to download after customize the layout (example default there are 5 field then user hide 2 field so only 3 field are displayed and downloaded).
    2nd I use FM REUSE_ALV_GRID_DISPLAY to display as ALV format. and user can download via download button default in ALV format.
    so, anyone.. could u help me ??
    Thanks

    Hi,
    ok I generaeted the fieldcatalog for the above and try to execute as this as I described above
    i am giving the code just check it.
    type-pools SLIS.
    data : lv_vbeln type vbak-vbeln.
    select-options : so_vbeln for lv_vbeln.
    initialization.
    so_vbeln-low = '4970'.
    so_vbeln-high = '4975'.
    append so_vbeln.
    data : lt_fcat type SLIS_T_FIELDCAT_ALV,
           ls_fcat like line of lt_fcat.
    types : begin of ty_vbak,
             vbeln type vbak-vbeln,
             erdat type vbak-erdat,
             erzet type vbak-erzet,
             ernam type vbak-ernam,
           end of ty_vbak.
    data : lt_vbak type standard table of ty_vbak,
           ls_vbak type ty_vbak.
    data : ls_variant like DISVARIANT.
    data : ls_layo type  SLIS_LAYOUT_ALV.
    start-of-selection.
    perform getvbak.
    if sy-subrc eq 0.
    perform displayvbak.
    endif.
    FORM GETVBAK .
    select vbeln erdat erzet ernam from vbak
      into table lt_vbak
      where vbeln in so_vbeln.
    ENDFORM.                    " GETVBAK
    FORM DISPLAYVBAK .
    clear ls_fcat.
    ls_fact-fieldname = 'VBELN'.
    ls_fcat-colpos = 1.
    ls_fcat-seltext_m = 'Sales No'.
    ls_fcat-outputlen = 10.
    append ls_fcat to lt_fcat.
    clear ls_fcat.
    ls_fact-fieldname = 'ERDAT'.
    ls_fcat-colpos = '2'.
    ls_fcat-seltext_m = 'Date'.
    ls_fcat-outputlen = 10.
    append ls_fcat to lt_fcat.
    clear ls_fcat.
    ls_fact-fieldname = 'ERZET'.
    ls_fcat-colpos = '3'.
    ls_fcat-seltext_m = 'Time'.
    ls_fcat-outputlen = 10.
    append ls_fcat to lt_fcat.
    clear ls_fcat.
    ls_fact-fieldname = 'ERNAM'.
    ls_fcat-colpos = '4'.
    ls_fcat-seltext_m = 'Created By'.
    ls_fcat-outputlen = 10.
    append ls_fcat to lt_fcat.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = sy-repid
       IS_LAYOUT                         = ls_layo
       IT_FIELDCAT                       = lt_fcat[]
       I_SAVE                            = 'X'
       IS_VARIANT                        = ls_variant
      TABLES
        T_OUTTAB                          = lt_vbak[].
    ENDFORM.                    " DISPLAYVBAK
    Thanks & Regards,
    Raghunadh K

  • Layout change and save for ALV report

    Hi,
    I ahve created R3 report in which report has been displayed using ALV grid, I am able to change the layout as I can see the layout -> change option in settings menu, but save and choose option is disabled.
    Please advise how to enable layoutr save and choose option for ALV grid.
    Thanks,
    Piyush

    Hi,
    According to sap help you need authorization to save Layout
    [ALV -Layout|http://help.sap.com/saphelp_sm32/helpdata/en/82/839d37664e4d45e10000009b38f8cf/content.htm]
    To save layouts for all users, you need the authorization S_ALV_LAYO with activity 23 as of Release 4.6C. You can only go to the layout administration if you have this authorization.
    You must maintain the authorization object S_ALV_LAYO using the user administration.
    If you would like to use or save the Excel view in your layout, you also require the additional authorization S_BDS_DS with activity 01,02,03,06,30; CLASSNAME ALVLAYOUTTEMPLATES and CLASSTYPE OT.
    Furthermore, there are applications that have their own authorization checks installed.
    In some ALV lists, you can only save user-specific layouts. In these cases, the indicator "user-specific" is active , on a grey background and unable to be changed. This is related to the parameter I_SAVE. This controls which options you have to save the layout.
    To be able to define default layouts, the parameter I_DEFAULT must have the value 'X'.
    Notes 409190 and 601803 also provide further information on authorizations.

  • Field Description and Total in ALV

    Hi Guys,
    I have a certain field in my itab that I declared like field dmbtr, I want that field to be summed up in alv so I had to put dmbtr as its reference field when I defined the field catalog for it. However, it now displays the description of dmbtr rather than my own description.
    How do I go about this?
    Thanks.
    Kenny

    Hello Kenny
    The following fields in the fieldcatalog (LVC_S_FCAT) can be used to modify descriptive texts of the column:
    REPTEXT
    COLTEXT
    SCRTEXT_L
    SCRTEXT_M
    SCRTEXT_S
    COLDDICTXT
    SELDDICTXT
    TIPDDICTXT
    Try to change these field values for your column and see if it has the appropriate effect when the field is summed up.
    Regards
      Uwe

Maybe you are looking for

  • In what folder does FF Android store bookmarks?

    I need to get a copy of my FF bookmarks from my Android phone. Where does FF store its bookmark file on an Android device, and what file should I be looking for? I have a file browsing app which allows me to look anywhere on the phone, but I see no f

  • N9 French virtual keyboard bug - unable to enter à...

    On my Nokia N9, with the French virtual keyboards set, I am unable to enter essential characters such as " à " (a grave), " é " (e acute), " è " (e grave), etc. Is there a way to enter these characters? Or a solution to this bug? The only accented ch

  • Probem after changing the system name of EP 6.0 SP9

    Hi, I have changed the system name of the EP 6.0 SP9 system and restarted it and after I again shifted back to the old system name and restarted the system. Now the j2ee engine is not coming up ... I am placing the developer trace. Pl. suggest what m

  • Renaming column name of view

    suppose i have a table employee with column name first and last. Now i want to make a view of that table employee with column name First_name and Last_name. Is it possible?

  • Mac Sleeping Problems

    This problem just started Monday and I've never had this before until now. I put my Mac to sleep on Monday night before I went to bed. Exactly 20 minutes later it wakes itself back up like it's possessed or something. I put it back to sleep and then