Total sum of column for a af:table

Hi all,
I am using JDeveloper 11g with ADF BC.
I've try to create a method in VO to iterate through all the rows to calculate sum as following:
        Row curItem = first();
        while (curItem!=null) {
            Long l = DbsDelegate.attributeAsLong(curItem.getAttribute("field1"));
            if (l != null)
                result+= l.longValue();
            curItem = next();
        }        I found it is not a good practice. Since the cursor will jump to the last record after that. And most important, the next() method call will fire a NavigationEvent to registered RowSetListeners, by calling RowSetListener.navigated() as documented here: http://www.bisnis.com/doc/rt/oracle/jbo/server/ViewObjectImpl.html#next%28%29
Is there any better way to iterate through a VO and calculate some summary data?
Regards,
Samson Fu

Let the DB do the calculation. Implement a method in your VO which returns the 'select sum(col) from table'.
Timo

Similar Messages

  • Calculating Sum of columns for a row- OBIEE 11.1.1.6

    Hi,
    We are on OBIEE 11.1.1.6.
    We have  a pivot table with a measure MCount. Our Table looks something like this:
          X  Y  Z
    A  c1  c2 c3
    B  c4  c5 c6
    C c7  c8  c9
    We want to add another column "Total" which is equal to sum of  counts for each row. So our table should be like:
          X  Y  Z     Total 
    A  c1  c2 c3   (c1+c2+c3)
    B  c4  c5 c6    (c4+c5+c6)
    C c7  c8  c9    (c7+c8+c9)
    We added another column in Criteria tab with the following formula, where Dy is the dimension along the Y axis (i.e with values A B and C)
    rsum (Mcount BY Dy). We left the aggregation rule to be default (which is sum.)
    This solution calculates the sum, however for some reason is giving the value twice of the actual value. So modifying formula to rsum (Mcount BY Dy)/2 fixes our problem.
    Can anyone please suggest a better way of doing this ?
    Thanks!
    SJ

    Hi Srini,
    Thanks for your answer. I followed your suggestion and Unfortunately now the value is 4 times the actual value. I chose the aggregation rule for the measure as
    Aggregation Rule (Totals Row): Sum
    Am I missing something ?
    SJ

  • Poor Response Time- Total on a column for n number of rows

    I have a table with column cost on my custom OAF page.
    When I query for configuration it returns me many rows. so I have set the default rows for table = 10 and then I neatly have next button to go to other rows.
    I have enabled totalling on cost column.
    Row for Total appears showing sum for the costs only on that page( for only 10 rows). I click for next from drop down , and I see total for the costs for the second page.
    Ex:
    table has 17 rows and
    page 1 :
    total row at the end saying 1000.00
    page 2 :
    total = 1500.00
    I want to display Total Cost by summing up the costs for say 300 items returned by the query on all the pages , in above case 2500.00.
    I thought of a way to do it ;
    I added a sumVO with query "select sum(...) from table" .
    Added a new region in my page , added a messageStyleText based on the sumVO, and pulled the total cost in.
    It shows me the right result, but my problem is performance.
    It is getting very slow. I am using the same query as for displaying the results in table, but summing on cost column.
    Can I avoid writing the sum query and do it programmatically in OAF ??
    Thanks in advance.

    Even if you use programmatic approach, what do you think program will do?
    Program has to fetch all the rows in the middle tier and sum it up using for loop. No way its going to solve your problem.
    First find out the reason for the slow performance using Trace option. and fix the query.
    If your not able to fix it, try materialized view for the summation query.
    To take sql trace for OAF page refer this link infor http://prasanna-adf.blogspot.com/2009/01/sql-trace.html
    --Prasanna                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Total sum to be displayed in a table view control ?

    Hi,
      I am unable to display the total sum of a column in a table view control( using HTMLB ). How should one display the sum of a column ?
    THanks in advance,
    VaraPrasad

    Hi,
    it should work once you are restricting the capacity of the out put port then it should provide that much rows only otherwise its a Bug.
    Alternativily you are tellin to disaply using sorting then add a Sort operator to the output port and the display ur output port in down order.
    But first option should work just check it again.
    On which SP u r working?
    Regards,
    Govindu

  • How to sum different column in the same table

    Hi everyone
    I would like to know how can I make the sum of different column in the same table using apex
    exple:
    TR_PROJ_BIL_TRIM.ENTPIDFISC as ENTPIDFISC,
        TR_PROJ_BIL_TRIM.EXEANNEE as EXEANNEE,
        TR_PROJ_BIL_TRIM.PROJBILTRIMT1PREV as PROJBILTRIMT1PREV,
        TR_PROJ_BIL_TRIM.PROJBILTRIMT2PREV as PROJBILTRIMT2PREV,
        trunc( TR_PROJ_BIL_TRIM.PROJBILTRIMT1PREV)+(TR_PROJ_BIL_TRIM.PROJBILTRIMT2PREV)
    from TR_PROJ_BIL_TRIM TR_PROJ_BIL_TRIM
    group by TR_PROJ_BIL_TRIM.ENTPIDFISC,TR_PROJ_BIL_TRIM.EXEANNEE
    but while trying to run this script i get this error message:"ORA-00979: not a GROUP BY expression"
    thanks for reading me and I hope to hear from you soon

    Hi,
    Your question do not have anything do with APEX.
    It is pure SQL question and you will get better answer this kind questions from SQL and PL/SQL forum
    You need have GROUP BY when you use aggregate functions like SUM.
    I assume you like just add two columns.
    Try
    SELECT ENTPIDFISC
        ,EXEANNEE
        ,PROJBILTRIMT1PREV
        ,PROJBILTRIMT2PREV
        ,trunc(PROJBILTRIMT1PREV) + (PROJBILTRIMT2PREV)
    FROM TR_PROJ_BIL_TRIM
    Regards,
    Jari

  • How to create New columns for the Internal Table Dynamically?

    HI Guys,
                          In my logic i have to create new columns depending on the logic which i am executing.
    My requirement is .I have to display o/p like this
    Material || Year || Period  ||  Mix ratio || Vendor ||Mix Ratio || Vendor || Mix Ratio Vendor || Mix ratio || Vendor || Mix ratio.............................from table's CKMLMV003 and CKMLMV001.Her i have to display the o/p in the above format and i have to display Vendor and Mix Ratio for 5 columns irrespective of data .If i have more than 5 columns for any record then i have to create a New columns dynamically for Vendor and Mix ratio.If anybody want my code i can Submit But plz tell with example how to do?
                    <b>The O/P must be finally shown in ALV Grid</b>
    Thanks,
    Gopi

    You must create the entire internal table dynamically, you can not add columns to a statically define internal table.  Here is an example of creating a dynamic internal table.
    Creation of internal table dynamically based on the Date Range entered
    Regards,
    Rich Heilman

  • How do I delete a column for just one table and not all the others?

    I have multiple tabels in a Pages document. I want to delete some columns on some of the tables but keep them on the other tables. When I delete the columns it deletes all of them on all of the tabels and I dont want that.

    No. To do what you are asking for would require a separate table on each page.
    Of course you can always move blocks of cells around manually, but I can't imagine how you would manage that.
    Jerry

  • How can I do a Header Group Using Group columns for WD ALV tables

    Hi
    I want to group columns into a header group.
    Eg:
                       from Date
    Availability
                       to date
    Any ideas if it is possible with WD ALV tables?

    Hi,
    Try to use the if_salv_wd_field_settings for the column grouping of the Model object.
    Also check the class CL_SALV_WD_FIELD.
    Regards,
    Lekha.

  • How to Hide rows in ALV without affecting total sum at the end of table?

    Hi,
    I need some help in hiding particular rows in an ALV Grid without affecting the total sum at the end of the table. I am trying to hide the rows that have negative quantities, but I still need those values so that the user can still compute for the total sums. Can anyone help? Thanks.
    Joseph

    Hi,
    Hopw this way you can hide the rows in the GRID.
    DATA:
      ld_column      TYPE lvc_fname,
      ld_hide          TYPE abap_bool.
    FIELD-SYMBOLS:
      <ls_entry>     TYPE any,
      <ld_fld>         TYPE any.
      ld_column = 'COL_1'.  " column which you want to suppress if everything is zero
      ld_hide     = abap_true.  " = 'X';  default hide column
      LOOP at <gt_outtab> ASSIGNING <ls_entry>.
        ASSIGN COMPONENT (ld_column) OF STRUCTURE <ls_entry> TO <ld_fld>.
        IF ( <ld_fld>   > 0 ).
          ld_hide = abap_false.  " display column because at least single value > 0
          EXIT.  " leave LOOP
        ENDIF.
      ENDLOOP.
      READ TABLE gt_fcat INTO ls_fcat
                           WITH KEY fieldname = ld_column.
      IF ( syst-subrc = 0 ).
        ls_fcat-no_out = ld_hide.
        MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
      ENDIF.
    hop you will get the total with for those columns too.
    Regards,
    Madhavi

  • How to add columns for existing table dynamically?

    Hi,
    I created table structure only. I want to add columns for this existing  table. Columns are not fixed, according to the  user choice i  need to write code.
    Plz give me reply asap.
    Thanks
    Shirisha

    Hi Shirisha,
    I think the following code snippet will help you.
    int l_no_cols = 0;
    //Get the number of columns in this variable, something like the following
    //l_no_cols = wdContext().currentContextElement().get<Context_attribute_name>;
    IWDTable l_tab;
    IWDTransparentContainer l_tbl_cont = (IWDTransparentContainer)view.getElement("TableDataCont");//ID of Container
    l_tab = (IWDTable)view.getElement("TableData");//ID of Table
    l_tab.setVisible(WDVisibility.VISIBLE);
    l_tab.bindDataSource(wdContext.nodeTable_Data().getNodeInfo());
    for(int a = 1; a <=l_no_cols; a++)
    //Creating the column
    IWDTableColumn l_tab_col = (IWDTableColumn)view.createElement(IWDTableColumn.class,"COL"+a);
    //Creating Caption for Column Header
    IWDCaption l_tab_cap = (IWDCaption)view.createElement(IWDCaption.class,"Caption"+a);
    l_tab_cap.setText("Col"+i);               
    l_tab_col.setHeader(l_tab_cap);
    //Creating Table Cell Editor for column
    IWDInputField l_tab_cell = (IWDInputField)view.createElement(IWDInputField.class,"CellEditor"+a);
    //creating context node attribute for the column dynamically
    wdContext.nodeTable_Data().getNodeInfo().addAttribute("Col"+i,"com.sap.dictionary.String");
    l_tab_cell.bindValue(wdContext.nodeTable_Data().getNodeInfo().getAttribute("Col"+i));
    l_tab_col.setTableCellEditor(l_tab_cell);
    l_tab.addColumn(l_tab_col);
    l_tbl_cont.addChild(l_tab);
    Regards,
    Alka

  • What is the maximum number of columns allowed on a table?

    What is the maximum number of columns that a table can have? I have a research team that wants to have 140,000 columns on one table and 2000 rows.
    What would be the best way to input (SQL*Loader?) that data on this table and retrieve data from this table? The highest number of columns that I have implemented on a table was 500.
    Any feedback would be greatly appreciated.
    Thanks. ;-)

    Holy cow 140,000 columns and 2000 rows!! I think you are going to have to tell someone to come up with a better design because that doesn't sound like a relational table. Besides, I found this in the Oracle 8.1.7 Reference Manual:
    "The absolute maximum number of columns in a table is 1000. However, when you create an object table (or a relational table with columns of object, nested table, varray, or REF type), Oracle maps the columns of the user-defined types to relational columns, creating in effect "hidden columns" that count toward the 1000-column limit. For details on how Oracle calculates the total number of columns in such a table, please refer to Oracle8i Administrator's Guide."

  • Unable to find mapping Interface columns for Service Items in Sales Order

    Hi All,
    I have a requirement to create a service item for a Sales Order through Interface tables. Once the oe_headers_iface_all and oe_lines_iface_all tables are populated, order import program is run to populate the data into the base tables.
    I am unable to figure out the interface mapping columns for the base table columns namely,
    (oe_order_lines_all table)
    service_ref_order_type
    service_ref_order_numbe
    service_ref_line_number
    service_ref_shipment_number
    Also, the above mentioned base table columns are mandatory and not able to create a Service item through Order import.
    When checked in the front end, per record history these columns are taken from oe_order_lines_v, however when checked in the query of this view am unable to trace the above four columns.
    Any help will be greatly appreciated.
    Thanks,
    Jay

    This does not appear to be connected with the subject of this forum, which is [Oracle Application Express|http://apex.oracle.com/i/index.html].
    Taking a wild guess, this might have something to do with [eBusiness Suite|http://forums.oracle.com/forums/category.jspa?categoryID=3]?

  • Different units in total sum row

    Hello Bex Experts,
    I have orders with different Units in a report. currently the total sum row show * for Mix
    How can I get the total sum for ST and KG like
    Total Sum 366 KG
    Total Sum 342 ST
    BR Matthias

    Hi Matthias,
    If you want to sum their numbers regardless of the UNITS, just use the NODIM() in formula..But if you need to add them and have 1 unit for the result, you must convert one of the them to another unit..
    Regards,
    Loed

  • Smartform total sum

    Hi All,
    I am a newer of smartform. Now I face a problem, I want to do total sum at the bottom of main table without showed at each page. But I tried many method and it is not ok.
    Plz help me.

    Hi,
    In the node where u r printing the value , u will be printing each value in the textelement.  so Before that text elelment u create a program line.
    u take a variable and assign the variable as zero .
    in the program lines u put the code as
    variable = variable + (text-value).
    ex:-itab-menge.( uwant to make sum of menge).
    var type menge.  = 0.(This u do in global def.).
    in the program lines.
    var = var + itab-menge.
    after the loop.
    var will be sum of the all .
    Assign points if useful.

  • Get Total of a Column of Advanced Table and use it in Controller in OAF

    I have an advanced table on my custom page. I am calculating total of a column in my footer. I am acheiving this using the standard functionality of advanced table by setting total value property of my column to "TRUE" and displaying the total in the tablefooter components.
    In addition to this I want to retreive the total value from my footer and use it in my Controller for further validations but I am not able to acheive this.
    I tried some code already present in the Community for the same but nothing turned out right for me.
    Can anyone please help me on this.

       Hi there ,
      You can manually add the values of each row of a  column and make use of the value obtained in your controller .
    Here is the logic ,
    1) get the vo instnace attached to that table .
    2) Loop through every single row in the table .
    3) get the value and sum up the value and use it in your controller .
    int fetchRowCount = vo.getFetchRowCount();  
    voRowImpl row = null;  
    int count =0;
    if (fetchRowCount  > 0) { 
    RowSetIterator iter = vo.createRowSetIterator("Iter"); 
    iter.setRangeStart(0);
      iter.setRangeSize(fetchBidderRowCount);
       for (int i = 0; i < fetchBidderRowCount; i++) {
      row = voRowImpl iter.getRowAtRangeIndex(i);
       //use RowImpl getters   10.   
             Number personId = row.getPersonId();
    count =personId+count;         // add each and every value and have in variable
    iter.closeRowSetIterator();
    Regards ,
    Keerthi

Maybe you are looking for