Sub total text in ALV report

Hi,
I need to do subtotalling in my program using ALV. I am getting the subtotal value in ALV list display , but not getting the text for subtotalling.
matnr               werks                       stock
154                  1001                         1589
158                  1001                         1651
Subtotal for plant 1001                               3240
155                  1002                         465
Subtotal for plant 1002                       465

hi,
how did u declared ur internal table?
Declare a dummy field in your internal table to trigger subtotal text event.
TYPES: BEGIN OF ty_ekpo,
          lifnr TYPE ekko-lifnr,    "vendor number
          ebeln TYPE ekko-ebeln,    "purchase document number
          ebelp TYPE ekpo-ebelp,    "Item Number of Purchasing Document
          matnr TYPE ekpo-matnr,    "Material Number
          bukrs TYPE ekpo-bukrs,    "Company Code
          werks TYPE ekpo-werks,    "Plant
          d,                        "Dummy field to fire the Subtotal text event
      END OF ty_ekpo.
Prepare field catalog for that dummyfield also and set attributes like below
wa_fcat-col_pos = 7.
  wa_fcat-fieldname = 'D'.
  wa_fcat-tabname = 'IT_EKPO'.
  wa_fcat-ref_fieldname = 'NETPR'.
  wa_fcat-ref_tabname = 'EKPO'.
  wa_fcat-no_out = 'X'.
  APPEND wa_fcat TO it_fcat.
Fill sortinfo table as follows
wa_sort-spos = 1.
  wa_sort-fieldname = 'LIFNR'.
  wa_sort-tabname = 'IT_EKPO'.
  wa_sort-up = 'X'.
  wa_sort-group = 'UL'.
  APPEND wa_sort TO it_sort.
  CLEAR wa_sort.
  wa_sort-spos = 2.
  wa_sort-fieldname = 'D'.
  wa_sort-tabname = 'IT_EKPO'.
  wa_sort-up = 'X'.
  wa_sort-group = 'UL'.
  wa_sort-subtot = 'X'.
  APPEND wa_sort TO it_sort.
fill the event table
wa_event-name = 'SUBTOTAL_TEXT'.  "--> this event is used to trigger subtotal text
  wa_event-form = 'SUBTOTAL'.
  APPEND wa_event TO it_event.
*&      Form  subtotal
FORM subtotal USING i_listhead STRUCTURE wa_ekpo  i_subtotal TYPE slis_subtot_text.
  READ TABLE it_sort INTO wa_sort WITH KEY fieldname = 'D'.
  IF sy-subrc = 0.
    IF i_subtotal-criteria = 'D'.
      i_subtotal-display_text_for_subtotal = 'Sub total'.
    ENDIF.
  ENDIF.
ENDFORM.                    "subtotal
Thanks & REgards

Similar Messages

  • How to print sub total text in ALV

    Hi All,
       I have a prblem in printing sub total text in ALV. I am passing the text for sub total in ALV layout to the field SUBTOTALS_TEXT. Even then the text is not displayed where as this is working for TOTAL with the field TOTALS_TEXT.
       Could any one provide me the solution please?
    Thanks & Regards,
    S.Lakshmi

    Hi Lakshmi,
    Please refer to the following code :
    report zalv10.
    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'. ***CRUCIAL STATEMENT****
    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'. **THIS SHOULD NOT BE UNCOMENTED*
    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.
    <b>Please reward points if helpful.</b>
    Regards,
    Amit Mishra

  • How to display sub total text in ALV grid display reporting

    Hi,
    I want to display a text 'SUB TOTAL'  in Sub total  row  of an ALV report.
    Presently I am getting the name of the field used in sorting to get sub totals. But I required to display own text. Could you please give me solution.
    Thanks
    Giridhar Karnam

    For doing this u need to simply modify the layout properties, please award points if found helpful
    DATA: L_LAYOUT TYPE SLIS_LAYOUT_ALV.
    L_LAYOUT-SUBTOTALS_TEXT = 'GEN SUBTOT'.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            I_CALLBACK_PROGRAM = SY-REPID
            IS_LAYOUT          = L_LAYOUT
            IT_FIELDCAT        = IT_FIELDCAT
          TABLES
            T_OUTTAB           = IT_FINAL
          EXCEPTIONS
            PROGRAM_ERROR      = 1
            OTHERS             = 2.

  • Short dump when I do total or sub total in the ALV report

    Hi,
    When I do total or sub-total on the currency field in the ALV report, it'll give a short dump like
    " 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)".
       Short text of error message:
       Technical information about the message:
       Message classe...... "0K"
       Number.............. 000
       Variable 1.......... " "
       Variable 2.......... " "
       Variable 3.......... " "
       Variable 4.......... " "
       Variable 3.......... " "
       Variable 4.......... " "
    Trigger Location of Runtime Error
        Program                                 SAPLSLVC
        Include                                 LSLVCF36
        Row                                     2,726
        Module type                             (FORM)
        Module Name                             FILL_DATA_TABLE
    sometime when I do the page down on the ALV report, the same short dump is coming.
    Can anyone help me out.
    Thanks
    Selva

    Hi,
    I'm getting this short dump in the standard program.
    I'm getting ALV report display perfectly. the problem is, when I do total or subtotal on the currency fields.
    2704
    2705 ************************************
    2706 * Column per Fieldcat Entry
    2707 ************************************
    2708         ls_lvc_data-value = space.
    2709         clear ls_lvc_data-style.
    2710         loop at it_fcat_local assigning <ls_fcat>
    2711                 where tech ne 'X' and no_out ne 'X'.
    2712           if l_invisible eq 'X'.
    2713             clear l_invisible.
    2714             if <ls_fcat>-do_sum is initial.
    2715               continue.
    2716             else.
    2717               clear ls_lvc_data-col_pos.
    2718             endif.
    2719           endif.
    2720
    2721           add 1 to ls_lvc_data-col_pos.
    2722
    2723           assign component <ls_fcat>-fieldname
    2724                            of structure <ls_data> to <l_field_value>.
    2725           if sy-subrc ne 0.
    >>>>>             message x000(0k).
    2727           endif.
    2728
    in this standard program, I'm getting the dump. the line is mentioned above in the code.

  • Urgent: regarding sub total button in alv report

    hi,
    i had made dis report and it is is fine till now,but now i want add the sub total field in it ,by making double click on the field sub-total should be displayed in it.
    here is d code as i had tried the sub - total but when i execute it is giving some diferrent result.
    *& Report  ZTET2
    REPORT  ZTET2.
    TABLES: ISEG,MARA.
    TYPE-POOLS : SLIS.
    DATA : DATE1(15) TYPE C,
    DATE2(15) TYPE C,
    TITLE(65) TYPE C,
    DT(25) TYPE C.
    DATA : ITEVENT TYPE SLIS_T_EVENT.
    DATA: lv_sort TYPE slis_sortinfo_alv,
          t_sort type slis_t_sortinfo_alv.
    DATA : repid LIKE sy-repid.
    INTERNAL TABLE FOR INVENTORY STOCK *****************
    DATA: BEGIN OF ITS1 OCCURS 0,
          MATNR LIKE ISEG-MATNR,
          ITEMID(6) TYPE C,
          MEINS LIKE ISEG-MEINS,
          MENGE LIKE ISEG-MENGE,
          WRTZL LIKE ISEG-WRTZL,
          BUCHM LIKE ISEG-BUCHM,
          WRTBM LIKE ISEG-WRTBM,
          WERKS LIKE ISEG-WERKS,
          BUDAT LIKE ISEG-BUDAT,
          ZLDAT LIKE ISEG-ZLDAT,
          MTART LIKE MARA-MTART,
          ITEMDESC LIKE MAKT-MAKTX,
          DIFFQTY LIKE ISEG-BUCHM,
          DIFFVALUE LIKE ISEG-WRTBM,
          GRUND LIKE ISEG-GRUND,
          GRTXT LIKE T157E-GRTXT,
          BWART LIKE T157E-BWART,
          REAS TYPE C LENGTH 15,
          END OF ITS1.
    data: t_heading type slis_t_listheader.
    SELECTION-SCREEN BEGIN OF BLOCK PAR1 WITH FRAME TITLE TEXT-001.
    *SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    *********PARAMETERS*********
    PARAMETERS : PLANT LIKE ISEG-WERKS OBLIGATORY.
    *********SELECTION SCREEN OPTIONS*********
    SELECT-OPTIONS : R_DATE FOR ISEG-BUDAT OBLIGATORY NO-EXTENSION,
                     M_TYPE  FOR MARA-MTART,
                     IT_M FOR MARA-MATNR.
    *********DEFINING VARIABLES*********
    SELECTION-SCREEN END OF BLOCK par1.
    CONCATENATE R_DATE-LOW6(2) '.' R_DATE-LOW4(2) '.' R_DATE-LOW+0(4) INTO DATE1.
    CONCATENATE R_DATE-HIGH6(2) '.' R_DATE-HIGH4(2) '.' R_DATE-HIGH+0(4) INTO DATE2.
    TOP-OF-PAGE.
      PERFORM PG_HEADER.
       START-OF-SELECTION.
      SELECT AMATNR AMEINS AMENGE AWRTZL ABUCHM AWRTBM AWERKS ABUDAT AZLDAT BMTART AGRUND CBWART
       FROM ISEG AS A INNER JOIN MARA AS B ON BMATNR = AMATNR
       INNER JOIN MSEG AS C ON AMBLNR = CMBLNR
       INTO CORRESPONDING FIELDS OF TABLE ITS1 WHERE BMATNR = AMATNR  AND BMEINS = AMEINS AND AWERKS = PLANT AND ABUDAT IN R_DATE AND BMTART IN M_TYPE AND BMATNR IN IT_M.
    LOOP AT ITS1.
         ITS1-ITEMID = ITS1-MATNR+12(6).
         ITS1-DIFFQTY = ITS1-MENGE - ITS1-BUCHM.
         ITS1-DIFFVALUE = ITS1-WRTZL - ITS1-WRTBM.
         SELECT SINGLE MAKTX FROM MAKT INTO ITS1-ITEMDESC WHERE MATNR = ITS1-MATNR.
         SELECT SINGLE GRTXT INTO ITS1-GRTXT FROM T157E WHERE GRUND = ITS1-GRUND AND SPRAS = 'E' AND BWART = ITS1-BWART.
         MODIFY ITS1.
    ENDLOOP.
    PERFORM PRN_SMSTOCK_ALV.
    WRITING DATA FROM D TABLES**********
    FORM PG_HEADER.
    WRITE : 'PHYSICAL INVENTORY AUDIT REPORT             PLANT : ', PLANT.
    ENDFORM.
    *&      Form  PRN_SMSTOCK_ALV
          text
    -->  p1        text
    <--  p2        text
    form PRN_SMSTOCK_ALV .
    data: w_title   type lvc_title,
          w_repid   type syrepid,
          w_comm    type slis_formname,
          w_status  type slis_formname,
          x_layout  type slis_layout_alv,
          t_event   type slis_t_event,
          t_fieldcat type slis_t_fieldcat_alv,
          t_subtot TYPE slis_t_sortinfo_alv,
          subtot LIKE LINE OF t_subtot.
    refresh t_fieldcat.
    refresh t_event.
    refresh t_sort.
    clear x_layout.
    clear w_title.
      perform set_fieldcat2 using:
    1  'MTART'     'MTART'     'MARA'  '15'  space 'MATERIAL TYPE'        space  space  space space space space space space SPACE t_fieldcat 'L' 'L',
    2  'ITEMID'    'ITEMID'    'MARA'  '7'   space 'ITEM ID'              space  space  space space space space space space SPACE t_fieldcat 'R' 'C',
    3  'ITEMDESC'  'MAKTX'     'MAKT'  '25'  space 'MATERIAL DESCRIPTION' space  space  space space space space space space SPACE t_fieldcat 'L' 'C',
    4  'MEINS'     'MEINS'     'MARA'  '5'   space 'UOM'                  space  space  space space space space space space SPACE t_fieldcat 'C' 'C',
    5  'MENGE'     'MENGE'     'ISEG'  '13'  space 'ORG.INV.QTY'          space  space  space space space space space space SPACE t_fieldcat 'R' 'C',
    6  'WRTZL'     'WRTZL'     'ISEG'  '13'  space 'ORG.INV.VALUE'        space  space  space space space space space space SPACE t_fieldcat 'R' 'C',
    7  'BUCHM'     'BUCHM'     'ISEG'  '13'  space 'PHY.INV.QTY'          space  space  space space space space space space SPACE t_fieldcat 'R' 'C',
    8  'WRTBM'     'WRTBM'     'ISEG'  '13'  space 'PHY.INV.VALUE'        space  space  space space space space space space SPACE t_fieldcat 'R' 'C',
    9  'DIFFQTY'   'MENGE'     'ISEG'  '13'  space 'DIFF.INV.QTY'         space  space  space space space space space space SPACE t_fieldcat 'R' 'C',
    10 'DIFFVALUE' 'WRTZL'     'ISEG'  '13'  space 'DIFF.INV.VALUE'       space  space  space space space space space space SPACE t_fieldcat SPACE 'P',
    11 'BUDAT'     'BUDAT'     'ISEG'  '18'  space 'CORRECTED DATE'       space  space  space space space space space space SPACE t_fieldcat  'C' 'C',
    12 'GRTXT'     'GRTXT'     'ISEG'  '18'  space 'REASON'               space  space  space space space space space space SPACE t_fieldcat  'L' 'L',
    13 'REAS'      'REAS'      'ISEG'  '18'  space 'AUTH.BY'              space  space  space space space space space space SPACE t_fieldcat  'C' 'C'.
    x_layout-zebra = 'X'.
    perform set_top_page_heading using t_heading t_event.
    perform set_events using t_event.
    perform get_subtotals.
      w_status = ''.
      w_repid = sy-repid.
    w_comm   = 'USER_COMMAND'.
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program       = w_repid
          it_fieldcat              = t_fieldcat
          i_Callback_top_of_page   = 'Top-of-page'
          is_layout                = x_layout
          it_sort                  = t_sort
          i_callback_pf_status_set = w_status
          i_callback_user_command  = w_comm
          i_save                   = 'X'
          it_events                = t_event
          i_grid_title             = w_title
          tables
          t_outtab                 = ITS1
          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.
    FORM set_fieldcat2 USING
          p_colpos p_fieldname p_ref_fieldname p_ref_tabname
          p_outputlen p_noout
          p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
          p_hotspot p_showasicon p_checkbox p_edit
          p_dosum
        p_subtot
          t_fieldcat TYPE slis_t_fieldcat_alv
          P_JUST
          P_FTYPE.
      DATA: wa_fieldcat TYPE slis_fieldcat_alv.
      CLEAR wa_fieldcat.
    General settings
      wa_fieldcat-fieldname = p_fieldname.
      wa_fieldcat-col_pos = p_colpos.
      wa_fieldcat-no_out = p_noout.
      wa_fieldcat-hotspot = p_hotspot.
      wa_fieldcat-checkbox = p_checkbox.
      wa_fieldcat-icon = p_showasicon.
      wa_fieldcat-do_sum = p_dosum.
    wa_fieldcat-t_subtot = p_subtot.
    Set output length.
      IF NOT p_outputlen IS INITIAL.
        wa_fieldcat-outputlen = p_outputlen.
      ENDIF.
    Set text headers.
    IF NOT p_seltext_m IS INITIAL.
        wa_fieldcat-seltext_m = p_seltext_m.
    ENDIF.
    IF NOT p_seltext_l IS INITIAL.
        wa_fieldcat-seltext_l = p_seltext_l.
    ENDIF.
    IF NOT p_seltext_s IS INITIAL.
        wa_fieldcat-seltext_s = p_seltext_s.
    ENDIF.
      IF NOT p_reptext_ddic IS INITIAL.
        wa_fieldcat-reptext_ddic = p_reptext_ddic.
      ENDIF.
    IF NOT p_ddictxt IS INITIAL.
        wa_fieldcat-ddictxt = p_ddictxt.
    ENDIF.
      IF NOT P_JUST IS INITIAL.
        WA_FIELDCAT-JUST = P_JUST.
      ENDIF.
      IF NOT p_edit IS INITIAL.
        wa_fieldcat-Input     = 'X'.
        wa_fieldcat-edit     = 'X'.
        wa_fieldcat-do_sum = 'x'.
       wa_fieldcat-p_subtot = 'x'.
      ENDIF.
    APPEND wa_fieldcat TO t_fieldcat.
    ENDFORM.                   "set_fieldcat2
    ======================== Subroutines called by ALV ================
    *&      Form  top_of_page
          Called on top_of_page ALV event.
          Prints the heading.
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
         exporting
              it_list_commentary = t_heading.
    ENDFORM.
    form set_top_page_heading using t_heading type slis_t_listheader
                                    t_events  type slis_t_event.
    data: x_heading type slis_listheader,
          x_event   type line of slis_t_event.
    Report title
      clear t_heading[].
      clear x_heading.
      x_heading-typ = 'H'.
      x_heading-info = 'PHYSICAL INVENTORY AUDIT REPORT'.
      append x_heading to t_heading.
    Plant Name
    clear x_heading.
      x_heading-typ = 'S'.
      x_heading-key = 'PLANT        : '.
      x_heading-info = PLANT.
      append x_heading to t_heading.
    IF DATE2 = '00.00.0000'.
      CONCATENATE DATE1 'to' DATE1 INTO DT SEPARATED BY SPACE.
    ELSE.
      CONCATENATE DATE1 'to' DATE2 INTO DT SEPARATED BY SPACE.
    ENDIF.
    X_heading-TYP = 'S'.
    X_heading-key = 'PERIOD         :'.
    X_heading-INFO = DT.
    APPEND x_heading TO t_heading.
    Control Date
      clear x_heading.
      x_heading-typ = 'S'.
      x_heading-key = 'CONTROL NO. :'.
      x_heading-info = ' ASDFADDFAAS  DATE : 11.04.2007'.
      append x_heading to t_heading.
    Control date
    clear x_heading.
    x_heading-typ = 'S'.
    x_heading-key = 'CONTROL DATE : '.
    x_heading-info = ''.
    append x_heading to t_heading.
    Time of execution
    clear x_heading.
    x_heading-typ = 'S'.
    x_heading-key = 'DATE : '.
    write sy-DATUM to x_heading-info.
    append x_heading to t_heading.
    Top of page event
      x_event-name = slis_ev_top_of_page.
      x_event-form = 'TOP_OF_PAGE'.
      append x_event to t_events.
    endform.
    FORM get_subtotals.
    CLEAR lv_sort.
    lv_sort-fieldname = 'MENGE'.
    lv_sort-up = 'X'.
    lv_sort-subtot = 'X'.
    APPEND lv_sort TO t_sort.
    clear lv_sort.
    *lv_sort-fieldname = 'MENGE'.
    *lv_sort-tabname = 'ITS1'.
    *lv_sort-subtot = 'X'.
    *APPEND lv_sort TO t_sort.
    lv_sort-fieldname = 'WRTZL'.
    lv_sort-tabname = 'ITS1'.
    lv_sort-subtot = 'X'.
    APPEND lv_sort TO t_sort.
    clear lv_sort.
    lv_sort-fieldname = 'BUCHM'.
    lv_sort-tabname = 'ITS1'.
    lv_sort-subtot = 'X'.
    APPEND lv_sort TO t_sort.
    clear lv_sort.
    lv_sort-fieldname = 'WRTBM'.
    lv_sort-tabname = 'ITS1'.
    lv_sort-subtot = 'X'.
    APPEND lv_sort TO t_sort.
    clear lv_sort.
    lv_sort-fieldname = 'DIFFQTY'.
    lv_sort-tabname = 'ITS1'.
    lv_sort-subtot = 'X'.
    APPEND lv_sort TO t_sort.
    clear lv_sort.
    lv_sort-fieldname = 'DIFFVALUE'.
    lv_sort-tabname = 'ITS1'.
    lv_sort-subtot = 'X'.
    APPEND lv_sort TO t_sort.
    clear lv_sort.
    ENDFORM.
    form set_events using t_events type slis_t_event.
    data: x_event   type line of slis_t_event.
    endform.
    PLZ HELP ME and definately get rewarded.

    hi,
    how did u declared ur internal table?
    Declare a dummy field in your internal table to trigger subtotal text event.
    TYPES: BEGIN OF ty_ekpo,
              lifnr TYPE ekko-lifnr,    "vendor number
              ebeln TYPE ekko-ebeln,    "purchase document number
              ebelp TYPE ekpo-ebelp,    "Item Number of Purchasing Document
              matnr TYPE ekpo-matnr,    "Material Number
              bukrs TYPE ekpo-bukrs,    "Company Code
              werks TYPE ekpo-werks,    "Plant
              d,                        "Dummy field to fire the Subtotal text event
          END OF ty_ekpo.
    Prepare field catalog for that dummyfield also and set attributes like below
    wa_fcat-col_pos = 7.
      wa_fcat-fieldname = 'D'.
      wa_fcat-tabname = 'IT_EKPO'.
      wa_fcat-ref_fieldname = 'NETPR'.
      wa_fcat-ref_tabname = 'EKPO'.
      wa_fcat-no_out = 'X'.
      APPEND wa_fcat TO it_fcat.
    Fill sortinfo table as follows
    wa_sort-spos = 1.
      wa_sort-fieldname = 'LIFNR'.
      wa_sort-tabname = 'IT_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-group = 'UL'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
      wa_sort-spos = 2.
      wa_sort-fieldname = 'D'.
      wa_sort-tabname = 'IT_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-group = 'UL'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO it_sort.
    fill the event table
    wa_event-name = 'SUBTOTAL_TEXT'.  "--> this event is used to trigger subtotal text
      wa_event-form = 'SUBTOTAL'.
      APPEND wa_event TO it_event.
    *&      Form  subtotal
    FORM subtotal USING i_listhead STRUCTURE wa_ekpo  i_subtotal TYPE slis_subtot_text.
      READ TABLE it_sort INTO wa_sort WITH KEY fieldname = 'D'.
      IF sy-subrc = 0.
        IF i_subtotal-criteria = 'D'.
          i_subtotal-display_text_for_subtotal = 'Sub total'.
        ENDIF.
      ENDIF.
    ENDFORM.                    "subtotal
    Thanks & REgards

  • Sub totaling in the ALV report

    Hi,
    My requirement is to display the data in a ALV format. The ALV need to display the sub total. For example if the ALV display the comapny code, the number of the line of the company code need to displayed.
    1000
    1000
    1000
    Sub total 3
    2000
    2000
    2000
    2000
    sub total 4
    I made the changes to display the ALV. Please help mein obtaining the sub total..
    Regards
    Suresh

    HI,
    Below example may clear ur requirement.
    REPORT YMS_ALVSUBTOTAL.
    *REPORT z_alv_sub_totals .
    TYPE-POOLS: slis.
    DATA: BEGIN OF it_output OCCURS 0,
    var1(8) TYPE n,
    var2(10),
    var3 TYPE I,
    END OF it_output.
    DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
    t_fieldcat TYPE slis_fieldcat_alv,
    it_sort TYPE slis_t_sortinfo_alv,
    t_sort TYPE slis_sortinfo_alv,
    v_repid LIKE sy-repid.
    INITIALIZATION.
    v_repid = sy-repid.
    START-OF-SELECTION.
    PERFORM get_data.
    PERFORM sort_fields.
    PERFORM fill_fieldcat.
    PERFORM list_display.
    *& Form GET_DATA
    text
    --> p1 text
    <-- p2 text
    FORM get_data.
    it_output-var1 = 1000.
    it_output-var2 = 'anupama'.
    it_output-var3 = '10000'.
    APPEND it_output.
    CLEAR it_output.
    it_output-var1 = 1000.
    it_output-var2 = 'siddhu'.
    it_output-var3 = '20000'.
    APPEND it_output.
    CLEAR it_output.
    it_output-var1 = 1000.
    it_output-var2 = 'chinni'.
    it_output-var3 = '100000'.
    APPEND it_output.
    CLEAR it_output.
    it_output-var1 = 2000.
    it_output-var2 = 'chicchu'.
    it_output-var3 = '10000'.
    APPEND it_output.
    CLEAR it_output.
    it_output-var1 = 2000.
    it_output-var2 = 'candy'.
    it_output-var3 = '10000'.
    APPEND it_output.
    CLEAR it_output.
    it_output-var1 = 1000.
    it_output-var2 = 'anupama'.
    it_output-var3 = '10000'.
    APPEND it_output.
    CLEAR it_output.
    it_output-var1 = 4000.
    it_output-var2 = 'anupama'.
    it_output-var3 = '10000'.
    APPEND it_output.
    CLEAR it_output.
    ENDFORM. " GET_DATA
    *& Form fill_fieldcat
    text
    --> p1 text
    <-- p2 text
    FORM fill_fieldcat.
    PERFORM fill_fields USING: 'IT_OUTPUT' 'VAR1' 'Variable 1' ' ',
    'IT_OUTPUT' 'VAR2' 'Variable 2' ' ',
    'IT_OUTPUT' 'VAR3' 'Variable 3' 'X'.
    ENDFORM. " fill_fieldcat
    *& Form fill_fields
    text
    -->P_0146 text
    -->P_0147 text
    -->P_0148 text
    -->P_0149 text
    FORM fill_fields USING value(tabname) TYPE slis_tabname
    value(fieldname) TYPE slis_fieldname
    value(seltext_m) LIKE dd03p-scrtext_m
    value(do_sum) TYPE c.
    t_fieldcat-tabname = tabname.
    t_fieldcat-fieldname = fieldname.
    t_fieldcat-seltext_m = seltext_m.
    IF do_sum = 'X'.
    t_fieldcat-datatype = 'CURR'.
    ENDIF.
    t_fieldcat-do_sum = do_sum.
    APPEND t_fieldcat TO it_fieldcat.
    CLEAR t_fieldcat.
    ENDFORM. " fill_fields
    *& Form list_display
    text
    --> p1 text
    <-- p2 text
    FORM list_display.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    i_callback_program = v_repid
    it_fieldcat = it_fieldcat
    it_sort = it_sort[]
    TABLES
    t_outtab = it_output
    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. " list_display
    *& Form sort_fields
    text
    --> p1 text
    <-- p2 text
    FORM sort_fields.
    t_sort-fieldname = 'VAR1'.
    t_sort-tabname = 'IT_OUTPUT'.
    t_sort-spos = 1.
    t_sort-up = 'X'.
    t_sort-subtot = 'X'.
    APPEND t_sort TO it_sort.
    CLEAR t_sort.
    t_sort-fieldname = 'VAR3'.
    t_sort-tabname = 'IT_OUTPUT'.
    t_sort-spos = 2.
    t_sort-up = 'X'.
    APPEND t_sort TO it_sort.
    CLEAR t_sort.
    ENDFORM. " sort_fields
    Thanks,
    Shankar

  • Regarding totals  and sub totals text in alv

    Hi all,
    i am displaying Totals and subtotals ......but i want to display the text before the the Totals and Subtotals.
    Please help me in regarding this..
    Thanks in advance,
    S.Gangi reddy.

    hi,
    check this report.
    *& Report  ZGM_ALV_SUBTOTAL_TEXT                                       *
    *& Author :
    *& Date :
    *& Description :
    *& Modification History
    REPORT  ZGM_ALV_SUBTOTAL_TEXT                   .
    *& 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:
      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 width
    ENDFORM. " 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_textSelection screen:
    \[removed by moderator\]
    Edited by: Jan Stallkamp on Sep 3, 2008 6:17 PM

  • Totals text for ALV report

    In my ALV report I need to add descriptions for totals
                Col1        Col2          Col3
    Sum1       #Value      #Value      #Value
    Sum2       #Value      #Value      #Value
    Sum3       #Value      #Value      #Value
    How to add text Sum1, Sum2, Sum3 to the report?
    I tried to use subtotals_text and totals_text in slis_layout_alv for REUSE_ALV_GRID_DISPLAY but that did not work out. I also tried to look for methods using CL_SALV_TABLE class and have not been able to find a solution yet.
    Edited by: Megan Flores on Feb 25, 2008 8:28 PM

    it's a package in the systems above 6.4 with new ALV. There are nice examples. Main package is SALV.
    /wg

  • Remove sub total text in ALV.

    Hello,
    How can I remove the text in sub total in ALV? I want to show only sub total values, not any explanation.
    Thanks.

    In my code;
    FIELDCATALOG-FIELDNAME   = 'SYSTEM_UNIQ_NO'.
    FIELDCATALOG-SELTEXT_L   = 'No'.
    FIELDCATALOG-DDICTXT     = 'L'.
    APPEND FIELDCATALOG TO FIELDCATALOG.
    FIELDCATALOG-FIELDNAME   = 'QUANTITY'.
    FIELDCATALOG-SELTEXT_L   = 'Quantity'.
    FIELDCATALOG-DDICTXT     = 'L'.
    FIELDCATALOG-do_sum       = 'X'.
    FIELDCATALOG-QFIELDNAME  = 'QUNIT'.
    APPEND FIELDCATALOG TO FIELDCATALOG.
    it_sort-spos      = 1.
    it_sort-fieldname = 'SYSTEM_UNIQ_NO'.
    it_sort-SUBTOT    = 'X'.
    it_sort-UP        = 'X'.
    GD_LAYOUT-NO_INPUT          = 'X'.
    GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    GD_LAYOUT-no_totalline      = 'X'.
    GD_LAYOUT-subtotals_text    = SPACE.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
             EXPORTING
                  I_CALLBACK_PROGRAM      = GD_REPID
                  I_CALLBACK_USER_COMMAND = 'USER_COMMAND' 
                  IS_LAYOUT               = GD_LAYOUT
                  IT_FIELDCAT             = FIELDCATALOG[]
                  I_SAVE                  = 'X'
                  IT_SORT                 = IT_SORT[]
             TABLES
                  T_OUTTAB                = ITAB
             EXCEPTIONS
                  PROGRAM_ERROR           = 1
                  OTHERS                  = 2.
    But, I am seeing the System Uniq No before sub totals. Also, I have assigned 'Test' to GD_LAYOUT-subtotals_text. But, I can not see 'Test' anywhere.

  • How to calculate totals in Blocked ALV Report

    Hi All,
    Can any body tell how to calculate totals & sub totals in
    Blocked ALV Report[Blocked List].
    Thanks in advance
    Thanks & Regards,
    Rayeezuddin.

    read this it might help
    Sums                                                       
    15. No_sumchoice(1) TYPE c : This parameter allows the choice for summing up
    Only by fieldcatalog.
    Value set: SPACE, 'X'
    'X' = fields which are to be summed, passed by the calling program (FIELDCAT-DO_SUM = 'X'). The user should not be able to change this value interactively.
    16. No_totalline(1) TYPE c : Removes the option of having totals after sub-totals.
    Value set: SPACE, 'X'
    'X' = no total record is to be output. Subtotals can still be calculated and output. The fields in the subtotals are flagged DO_SUM = 'X' in the field list.
    17. No_subchoice(1) TYPE c : Does not allow the user to interactively change the field chosen for subtotals.
    Value set: SPACE, 'X'
    'X' = value whose change triggers subtotals, provided by the calling program. The user should not be able to change this value interactively.
    18. No_subtotals(1) TYPE c : No subtotals possible          
    Value set: SPACE, 'X'
    'X' = no subtotals.
    19. Numc_sum(1)  TYPE c : Totals only possible for NUMC-Fields.
    20. No_unit_splitting TYPE c: No separate total lines by inh.units   
    21.totals_before_items TYPE c: Display totals before the items   
    22. Totals_only(1) TYPE c :  Show only totals      
    Value set: SPACE, 'X'
    'X' = only total records are output.
    23. Totals_text(60) TYPE c : Text for 1st col. in totals   
    Value set: SPACE, string (max.60)
    ' ' = The first column in the total record contains an appropriate number of '*'s to indicate the total by default. If the first column is wide enough, the string 'Total' is output after the asterisks.
    'String’ = The string passed is output after the total indicated by '*', if the column is wide enough.
    24. Subtotals_text(60) TYPE c : Texts for subtotals
    Value set: SPACE, string (max.60)
    ' ' = In the first column of subtotal records, the subtotal is indicated by an appropriate number of '*' by default. If the first column is not a subtotal criterion, the string 'Total' is output after the asterisks, if the column is wide enough.
    'String’ = the string passed is output after the subtotal indicated by '*', if the column is wide enough and the first column is not a subtotal criterion. If it is a subtotal criterion, its value is repeated after the total, if the column is wide enough.
    ELSE TELL ME I WILL PASTE COMPLETE HELP
    regards

  • Hide grand total field on ALV report, But keep the sub total fields

    Dear Experts,
    1) How to hide grand total field on ALV report, But keep the sub total fields.
    2) How to populate rate per ton & calculate total price according to the qty in delivering document.

    Dear Experts,
    1) How to hide grand total field on ALV report, But keep the sub total fields.
    2) How to populate rate per ton & calculate total price according to the qty in delivering document.

  • ALV Sub total texts. displayed in list not in grid.

    Hi,
    I am displaying data using alv and sub-totals on a particular column.
    i am getting the sub-totals but i am not getting the sub-total texts when i am displaying data in a grid.
    'REUSE_ALV_GRID_DISPLAY'.
    i am getting subtotals and subtotal texts when i am diSplAying in list.
    'REUSE_ALV_LIST_DISPLAY'.
    but i want to get subtotal texts using alv grid, is it possible, if so please send me the code.
    Any help in this regard is highly appreciated.
    Thanks in advance for your help.

    Hi,
    Actually i have wriitten the same code, in the alv. I am using Function modules. for the same code the sub-total and total text is appearing in the list output. but not in the grid output.
    code.
      wa_layout-zebra          = 'X'.
      wa_layout-subtotals_text = 'Total'.
      wa_layout-totals_text    = 'Sum of Marks'.
    alv statement.
         is_layout = wa_layout
    Declaration.
    DATA : wa_layout type slis_layout_alv.
    for the same declarations (Above) list is showing the texts but not the grid.
    Any help in this regard is highly appreciated.

  • Sub Total Text in an ALV using FACTORY Method

    Hi Gurus,
    My requirement is simple, but I couldn't find any answers under SDN or any other forums. Some of you may ask me to check for the SCN posts, but I almost checked everything.
    My requirement is - When I get the Sub-total in my ALV, it should print a text other than the field which has got sub-total value.
    My ALV Schema:
    Field1  |  Field2 |  Field 3 |
    ____   |______ |______ |
               |             |             |
               |             |             |
              Tot. Qty  | 1000.00|
    I have sorted and added the subtotal = 'X' for the field which I need the Subtotal. Added Aggregations to Field3. But where and how to the field 'Tot. Qty', so that it should appear at the Sub-Total Level.
    Please guide me if I've missed any of the forums. Again my requirement is to print the Field Name.
    Regards,
    -Wahid Hussain Syed.

    Hi,
    You can view this thread for example Display constant text in intermediate results column of SALV as it says that this is a limitation in SALV that "The output of totals and subtotals is handled solely by ALV. You can neither pass the results to your application nor manipulate them in any way.". But you can see a work around done for this problem, to be frank that I have not done that and I am only providing this link for your reference.

  • Static text in ALV Report

    Hi,
    I have a requirement to create an ALV report which has to display some static text on each page. In the format below, the line item texts and sub total texts will be the same for each page. Each page displays data for one company code. The company code should be displayed on the top of page.
    Line Items    Sub totals          Amounts
    Line item 1                              Amt1
    Line item 2                              Amt2
    Line item 3                              Amt3
                            Sub total          1-3
    Line item 4                              Amt4
    Line item 5                              Amt5
                            Sub total        1-5           
                                                 Total
    1. How to display the same item texts on each page? Can I use text symbols to avoid hard coding?
    2. How do I get sub totals?
    3. Display company code on top of page according to the viewed page?
    any sample code greatly appreciated.
    Thanks,
    MJ

    Hi,
    I have a requirement to create an ALV report which has to display some static text on each page. In the format below, the line item texts and sub total texts will be the same for each page. Each page displays data for one company code. The company code should be displayed on the top of page.
    Line Items                       Amounts
    Line item 1                        Amt1
    Line item 2                        Amt2
    Line item 3                        Amt3
    Sub total                             1-3
    Line item 4                         Amt4
    Line item 5                         Amt5
    Sub total                            1-5           
       Total                               1-5
    1. How to display the same item texts on each page? Can I use text symbols to avoid hard coding?
    2. How do I get sub totals?
    3. Display company code on top of page according to the viewed page?
    any sample code greatly appreciated.
    Thanks,
    MJ

  • Sub total text is not working

    Dear experts,
    I am working on ALV report. I need to maintain Sub total text but its not working with the below code.
    Can you please tell me whats wrong with this code.
    FORM f_display_alv_output .
      DATA: loc_repid TYPE sy-repid.
      CLEAR: loc_repid.
      loc_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = loc_repid
    *   I_CALLBACK_PF_STATUS_SET          = ' '
    *   I_CALLBACK_USER_COMMAND           = ' '
    *   i_callback_top_of_page            = 'F_ALV_TOP_OF_PAGE'
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = ' '
    *   I_GRID_TITLE                      =
    *   I_GRID_SETTINGS                   =
       is_layout                         = fs_layout
       it_fieldcat                       = itab_fieldcat
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
       it_sort                           = itab_sort
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
       i_default                         = 'X'
       i_save                            = 'A'
    *   IS_VARIANT                        =
       it_events                         = itab_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                          = itab_output
    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.                    " F_DISPLAY_ALV_OUTPUT
    *&      Form  F_POPULATE_SORT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f_populate_sort .
      CLEAR: fs_sort.
      REFRESH: itab_sort.
    * Sort by Account Manager
      fs_sort-spos = '01' .
      fs_sort-fieldname = 'ACT_MANAGER'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    * Sort by Sales Office
      fs_sort-spos = '02' .
      fs_sort-fieldname = 'VKBUR'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    * Sort by Customer
      fs_sort-spos = '03' .
      fs_sort-fieldname = 'KUNNR'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    * Sort by Material
      fs_sort-spos = '04' .
      fs_sort-fieldname = 'MATNR'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    ENDFORM.                    " F_POPULATE_SORT
    *&      Form  F_GET_EVENT
    *  Handle events for the list
    *  -->  p1        text
    *  <--  p2        text
    FORM f_get_event .
      REFRESH: itab_events.
      CLEAR: fs_events.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 4
        IMPORTING
          et_events       = itab_events
        EXCEPTIONS
          list_type_wrong = 0
          OTHERS          = 0.
      CLEAR: fs_events.
      READ TABLE itab_events INTO fs_events WITH KEY name = slis_ev_top_of_page.
      IF sy-subrc EQ 0.
        MOVE 'F_ALV_TOP_OF_PAGE' TO fs_events-form.
        MODIFY itab_events FROM fs_events INDEX sy-tabix.
      ENDIF.
      CLEAR fs_events.
      READ TABLE itab_events  INTO fs_events WITH KEY name = slis_ev_subtotal_text.
      IF sy-subrc = 0.
        MOVE wl_formname_subtotal_text TO fs_events-form.
        MODIFY itab_events FROM fs_events INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    " F_GET_EVENT
    *&      Form  SUBTOTAL_TEXT_form
    *       text
    FORM subtotal_text_form USING p_subtot_text TYPE slis_subtot_text.
      IF p_subtot_text-criteria = 'ACT_MANAGER'.
        p_subtot_text-display_text_for_subtotal = 'Account Manager Level Subtotal'(020).
      ENDIF.
    ENDFORM.                    "SUBTOTAL_TEXT
    *&      Form  f_alv_top_of_page
    *       text
    FORM f_alv_top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = itab_top_of_page.
    ENDFORM.                    "F_ALV_TOP_OF_PAGE
    Edited by: Rajesh Tummala on Apr 7, 2009 4:16 PM

    Here's the code below. Sub total text event is not working but top of page is working fine.
    *&      Form  F_POPULATE_SORT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f_populate_sort .
      CLEAR: fs_sort.
      REFRESH: itab_sort.
    * Sort by Account Manager
      fs_sort-spos = '01' .
      fs_sort-fieldname = 'ACT_MANAGER'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    * Sort by Sales Office
      fs_sort-spos = '02' .
      fs_sort-fieldname = 'VKBUR'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    * Sort by Customer
      fs_sort-spos = '03' .
      fs_sort-fieldname = 'KUNNR'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    * Sort by Material
      fs_sort-spos = '04' .
      fs_sort-fieldname = 'MATNR'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    ENDFORM.                    " F_POPULATE_SORT
    *&      Form  F_GET_EVENT
    *  Handle events for the list
    *  -->  p1        text
    *  <--  p2        text
    FORM f_get_event .
      REFRESH: itab_events.
      CLEAR: fs_events.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 4
        IMPORTING
          et_events       = itab_events
        EXCEPTIONS
          list_type_wrong = 0
          OTHERS          = 0.
      CLEAR: fs_events.
      READ TABLE itab_events INTO fs_events WITH KEY name = slis_ev_top_of_page.
      IF sy-subrc EQ 0.
        MOVE 'F_ALV_TOP_OF_PAGE' TO fs_events-form.
        MODIFY itab_events FROM fs_events INDEX sy-tabix.
      ENDIF.
      CLEAR fs_events.
      READ TABLE itab_events  INTO fs_events WITH KEY name = slis_ev_subtotal_text.
      IF sy-subrc = 0.
        MOVE wl_formname_subtotal_text TO fs_events-form.
        MODIFY itab_events FROM fs_events INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    " F_GET_EVENT
    *&      Form  F_DISPLAY_ALV_OUTPUT
    *   Display the list output
    *  -->  p1        text
    *  <--  p2        text
    FORM f_display_alv_output .
      DATA: loc_repid TYPE sy-repid.
      CLEAR: loc_repid.
      loc_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = loc_repid
    *   I_CALLBACK_PF_STATUS_SET          = ' '
    *   I_CALLBACK_USER_COMMAND           = ' '
    *   i_callback_top_of_page            = 'F_ALV_TOP_OF_PAGE'
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = ' '
    *   I_GRID_TITLE                      =
    *   I_GRID_SETTINGS                   =
       is_layout                         = fs_layout
       it_fieldcat                       = itab_fieldcat
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
       it_sort                           = itab_sort
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
       i_default                         = 'X'
       i_save                            = 'A'
    *   IS_VARIANT                        =
       it_events                         = itab_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                          = itab_output
    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.                    " F_DISPLAY_ALV_OUTPUT
    *&      Form  SUBTOTAL_TEXT_form
    *       text
    FORM subtotal_text_form USING p_subtot_text TYPE slis_subtot_text.
      IF p_subtot_text-criteria = 'ACT_MANAGER'.
        p_subtot_text-display_text_for_subtotal = 'Account Manager Level Subtotal'(020).
      ENDIF.
    ENDFORM.                    "SUBTOTAL_TEXT
    *&      Form  f_alv_top_of_page
    *       text
    FORM f_alv_top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = itab_top_of_page.
    ENDFORM.                    "F_ALV_TOP_OF_PAGE

Maybe you are looking for

  • Import Purchase Order issue

    Hi MM Gurus, In Import pricing Procedure I have assigned  FR3 as the account key for the custom clearing condition types. I have also assign the G/L account for FR3 in OBYC. But when i am doing the MIRO for bill of Entry, it is only showing the Cr. a

  • How can I get my delete key to work as a delete key in Windows?

    When I try to control-alt-delete in order to log onto my computer profile, using only my MacBook Pro keyboard, Windows thinks that the delete key is a backspace key and will not let give me access to the login screen. If I connect an external keyboar

  • CRM Activities & Case link

    Hi, I want to generate a report/query to get Activities & connected Cases using CRM 5.0. Can anyone please let me know the tables involved or query to be used? thanks in advance, LSP

  • Newbie: External App to Create Users/Groups

    I am new to web based security, so please excuse what is probably a very simple question. I was reading the security documentation for WLS 8.1 and it seems to me that all users/groups, etc must be administered from within the WLS console. Is it possi

  • Any hope for midi import update iOS 6 for iPad3?

    I purchased the iPad3 after seeing all the cool stuff you could do with it, nicely portable, and GarageBand expecting all the great features I saw in YouTube video.  Turns out GarageBand for iOS is an inferior product to the Mac version.  Had I known