Alv subtotal

HI all,
I need subtotal based on 2 fields one is matnr and the other one is vben but i am getting subtotals based on only matnr but not on vbeln what could be the problem?
it_sort-fieldname = 'VBELN'.
IT_SORT-TABNAME = 'GI_FINAL'.
IT-SORT-SPOS = '1'.
IT_SORT-SUBTOT = 'X'.
IT-SORT-UP = 'X'.
APPEND IT-SORT.
it_sort-fieldname = 'MATNR'.
IT_SORT-TABNAME = 'GI_FINAL'.
IT-SORT-SPOS = '1'.
IT_SORT-SUBTOT = 'X'.
IT-SORT-UP = 'X'.
APPEND IT-SORT.
Please refer the above code and suggest me
what exact purpose of spos here?
Thanks&Regards
mahsh

Hi,
Herewith i am sending the sample coding for the ALV SUBTOTAL report.
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
Hope it will helps to u.
Thanks,
Shankar

Similar Messages

  • A question about ALV subtotal

    Hello Expert,
    I have a question about ALV subtotal
    In my ALV output, there are three columns: SalesOrder, Item, Sales Volumn. Suppose there are following data in the ALV output
    SalesOrder   Item   Volumn
    123              10      100.00
    123              20      300.00
    456              10      200.00
    456              20      500.00
    What I want in the ALV outpu is as below:
    SalesOrder   Item   Volumn
    123              10      100.00
    123              20      300.00
                     subtotal  400.00
    456              10      200.00
    456              20      500.00
                     Subtotal 700.00
    Total                       1100.00
    Is this possible, and how can I achieve that result?
    Thanks & Regards, Johnny

    You can use sortinfo structure of ALV.
      Data:GT_SORT TYPE slis_t_sortinfo_alv.
      GTT_SORT-FIELDNAME = 'VBELN'.
      GTT_SORT-UP = 'X'.
      GTT_SORT-SUBTOT = 'X'.
      APPEND GTT_SORT TO GT_SORT.

  • ALV subtotal & grand total

    Hi experts,
    I have a ALV display which displays subtotals & grandtotals. I only want the subtotals, How can I supress the grantotal?
    ex.
    DOC num 50003859
    200 USD
    300 USD
    subtotal = 500
    DOC num 50005469
    600 USD
    subtotal = 600
    Grandtotal = 1100 <- I dont want this to show.

    Hi,
    You can do as below for Subtotal and suppress the grand total.
    data :gt_sort TYPE slis_t_sortinfo_alv,
    DATA: ls_sort TYPE slis_sortinfo_alv.
    CLEAR ls_sort.
    ls_sort-fieldname = 'BELNR'.
    ls_sort-up = 'X'.
    ls_sort-subtot = 'X'.
    APPEND ls_sort TO gt_sort.
    And pass gt_sort to grid display export parameter IT_sort.
    And to suppress the grandtotal.
    in the layout use the below code :
    wa_layout-no_totalline = 'X'.
    Thanks,
    Sriram Ponna.

  • Calculation in ALV subtotal field

    Hi,
    I have a requirement to display the percentage field in the subtotal and total field in ALV display.
    ie, I have 3 fields, say, A, B and percent. (percent = A/B * 100)
    A              B                     percent
    10             10                     100
    5               10                     50
    15              20                     75
    Currently I am getting like below:-
    A              B                     percent
    10             10                     100
    5               10                     50
    15              20                     150
    Is there any way to display the proper percentage in subtotal field in ALV?
    Thanks in advance.
    Regards,
    Arun Mohan

    Hi,
    As you have mentioned in the question
    A B percent
    10 10 100
    5 10 50
    15 20 75
    Here you can divide the percentage field by the number of rows you have in the report. E.g here you have 2 rows, so sum is 150/2 = 75
    HTH
    Regards,
    Dhruv Shah

  • In ALV Subtotal line with Color

    Hi,
    I am working on ALV Grid and the output and all are ok.
    Only the problem is User expecting Subtotal in row should be in color.
    Can you pls advise me.
    Thank You,
    Sri.

    Hi,
    plz refer this link.
    Color the sub-total row in an alv-grid
    saptechnical/Tutorials/ALV/Subtotals/Define.htm
    sap.niraj.tripod.com/id64.html
    Regards,
    Pravin

  • Alv subtotal calculation

    hi gurus,
    my query is :
    i have to calculate rate per min , p3 =  p1/p2 in subtotal column.but in the scenario given below it is just adding all the rpm and giving the total = 0.56 ,
    but -3612/13940 = 0.26 is correct.
    EX:
      amt(P1)     minutes (p2)   rpm(rate per min)(p3)
    9,500.00-       5233             1.82-
    1,500.00        3235              0.46
    4,388.00        5472              0.80
    3,612.00-      13940              0.56-   -
    subtotal of above rows
    so i want the subtotal value of p3 as p1/p2  and not just sum
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Apr 21, 2008 5:47 PM

    This you can do using the Subtotal_text event of alv.
    Check the sample code below..
    in the event you will have the SUB TOTAL ROW INFORMATION, now divide the P1/P2  and get the P3 value.
    modify the P3 value with value calculated , this will show the Changed value.
    For information:-
    you can find 2 programs one using class, one using Grid Function.
    Re: SubTotal Text in ALV?

  • ALV SUBTOTAL (Change at summation Level)

    Hi All,
    I need to add some code at the subtotal level of the ALV report output. My output shound look something like this.
         FLD1     FLD2     FLD3     FLD4
         A1     B1     1     AA
         A1     B1     2     BB
    <i><b>Sum     A1     B1     3     C</b></i>
         A1     B2     11     D1
         A1     B2     22     D2
    <i><b>Sum     A1     B2     33     CD</b></i>
         B1     B1     1     D1
    <i><b>Sum     B1     B1     1     CCD</b></i>
         B1     B2     5     D1     
    <i><b>Sum     B1     B2     5     CCDD</b></i>
    I should be able insert a summation level into the output so that the FLD4 can be changed based on the total of FLD3 at the summation level.
    Please let me know if this is a possibility atleast.
    Thanks in advance..!
    Jr.
    Message was edited by: Jr Abaper

    You need to build a sort table with feild you want to have for subtoal by setting one of attributes subtot    = 'X'.
    Data:
          dt_sortcat TYPE slis_t_sortinfo_alv,    "table - sort table
           ds_sortcat LIKE LINE OF dt_sortcat,     "structure-sort structure
      ds_sortcat-spos      = '1'.
      ds_sortcat-fieldname = 'VBELN'.
      ds_sortcat-tabname   = 'IT_DATA'.
      ds_sortcat-up        = 'X'.
      ds_sortcat-down      = space.
      ds_sortcat-subtot    = 'X'.
      APPEND ds_sortcat TO dt_sortcat.
       ds_sortcat-spos      = '2'.
      ds_sortcat-fieldname = 'POSNR'.
      ds_sortcat-tabname   = 'IT_DATA'.
      ds_sortcat-up        = 'X'.
      ds_sortcat-down      = space.
      APPEND ds_sortcat TO dt_sortcat.
    and pass the sort table to the exporting parameter IT_SORT of the REUSE_ALV_GRID_DISPLAY function module.
    For Demo programs: Go to se38 and enter BCALV* and press F4 key you will get list of ALV demo programs
    Message was edited by: Sid

  • Shrinking the ALV subtotal icon

    Hi Experts
    I have developed Interactive Grid ALV. In  Basic list Subtotal is for 3 column.
    i wanted to display by default the Shrink format, then user will expand the details
    as per the requirement. i have seen this query is already posted by Shanthi  
    i have tried the same option. but it doesnt work. i have also tried COMP and
    EXPA fields slis_sorting_alv. but still not getting the shrink version.
    Kindly guide me for the same.
    Thanks
    Nishita

    Hi,
    I have tried this. But stil, the subtotal of every item gets displayed.  by default, the subtotal alone shoudl be displayed in the output.
    On expanding the icon, each item should get displayed.
    Pls tell me how to achieve the same in ALV GRID DISPLAY..

  • REGARDING alv sUBTOTAL

    hi friends,
    in alv grid display output on toolbar how to get button of Subtotal,Expand and Colapse
    pls,reply...........

    hi,
    try this.
    <b>DATA: gt_subtot TYPE slis_t_sortinfo_alv,
            subtot LIKE LINE OF gt_subtot.</b>
    subtot-spos = 1.
      subtot-fieldname = 'NAME1'.
      subtot-tabname = 'ITAB_HEAD'.
      subtot-up = 'X'.
      subtot-group = 'X'.
      subtot-subtot = 'X'.
      subtot-expa = 'X'.
      APPEND subtot TO gt_subtot.
      CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
        EXPORTING
          i_callback_program = 'ZRAW_COST'
          it_fieldcat        = fcat
         <b> it_sort            = gt_subtot</b>
          it_events          = eve
          i_tabname_header   = 'ITAB_HEAD'
          i_tabname_item     = 'ITAB_ITM'
          is_keyinfo         = alv_keyinfo
        TABLES
          t_outtab_header    = itab_head
          t_outtab_item      = itab_itm
        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.
    reward if useful.
    this is whole report for better understanding.
    REPORT  ZRAW_COST.
    TYPE-POOLS:slis.
    TABLES:mseg,
           lfa1,
           mkpf,
           ekpo,
           mara,
           j_1iexchdr,
           mbew.
    DATA:BEGIN OF itab_vend OCCURS 0,
          lifnr LIKE lfa1-lifnr,                      "Vendor Code
         END OF itab_vend.
    DATA:BEGIN OF itab_data OCCURS 0,
          lifnr LIKE mseg-lifnr,                      "Vendor Code
          mblnr LIKE mseg-mblnr,                      "Material Doc.
          charg LIKE mseg-charg,                      "Batch
          matnr LIKE mseg-matnr,                      "Material
          maktx LIKE makt-maktx,                      "Description
          menge LIKE mseg-menge,                      "Quantity
          dmbtr LIKE mseg-dmbtr,                      "Amount
          budat LIKE mkpf-budat,                      "G.R.Date
          xblnr LIKE mkpf-xblnr,                      "Delivery Note(Bill No.)
          frbnr LIKE mkpf-frbnr,                      "Bill of Lading(Bill Date)
          netpr LIKE ekpo-netpr,                      "Basic Rate
          matkl LIKE ekpo-matkl,                      "Material Group
         END OF itab_data.
    DATA:BEGIN OF itab_itm OCCURS 0,
          lifnr LIKE mseg-lifnr,                      "Vendor Code
          name1 LIKE lfa1-name1,                      "Vendor Name
          matkl LIKE ekpo-matkl,                      "Material Group
          wgbez LIKE t023t-wgbez,                     "Material Group Name
          mblnr LIKE mseg-mblnr,                      "Material Doc.
          matnr LIKE mseg-matnr,                      "Material
          maktx LIKE makt-maktx,                      "Description
          xblnr LIKE mkpf-xblnr,                      "Delivery Note(Bill No.)
          frbnr LIKE mkpf-frbnr,                      "Bill of lading(Bill Date)
          budat LIKE mkpf-budat,                      "G.R.Date
          exnum LIKE j_1iexchdr-exnum,                "Ex.Bill No.
          exdat LIKE j_1iexchdr-exdat,                "Ex.Bill Date
          charg LIKE mseg-charg,                      "Batch
          menge LIKE mseg-menge,                      "Quantity
          netpr LIKE ekpo-netpr,                      "Basic Rate
          verpr LIKE mbew-verpr,                      "Costing Rate
          dmbtr LIKE mseg-dmbtr,                      "Amount
         END OF itab_itm.
    DATA:BEGIN OF itab_head OCCURS 0,
          lifnr LIKE mseg-lifnr,                      "Vendor Code
          name1 LIKE lfa1-name1,                      "Vendor Name
          matkl LIKE ekpo-matkl,                      "Material Group
          wgbez LIKE t023t-wgbez,                     "Material Group Name
         END OF itab_head.
    DATA:fcat TYPE slis_t_fieldcat_alv,
         eve TYPE slis_t_event,
         alv_keyinfo  TYPE slis_keyinfo_alv,
         gt_subtot TYPE slis_t_sortinfo_alv,
         subtot LIKE LINE OF gt_subtot.
    DATA:ex_doc LIKE j_1iexchdr-exnum,
         ex_dat LIKE j_1iexchdr-exdat,
         mov_pr LIKE mbew-verpr,
         name LIKE lfa1-name1,
         gr_nm LIKE t023t-wgbez,
         t_mblnr LIKE mseg-mblnr,
         yr LIKE mseg-mjahr.
    DATA: BEGIN OF record OCCURS 0,
            act(003),
            rfd(003),
            matdoc(010),
            docyr(004),
          END OF record.
    DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
    SELECTION-SCREEN:BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:dt FOR mkpf-budat OBLIGATORY,
                   vend FOR lfa1-lifnr,
                   mat_gr FOR mara-matkl.
    SELECTION-SCREEN:END OF BLOCK blk1.
    INITIALIZATION.
      PERFORM build_cat USING fcat.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM dis_data.
    *&      Form  build_cat
          text
         -->T_FCAT     text
    FORM build_cat USING t_fcat TYPE slis_t_fieldcat_alv.
      DATA:wa_fcat TYPE slis_fieldcat_alv.
      wa_fcat-tabname = 'ITAB_HEAD'.
      wa_fcat-fieldname = 'NAME1'.
      wa_fcat-seltext_m = 'Vendor Name'.
      wa_fcat-outputlen = '30'.
    wa_fcat-just = 'C'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB_HEAD'.
      wa_fcat-fieldname = 'WGBEZ'.
      wa_fcat-seltext_m = 'Material Group Name'.
      wa_fcat-outputlen = '30'.
      wa_fcat-just = 'C'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB_ITM'.
      wa_fcat-fieldname = 'MBLNR'.
      wa_fcat-seltext_m = 'Material Doc.'.
      wa_fcat-outputlen = '15'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB_ITM'.
      wa_fcat-fieldname = 'MAKTX'.
      wa_fcat-seltext_m = 'Product Name'.
      wa_fcat-outputlen = '40'.
      wa_fcat-just = 'L'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB_ITM'.
      wa_fcat-fieldname = 'XBLNR'.
      wa_fcat-seltext_m = 'Bill.No.'.
      wa_fcat-just = 'C'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB_ITM'.
      wa_fcat-fieldname = 'FRBNR'.
      wa_fcat-seltext_m = 'Bill Date'.
      wa_fcat-just = 'C'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB_ITM'.
      wa_fcat-fieldname = 'BUDAT'.
      wa_fcat-seltext_m = 'G.R.Date'.
      wa_fcat-outputlen = '10'.
      wa_fcat-just = 'C'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB_ITM'.
      wa_fcat-fieldname = 'EXNUM'.
      wa_fcat-seltext_m = 'Ex.Bill.No.'.
      wa_fcat-just = 'C'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB_ITM'.
      wa_fcat-fieldname = 'EXDAT'.
      wa_fcat-seltext_m = 'Ex.Bill Date'.
      wa_fcat-just = 'C'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB_ITM'.
      wa_fcat-fieldname = 'CHARG'.
      wa_fcat-seltext_m = 'Batch'.
      wa_fcat-outputlen = '15'.
      wa_fcat-just = 'C'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB_ITM'.
      wa_fcat-fieldname = 'MENGE'.
      wa_fcat-seltext_m = 'Qty'.
      wa_fcat-do_sum = 'Y'.
      wa_fcat-outputlen = '15'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB_ITM'.
      wa_fcat-fieldname = 'NETPR'.
      wa_fcat-seltext_m = 'Basic Rate'.
      wa_fcat-do_sum = 'Y'.
      wa_fcat-outputlen = '12'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB_ITM'.
      wa_fcat-fieldname = 'VERPR'.
      wa_fcat-seltext_m = 'Costing Rate'.
      wa_fcat-do_sum = 'Y'.
      wa_fcat-outputlen = '12'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB_ITM'.
      wa_fcat-fieldname = 'DMBTR'.
      wa_fcat-seltext_m = 'Amount'.
      wa_fcat-do_sum = 'Y'.
      wa_fcat-outputlen = '15'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      subtot-spos = 1.
      subtot-fieldname = 'NAME1'.
      subtot-tabname = 'ITAB_HEAD'.
      subtot-up = 'X'.
      subtot-group = 'X'.
      subtot-subtot = 'X'.
      subtot-expa = 'X'.
      APPEND subtot TO gt_subtot.
      subtot-spos = 2.
      subtot-fieldname = 'WGBEZ'.
      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  get_data
          text
    FORM get_data.
      SELECT DISTINCT mseg~lifnr INTO CORRESPONDING FIELDS OF TABLE itab_vend
      FROM mseg INNER JOIN mkpf
      ON msegmblnr = mkpfmblnr
      WHERE mkpfbudat IN dt AND mseglifnr IN vend.
      LOOP AT itab_vend.
        SELECT mseglifnr msegmblnr msegmatnr maktmaktx msegcharg msegmenge msegdmbtr mkpfbudat  mkpfxblnr mkpffrbnr ekponetpr ekpomatkl
        INTO CORRESPONDING FIELDS OF TABLE itab_data
        FROM mseg INNER JOIN mkpf ON
        msegmblnr = mkpfmblnr
        INNER JOIN ekpo ON
        msegebeln = ekpoebeln AND msegmatnr = ekpomatnr
        INNER JOIN makt ON
        msegmatnr = maktmatnr
        WHERE mkpfbudat IN dt AND mseglifnr IN vend AND msegbwart = '101' AND msegebeln <> '' AND ekpo~matkl IN mat_gr.
      ENDLOOP.
      SORT itab_data BY lifnr matkl matnr mblnr.
      LOOP AT itab_data.
        CLEAR: ex_doc,ex_dat,mov_pr,name,gr_nm.
        MOVE-CORRESPONDING itab_data TO itab_itm.
        SELECT SINGLE name1 FROM lfa1 INTO name WHERE lifnr = itab_data-lifnr.
        SELECT SINGLE wgbez FROM t023t INTO gr_nm WHERE matkl = itab_data-matkl.
        SELECT SINGLE exnum exdat FROM j_1iexchdr INTO (ex_doc,ex_dat) WHERE rdoc = itab_data-mblnr.
        SELECT SINGLE verpr INTO mov_pr FROM mbew WHERE matnr = itab_data-matnr AND bwtar = itab_data-charg.
        itab_itm-exnum = ex_doc.
        itab_itm-exdat = ex_dat.
        itab_itm-verpr = mov_pr.
        itab_itm-name1 = name.
        itab_itm-wgbez = gr_nm.
        APPEND itab_itm.
      ENDLOOP.
      SORT itab_itm .  "BY lifnr matkl mblnr matnr charg.
      DELETE ADJACENT DUPLICATES FROM itab_itm.
    ENDFORM.                    "get_data
    *&      Form  dis_data
          text
    FORM dis_data.
      alv_keyinfo-header01 = 'LIFNR'.
      alv_keyinfo-item01   = 'LIFNR'.
      alv_keyinfo-header02 = 'MATKL'.
      alv_keyinfo-item02   = 'MATKL'.
      REFRESH itab_head.
      LOOP AT itab_itm.
        ON CHANGE OF itab_itm-lifnr OR itab_itm-matkl .
          MOVE-CORRESPONDING itab_itm TO itab_head.
          APPEND itab_head.
        ENDON.
      ENDLOOP.
      CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
        EXPORTING
          i_callback_program = 'ZRAW_COST'
          it_fieldcat        = fcat
          it_sort            = gt_subtot
          i_tabname_header   = 'ITAB_HEAD'
          i_tabname_item     = 'ITAB_ITM'
          is_keyinfo         = alv_keyinfo
        TABLES
          t_outtab_header    = itab_head
          t_outtab_item      = itab_itm
        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

  • ALV subtotal for non numeric

    hi could you pls tell me how to do the subtotal for non-numeric fields in ALV.

    see the following example
    REPORT z_demo_alv_total.
    TYPES :
      BEGIN OF ty_vbak,
        vkorg TYPE vbak-vkorg,             " Sales organization
        kunnr TYPE vbak-kunnr,             " Sold-to party
        vbeln TYPE vbak-vbeln,             " Sales document
        netwr TYPE vbak-netwr,             " Net Value of the Sales Order
        waerk TYPE vbak-waerk,             " Document currency
      END OF ty_vbak.
    DATA:
      vbak    TYPE vbak,
      gt_vbak TYPE TABLE OF ty_vbak.
    SELECT-OPTIONS :
      s_vkorg FOR vbak-vkorg,              " Sales organization
      s_kunnr FOR vbak-kunnr,              " Sold-to party
      s_vbeln FOR vbak-vbeln.              " Sales document
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
    PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    INITIALIZATION.
      v_1 = 'Maximum of records to read'.
    START-OF-SELECTION.
      PERFORM f_read_data.
      PERFORM f_display_data.
    *      Form  f_read_data
    FORM f_read_data.
      SELECT vkorg kunnr vbeln netwr waerk
          UP TO p_max ROWS
        INTO TABLE gt_vbak
        FROM vbak
       WHERE kunnr IN s_kunnr
         AND vbeln IN s_vbeln
         AND vkorg IN s_vkorg.
    ENDFORM.                               " F_READ_DATA
    *      Form  f_display_data
    FORM f_display_data.
      TYPE-POOLS: slis.                    " ALV Global types
      DEFINE m_fieldcat.
        add 1 to ls_fieldcat-col_pos.
        ls_fieldcat-fieldname   = &1.
        ls_fieldcat-ref_tabname = 'VBAK'.
        ls_fieldcat-do_sum      = &2.
        ls_fieldcat-cfieldname  = &3.
        append ls_fieldcat to lt_fieldcat.
      END-OF-DEFINITION.
      DEFINE m_sort.
        add 1 to ls_sort-spos.
        ls_sort-fieldname = &1.
        ls_sort-up        = 'X'.
        ls_sort-subtot    = &2.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
      DATA:
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv,
        lt_sort     TYPE slis_t_sortinfo_alv,
        ls_sort     TYPE slis_sortinfo_alv,
        ls_layout   TYPE slis_layout_alv.
      m_fieldcat 'VKORG' ''  ''.
      m_fieldcat 'KUNNR' ''  ''.
      m_fieldcat 'VBELN' ''  ''.
      m_fieldcat 'NETWR' 'X' 'WAERK'.
      m_fieldcat 'WAERK' ''  ''.
      m_sort 'VKORG' 'X'.                  " Sort by vkorg and subtotal
      m_sort 'KUNNR' 'X'.                  " Sort by kunnr and subtotal
      m_sort 'VBELN' ''.                   " Sort by vbeln
      ls_layout-cell_merge = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                is_layout   = ls_layout
                it_fieldcat = lt_fieldcat
                it_sort     = lt_sort
           TABLES
                t_outtab    = gt_vbak.
    ENDFORM.                               " F_DISPLAY_DATA

  • ALV subtotal display

    Dear all,
    i want to display
             field1 field2  fie3  field4
    mat1   10     20     tere    50
    mar2    60    50     erhr    70
    total                              120
    fright                               40
    cst                                  20
    G.total                           180
    like this , is it possible in alv display?, pls tell me

    hi,
    You use this code it will full fill ur recuirement.
    type-pools: slis.
    tables: vbak,vbap.
    selecting range of soles order no by using below statement.
    SELECT-OPTIONS: so_vbeln for vbak-vbeln.
    *Creating the structure's to hold sales order header and item details.
    types: begin of ty_vbak,
           VBELN type vbak-vbeln,
           ERDAT type vbak-erdat,
           NETWR type vbak-netwr,
           WAERK type vbak-waerk,
           end of ty_vbak,
           begin of ty_vbap,
           mandt type vbap-mandt,
           vbeln type vbap-vbeln,
           POSNR  type vbap-posnr,
           KWMENG type vbap-KWMENG,
           VRKME TYPE VBAP-VRKME,
           NETWR type vbap-netwr,
           WAERK type  vbap-waerk,
           DISAMT type  vbap-netwr,
           end of ty_vbap.
    *Creating the referances of required Objects.
    data: w_vbak  type ty_vbak,
          it_vbak type table of ty_vbak,
          w_vbap  type ty_vbap,
          it_vbap type table of ty_vbap,
          w_fieldcat type slis_fieldcat_alv,
          i_fieldcat type slis_t_fieldcat_alv,
          i_fieldcat1 type slis_t_fieldcat_alv,
          w_slis_selfield type slis_selfield,
          W_IS_LAYOUT TYPE SLIS_LAYOUT_ALV,
          repid type sy-repid,
          i_event TYPE slis_t_event,
          l_s_event TYPE slis_alv_event,
          i_sort TYPE  slis_t_sortinfo_alv,
          wa_sort TYPE slis_sortinfo_alv,
          i_alv_top_of_page TYPE slis_t_listheader.
    *This is display date and time on top of page.
    PERFORM sub_top_of_page.
    This perform to make structure for header details.
    PERFORM FIELDCATLOG1.
    This perform to make structure for item details.
    PERFORM FIELDCATLOG2.
    *This is to define Layout structure.
    PERFORM LAYOUT_STU.
    *This statement is to get header info from header table.
    SELECT VBELN ERDAT NETWR WAERK from VBAK into table It_vbak where vbeln in so_vbeln.
    repid = SY-REPID.
    *This is heder info display grid alv.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM      = repid
        I_CALLBACK_TOP_OF_PAGE  = 'TOP-OF-PAGE'
        I_CALLBACK_USER_COMMAND = 'INTERACTIVE'
        IS_LAYOUT               = w_is_layout
        IT_FIELDCAT             = i_fieldcat
      TABLES
        T_OUTTAB                = it_vbak
      EXCEPTIONS
        PROGRAM_ERROR           = 1
        OTHERS                  = 2.
    &      Form  INTERACTIVE
        This form dispaly item info on alv grid form.
           -->R_UCOMM      text
           -->RS_SELFIELD  text
    FORM INTERACTIVE USING R_UCOMM LIKE SY-UCOMM
                           RS_SELFIELD TYPE SLIS_SELFIELD.
      DATA: TEMP_VBELN TYPE VBAK-VBELN.
      IF RS_SELFIELD-FIELDNAME = 'VBELN'.
        CASE R_UCOMM.
          WHEN '&IC1'.
            refresh: it_vbak , it_vbap , i_event , i_sort.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING
                INPUT  = RS_SELFIELD-VALUE
              IMPORTING
                OUTPUT = TEMP_VBELN.
            TEMP_VBELN = RS_SELFIELD-VALUE.
    *This statement is to get item info from item table
            SELECT VBELN POSNR KWMENG VRKME NETWR WAERK INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
                                                               FROM VBAP WHERE VBELN = TEMP_VBELN.
            IF sy-subrc = 0.
              SORT IT_VBAP BY VBELN POSNR KWMENG .
            ENDIF.
    *This is to calculate 30% of discount amount
            LOOP AT IT_VBAP INTO W_VBAP .
              W_VBAP-DISAMT = ( ( W_VBAP-NETWR  / 100 ) * 30 ).
              W_VBAP-DISAMT = W_VBAP-NETWR - W_VBAP-DISAMT.
              MODIFY TABLE IT_VBAP FROM W_VBAP.
            ENDLOOP.
    *This is to sort the item info internal table
            PERFORM sub_populate_sort.
    *This is dynamic call of event.
            PERFORM sub_get_event.
    *THis is item info display grid alv.
            PERFORM ALV_DISPLAY.
        ENDCASE.
      ENDIF.
    ENDFORM.                    "INTERACTIVE
    &      Form  sub_get_event
          This form for event Perform which have decalred above
    FORM sub_get_event.
      CONSTANTS: c_formname_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 4
        IMPORTING
          et_events       = i_event
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      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  ALV_DISPLAY
    form for item ingo dsplay perform
    -->  p1        text
    <--  p2        text
    FORM ALV_DISPLAY .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM = REPID
          I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'
          IS_LAYOUT          = w_is_layout
          IT_FIELDCAT        = I_FIELDCAT1
          it_sort            = i_sort
          it_events          = i_event
          i_default          = 'X'
          i_save             = 'A'
        TABLES
          T_OUTTAB           = IT_VBAP
        EXCEPTIONS
          PROGRAM_ERROR      = 1
          OTHERS             = 2.
    ENDFORM.                    " ALV_DISPLAY
    &      Form  SUBTOTAL_TEXT
         This dynamic call of  subtotal_text event.
           -->P_TOTAL        text
           -->P_SUBTOT_TEXT  text
    FORM subtotal_text CHANGING P_TOTAL TYPE ANY
                          p_subtot_text TYPE slis_subtot_text.
      IF p_subtot_text-criteria = 'MANDT'.
         p_subtot_text-display_text_for_SUBtotal = 'TOTAL'.
      ENDIF.
    ENDFORM.     "subtotal_text
    *&      Form  sub_populate_sort
         This form to sort item internal table.
    -->  p1        text
    <--  p2        text
    FORM sub_populate_sort .
      wa_sort-spos = '01' .
      wa_sort-fieldname = 'MANDT'.
      wa_sort-tabname = 'IT_VBAP'.
      wa_sort-up = 'X'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO i_sort .
      CLEAR wa_sort.
    ENDFORM.                    " sub_populate_sort
    *&      Form  fIELDCATLOG1
          Structure of header fields
    -->  p1        text
    <--  p2        text
    FORM FIELDCATLOG1 .
      PERFORM sub_fill_alv_field_catalog1 USING:
         '01' 'VBELN'  'C' '13' 'S_Order No',
         '02' 'ERDAT'  'C' '11' 'Created Date',
         '03' 'NETWR'  'C' '18' 'Net_Amt',
         '04' 'WAERK'  'C' '10' 'Currency'.
    ENDFORM.                    " fIELDCATLOG1
    FORM TOP-OF-PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = i_alv_top_of_page
    i_logo = 'MOURISOFTLOGO1'.
      ENDFORM.
    *&      Form  sub_fill_alv_field_catalog
          header fieldcatlog details
         -->P_0664   text
         -->P_0665   text
         -->P_0666   text
         -->P_0667   text
         -->P_0668   text
    FORM sub_fill_alv_field_catalog1  USING  p_colpos    TYPE sycucol
                                            p_fldnam    TYPE fieldname
                                            p_justif    TYPE char1
                                            p_OUTPUTLEN TYPE dd03p-outputlen
                                            p_seltext   TYPE dd03p-scrtext_l.
      w_fieldcat-col_pos        =  p_colpos.     "Column
      w_fieldcat-fieldname      =  p_fldnam.     "Field Name
      w_fieldcat-just           =  p_justif.     "Screen Justified
      w_fieldcat-outputlen      =  p_OUTPUTLEN.
      w_fieldcat-seltext_l      =  p_seltext.    "Field Text
      APPEND w_fieldcat TO i_fieldcat.
      CLEAR w_fieldcat.
    ENDFORM.                    " sub_fill_alv_field_catalog
    *&      Form  FIELDCATLOG2
          structure for item fields
    -->  p1        text
    <--  p2        text
    FORM FIELDCATLOG2 .
      PERFORM sub_fill_alv_field_catalog2 USING:
            '01' 'MANDT'   'C' '03' 'Client_No'        'X' ' ',
            '02' 'VBELN'   'L' '13' 'Sales_No'         ' ' ' ',
            '03' 'POSNR'   'C' '08' 'Items_No'         ' ' ' ',
            '04' 'KWMENG'  'C' '18' 'Quantity'         ' ' ' ',
            '05' 'VRKME'   'C' '05' 'Unit'             ' ' ' ',
            '06' 'NETWR'   'C' '18' 'Net_Amt'          ' ' ' ',
            '07' 'WAERK'   'C' '10' 'Currency'         ' ' ' ',
            '08' 'DISAMT'  'C' '20' '30% Discount_Amt' ' ' ' ',
            '09' 'WAERK'   'C' '10' 'Currency'         ' ' ' '.
    ENDFORM.                    " FIELDCATLOG2
    *&      Form  sub_fill_alv_field_catalog2
          item fieldcatlog details
         -->P_0741   text
         -->P_0742   text
         -->P_0743   text
         -->P_0744   text
         -->P_0745   text
         -->P_0746   text
         -->P_0747   text
    FORM sub_fill_alv_field_catalog2  USING p_colpos    TYPE sycucol
                                            p_fldnam    TYPE fieldname
                                            p_justif    TYPE char1
                                            p_OUTPUTLEN TYPE dd03p-outputlen
                                            p_seltext   TYPE dd03p-scrtext_l
                                            p_out       TYPE char1
                                            p_tech      TYPE char1.
      w_fieldcat-col_pos        =  p_colpos.     "Column
      w_fieldcat-fieldname      =  p_fldnam.     "Field Name
      w_fieldcat-just           =  p_justif.     "Screen Justified
      w_fieldcat-outputlen      =  p_OUTPUTLEN.
      w_fieldcat-seltext_l      =  p_seltext.    "Field Text
      W_FIELDCAT-no_out            =  p_out.
      W_FIELDCAT-tech         =  P_TECH.
      IF W_FIELDCAT-FIELDNAME = 'KWMENG'.
        W_FIELDCAT-do_sum = 'X'.
      ENDIF.
      IF W_FIELDCAT-FIELDNAME = 'NETWR'.
        W_FIELDCAT-do_sum = 'X'.
      ENDIF.
      IF W_FIELDCAT-FIELDNAME = 'DISAMT'.
        W_FIELDCAT-do_sum = 'X'.
      ENDIF.
      APPEND w_fieldcat TO i_fieldcat1.
      CLEAR w_fieldcat.
    ENDFORM.                    " sub_fill_alv_field_catalog2
    *&      Form  sub_top_of_page
          text
    -->  p1        text
    <--  p2        text
    FORM sub_top_of_page .
    DATA: l_system     TYPE char10 ,          "System id
            l_r_line     TYPE slis_listheader,  "Hold list header
            l_date       TYPE char10,           "Date
            l_time       TYPE SY-UZEIT,           "Time
            l_success_records TYPE i,           "No of success records
            l_title(300) TYPE c.                " Title
    Run date Display
      l_r_line-typ  = 'S'.                " Item
      WRITE: sy-datum  TO l_date MM/DD/YYYY.
      l_r_line-key = 'Run Date :'.
      l_r_line-info = l_date.
      APPEND l_r_line TO i_alv_top_of_page.
      CLEAR: l_r_line,
             l_date.
    Time  Display
      l_r_line-typ = 'S'.               " header
      WRITE: SY-UZEIT to l_time USING EDIT MASK '__:__:__'.
      l_r_line-key = 'Current Time'.
      l_r_line-info = l_time.
      APPEND l_r_line TO i_alv_top_of_page.
      CLEAR: l_r_line, l_time.
    ENDFORM.                    " sub_top_of_page
    *&      Form  LAYOUT_STU
          text
    -->  p1        text
    <--  p2        text
    FORM LAYOUT_STU .
    *Layout declaration for alv display.
    W_IS_LAYOUT-ZEBRA = 'X'.
    W_IS_LAYOUT-NO_VLINE = 'X'.
    W_IS_layout-no_input = 'X'.
    *W_IS_layout-colwidth_optimize = 'X'.
    w_is_layout-no_totalline = 'X'.
    ENDFORM.                    " LAYOUT_STU

  • ALV subtotal icon

    Hello;
    I use OO ALV grid to display data. I want to have totals and subtotals icons in the display. Thay are not excluded but only totals icon is displayed. How can I display also the subtotals icon?
    Thx in advance,
    Ali.

    Hi,
    Below is the sample code :
    data : gt_sortfields  type lvc_t_sort with header line.
      gt_sortfields-fieldname = 'WAERS'.
      gt_sortfields-spos      = 1.
      gt_sortfields-subtot    = 'X'.
      gt_sortfields-up        = 'X'.
      append gt_sortfields.
      gt_sortfields-fieldname = 'PERNR'.
      gt_sortfields-spos      = 2.
      gt_sortfields-subtot    = 'X'.
      gt_sortfields-up        = 'X'.
      append gt_sortfields.
      gt_sortfields-fieldname = 'LGART'.
      gt_sortfields-spos      = 3.
      gt_sortfields-subtot    = 'X'.
      gt_sortfields-up        = 'X'.
      append gt_sortfields.
    And then pass it FM
      call method gv_grid->set_table_for_first_display
        exporting
          is_layout       = gs_layout
          i_save          = gv_variant_save
          is_variant      = gs_variant
        changing
          it_fieldcatalog = gt_fieldcat[]
          it_outtab       = gt_final_labor[]
          it_sort         = gt_sortfields[].
    Thanks,
    Sriram POnna.

  • ALV subtotal but no grandtotal

    Hi guys. I was just wondering if there is a code in alv that gets the subtotal for a field but not display that field in the grand total? I've tried using do_sum = 'X' but while it displays the subtotal it also displays that field in the grand total.
    For example: I have three fields. MATNR , QUANTITY and PRICE. What I need to do is display the subtotal for QUANTITY and PRICE if the MATNR changes and then display the grandtotal for PRICE <u>only.</u>
    I have already tried searching the net but I can't seem to find a way. Is this possible? Please help. Thanks.

    Hi,
    i have added a dummy field which is not displayed in the list but used in the sorting the entries, looks like it is achieving the requirement. Let me know if this is okay with you.
    type-pools : slis.
    data : t_fieldcat TYPE slis_t_fieldcat_alv,
           t_sort TYPE slis_t_sortinfo_alv,
           wa_fieldcat TYPE slis_fieldcat_alv,
           wa_sort type slis_sortinfo_alv.
    data : begin of t_table occurs 0,
            matnr type mara-matnr,
            tkg001 type cost-tkg001,
            tkg002 type cost-tkg002,
            value  type char01,
           end of t_table.
    data wa_layout type slis_layout_alv.
    data l_col_pos type i.
    t_table-matnr = '100'.
    t_table-tkg001 = '10'.
    t_table-tkg002 = '100.00'.
    t_table-value = '1'.
    append t_table.
    t_table-matnr = '100'.
    t_table-tkg001 = '11'.
    t_table-tkg002 = '111.00'.
    t_table-value = '1'.
    append t_table.
    t_table-matnr = '101'.
    t_table-tkg001 = '10'.
    t_table-tkg002 = '100.00'.
    t_table-value = '1'.
    append t_table.
    t_table-matnr = '102'.
    t_table-tkg001 = '11'.
    t_table-tkg002 = '100.00'.
    t_table-value = '1'.
    append t_table.
    **Customer Number
      ADD 1 TO l_col_pos.
      CLEAR wa_fieldcat.
      wa_fieldcat-tabname = 'T_TABLE'.
      wa_fieldcat-fieldname = 'MATNR'.
      wa_fieldcat-seltext_l = 'Material'.
      wa_fieldcat-outputlen = 40.
      APPEND wa_fieldcat TO t_fieldcat.
      ADD 1 TO l_col_pos.
      CLEAR wa_fieldcat.
      wa_fieldcat-tabname = 'T_TABLE'.
      wa_fieldcat-fieldname = 'TKG001'.
      wa_fieldcat-seltext_l = 'quantity'.
      wa_fieldcat-outputlen = 20.
    wa_fieldcat-no_sum = 'X'.
    wa_fieldcat-do_sum = 'X'.
      APPEND wa_fieldcat TO t_fieldcat.
      ADD 1 TO l_col_pos.
      CLEAR wa_fieldcat.
      wa_fieldcat-tabname = 'T_TABLE'.
      wa_fieldcat-fieldname = 'TKG002'.
      wa_fieldcat-seltext_l = 'price'.
      wa_fieldcat-outputlen = 20.
      wa_fieldcat-do_sum = 'X'.
      APPEND wa_fieldcat TO t_fieldcat.
      ADD 1 TO l_col_pos.
      CLEAR wa_fieldcat.
      wa_fieldcat-tabname = 'T_TABLE'.
      wa_fieldcat-fieldname = 'VALUE'.
      wa_fieldcat-seltext_l = 'price'.
      wa_fieldcat-outputlen = 20.
      wa_fieldcat-no_out = 'X'.
      APPEND wa_fieldcat TO t_fieldcat.
      wa_sort-fieldname = 'MATNR'.
      wa_sort-spos = '2'.
      wa_sort-subtot = 'X'.
      wa_sort-up = 'X'.
      append wa_sort to t_sort.
      wa_sort-fieldname = 'VALUE'.
      wa_sort-spos = '1'.
    wa_sort-subtot = 'X'.
      wa_sort-up = 'X'.
      append wa_sort to t_sort.
    CALL FUNCTION 'REUSE_ALV_LIST_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_STRUCTURE_NAME               =
        IS_LAYOUT                      = wa_layout
        IT_FIELDCAT                    = t_fieldcat
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
       IT_SORT                        = t_sort
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
      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
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
      TABLES
        t_outtab                       = t_table
    EXCEPTIONS
      PROGRAM_ERROR                  = 1
      OTHERS                         = 2

  • Alv subtotal value correction

    Hi gurus,
    my ques is i have a report calculating following fields cutomer wise , month wise:
          amount , qty , rate per qty.
    ex:    9500     5233      1.82 (9500/5233)
            4388      5472      0.80 (5472/4388)
    total:  13888    10705       2.62        (10705/13888= 0.77)
                (p1)       (p2)         (p3)
    in the ex: i want the rate per min value in the subtotal as a value calculated as  p2/p1  i.e 0.77 , instead here it is taking the sum of above two values 1.82 + 0.80 = 2.62 which is not the correct value.

    Hi gurus,
    my ques is i have a report calculating following fields cutomer wise , month wise:
          amount , qty , rate per qty.
    ex:    9500     5233      1.82 (9500/5233)
            4388      5472      0.80 (5472/4388)
    total:  13888    10705       2.62        (10705/13888= 0.77)
                (p1)       (p2)         (p3)
    in the ex: i want the rate per min value in the subtotal as a value calculated as  p2/p1  i.e 0.77 , instead here it is taking the sum of above two values 1.82 + 0.80 = 2.62 which is not the correct value.

  • Exclude buttons from ALV

    Hi All,
      I want to exclude pushbuttons from ALV. Can any body suggest me how to do this. I am using classes to display ALV.
    Regards,
    Venkat.

    in the pbo of your screen, before displaying your alv grid write in the following way:-
    data: g_alv_grid          type ref to cl_gui_alv_grid,
             g_exclude          type ui_func,
             g_t_tlbr_excl       type ui_functions.
    *PBO if used container or screen ,
    start of selection - if working with selection screen but before displaying alv.
    Exclude ICONS
        perform form_exculde_icons.
        call method g_alv_grid->set_table_for_first_display
          EXPORTING
            is_variant           = VARIANT
            is_layout            = LAYOUT
            is_print             =  PRINT
            it_toolbar_excluding = g_t_tlbr_excl
          CHANGING
            it_outtab            = ITAB
            it_fieldcatalog      = FIELDCATALOG[]
        if sy-subrc <> 0.
          write: 'Method call ''Set_table_for_first_display'' failed.'.
          exit.
        endif.
    form form_exculde_icons .
    Exclude alv sum button
      g_exclude = cl_gui_alv_grid=>mc_fc_sum.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv count button
      g_exclude = cl_gui_alv_grid=>mc_fc_count.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv average button
      g_exclude = cl_gui_alv_grid=>mc_fc_average.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv maximum button
      g_exclude = cl_gui_alv_grid=>mc_fc_maximum.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv manimum button
      g_exclude = cl_gui_alv_grid=>mc_fc_minimum.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv subtotal button
      g_exclude = cl_gui_alv_grid=>mc_fc_subtot.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv auf button
      g_exclude = cl_gui_alv_grid=>mc_fc_auf.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv locpaste button
      g_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv new_row button
      g_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv mb_view button
      g_exclude = cl_gui_alv_grid=>mc_mb_view.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv fc_view button
      g_exclude = cl_gui_alv_grid=>mc_fc_views.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv print_prev button
      g_exclude = cl_gui_alv_grid=>mc_fc_print_prev.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv viewgrid button
      g_exclude = cl_gui_alv_grid=>mc_fc_view_grid.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv view_excel button
      g_exclude = cl_gui_alv_grid=>mc_fc_view_excel.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv view_crystal button
      g_exclude = cl_gui_alv_grid=>mc_fc_view_crystal.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv view_lotus button
      g_exclude = cl_gui_alv_grid=>mc_fc_view_lotus.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv send button
      g_exclude = cl_gui_alv_grid=>mc_fc_send.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv call_abc button
      g_exclude = cl_gui_alv_grid=>mc_fc_call_abc.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv call_xint button
      g_exclude = cl_gui_alv_grid=>mc_fc_call_xint.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv fc_expcrdesig button
      g_exclude = cl_gui_alv_grid=>mc_fc_expcrdesig.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv fc_expcrtempl button
      g_exclude = cl_gui_alv_grid=>mc_fc_expcrtempl.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv mb_paste button
      g_exclude = cl_gui_alv_grid=>mc_mb_paste.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv load_variant button
      g_exclude = cl_gui_alv_grid=>mc_fc_load_variant.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv current_variant button
      g_exclude = cl_gui_alv_grid=>mc_fc_current_variant.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv maintain_variant button
      g_exclude = cl_gui_alv_grid=>mc_fc_maintain_variant.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv save_variant button
      g_exclude = cl_gui_alv_grid=>mc_fc_save_variant.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv select_all button
      g_exclude = cl_gui_alv_grid=>mc_fc_select_all.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv deselect_all button
      g_exclude = cl_gui_alv_grid=>mc_fc_deselect_all.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv graph button
      g_exclude = cl_gui_alv_grid=>mc_fc_graph.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv info button
      g_exclude = cl_gui_alv_grid=>mc_fc_info.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv f4 button
      g_exclude = cl_gui_alv_grid=>mc_fc_f4.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv call_report button
      g_exclude = cl_gui_alv_grid=>mc_fc_call_report.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv fc_check button
      g_exclude = cl_gui_alv_grid=>mc_fc_check.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv fc_refresh button
      g_exclude = cl_gui_alv_grid=>mc_fc_refresh.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv loc_cut button
      g_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv loc_copy button
      g_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv loc_undo button
      g_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv append_row button
      g_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv insert_row button
      g_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv delete_row button
      g_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv copy_row button
      g_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv reprep button
      g_exclude = cl_gui_alv_grid=>mc_fc_reprep.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv call_chain button
      g_exclude = cl_gui_alv_grid=>mc_fc_call_chain.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv call_more button
      g_exclude = cl_gui_alv_grid=>mc_fc_call_more.
      append g_exclude to g_t_tlbr_excl.
    Exclude alv call_master_data button
      g_exclude = cl_gui_alv_grid=>mc_fc_call_master_data.
      append g_exclude to g_t_tlbr_excl.
    endform.

Maybe you are looking for