Alv - sub  totals and avg

Hi gurus,
I have a problem, please help me out.
Iam doing an report program with alv display. In that iam calculating the AVG for the workcenter wise for the field TAT.
please observe my below o/p in general ALv  format.
work center-- TAT- Tat(Yes/no)
qm0010------ 1 --  yes
qm0010-------2 --  yes
qm0010------ 4 -- yes
qm0010------ 7 -- No (because >5)
Subtotal(qm0010)--3  (avg caluculated)
qm0020--  4 --- yes
qm0020-7-- No (because >5)
qm0020--10 - No (because >5)
qm002010- No (because >5)
Subtotal(qm0020)-- 7 (avg caluculated).
this is the rough o/p iam getting . this is acheived by programming the Field catalog for TAT field i.e... do_sum  = 'C'.
then giving the sort table to REUSE_ALV_GRID_DISPLAY.
Now my problem is:
I want the avg to be calcuted by the business formula which is:
avg  =  sum of(TAT within 5 days) / total no of the entries .
Ex:
work center-- TAT- Tat(Yes/no)
qm0010------ 1 --  yes
qm0010-------2 --  yes
qm0010------ 4 -- yes
qm0010------ 7 -- No (because >5)
Subtotal(qm0010)---*7/4=2 (avg caluculated for tat<5)*
qm0020--  4 --- yes
qm0020-7-- No (because >5)
qm0020--10 - No (because >5)
qm002010- No (because >5)
Subtotal(qm0020)--4/4=1 (avg caluculated for tat<5).
How can i acheive the above, since in field catalog and alv, i think we cannot pass any conditions(like for TAT which is less than 5). So is there any other way to acheive the above.
Please understand the problem and give me(please directly dont suggest any programs , since iam not a expert to understand)..
Please explain me in detail.  Points will be duly rewarded.
Thanks in advance........Chaitu
Edited by: chaitanya on May 30, 2008 12:33 PM
Edited by: chaitanya on May 30, 2008 12:38 PM
Edited by: chaitanya on May 30, 2008 12:39 PM

Hi Chaitanya,
   You can display in your report with totals and sub-totals using alv, but not average. That functionality has not provided by sap. Do one thing add one more extra column Average in your output, do the calculation for average and pass the value in the coding itself. Then last display your report with Average field.
Rgds,
Bujji

Similar Messages

  • Sub-total and Total for a column having checkboxes in WD ABAP ALV

    Hello Experts,
    I have used ALV in We bdynpro ABAP to display my output. There are 2 columns that are checkboxes in Output. I want a sub-total and total for those two columns. I know tht total and sub-total functionality is available only for numeric fields .
    Is there any other indirect way by which i can achieve the same ?

    Hi Ragini,
    Please refer this thread: [alv total and subtotal|How to display graphs;.
    I hope it helps.
    Regards
    Arjun

  • 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-totals and Totals calculations....?

    How to Calculate the Sub-totals and Grand totals in ABAP Programs.

    Hi Bhaskar,
    In my opinion this can be acheived in two ways:
    1. Using ALV GRID DISPLAY
    2. Using AT NEW  , ON CHANGE OF  , etc events.
    1. In the ALV field catalogue u create entries for all the fileds to b
    displayed in the output list.
    Here, we need to put DO_SUM = 'X' .
    eg
      ****************fieldcatalog*********************
    data:anytab type slis_t_fieldcat_alv with header line.
    **************pgm name**********************
    data:anypgnm type sy-repid.
    **************events*************************
    anytab-fieldname   = 'MATNR'.
      anytab-seltext_m   = 'Material Number'.
      anytab-col_pos     = 0.
      anytab-outputlen   = 20.
      anytab-emphasize   = 'X'.
      anytab-do_sum = 'X' .                  <----
    here it is.
      append anytab to anytab .
      clear  anytab .
    Now wen u call the fm REUSE_ALV_GRID_DISPLAY , plz pass anytab ie fieldcatalog  and  the tabel with records to  b displayed .
    this would  sum the fields at the end.
    2.  Alternately ....for SUb-totals ;
       Sort itab in an ascending manner.
    Data : wa_itab    like line of itab,
              wa_subtotal type i.
    " fieldname1 in itab is the key field
    " fieldname2 is the value field
    LOOP at itab into wa_itab .
      wa_subtotal = wa-subtotal  + itab-<fieldname2>.
      AT END OF <fieldname1> .
          " your programming logic for subtotal
           Write :/ wa_itab-fieldname1 , wa_subtotal.
           Clear  wa_subtotal.
       ENDAT.
       " write :/  ....if u need to write any lofgic values ....
    ENDLOOP .
    Note : plz sc if a field in itab that is left of fieldname1 changes
              the AT END OF event is triggered.
             Therefoe , see that  pur key fields towards left in itab.
    FYI : u can try ON CHANGE OF....ENDON....
                          AT NEW .....ENDAT
                           AT LAST....ENDAT
                           AT FIRST ......ENDAT  events for ur own understanding
    i hope this helps u.
    Regards
    panakj

  • Interactive Report Sub-total and total

    Hi friends,
    I have an employee interactive report with group by job name and also showing the salary sub-total for each and every job(group by).
    I have an requirement like to highlight the sub-total for each and every job with a background color so that the user can identify the sub-total with the color, and also whether it is possible to display an overall total @ last in the report with a label named "Total Salary" in which it calculates the overall salary is also to be highlightened with the background color.
    Also is it possible to display a text "Sub-total" besides each and every salary sub-total  of job(group by). Currently if we display a sum for the salary then im getting the total's but with out a text named total.
    Since i can see the highlighted feature in interactive report but im not sure how to apply it for the sub-total and total column.
    I have reproduced the example in apex.oracle.com
    http://apex.oracle.com/pls/apex/f?p=4550:1:0:::::
    In the application 9494 named "test" in page1.
    Thanks in advance.
    Brgds,
    Mini

    Hi, Mini,
    style=background-color:red;
    But that Total region color dint change.The code for style should be in "Form HTML Element Attributes". However, this changes the background color only for the Total value not for the whole row.
    If you want to change for the whole row, you need to change the template that is selected for the region.
    I changed the region template in your application to "Borderless Region" and made the changes to the "Borderless Region" template, it now shows the background color for Total Value.
    <table class="t20Region t20Borderless #REGION_CSS_CLASSES#" id="#REGION_STATIC_ID#" border="0" cellpadding="0" cellspacing="0" summary="" #REGION_ATTRIBUTES#>
    <thead><tr><th class="t20RegionHeader" id="#REGION_STATIC_ID#_header">#TITLE#</th></tr></thead>
    <tbody id="#REGION_STATIC_ID#_body">
    <tr><td class="t20ButtonHolder">#CLOSE##PREVIOUS##NEXT##DELETE##EDIT##CHANGE##CREATE##CREATE2##EXPAND##COPY##HELP#</td></tr>
    <tr><td class="t20RegionBody" style="background-color:orange">#BODY#</td></tr>
    </tbody>
    </table>The below does the trick. :)
    <tr><td class="t20RegionBody" style="background-color:orange">#BODY#</td></tr>Note: I made the changes to "Borderless Template", but you can copy the template to your own and apply this change.
    Regards,
    Natarajan

  • Urgent : how to calculate sub total and grand total in smart forms

    Hi Friens..how to calculate sub total and grand total in smart forms..How to print them in smart forms...Also kindly explain how to handle events in smart forms..Thanks in advance

    Re: Subtotal with Table Node in smartforms

  • Sub totals and Totals

    I am developing a query using SQVI.
    How do I insert subtotals and totals for certain fields at the end of the query report.
    Thanks
    Sandeep

    hI SANDEEP  .....
    if you  go with  layou mode   then    there will be   3  pops  like   delete  ,  TOOL BAR  , SORT FIELDS ....etc ..
    there is  TOOL BAR   with the following  options   ...
    Background
    Heading
    Normal
    <b>Subtotals</b>
    Key Columns
    Positive
    Negative
    Control Levels
    Background (intensified
    Header (intensified)
    Normal (intensified)
    Sum totals (intensified
    Keys (intensified)
    Positive (intensified)
    Negative (intensified)
    Control lev.(intensifie
    so  that  by selecting the  fields   .....  liek sub total   acrros the  Fiscal  year  can be done  ....  Document wise   sub total  ..... vendor wise   , customer wise  ... like  based  on the fields   selection for sub total  and   total can  be  done ...
    Girish

  • Sub totals and Sort Text issue in ALV report

    Hi,
    I have requirement for list of Purchase orders.
    1st. sort the list by vendor (This i did by using sort)
    2nd. Vendor name should be display after sorting the lines.
    3rd  should count the no lines which has mark 'X' in field ELIKZ and sum the total counts and display it for every vendor after the sorted line.
    I could sort the list by vendors. but don't know how to display the vendor name after those lines. then sub total also.
    Please help
    Moderator Message: spec-dumping is not allowed. Please use the availble resources and put some effort from your end.
    Edited by: kishan P on Oct 27, 2010 3:02 PM

    Hi,
    I have requirement for list of Purchase orders.
    1st. sort the list by vendor (This i did by using sort)
    2nd. Vendor name should be display after sorting the lines.
    3rd  should count the no lines which has mark 'X' in field ELIKZ and sum the total counts and display it for every vendor after the sorted line.
    I could sort the list by vendors. but don't know how to display the vendor name after those lines. then sub total also.
    Please help
    Moderator Message: spec-dumping is not allowed. Please use the availble resources and put some effort from your end.
    Edited by: kishan P on Oct 27, 2010 3:02 PM

  • Queries on ALV Sub totalling

    Hi all,
            I have a requirement to change few fields in existing ALV.
    1) i have data like this in ALV.
    GROUP      G/L ACCOUNT         LC           USD
      100              10                         5               5
      100              11                         6               4
      100              12                         3               3
      100              11                         3               2
      200              10                         5               5
      200              11                         6               4
      200              12                         3               3
      200              11                         3               2
    now for  particular GROUP (ex: 100) i need the sub totals of LC(5633=17) and USD(5432=14)
    it should be shown before the GROUP 200 begins.
    now the output should come as:
    GROUP      G/L ACCOUNT         LC           USD
      100              10                         5               5
                         11                         6               4
                         12                         3               3
                         11                         3               2
    TOTAL                                      17              14
      200              10                         5               5
                         11                         6               4
                         12                         3               3
                         11                         3               2
    TOTAL                                       17             14
    Is there any way to do this..please help
    thanks,
    prasanth

    Hai Prasanth,
    Try this.
      LR_SORTS = LR_TABLE->GET_SORTS( ).
      LR_AGGREGATIONS = LR_TABLE->GET_AGGREGATIONS( ).
      PERFORM SET_AGGREGATIONS USING LR_AGGREGATIONS '<lc fieldname>'. 
      PERFORM SET_SORTS USING LR_SORTS '<group filedname>' 1
                                 1   'X'  .
    Double click SET_AGGREGATIONS
    *&      Form  SET_AGGREGATIONS
          text
         -->P_LR_AGGREGATIONS  text
         -->P_0834   text
    FORM SET_AGGREGATIONS USING IR_AGGREGATIONS TYPE REF TO CL_SALV_AGGREGATIONS
                                L_COL          TYPE ANY.
      CONSTANTS: L_1 TYPE SALV_DE_AGGREGATION VALUE '1'.
      TRY.
          IR_AGGREGATIONS->SET_NUMERICAL_AGGREGATION( ABAP_FALSE ).
          TRY.
              IR_AGGREGATIONS->ADD_AGGREGATION(
                COLUMNNAME  = L_COL
                AGGREGATION = L_1 ).
            CATCH CX_SALV_DATA_ERROR CX_SALV_EXISTING CX_SALV_NOT_FOUND.
              MESSAGE I023(SALV_EXCEPTION).
            CATCH CX_SALV_METHOD_NOT_SUPPORTED.
              MESSAGE I028(SALV_EXCEPTION) WITH SPACE SPACE SPACE SPACE.
          ENDTRY.
        CATCH CX_SALV_METHOD_NOT_SUPPORTED.
          MESSAGE I028(SALV_EXCEPTION) WITH SPACE SPACE SPACE SPACE.
      ENDTRY.
    ENDFORM. " SET_AGGREGATIONS
    Double click SET_SORTS
    *&      Form  SET_SORTS
          text
         -->P_LR_SORTS  text
         -->P_0827   text
         -->P_1      text
         -->P_1      text
         -->P_0830   text
    FORM SET_SORTS USING IR_SORTS TYPE REF TO CL_SALV_SORTS
                         L_COL    TYPE ANY
                         L_POS    TYPE I
                         L_SEQ    TYPE SALV_DE_SORT_SEQUENCE
                         L_TOT    TYPE SAP_BOOL.
      TRY.
          IR_SORTS->SET_GROUP_ACTIVE( ABAP_FALSE ).
          TRY.
              IR_SORTS->ADD_SORT(
                COLUMNNAME = L_COL
                POSITION   = L_POS
                SEQUENCE   = L_SEQ
                SUBTOTAL   = L_TOT
            CATCH CX_SALV_DATA_ERROR CX_SALV_EXISTING CX_SALV_NOT_FOUND.
              MESSAGE I023(SALV_EXCEPTION).
            CATCH CX_SALV_METHOD_NOT_SUPPORTED.
              MESSAGE I028(SALV_EXCEPTION) WITH SPACE SPACE SPACE SPACE.
          ENDTRY.
        CATCH CX_SALV_METHOD_NOT_SUPPORTED.
          MESSAGE I028(SALV_EXCEPTION) WITH SPACE SPACE SPACE SPACE.
      ENDTRY.
    ENDFORM. " SET_SORTS

  • Reg. ALV- Sub total?

    Hi Experts,
    How to hide the column values in ALV? That is I need to display the sub-total values alone and not to show the other values in the ALV output. Take for e.g
    1   2   2  andre
    2   3   4  brown
    3   5   6  subtotal
    2   2    3  A
    1   1    1  B
    1   1     1  C
    1   1     2  D
    5   5   7   subtotal
    If the alv output is like this means, I want to display the 3, 5, 6 fields alone how to hide the first column colum field values alone i.e 1 & 2. Then in second part of the ALV how to hide the first column values 2,1,1 & 1 alone.
    Regards,
    Sakthi

    Hi Tarun,
    Thanks for your reply.
    If I give that no_out = 'X' in the sense it will hide the whole column.
    I need How to hide the values alone and need to display the column subtotal.
    Those values need to be displayed as blank in the output.
    How to do that?
    The output normally will be like this.
    1 1 1 A
    1 2 3 B
    1 1 1 C
    3 4 5 subtotal
    1 2 3 E
    1 1 1 F
    2 3 4 SubTotal
    But what I need  is
        1 1 A
        2 3 B
        1 1 C
    3   4 5 SubTotal
      2 3 E
      1 1 F
    2 3 4 Sub Total
    Like this I need to hide a single column values alone not along with sub total values. The first column values should not appear but subtotal value should appear.

  • Alv sub totals

    Hi
    In ALV grid I want subtotal for accounts group INCOME ( 300000,301000,302007 sub total-1) again Expenses( 400000,401012,403001) subtotal-2 like wise etc there are more than 3 groups
    Please help.
    Regards
    Vinayak M. Deosthali.

    Hi Vinayak,
      By now I think you understand how to give Subtotals for a column by filling it in SORT table.
      I think you can achieve your requirement by adding one more column to your display called "Account Group" or just "Group" and fill it with INCOME for 300000, 301000, 302007 and similarily EXPENSES for 400000, 401012, 403001 etc.
      And then fill your SORT table with this field and set properties UP = 'X', SUBTOT = 'X' for it.
      You can actually keep this column at the very end of the grid (by adding it to the field catalog at the very end) if you dont want it to appear next to other important columns. 
      Hope this helps..
    Sri
    Message was edited by: Srikanth Pinnamaneni
    Message was edited by: Srikanth Pinnamaneni

  • Alv sub total problem

    hi,
    in alv i want sub total text for purchase order.
    can you check my code . i am not getting.
    TYPE-POOLS: slis.
    TABLES: ekko,ekpo,eket.
    TYPES: BEGIN OF ty_ekko,
            lifnr TYPE elifn,
            ebeln TYPE ebeln,
            ebeln1 TYPE ebeln,
            bsart TYPE esart,
            ekorg TYPE ekorg,
            ekgrp TYPE bkgrp,
            ernam TYPE ernam,
           END OF ty_ekko,
           BEGIN OF ty_ekpo,
            ebeln TYPE ebeln,
            matnr TYPE matnr,
            ebelp TYPE ebelp,
            ebelp1 TYPE ebelp,
            menge TYPE bstmg,
            meins TYPE bstme,
            netpr TYPE bprei,
            werks TYPE ewerk,
           END OF ty_ekpo,
           BEGIN OF ty_eket,
            ebeln TYPE ebeln,
            ebelp TYPE ebelp,
            etenr TYPE eeten,
            eindt TYPE eindt,
           END OF ty_eket,
           BEGIN OF ty_final,
            slno TYPE sy-dbcnt,
            lifnr TYPE elifn,
            ebeln TYPE ebeln,
            ebeln1 TYPE ebeln,
            bsart TYPE esart,
            ekorg TYPE ekorg,
            ekgrp TYPE bkgrp,
            ernam TYPE ernam,
            matnr TYPE matnr,
            ebelp TYPE ebelp,
            ebelp1 TYPE ebelp,
            menge TYPE bstmg,
            meins TYPE bstme,
            netpr TYPE bprei,
            werks TYPE ewerk,
            eindt TYPE eindt,
           END OF ty_final.
    DATA: it_ekko TYPE STANDARD TABLE OF ty_ekko,
          it_ekpo TYPE STANDARD  TABLE OF ty_ekpo,
          it_eket TYPE STANDARD  TABLE OF ty_eket,
          it_final TYPE STANDARD TABLE OF ty_final,
          it_fieldcat TYPE slis_t_fieldcat_alv,
          it_alv_top_of_page TYPE slis_t_listheader,
          it_sort TYPE  slis_t_sortinfo_alv,
          it_event TYPE slis_t_event,
          l_repid TYPE syrepid,
          slno TYPE i VALUE 1.
    DATA: wa_ekko TYPE ty_ekko,
          wa_ekpo TYPE ty_ekpo,
          wa_eket TYPE ty_eket,
          wa_final TYPE ty_final,
          wa_fieldcat TYPE slis_fieldcat_alv,
          wa_alv_top_of_page TYPE slis_listheader,
          wa_sort TYPE  slis_sortinfo_alv,
          wa_layout   TYPE slis_layout_alv.
         wa_event TYPE slis_alv_event.
    CONSTANTS:
       c_header   TYPE char1
                  VALUE 'H',                    "Header in ALV
       c_item     TYPE char1
                  VALUE 'S'.
    SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_aedat FOR ekko-aedat.
    SELECTION-SCREEN END OF BLOCK blk.
    START-OF-SELECTION.
    PERFORM validation.
      PERFORM retrive_data.
      PERFORM sub_build_header.
      PERFORM sub_field_catalog.
      PERFORM sub_populate_layout.
      PERFORM sub_populate_sort.
      PERFORM sub_get_event.
    *END-OF-SELECTION.
    Perform to display ALV report
      PERFORM sub_alv_report_display.
    *FORM validation .
    SELECT SINGLE * FROM ekko WHERE aedat IN s_aedat .
    IF sy-subrc <> 0.
       MESSAGE e001(zram).
    ENDIF.
    *ENDFORM.                    " validation
    FORM retrive_data .
      SELECT lifnr
             ebeln
             ebeln
             bsart
             ekorg
             ekgrp
             ernam FROM ekko INTO TABLE it_ekko
            INTO CORRESPONDING FIELDS OF TABLE it_ekko
             WHERE aedat IN s_aedat .
      IF it_ekko[] IS NOT INITIAL.
        SELECT ebeln
               ebelp
               ebelp
               matnr
               menge
               meins
               netpr
               werks FROM ekpo
               INTO corresponding fields of  TABLE it_ekpo
               FOR ALL ENTRIES IN it_ekko
               WHERE ebeln = it_ekko-ebeln .
          if sy-subrc = 0.
             SELECT ebeln
               ebelp
               etenr
               eindt
               FROM eket INTO  TABLE it_eket
               FOR ALL ENTRIES IN it_ekpo
               WHERE ebeln = it_ekpo-ebeln .
            endif.
      ENDIF.
    ENDIF.
      LOOP AT it_ekko INTO wa_ekko.
        READ TABLE it_ekpo INTO wa_ekpo
                              WITH KEY ebeln = wa_ekko-ebeln.
        READ TABLE it_eket INTO wa_eket
                                WITH KEY ebeln = wa_ekpo-ebeln.
        wa_final-slno  =  slno.
        wa_final-lifnr = wa_ekko-lifnr.
        wa_final-ebeln = wa_ekko-ebeln.
        wa_final-bsart = wa_ekko-bsart.
        wa_final-ekgrp = wa_ekko-ekgrp.
        wa_final-ekorg = wa_ekko-ekorg.
        wa_final-ernam = wa_ekko-ernam.
        wa_final-ebelp = wa_ekpo-ebelp.
        wa_final-matnr = wa_ekpo-matnr.
        wa_final-menge = wa_ekpo-menge.
        wa_final-meins = wa_ekpo-meins.
        wa_final-netpr = wa_ekpo-netpr.
        wa_final-werks = wa_ekpo-werks.
        wa_final-eindt = wa_eket-eindt.
        slno = slno + 1.
        APPEND wa_final TO it_final.
      ENDLOOP.
    ENDFORM.                    " retrive_data
    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 it_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 it_alv_top_of_page.
      CLEAR: l_r_line,
             l_date.
    ENDFORM.                    " sub_build_header
    FORM sub_field_catalog .
      REFRESH it_fieldcat.
      wa_fieldcat-row_pos        = '01'.  "  p_rowpos.     "Row
      wa_fieldcat-col_pos        = '01'.       "p_colpos.     "Column
      wa_fieldcat-fieldname      = 'SLNO'.       "p_fldnam.     "Field Name
      wa_fieldcat-tabname        = 'IT_FINAL'.      "p_tabnam.     "Internal Table Name
      wa_fieldcat-just           = ' '.       "p_justif.     "Screen Justified
      wa_fieldcat-seltext_l      = 'SLNo'.       "p_seltext.    "Field Text
      wa_fieldcat-do_sum         = ' '.
      wa_fieldcat-outputlen      = '4'    .
      wa_fieldcat-no_out         = ' '.       "p_out.        "No output
      wa_fieldcat-tech           = ' '.      "p_tech.       "Technical field
      wa_fieldcat-qfieldname     = ' '.       "p_qfield.     "Quantity unit
      wa_fieldcat-qtabname       = ' '.       "p_qtab .      "Quantity table
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-row_pos        = '01'.  "  p_rowpos.     "Row
      wa_fieldcat-col_pos        = '02'.       "p_colpos.     "Column
      wa_fieldcat-fieldname      = 'LIFNR'.       "p_fldnam.     "Field Name
      wa_fieldcat-tabname        = 'IT_FINAL'.      "p_tabnam.     "Internal Table Name
      wa_fieldcat-just           = ' '.       "p_justif.     "Screen Justified
      wa_fieldcat-seltext_l      = 'Supplier Name'.       "p_seltext.    "Field Text
      wa_fieldcat-do_sum         = ' '.
      wa_fieldcat-outputlen      = '12'    .
      wa_fieldcat-no_out         = ' '.       "p_out.        "No output
      wa_fieldcat-tech           = ' '.      "p_tech.       "Technical field
      wa_fieldcat-qfieldname     = ' '.       "p_qfield.     "Quantity unit
      wa_fieldcat-qtabname       = ' '.       "p_qtab .      "Quantity table
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-row_pos        = '01'.  "  p_rowpos.     "Row
      wa_fieldcat-col_pos        = '03'.       "p_colpos.     "Column
      wa_fieldcat-fieldname      = 'EBELN'.       "p_fldnam.     "Field Name
      wa_fieldcat-tabname        = 'IT_FINAL'.      "p_tabnam.     "Internal Table Name
      wa_fieldcat-just           = ' '.       "p_justif.     "Screen Justified
      wa_fieldcat-seltext_l      = 'PO No'.       "p_seltext.    "Field Text
      wa_fieldcat-do_sum         = ' '.
      wa_fieldcat-outputlen      = '15'    .
      wa_fieldcat-no_out         = ' '.       "p_out.        "No output
      wa_fieldcat-tech           = ' '.      "p_tech.       "Technical field
      wa_fieldcat-qfieldname     = ' '.       "p_qfield.     "Quantity unit
      wa_fieldcat-qtabname       = ' '.       "p_qtab .      "Quantity table
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-row_pos        = '01'.  "  p_rowpos.     "Row
      wa_fieldcat-col_pos        = '03'.       "p_colpos.     "Column
      wa_fieldcat-fieldname      = 'EBELN1'.       "p_fldnam.     "Field Name
      wa_fieldcat-tabname        = 'IT_FINAL'.      "p_tabnam.     "Internal Table Name
      wa_fieldcat-just           = ' '.       "p_justif.     "Screen Justified
      wa_fieldcat-seltext_l      = 'PO No'.       "p_seltext.    "Field Text
      wa_fieldcat-do_sum         = ' '.
      wa_fieldcat-no_out         = ' '.       "p_out.        "No output
      wa_fieldcat-tech           = 'X'.      "p_tech.       "Technical field
      wa_fieldcat-qfieldname     = ' '.       "p_qfield.     "Quantity unit
      wa_fieldcat-qtabname       = ' '.       "p_qtab .      "Quantity table
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
    ENDFORM.                    " sub_field_catalog
    FORM sub_populate_layout .
      CLEAR wa_layout.
      wa_layout-colwidth_optimize = 'X'." Optimization of Col width
    ENDFORM.                    " sub_populate_layout
    FORM sub_populate_sort .
    Sort on material
      wa_sort-spos      = '01' .
      wa_sort-fieldname = 'EBELN'.
      wa_sort-tabname   = 'IT_FINAL'.
      wa_sort-up        = 'X'.
      wa_sort-subtot    = 'X'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    Sort on plant
      wa_sort-spos      = '02'.
      wa_sort-fieldname = 'EBELP'.
      wa_sort-tabname   = 'IT_FINAL'.
      wa_sort-up        = 'X'.
      wa_sort-subtot    = 'X'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    ENDFORM.                    " sub_populate_sort
    FORM sub_get_event .
      CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE
                                                      'SUBTOTAL_TEXT'.
      data : wa_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 4
        IMPORTING
          et_events       = it_event
        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.
    Subtotal
      READ TABLE it_event  INTO wa_event
                        WITH KEY name = slis_ev_subtotal_text.
      IF sy-subrc = 0.
        MOVE c_formname_subtotal_text TO wa_event-form.
        MODIFY it_event FROM wa_event  INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    " sub_get_event
    FORM sub_alv_report_display .
      l_repid = sy-repid .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = l_repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
         i_callback_top_of_page            = 'SUB_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                         = wa_layout
       it_fieldcat                       = it_fieldcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
       it_sort                           = it_sort
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      i_default                         = 'X'
      i_save                            = 'A'
      IS_VARIANT                        =
      IT_EVENTS                         = i_event
      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                          = it_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.                    " sub_alv_report_display
    FORM sub_alv_top_of_page.                                   "#EC CALLED
    To write header for the ALV
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = it_alv_top_of_page.
    ENDFORM.                    "alv_top_of_page
    FORM subtotal_text CHANGING
                   p_total TYPE any
                   p_subtot_text TYPE slis_subtot_text.
    Material level sub total
      IF p_subtot_text-criteria = 'EBELN'.
        p_subtot_text-display_text_for_subtotal
        = 'The Nett price of PO No'(009).
      ENDIF.
    Plant level sub total
      IF p_subtot_text-criteria = 'EBELP'.
        p_subtot_text-display_text_for_subtotal = 'Total Purchase Order value placed'(010).
      ENDIF.
    ENDFORM.                    "subtotal_text

    hi ,
    try the given below code ...
    "*************INTERNAL TABLE FR SORTING***********************
    DATA: it_sort TYPE slis_t_sortinfo_alv.
    "******** WORK AREA FR FIELD CATALOG *************************
    DATA: wa_sort TYPE slis_sortinfo_alv.
       wa_sort-fieldname = 'EBELN'."field name
      wa_sort-tabname = 'IT_TAB'."internal table name
      wa_sort-up = 'X'.
      wa_sort-subtot ='X'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    it_sort                           = it_sort
    ENDFORM.                    "alv
    hope this helps
    Regards
    RItesh J

  • How to create a sub total and grand total using my query.

    How can I create a sub total for each section and grand total for using my query like this.  your help is appreciated. I am working with 9g
    WITH  BidItemsInformation  AS
    ( SELECT DISTINCT q.iplineno "Line Number", q.section "Section Number",
             i.item "Item Number",
             initcap(i.idescr) "Description" ,
             i.iunits "Unit",
             q.qty "Quantity" ,q.price  "Engineers Unit Price",
           (q.price * q.qty) "Engineers Estimate"
         FROM letprop l,
            proposal p,
            propitem q,
            bidlet b,
            bidtabs c,
            itemlist i,
            vendor v,
            bidders d 
         WHERE(l.letting = b.letting
                And b.letting = c.letting
                And p.cspecyr = i.ispecyr)
                AND q.prpitem = i.item
                AND p.contid = l.lcontid
                AND q.contid = p.contid
                AND c.vendor = l.avendor
                AND l.CALL = c.CALL
                AND q.lineflag = c.lineflag
                AND q.iplineno = c.iplineno
                AND l.letting = d.letting 
                AND c.letting = l.letting
                AND c.CALL = d.CALL
                AND v.vendor = d.vendor
                --  AND AND l.letstat = 'A'
                AND c.lineflag = 'L'
                AND  l.letting ='&letting'
                AND l.CALL = '&call'
    ), BiddersInformation  AS
    -- This is where you make your changes for vendor name and vendor number Do not touch the above code
    -- It is always the same for any call number and letting date
    ( SELECT IPLINENO "BLine Number",
            MAX(CASE WHEN VENDOR='K020'  THEN bidprice ELSE NULL END) "K020:: Unit Price",
            MAX(CASE WHEN VENDOR='K020'  THEN bidprice ELSE NULL END) K,
            MAX(CASE WHEN VENDOR='H438'  THEN bidprice ELSE NULL END) "H438:: Unit Price",
            MAX(CASE WHEN VENDOR='H438'  THEN bidprice ELSE NULL END) H,
            MAX(CASE WHEN VENDOR='U010'  THEN bidprice ELSE NULL END) "U010:: Unit Price",
            MAX(CASE WHEN VENDOR='U010'  THEN bidprice ELSE NULL END) U,
            MAX(CASE WHEN VENDOR='G110'  THEN bidprice ELSE NULL END) "G110:: Unit Price",
            MAX(CASE WHEN VENDOR='G110'  THEN bidprice ELSE NULL END) G,
            MAX(CASE WHEN VENDOR='H530'  THEN bidprice ELSE NULL END) "H530:: Unit Price",
            MAX(CASE WHEN VENDOR='H530'  THEN bidprice ELSE NULL END) H1
        FROM  BIDTABS
        WHERE LETTING='&letting'
              AND CALL='&call'
              AND BIDPRICE <> 0
        GROUP BY IPLINENO
    SELECT BidItemsInformation."Line Number",
           BidItemsInformation."Section Number",
           BidItemsInformation."Item Number",
           BidItemsInformation."Description",
           BidItemsInformation."Unit",
           BidItemsInformation."Quantity",
           BidItemsInformation."Engineers Unit Price",
           BidItemsInformation."Engineers Estimate",
           BiddersInformation."K020:: Unit Price",
            (BidItemsInformation."Quantity" * K) "KGM CONTRACTORS INC",
           BiddersInformation."H438:: Unit Price",       
            (BidItemsInformation."Quantity" * H) "HOFFMAN CONSTRUCTION COMPAN",
           BiddersInformation."U010:: Unit Price",       
            (BidItemsInformation."Quantity" * U) "ULLAND BROTHERS INC",
           BiddersInformation."G110:: Unit Price",      
            (BidItemsInformation."Quantity" * G) "GLADEN CONSTRUCTION INC",
           BiddersInformation."H530:: Unit Price",      
            (BidItemsInformation."Quantity" * H1) "HOOVER CONSTRUCTION CO"
    FROM   BidItemsInformation,BiddersInformation
    WHERE  BidItemsInformation."Line Number" = BiddersInformation."BLine Number";
    Line Number     Section Number     Item Number     Description     Unit     Quantity     Engineers Unit Price     Engineers Estimate     K020:: Unit Price     
    0010     0001     2011601/00003     Construction Surveying     LS       1     143,000     143,000     75,000     75,000     67,080     67,080
    0013     0001     2013601/00010     Survey Equipment     LS       1     25,000     25,000     25,000     25,000     30,000     30,000
    0020     0001     2015601/00030     Blast Monitor/Survey     LS       1     50,000     50,000     30,000     30,000     35,000     35,000
    0030     0001     2021501/00010     Mobilization     LS       1     382,250     382,250     809,000     809,000     704,000     704,000
    0040     0001     2021602/00010     Well Survey     EACH     60     500     30,000     2,150     129,000     1,600     96,000
    0050     0001     2031501/00040     Field Office Type D     EACH     1     6,367     6,367     4,000     4,000     25,000     25,000
    sub total:
    1610     0002     2401501/01143     Structural Concrete (1a43)     C Y      46     350     16,100     408     18,768     400     18,400
    1620     0002     2401501/01362     Structural Concrete (1c62)     C Y      68     200     13,600     204     13,872     200     13,600
    1630     0002     2401501/03643     Structural Concrete (3y43)     C Y      60     600     36,000     592     35,520     580     34,800
    1640     0002     2401512/03633     Bridge Slab Concrete (3y33)     S F      1,876     24     45,024     28     51,778     27     50,652
    1650     0002     2401521/00030     Structure Excavation Class R     C Y      17     125     2,125     1,000     17,000     500     8,500
    1660     0002     2401541/00010     Reinforcement Bars     LB       2,490     2     3,735     1     3,312     1     3,237
    1670     0002     2401541/00011     Reinforcement Bars (Epoxy Coated)     LB       12,380     2     18,570     1     17,703     1     17,332
    1680     0002     2401601/00010     Structure Excavation     LS       1     2,500     2,500     2,000     2,000     5,000     5,000
    1690     0002     2402583/00020     Ornamental Metal Railing Type Special     L F      284     150     42,600     194     55,096     190     53,960
    sub total
    1820     0003     2401513/00346     Type Curb Railing Concrete (3y46)     L F      135     25     3,375     16     2,093     15     2,025
    1830     0003     2401513/07447     Type Mod P-4 (Tl-4) Railing Conc (3y46)     L F      302     85     25,670     72     21,593     70     21,140
    1840     0003     2401541/00010     Reinforcement Bars     LB       14,780     1     18,475     1     13,598     1     13,302
    1850     0003     2401541/00011     Reinforcement Bars (Epoxy Coated)     LB       76,720     1     103,572     1     85,926     1     84,392
    1860     0003     2401601/00010     Structure Excavation     LS       1     10,000     10,000     116,000     116,000     115,000     115,000
    1870     0003     2402583/00020     Ornamental Metal Railing Type Special     L F      132     150     19,800     184     24,288     180     23,760
    sub total
    total

    You can accomplish that using decode with the grouping function. It returns 1 when that column passed as argument was grouped (or is in some total) and 0 otherwise.
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> with t as
      2  (select 'New York' city, 'US' country, 1 num from dual
      3  union all select 'Los Angeles' city, 'US' country, 2 num from dual
      4  union all select 'London' city, 'GB' country, 2 num from dual
      5  union all select 'London' city, 'GB' country, 2 num from dual
      6  union all select 'London' city, 'GB' country, 7 num from dual)
      7  select decode(grouping(country), 0, country, 'GRAND TOTAL') country,
      8         decode(grouping(city), 0, city, decode(grouping(country), 0, 'SUBTOTAL')) city,
      9         sum(num) num_total
    10   from t
    11  group by rollup(country, city)
    12  /
    COUNTRY     CITY         NUM_TOTAL
    GB          London              11
    GB          SUBTOTAL            11
    US          New York             1
    US          Los Angeles          2
    US          SUBTOTAL             3
    GRAND TOTAL                     14
    6 linhas selecionadas.
    SQL>

  • Page break,sub total and grand total  in adobe forms

    hi,
    In adobe forms, i am displaying purchase order details in table format. internal table contains 150 records but it displaying
    only 50 records in single page. how i have to call a new page,how i have to create a page preak and i want to display only
    5 records for a page with carry forward,page total and total net value.

    Hi Sivaprasath,
    For the table content to flow onto the next pages please make sure that the outermost subform is NOT with the content property "Positioned".
    For having only 5 records per page, you can design a deep structure with fields:
    Table 1 (The table which will hold 5 records per page)
    Page total
    total net value
    Have the table type of it defined in the form.
    Put the logic for filling the table in such a way that each row of this nested table has 5 records and pagetotal and total net value.
    then put it inside a subform and check the checkbox for "rpeat subformt for each data item".
    Another way is to use Conditional breaks in Pagination tab.
    Thanks and regards,
    Priyanka

  • ALV SUB TOTAL

    HI
    AM DOING A ALV report in se 38 in which i need to display the subtotals on plant wise ,storage location wise apart from the grand total..please help me
    with regards
    vijay

    HEY BUT D VARIABLES IN D FIRST FIELS ARE NOT ADDED...I WANT D VARIABLE IN D FIELDS FIELD1 AND FIELD 3 TO B ADDED AND ALSO IN MY CASE I CANT GIVE D VALUES DEY R RETRIEVED FROM D TABLE....PLZZ GO THRU D CODE BELOW
    REPORT  ZSALES1.
    DATA:X TYPE I,Y TYPE I,a type i,b type i.
    TABLES:VBRP.
    TYPE-POOLS:SLIS.
    TYPES:BEGIN OF T_VBRP,
      VBELN TYPE VBRP-VBELN,
      FBUDA TYPE VBRP-FBUDA,
      WERKS TYPE VBRP-WERKS,
      LGORT TYPE VBRP-LGORT,
      NETWR TYPE VBRP-NETWR,
      Y TYPE I,
      END OF T_VBRP.
      DATA:IT_VBRP TYPE STANDARD TABLE OF T_VBRP INITIAL SIZE 0   WITH HEADER LINE    ,
            WA_VBRP TYPE T_VBRP.
    SELECT-OPTIONS DATE FOR VBRP-FBUDA OBLIGATORY.
    SELECT-OPTIONS:PLANT FOR VBRP-WERKS NO INTERVALS.
      data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    FORM build_fieldcatalog.
      fieldcatalog-FIELDNAME   = 'FBUDA'.
          fieldcatalog-seltext_m   = 'DATE '.
            fieldcatalog-col_pos     =  0.
              fieldcatalog-tabname = 'it_vbrp'.
                APPEND fieldcatalog TO fieldcatalog.
                  CLEAR fieldcatalog.
             fieldcatalog-FIELDNAME   = 'VBELN'.
               fieldcatalog-seltext_m   = 'BILLING DOCUMENT NUMBER '.
                 fieldcatalog-col_pos     =  1.
                   fieldcatalog-tabname = 'it_vbrp'.
                     APPEND fieldcatalog TO fieldcatalog.
                       CLEAR fieldcatalog.
                    fieldcatalog-FIELDNAME   = 'WERKS'.
                      fieldcatalog-seltext_m   = 'PLANT '.
                        fieldcatalog-col_pos     =  2.
                          fieldcatalog-tabname = 'it_vbrp'.
                            APPEND fieldcatalog TO fieldcatalog.
                              CLEAR fieldcatalog.
                          fieldcatalog-FIELDNAME   = 'LGORT'.
                             fieldcatalog-seltext_m   = 'STORAGE LOCATION '.
                                 fieldcatalog-col_pos     =  3.
                                    fieldcatalog-tabname = 'it_vbrp'.
                                        APPEND fieldcatalog TO fieldcatalog.
                                          CLEAR fieldcatalog.
                                fieldcatalog-FIELDNAME   = 'NETWR'.
                                   fieldcatalog-seltext_m   = 'NET VALUE'.
                                      fieldcatalog-col_pos     =  4.
                                      FIELDCATALOG-DO_SUM = 'Y'.
                                          fieldcatalog-tabname = 'it_vbrp'.
                                             APPEND fieldcatalog TO fieldcatalog.
                                                CLEAR fieldcatalog.
    ENDFORM.
    FORM build_layout.
      gd_layout-NO_INPUT = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      GD_LAYOUT-TOTALS_TEXT = 'TOTALS'(201).
      ENDFORM.
      form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                 is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
                i_save                  = 'X'
                tables
                t_outtab                = IT_VBRP
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
    endif.
    endform.                    " DISPLAY_ALV_REPORT
    form data_retrieval.
    select FBUDA VBELN WERKS LGORT NETWR
      from vbrp
        into CORRESPONDING FIELDS OF TABLE IT_VBRP
          WHERE FBUDA in date and
      WERKS IN PLANT.
    X = IT_VBRP-NETWR .
      ADD X TO Y.
       endform.
    PLZ EXECUTE D CODE ONCE SO U WIL,GET A CLEAR IDEA
    THANKS
    VIJAY

Maybe you are looking for

  • Portugal Payment medium format - PS2 - configuration and custom program

    Hello, this is my first post here, so first of all "hi!" and second, sorry if this thread isn't in the right forum. I need to do a custom copy of the PS2 payment medium format, which is used in Portugal. It would be a short development, I just need t

  • Some questions on 802.1x?

    Hello Everyone I have few questions regarding 802.1x authetication in wierd enviornment and with VLAN assignment by ACS. Please help me with these 1. How do I use 802.1x authentication in Windows enviornment with domain authentication? Is that the PC

  • I was told to use Mozilla Firefox to use 'mirc" whatever that is ---but my computer won't let me---can someone walk me through the process?

    Here's the deal. I want to go to multiplayertrivia.com and play this interactive online trivia game, and I can't seem to get started. I know my computer is capable of this, because I signed up and used this "mirc" thing before when using a different

  • Touch 2G problem

    Hello I had updated my IPod Touch 2G on FW 4.2.1 Now I have a problem with the IPod and my Car Radio. I know that there are Problems in iOS4 with Car Radios and that this problems where fixed with newer updates. But the 4.2.1 is the last FW for Touch

  • Duplication of Calendars

    On my phone, when I chose all calendars, it shows things twice. It shows my MobileMe and iMac computer calendars. If I choose just the iMac or MobileMe everything is ok. Is that how it's supposed to work? Seems odd...I would think it would recognize