Skip to Content
avatar image
Former Member

displaying only subtotals and grand totals in alv

hi,

Is it possible to show only subtotals and grand-totals of fields in alv report.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Sep 23, 2008 at 11:01 AM

    I'm not sure what you are trying to do. Yes, you can set it up so only certain summarization levels of the ALV will display.

    Click on the subtotal button drop down. From there, select drilldown sum level. Then you can set up what level will display on the screen.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 23, 2008 at 11:19 AM

    Yes, it is possible you have to use control break events in your logic and pass that values to final table.

    Rajneesh Gupta

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 23, 2008 at 11:44 AM
    *&---------------------------------------------------------------------*
    *& MONTHLY SALES REVENUE FOR  DOMESTIC GOODS
    *& FBL3N                                                             *
    *&---------------------------------------------------------------------*
    *& REPORT TO DISPLAY THE MONTHLY WISE SALES REVENUE
    *& DATE : 11.08.2008                                                   *
    *& DONE BY :  MUTHUMAHARAJA                     *
    *& This Program will fetch the details of the monthly sales revenue   *
    *& for the domestic goods based on the G/L account number.
    *&
    *& Tax calculations are excluded as per clients requirement            *
    *&---------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *& HEADER DETAILS HAS BEEN GIVEN IN THE FORM TOP  WHICH CONTAINS THE   *
    *& HEADER INFORMATIONS , THE COMMENTED FIELDS CAN BE USED IN NEED.     *
    *&---------------------------------------------------------------------*
    
    REPORT  ZMONTHLY_REVENUE5.
    
    TABLES : BSIS.
    TABLES : T001. "COMPANY CODES
    
    TYPE-POOLS : SLIS.
    *&---------------------------------------------------------------------*
    *&      structure declaration  - BSIS
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    TYPES : BEGIN OF ST_BSIS,
            BUKRS TYPE BSIS-BUKRS,
            HKONT TYPE BSIS-HKONT,
            AUGDT TYPE BSIS-AUGDT,
            BELNR TYPE BSIS-BELNR,
            BUDAT TYPE BSIS-BUDAT,
            BLDAT TYPE BSIS-BLDAT,
            WAERS TYPE BSIS-WAERS,
            MWSKZ TYPE BSIS-MWSKZ,
            SHKZG TYPE BSIS-SHKZG,
            DMBTR TYPE BSIS-DMBTR,
            DMBTR1(16) TYPE P,
            DMBTR2(16) TYPE P,
            DMBTR3(16) TYPE P,
            END OF ST_BSIS.
    
    *&---------------------------------------------------------------------*
    *&      passing data from structure - bsis to final structure
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    TYPES : BEGIN OF ST_FINAL,
            BUKRS TYPE BSIS-BUKRS,
            HKONT TYPE BSIS-HKONT,
            AUGDT TYPE BSIS-AUGDT,
            BELNR TYPE BSIS-BELNR,
            BUDAT TYPE BSIS-BUDAT,
            BLDAT TYPE BSIS-BLDAT,
            WAERS TYPE BSIS-WAERS,
            MWSKZ TYPE BSIS-MWSKZ,
            SHKZG TYPE BSIS-SHKZG,
            DMBTR TYPE BSIS-DMBTR,
            DMBTR1(16) TYPE P,
            DMBTR2(16) TYPE P,
            DMBTR3(16) TYPE P,
            DATE TYPE BSIS-BLDAT,
            L_LTEXT TYPE T247-LTX,
            S_DATE TYPE STRING,
            YEAR(6) TYPE C,
            DAY(4) TYPE C,
            MONTH(2) TYPE C,
            END OF ST_FINAL.
    
    types : begin of ty_t001,
              bukrs type t001-bukrs,
              butxt type t001-butxt,
              adrnr type t001-adrnr,
            end of ty_t001.
    DATA : COMP(50) TYPE C.
    
    *&---------------------------------------------------------------------*
    *&      internal table and work area declaration
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    DATA : ITAB_BSIS TYPE TABLE OF ST_BSIS,
           WA_BSIS TYPE ST_BSIS,
           ITAB_FINAL TYPE TABLE OF ST_FINAL,
           WA_FINAL TYPE ST_FINAL.
    *&---------------------------------------------------------------------*
    *&      ALV declaration
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    
    DATA : SA_LAYOUT TYPE SLIS_LAYOUT_ALV,
           SAFIELD_H TYPE SLIS_FIELDCAT_ALV,
           SAFIELD_I TYPE SLIS_T_FIELDCAT_ALV,
           SALIST_I TYPE SLIS_T_LISTHEADER,
           SALIST_H TYPE SLIS_LISTHEADER,
           SASORT_H TYPE SLIS_SORTINFO_ALV,
           SASORT_I TYPE SLIS_T_SORTINFO_ALV,
           IT_EVENTS TYPE SLIS_T_EVENT,
           WA_EVENTS TYPE SLIS_ALV_EVENT,
           SATOT_H TYPE SLIS_LINEINFO.
    
    data : lt_t001 type table of ty_t001 initial size 0,
           wa_t001 type ty_t001.
    
    *&---------------------------------------------------------------------*
    *&      selection screen
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS :  CODE FOR BSIS-BUKRS,
                      GLNO FOR BSIS-HKONT NO INTERVALS no-extension OBLIGATORY,
                      PERIOD FOR BSIS-BUDAT.
    SELECTION-SCREEN : END OF BLOCK B1.
    
    *&---------------------------------------------------------------------*
    *&     internal subroutines
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    PERFORM SELECT.
    PERFORM LAYOUT.
    PERFORM TOPHEADER.
    PERFORM SORT.
    PERFORM FIELDCAT.
    PERFORM DISPLAY.
    
    *&---------------------------------------------------------------------*
    *&      Form  SELECT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM SELECT .
    
      select distinct
             bukrs
             butxt
             adrnr from t001 into corresponding fields of table lt_t001 where bukrs in CODE.
    
    
      SELECT   BUKRS
               HKONT
               AUGDT
               BELNR
               BUDAT
               BLDAT
               WAERS
               MWSKZ
               SHKZG
               DMBTR FROM BSIS INTO TABLE ITAB_BSIS
               WHERE BUKRS IN CODE
               AND   HKONT IN GLNO
               AND   BUDAT IN PERIOD.
    
      LOOP AT ITAB_BSIS INTO WA_BSIS.
        WA_FINAL-BUKRS = WA_BSIS-BUKRS.
        WA_FINAL-HKONT = WA_BSIS-HKONT.
        WA_FINAL-AUGDT = WA_BSIS-AUGDT.
        WA_FINAL-BELNR = WA_BSIS-BELNR.
        WA_FINAL-BUDAT = WA_BSIS-BUDAT.
        WA_FINAL-BLDAT = WA_BSIS-BLDAT.
        WA_FINAL-WAERS = WA_BSIS-WAERS.
        WA_FINAL-MWSKZ = WA_BSIS-MWSKZ.
        WA_FINAL-SHKZG = WA_BSIS-SHKZG.
        WA_FINAL-DMBTR = WA_BSIS-DMBTR.
        WA_FINAL-DATE = WA_BSIS-BLDAT.
        WA_FINAL-YEAR = WA_FINAL-DATE(6).
        PERFORM DATE.
        APPEND WA_FINAL TO ITAB_FINAL.
      ENDLOOP.
    *&---------------------------------------------------------------------*
    *&      calculating credit/debit indicator
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
      LOOP AT ITAB_FINAL INTO WA_FINAL.
        IF WA_FINAL-SHKZG = 'H'.
          WA_FINAL-DMBTR = 0 - WA_FINAL-DMBTR.
          WA_FINAL-DMBTR1 = WA_FINAL-DMBTR.
        ELSE.
          WA_FINAL-SHKZG = 'S'.
          WA_FINAL-DMBTR =  0 - WA_FINAL-DMBTR.
          WA_FINAL-DMBTR2 = WA_FINAL-DMBTR.
        ENDIF.
        WA_FINAL-DMBTR3 = WA_FINAL-DMBTR1 - WA_FINAL-DMBTR2.
        WA_FINAL-DMBTR = WA_FINAL-DMBTR3.
        MODIFY ITAB_FINAL FROM WA_FINAL.
      ENDLOOP.
    
    ENDFORM.                    " SELECT
    *&---------------------------------------------------------------------*
    *&      Form  LAYOUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM LAYOUT .
    
      SA_LAYOUT-ZEBRA = 'X'.
      SA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    
    ENDFORM.                    " LAYOUT
    
    *&---------------------------------------------------------------------*
    *&      Form  TOPHEADER
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM TOPHEADER .
    
      CLEAR SALIST_H.
      CLEAR SALIST_I.
    
      READ TABLE LT_T001 INTO WA_T001  INDEX 1.
    
      SALIST_H-TYP = 'H'.
      CONCATENATE '' WA_T001-BUTXT INTO COMP.
      SALIST_H-INFO = COMP.
      APPEND SALIST_H TO SALIST_I.
      CLEAR SALIST_H.
    
    
      DATA : TEXT(100) TYPE C.
      CONCATENATE 'COMPANY CODE:' WA_FINAL-BUKRS  INTO TEXT.
      SALIST_H-TYP = 'S'.
      SALIST_H-INFO = TEXT.
      APPEND SALIST_H TO SALIST_I.
      CLEAR SALIST_H.
    
      DATA : TEXT1(100) TYPE C.
      CONCATENATE 'CURRENCY KEY:' WA_FINAL-WAERS INTO TEXT1.
      SALIST_H-TYP = 'S'.
      SALIST_H-INFO = TEXT1.
      APPEND SALIST_H TO SALIST_I.
      CLEAR SALIST_H.
    
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = SALIST_I
          I_LOGO                   = 'TRI'
    *   I_END_OF_LIST_GRID       =
    *   I_ALV_FORM               =
                .
      CLEAR SALIST_H.
    
    ENDFORM.                    " TOPHEADER
    
    *&---------------------------------------------------------------------*
    *&      Form  SORT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM SORT .
      SASORT_H-SPOS = '1'.
      SASORT_H-FIELDNAME = 'YEAR'.
      SASORT_H-GROUP = 'X'.
      SASORT_H-SUBTOT = 'X'.
      SASORT_H-TABNAME = 'WA_FINAL'.
      APPEND SASORT_H TO SASORT_I.
    
      SASORT_H-SPOS = '2'.
      SASORT_H-FIELDNAME = 'S_DATE'.
      SASORT_H-GROUP = 'X'.
      SASORT_H-SUBTOT = 'X'.
      sasort_h-up = 'X'.
      SASORT_H-TABNAME = 'WA_FINAL'.
      APPEND SASORT_H TO SASORT_I.
    
    
    ENDFORM.                    " SORT
    
    *&---------------------------------------------------------------------*
    *&      Form  FIELDCAT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FIELDCAT .
    
      CLEAR : SAFIELD_H,
              SAFIELD_I.
    
    
      SAFIELD_H-FIELDNAME = 'YEAR'        .
      SAFIELD_H-SELTEXT_L = 'YEAR'.
      SAFIELD_H-OUTPUTLEN = 26.
      SAFIELD_H-DO_SUM = 'X'.
      SAFIELD_H-NO_OUT = 'X'.
      SAFIELD_H-TABNAME = 'WA_FINAL'.
      APPEND SAFIELD_H TO SAFIELD_I.
      CLEAR SAFIELD_H.
    
      SAFIELD_H-FIELDNAME = 'S_DATE'        .
      SAFIELD_H-SELTEXT_L = 'MONTH'.
      SAFIELD_H-OUTPUTLEN = 26.
    *SAFIELD_H-DO_SUM = 'X'.
    *SAFIELD_H-NO_OUT = 'X'.
      SAFIELD_H-TABNAME = 'WA_FINAL'.
      APPEND SAFIELD_H TO SAFIELD_I.
      CLEAR SAFIELD_H.
    
      SAFIELD_H-FIELDNAME = 'BUKRS'        .
      SAFIELD_H-SELTEXT_L = 'COMPANY CODE'.
      sAFIELD_H-LZERO = 'X'.
      SAFIELD_H-OUTPUTLEN = 13.
      SAFIELD_H-NO_OUT = 'X'.
      SAFIELD_H-TABNAME = 'WA_FINAL'.
      APPEND SAFIELD_H TO SAFIELD_I.
      CLEAR SAFIELD_H.
    
      SAFIELD_H-FIELDNAME = 'BLDAT'        .
      SAFIELD_H-SELTEXT_L = 'DOCUMENT DATE IN THE DOCUMENT'.
      SAFIELD_H-OUTPUTLEN = 26.
      SAFIELD_H-TABNAME = 'WA_FINAL'.
      APPEND SAFIELD_H TO SAFIELD_I.
      CLEAR SAFIELD_H.
    
      SAFIELD_H-FIELDNAME = 'HKONT'        .
      SAFIELD_H-SELTEXT_L = 'G/L ACCOUNT NUMBER'.
      SAFIELD_H-OUTPUTLEN = 19.
      SAFIELD_H-NO_OUT = 'X'.
      SAFIELD_H-TABNAME = 'WA_FINAL'.
      APPEND SAFIELD_H TO SAFIELD_I.
      CLEAR SAFIELD_H.
    
      SAFIELD_H-FIELDNAME = 'BELNR'        .
      SAFIELD_H-SELTEXT_L = 'ACCOUNTING DOCUMENT NUMBER'.
      SAFIELD_H-OUTPUTLEN = 26.
      SAFIELD_H-TABNAME = 'WA_FINAL'.
      APPEND SAFIELD_H TO SAFIELD_I.
      CLEAR SAFIELD_H.
    
      SAFIELD_H-FIELDNAME = 'MWSKZ'        .
      SAFIELD_H-SELTEXT_L = 'SALES TAX CODE'.
      SAFIELD_H-OUTPUTLEN = 15.
      SAFIELD_H-TABNAME = 'WA_FINAL'.
      APPEND SAFIELD_H TO SAFIELD_I.
      CLEAR SAFIELD_H.
    
      SAFIELD_H-FIELDNAME = 'DMBTR'        .
      SAFIELD_H-SELTEXT_L = 'AMOUNT IN LOCAL CURRENCY'.
      SAFIELD_H-OUTPUTLEN = 24.
      SAFIELD_H-TABNAME = 'WA_FINAL'.
      SAFIELD_H-DO_SUM = 'X'.
      APPEND SAFIELD_H TO SAFIELD_I.
      CLEAR SAFIELD_H.
    
      SAFIELD_H-FIELDNAME = 'WAERS'        .
      SAFIELD_H-SELTEXT_L = 'CURRENCY KEY'.
      SAFIELD_H-OUTPUTLEN = 13.
      SAFIELD_H-NO_OUT = 'X'.
      SAFIELD_H-TABNAME = 'WA_FINAL'.
      APPEND SAFIELD_H TO SAFIELD_I.
      CLEAR SAFIELD_H.
    
    
      SAFIELD_H-FIELDNAME = 'AUGDT'        .
      SAFIELD_H-SELTEXT_L = 'CLEARING DATE'.
      SAFIELD_H-OUTPUTLEN = 13.
      SAFIELD_H-NO_OUT = 'X'.
      SAFIELD_H-TABNAME = 'WA_FINAL'.
      APPEND SAFIELD_H TO SAFIELD_I.
      CLEAR SAFIELD_H.
    
      SAFIELD_H-FIELDNAME = 'BUDAT'        .
      SAFIELD_H-SELTEXT_L = 'POSTING DATE IN THE DOCUMENT'.
      SAFIELD_H-OUTPUTLEN = 26.
      SAFIELD_H-DO_SUM = 'X'.
      SAFIELD_H-NO_OUT = 'X'.
      SAFIELD_H-TABNAME = 'WA_FINAL'.
      APPEND SAFIELD_H TO SAFIELD_I.
      CLEAR SAFIELD_H.
    
    ENDFORM.                    " FIELDCAT
    
    *&---------------------------------------------------------------------*
    *&      Form  DISPLAY
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM DISPLAY .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
         I_CALLBACK_PROGRAM                = SY-REPID
    *   I_CALLBACK_PF_STATUS_SET          = ' '
    *   I_CALLBACK_USER_COMMAND           = ' '
         I_CALLBACK_TOP_OF_PAGE            = 'TOPHEADER'
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = ' '
         I_GRID_TITLE                      = 'MONTH WISE SALES REVENUES'
    *   I_GRID_SETTINGS                   =
         IS_LAYOUT                         = SA_LAYOUT
         IT_FIELDCAT                       = SAFIELD_I
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
         IT_SORT                           = SASORT_I
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
    *   I_SAVE                            = ' '
    *   IS_VARIANT                        =
         IT_EVENTS                         = IT_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_FINAL.
    * 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
    
    
    
    *&---------------------------------------------------------------------*
    *&      Form  DATE
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM DATE .
    
      CALL FUNCTION 'HR_IN_GET_DATE_COMPONENTS'
        EXPORTING
          IDATE                               = WA_FINAL-DATE
       IMPORTING
         DAY                                 = wa_final-day
         MONTH                               = wa_final-month
         YEAR                                = wa_final-year
    *   STEXT                               =
         LTEXT                               = wa_final-l_ltext
    *   USERDATE                            =
    * EXCEPTIONS
    *   INPUT_DATE_IS_INITIAL               = 1
    *   TEXT_FOR_MONTH_NOT_MAINTAINED       = 2
    *   OTHERS                              = 3
                .
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    
      CONCATENATE wa_final-l_ltext '.' INTO wa_final-s_date.
    
    
    
    ENDFORM.                    " DATE
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 23, 2008 at 11:46 AM

    Hi anshul hope that code will help you for subtotals and grand totals.reward if useful.

    Add comment
    10|10000 characters needed characters exceeded