Skip to Content
author's profile photo Former Member
Former Member

SUBTOTALS IN HSEQ ALV DISPLAY

Hi Experts,

I have a hierarchial sequential list.how to get subtotals in the list?

for subtotlas i have written like this (fcat-do_sum = 'X') and its giving the grand total but not material wise and companycode subtotals.

fcat-do_sum = 'X'

rewards for all helpful answers

Thanx and regards,

Prajith

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 09:30 AM

    Hi

    Hope it will help you.

    Pls Reward if help.

    REPORT ZALV5_OBJECTS.

    TABLES : EKKO.

    TYPE-POOLS : SLIS.

    TYPES : BEGIN OF TY_EKKO,

    EBELN TYPE EKPO-EBELN,

    EBELP TYPE EKPO-EBELP,

    STATU TYPE EKPO-STATU,

    AEDAT TYPE EKPO-AEDAT,

    MATNR TYPE EKPO-MATNR,

    MENGE TYPE EKPO-MENGE,

    MEINS TYPE EKPO-MEINS,

    NETPR TYPE EKPO-NETPR,

    PEINH TYPE EKPO-PEINH,

    END OF TY_EKKO.

    DATA: IT_EKKO TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,

    IT_EKPO TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,

    IT_EMPTYTAB TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,

    WA_EKKO TYPE TY_EKKO,

    WA_EKPO TYPE TY_EKKO.

    DATA: OK_CODE LIKE SY-UCOMM, "OK-Code

    SAVE_OK LIKE SY-UCOMM.

    *ALV data declarations

    DATA: FIELDCATALOG TYPE LVC_T_FCAT WITH HEADER LINE.

    DATA: GD_FIELDCAT TYPE LVC_T_FCAT,

    GD_TAB_GROUP TYPE SLIS_T_SP_GROUP_ALV,

    GD_LAYOUT TYPE SLIS_LAYOUT_ALV.

    *ALVtree data declarations

    CLASS CL_GUI_COLUMN_TREE DEFINITION LOAD.

    CLASS CL_GUI_CFW DEFINITION LOAD.

    DATA: GD_TREE TYPE REF TO CL_GUI_ALV_TREE,

    GD_HIERARCHY_HEADER TYPE TREEV_HHDR,

    GD_REPORT_TITLE TYPE SLIS_T_LISTHEADER,

    GD_LOGO TYPE SDYDO_VALUE,

    GD_VARIANT TYPE DISVARIANT.

    *Create container for alv-tree

    DATA: GD_TREE_CONTAINER_NAME(30) TYPE C,

    GD_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

    ************************************************************************

    *Includes

    *INCLUDE ZDEMO_ALVTREEO01. "Screen PBO Modules

    *INCLUDE ZDEMO_ALVTREEI01. "Screen PAI Modules

    *INCLUDE ZDEMO_ALVTREEF01. "ABAP Subroutines(FORMS)

    ************************************************************************

    *Start-of-selection.

    START-OF-SELECTION.

    • ALVtree setup data

    PERFORM DATA_RETRIEVAL.

    PERFORM BUILD_FIELDCATALOG.

    PERFORM BUILD_LAYOUT.

    PERFORM BUILD_HIERARCHY_HEADER CHANGING GD_HIERARCHY_HEADER.

    PERFORM BUILD_REPORT_TITLE USING GD_REPORT_TITLE GD_LOGO.

    PERFORM BUILD_VARIANT.

    • Display ALVtree report

    • CALL SCREEN 100.

    &----


    *& Form data_retrieval

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM DATA_RETRIEVAL .

    SELECT EBELN

    UP TO 10 ROWS

    FROM EKKO

    INTO CORRESPONDING FIELDS OF TABLE IT_EKKO.

    LOOP AT IT_EKKO INTO WA_EKKO.

    SELECT EBELN EBELP STATU AEDAT MATNR MENGE MEINS NETPR PEINH

    FROM EKPO

    APPENDING TABLE IT_EKPO

    WHERE EBELN EQ WA_EKKO-EBELN.

    ENDLOOP.

    ENDFORM. " data_retrieval

    &----


    *& Form build_fieldcatalog

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM BUILD_FIELDCATALOG .

    • Please not there are a number of differences between the structure of

    • ALVtree fieldcatalogs and ALVgrid fieldcatalogs.

    • For example the field seltext_m is replace by scrtext_m in ALVtree.

    FIELDCATALOG-FIELDNAME = 'EBELN'. "Field name in itab

    FIELDCATALOG-SCRTEXT_M = 'Purchase Order'. "Column text

    FIELDCATALOG-COL_POS = 0. "Column position

    FIELDCATALOG-OUTPUTLEN = 15. "Column width

    FIELDCATALOG-EMPHASIZE = 'X'. "Emphasize (X or SPACE)

    FIELDCATALOG-KEY = 'X'. "Key Field? (X or SPACE)

    • fieldcatalog-do_sum = 'X'. "Sum Column?

    • fieldcatalog-no_zero = 'X'. "Don't display if zero

    APPEND FIELDCATALOG TO GD_FIELDCAT.

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'EBELP'.

    FIELDCATALOG-SCRTEXT_M = 'PO Iten'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 1.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'STATU'.

    FIELDCATALOG-SCRTEXT_M = 'Status'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 2.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'AEDAT'.

    FIELDCATALOG-SCRTEXT_M = 'Item change date'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 3.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'MATNR'.

    FIELDCATALOG-SCRTEXT_M = 'Material Number'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 4.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'MENGE'.

    FIELDCATALOG-SCRTEXT_M = 'PO quantity'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 5.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'MEINS'.

    FIELDCATALOG-SCRTEXT_M = 'Order Unit'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 6.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'NETPR'.

    FIELDCATALOG-SCRTEXT_M = 'Net Price'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 7.

    FIELDCATALOG-DATATYPE = 'CURR'.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'PEINH'.

    FIELDCATALOG-SCRTEXT_M = 'Price Unit'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 8.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    ENDFORM. " build_fieldcatalog

    &----


    *& Form build_layout

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM BUILD_LAYOUT .

    GD_LAYOUT-NO_INPUT = 'X'.

    GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

    GD_LAYOUT-TOTALS_TEXT = 'Totals'(201).

    • gd_layout-totals_only = 'X'.

    • gd_layout-f2code = 'DISP'. "Sets fcode for when double

    • "click(press f2)

    • gd_layout-zebra = 'X'.

    • gd_layout-group_change_edit = 'X'.

    • gd_layout-header_text = 'helllllo'

    ENDFORM. " build_layout

    &----


    *& Form build_hierarchy_header

    &----


    • text

    ----


    • <--P_GD_HIERARCHY_HEADER text

    ----


    FORM BUILD_HIERARCHY_HEADER CHANGING

    P_HIERARCHY_HEADER TYPE TREEV_HHDR.

    P_HIERARCHY_HEADER-HEADING = 'Hierarchy Header'(013).

    P_HIERARCHY_HEADER-TOOLTIP = 'This is the Hierarchy Header !'(014).

    P_HIERARCHY_HEADER-WIDTH = 30.

    P_HIERARCHY_HEADER-WIDTH_PIX = ''.

    ENDFORM. " build_hierarchy_header

    &----


    *& Form build_report_title

    &----


    • text

    ----


    • -->P_GD_REPORT_TITLE text

    • -->P_GD_LOGO text

    ----


    FORM BUILD_REPORT_TITLE USING PT_REPORT_TITLE TYPE SLIS_T_LISTHEADER

    P_GD_LOGO TYPE SDYDO_VALUE.

    DATA: LS_LINE TYPE SLIS_LISTHEADER,

    LD_DATE(10) TYPE C.

    • List Heading Line(TYPE H)

    CLEAR LS_LINE.

    LS_LINE-TYP = 'H'.

    • ls_line-key "Not Used For This Type(H)

    LS_LINE-INFO = 'PO ALVTree Display'.

    APPEND LS_LINE TO PT_REPORT_TITLE.

    • Status Line(TYPE S)

    LD_DATE(2) = SY-DATUM+6(2).

    LD_DATE+2(1) = '/'.

    LD_DATE3(2) = SY-DATUM4(2).

    LD_DATE+5(1) = '/'.

    LD_DATE+6(4) = SY-DATUM(4).

    LS_LINE-TYP = 'S'.

    LS_LINE-KEY = 'Date'.

    LS_LINE-INFO = LD_DATE.

    APPEND LS_LINE TO PT_REPORT_TITLE.

    • Action Line(TYPE A)

    CLEAR LS_LINE.

    LS_LINE-TYP = 'A'.

    CONCATENATE 'Report: ' SY-REPID INTO LS_LINE-INFO SEPARATED BY SPACE.

    APPEND LS_LINE TO PT_REPORT_TITLE.

    ENDFORM. " build_report_title

    &----


    *& Form build_variant

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM BUILD_VARIANT .

    • Set repid for storing variants

    GD_VARIANT-REPORT = SY-REPID.

    ENDFORM. " build_variant

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      hi,

      try this

      TYPE-POOLS : slis.

      TABLES : mseg.

      DATA : BEGIN OF itab_head OCCURS 0,

      mat LIKE mseg-matnr,

      • matnr LIKE mseg-matnr,

      werks LIKE mseg-werks,

      END OF itab_head.

      DATA : BEGIN OF itab_item OCCURS 0,

      • mat LIKE mseg-matnr,

      matnr LIKE mseg-matnr,

      werks LIKE mseg-werks,

      mblnr LIKE mseg-mblnr,

      menge LIKE mseg-menge,

      END OF itab_item.

      DATA : t_fcat TYPE slis_t_fieldcat_alv,

      key_info TYPE slis_keyinfo_alv,

      t_eve TYPE slis_t_event,

      gt_subtot TYPE slis_t_sortinfo_alv,

      subtot LIKE LINE OF gt_subtot,

      t_listhead TYPE slis_t_listheader,

      st_line TYPE slis_listheader.

      DATA : lin_no TYPE i.

      DATA : t_mtdoc LIKE mseg-mblnr.

      SELECT-OPTIONS : mat FOR mseg-matnr.

      INITIALIZATION.

      PERFORM build_cat USING t_fcat.

      PERFORM build_eve.

      START-OF-SELECTION.

      PERFORM get_data.

      PERFORM dis_data.

      &----


      *& Form build_cat

      &----


      • text

      ----


      • -->TEMP_FCAT text

      ----


      FORM build_cat USING temp_fcat TYPE slis_t_fieldcat_alv.

      DATA : wa_fcat TYPE slis_fieldcat_alv.

      wa_fcat-tabname = 'ITAB_HEAD'.

      wa_fcat-fieldname = 'MAT'.

      wa_fcat-seltext_m = 'Material'.

      APPEND wa_fcat TO temp_fcat.

      CLEAR wa_fcat.

      wa_fcat-tabname = 'ITAB_HEAD'.

      wa_fcat-fieldname = 'WERKS'.

      wa_fcat-seltext_m = 'Plant'.

      APPEND wa_fcat TO temp_fcat.

      CLEAR wa_fcat.

      wa_fcat-tabname = 'ITAB_ITEM'.

      wa_fcat-fieldname = 'MBLNR'.

      wa_fcat-seltext_m = 'Material Doc.'.

      APPEND wa_fcat TO temp_fcat.

      CLEAR wa_fcat.

      wa_fcat-tabname = 'ITAB_ITEM'.

      wa_fcat-fieldname = 'MENGE'.

      wa_fcat-seltext_m = 'Quantity'.

      • wa_fcat-edit = 'X'.

      • wa_fcat-input = 'X'.

      wa_fcat-do_sum = 'Y'.

      APPEND wa_fcat TO temp_fcat.

      CLEAR wa_fcat.

      subtot-spos = 1.

      subtot-fieldname = 'MAT'.

      subtot-tabname = 'ITAB_HEAD'.

      subtot-up = 'X'.

      subtot-group = 'X'.

      subtot-subtot = 'X'.

      subtot-expa = 'X'.

      APPEND subtot TO gt_subtot.

      ENDFORM. "build_cat

      &----


      *& Form build_eve

      &----


      • text

      ----


      FORM build_eve.

      DATA : wa_eve TYPE slis_alv_event.

      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

      EXPORTING

      i_list_type = 0

      IMPORTING

      et_events = t_eve

      • 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 t_eve INTO wa_eve WITH KEY name = 'TOP_OF_PAGE'.

      IF sy-subrc = 0.

      wa_eve-form = 'TOP_OF_PAGE'.

      MODIFY t_eve FROM wa_eve INDEX sy-tabix.

      ENDIF.

      ENDFORM. "build_eve

      &----


      *& Form get_data

      &----


      • text

      ----


      FORM get_data.

      SELECT matnr werks mblnr menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE itab_item

      WHERE matnr IN mat.

      ENDFORM. "get_data

      &----


      *& Form dis_data

      &----


      • text

      ----


      FORM dis_data.

      key_info-header01 = 'MAT'.

      key_info-item01 = 'MATNR'.

      key_info-header02 = 'WERKS'.

      key_info-item02 = 'WERKS'.

      REFRESH itab_head.

      LOOP AT itab_item.

      ON CHANGE OF itab_item-matnr OR itab_item-werks.

      MOVE-CORRESPONDING itab_item TO itab_head.

      itab_head-mat = itab_item-matnr.

      APPEND itab_head.

      ENDON.

      ENDLOOP.

      CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

      EXPORTING

      i_callback_program = 'ZALV_PRDS'

      it_fieldcat = t_fcat

      it_sort = gt_subtot

      it_events = t_eve[]

      i_tabname_header = 'ITAB_HEAD'

      i_tabname_item = 'ITAB_ITEM'

      is_keyinfo = key_info

      TABLES

      t_outtab_header = itab_head

      t_outtab_item = itab_item

      • 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. "dis_data

      &----


      *& Form top_of_page

      &----


      • text

      ----


      FORM top_of_page.

      CLEAR st_line.

      st_line-typ = 'H'.

      st_line-info = 'Data'.

      APPEND st_line TO t_listhead.

      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

      EXPORTING

      it_list_commentary = t_listhead

      • I_LOGO =

      • I_END_OF_LIST_GRID =

      • I_ALV_FORM =

      .

      ENDFORM. "top_of_page

      reward if usefull.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.